// 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; } }