diff --git a/substrate/frame/contracts/primitives/src/lib.rs b/substrate/frame/contracts/primitives/src/lib.rs index ddd97d99b2f59d5d1ad22cac29ecdb5d25c110b8..c33149285004b38ad4beee7aac330c9d7421324b 100644 --- a/substrate/frame/contracts/primitives/src/lib.rs +++ b/substrate/frame/contracts/primitives/src/lib.rs @@ -20,7 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use bitflags::bitflags; -use codec::{Decode, Encode}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::{ traits::{Saturating, Zero}, @@ -39,7 +39,7 @@ use sp_weights::Weight; /// It has been extended to include `events` at the end of the struct while not bumping the /// `ContractsApi` version. Therefore when SCALE decoding a `ContractResult` its trailing data /// should be ignored to avoid any potential compatibility issues. -#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct ContractResult<R, Balance, EventRecord> { /// How much weight was consumed during execution. pub gas_consumed: Weight, @@ -99,7 +99,7 @@ pub type CodeUploadResult<CodeHash, Balance> = pub type GetStorageResult = Result<Option<Vec<u8>>, ContractAccessError>; /// The possible errors that can happen querying the storage of a contract. -#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, MaxEncodedLen, RuntimeDebug, TypeInfo)] pub enum ContractAccessError { /// The given address doesn't point to a contract. DoesntExist, @@ -119,7 +119,7 @@ bitflags! { } /// Output of a contract call or instantiation which ran to completion. -#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] +#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct ExecReturnValue { /// Flags passed along by `seal_return`. Empty when `seal_return` was never called. pub flags: ReturnFlags, @@ -135,7 +135,7 @@ impl ExecReturnValue { } /// The result of a successful contract instantiation. -#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] +#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct InstantiateReturnValue<AccountId> { /// The output of the called constructor. pub result: ExecReturnValue, @@ -144,7 +144,7 @@ pub struct InstantiateReturnValue<AccountId> { } /// The result of successfully uploading a contract. -#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)] +#[derive(Clone, PartialEq, Eq, Encode, Decode, MaxEncodedLen, RuntimeDebug, TypeInfo)] pub struct CodeUploadReturnValue<CodeHash, Balance> { /// The key under which the new code is stored. pub code_hash: CodeHash, @@ -153,7 +153,7 @@ pub struct CodeUploadReturnValue<CodeHash, Balance> { } /// Reference to an existing code hash or a new wasm module. -#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] pub enum Code<Hash> { /// A wasm module as raw bytes. Upload(Vec<u8>), @@ -162,7 +162,9 @@ pub enum Code<Hash> { } /// The amount of balance that was either charged or refunded in order to pay for storage. -#[derive(Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, Clone, TypeInfo)] +#[derive( + Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, RuntimeDebug, TypeInfo, +)] pub enum StorageDeposit<Balance> { /// The transaction reduced storage consumption. /// diff --git a/substrate/frame/contracts/src/exec.rs b/substrate/frame/contracts/src/exec.rs index c540e932cc24ba85ae1d92f17cdbe6c0810b5c27..9e5fd780ac6ca72a23d263ca3f9d85686b26882c 100644 --- a/substrate/frame/contracts/src/exec.rs +++ b/substrate/frame/contracts/src/exec.rs @@ -346,7 +346,17 @@ pub trait Ext: sealing::Sealed { } /// Describes the different functions that can be exported by an [`Executable`]. -#[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[derive( + Copy, + Clone, + PartialEq, + Eq, + sp_core::RuntimeDebug, + codec::Decode, + codec::Encode, + codec::MaxEncodedLen, + scale_info::TypeInfo, +)] pub enum ExportedFunction { /// The constructor function which is executed on deployment of a contract. Constructor, diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index 0186e190fb78550c8dd969b6713d346ea8f5bc45..37b79c2d585adcc68bde50d88c4bab9a387e8362 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -108,7 +108,7 @@ use crate::{ storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueueManager}, wasm::{CodeInfo, WasmBlob}, }; -use codec::{Codec, Decode, Encode, HasCompact}; +use codec::{Codec, Decode, Encode, HasCompact, MaxEncodedLen}; use environmental::*; use frame_support::{ dispatch::{ @@ -122,7 +122,7 @@ use frame_support::{ ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, - BoundedVec, RuntimeDebugNoBound, + BoundedVec, RuntimeDebug, RuntimeDebugNoBound, }; use frame_system::{ensure_signed, pallet_prelude::OriginFor, EventRecord, Pallet as System}; use pallet_contracts_primitives::{ @@ -1119,7 +1119,9 @@ struct InstantiateInput<T: Config> { } /// Determines whether events should be collected during execution. -#[derive(PartialEq)] +#[derive( + Copy, Clone, PartialEq, Eq, RuntimeDebug, Decode, Encode, MaxEncodedLen, scale_info::TypeInfo, +)] pub enum CollectEvents { /// Collect events. /// @@ -1135,7 +1137,9 @@ pub enum CollectEvents { } /// Determines whether debug messages will be collected. -#[derive(PartialEq)] +#[derive( + Copy, Clone, PartialEq, Eq, RuntimeDebug, Decode, Encode, MaxEncodedLen, scale_info::TypeInfo, +)] pub enum DebugInfo { /// Collect debug messages. /// # Note