difftreelog
fix unbroke ink contract build substrate v0.9.8
in: master
7 files changed
Cargo.lockdiffbeforeafterboth4935name = "nft-data-structs"4935name = "nft-data-structs"4936version = "0.9.0"4936version = "0.9.0"4937dependencies = [4937dependencies = [4938 "derivative",4938 "frame-support",4939 "frame-support",4939 "frame-system",4940 "frame-system",4941 "max-encoded-len",4940 "parity-scale-codec",4942 "parity-scale-codec",4941 "serde",4943 "serde",4942 "sp-core",4944 "sp-core",4943 "sp-runtime",4945 "sp-runtime",4946 "sp-std",4944]4947]494549484946[[package]]4949[[package]]4999 "cumulus-primitives-core",5002 "cumulus-primitives-core",5000 "cumulus-primitives-timestamp",5003 "cumulus-primitives-timestamp",5001 "cumulus-primitives-utility",5004 "cumulus-primitives-utility",5005 "derivative",5002 "fp-rpc",5006 "fp-rpc",5003 "frame-benchmarking",5007 "frame-benchmarking",5004 "frame-executive",5008 "frame-executive",5007 "frame-system-benchmarking",5011 "frame-system-benchmarking",5008 "frame-system-rpc-runtime-api",5012 "frame-system-rpc-runtime-api",5009 "hex-literal",5013 "hex-literal",5014 "max-encoded-len",5010 "nft-data-structs",5015 "nft-data-structs",5011 "pallet-aura",5016 "pallet-aura",5012 "pallet-balances",5017 "pallet-balances",pallets/nft/src/lib.rsdiffbeforeafterboth1675 CreateItemData::NFT(data) => {1675 CreateItemData::NFT(data) => {1676 let item = NftItemType {1676 let item = NftItemType {1677 owner: owner.clone(),1677 owner: owner.clone(),1678 const_data: data.const_data,1678 const_data: data.const_data.into_inner(),1679 variable_data: data.variable_data,1679 variable_data: data.variable_data.into_inner(),1680 };1680 };168116811682 Self::add_nft_item(collection, item)?;1682 Self::add_nft_item(collection, item)?;169216921693 let item = ReFungibleItemType {1693 let item = ReFungibleItemType {1694 owner: owner_list,1694 owner: owner_list,1695 const_data: data.const_data,1695 const_data: data.const_data.into_inner(),1696 variable_data: data.variable_data,1696 variable_data: data.variable_data.into_inner(),1697 };1697 };169816981699 Self::add_refungible_item(collection, item)?;1699 Self::add_refungible_item(collection, item)?;primitives/nft/Cargo.tomldiffbeforeafterboth9version = '0.9.0'9version = '0.9.0'101011[dependencies]11[dependencies]12codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ['derive'] }12codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ['derive'] }13serde = { version = "1.0.119", features = ['derive'], default-features = false }13serde = { version = "1.0.119", features = ['derive'], default-features = false }14max-encoded-len = { default-features = false, features = ['derive'], version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }14frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }15frame-support = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }15frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }16frame-system = { default-features = false, version = '3.0.0', git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }16sp-core = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }17sp-core = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }18sp-std = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }17sp-runtime = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }19sp-runtime = { version = "3.0.0", default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.8' }20derivative = "2.2.0"182119[features]22[features]20default = ["std"]23default = ["std"]21std = [24std = [22 "serde/std",25 "serde/std",23 "codec/std",26 "codec/std",27 "max-encoded-len/std",24 "frame-system/std",28 "frame-system/std",25 "frame-support/std",29 "frame-support/std",26 "sp-runtime/std",30 "sp-runtime/std",27 "sp-core/std",31 "sp-core/std",32 "sp-std/std",28]33]primitives/nft/src/lib.rsdiffbeforeafterboth445use sp_runtime::sp_std::prelude::Vec;5use sp_runtime::sp_std::prelude::Vec;6use codec::{Decode, Encode};6use codec::{Decode, Encode};7use max_encoded_len::MaxEncodedLen;7pub use frame_support::{8pub use frame_support::{8 construct_runtime, decl_event, decl_module, decl_storage, decl_error,9 BoundedVec, construct_runtime, decl_event, decl_module, decl_storage, decl_error,9 dispatch::DispatchResult,10 dispatch::DispatchResult,10 ensure, fail, parameter_types,11 ensure, fail, parameter_types,11 traits::{12 traits::{19 },20 },20 StorageValue, transactional,21 StorageValue, transactional,21};22};23use derivative::Derivative;222423pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;25pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;24pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;26pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;25pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;27pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;26pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_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}273728pub type CollectionId = u32;38pub type CollectionId = u32;29pub type TokenId = u32;39pub type TokenId = u32;30pub type DecimalPoints = u8;40pub type DecimalPoints = u8;314132#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]42#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]33#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]34pub enum CollectionMode {43pub enum CollectionMode {35 Invalid,44 Invalid,36 NFT,45 NFT,60 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;69 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;61}70}627163#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]72#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]64#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]65pub enum AccessMode {73pub enum AccessMode {66 Normal,74 Normal,67 WhiteList,75 WhiteList,72 }80 }73}81}748275#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]83#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, Serialize, Deserialize)]76#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]77pub enum SchemaVersion {84pub enum SchemaVersion {78 ImageURL,85 ImageURL,79 Unique,86 Unique,84 }91 }85}92}869387#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]94#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]88#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]89pub struct Ownership<AccountId> {95pub struct Ownership<AccountId> {90 pub owner: AccountId,96 pub owner: AccountId,91 pub fraction: u128,97 pub fraction: u128,92}98}939994#[derive(Encode, Decode, Debug, Clone, PartialEq)]100#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]95#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]96pub enum SponsorshipState<AccountId> {101pub enum SponsorshipState<AccountId> {97 /// The fees are applied to the transaction sender102 /// The fees are applied to the transaction sender98 Disabled,103 Disabled,147 pub transfers_enabled: bool,152 pub transfers_enabled: bool,148}153}149154150#[derive(Encode, Decode, Debug, Clone, PartialEq)]155#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]151#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]152pub struct NftItemType<AccountId> {156pub struct NftItemType<AccountId> {153 pub owner: AccountId,157 pub owner: AccountId,154 pub const_data: Vec<u8>,158 pub const_data: Vec<u8>,155 pub variable_data: Vec<u8>,159 pub variable_data: Vec<u8>,156}160}157161158#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]162#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]159#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]160pub struct FungibleItemType {163pub struct FungibleItemType {161 pub value: u128,164 pub value: u128,162}165}163166164#[derive(Encode, Decode, Debug, Clone, PartialEq)]167#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]165#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]166pub struct ReFungibleItemType<AccountId> {168pub struct ReFungibleItemType<AccountId> {167 pub owner: Vec<Ownership<AccountId>>,169 pub owner: Vec<Ownership<AccountId>>,168 pub const_data: Vec<u8>,170 pub const_data: Vec<u8>,169 pub variable_data: Vec<u8>,171 pub variable_data: Vec<u8>,170}172}171173172#[derive(Encode, Decode, Debug, Clone, PartialEq)]174#[derive(Encode, Decode, Debug, Clone, PartialEq, Serialize, Deserialize)]173#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]174pub struct CollectionLimits<BlockNumber: Encode + Decode> {175pub struct CollectionLimits<BlockNumber: Encode + Decode> {175 pub account_token_ownership_limit: u32,176 pub account_token_ownership_limit: u32,176 pub sponsored_data_size: u32,177 pub sponsored_data_size: u32,200 }201 }201}202}202203203#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]204#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, Serialize, Deserialize)]204#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]205pub struct ChainLimits {205pub struct ChainLimits {206 pub collection_numbers_limit: u32,206 pub collection_numbers_limit: u32,207 pub account_token_ownership_limit: u32,207 pub account_token_ownership_limit: u32,219 pub const_on_chain_schema_limit: u32,219 pub const_on_chain_schema_limit: u32,220}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}221253222#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]254#[derive(255 Encode, Decode, MaxEncodedLen, Default, Derivative, Clone, PartialEq, Serialize, Deserialize,256)]223#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]257#[derivative(Debug)]224pub struct CreateNftData {258pub struct CreateNftData {259 #[serde(with = "bounded_serde")]260 #[derivative(Debug="ignore")]225 pub const_data: Vec<u8>,261 pub const_data: BoundedVec<u8, MaxDataSize>,262 #[serde(with = "bounded_serde")]263 #[derivative(Debug="ignore")]226 pub variable_data: Vec<u8>,264 pub variable_data: BoundedVec<u8, MaxDataSize>,227}265}228266229#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]267#[derive(230#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]268 Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, Serialize, Deserialize,269)]231pub struct CreateFungibleData {270pub struct CreateFungibleData {232 pub value: u128,271 pub value: u128,233}272}234273235#[derive(Encode, Decode, Default, Debug, Clone, PartialEq)]274#[derive(275 Encode, Decode, MaxEncodedLen, Default, Derivative, Clone, PartialEq, Serialize, Deserialize,276)]236#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]277#[derivative(Debug)]237pub struct CreateReFungibleData {278pub struct CreateReFungibleData {279 #[serde(with = "bounded_serde")]280 #[derivative(Debug="ignore")]238 pub const_data: Vec<u8>,281 pub const_data: BoundedVec<u8, MaxDataSize>,282 #[serde(with = "bounded_serde")]283 #[derivative(Debug="ignore")]239 pub variable_data: Vec<u8>,284 pub variable_data: BoundedVec<u8, MaxDataSize>,240 pub pieces: u128,285 pub pieces: u128,241}286}242287243#[derive(Encode, Decode, Debug, Clone, PartialEq)]288#[derive(Encode, Decode, MaxEncodedLen, Debug, Clone, PartialEq, Serialize, Deserialize)]244#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]245pub enum CreateItemData {289pub enum CreateItemData {246 NFT(CreateNftData),290 NFT(CreateNftData),247 Fungible(CreateFungibleData),291 Fungible(CreateFungibleData),runtime/Cargo.tomldiffbeforeafterboth31]31]32std = [32std = [33 'codec/std',33 'codec/std',34 'max-encoded-len/std',34 'cumulus-pallet-aura-ext/std',35 'cumulus-pallet-aura-ext/std',35 'cumulus-pallet-parachain-system/std',36 'cumulus-pallet-parachain-system/std',36 'cumulus-pallet-xcm/std',37 'cumulus-pallet-xcm/std',378# local dependencies379# local dependencies379380380[dependencies]381[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"381pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }384pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }382pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }385pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }383nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }386nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }runtime/src/chain_extension.rsdiffbeforeafterboth6//6//778use codec::{Decode, Encode};8use codec::{Decode, Encode};9use max_encoded_len::MaxEncodedLen;10use derivative::Derivative;91110pub use pallet_contracts::chain_extension::RetVal;12pub use pallet_contracts::chain_extension::RetVal;11use pallet_contracts::chain_extension::{13use pallet_contracts::chain_extension::{20use pallet_nft::CrossAccountId;22use pallet_nft::CrossAccountId;21use nft_data_structs::*;23use nft_data_structs::*;2223use crate::Vec;242425/// Create item parameters25/// Create item parameters26#[derive(Debug, PartialEq, Encode, Decode)]26#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]27pub struct NFTExtCreateItem<E: Ext> {27pub struct NFTExtCreateItem<AccountId> {28 pub owner: <E::T as SysConfig>::AccountId,28 pub owner: AccountId,29 pub collection_id: u32,29 pub collection_id: u32,30 pub data: CreateItemData,30 pub data: CreateItemData,31}31}323233/// Transfer parameters33/// Transfer parameters34#[derive(Debug, PartialEq, Encode, Decode)]34#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]35pub struct NFTExtTransfer<E: Ext> {35pub struct NFTExtTransfer<AccountId> {36 pub recipient: <E::T as SysConfig>::AccountId,36 pub recipient: AccountId,37 pub collection_id: u32,37 pub collection_id: u32,38 pub token_id: u32,38 pub token_id: u32,39 pub amount: u128,39 pub amount: u128,40}40}414142#[derive(Debug, PartialEq, Encode, Decode)]42#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]43#[derivative(Debug)]43pub struct NFTExtCreateMultipleItems<E: Ext> {44pub struct NFTExtCreateMultipleItems<AccountId> {44 pub owner: <E::T as SysConfig>::AccountId,45 pub owner: AccountId,45 pub collection_id: u32,46 pub collection_id: u32,47 #[derivative(Debug = "ignore")]46 pub data: Vec<CreateItemData>,48 pub data: BoundedVec<CreateItemData, MaxItemsPerBatch>,47}49}485049#[derive(Debug, PartialEq, Encode, Decode)]51#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]50pub struct NFTExtApprove<E: Ext> {52pub struct NFTExtApprove<AccountId> {51 pub spender: <E::T as SysConfig>::AccountId,53 pub spender: AccountId,52 pub collection_id: u32,54 pub collection_id: u32,53 pub item_id: u32,55 pub item_id: u32,54 pub amount: u128,56 pub amount: u128,55}57}565857#[derive(Debug, PartialEq, Encode, Decode)]59#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]58pub struct NFTExtTransferFrom<E: Ext> {60pub struct NFTExtTransferFrom<AccountId> {59 pub owner: <E::T as SysConfig>::AccountId,61 pub owner: AccountId,60 pub recipient: <E::T as SysConfig>::AccountId,62 pub recipient: AccountId,61 pub collection_id: u32,63 pub collection_id: u32,62 pub item_id: u32,64 pub item_id: u32,63 pub amount: u128,65 pub amount: u128,64}66}656766#[derive(Debug, PartialEq, Encode, Decode)]68#[derive(Derivative, PartialEq, Encode, Decode, MaxEncodedLen)]69#[derivative(Debug)]67pub struct NFTExtSetVariableMetaData {70pub struct NFTExtSetVariableMetaData {68 pub collection_id: u32,71 pub collection_id: u32,69 pub item_id: u32,72 pub item_id: u32,73 #[derivative(Debug = "ignore")]70 pub data: Vec<u8>,74 pub data: BoundedVec<u8, MaxDataSize>,71}75}727673#[derive(Debug, PartialEq, Encode, Decode)]77#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]74pub struct NFTExtToggleWhiteList<E: Ext> {78pub struct NFTExtToggleWhiteList<AccountId> {75 pub collection_id: u32,79 pub collection_id: u32,76 pub address: <E::T as SysConfig>::AccountId,80 pub address: AccountId,77 pub whitelisted: bool,81 pub whitelisted: bool,78}82}7983828683pub type NftWeightInfoOf<C> = <C as pallet_nft::Config>::WeightInfo;87pub type NftWeightInfoOf<C> = <C as pallet_nft::Config>::WeightInfo;8889pub type AccountIdOf<C> = <C as SysConfig>::AccountId;849085impl<C: Config + pallet_contracts::Config> ChainExtension<C> for NFTExtension {91impl<C: Config + pallet_contracts::Config> ChainExtension<C> for NFTExtension {86 fn call<E: Ext>(func_id: u32, env: Environment<E, InitState>) -> Result<RetVal, DispatchError>92 fn call<E: Ext>(func_id: u32, env: Environment<E, InitState>) -> Result<RetVal, DispatchError>93 match func_id {99 match func_id {94 0 => {100 0 => {95 let mut env = env.buf_in_buf_out();101 let mut env = env.buf_in_buf_out();96 let input: NFTExtTransfer<E> = env.read_as()?;102 let input: NFTExtTransfer<AccountIdOf<C>> = env.read_as()?;97 env.charge_weight(NftWeightInfoOf::<C>::transfer())?;103 env.charge_weight(NftWeightInfoOf::<C>::transfer())?;9810499 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;105 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;106 input.amount,112 input.amount,107 )?;113 )?;108114109 pallet_nft::Module::<C>::submit_logs(collection)?;115 collection.submit_logs()?;110 Ok(RetVal::Converging(0))116 Ok(RetVal::Converging(0))111 }117 }112 1 => {118 1 => {113 // Create Item119 // Create Item114 let mut env = env.buf_in_buf_out();120 let mut env = env.buf_in_buf_out();115 let input: NFTExtCreateItem<E> = env.read_as()?;121 let input: NFTExtCreateItem<AccountIdOf<C>> = env.read_as()?;116 env.charge_weight(NftWeightInfoOf::<C>::create_item(input.data.data_size()))?;122 env.charge_weight(NftWeightInfoOf::<C>::create_item(input.data.data_size()))?;117123118 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;124 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;124 input.data,130 input.data,125 )?;131 )?;126132127 pallet_nft::Module::<C>::submit_logs(collection)?;133 collection.submit_logs()?;128 Ok(RetVal::Converging(0))134 Ok(RetVal::Converging(0))129 }135 }130 2 => {136 2 => {131 // Create multiple items137 // Create multiple items132 let mut env = env.buf_in_buf_out();138 let mut env = env.buf_in_buf_out();133 let input: NFTExtCreateMultipleItems<E> = env.read_as()?;139 let input: NFTExtCreateMultipleItems<AccountIdOf<C>> = env.read_as()?;134 env.charge_weight(NftWeightInfoOf::<C>::create_item(140 env.charge_weight(NftWeightInfoOf::<C>::create_item(135 input.data.iter().map(|i| i.data_size()).sum(),141 input.data.iter().map(|i| i.data_size()).sum(),136 ))?;142 ))?;141 &C::CrossAccountId::from_sub(env.ext().address().clone()),147 &C::CrossAccountId::from_sub(env.ext().address().clone()),142 &collection,148 &collection,143 &C::CrossAccountId::from_sub(input.owner),149 &C::CrossAccountId::from_sub(input.owner),144 input.data,150 input.data.into_inner(),145 )?;151 )?;146152147 pallet_nft::Module::<C>::submit_logs(collection)?;153 collection.submit_logs()?;148 Ok(RetVal::Converging(0))154 Ok(RetVal::Converging(0))149 }155 }150 3 => {156 3 => {151 // Approve157 // Approve152 let mut env = env.buf_in_buf_out();158 let mut env = env.buf_in_buf_out();153 let input: NFTExtApprove<E> = env.read_as()?;159 let input: NFTExtApprove<AccountIdOf<C>> = env.read_as()?;154 env.charge_weight(NftWeightInfoOf::<C>::approve())?;160 env.charge_weight(NftWeightInfoOf::<C>::approve())?;155161156 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;162 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;163 input.amount,169 input.amount,164 )?;170 )?;165171166 pallet_nft::Module::<C>::submit_logs(collection)?;172 collection.submit_logs()?;167 Ok(RetVal::Converging(0))173 Ok(RetVal::Converging(0))168 }174 }169 4 => {175 4 => {170 // Transfer from176 // Transfer from171 let mut env = env.buf_in_buf_out();177 let mut env = env.buf_in_buf_out();172 let input: NFTExtTransferFrom<E> = env.read_as()?;178 let input: NFTExtTransferFrom<AccountIdOf<C>> = env.read_as()?;173 env.charge_weight(NftWeightInfoOf::<C>::transfer_from())?;179 env.charge_weight(NftWeightInfoOf::<C>::transfer_from())?;174180175 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;181 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;183 input.amount,189 input.amount,184 )?;190 )?;185191186 pallet_nft::Module::<C>::submit_logs(collection)?;192 collection.submit_logs()?;187 Ok(RetVal::Converging(0))193 Ok(RetVal::Converging(0))188 }194 }189 5 => {195 5 => {198 &C::CrossAccountId::from_sub(env.ext().address().clone()),204 &C::CrossAccountId::from_sub(env.ext().address().clone()),199 &collection,205 &collection,200 input.item_id,206 input.item_id,201 input.data,207 input.data.into_inner(),202 )?;208 )?;203209204 pallet_nft::Module::<C>::submit_logs(collection)?;210 collection.submit_logs()?;205 Ok(RetVal::Converging(0))211 Ok(RetVal::Converging(0))206 }212 }207 6 => {213 6 => {208 // Toggle whitelist214 // Toggle whitelist209 let mut env = env.buf_in_buf_out();215 let mut env = env.buf_in_buf_out();210 let input: NFTExtToggleWhiteList<E> = env.read_as()?;216 let input: NFTExtToggleWhiteList<AccountIdOf<C>> = env.read_as()?;211 env.charge_weight(NftWeightInfoOf::<C>::add_to_white_list())?;217 env.charge_weight(NftWeightInfoOf::<C>::add_to_white_list())?;212218213 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;219 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;219 input.whitelisted,225 input.whitelisted,220 )?;226 )?;221227222 pallet_nft::Module::<C>::submit_logs(collection)?;228 collection.submit_logs()?;223 Ok(RetVal::Converging(0))229 Ok(RetVal::Converging(0))224 }230 }225 _ => Err(DispatchError::Other("unknown chain_extension func_id")),231 _ => Err(DispatchError::Other("unknown chain_extension func_id")),runtime/src/lib.rsdiffbeforeafterboth72use sp_runtime::{72use sp_runtime::{73 traits::{Dispatchable},73 traits::{Dispatchable},74};74};75// use pallet_contracts::chain_extension::UncheckedFrom;767577// pub use pallet_timestamp::Call as TimestampCall;76// pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;77pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;379 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE378 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE380}379}381380382/*381/*383parameter_types! {382parameter_types! {384 pub TombstoneDeposit: Balance = deposit(383 pub TombstoneDeposit: Balance = deposit(385 1,384 1,386 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,385 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,387 );386 );388 pub DepositPerContract: Balance = TombstoneDeposit::get();387 pub DepositPerContract: Balance = TombstoneDeposit::get();389 pub const DepositPerStorageByte: Balance = deposit(0, 1);388 pub const DepositPerStorageByte: Balance = deposit(0, 1);390 pub const DepositPerStorageItem: Balance = deposit(1, 0);389 pub const DepositPerStorageItem: Balance = deposit(1, 0);391 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);390 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);392 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;391 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;393 pub const SignedClaimHandicap: u32 = 2;392 pub const SignedClaimHandicap: u32 = 2;394 pub const MaxDepth: u32 = 32;393 pub const MaxDepth: u32 = 32;395 pub const MaxValueSize: u32 = 16 * 1024;394 pub const MaxValueSize: u32 = 16 * 1024;396 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb395 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb397 // The lazy deletion runs inside on_initialize.396 // The lazy deletion runs inside on_initialize.398 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *397 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *399 RuntimeBlockWeights::get().max_block;398 RuntimeBlockWeights::get().max_block;400 // The weight needed for decoding the queue should be less or equal than a fifth399 // The weight needed for decoding the queue should be less or equal than a fifth401 // of the overall weight dedicated to the lazy deletion.400 // of the overall weight dedicated to the lazy deletion.402 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (401 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (403 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -402 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -404 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)403 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)405 )) / 5) as u32;404 )) / 5) as u32;406 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();405 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();407}406}408407409impl pallet_contracts::Config for Runtime {408impl pallet_contracts::Config for Runtime {410 type Time = Timestamp;409 type Time = Timestamp;411 type Randomness = RandomnessCollectiveFlip;410 type Randomness = RandomnessCollectiveFlip;412 type Currency = Balances;411 type Currency = Balances;413 type Event = Event;412 type Event = Event;414 type RentPayment = ();413 type RentPayment = ();415 type SignedClaimHandicap = SignedClaimHandicap;414 type SignedClaimHandicap = SignedClaimHandicap;416 type TombstoneDeposit = TombstoneDeposit;415 type TombstoneDeposit = TombstoneDeposit;417 type DepositPerContract = DepositPerContract;416 type DepositPerContract = DepositPerContract;418 type DepositPerStorageByte = DepositPerStorageByte;417 type DepositPerStorageByte = DepositPerStorageByte;419 type DepositPerStorageItem = DepositPerStorageItem;418 type DepositPerStorageItem = DepositPerStorageItem;420 type RentFraction = RentFraction;419 type RentFraction = RentFraction;421 type SurchargeReward = SurchargeReward;420 type SurchargeReward = SurchargeReward;422 type WeightPrice = pallet_transaction_payment::Module<Self>;421 type WeightPrice = pallet_transaction_payment::Pallet<Self>;423 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;422 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;424 type ChainExtension = NFTExtension;423 type ChainExtension = NFTExtension;425 type DeletionQueueDepth = DeletionQueueDepth;424 type DeletionQueueDepth = DeletionQueueDepth;426 type DeletionWeightLimit = DeletionWeightLimit;425 type DeletionWeightLimit = DeletionWeightLimit;427 type Schedule = Schedule;426 type Schedule = Schedule;428 type CallStack = [pallet_contracts::Frame<Self>; 31];427 type CallStack = [pallet_contracts::Frame<Self>; 31];429}428}430*/429*/431430432parameter_types! {431parameter_types! {433 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer432 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer