git.delta.rocks / unique-network / refs/commits / 251ea62d352e

difftreelog

fix unbroke ink contract build substrate v0.9.8

Yaroslav Bolyukin2021-08-06parent: #d49b9b4.patch.diff
in: master

7 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4935,12 +4935,15 @@
 name = "nft-data-structs"
 version = "0.9.0"
 dependencies = [
+ "derivative",
  "frame-support",
  "frame-system",
+ "max-encoded-len",
  "parity-scale-codec",
  "serde",
  "sp-core",
  "sp-runtime",
+ "sp-std",
 ]
 
 [[package]]
@@ -4999,6 +5002,7 @@
  "cumulus-primitives-core",
  "cumulus-primitives-timestamp",
  "cumulus-primitives-utility",
+ "derivative",
  "fp-rpc",
  "frame-benchmarking",
  "frame-executive",
@@ -5007,6 +5011,7 @@
  "frame-system-benchmarking",
  "frame-system-rpc-runtime-api",
  "hex-literal",
+ "max-encoded-len",
  "nft-data-structs",
  "pallet-aura",
  "pallet-balances",
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -1675,8 +1675,8 @@
 			CreateItemData::NFT(data) => {
 				let item = NftItemType {
 					owner: owner.clone(),
-					const_data: data.const_data,
-					variable_data: data.variable_data,
+					const_data: data.const_data.into_inner(),
+					variable_data: data.variable_data.into_inner(),
 				};
 
 				Self::add_nft_item(collection, item)?;
@@ -1692,8 +1692,8 @@
 
 				let item = ReFungibleItemType {
 					owner: owner_list,
-					const_data: data.const_data,
-					variable_data: data.variable_data,
+					const_data: data.const_data.into_inner(),
+					variable_data: data.variable_data.into_inner(),
 				};
 
 				Self::add_refungible_item(collection, item)?;
modifiedprimitives/nft/Cargo.tomldiffbeforeafterboth
--- a/primitives/nft/Cargo.toml
+++ b/primitives/nft/Cargo.toml
@@ -9,20 +9,25 @@
 version = '0.9.0'
 
 [dependencies]
-codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ['derive'] }
+codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ['derive'] }
 serde = { version = "1.0.119", features = ['derive'], default-features = false }
+max-encoded-len = { default-features = false, features = ['derive'], version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }
 frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }
 frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }
 sp-core = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }
+sp-std = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }
 sp-runtime = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }
+derivative = "2.2.0"
 
 [features]
 default = ["std"]
 std = [
   "serde/std",
   "codec/std",
+  "max-encoded-len/std",
   "frame-system/std",
   "frame-support/std",
   "sp-runtime/std",
   "sp-core/std",
+  "sp-std/std",
 ]
\ No newline at end of file
modifiedprimitives/nft/src/lib.rsdiffbeforeafterboth
before · primitives/nft/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23pub use serde::{Serialize, Deserialize};45use sp_runtime::sp_std::prelude::Vec;6use codec::{Decode, Encode};7pub use frame_support::{8	construct_runtime, decl_event, decl_module, decl_storage, decl_error,9	dispatch::DispatchResult,10	ensure, fail, parameter_types,11	traits::{12		Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,13		Randomness, IsSubType, WithdrawReasons,14	},15	weights::{16		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},17		DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,18		WeightToFeePolynomial, DispatchClass,19	},20	StorageValue, transactional,21};2223pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;24pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;25pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;26pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;2728pub type CollectionId = u32;29pub type TokenId = u32;30pub type DecimalPoints = u8;3132#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]33#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]34pub enum CollectionMode {35	Invalid,36	NFT,37	// decimal points38	Fungible(DecimalPoints),39	ReFungible,40}4142impl Default for CollectionMode {43	fn default() -> Self {44		Self::Invalid45	}46}4748impl CollectionMode {49	pub fn id(&self) -> u8 {50		match self {51			CollectionMode::Invalid => 0,52			CollectionMode::NFT => 1,53			CollectionMode::Fungible(_) => 2,54			CollectionMode::ReFungible => 3,55		}56	}57}5859pub trait SponsoringResolve<AccountId, Call> {60	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;61}6263#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]64#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]65pub enum AccessMode {66	Normal,67	WhiteList,68}69impl Default for AccessMode {70	fn default() -> Self {71		Self::Normal72	}73}7475#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]76#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]77pub enum SchemaVersion {78	ImageURL,79	Unique,80}81impl Default for SchemaVersion {82	fn default() -> Self {83		Self::ImageURL84	}85}8687#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]88#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]89pub struct Ownership<AccountId> {90	pub owner: AccountId,91	pub fraction: u128,92}9394#[derive(Encode, Decode, Debug, Clone, PartialEq)]95#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]96pub enum SponsorshipState<AccountId> {97	/// The fees are applied to the transaction sender98	Disabled,99	Unconfirmed(AccountId),100	/// Transactions are sponsored by specified account101	Confirmed(AccountId),102}103104impl<AccountId> SponsorshipState<AccountId> {105	pub fn sponsor(&self) -> Option<&AccountId> {106		match self {107			Self::Confirmed(sponsor) => Some(sponsor),108			_ => None,109		}110	}111112	pub fn pending_sponsor(&self) -> Option<&AccountId> {113		match self {114			Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),115			_ => None,116		}117	}118119	pub fn confirmed(&self) -> bool {120		matches!(self, Self::Confirmed(_))121	}122}123124impl<T> Default for SponsorshipState<T> {125	fn default() -> Self {126		Self::Disabled127	}128}129130#[derive(Encode, Decode, Clone, PartialEq)]131#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]132pub struct Collection<T: frame_system::Config> {133	pub owner: T::AccountId,134	pub mode: CollectionMode,135	pub access: AccessMode,136	pub decimal_points: DecimalPoints,137	pub name: Vec<u16>,        // 64 include null escape char138	pub description: Vec<u16>, // 256 include null escape char139	pub token_prefix: Vec<u8>, // 16 include null escape char140	pub mint_mode: bool,141	pub offchain_schema: Vec<u8>,142	pub schema_version: SchemaVersion,143	pub sponsorship: SponsorshipState<T::AccountId>,144	pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions145	pub variable_on_chain_schema: Vec<u8>,        //146	pub const_on_chain_schema: Vec<u8>,           //147	pub transfers_enabled: bool,148}149150#[derive(Encode, Decode, Debug, Clone, PartialEq)]151#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]152pub struct NftItemType<AccountId> {153	pub owner: AccountId,154	pub const_data: Vec<u8>,155	pub variable_data: Vec<u8>,156}157158#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]159#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]160pub struct FungibleItemType {161	pub value: u128,162}163164#[derive(Encode, Decode, Debug, Clone, PartialEq)]165#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]166pub struct ReFungibleItemType<AccountId> {167	pub owner: Vec<Ownership<AccountId>>,168	pub const_data: Vec<u8>,169	pub variable_data: Vec<u8>,170}171172#[derive(Encode, Decode, Debug, Clone, PartialEq)]173#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]174pub struct CollectionLimits<BlockNumber: Encode + Decode> {175	pub account_token_ownership_limit: u32,176	pub sponsored_data_size: u32,177	/// None - setVariableMetadata is not sponsored178	/// Some(v) - setVariableMetadata is sponsored179	///           if there is v block between txs180	pub sponsored_data_rate_limit: Option<BlockNumber>,181	pub token_limit: u32,182183	// Timeouts for item types in passed blocks184	pub sponsor_transfer_timeout: u32,185	pub owner_can_transfer: bool,186	pub owner_can_destroy: bool,187}188189impl<BlockNumber: Encode + Decode> Default for CollectionLimits<BlockNumber> {190	fn default() -> Self {191		Self {192			account_token_ownership_limit: 10_000_000,193			token_limit: u32::max_value(),194			sponsored_data_size: u32::MAX,195			sponsored_data_rate_limit: None,196			sponsor_transfer_timeout: 14400,197			owner_can_transfer: true,198			owner_can_destroy: true,199		}200	}201}202203#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]204#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]205pub struct ChainLimits {206	pub collection_numbers_limit: u32,207	pub account_token_ownership_limit: u32,208	pub collections_admins_limit: u64,209	pub custom_data_limit: u32,210211	// Timeouts for item types in passed blocks212	pub nft_sponsor_transfer_timeout: u32,213	pub fungible_sponsor_transfer_timeout: u32,214	pub refungible_sponsor_transfer_timeout: u32,215216	// Schema limits217	pub offchain_schema_limit: u32,218	pub variable_on_chain_schema_limit: u32,219	pub const_on_chain_schema_limit: u32,220}221222#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]223#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]224pub struct CreateNftData {225	pub const_data: Vec<u8>,226	pub variable_data: Vec<u8>,227}228229#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]230#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]231pub struct CreateFungibleData {232	pub value: u128,233}234235#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]236#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]237pub struct CreateReFungibleData {238	pub const_data: Vec<u8>,239	pub variable_data: Vec<u8>,240	pub pieces: u128,241}242243#[derive(Encode, Decode, Debug, Clone, PartialEq)]244#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]245pub enum CreateItemData {246	NFT(CreateNftData),247	Fungible(CreateFungibleData),248	ReFungible(CreateReFungibleData),249}250251impl CreateItemData {252	pub fn data_size(&self) -> usize {253		match self {254			CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),255			CreateItemData::ReFungible(data) => data.variable_data.len() + data.const_data.len(),256			_ => 0,257		}258	}259}260261impl From<CreateNftData> for CreateItemData {262	fn from(item: CreateNftData) -> Self {263		CreateItemData::NFT(item)264	}265}266267impl From<CreateReFungibleData> for CreateItemData {268	fn from(item: CreateReFungibleData) -> Self {269		CreateItemData::ReFungible(item)270	}271}272273impl From<CreateFungibleData> for CreateItemData {274	fn from(item: CreateFungibleData) -> Self {275		CreateItemData::Fungible(item)276	}277}
after · primitives/nft/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23pub use serde::{Serialize, Deserialize};45use sp_runtime::sp_std::prelude::Vec;6use codec::{Decode, Encode};7use max_encoded_len::MaxEncodedLen;8pub use frame_support::{9	BoundedVec, construct_runtime, decl_event, decl_module, decl_storage, decl_error,10	dispatch::DispatchResult,11	ensure, fail, parameter_types,12	traits::{13		Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,14		Randomness, IsSubType, WithdrawReasons,15	},16	weights::{17		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},18		DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,19		WeightToFeePolynomial, DispatchClass,20	},21	StorageValue, transactional,22};23use derivative::Derivative;2425pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;26pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;27pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;28pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;2930// TODO: Somehow use ChainLimits for BoundedVec len calculation?31// Do we need ChainLimits anyway, if we can change them via forkless upgrades?32parameter_types! {33pub const MaxDataSize: u32 = 2048;34// TODO: This limit isn't checked for substrate create_multiple_items call35pub const MaxItemsPerBatch: u32 = 200;36}3738pub type CollectionId = u32;39pub type TokenId = u32;40pub type DecimalPoints = u8;4142#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]43pub enum CollectionMode {44	Invalid,45	NFT,46	// decimal points47	Fungible(DecimalPoints),48	ReFungible,49}5051impl Default for CollectionMode {52	fn default() -> Self {53		Self::Invalid54	}55}5657impl CollectionMode {58	pub fn id(&self) -> u8 {59		match self {60			CollectionMode::Invalid => 0,61			CollectionMode::NFT => 1,62			CollectionMode::Fungible(_) => 2,63			CollectionMode::ReFungible => 3,64		}65	}66}6768pub trait SponsoringResolve<AccountId, Call> {69	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;70}7172#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]73pub enum AccessMode {74	Normal,75	WhiteList,76}77impl Default for AccessMode {78	fn default() -> Self {79		Self::Normal80	}81}8283#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]84pub enum SchemaVersion {85	ImageURL,86	Unique,87}88impl Default for SchemaVersion {89	fn default() -> Self {90		Self::ImageURL91	}92}9394#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]95pub struct Ownership<AccountId> {96	pub owner: AccountId,97	pub fraction: u128,98}99100#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]101pub enum SponsorshipState<AccountId> {102	/// The fees are applied to the transaction sender103	Disabled,104	Unconfirmed(AccountId),105	/// Transactions are sponsored by specified account106	Confirmed(AccountId),107}108109impl<AccountId> SponsorshipState<AccountId> {110	pub fn sponsor(&self) -> Option<&AccountId> {111		match self {112			Self::Confirmed(sponsor) => Some(sponsor),113			_ => None,114		}115	}116117	pub fn pending_sponsor(&self) -> Option<&AccountId> {118		match self {119			Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),120			_ => None,121		}122	}123124	pub fn confirmed(&self) -> bool {125		matches!(self, Self::Confirmed(_))126	}127}128129impl<T> Default for SponsorshipState<T> {130	fn default() -> Self {131		Self::Disabled132	}133}134135#[derive(Encode, Decode, Clone, PartialEq)]136#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]137pub struct Collection<T: frame_system::Config> {138	pub owner: T::AccountId,139	pub mode: CollectionMode,140	pub access: AccessMode,141	pub decimal_points: DecimalPoints,142	pub name: Vec<u16>,        // 64 include null escape char143	pub description: Vec<u16>, // 256 include null escape char144	pub token_prefix: Vec<u8>, // 16 include null escape char145	pub mint_mode: bool,146	pub offchain_schema: Vec<u8>,147	pub schema_version: SchemaVersion,148	pub sponsorship: SponsorshipState<T::AccountId>,149	pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions150	pub variable_on_chain_schema: Vec<u8>,        //151	pub const_on_chain_schema: Vec<u8>,           //152	pub transfers_enabled: bool,153}154155#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]156pub struct NftItemType<AccountId> {157	pub owner: AccountId,158	pub const_data: Vec<u8>,159	pub variable_data: Vec<u8>,160}161162#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]163pub struct FungibleItemType {164	pub value: u128,165}166167#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]168pub struct ReFungibleItemType<AccountId> {169	pub owner: Vec<Ownership<AccountId>>,170	pub const_data: Vec<u8>,171	pub variable_data: Vec<u8>,172}173174#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]175pub struct CollectionLimits<BlockNumber: Encode + Decode> {176	pub account_token_ownership_limit: u32,177	pub sponsored_data_size: u32,178	/// None - setVariableMetadata is not sponsored179	/// Some(v) - setVariableMetadata is sponsored180	///           if there is v block between txs181	pub sponsored_data_rate_limit: Option<BlockNumber>,182	pub token_limit: u32,183184	// Timeouts for item types in passed blocks185	pub sponsor_transfer_timeout: u32,186	pub owner_can_transfer: bool,187	pub owner_can_destroy: bool,188}189190impl<BlockNumber: Encode + Decode> Default for CollectionLimits<BlockNumber> {191	fn default() -> Self {192		Self {193			account_token_ownership_limit: 10_000_000,194			token_limit: u32::max_value(),195			sponsored_data_size: u32::MAX,196			sponsored_data_rate_limit: None,197			sponsor_transfer_timeout: 14400,198			owner_can_transfer: true,199			owner_can_destroy: true,200		}201	}202}203204#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]205pub struct ChainLimits {206	pub collection_numbers_limit: u32,207	pub account_token_ownership_limit: u32,208	pub collections_admins_limit: u64,209	pub custom_data_limit: u32,210211	// Timeouts for item types in passed blocks212	pub nft_sponsor_transfer_timeout: u32,213	pub fungible_sponsor_transfer_timeout: u32,214	pub refungible_sponsor_transfer_timeout: u32,215216	// Schema limits217	pub offchain_schema_limit: u32,218	pub variable_on_chain_schema_limit: u32,219	pub const_on_chain_schema_limit: u32,220}221222/// BoundedVec doesn't supports serde223mod bounded_serde {224	use core::convert::TryFrom;225	use frame_support::{BoundedVec, traits::Get};226	use serde::{227		ser::{self, Serialize},228		de::{self, Deserialize, Error},229	};230	use sp_std::vec::Vec;231232	pub fn serialize<D, V, S>(value: &BoundedVec<V, S>, serializer: D) -> Result<D::Ok, D::Error>233	where234		D: ser::Serializer,235		V: Serialize,236	{237		let vec: &Vec<_> = &value;238		vec.serialize(serializer)239	}240241	pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>242	where243		D: de::Deserializer<'de>,244		V: de::Deserialize<'de>,245		S: Get<u32>,246	{247		// TODO: Implement custom visitor, which will limit vec size at parse time? Will serde only be used by chainspec?248		let vec = <Vec<V>>::deserialize(deserializer)?;249		let len = vec.len();250		TryFrom::try_from(vec).map_err(|_| D::Error::invalid_length(len, &"lesser size"))251	}252}253254#[derive(255	Encode, Decode, MaxEncodedLen, Default, Derivative, Clone, PartialEq, Serialize, Deserialize,256)]257#[derivative(Debug)]258pub struct CreateNftData {259	#[serde(with = "bounded_serde")]260	#[derivative(Debug="ignore")]261	pub const_data: BoundedVec<u8, MaxDataSize>,262	#[serde(with = "bounded_serde")]263	#[derivative(Debug="ignore")]264	pub variable_data: BoundedVec<u8, MaxDataSize>,265}266267#[derive(268	Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, Serialize, Deserialize,269)]270pub struct CreateFungibleData {271	pub value: u128,272}273274#[derive(275	Encode, Decode, MaxEncodedLen, Default, Derivative, Clone, PartialEq, Serialize, Deserialize,276)]277#[derivative(Debug)]278pub struct CreateReFungibleData {279	#[serde(with = "bounded_serde")]280	#[derivative(Debug="ignore")]281	pub const_data: BoundedVec<u8, MaxDataSize>,282	#[serde(with = "bounded_serde")]283	#[derivative(Debug="ignore")]284	pub variable_data: BoundedVec<u8, MaxDataSize>,285	pub pieces: u128,286}287288#[derive(Encode, Decode, MaxEncodedLen, Debug, Clone, PartialEq, Serialize, Deserialize)]289pub enum CreateItemData {290	NFT(CreateNftData),291	Fungible(CreateFungibleData),292	ReFungible(CreateReFungibleData),293}294295impl CreateItemData {296	pub fn data_size(&self) -> usize {297		match self {298			CreateItemData::NFT(data) => data.variable_data.len() + data.const_data.len(),299			CreateItemData::ReFungible(data) => data.variable_data.len() + data.const_data.len(),300			_ => 0,301		}302	}303}304305impl From<CreateNftData> for CreateItemData {306	fn from(item: CreateNftData) -> Self {307		CreateItemData::NFT(item)308	}309}310311impl From<CreateReFungibleData> for CreateItemData {312	fn from(item: CreateReFungibleData) -> Self {313		CreateItemData::ReFungible(item)314	}315}316317impl From<CreateFungibleData> for CreateItemData {318	fn from(item: CreateFungibleData) -> Self {319		CreateItemData::Fungible(item)320	}321}
modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -31,6 +31,7 @@
 ]
 std = [
     'codec/std',
+    'max-encoded-len/std',
     'cumulus-pallet-aura-ext/std',
     'cumulus-pallet-parachain-system/std',
     'cumulus-pallet-xcm/std',
@@ -378,6 +379,8 @@
 # local dependencies
 
 [dependencies]
+max-encoded-len = { default-features = false, features = ['derive'], version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }
+derivative = "2.2.0"
 pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
 pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
 nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }
modifiedruntime/src/chain_extension.rsdiffbeforeafterboth
--- a/runtime/src/chain_extension.rs
+++ b/runtime/src/chain_extension.rs
@@ -6,6 +6,8 @@
 //
 
 use codec::{Decode, Encode};
+use max_encoded_len::MaxEncodedLen;
+use derivative::Derivative;
 
 pub use pallet_contracts::chain_extension::RetVal;
 use pallet_contracts::chain_extension::{
@@ -19,61 +21,63 @@
 pub use pallet_nft::*;
 use pallet_nft::CrossAccountId;
 use nft_data_structs::*;
-
-use crate::Vec;
 
 /// Create item parameters
-#[derive(Debug, PartialEq, Encode, Decode)]
-pub struct NFTExtCreateItem<E: Ext> {
-	pub owner: <E::T as SysConfig>::AccountId,
+#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]
+pub struct NFTExtCreateItem<AccountId> {
+	pub owner: AccountId,
 	pub collection_id: u32,
 	pub data: CreateItemData,
 }
 
 /// Transfer parameters
-#[derive(Debug, PartialEq, Encode, Decode)]
-pub struct NFTExtTransfer<E: Ext> {
-	pub recipient: <E::T as SysConfig>::AccountId,
+#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]
+pub struct NFTExtTransfer<AccountId> {
+	pub recipient: AccountId,
 	pub collection_id: u32,
 	pub token_id: u32,
 	pub amount: u128,
 }
 
-#[derive(Debug, PartialEq, Encode, Decode)]
-pub struct NFTExtCreateMultipleItems<E: Ext> {
-	pub owner: <E::T as SysConfig>::AccountId,
+#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]
+#[derivative(Debug)]
+pub struct NFTExtCreateMultipleItems<AccountId> {
+	pub owner: AccountId,
 	pub collection_id: u32,
-	pub data: Vec<CreateItemData>,
+	#[derivative(Debug = "ignore")]
+	pub data: BoundedVec<CreateItemData, MaxItemsPerBatch>,
 }
 
-#[derive(Debug, PartialEq, Encode, Decode)]
-pub struct NFTExtApprove<E: Ext> {
-	pub spender: <E::T as SysConfig>::AccountId,
+#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]
+pub struct NFTExtApprove<AccountId> {
+	pub spender: AccountId,
 	pub collection_id: u32,
 	pub item_id: u32,
 	pub amount: u128,
 }
 
-#[derive(Debug, PartialEq, Encode, Decode)]
-pub struct NFTExtTransferFrom<E: Ext> {
-	pub owner: <E::T as SysConfig>::AccountId,
-	pub recipient: <E::T as SysConfig>::AccountId,
+#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]
+pub struct NFTExtTransferFrom<AccountId> {
+	pub owner: AccountId,
+	pub recipient: AccountId,
 	pub collection_id: u32,
 	pub item_id: u32,
 	pub amount: u128,
 }
 
-#[derive(Debug, PartialEq, Encode, Decode)]
+#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]
+#[derivative(Debug)]
 pub struct NFTExtSetVariableMetaData {
 	pub collection_id: u32,
 	pub item_id: u32,
-	pub data: Vec<u8>,
+	#[derivative(Debug = "ignore")]
+	pub data: BoundedVec<u8, MaxDataSize>,
 }
 
-#[derive(Debug, PartialEq, Encode, Decode)]
-pub struct NFTExtToggleWhiteList<E: Ext> {
+#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]
+pub struct NFTExtToggleWhiteList<AccountId> {
 	pub collection_id: u32,
-	pub address: <E::T as SysConfig>::AccountId,
+	pub address: AccountId,
 	pub whitelisted: bool,
 }
 
@@ -82,6 +86,8 @@
 
 pub type NftWeightInfoOf<C> = <C as pallet_nft::Config>::WeightInfo;
 
+pub type AccountIdOf<C> = <C as SysConfig>::AccountId;
+
 impl<C: Config + pallet_contracts::Config> ChainExtension<C> for NFTExtension {
 	fn call<E: Ext>(func_id: u32, env: Environment<E, InitState>) -> Result<RetVal, DispatchError>
 	where
@@ -93,7 +99,7 @@
 		match func_id {
 			0 => {
 				let mut env = env.buf_in_buf_out();
-				let input: NFTExtTransfer<E> = env.read_as()?;
+				let input: NFTExtTransfer<AccountIdOf<C>> = env.read_as()?;
 				env.charge_weight(NftWeightInfoOf::<C>::transfer())?;
 
 				let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;
@@ -106,13 +112,13 @@
 					input.amount,
 				)?;
 
-				pallet_nft::Module::<C>::submit_logs(collection)?;
+				collection.submit_logs()?;
 				Ok(RetVal::Converging(0))
 			}
 			1 => {
 				// Create Item
 				let mut env = env.buf_in_buf_out();
-				let input: NFTExtCreateItem<E> = env.read_as()?;
+				let input: NFTExtCreateItem<AccountIdOf<C>> = env.read_as()?;
 				env.charge_weight(NftWeightInfoOf::<C>::create_item(input.data.data_size()))?;
 
 				let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;
@@ -124,13 +130,13 @@
 					input.data,
 				)?;
 
-				pallet_nft::Module::<C>::submit_logs(collection)?;
+				collection.submit_logs()?;
 				Ok(RetVal::Converging(0))
 			}
 			2 => {
 				// Create multiple items
 				let mut env = env.buf_in_buf_out();
-				let input: NFTExtCreateMultipleItems<E> = env.read_as()?;
+				let input: NFTExtCreateMultipleItems<AccountIdOf<C>> = env.read_as()?;
 				env.charge_weight(NftWeightInfoOf::<C>::create_item(
 					input.data.iter().map(|i| i.data_size()).sum(),
 				))?;
@@ -141,16 +147,16 @@
 					&C::CrossAccountId::from_sub(env.ext().address().clone()),
 					&collection,
 					&C::CrossAccountId::from_sub(input.owner),
-					input.data,
+					input.data.into_inner(),
 				)?;
 
-				pallet_nft::Module::<C>::submit_logs(collection)?;
+				collection.submit_logs()?;
 				Ok(RetVal::Converging(0))
 			}
 			3 => {
 				// Approve
 				let mut env = env.buf_in_buf_out();
-				let input: NFTExtApprove<E> = env.read_as()?;
+				let input: NFTExtApprove<AccountIdOf<C>> = env.read_as()?;
 				env.charge_weight(NftWeightInfoOf::<C>::approve())?;
 
 				let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;
@@ -163,13 +169,13 @@
 					input.amount,
 				)?;
 
-				pallet_nft::Module::<C>::submit_logs(collection)?;
+				collection.submit_logs()?;
 				Ok(RetVal::Converging(0))
 			}
 			4 => {
 				// Transfer from
 				let mut env = env.buf_in_buf_out();
-				let input: NFTExtTransferFrom<E> = env.read_as()?;
+				let input: NFTExtTransferFrom<AccountIdOf<C>> = env.read_as()?;
 				env.charge_weight(NftWeightInfoOf::<C>::transfer_from())?;
 
 				let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;
@@ -183,7 +189,7 @@
 					input.amount,
 				)?;
 
-				pallet_nft::Module::<C>::submit_logs(collection)?;
+				collection.submit_logs()?;
 				Ok(RetVal::Converging(0))
 			}
 			5 => {
@@ -198,16 +204,16 @@
 					&C::CrossAccountId::from_sub(env.ext().address().clone()),
 					&collection,
 					input.item_id,
-					input.data,
+					input.data.into_inner(),
 				)?;
 
-				pallet_nft::Module::<C>::submit_logs(collection)?;
+				collection.submit_logs()?;
 				Ok(RetVal::Converging(0))
 			}
 			6 => {
 				// Toggle whitelist
 				let mut env = env.buf_in_buf_out();
-				let input: NFTExtToggleWhiteList<E> = env.read_as()?;
+				let input: NFTExtToggleWhiteList<AccountIdOf<C>> = env.read_as()?;
 				env.charge_weight(NftWeightInfoOf::<C>::add_to_white_list())?;
 
 				let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;
@@ -219,7 +225,7 @@
 					input.whitelisted,
 				)?;
 
-				pallet_nft::Module::<C>::submit_logs(collection)?;
+				collection.submit_logs()?;
 				Ok(RetVal::Converging(0))
 			}
 			_ => Err(DispatchError::Other("unknown chain_extension func_id")),
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -72,7 +72,6 @@
 use sp_runtime::{
 	traits::{Dispatchable},
 };
-// use pallet_contracts::chain_extension::UncheckedFrom;
 
 // pub use pallet_timestamp::Call as TimestampCall;
 pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
@@ -419,7 +418,7 @@
 	type DepositPerStorageItem = DepositPerStorageItem;
 	type RentFraction = RentFraction;
 	type SurchargeReward = SurchargeReward;
-	type WeightPrice = pallet_transaction_payment::Module<Self>;
+	type WeightPrice = pallet_transaction_payment::Pallet<Self>;
 	type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
 	type ChainExtension = NFTExtension;
 	type DeletionQueueDepth = DeletionQueueDepth;