referrerpolicy=no-referrer-when-downgrade

pallet_contracts_uapi/
flags.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18use bitflags::bitflags;
19
20bitflags! {
21	/// Flags used by a contract to customize exit behaviour.
22	#[cfg_attr(feature = "scale", derive(codec::Encode, codec::Decode, scale_info::TypeInfo))]
23	pub struct ReturnFlags: u32 {
24		/// If this bit is set all changes made by the contract execution are rolled back.
25		const REVERT = 0x0000_0001;
26	}
27}
28
29bitflags! {
30	/// Flags used to change the behaviour of `seal_call` and `seal_delegate_call`.
31	pub struct CallFlags: u32 {
32		/// Forward the input of current function to the callee.
33		///
34		/// Supplied input pointers are ignored when set.
35		///
36		/// # Note
37		///
38		/// A forwarding call will consume the current contracts input. Any attempt to
39		/// access the input after this call returns will lead to [`Error::InputForwarded`].
40		/// It does not matter if this is due to calling `seal_input` or trying another
41		/// forwarding call. Consider using [`Self::CLONE_INPUT`] in order to preserve
42		/// the input.
43		const FORWARD_INPUT = 0b0000_0001;
44		/// Identical to [`Self::FORWARD_INPUT`] but without consuming the input.
45		///
46		/// This adds some additional weight costs to the call.
47		///
48		/// # Note
49		///
50		/// This implies [`Self::FORWARD_INPUT`] and takes precedence when both are set.
51		const CLONE_INPUT = 0b0000_0010;
52		/// Do not return from the call but rather return the result of the callee to the
53		/// callers caller.
54		///
55		/// # Note
56		///
57		/// This makes the current contract completely transparent to its caller by replacing
58		/// this contracts potential output by the callee ones. Any code after `seal_call`
59		/// can be safely considered unreachable.
60		const TAIL_CALL = 0b0000_0100;
61		/// Allow the callee to reenter into the current contract.
62		///
63		/// Without this flag any reentrancy into the current contract that originates from
64		/// the callee (or any of its callees) is denied. This includes the first callee:
65		/// You cannot call into yourself with this flag set.
66		///
67		/// # Note
68		///
69		/// For `seal_delegate_call` should be always unset, otherwise
70		/// [`Error::InvalidCallFlags`] is returned.
71		const ALLOW_REENTRY = 0b0000_1000;
72		/// Indicates that the callee is restricted from modifying the state during call execution,
73		/// equivalent to Ethereum's STATICCALL.
74		///
75		/// # Note
76		///
77		/// For `seal_delegate_call` should be always unset, otherwise
78		/// [`Error::InvalidCallFlags`] is returned.
79		const READ_ONLY = 0b0001_0000;
80	}
81}