diff --git a/blockchain/modules/nft/src/benchmarking.rs b/blockchain/modules/nft/src/benchmarking.rs
index d9939890..f10f5b2c 100644
--- a/blockchain/modules/nft/src/benchmarking.rs
+++ b/blockchain/modules/nft/src/benchmarking.rs
@@ -1,330 +1,330 @@
-// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
-
-// This file is part of Setheum.
-
-// Copyright (C) 2019-Present Setheum Labs.
-// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-//! Benchmarks for the nft module.
-
-#![cfg(feature = "runtime-benchmarks")]
-
-use sp_std::vec;
-
-use frame_benchmarking::{account, benchmarks};
-use frame_support::{dispatch::DispatchClass, dispatch::DispatchErrorWithPostInfo, traits::Get};
-use frame_system::RawOrigin;
-use sp_runtime::traits::{AccountIdConversion, StaticLookup, UniqueSaturatedInto};
-use sp_std::collections::btree_map::BTreeMap;
-
-pub use crate::*;
-use primitives::Balance;
-
-pub struct Module(crate::Pallet);
-
-const SEED: u32 = 0;
-
-fn dollar(d: u32) -> Balance {
- let d: Balance = d.into();
- d.saturating_mul(1_000_000_000_000_000_000)
-}
-
-fn test_attr() -> Attributes {
- let mut attr: Attributes = BTreeMap::new();
- for i in 0..30 {
- attr.insert(vec![i], vec![0; 64]);
- }
- attr
-}
-
-fn create_token_class(caller: T::AccountId) -> Result {
- let base_currency_amount = dollar(1000);
- ::Currency::make_free_balance_be(&caller, base_currency_amount.unique_saturated_into());
-
- let module_account: T::AccountId =
- T::PalletId::get().into_sub_account_truncating(orml_nft::Pallet::::next_class_id());
- crate::Pallet::::create_class(
- RawOrigin::Signed(caller).into(),
- vec![1],
- Properties(
- ClassProperty::Transferable
- | ClassProperty::Burnable
- | ClassProperty::Mintable
- | ClassProperty::ClassPropertiesMutable,
- ),
- test_attr(),
- )?;
-
- ::Currency::make_free_balance_be(
- &module_account,
- base_currency_amount.unique_saturated_into(),
- );
-
- Ok(module_account)
-}
-
-benchmarks! {
- // create NFT class
- create_class {
- let caller: T::AccountId = account("caller", 0, SEED);
- let base_currency_amount = dollar(1000);
-
- ::Currency::make_free_balance_be(&caller, base_currency_amount.unique_saturated_into());
- }: _(RawOrigin::Signed(caller), vec![1], Properties(ClassProperty::Transferable | ClassProperty::Burnable), test_attr())
-
- // mint NFT token
- mint {
- let i in 1 .. 1000;
-
- let caller: T::AccountId = account("caller", 0, SEED);
- let to: T::AccountId = account("to", 0, SEED);
- let to_lookup = T::Lookup::unlookup(to);
-
- let module_account = create_token_class::(caller)?;
- }: _(RawOrigin::Signed(module_account), to_lookup, 0u32.into(), vec![1], test_attr(), i)
-
- // transfer NFT token to another account
- transfer {
- let caller: T::AccountId = account("caller", 0, SEED);
- let caller_lookup = T::Lookup::unlookup(caller.clone());
- let to: T::AccountId = account("to", 0, SEED);
- let to_lookup = T::Lookup::unlookup(to.clone());
-
- let module_account = create_token_class::(caller)?;
-
- crate::Pallet::::mint(RawOrigin::Signed(module_account).into(), to_lookup, 0u32.into(), vec![1], test_attr(), 1)?;
- }: _(RawOrigin::Signed(to), caller_lookup, (0u32.into(), 0u32.into()))
-
- // burn NFT token
- burn {
- let caller: T::AccountId = account("caller", 0, SEED);
- let to: T::AccountId = account("to", 0, SEED);
- let to_lookup = T::Lookup::unlookup(to.clone());
-
- let module_account = create_token_class::(caller)?;
-
- crate::Pallet::::mint(RawOrigin::Signed(module_account).into(), to_lookup, 0u32.into(), vec![1], test_attr(), 1)?;
- }: _(RawOrigin::Signed(to), (0u32.into(), 0u32.into()))
-
- // burn NFT token with remark
- burn_with_remark {
- let b in 0 .. *T::BlockLength::get().max.get(DispatchClass::Normal) as u32;
- let remark_message = vec![1; b as usize];
- let caller: T::AccountId = account("caller", 0, SEED);
- let to: T::AccountId = account("to", 0, SEED);
- let to_lookup = T::Lookup::unlookup(to.clone());
-
- let module_account = create_token_class::(caller)?;
-
- crate::Pallet::::mint(RawOrigin::Signed(module_account).into(), to_lookup, 0u32.into(), vec![1], test_attr(), 1)?;
- }: _(RawOrigin::Signed(to), (0u32.into(), 0u32.into()), remark_message)
-
- // destroy NFT class
- destroy_class {
- let caller: T::AccountId = account("caller", 0, SEED);
- let caller_lookup = T::Lookup::unlookup(caller.clone());
-
- let base_currency_amount = dollar(1000);
-
- let module_account = create_token_class::(caller)?;
-
- }: _(RawOrigin::Signed(module_account), 0u32.into(), caller_lookup)
-
- update_class_properties {
- let caller: T::AccountId = account("caller", 0, SEED);
- let to: T::AccountId = account("to", 0, SEED);
- let to_lookup = T::Lookup::unlookup(to);
-
- let module_account = create_token_class::(caller)?;
- }: _(RawOrigin::Signed(module_account), 0u32.into(), Properties(ClassProperty::Transferable.into()))
-}
-
-#[cfg(test)]
-mod mock {
- use super::*;
- use crate as nft;
-
- use frame_support::{
- parameter_types,
- traits::{ConstU128, ConstU32, ConstU64, Contains, InstanceFilter},
- PalletId,
- };
- use parity_scale_codec::{Decode, Encode};
- use sp_core::{crypto::AccountId32, H256};
- use sp_runtime::{
- traits::{BlakeTwo256, IdentityLookup},
- BuildStorage, RuntimeDebug,
- };
-
- pub type AccountId = AccountId32;
-
- impl frame_system::Config for Runtime {
- type BaseCallFilter = BaseFilter;
- type RuntimeOrigin = RuntimeOrigin;
- type Nonce = u64;
- type Hash = H256;
- type RuntimeCall = RuntimeCall;
- type Hashing = BlakeTwo256;
- type AccountId = AccountId;
- type Lookup = IdentityLookup;
- type Block = Block;
- type RuntimeEvent = ();
- type BlockHashCount = ConstU64<250>;
- type BlockWeights = ();
- type BlockLength = ();
- type DbWeight = ();
- type Version = ();
- type PalletInfo = PalletInfo;
- type AccountData = pallet_balances::AccountData;
- type OnNewAccount = ();
- type OnKilledAccount = ();
- type SystemWeightInfo = ();
- type SS58Prefix = ();
- type OnSetCode = ();
- type MaxConsumers = ConstU32<16>;
- }
- impl pallet_balances::Config for Runtime {
- type Balance = Balance;
- type RuntimeEvent = ();
- type DustRemoval = ();
- type ExistentialDeposit = ConstU128<1>;
- type AccountStore = frame_system::Pallet;
- type MaxLocks = ();
- type MaxReserves = ConstU32<50>;
- type ReserveIdentifier = ReserveIdentifier;
- type WeightInfo = ();
- type RuntimeHoldReason = RuntimeHoldReason;
- type RuntimeFreezeReason = RuntimeFreezeReason;
- type FreezeIdentifier = ();
- type MaxHolds = ();
- type MaxFreezes = ();
- }
- impl pallet_utility::Config for Runtime {
- type RuntimeEvent = ();
- type RuntimeCall = RuntimeCall;
- type PalletsOrigin = OriginCaller;
- type WeightInfo = ();
- }
- #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)]
- pub enum ProxyType {
- Any,
- JustTransfer,
- JustUtility,
- }
- impl Default for ProxyType {
- fn default() -> Self {
- Self::Any
- }
- }
- impl InstanceFilter for ProxyType {
- fn filter(&self, c: &RuntimeCall) -> bool {
- match self {
- ProxyType::Any => true,
- ProxyType::JustTransfer => matches!(
- c,
- RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. })
- ),
- ProxyType::JustUtility => matches!(c, RuntimeCall::Utility(..)),
- }
- }
- fn is_superset(&self, o: &Self) -> bool {
- self == &ProxyType::Any || self == o
- }
- }
- pub struct BaseFilter;
- impl Contains for BaseFilter {
- fn contains(c: &RuntimeCall) -> bool {
- match *c {
- // Remark is used as a no-op call in the benchmarking
- RuntimeCall::System(SystemCall::remark { .. }) => true,
- RuntimeCall::System(_) => false,
- _ => true,
- }
- }
- }
- impl pallet_proxy::Config for Runtime {
- type RuntimeEvent = ();
- type RuntimeCall = RuntimeCall;
- type Currency = Balances;
- type ProxyType = ProxyType;
- type ProxyDepositBase = ConstU128<1>;
- type ProxyDepositFactor = ConstU128<1>;
- type MaxProxies = ConstU32<4>;
- type WeightInfo = ();
- type CallHasher = BlakeTwo256;
- type MaxPending = ConstU32<2>;
- type AnnouncementDepositBase = ConstU128<1>;
- type AnnouncementDepositFactor = ConstU128<1>;
- }
-
- parameter_types! {
- pub const NftPalletId: PalletId = PalletId(*b"aca/aNFT");
- }
-
- impl crate::Config for Runtime {
- type RuntimeEvent = ();
- type Currency = Balances;
- type CreateClassDeposit = ConstU128<200>;
- type CreateTokenDeposit = ConstU128<100>;
- type DataDepositPerByte = ConstU128<10>;
- type PalletId = NftPalletId;
- type MaxAttributesBytes = ConstU32<2048>;
- type WeightInfo = ();
- }
-
- impl orml_nft::Config for Runtime {
- type ClassId = u32;
- type TokenId = u64;
- type ClassData = ClassData;
- type TokenData = TokenData;
- type MaxClassMetadata = ConstU32<1024>;
- type MaxTokenMetadata = ConstU32<1024>;
- }
-
- type Block = frame_system::mocking::MockBlock;
-
- frame_support::construct_runtime!(
- pub enum Runtime {
- System: frame_system,
- Utility: pallet_utility,
- Balances: pallet_balances,
- Proxy: pallet_proxy,
- OrmlNFT: orml_nft,
- NFT: nft,
- }
- );
-
- use frame_system::Call as SystemCall;
-
- pub fn new_test_ext() -> sp_io::TestExternalities {
- let t = frame_system::GenesisConfig::::default()
- .build_storage()
- .unwrap();
-
- let mut ext = sp_io::TestExternalities::new(t);
- ext.execute_with(|| System::set_block_number(1));
- ext
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::mock::*;
- use super::*;
- use frame_benchmarking::impl_benchmark_test_suite;
-
- impl_benchmark_test_suite!(Pallet, super::new_test_ext(), super::Runtime,);
-}
+// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
+
+// This file is part of Setheum.
+
+// Copyright (C) 2019-Present Setheum Labs.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+//! Benchmarks for the nft module.
+
+#![cfg(feature = "runtime-benchmarks")]
+
+use sp_std::vec;
+
+use frame_benchmarking::{account, benchmarks};
+use frame_support::{dispatch::DispatchClass, dispatch::DispatchErrorWithPostInfo, traits::Get};
+use frame_system::RawOrigin;
+use sp_runtime::traits::{AccountIdConversion, StaticLookup, UniqueSaturatedInto};
+use sp_std::collections::btree_map::BTreeMap;
+
+pub use crate::*;
+use primitives::Balance;
+
+pub struct Module(crate::Pallet);
+
+const SEED: u32 = 0;
+
+fn dollar(d: u32) -> Balance {
+ let d: Balance = d.into();
+ d.saturating_mul(1_000_000_000_000_000_000)
+}
+
+fn test_attr() -> Attributes {
+ let mut attr: Attributes = BTreeMap::new();
+ for i in 0..30 {
+ attr.insert(vec![i], vec![0; 64]);
+ }
+ attr
+}
+
+fn create_token_class(caller: T::AccountId) -> Result {
+ let base_currency_amount = dollar(1000);
+ ::Currency::make_free_balance_be(&caller, base_currency_amount.unique_saturated_into());
+
+ let module_account: T::AccountId =
+ T::PalletId::get().into_sub_account_truncating(orml_nft::Pallet::::next_class_id());
+ crate::Pallet::::create_class(
+ RawOrigin::Signed(caller).into(),
+ vec![1],
+ Properties(
+ ClassProperty::Transferable
+ | ClassProperty::Burnable
+ | ClassProperty::Mintable
+ | ClassProperty::ClassPropertiesMutable,
+ ),
+ test_attr(),
+ )?;
+
+ ::Currency::make_free_balance_be(
+ &module_account,
+ base_currency_amount.unique_saturated_into(),
+ );
+
+ Ok(module_account)
+}
+
+benchmarks! {
+ // create NFT class
+ create_class {
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let base_currency_amount = dollar(1000);
+
+ ::Currency::make_free_balance_be(&caller, base_currency_amount.unique_saturated_into());
+ }: _(RawOrigin::Signed(caller), vec![1], Properties(ClassProperty::Transferable | ClassProperty::Burnable), test_attr())
+
+ // mint NFT token
+ mint {
+ let i in 1 .. 1000;
+
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let to: T::AccountId = account("to", 0, SEED);
+ let to_lookup = T::Lookup::unlookup(to);
+
+ let module_account = create_token_class::(caller)?;
+ }: _(RawOrigin::Signed(module_account), to_lookup, 0u32.into(), vec![1], test_attr(), i)
+
+ // transfer NFT token to another account
+ transfer {
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let caller_lookup = T::Lookup::unlookup(caller.clone());
+ let to: T::AccountId = account("to", 0, SEED);
+ let to_lookup = T::Lookup::unlookup(to.clone());
+
+ let module_account = create_token_class::(caller)?;
+
+ crate::Pallet::::mint(RawOrigin::Signed(module_account).into(), to_lookup, 0u32.into(), vec![1], test_attr(), 1)?;
+ }: _(RawOrigin::Signed(to), caller_lookup, (0u32.into(), 0u32.into()))
+
+ // burn NFT token
+ burn {
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let to: T::AccountId = account("to", 0, SEED);
+ let to_lookup = T::Lookup::unlookup(to.clone());
+
+ let module_account = create_token_class::(caller)?;
+
+ crate::Pallet::::mint(RawOrigin::Signed(module_account).into(), to_lookup, 0u32.into(), vec![1], test_attr(), 1)?;
+ }: _(RawOrigin::Signed(to), (0u32.into(), 0u32.into()))
+
+ // burn NFT token with remark
+ burn_with_remark {
+ let b in 0 .. *T::BlockLength::get().max.get(DispatchClass::Normal) as u32;
+ let remark_message = vec![1; b as usize];
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let to: T::AccountId = account("to", 0, SEED);
+ let to_lookup = T::Lookup::unlookup(to.clone());
+
+ let module_account = create_token_class::(caller)?;
+
+ crate::Pallet::::mint(RawOrigin::Signed(module_account).into(), to_lookup, 0u32.into(), vec![1], test_attr(), 1)?;
+ }: _(RawOrigin::Signed(to), (0u32.into(), 0u32.into()), remark_message)
+
+ // destroy NFT class
+ destroy_class {
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let caller_lookup = T::Lookup::unlookup(caller.clone());
+
+ let base_currency_amount = dollar(1000);
+
+ let module_account = create_token_class::(caller)?;
+
+ }: _(RawOrigin::Signed(module_account), 0u32.into(), caller_lookup)
+
+ update_class_properties {
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let to: T::AccountId = account("to", 0, SEED);
+ let to_lookup = T::Lookup::unlookup(to);
+
+ let module_account = create_token_class::(caller)?;
+ }: _(RawOrigin::Signed(module_account), 0u32.into(), Properties(ClassProperty::Transferable.into()))
+}
+
+#[cfg(test)]
+mod mock {
+ use super::*;
+ use crate as nft;
+
+ use frame_support::{
+ parameter_types,
+ traits::{ConstU128, ConstU32, ConstU64, Contains, InstanceFilter},
+ PalletId,
+ };
+ use parity_scale_codec::{Decode, Encode};
+ use sp_core::{crypto::AccountId32, H256};
+ use sp_runtime::{
+ traits::{BlakeTwo256, IdentityLookup},
+ BuildStorage, RuntimeDebug,
+ };
+
+ pub type AccountId = AccountId32;
+
+ impl frame_system::Config for Runtime {
+ type BaseCallFilter = BaseFilter;
+ type RuntimeOrigin = RuntimeOrigin;
+ type Nonce = u64;
+ type Hash = H256;
+ type RuntimeCall = RuntimeCall;
+ type Hashing = BlakeTwo256;
+ type AccountId = AccountId;
+ type Lookup = IdentityLookup;
+ type Block = Block;
+ type RuntimeEvent = ();
+ type BlockHashCount = ConstU64<250>;
+ type BlockWeights = ();
+ type BlockLength = ();
+ type DbWeight = ();
+ type Version = ();
+ type PalletInfo = PalletInfo;
+ type AccountData = pallet_balances::AccountData;
+ type OnNewAccount = ();
+ type OnKilledAccount = ();
+ type SystemWeightInfo = ();
+ type SS58Prefix = ();
+ type OnSetCode = ();
+ type MaxConsumers = ConstU32<16>;
+ }
+ impl pallet_balances::Config for Runtime {
+ type Balance = Balance;
+ type RuntimeEvent = ();
+ type DustRemoval = ();
+ type ExistentialDeposit = ConstU128<1>;
+ type AccountStore = frame_system::Pallet;
+ type MaxLocks = ();
+ type MaxReserves = ConstU32<50>;
+ type ReserveIdentifier = ReserveIdentifier;
+ type WeightInfo = ();
+ type RuntimeHoldReason = RuntimeHoldReason;
+ type RuntimeFreezeReason = RuntimeFreezeReason;
+ type FreezeIdentifier = ();
+ type MaxHolds = ();
+ type MaxFreezes = ();
+ }
+ impl pallet_utility::Config for Runtime {
+ type RuntimeEvent = ();
+ type RuntimeCall = RuntimeCall;
+ type PalletsOrigin = OriginCaller;
+ type WeightInfo = ();
+ }
+ #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)]
+ pub enum ProxyType {
+ Any,
+ JustTransfer,
+ JustUtility,
+ }
+ impl Default for ProxyType {
+ fn default() -> Self {
+ Self::Any
+ }
+ }
+ impl InstanceFilter for ProxyType {
+ fn filter(&self, c: &RuntimeCall) -> bool {
+ match self {
+ ProxyType::Any => true,
+ ProxyType::JustTransfer => matches!(
+ c,
+ RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. })
+ ),
+ ProxyType::JustUtility => matches!(c, RuntimeCall::Utility(..)),
+ }
+ }
+ fn is_superset(&self, o: &Self) -> bool {
+ self == &ProxyType::Any || self == o
+ }
+ }
+ pub struct BaseFilter;
+ impl Contains for BaseFilter {
+ fn contains(c: &RuntimeCall) -> bool {
+ match *c {
+ // Remark is used as a no-op call in the benchmarking
+ RuntimeCall::System(SystemCall::remark { .. }) => true,
+ RuntimeCall::System(_) => false,
+ _ => true,
+ }
+ }
+ }
+ impl pallet_proxy::Config for Runtime {
+ type RuntimeEvent = ();
+ type RuntimeCall = RuntimeCall;
+ type Currency = Balances;
+ type ProxyType = ProxyType;
+ type ProxyDepositBase = ConstU128<1>;
+ type ProxyDepositFactor = ConstU128<1>;
+ type MaxProxies = ConstU32<4>;
+ type WeightInfo = ();
+ type CallHasher = BlakeTwo256;
+ type MaxPending = ConstU32<2>;
+ type AnnouncementDepositBase = ConstU128<1>;
+ type AnnouncementDepositFactor = ConstU128<1>;
+ }
+
+ parameter_types! {
+ pub const NftPalletId: PalletId = PalletId(*b"set/sNFT");
+ }
+
+ impl crate::Config for Runtime {
+ type RuntimeEvent = ();
+ type Currency = Balances;
+ type CreateClassDeposit = ConstU128<200>;
+ type CreateTokenDeposit = ConstU128<100>;
+ type DataDepositPerByte = ConstU128<10>;
+ type PalletId = NftPalletId;
+ type MaxAttributesBytes = ConstU32<2048>;
+ type WeightInfo = ();
+ }
+
+ impl orml_nft::Config for Runtime {
+ type ClassId = u32;
+ type TokenId = u64;
+ type ClassData = ClassData;
+ type TokenData = TokenData;
+ type MaxClassMetadata = ConstU32<1024>;
+ type MaxTokenMetadata = ConstU32<1024>;
+ }
+
+ type Block = frame_system::mocking::MockBlock;
+
+ frame_support::construct_runtime!(
+ pub enum Runtime {
+ System: frame_system,
+ Utility: pallet_utility,
+ Balances: pallet_balances,
+ Proxy: pallet_proxy,
+ OrmlNFT: orml_nft,
+ NFT: nft,
+ }
+ );
+
+ use frame_system::Call as SystemCall;
+
+ pub fn new_test_ext() -> sp_io::TestExternalities {
+ let t = frame_system::GenesisConfig::::default()
+ .build_storage()
+ .unwrap();
+
+ let mut ext = sp_io::TestExternalities::new(t);
+ ext.execute_with(|| System::set_block_number(1));
+ ext
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::mock::*;
+ use super::*;
+ use frame_benchmarking::impl_benchmark_test_suite;
+
+ impl_benchmark_test_suite!(Pallet, super::new_test_ext(), super::Runtime,);
+}
diff --git a/blockchain/modules/nft/src/mock.rs b/blockchain/modules/nft/src/mock.rs
index 56b68141..e11d9f14 100644
--- a/blockchain/modules/nft/src/mock.rs
+++ b/blockchain/modules/nft/src/mock.rs
@@ -1,266 +1,266 @@
-// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
-
-// This file is part of Setheum.
-
-// Copyright (C) 2019-Present Setheum Labs.
-// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-#![cfg(test)]
-
-use super::*;
-
-use crate as nft;
-use frame_support::{
- construct_runtime, ord_parameter_types, parameter_types,
- traits::{ConstU128, ConstU32, ConstU64, Contains, InstanceFilter, Nothing},
-};
-use frame_system::EnsureSignedBy;
-use module_support::mocks::MockAddressMapping;
-use orml_traits::parameter_type_with_key;
-use parity_scale_codec::{Decode, Encode};
-use primitives::{Amount, Balance, CurrencyId, ReserveIdentifier, TokenSymbol};
-use sp_core::{crypto::AccountId32, H160, H256};
-use sp_runtime::{
- traits::{BlakeTwo256, IdentityLookup},
- BuildStorage, RuntimeDebug,
-};
-
-pub type AccountId = AccountId32;
-
-impl frame_system::Config for Runtime {
- type BaseCallFilter = BaseFilter;
- type RuntimeOrigin = RuntimeOrigin;
- type Nonce = u64;
- type Hash = H256;
- type RuntimeCall = RuntimeCall;
- type Hashing = BlakeTwo256;
- type AccountId = AccountId;
- type Lookup = IdentityLookup;
- type Block = Block;
- type RuntimeEvent = RuntimeEvent;
- type BlockHashCount = ConstU64<250>;
- type DbWeight = ();
- type BlockWeights = ();
- type BlockLength = ();
- type Version = ();
- type PalletInfo = PalletInfo;
- type AccountData = pallet_balances::AccountData;
- type OnNewAccount = ();
- type OnKilledAccount = ();
- type SystemWeightInfo = ();
- type SS58Prefix = ();
- type OnSetCode = ();
- type MaxConsumers = ConstU32<16>;
-}
-
-impl pallet_balances::Config for Runtime {
- type Balance = Balance;
- type RuntimeEvent = RuntimeEvent;
- type DustRemoval = ();
- type ExistentialDeposit = ConstU128<1>;
- type AccountStore = frame_system::Pallet;
- type MaxLocks = ();
- type MaxReserves = ConstU32<50>;
- type ReserveIdentifier = ReserveIdentifier;
- type WeightInfo = ();
- type RuntimeHoldReason = RuntimeHoldReason;
- type RuntimeFreezeReason = RuntimeFreezeReason;
- type FreezeIdentifier = ();
- type MaxHolds = ();
- type MaxFreezes = ();
-}
-impl pallet_utility::Config for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type RuntimeCall = RuntimeCall;
- type PalletsOrigin = OriginCaller;
- type WeightInfo = ();
-}
-
-#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)]
-pub enum ProxyType {
- Any,
- JustTransfer,
- JustUtility,
-}
-impl Default for ProxyType {
- fn default() -> Self {
- Self::Any
- }
-}
-impl InstanceFilter for ProxyType {
- fn filter(&self, c: &RuntimeCall) -> bool {
- match self {
- ProxyType::Any => true,
- ProxyType::JustTransfer => matches!(
- c,
- RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. })
- ),
- ProxyType::JustUtility => matches!(c, RuntimeCall::Utility { .. }),
- }
- }
- fn is_superset(&self, o: &Self) -> bool {
- self == &ProxyType::Any || self == o
- }
-}
-pub struct BaseFilter;
-impl Contains for BaseFilter {
- fn contains(c: &RuntimeCall) -> bool {
- match *c {
- // Remark is used as a no-op call in the benchmarking
- RuntimeCall::System(SystemCall::remark { .. }) => true,
- RuntimeCall::System(_) => false,
- _ => true,
- }
- }
-}
-
-impl pallet_proxy::Config for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type RuntimeCall = RuntimeCall;
- type Currency = Balances;
- type ProxyType = ProxyType;
- type ProxyDepositBase = ConstU128<1>;
- type ProxyDepositFactor = ConstU128<1>;
- type MaxProxies = ConstU32<4>;
- type WeightInfo = ();
- type CallHasher = BlakeTwo256;
- type MaxPending = ConstU32<2>;
- type AnnouncementDepositBase = ConstU128<1>;
- type AnnouncementDepositFactor = ConstU128<1>;
-}
-
-pub type NativeCurrency = module_currencies::BasicCurrencyAdapter;
-
-parameter_type_with_key! {
- pub ExistentialDeposits: |_currency_id: CurrencyId| -> Balance {
- Default::default()
- };
-}
-
-ord_parameter_types! {
- pub const One: AccountId = ALICE;
-}
-
-impl orml_tokens::Config for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type Balance = Balance;
- type Amount = Amount;
- type CurrencyId = CurrencyId;
- type WeightInfo = ();
- type ExistentialDeposits = ExistentialDeposits;
- type CurrencyHooks = ();
- type MaxLocks = ();
- type MaxReserves = ();
- type ReserveIdentifier = [u8; 8];
- type DustRemovalWhitelist = Nothing;
-}
-
-pub const NATIVE_CURRENCY_ID: CurrencyId = CurrencyId::Token(TokenSymbol::SEE);
-
-parameter_types! {
- pub const GetNativeCurrencyId: CurrencyId = NATIVE_CURRENCY_ID;
- pub Erc20HoldingAccount: H160 = H160::from_low_u64_be(1);
-}
-
-impl module_currencies::Config for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type MultiCurrency = Tokens;
- type NativeCurrency = NativeCurrency;
- type GetNativeCurrencyId = GetNativeCurrencyId;
- type Erc20HoldingAccount = Erc20HoldingAccount;
- type WeightInfo = ();
- type AddressMapping = MockAddressMapping;
- type EVMBridge = ();
- type GasToWeight = ();
- type SweepOrigin = EnsureSignedBy;
- type OnDust = ();
-}
-
-parameter_types! {
- pub const NftPalletId: PalletId = PalletId(*b"aca/aNFT");
-}
-pub const CREATE_CLASS_DEPOSIT: u128 = 200;
-pub const CREATE_TOKEN_DEPOSIT: u128 = 100;
-pub const DATA_DEPOSIT_PER_BYTE: u128 = 10;
-pub const MAX_ATTRIBUTES_BYTES: u32 = 10;
-impl Config for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type Currency = Balances;
- type CreateClassDeposit = ConstU128;
- type CreateTokenDeposit = ConstU128;
- type DataDepositPerByte = ConstU128;
- type PalletId = NftPalletId;
- type MaxAttributesBytes = ConstU32;
- type WeightInfo = ();
-}
-
-impl orml_nft::Config for Runtime {
- type ClassId = u32;
- type TokenId = u64;
- type ClassData = ClassData;
- type TokenData = TokenData;
- type MaxClassMetadata = ConstU32<1024>;
- type MaxTokenMetadata = ConstU32<1024>;
-}
-
-use frame_system::Call as SystemCall;
-
-type Block = frame_system::mocking::MockBlock;
-
-construct_runtime!(
- pub enum Runtime {
- System: frame_system,
- NFTModule: nft,
- OrmlNFT: orml_nft,
- Balances: pallet_balances,
- Proxy: pallet_proxy,
- Utility: pallet_utility,
- Tokens: orml_tokens,
- Currency: module_currencies,
- }
-);
-
-pub const ALICE: AccountId = AccountId::new([1u8; 32]);
-pub const BOB: AccountId = AccountId::new([2u8; 32]);
-pub const CLASS_ID: ::ClassId = 0;
-pub const CLASS_ID_NOT_EXIST: ::ClassId = 1;
-pub const TOKEN_ID: ::TokenId = 0;
-pub const TOKEN_ID_NOT_EXIST: ::TokenId = 1;
-
-pub struct ExtBuilder;
-impl Default for ExtBuilder {
- fn default() -> Self {
- ExtBuilder
- }
-}
-
-impl ExtBuilder {
- pub fn build(self) -> sp_io::TestExternalities {
- let mut t = frame_system::GenesisConfig::::default()
- .build_storage()
- .unwrap();
-
- pallet_balances::GenesisConfig:: {
- balances: vec![(ALICE, 100000)],
- }
- .assimilate_storage(&mut t)
- .unwrap();
-
- let mut ext = sp_io::TestExternalities::new(t);
- ext.execute_with(|| System::set_block_number(1));
- ext
- }
-}
+// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
+
+// This file is part of Setheum.
+
+// Copyright (C) 2019-Present Setheum Labs.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+#![cfg(test)]
+
+use super::*;
+
+use crate as nft;
+use frame_support::{
+ construct_runtime, ord_parameter_types, parameter_types,
+ traits::{ConstU128, ConstU32, ConstU64, Contains, InstanceFilter, Nothing},
+};
+use frame_system::EnsureSignedBy;
+use module_support::mocks::MockAddressMapping;
+use orml_traits::parameter_type_with_key;
+use parity_scale_codec::{Decode, Encode};
+use primitives::{Amount, Balance, CurrencyId, ReserveIdentifier, TokenSymbol};
+use sp_core::{crypto::AccountId32, H160, H256};
+use sp_runtime::{
+ traits::{BlakeTwo256, IdentityLookup},
+ BuildStorage, RuntimeDebug,
+};
+
+pub type AccountId = AccountId32;
+
+impl frame_system::Config for Runtime {
+ type BaseCallFilter = BaseFilter;
+ type RuntimeOrigin = RuntimeOrigin;
+ type Nonce = u64;
+ type Hash = H256;
+ type RuntimeCall = RuntimeCall;
+ type Hashing = BlakeTwo256;
+ type AccountId = AccountId;
+ type Lookup = IdentityLookup;
+ type Block = Block;
+ type RuntimeEvent = RuntimeEvent;
+ type BlockHashCount = ConstU64<250>;
+ type DbWeight = ();
+ type BlockWeights = ();
+ type BlockLength = ();
+ type Version = ();
+ type PalletInfo = PalletInfo;
+ type AccountData = pallet_balances::AccountData;
+ type OnNewAccount = ();
+ type OnKilledAccount = ();
+ type SystemWeightInfo = ();
+ type SS58Prefix = ();
+ type OnSetCode = ();
+ type MaxConsumers = ConstU32<16>;
+}
+
+impl pallet_balances::Config for Runtime {
+ type Balance = Balance;
+ type RuntimeEvent = RuntimeEvent;
+ type DustRemoval = ();
+ type ExistentialDeposit = ConstU128<1>;
+ type AccountStore = frame_system::Pallet;
+ type MaxLocks = ();
+ type MaxReserves = ConstU32<50>;
+ type ReserveIdentifier = ReserveIdentifier;
+ type WeightInfo = ();
+ type RuntimeHoldReason = RuntimeHoldReason;
+ type RuntimeFreezeReason = RuntimeFreezeReason;
+ type FreezeIdentifier = ();
+ type MaxHolds = ();
+ type MaxFreezes = ();
+}
+impl pallet_utility::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type RuntimeCall = RuntimeCall;
+ type PalletsOrigin = OriginCaller;
+ type WeightInfo = ();
+}
+
+#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)]
+pub enum ProxyType {
+ Any,
+ JustTransfer,
+ JustUtility,
+}
+impl Default for ProxyType {
+ fn default() -> Self {
+ Self::Any
+ }
+}
+impl InstanceFilter for ProxyType {
+ fn filter(&self, c: &RuntimeCall) -> bool {
+ match self {
+ ProxyType::Any => true,
+ ProxyType::JustTransfer => matches!(
+ c,
+ RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. })
+ ),
+ ProxyType::JustUtility => matches!(c, RuntimeCall::Utility { .. }),
+ }
+ }
+ fn is_superset(&self, o: &Self) -> bool {
+ self == &ProxyType::Any || self == o
+ }
+}
+pub struct BaseFilter;
+impl Contains for BaseFilter {
+ fn contains(c: &RuntimeCall) -> bool {
+ match *c {
+ // Remark is used as a no-op call in the benchmarking
+ RuntimeCall::System(SystemCall::remark { .. }) => true,
+ RuntimeCall::System(_) => false,
+ _ => true,
+ }
+ }
+}
+
+impl pallet_proxy::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type RuntimeCall = RuntimeCall;
+ type Currency = Balances;
+ type ProxyType = ProxyType;
+ type ProxyDepositBase = ConstU128<1>;
+ type ProxyDepositFactor = ConstU128<1>;
+ type MaxProxies = ConstU32<4>;
+ type WeightInfo = ();
+ type CallHasher = BlakeTwo256;
+ type MaxPending = ConstU32<2>;
+ type AnnouncementDepositBase = ConstU128<1>;
+ type AnnouncementDepositFactor = ConstU128<1>;
+}
+
+pub type NativeCurrency = module_currencies::BasicCurrencyAdapter;
+
+parameter_type_with_key! {
+ pub ExistentialDeposits: |_currency_id: CurrencyId| -> Balance {
+ Default::default()
+ };
+}
+
+ord_parameter_types! {
+ pub const One: AccountId = ALICE;
+}
+
+impl orml_tokens::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type Balance = Balance;
+ type Amount = Amount;
+ type CurrencyId = CurrencyId;
+ type WeightInfo = ();
+ type ExistentialDeposits = ExistentialDeposits;
+ type CurrencyHooks = ();
+ type MaxLocks = ();
+ type MaxReserves = ();
+ type ReserveIdentifier = [u8; 8];
+ type DustRemovalWhitelist = Nothing;
+}
+
+pub const NATIVE_CURRENCY_ID: CurrencyId = CurrencyId::Token(TokenSymbol::SEE);
+
+parameter_types! {
+ pub const GetNativeCurrencyId: CurrencyId = NATIVE_CURRENCY_ID;
+ pub Erc20HoldingAccount: H160 = H160::from_low_u64_be(1);
+}
+
+impl module_currencies::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type MultiCurrency = Tokens;
+ type NativeCurrency = NativeCurrency;
+ type GetNativeCurrencyId = GetNativeCurrencyId;
+ type Erc20HoldingAccount = Erc20HoldingAccount;
+ type WeightInfo = ();
+ type AddressMapping = MockAddressMapping;
+ type EVMBridge = ();
+ type GasToWeight = ();
+ type SweepOrigin = EnsureSignedBy;
+ type OnDust = ();
+}
+
+parameter_types! {
+ pub const NftPalletId: PalletId = PalletId(*b"set/sNFT");
+}
+pub const CREATE_CLASS_DEPOSIT: u128 = 200;
+pub const CREATE_TOKEN_DEPOSIT: u128 = 100;
+pub const DATA_DEPOSIT_PER_BYTE: u128 = 10;
+pub const MAX_ATTRIBUTES_BYTES: u32 = 10;
+impl Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type Currency = Balances;
+ type CreateClassDeposit = ConstU128;
+ type CreateTokenDeposit = ConstU128;
+ type DataDepositPerByte = ConstU128;
+ type PalletId = NftPalletId;
+ type MaxAttributesBytes = ConstU32;
+ type WeightInfo = ();
+}
+
+impl orml_nft::Config for Runtime {
+ type ClassId = u32;
+ type TokenId = u64;
+ type ClassData = ClassData;
+ type TokenData = TokenData;
+ type MaxClassMetadata = ConstU32<1024>;
+ type MaxTokenMetadata = ConstU32<1024>;
+}
+
+use frame_system::Call as SystemCall;
+
+type Block = frame_system::mocking::MockBlock;
+
+construct_runtime!(
+ pub enum Runtime {
+ System: frame_system,
+ NFTModule: nft,
+ OrmlNFT: orml_nft,
+ Balances: pallet_balances,
+ Proxy: pallet_proxy,
+ Utility: pallet_utility,
+ Tokens: orml_tokens,
+ Currency: module_currencies,
+ }
+);
+
+pub const ALICE: AccountId = AccountId::new([1u8; 32]);
+pub const BOB: AccountId = AccountId::new([2u8; 32]);
+pub const CLASS_ID: ::ClassId = 0;
+pub const CLASS_ID_NOT_EXIST: ::ClassId = 1;
+pub const TOKEN_ID: ::TokenId = 0;
+pub const TOKEN_ID_NOT_EXIST: ::TokenId = 1;
+
+pub struct ExtBuilder;
+impl Default for ExtBuilder {
+ fn default() -> Self {
+ ExtBuilder
+ }
+}
+
+impl ExtBuilder {
+ pub fn build(self) -> sp_io::TestExternalities {
+ let mut t = frame_system::GenesisConfig::::default()
+ .build_storage()
+ .unwrap();
+
+ pallet_balances::GenesisConfig:: {
+ balances: vec![(ALICE, 100000)],
+ }
+ .assimilate_storage(&mut t)
+ .unwrap();
+
+ let mut ext = sp_io::TestExternalities::new(t);
+ ext.execute_with(|| System::set_block_number(1));
+ ext
+ }
+}
diff --git a/blockchain/modules/transaction-payment/Cargo.toml b/blockchain/modules/transaction-payment/Cargo.toml
index 754dd3bd..3e8d49eb 100644
--- a/blockchain/modules/transaction-payment/Cargo.toml
+++ b/blockchain/modules/transaction-payment/Cargo.toml
@@ -1,8 +1,8 @@
[package]
name = "module-transaction-payment"
-version = "1.0.0"
+version = "0.9.81"
authors = ["Setheum Labs"]
-edition = "2018"
+edition = "2021"
[dependencies]
serde = { version = "1.0.124", optional = true }
diff --git a/blockchain/modules/transaction-payment/src/lib.rs b/blockchain/modules/transaction-payment/src/lib.rs
index 5be7c161..113f331f 100644
--- a/blockchain/modules/transaction-payment/src/lib.rs
+++ b/blockchain/modules/transaction-payment/src/lib.rs
@@ -53,7 +53,7 @@ use sp_runtime::{
FixedPointNumber, FixedPointOperand, FixedU128, Perquintill,
};
use sp_std::{convert::TryInto, prelude::*, vec};
-use support::{DEXManager, PriceProvider, Ratio, TransactionPayment};
+use support::{SwapDexManager, PriceProvider, Ratio, TransactionPayment};
mod mock;
mod tests;
@@ -258,7 +258,7 @@ pub mod module {
type FeeMultiplierUpdate: MultiplierUpdate;
/// DEX to exchange currencies.
- type DEX: DEXManager;
+ type DEX: SwapDexManager;
/// When swap with DEX, the acceptable max slippage for the price from oracle.
#[pallet::constant]
diff --git a/blockchain/modules/transaction-payment/src/mock.rs b/blockchain/modules/transaction-payment/src/mock.rs
index 3eaa0f86..dc877930 100644
--- a/blockchain/modules/transaction-payment/src/mock.rs
+++ b/blockchain/modules/transaction-payment/src/mock.rs
@@ -317,7 +317,7 @@ ord_parameter_types! {
}
parameter_types! {
- pub const DEXPalletId: PalletId = PalletId(*b"set/sdex");
+ pub const DEXPalletId: PalletId = PalletId(*b"edf/swap");
pub GetExchangeFee: (u32, u32) = (1, 100); // 1%
pub const TradingPathLimit: u32 = 4;
pub GetStableCurrencyExchangeFee: (u32, u32) = (1, 200); // 0.5%