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
--- a/primitives/nft/src/lib.rs
+++ b/primitives/nft/src/lib.rs
@@ -4,8 +4,9 @@
 
 use sp_runtime::sp_std::prelude::Vec;
 use codec::{Decode, Encode};
+use max_encoded_len::MaxEncodedLen;
 pub use frame_support::{
-	construct_runtime, decl_event, decl_module, decl_storage, decl_error,
+	BoundedVec, construct_runtime, decl_event, decl_module, decl_storage, decl_error,
 	dispatch::DispatchResult,
 	ensure, fail, parameter_types,
 	traits::{
@@ -19,18 +20,26 @@
 	},
 	StorageValue, transactional,
 };
+use derivative::Derivative;
 
 pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;
 pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;
 pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;
 pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;
 
+// TODO: Somehow use ChainLimits for BoundedVec len calculation?
+// Do we need ChainLimits anyway, if we can change them via forkless upgrades?
+parameter_types! {
+pub const MaxDataSize: u32 = 2048;
+// TODO: This limit isn't checked for substrate create_multiple_items call
+pub const MaxItemsPerBatch: u32 = 200;
+}
+
 pub type CollectionId = u32;
 pub type TokenId = u32;
 pub type DecimalPoints = u8;
 
-#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub enum CollectionMode {
 	Invalid,
 	NFT,
@@ -60,8 +69,7 @@
 	fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;
 }
 
-#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub enum AccessMode {
 	Normal,
 	WhiteList,
@@ -72,8 +80,7 @@
 	}
 }
 
-#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub enum SchemaVersion {
 	ImageURL,
 	Unique,
@@ -84,15 +91,13 @@
 	}
 }
 
-#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub struct Ownership<AccountId> {
 	pub owner: AccountId,
 	pub fraction: u128,
 }
 
-#[derive(Encode, Decode, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub enum SponsorshipState<AccountId> {
 	/// The fees are applied to the transaction sender
 	Disabled,
@@ -147,30 +152,26 @@
 	pub transfers_enabled: bool,
 }
 
-#[derive(Encode, Decode, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub struct NftItemType<AccountId> {
 	pub owner: AccountId,
 	pub const_data: Vec<u8>,
 	pub variable_data: Vec<u8>,
 }
 
-#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub struct FungibleItemType {
 	pub value: u128,
 }
 
-#[derive(Encode, Decode, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub struct ReFungibleItemType<AccountId> {
 	pub owner: Vec<Ownership<AccountId>>,
 	pub const_data: Vec<u8>,
 	pub variable_data: Vec<u8>,
 }
 
-#[derive(Encode, Decode, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub struct CollectionLimits<BlockNumber: Encode + Decode> {
 	pub account_token_ownership_limit: u32,
 	pub sponsored_data_size: u32,
@@ -200,8 +201,7 @@
 	}
 }
 
-#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub struct ChainLimits {
 	pub collection_numbers_limit: u32,
 	pub account_token_ownership_limit: u32,
@@ -219,29 +219,73 @@
 	pub const_on_chain_schema_limit: u32,
 }
 
-#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+/// BoundedVec doesn't supports serde
+mod bounded_serde {
+	use core::convert::TryFrom;
+	use frame_support::{BoundedVec, traits::Get};
+	use serde::{
+		ser::{self, Serialize},
+		de::{self, Deserialize, Error},
+	};
+	use sp_std::vec::Vec;
+
+	pub fn serialize<D, V, S>(value: &BoundedVec<V, S>, serializer: D) -> Result<D::Ok, D::Error>
+	where
+		D: ser::Serializer,
+		V: Serialize,
+	{
+		let vec: &Vec<_> = &value;
+		vec.serialize(serializer)
+	}
+
+	pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>
+	where
+		D: de::Deserializer<'de>,
+		V: de::Deserialize<'de>,
+		S: Get<u32>,
+	{
+		// TODO: Implement custom visitor, which will limit vec size at parse time? Will serde only be used by chainspec?
+		let vec = <Vec<V>>::deserialize(deserializer)?;
+		let len = vec.len();
+		TryFrom::try_from(vec).map_err(|_| D::Error::invalid_length(len, &"lesser size"))
+	}
+}
+
+#[derive(
+	Encode, Decode, MaxEncodedLen, Default, Derivative, Clone, PartialEq, Serialize, Deserialize,
+)]
+#[derivative(Debug)]
 pub struct CreateNftData {
-	pub const_data: Vec<u8>,
-	pub variable_data: Vec<u8>,
+	#[serde(with = "bounded_serde")]
+	#[derivative(Debug="ignore")]
+	pub const_data: BoundedVec<u8, MaxDataSize>,
+	#[serde(with = "bounded_serde")]
+	#[derivative(Debug="ignore")]
+	pub variable_data: BoundedVec<u8, MaxDataSize>,
 }
 
-#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(
+	Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, Serialize, Deserialize,
+)]
 pub struct CreateFungibleData {
 	pub value: u128,
 }
 
-#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(
+	Encode, Decode, MaxEncodedLen, Default, Derivative, Clone, PartialEq, Serialize, Deserialize,
+)]
+#[derivative(Debug)]
 pub struct CreateReFungibleData {
-	pub const_data: Vec<u8>,
-	pub variable_data: Vec<u8>,
+	#[serde(with = "bounded_serde")]
+	#[derivative(Debug="ignore")]
+	pub const_data: BoundedVec<u8, MaxDataSize>,
+	#[serde(with = "bounded_serde")]
+	#[derivative(Debug="ignore")]
+	pub variable_data: BoundedVec<u8, MaxDataSize>,
 	pub pieces: u128,
 }
 
-#[derive(Encode, Decode, Debug, Clone, PartialEq)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, MaxEncodedLen, Debug, Clone, PartialEq, Serialize, Deserialize)]
 pub enum CreateItemData {
 	NFT(CreateNftData),
 	Fungible(CreateFungibleData),
modifiedruntime/Cargo.tomldiffbeforeafterboth
before · runtime/Cargo.toml
1################################################################################2# Package 34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Substrate node nft'8edition = '2018'9homepage = 'https://unique.network'10license = 'All Rights Reserved'11name = 'nft-runtime'12repository = 'https://github.com/usetech-llc/nft_private/'13version = '3.0.0'1415[package.metadata.docs.rs]16targets = ['x86_64-unknown-linux-gnu']1718[features]19default = ['std']20runtime-benchmarks = [21    'hex-literal',22    'frame-benchmarking',23    'frame-support/runtime-benchmarks',24    'frame-system-benchmarking',25    'frame-system/runtime-benchmarks',26    'pallet-balances/runtime-benchmarks',27    'pallet-timestamp/runtime-benchmarks',28    'pallet-nft/runtime-benchmarks',29    'pallet-inflation/runtime-benchmarks',30    'sp-runtime/runtime-benchmarks',31]32std = [33    'codec/std',34    'cumulus-pallet-aura-ext/std',35    'cumulus-pallet-parachain-system/std',36    'cumulus-pallet-xcm/std',37    'cumulus-pallet-xcmp-queue/std',38    'cumulus-primitives-core/std',39    'cumulus-primitives-utility/std',40    'frame-executive/std',41    'frame-support/std',42    'frame-system/std',43    'frame-system-rpc-runtime-api/std',44    'pallet-aura/std',45    'pallet-balances/std',46    # 'pallet-contracts/std',47    # 'pallet-contracts-primitives/std',48    # 'pallet-contracts-rpc-runtime-api/std',49    # 'pallet-contract-helpers/std',50    'pallet-randomness-collective-flip/std',51    'pallet-sudo/std',52    'pallet-timestamp/std',53    'pallet-transaction-payment/std',54    'pallet-transaction-payment-rpc-runtime-api/std',55    'pallet-treasury/std',56    'pallet-vesting/std',57    'pallet-evm/std',58    'pallet-evm-contract-helpers/std',59    'pallet-evm-transaction-payment/std',60    'pallet-evm-coder-substrate/std',61    'pallet-ethereum/std',62    'fp-rpc/std',63    'parachain-info/std',64    'serde',65    'pallet-inflation/std',66    'pallet-nft/std',67    'pallet-scheduler/std',68    'pallet-nft-charge-transaction/std',69    'pallet-nft-transaction-payment/std',70    'nft-data-structs/std',71    'sp-api/std',72    'sp-block-builder/std',73    "sp-consensus-aura/std",74    'sp-core/std',75    'sp-inherents/std',76    'sp-io/std',77    'sp-offchain/std',78    'sp-runtime/std',79    'sp-session/std',80    'sp-std/std',81    'sp-transaction-pool/std',82    'sp-version/std',83    'xcm/std',84    'xcm-builder/std',85    'xcm-executor/std',86]8788################################################################################89# Substrate Dependencies9091[dependencies.codec]92default-features = false93features = ['derive']94package = 'parity-scale-codec'95version = '2.0.0'9697[dependencies.frame-benchmarking]98default-features = false99git = 'https://github.com/paritytech/substrate.git'100optional = true101branch = 'polkadot-v0.9.8'102version = '3.0.0'103104[dependencies.frame-executive]105default-features = false106git = 'https://github.com/paritytech/substrate.git'107branch = 'polkadot-v0.9.8'108version = '3.0.0'109110[dependencies.frame-support]111default-features = false112git = 'https://github.com/paritytech/substrate.git'113branch = 'polkadot-v0.9.8'114version = '3.0.0'115116[dependencies.frame-system]117default-features = false118git = 'https://github.com/paritytech/substrate.git'119branch = 'polkadot-v0.9.8'120version = '3.0.0'121122[dependencies.frame-system-benchmarking]123default-features = false124git = 'https://github.com/paritytech/substrate.git'125optional = true126branch = 'polkadot-v0.9.8'127version = '3.0.0'128129[dependencies.frame-system-rpc-runtime-api]130default-features = false131git = 'https://github.com/paritytech/substrate.git'132branch = 'polkadot-v0.9.8'133version = '3.0.0'134135[dependencies.hex-literal]136optional = true137version = '0.3.1'138139[dependencies.serde]140default-features = false141features = ['derive']142optional = true143version = '1.0.119'144145[dependencies.pallet-aura]146default-features = false147git = 'https://github.com/paritytech/substrate.git'148branch = 'polkadot-v0.9.8'149version = '3.0.0'150151[dependencies.pallet-balances]152default-features = false153git = 'https://github.com/paritytech/substrate.git'154branch = 'polkadot-v0.9.8'155version = '3.0.0'156157# Contracts specific packages158# [dependencies.pallet-contracts]159# git = 'https://github.com/paritytech/substrate.git'160# default-features = false161# branch = 'polkadot-v0.9.8'162# version = '3.0.0'163164# [dependencies.pallet-contracts-primitives]165# git = 'https://github.com/paritytech/substrate.git'166# default-features = false167# branch = 'polkadot-v0.9.8'168# version = '3.0.0'169170# [dependencies.pallet-contracts-rpc-runtime-api]171# git = 'https://github.com/paritytech/substrate.git'172# default-features = false173# branch = 'polkadot-v0.9.8'174# version = '3.0.0'175176[dependencies.pallet-randomness-collective-flip]177default-features = false178git = 'https://github.com/paritytech/substrate.git'179branch = 'polkadot-v0.9.8'180version = '3.0.0'181182[dependencies.pallet-sudo]183default-features = false184git = 'https://github.com/paritytech/substrate.git'185branch = 'polkadot-v0.9.8'186version = '3.0.0'187188[dependencies.pallet-timestamp]189default-features = false190git = 'https://github.com/paritytech/substrate.git'191branch = 'polkadot-v0.9.8'192version = '3.0.0'193194[dependencies.pallet-transaction-payment]195default-features = false196git = 'https://github.com/paritytech/substrate.git'197branch = 'polkadot-v0.9.8'198version = '3.0.0'199200[dependencies.pallet-transaction-payment-rpc-runtime-api]201default-features = false202git = 'https://github.com/paritytech/substrate.git'203branch = 'polkadot-v0.9.8'204version = '3.0.0'205206[dependencies.pallet-treasury]207default-features = false208git = 'https://github.com/paritytech/substrate.git'209branch = 'polkadot-v0.9.8'210version = '3.0.0'211212[dependencies.pallet-vesting]213default-features = false214git = 'https://github.com/paritytech/substrate.git'215branch = 'polkadot-v0.9.8'216version = '3.0.0'217218[dependencies.sp-arithmetic]219default-features = false220git = 'https://github.com/paritytech/substrate.git'221branch = 'polkadot-v0.9.8'222version = '3.0.0'223224[dependencies.sp-api]225default-features = false226git = 'https://github.com/paritytech/substrate.git'227branch = 'polkadot-v0.9.8'228version = '3.0.0'229230[dependencies.sp-block-builder]231default-features = false232git = 'https://github.com/paritytech/substrate.git'233branch = 'polkadot-v0.9.8'234version = '3.0.0'235236[dependencies.sp-core]237default-features = false238git = 'https://github.com/paritytech/substrate.git'239branch = 'polkadot-v0.9.8'240version = '3.0.0'241242[dependencies.sp-consensus-aura]243default-features = false244git = 'https://github.com/paritytech/substrate.git'245branch = 'polkadot-v0.9.8'246version = '0.9.0'247248[dependencies.sp-inherents]249default-features = false250git = 'https://github.com/paritytech/substrate.git'251branch = 'polkadot-v0.9.8'252version = '3.0.0'253254[dependencies.sp-io]255default-features = false256git = 'https://github.com/paritytech/substrate.git'257branch = 'polkadot-v0.9.8'258version = '3.0.0'259260[dependencies.sp-offchain]261default-features = false262git = 'https://github.com/paritytech/substrate.git'263branch = 'polkadot-v0.9.8'264version = '3.0.0'265266[dependencies.sp-runtime]267default-features = false268git = 'https://github.com/paritytech/substrate.git'269branch = 'polkadot-v0.9.8'270version = '3.0.0'271272[dependencies.sp-session]273default-features = false274git = 'https://github.com/paritytech/substrate.git'275branch = 'polkadot-v0.9.8'276version = '3.0.0'277278[dependencies.sp-std]279default-features = false280git = 'https://github.com/paritytech/substrate.git'281branch = 'polkadot-v0.9.8'282version = '3.0.0'283284[dependencies.sp-transaction-pool]285default-features = false286git = 'https://github.com/paritytech/substrate.git'287branch = 'polkadot-v0.9.8'288version = '3.0.0'289290[dependencies.sp-version]291default-features = false292git = 'https://github.com/paritytech/substrate.git'293branch = 'polkadot-v0.9.8'294version = '3.0.0'295296[dependencies.smallvec]297version = '1.4.1'298299################################################################################300# Cumulus dependencies301302[dependencies.parachain-info]303default-features = false304git = 'https://github.com/paritytech/cumulus.git'305branch = 'polkadot-v0.9.8'306version = '0.1.0'307308[dependencies.cumulus-pallet-aura-ext]309git = 'https://github.com/paritytech/cumulus.git'310branch = 'polkadot-v0.9.8'311default-features = false312313[dependencies.cumulus-pallet-parachain-system]314git = 'https://github.com/paritytech/cumulus.git'315branch = 'polkadot-v0.9.8'316default-features = false317318[dependencies.cumulus-primitives-core]319git = 'https://github.com/paritytech/cumulus.git'320branch = 'polkadot-v0.9.8'321default-features = false322323[dependencies.cumulus-pallet-xcm]324git = 'https://github.com/paritytech/cumulus.git'325branch = 'polkadot-v0.9.8'326default-features = false327328[dependencies.cumulus-pallet-dmp-queue]329git = 'https://github.com/paritytech/cumulus.git'330branch = 'polkadot-v0.9.8'331default-features = false332333[dependencies.cumulus-pallet-xcmp-queue]334git = 'https://github.com/paritytech/cumulus.git'335branch = 'polkadot-v0.9.8'336default-features = false337338[dependencies.cumulus-primitives-utility]339git = 'https://github.com/paritytech/cumulus.git'340branch = 'polkadot-v0.9.8'341default-features = false342343[dependencies.cumulus-primitives-timestamp]344git = 'https://github.com/paritytech/cumulus.git'345branch = 'polkadot-v0.9.8'346default-features = false347348################################################################################349# Polkadot dependencies350351[dependencies.polkadot-parachain]352git = 'https://github.com/paritytech/polkadot'353branch = 'release-v0.9.8'354default-features = false355356[dependencies.xcm]357git = 'https://github.com/paritytech/polkadot'358branch = 'release-v0.9.8'359default-features = false360361[dependencies.xcm-builder]362git = 'https://github.com/paritytech/polkadot'363branch = 'release-v0.9.8'364default-features = false365366[dependencies.xcm-executor]367git = 'https://github.com/paritytech/polkadot'368branch = 'release-v0.9.8'369default-features = false370371[dependencies.pallet-xcm]372git = 'https://github.com/paritytech/polkadot'373branch = 'release-v0.9.8'374default-features = false375376377################################################################################378# local dependencies379380[dependencies]381pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }382pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }383nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }384pallet-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }385# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }386pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.0' }387pallet-nft-charge-transaction = { path = '../pallets/nft-charge-transaction', default-features = false, version = '3.0.0' }388pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }389pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }390pallet-evm-coder-substrate = { default-features = false, path = "../pallets/evm-coder-substrate" }391392pallet-evm = { default-features = false, version = "5.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" }393pallet-ethereum = { default-features = false, version = "3.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" }394fp-rpc = { default-features = false, version = "2.0.0", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" }395396################################################################################397# Build Dependencies398399[build-dependencies]400substrate-wasm-builder = '4.0.0'
after · runtime/Cargo.toml
1################################################################################2# Package 34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'7description = 'Substrate node nft'8edition = '2018'9homepage = 'https://unique.network'10license = 'All Rights Reserved'11name = 'nft-runtime'12repository = 'https://github.com/usetech-llc/nft_private/'13version = '3.0.0'1415[package.metadata.docs.rs]16targets = ['x86_64-unknown-linux-gnu']1718[features]19default = ['std']20runtime-benchmarks = [21    'hex-literal',22    'frame-benchmarking',23    'frame-support/runtime-benchmarks',24    'frame-system-benchmarking',25    'frame-system/runtime-benchmarks',26    'pallet-balances/runtime-benchmarks',27    'pallet-timestamp/runtime-benchmarks',28    'pallet-nft/runtime-benchmarks',29    'pallet-inflation/runtime-benchmarks',30    'sp-runtime/runtime-benchmarks',31]32std = [33    'codec/std',34    'max-encoded-len/std',35    'cumulus-pallet-aura-ext/std',36    'cumulus-pallet-parachain-system/std',37    'cumulus-pallet-xcm/std',38    'cumulus-pallet-xcmp-queue/std',39    'cumulus-primitives-core/std',40    'cumulus-primitives-utility/std',41    'frame-executive/std',42    'frame-support/std',43    'frame-system/std',44    'frame-system-rpc-runtime-api/std',45    'pallet-aura/std',46    'pallet-balances/std',47    # 'pallet-contracts/std',48    # 'pallet-contracts-primitives/std',49    # 'pallet-contracts-rpc-runtime-api/std',50    # 'pallet-contract-helpers/std',51    'pallet-randomness-collective-flip/std',52    'pallet-sudo/std',53    'pallet-timestamp/std',54    'pallet-transaction-payment/std',55    'pallet-transaction-payment-rpc-runtime-api/std',56    'pallet-treasury/std',57    'pallet-vesting/std',58    'pallet-evm/std',59    'pallet-evm-contract-helpers/std',60    'pallet-evm-transaction-payment/std',61    'pallet-evm-coder-substrate/std',62    'pallet-ethereum/std',63    'fp-rpc/std',64    'parachain-info/std',65    'serde',66    'pallet-inflation/std',67    'pallet-nft/std',68    'pallet-scheduler/std',69    'pallet-nft-charge-transaction/std',70    'pallet-nft-transaction-payment/std',71    'nft-data-structs/std',72    'sp-api/std',73    'sp-block-builder/std',74    "sp-consensus-aura/std",75    'sp-core/std',76    'sp-inherents/std',77    'sp-io/std',78    'sp-offchain/std',79    'sp-runtime/std',80    'sp-session/std',81    'sp-std/std',82    'sp-transaction-pool/std',83    'sp-version/std',84    'xcm/std',85    'xcm-builder/std',86    'xcm-executor/std',87]8889################################################################################90# Substrate Dependencies9192[dependencies.codec]93default-features = false94features = ['derive']95package = 'parity-scale-codec'96version = '2.0.0'9798[dependencies.frame-benchmarking]99default-features = false100git = 'https://github.com/paritytech/substrate.git'101optional = true102branch = 'polkadot-v0.9.8'103version = '3.0.0'104105[dependencies.frame-executive]106default-features = false107git = 'https://github.com/paritytech/substrate.git'108branch = 'polkadot-v0.9.8'109version = '3.0.0'110111[dependencies.frame-support]112default-features = false113git = 'https://github.com/paritytech/substrate.git'114branch = 'polkadot-v0.9.8'115version = '3.0.0'116117[dependencies.frame-system]118default-features = false119git = 'https://github.com/paritytech/substrate.git'120branch = 'polkadot-v0.9.8'121version = '3.0.0'122123[dependencies.frame-system-benchmarking]124default-features = false125git = 'https://github.com/paritytech/substrate.git'126optional = true127branch = 'polkadot-v0.9.8'128version = '3.0.0'129130[dependencies.frame-system-rpc-runtime-api]131default-features = false132git = 'https://github.com/paritytech/substrate.git'133branch = 'polkadot-v0.9.8'134version = '3.0.0'135136[dependencies.hex-literal]137optional = true138version = '0.3.1'139140[dependencies.serde]141default-features = false142features = ['derive']143optional = true144version = '1.0.119'145146[dependencies.pallet-aura]147default-features = false148git = 'https://github.com/paritytech/substrate.git'149branch = 'polkadot-v0.9.8'150version = '3.0.0'151152[dependencies.pallet-balances]153default-features = false154git = 'https://github.com/paritytech/substrate.git'155branch = 'polkadot-v0.9.8'156version = '3.0.0'157158# Contracts specific packages159# [dependencies.pallet-contracts]160# git = 'https://github.com/paritytech/substrate.git'161# default-features = false162# branch = 'polkadot-v0.9.8'163# version = '3.0.0'164165# [dependencies.pallet-contracts-primitives]166# git = 'https://github.com/paritytech/substrate.git'167# default-features = false168# branch = 'polkadot-v0.9.8'169# version = '3.0.0'170171# [dependencies.pallet-contracts-rpc-runtime-api]172# git = 'https://github.com/paritytech/substrate.git'173# default-features = false174# branch = 'polkadot-v0.9.8'175# version = '3.0.0'176177[dependencies.pallet-randomness-collective-flip]178default-features = false179git = 'https://github.com/paritytech/substrate.git'180branch = 'polkadot-v0.9.8'181version = '3.0.0'182183[dependencies.pallet-sudo]184default-features = false185git = 'https://github.com/paritytech/substrate.git'186branch = 'polkadot-v0.9.8'187version = '3.0.0'188189[dependencies.pallet-timestamp]190default-features = false191git = 'https://github.com/paritytech/substrate.git'192branch = 'polkadot-v0.9.8'193version = '3.0.0'194195[dependencies.pallet-transaction-payment]196default-features = false197git = 'https://github.com/paritytech/substrate.git'198branch = 'polkadot-v0.9.8'199version = '3.0.0'200201[dependencies.pallet-transaction-payment-rpc-runtime-api]202default-features = false203git = 'https://github.com/paritytech/substrate.git'204branch = 'polkadot-v0.9.8'205version = '3.0.0'206207[dependencies.pallet-treasury]208default-features = false209git = 'https://github.com/paritytech/substrate.git'210branch = 'polkadot-v0.9.8'211version = '3.0.0'212213[dependencies.pallet-vesting]214default-features = false215git = 'https://github.com/paritytech/substrate.git'216branch = 'polkadot-v0.9.8'217version = '3.0.0'218219[dependencies.sp-arithmetic]220default-features = false221git = 'https://github.com/paritytech/substrate.git'222branch = 'polkadot-v0.9.8'223version = '3.0.0'224225[dependencies.sp-api]226default-features = false227git = 'https://github.com/paritytech/substrate.git'228branch = 'polkadot-v0.9.8'229version = '3.0.0'230231[dependencies.sp-block-builder]232default-features = false233git = 'https://github.com/paritytech/substrate.git'234branch = 'polkadot-v0.9.8'235version = '3.0.0'236237[dependencies.sp-core]238default-features = false239git = 'https://github.com/paritytech/substrate.git'240branch = 'polkadot-v0.9.8'241version = '3.0.0'242243[dependencies.sp-consensus-aura]244default-features = false245git = 'https://github.com/paritytech/substrate.git'246branch = 'polkadot-v0.9.8'247version = '0.9.0'248249[dependencies.sp-inherents]250default-features = false251git = 'https://github.com/paritytech/substrate.git'252branch = 'polkadot-v0.9.8'253version = '3.0.0'254255[dependencies.sp-io]256default-features = false257git = 'https://github.com/paritytech/substrate.git'258branch = 'polkadot-v0.9.8'259version = '3.0.0'260261[dependencies.sp-offchain]262default-features = false263git = 'https://github.com/paritytech/substrate.git'264branch = 'polkadot-v0.9.8'265version = '3.0.0'266267[dependencies.sp-runtime]268default-features = false269git = 'https://github.com/paritytech/substrate.git'270branch = 'polkadot-v0.9.8'271version = '3.0.0'272273[dependencies.sp-session]274default-features = false275git = 'https://github.com/paritytech/substrate.git'276branch = 'polkadot-v0.9.8'277version = '3.0.0'278279[dependencies.sp-std]280default-features = false281git = 'https://github.com/paritytech/substrate.git'282branch = 'polkadot-v0.9.8'283version = '3.0.0'284285[dependencies.sp-transaction-pool]286default-features = false287git = 'https://github.com/paritytech/substrate.git'288branch = 'polkadot-v0.9.8'289version = '3.0.0'290291[dependencies.sp-version]292default-features = false293git = 'https://github.com/paritytech/substrate.git'294branch = 'polkadot-v0.9.8'295version = '3.0.0'296297[dependencies.smallvec]298version = '1.4.1'299300################################################################################301# Cumulus dependencies302303[dependencies.parachain-info]304default-features = false305git = 'https://github.com/paritytech/cumulus.git'306branch = 'polkadot-v0.9.8'307version = '0.1.0'308309[dependencies.cumulus-pallet-aura-ext]310git = 'https://github.com/paritytech/cumulus.git'311branch = 'polkadot-v0.9.8'312default-features = false313314[dependencies.cumulus-pallet-parachain-system]315git = 'https://github.com/paritytech/cumulus.git'316branch = 'polkadot-v0.9.8'317default-features = false318319[dependencies.cumulus-primitives-core]320git = 'https://github.com/paritytech/cumulus.git'321branch = 'polkadot-v0.9.8'322default-features = false323324[dependencies.cumulus-pallet-xcm]325git = 'https://github.com/paritytech/cumulus.git'326branch = 'polkadot-v0.9.8'327default-features = false328329[dependencies.cumulus-pallet-dmp-queue]330git = 'https://github.com/paritytech/cumulus.git'331branch = 'polkadot-v0.9.8'332default-features = false333334[dependencies.cumulus-pallet-xcmp-queue]335git = 'https://github.com/paritytech/cumulus.git'336branch = 'polkadot-v0.9.8'337default-features = false338339[dependencies.cumulus-primitives-utility]340git = 'https://github.com/paritytech/cumulus.git'341branch = 'polkadot-v0.9.8'342default-features = false343344[dependencies.cumulus-primitives-timestamp]345git = 'https://github.com/paritytech/cumulus.git'346branch = 'polkadot-v0.9.8'347default-features = false348349################################################################################350# Polkadot dependencies351352[dependencies.polkadot-parachain]353git = 'https://github.com/paritytech/polkadot'354branch = 'release-v0.9.8'355default-features = false356357[dependencies.xcm]358git = 'https://github.com/paritytech/polkadot'359branch = 'release-v0.9.8'360default-features = false361362[dependencies.xcm-builder]363git = 'https://github.com/paritytech/polkadot'364branch = 'release-v0.9.8'365default-features = false366367[dependencies.xcm-executor]368git = 'https://github.com/paritytech/polkadot'369branch = 'release-v0.9.8'370default-features = false371372[dependencies.pallet-xcm]373git = 'https://github.com/paritytech/polkadot'374branch = 'release-v0.9.8'375default-features = false376377378################################################################################379# local dependencies380381[dependencies]382max-encoded-len = { default-features = false, features = ['derive'], version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }383derivative = "2.2.0"384pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }385pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }386nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }387pallet-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }388# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }389pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.0' }390pallet-nft-charge-transaction = { path = '../pallets/nft-charge-transaction', default-features = false, version = '3.0.0' }391pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }392pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }393pallet-evm-coder-substrate = { default-features = false, path = "../pallets/evm-coder-substrate" }394395pallet-evm = { default-features = false, version = "5.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" }396pallet-ethereum = { default-features = false, version = "3.0.0-dev", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" }397fp-rpc = { default-features = false, version = "2.0.0", git = "https://github.com/uniquenetwork/frontier.git", branch = "injected-transactions-parachain" }398399################################################################################400# Build Dependencies401402[build-dependencies]403substrate-wasm-builder = '4.0.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;