mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Contracts: use compiled rust tests (#2347)
see #2189 This PR does the following: - Bring the user api functions into a new pallet-contracts-uapi (They are currently defined in ink! [here])(https://github.com/paritytech/ink/blob/master/crates/env/src/engine/on_chain/ext.rs) - Add older api versions and unstable to the user api trait. - Remove pallet-contracts-primitives and bring the types it defined in uapi / pallet-contracts - Add the infrastructure to build fixtures from Rust files and test it works by replacing `dummy.wat` and `call.wat` - Move all the doc from wasm/runtime.rs to pallet-contracts-uapi. This will be done in a follow up: - convert the rest of the test from .wat to rust - bring risc-v uapi up to date with wasm - finalize the uapi host fns, making sure everything is codegen from the source host fns in pallet-contracts --------- Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use bitflags::bitflags;
|
||||
|
||||
bitflags! {
|
||||
/// Flags used by a contract to customize exit behaviour.
|
||||
#[cfg_attr(feature = "scale", derive(scale::Encode, scale::Decode, scale_info::TypeInfo))]
|
||||
pub struct ReturnFlags: u32 {
|
||||
/// If this bit is set all changes made by the contract execution are rolled back.
|
||||
const REVERT = 0x0000_0001;
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
/// Flags used to change the behaviour of `seal_call` and `seal_delegate_call`.
|
||||
pub struct CallFlags: u32 {
|
||||
/// Forward the input of current function to the callee.
|
||||
///
|
||||
/// Supplied input pointers are ignored when set.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// A forwarding call will consume the current contracts input. Any attempt to
|
||||
/// access the input after this call returns will lead to [`Error::InputForwarded`].
|
||||
/// It does not matter if this is due to calling `seal_input` or trying another
|
||||
/// forwarding call. Consider using [`Self::CLONE_INPUT`] in order to preserve
|
||||
/// the input.
|
||||
const FORWARD_INPUT = 0b0000_0001;
|
||||
/// Identical to [`Self::FORWARD_INPUT`] but without consuming the input.
|
||||
///
|
||||
/// This adds some additional weight costs to the call.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This implies [`Self::FORWARD_INPUT`] and takes precedence when both are set.
|
||||
const CLONE_INPUT = 0b0000_0010;
|
||||
/// Do not return from the call but rather return the result of the callee to the
|
||||
/// callers caller.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This makes the current contract completely transparent to its caller by replacing
|
||||
/// this contracts potential output by the callee ones. Any code after `seal_call`
|
||||
/// can be safely considered unreachable.
|
||||
const TAIL_CALL = 0b0000_0100;
|
||||
/// Allow the callee to reenter into the current contract.
|
||||
///
|
||||
/// Without this flag any reentrancy into the current contract that originates from
|
||||
/// the callee (or any of its callees) is denied. This includes the first callee:
|
||||
/// You cannot call into yourself with this flag set.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// For `seal_delegate_call` should be always unset, otherwise
|
||||
/// [`Error::InvalidCallFlags`] is returned.
|
||||
const ALLOW_REENTRY = 0b0000_1000;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user