difftreelog
Small fixes
in: master
2 files changed
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -942,10 +942,10 @@
#[transactional]
pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {
- let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
+ let sender = ensure_signed(origin)?;
let mut target_collection = Self::get_collection(collection_id)?;
- Self::check_owner_permissions(&target_collection, sender.as_sub())?;
+ Self::check_owner_permissions(&target_collection, &sender)?;
target_collection.transfers_enabled = value;
Self::save_collection(target_collection);
pallets/nft/src/mock.rsdiffbeforeafterboth1#![allow(clippy::from_over_into)]23use crate as pallet_template;4use sp_core::H256;5use frame_support::{parameter_types, weights::IdentityFee};6use sp_runtime::{7 traits::{BlakeTwo256, IdentityLookup},8 testing::Header,9 Perbill,10};11use pallet_transaction_payment::{CurrencyAdapter};12use frame_system as system;13use pallet_evm::AddressMapping;14use crate::{EvmBackwardsAddressMapping, CrossAccountId};15use codec::{Encode, Decode};1617type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;18type Block = frame_system::mocking::MockBlock<Test>;1920// Configure a mock runtime to test the pallet.21frame_support::construct_runtime!(22 pub enum Test where23 Block = Block,24 NodeBlock = Block,25 UncheckedExtrinsic = UncheckedExtrinsic,26 {27 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},28 TemplateModule: pallet_template::{Pallet, Call, Storage},29 Balances: pallet_balances::{Pallet, Call, Storage},30 }31);3233parameter_types! {34 pub const BlockHashCount: u64 = 250;35 pub const SS58Prefix: u8 = 42;36}3738impl system::Config for Test {39 type BaseCallFilter = ();40 type BlockWeights = ();41 type BlockLength = ();42 type DbWeight = ();43 type Origin = Origin;44 type Call = Call;45 type Index = u64;46 type BlockNumber = u64;47 type Hash = H256;48 type Hashing = BlakeTwo256;49 type AccountId = u64;50 type Lookup = IdentityLookup<Self::AccountId>;51 type Header = Header;52 type Event = ();53 type BlockHashCount = BlockHashCount;54 type Version = ();55 type PalletInfo = PalletInfo;56 type AccountData = pallet_balances::AccountData<u64>;57 type OnNewAccount = ();58 type OnKilledAccount = ();59 type SystemWeightInfo = ();60 type SS58Prefix = SS58Prefix;61 type OnSetCode = ();62}6364parameter_types! {65 pub const ExistentialDeposit: u64 = 1;66 pub const MaxLocks: u32 = 50;67}68//frame_system::Module<Test>;69impl pallet_balances::Config for Test {70 type AccountStore = System;71 type Balance = u64;72 type DustRemoval = ();73 type Event = ();74 type ExistentialDeposit = ExistentialDeposit;75 type WeightInfo = ();76 type MaxLocks = MaxLocks;77 type MaxReserves = ();78 type ReserveIdentifier = [u8; 8];79}8081parameter_types! {82 pub const TransactionByteFee: u64 = 1;83}8485impl pallet_transaction_payment::Config for Test {86 type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;87 type TransactionByteFee = TransactionByteFee;88 type WeightToFee = IdentityFee<u64>;89 type FeeMultiplierUpdate = ();90}9192parameter_types! {93 pub const MinimumPeriod: u64 = 1;94}95impl pallet_timestamp::Config for Test {96 type Moment = u64;97 type OnTimestampSet = ();98 type MinimumPeriod = MinimumPeriod;99 type WeightInfo = ();100}101102type Timestamp = pallet_timestamp::Pallet<Test>;103type Randomness = pallet_randomness_collective_flip::Pallet<Test>;104105// parameter_types! {106// pub const TombstoneDeposit: u64 = 1;107// pub const DepositPerContract: u64 = 1;108// pub const DepositPerStorageByte: u64 = 1;109// pub const DepositPerStorageItem: u64 = 1;110// pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * 24 * 60 * 10);111// pub const SurchargeReward: u64 = 1;112// pub const SignedClaimHandicap: u32 = 2;113// pub DeletionWeightLimit: u64 = u64::MAX;//Perbill::from_percent(10);114// pub DeletionQueueDepth: u32 = 10;115// pub Schedule: pallet_contracts::Schedule<Test> = Default::default();116// }117118// impl pallet_contracts::Config for Test {119// type Time = Timestamp;120// type Randomness = Randomness;121// type Currency = pallet_balances::Pallet<Test>;122// type Event = ();123// type RentPayment = ();124// type SignedClaimHandicap = SignedClaimHandicap;125// type TombstoneDeposit = TombstoneDeposit;126// type DepositPerContract = DepositPerContract;127// type DepositPerStorageByte = DepositPerStorageByte;128// type DepositPerStorageItem = DepositPerStorageItem;129// type RentFraction = RentFraction;130// type SurchargeReward = SurchargeReward;131// type DeletionWeightLimit = DeletionWeightLimit;132// type DeletionQueueDepth = DeletionQueueDepth;133// type ChainExtension = ();134// type WeightPrice = ();135// type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;136// type Schedule = Schedule;137// type CallStack = [pallet_contracts::Frame<Self>; 31];138// }139140parameter_types! {141 pub const CollectionCreationPrice: u32 = 0;142 pub TreasuryAccountId: u64 = 1234;143 pub EthereumChainId: u32 = 1111;144}145146pub struct TestEvmAddressMapping;147impl AddressMapping<u64> for TestEvmAddressMapping {148 fn into_account_id(_addr: sp_core::H160) -> u64 {149 unimplemented!()150 }151}152153pub struct TestEvmBackwardsAddressMapping;154impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {155 fn from_account_id(_account_id: u64) -> sp_core::H160 {156 unimplemented!()157 }158}159160#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]161pub struct TestCrossAccountId(u64, sp_core::H160);162impl CrossAccountId<u64> for TestCrossAccountId {163 fn from_sub(sub: u64) -> Self {164 let mut eth = [0; 20];165 eth[12..20].copy_from_slice(&sub.to_be_bytes());166 Self(sub, sp_core::H160(eth))167 }168 fn as_sub(&self) -> &u64 {169 &self.0170 }171 fn from_eth(_eth: sp_core::H160) -> Self {172 unimplemented!()173 }174 fn as_eth(&self) -> &sp_core::H160 {175 &self.1176 }177}178179pub struct TestEtheremTransactionSender;180impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {181 fn submit_logs_transaction(182 _tx: pallet_ethereum::Transaction,183 _logs: Vec<pallet_ethereum::Log>,184 ) -> Result<(), sp_runtime::DispatchError> {185 Ok(())186 }187}188189impl pallet_template::Config for Test {190 type Event = ();191 type WeightInfo = ();192 type CollectionCreationPrice = CollectionCreationPrice;193 type Currency = pallet_balances::Pallet<Test>;194 type TreasuryAccountId = TreasuryAccountId;195 type EvmAddressMapping = TestEvmAddressMapping;196 type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;197 type CrossAccountId = TestCrossAccountId;198 type EthereumChainId = EthereumChainId;199 type EthereumTransactionSender = TestEtheremTransactionSender;200}201202// Build genesis storage according to the mock runtime.203pub fn new_test_ext() -> sp_io::TestExternalities {204 system::GenesisConfig::default()205 .build_storage::<Test>()206 .unwrap()207 .into()208}1#![allow(clippy::from_over_into)]23use crate as pallet_template;4use sp_core::H256;5use frame_support::{parameter_types, weights::IdentityFee};6use sp_runtime::{7 traits::{BlakeTwo256, IdentityLookup},8 testing::Header,9 Perbill,10};11use pallet_transaction_payment::{CurrencyAdapter};12use frame_system as system;13use pallet_evm::AddressMapping;14use crate::{EvmBackwardsAddressMapping, CrossAccountId};15use codec::{Encode, Decode};1617type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;18type Block = frame_system::mocking::MockBlock<Test>;1920// Configure a mock runtime to test the pallet.21frame_support::construct_runtime!(22 pub enum Test where23 Block = Block,24 NodeBlock = Block,25 UncheckedExtrinsic = UncheckedExtrinsic,26 {27 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},28 TemplateModule: pallet_template::{Pallet, Call, Storage},29 Balances: pallet_balances::{Pallet, Call, Storage},30 }31);3233parameter_types! {34 pub const BlockHashCount: u64 = 250;35 pub const SS58Prefix: u8 = 42;36}3738impl system::Config for Test {39 type BaseCallFilter = ();40 type BlockWeights = ();41 type BlockLength = ();42 type DbWeight = ();43 type Origin = Origin;44 type Call = Call;45 type Index = u64;46 type BlockNumber = u64;47 type Hash = H256;48 type Hashing = BlakeTwo256;49 type AccountId = u64;50 type Lookup = IdentityLookup<Self::AccountId>;51 type Header = Header;52 type Event = ();53 type BlockHashCount = BlockHashCount;54 type Version = ();55 type PalletInfo = PalletInfo;56 type AccountData = pallet_balances::AccountData<u64>;57 type OnNewAccount = ();58 type OnKilledAccount = ();59 type SystemWeightInfo = ();60 type SS58Prefix = SS58Prefix;61 type OnSetCode = ();62}6364parameter_types! {65 pub const ExistentialDeposit: u64 = 1;66 pub const MaxLocks: u32 = 50;67}68//frame_system::Module<Test>;69impl pallet_balances::Config for Test {70 type AccountStore = System;71 type Balance = u64;72 type DustRemoval = ();73 type Event = ();74 type ExistentialDeposit = ExistentialDeposit;75 type WeightInfo = ();76 type MaxLocks = MaxLocks;77 type MaxReserves = ();78 type ReserveIdentifier = [u8; 8];79}8081parameter_types! {82 pub const TransactionByteFee: u64 = 1;83}8485impl pallet_transaction_payment::Config for Test {86 type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;87 type TransactionByteFee = TransactionByteFee;88 type WeightToFee = IdentityFee<u64>;89 type FeeMultiplierUpdate = ();90}9192parameter_types! {93 pub const MinimumPeriod: u64 = 1;94}95impl pallet_timestamp::Config for Test {96 type Moment = u64;97 type OnTimestampSet = ();98 type MinimumPeriod = MinimumPeriod;99 type WeightInfo = ();100}101102type Timestamp = pallet_timestamp::Pallet<Test>;103type Randomness = pallet_randomness_collective_flip::Pallet<Test>;104105parameter_types! {106 pub const CollectionCreationPrice: u32 = 0;107 pub TreasuryAccountId: u64 = 1234;108 pub EthereumChainId: u32 = 1111;109}110111pub struct TestEvmAddressMapping;112impl AddressMapping<u64> for TestEvmAddressMapping {113 fn into_account_id(_addr: sp_core::H160) -> u64 {114 unimplemented!()115 }116}117118pub struct TestEvmBackwardsAddressMapping;119impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {120 fn from_account_id(_account_id: u64) -> sp_core::H160 {121 unimplemented!()122 }123}124125#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]126pub struct TestCrossAccountId(u64, sp_core::H160);127impl CrossAccountId<u64> for TestCrossAccountId {128 fn from_sub(sub: u64) -> Self {129 let mut eth = [0; 20];130 eth[12..20].copy_from_slice(&sub.to_be_bytes());131 Self(sub, sp_core::H160(eth))132 }133 fn as_sub(&self) -> &u64 {134 &self.0135 }136 fn from_eth(_eth: sp_core::H160) -> Self {137 unimplemented!()138 }139 fn as_eth(&self) -> &sp_core::H160 {140 &self.1141 }142}143144pub struct TestEtheremTransactionSender;145impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {146 fn submit_logs_transaction(147 _tx: pallet_ethereum::Transaction,148 _logs: Vec<pallet_ethereum::Log>,149 ) -> Result<(), sp_runtime::DispatchError> {150 Ok(())151 }152}153154impl pallet_template::Config for Test {155 type Event = ();156 type WeightInfo = ();157 type CollectionCreationPrice = CollectionCreationPrice;158 type Currency = pallet_balances::Pallet<Test>;159 type TreasuryAccountId = TreasuryAccountId;160 type EvmAddressMapping = TestEvmAddressMapping;161 type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;162 type CrossAccountId = TestCrossAccountId;163 type EthereumChainId = EthereumChainId;164 type EthereumTransactionSender = TestEtheremTransactionSender;165}166167// Build genesis storage according to the mock runtime.168pub fn new_test_ext() -> sp_io::TestExternalities {169 system::GenesisConfig::default()170 .build_storage::<Test>()171 .unwrap()172 .into()173}