git.delta.rocks / unique-network / refs/commits / ec0960098e79

difftreelog

test upgrade to new polkadot

Yaroslav Bolyukin2022-05-04parent: #9d1133e.patch.diff
in: master

3 files changed

modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -704,45 +704,64 @@
 	use frame_system::{EnsureRoot, EnsureSignedBy};
 	use crate as scheduler;
 
-	mod logger {
-		use super::*;
+	#[frame_support::pallet]
+	pub mod logger {
+		use super::{OriginCaller, OriginTrait};
+		use frame_support::pallet_prelude::*;
+		use frame_system::pallet_prelude::*;
 		use std::cell::RefCell;
 
 		thread_local! {
 			static LOG: RefCell<Vec<(OriginCaller, u32)>> = RefCell::new(Vec::new());
 		}
-		pub trait Config: system::Config {
-			type Event: From<Event> + Into<<Self as system::Config>::Event>;
+		pub fn log() -> Vec<(OriginCaller, u32)> {
+			LOG.with(|log| log.borrow().clone())
 		}
-		decl_event! {
-			pub enum Event {
-				Logged(u32, Weight),
-			}
+
+		#[pallet::pallet]
+		#[pallet::generate_store(pub(super) trait Store)]
+		pub struct Pallet<T>(PhantomData<T>);
+
+		#[pallet::hooks]
+		impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
+
+		#[pallet::config]
+		pub trait Config: frame_system::Config {
+			type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
 		}
-		decl_module! {
-			pub struct Module<T: Config> for enum Call
-			where
-				origin: <T as system::Config>::Origin,
-				<T as system::Config>::Origin: OriginTrait<PalletsOrigin = OriginCaller>
-			{
-				fn deposit_event() = default;
 
-				#[weight = *weight]
-				fn log(origin, i: u32, weight: Weight) {
-					Self::deposit_event(Event::Logged(i, weight));
-					LOG.with(|log| {
-						log.borrow_mut().push((origin.caller().clone(), i));
-					})
-				}
+		#[pallet::event]
+		#[pallet::generate_deposit(pub(super) fn deposit_event)]
+		pub enum Event<T: Config> {
+			Logged(u32, Weight),
+		}
 
-				#[weight = *weight]
-				fn log_without_filter(origin, i: u32, weight: Weight) {
-					Self::deposit_event(Event::Logged(i, weight));
-					LOG.with(|log| {
-						log.borrow_mut().push((origin.caller().clone(), i));
-					})
-				}
+		#[pallet::call]
+		impl<T: Config> Pallet<T>
+		where
+			<T as frame_system::Config>::Origin: OriginTrait<PalletsOrigin = OriginCaller>,
+		{
+			#[pallet::weight(*weight)]
+			pub fn log(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {
+				Self::deposit_event(Event::Logged(i, weight));
+				LOG.with(|log| {
+					log.borrow_mut().push((origin.caller().clone(), i));
+				});
+				Ok(())
 			}
+
+			#[pallet::weight(*weight)]
+			pub fn log_without_filter(
+				origin: OriginFor<T>,
+				i: u32,
+				weight: Weight,
+			) -> DispatchResult {
+				Self::deposit_event(Event::Logged(i, weight));
+				LOG.with(|log| {
+					log.borrow_mut().push((origin.caller().clone(), i));
+				});
+				Ok(())
+			}
 		}
 	}
 
@@ -756,7 +775,7 @@
 			UncheckedExtrinsic = UncheckedExtrinsic,
 		{
 			System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
-			Logger: logger::{Pallet, Call, Event},
+			Logger: logger::{Pallet, Call, Event<T>},
 			Scheduler: scheduler::{Pallet, Call, Storage, Event<T>},
 		}
 	);
modifiedpallets/unique/src/mock.rsdiffbeforeafterboth
before · pallets/unique/src/mock.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(clippy::from_over_into)]1819use crate as pallet_template;20use sp_core::{H160, H256};21use frame_support::{parameter_types, traits::Everything, weights::IdentityFee};22use sp_runtime::{23	traits::{BlakeTwo256, IdentityLookup},24	testing::Header,25};26use pallet_transaction_payment::{CurrencyAdapter};27use frame_system as system;28use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog, account::CrossAccountId};29use fp_evm_mapping::EvmBackwardsAddressMapping;30use codec::{Encode, Decode, MaxEncodedLen};31use scale_info::TypeInfo;32use up_data_structs::ConstU32;3334type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;35type Block = frame_system::mocking::MockBlock<Test>;3637// Configure a mock runtime to test the pallet.38frame_support::construct_runtime!(39	pub enum Test where40		Block = Block,41		NodeBlock = Block,42		UncheckedExtrinsic = UncheckedExtrinsic,43	{44		System: frame_system::{Pallet, Call, Config, Storage, Event<T>},45		TemplateModule: pallet_template::{Pallet, Call, Storage},46		Balances: pallet_balances::{Pallet, Call, Storage},47		Common: pallet_common::{Pallet, Storage, Event<T>},48		Fungible: pallet_fungible::{Pallet, Storage},49		Refungible: pallet_refungible::{Pallet, Storage},50		Nonfungible: pallet_nonfungible::{Pallet, Storage},51	}52);5354parameter_types! {55	pub const BlockHashCount: u64 = 250;56	pub const SS58Prefix: u8 = 42;57}5859impl system::Config for Test {60	type BaseCallFilter = Everything;61	type BlockWeights = ();62	type BlockLength = ();63	type DbWeight = ();64	type Origin = Origin;65	type Call = Call;66	type Index = u64;67	type BlockNumber = u64;68	type Hash = H256;69	type Hashing = BlakeTwo256;70	type AccountId = u64;71	type Lookup = IdentityLookup<Self::AccountId>;72	type Header = Header;73	type Event = ();74	type BlockHashCount = BlockHashCount;75	type Version = ();76	type PalletInfo = PalletInfo;77	type AccountData = pallet_balances::AccountData<u64>;78	type OnNewAccount = ();79	type OnKilledAccount = ();80	type SystemWeightInfo = ();81	type SS58Prefix = SS58Prefix;82	type OnSetCode = ();83	type MaxConsumers = ConstU32<16>;84}8586parameter_types! {87	pub const ExistentialDeposit: u64 = 1;88	pub const MaxLocks: u32 = 50;89}90//frame_system::Module<Test>;91impl pallet_balances::Config for Test {92	type AccountStore = System;93	type Balance = u64;94	type DustRemoval = ();95	type Event = ();96	type ExistentialDeposit = ExistentialDeposit;97	type WeightInfo = ();98	type MaxLocks = MaxLocks;99	type MaxReserves = ();100	type ReserveIdentifier = [u8; 8];101}102103parameter_types! {104	pub const TransactionByteFee: u64 = 1;105	pub const OperationalFeeMultiplier: u8 = 5;106}107108impl pallet_transaction_payment::Config for Test {109	type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;110	type TransactionByteFee = TransactionByteFee;111	type WeightToFee = IdentityFee<u64>;112	type FeeMultiplierUpdate = ();113	type OperationalFeeMultiplier = OperationalFeeMultiplier;114}115116parameter_types! {117	pub const MinimumPeriod: u64 = 1;118}119impl pallet_timestamp::Config for Test {120	type Moment = u64;121	type OnTimestampSet = ();122	type MinimumPeriod = MinimumPeriod;123	type WeightInfo = ();124}125126parameter_types! {127	pub const CollectionCreationPrice: u32 = 100;128	pub TreasuryAccountId: u64 = 1234;129	pub EthereumChainId: u32 = 1111;130}131132pub struct TestEvmAddressMapping;133impl AddressMapping<u64> for TestEvmAddressMapping {134	fn into_account_id(_addr: sp_core::H160) -> u64 {135		unimplemented!()136	}137}138139pub struct TestEvmBackwardsAddressMapping;140impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {141	fn from_account_id(_account_id: u64) -> sp_core::H160 {142		unimplemented!()143	}144}145146#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]147pub struct TestCrossAccountId(u64, sp_core::H160);148impl CrossAccountId<u64> for TestCrossAccountId {149	fn as_sub(&self) -> &u64 {150		&self.0151	}152	fn as_eth(&self) -> &sp_core::H160 {153		&self.1154	}155	fn from_sub(sub: u64) -> Self {156		let mut eth = [0; 20];157		eth[12..20].copy_from_slice(&sub.to_be_bytes());158		Self(sub, sp_core::H160(eth))159	}160	fn from_eth(eth: sp_core::H160) -> Self {161		let mut sub_raw = [0; 8];162		sub_raw.copy_from_slice(&eth.0[0..8]);163		let sub = u64::from_be_bytes(sub_raw);164		Self(sub, eth)165	}166	fn conv_eq(&self, other: &Self) -> bool {167		self.as_sub() == other.as_sub()168	}169}170171impl Default for TestCrossAccountId {172	fn default() -> Self {173		Self::from_sub(0)174	}175}176177pub struct TestEtheremTransactionSender;178impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {179	fn submit_logs_transaction(180		_source: H160,181		_tx: pallet_ethereum::Transaction,182		_logs: Vec<MaybeMirroredLog>,183	) {184	}185}186187impl pallet_evm_coder_substrate::Config for Test {188	type EthereumTransactionSender = TestEtheremTransactionSender;189	type GasWeightMapping = ();190}191192impl pallet_common::Config for Test {193	type Event = ();194	type Currency = Balances;195	type CollectionCreationPrice = CollectionCreationPrice;196	type TreasuryAccountId = TreasuryAccountId;197}198199impl pallet_evm::account::Config for Test {200	type CrossAccountId = TestCrossAccountId;201	type EvmAddressMapping = TestEvmAddressMapping;202	type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;203}204205impl pallet_fungible::Config for Test {206	type WeightInfo = ();207}208impl pallet_refungible::Config for Test {209	type WeightInfo = ();210}211impl pallet_nonfungible::Config for Test {212	type WeightInfo = ();213}214215impl pallet_template::Config for Test {216	type Event = ();217	type WeightInfo = ();218}219220// Build genesis storage according to the mock runtime.221pub fn new_test_ext() -> sp_io::TestExternalities {222	system::GenesisConfig::default()223		.build_storage::<Test>()224		.unwrap()225		.into()226}
after · pallets/unique/src/mock.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![allow(clippy::from_over_into)]1819use crate as pallet_template;20use sp_core::{H160, H256};21use frame_support::{parameter_types, traits::Everything, weights::IdentityFee};22use sp_runtime::{23	traits::{BlakeTwo256, IdentityLookup},24	testing::Header,25};26use pallet_transaction_payment::{CurrencyAdapter};27use frame_system as system;28use pallet_evm::{AddressMapping, runner::stack::MaybeMirroredLog, account::CrossAccountId};29use fp_evm_mapping::EvmBackwardsAddressMapping;30use codec::{Encode, Decode, MaxEncodedLen};31use scale_info::TypeInfo;32use up_data_structs::ConstU32;3334type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;35type Block = frame_system::mocking::MockBlock<Test>;3637// Configure a mock runtime to test the pallet.38frame_support::construct_runtime!(39	pub enum Test where40		Block = Block,41		NodeBlock = Block,42		UncheckedExtrinsic = UncheckedExtrinsic,43	{44		System: frame_system::{Pallet, Call, Config, Storage, Event<T>},45		TemplateModule: pallet_template::{Pallet, Call, Storage},46		Balances: pallet_balances::{Pallet, Call, Storage},47		Common: pallet_common::{Pallet, Storage, Event<T>},48		Fungible: pallet_fungible::{Pallet, Storage},49		Refungible: pallet_refungible::{Pallet, Storage},50		Nonfungible: pallet_nonfungible::{Pallet, Storage},51	}52);5354parameter_types! {55	pub const BlockHashCount: u64 = 250;56	pub const SS58Prefix: u8 = 42;57}5859impl system::Config for Test {60	type BaseCallFilter = Everything;61	type BlockWeights = ();62	type BlockLength = ();63	type DbWeight = ();64	type Origin = Origin;65	type Call = Call;66	type Index = u64;67	type BlockNumber = u64;68	type Hash = H256;69	type Hashing = BlakeTwo256;70	type AccountId = u64;71	type Lookup = IdentityLookup<Self::AccountId>;72	type Header = Header;73	type Event = ();74	type BlockHashCount = BlockHashCount;75	type Version = ();76	type PalletInfo = PalletInfo;77	type AccountData = pallet_balances::AccountData<u64>;78	type OnNewAccount = ();79	type OnKilledAccount = ();80	type SystemWeightInfo = ();81	type SS58Prefix = SS58Prefix;82	type OnSetCode = ();83	type MaxConsumers = ConstU32<16>;84}8586parameter_types! {87	pub const ExistentialDeposit: u64 = 1;88	pub const MaxLocks: u32 = 50;89}90//frame_system::Module<Test>;91impl pallet_balances::Config for Test {92	type AccountStore = System;93	type Balance = u64;94	type DustRemoval = ();95	type Event = ();96	type ExistentialDeposit = ExistentialDeposit;97	type WeightInfo = ();98	type MaxLocks = MaxLocks;99	type MaxReserves = ();100	type ReserveIdentifier = [u8; 8];101}102103parameter_types! {104	pub const OperationalFeeMultiplier: u8 = 5;105}106107impl pallet_transaction_payment::Config for Test {108	type OnChargeTransaction = CurrencyAdapter<pallet_balances::Pallet<Test>, ()>;109	type LengthToFee = IdentityFee<u64>;110	type WeightToFee = IdentityFee<u64>;111	type FeeMultiplierUpdate = ();112	type OperationalFeeMultiplier = OperationalFeeMultiplier;113}114115parameter_types! {116	pub const MinimumPeriod: u64 = 1;117}118impl pallet_timestamp::Config for Test {119	type Moment = u64;120	type OnTimestampSet = ();121	type MinimumPeriod = MinimumPeriod;122	type WeightInfo = ();123}124125parameter_types! {126	pub const CollectionCreationPrice: u32 = 100;127	pub TreasuryAccountId: u64 = 1234;128	pub EthereumChainId: u32 = 1111;129}130131pub struct TestEvmAddressMapping;132impl AddressMapping<u64> for TestEvmAddressMapping {133	fn into_account_id(_addr: sp_core::H160) -> u64 {134		unimplemented!()135	}136}137138pub struct TestEvmBackwardsAddressMapping;139impl EvmBackwardsAddressMapping<u64> for TestEvmBackwardsAddressMapping {140	fn from_account_id(_account_id: u64) -> sp_core::H160 {141		unimplemented!()142	}143}144145#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, TypeInfo, MaxEncodedLen)]146pub struct TestCrossAccountId(u64, sp_core::H160);147impl CrossAccountId<u64> for TestCrossAccountId {148	fn as_sub(&self) -> &u64 {149		&self.0150	}151	fn as_eth(&self) -> &sp_core::H160 {152		&self.1153	}154	fn from_sub(sub: u64) -> Self {155		let mut eth = [0; 20];156		eth[12..20].copy_from_slice(&sub.to_be_bytes());157		Self(sub, sp_core::H160(eth))158	}159	fn from_eth(eth: sp_core::H160) -> Self {160		let mut sub_raw = [0; 8];161		sub_raw.copy_from_slice(&eth.0[0..8]);162		let sub = u64::from_be_bytes(sub_raw);163		Self(sub, eth)164	}165	fn conv_eq(&self, other: &Self) -> bool {166		self.as_sub() == other.as_sub()167	}168}169170impl Default for TestCrossAccountId {171	fn default() -> Self {172		Self::from_sub(0)173	}174}175176pub struct TestEtheremTransactionSender;177impl pallet_ethereum::EthereumTransactionSender for TestEtheremTransactionSender {178	fn submit_logs_transaction(_source: H160, _logs: Vec<MaybeMirroredLog>) {}179}180181impl pallet_evm_coder_substrate::Config for Test {182	type EthereumTransactionSender = TestEtheremTransactionSender;183	type GasWeightMapping = ();184}185186impl pallet_common::Config for Test {187	type Event = ();188	type Currency = Balances;189	type CollectionCreationPrice = CollectionCreationPrice;190	type TreasuryAccountId = TreasuryAccountId;191}192193impl pallet_evm::account::Config for Test {194	type CrossAccountId = TestCrossAccountId;195	type EvmAddressMapping = TestEvmAddressMapping;196	type EvmBackwardsAddressMapping = TestEvmBackwardsAddressMapping;197}198199impl pallet_fungible::Config for Test {200	type WeightInfo = ();201}202impl pallet_refungible::Config for Test {203	type WeightInfo = ();204}205impl pallet_nonfungible::Config for Test {206	type WeightInfo = ();207}208209impl pallet_template::Config for Test {210	type Event = ();211	type WeightInfo = ();212}213214// Build genesis storage according to the mock runtime.215pub fn new_test_ext() -> sp_io::TestExternalities {216	system::GenesisConfig::default()217		.build_storage::<Test>()218		.unwrap()219		.into()220}
modifiedpallets/unique/src/tests.rsdiffbeforeafterboth
--- a/pallets/unique/src/tests.rs
+++ b/pallets/unique/src/tests.rs
@@ -18,7 +18,6 @@
 use super::*;
 use crate::mock::*;
 use crate::{AccessMode, CollectionMode};
-use sp_runtime::AccountId32;
 use up_data_structs::{
 	COLLECTION_NUMBER_LIMIT, CollectionId, CreateItemData, CreateFungibleData, CreateNftData,
 	CreateReFungibleData, MAX_DECIMAL_POINTS, COLLECTION_ADMINS_LIMIT, MetaUpdatePermission,