git.delta.rocks / unique-network / refs/commits / 4dd148686c6b

difftreelog

refactor reorganize imports

Yaroslav Bolyukin2023-10-02parent: #a64769f.patch.diff
in: master

119 files changed

modified.rustfmt.tomldiffbeforeafterboth
--- a/.rustfmt.toml
+++ b/.rustfmt.toml
@@ -1,2 +1,3 @@
+group_imports = "stdexternalcrate"
 hard_tabs = true
-reorder_imports = false
+imports_granularity = "crate"
modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -17,23 +17,19 @@
 // Original License
 use std::sync::Arc;
 
-use codec::Decode;
-use jsonrpsee::{
-	core::{RpcResult as Result},
-	proc_macros::rpc,
-};
 use anyhow::anyhow;
+use app_promotion_rpc::AppPromotionApi as AppPromotionRuntimeApi;
+pub use app_promotion_unique_rpc::AppPromotionApiServer;
+use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
+use parity_scale_codec::Decode;
+use sp_api::{ApiExt, BlockT, ProvideRuntimeApi};
+use sp_blockchain::HeaderBackend;
 use sp_runtime::traits::{AtLeast32BitUnsigned, Member};
 use up_data_structs::{
-	RpcCollection, CollectionId, CollectionStats, CollectionLimits, TokenId, Property,
-	PropertyKeyPermission, TokenData, TokenChild,
+	CollectionId, CollectionLimits, CollectionStats, Property, PropertyKeyPermission,
+	RpcCollection, TokenChild, TokenData, TokenId,
 };
-use sp_api::{BlockT, ProvideRuntimeApi, ApiExt};
-use sp_blockchain::HeaderBackend;
 use up_rpc::UniqueApi as UniqueRuntimeApi;
-use app_promotion_rpc::AppPromotionApi as AppPromotionRuntimeApi;
-
-pub use app_promotion_unique_rpc::AppPromotionApiServer;
 
 #[cfg(feature = "pov-estimate")]
 pub mod pov_estimate;
@@ -549,16 +545,16 @@
 	keys.map(|keys| keys.into_iter().map(|key| key.into_bytes()).collect())
 }
 
-fn decode_collection_from_bytes<T: codec::Decode>(
+fn decode_collection_from_bytes<T: parity_scale_codec::Decode>(
 	bytes: &[u8],
-) -> core::result::Result<T, codec::Error> {
-	let mut reader = codec::IoReader(bytes);
+) -> core::result::Result<T, parity_scale_codec::Error> {
+	let mut reader = parity_scale_codec::IoReader(bytes);
 	T::decode(&mut reader)
 }
 
 fn detect_type_and_decode_collection<AccountId: Decode>(
 	bytes: &[u8],
-) -> core::result::Result<RpcCollection<AccountId>, codec::Error> {
+) -> core::result::Result<RpcCollection<AccountId>, parity_scale_codec::Error> {
 	use up_data_structs::{CollectionVersion1, RpcCollectionVersion1};
 
 	decode_collection_from_bytes::<RpcCollection<AccountId>>(bytes)
@@ -574,11 +570,12 @@
 
 #[cfg(test)]
 mod tests {
-	use super::*;
-	use codec::IoReader;
 	use hex_literal::hex;
+	use parity_scale_codec::IoReader;
 	use up_data_structs::{CollectionVersion1, RawEncoded};
 
+	use super::*;
+
 	const ENCODED_COLLECTION_V1: [u8; 180] = hex!("aab94a1ee784bc17f68d76d4d48d736916ca6ff6315b8c1fa1175726c8345a390000285000720069006d00610020004c00690076006500d04500730065006d00700069006f00200064006900200063007200650061007a0069006f006e006500200064006900200075006e00610020006e0075006f0076006100200063006f006c006c0065007a0069006f006e00650020006400690020004e004600540021000c464e5400000000000000000000000000000000");
 	const ENCODED_RPC_COLLECTION_V2: [u8; 618] = hex!("d00dcc24bf66750d3809aa26884b930ec8a3094d6f6f19fdc62020b2fbec013400604d0069006e007400460065007300740020002d002000460075006e006e007900200061006e0069006d0061006c0073008c430072006f00730073006f0076006500720020006200650074007700650065006e00200061006e0069006d0061006c00730020002d00200066006f0072002000660075006e00104d46464100000000000000000000010001000100000004385f6f6c645f636f6e7374446174610001000c5c5f6f6c645f636f6e73744f6e436861696e536368656d6139047b226e6573746564223a7b226f6e436861696e4d65746144617461223a7b226e6573746564223a7b224e46544d657461223a7b226669656c6473223a7b22697066734a736f6e223a7b226964223a312c2272756c65223a227265717569726564222c2274797065223a22737472696e67227d2c2248656164223a7b226964223a322c2272756c65223a227265717569726564222c2274797065223a22737472696e67227d2c22426f6479223a7b226964223a332c2272756c65223a227265717569726564222c2274797065223a22737472696e67227d2c225461696c223a7b226964223a342c2272756c65223a227265717569726564222c2274797065223a22737472696e67227d7d7d7d7d7d7d485f6f6c645f736368656d6156657273696f6e18556e69717565685f6f6c645f7661726961626c654f6e436861696e536368656d6111017b22636f6c6c656374696f6e436f766572223a22516d53557a7139354c357a556777795a584d3731576a3762786b36557048515468633162536965347766706e5435227d000000");
 
modifiedclient/rpc/src/pov_estimate.rsdiffbeforeafterboth
--- a/client/rpc/src/pov_estimate.rs
+++ b/client/rpc/src/pov_estimate.rs
@@ -16,39 +16,31 @@
 
 use std::sync::Arc;
 
-use codec::{Encode, Decode};
-use sp_externalities::Extensions;
-
-use up_pov_estimate_rpc::{PovEstimateApi as PovEstimateRuntimeApi};
-use up_common::types::opaque::RuntimeId;
-
-use sc_service::{NativeExecutionDispatch, config::ExecutionStrategy};
-use sp_state_machine::{StateMachine, TrieBackendBuilder};
-use trie_db::{Trie, TrieDBBuilder};
-
+use anyhow::anyhow;
 use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
-use anyhow::anyhow;
-
+use parity_scale_codec::{Decode, Encode};
 use sc_client_api::backend::Backend;
+use sc_executor::NativeElseWasmExecutor;
+use sc_rpc_api::DenyUnsafe;
+use sc_service::{config::ExecutionStrategy, NativeExecutionDispatch};
+use sp_api::{AsTrieBackend, BlockId, BlockT, ProvideRuntimeApi};
 use sp_blockchain::HeaderBackend;
 use sp_core::{
-	Bytes,
 	offchain::{
 		testing::{TestOffchainExt, TestTransactionPoolExt},
 		OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
 	},
 	testing::TaskExecutor,
 	traits::TaskExecutorExt,
+	Bytes,
 };
+use sp_externalities::Extensions;
 use sp_keystore::{testing::KeyStore, KeystoreExt};
-use sp_api::{AsTrieBackend, BlockId, BlockT, ProvideRuntimeApi};
-
-use sc_executor::NativeElseWasmExecutor;
-use sc_rpc_api::DenyUnsafe;
-
 use sp_runtime::traits::Header;
-
-use up_pov_estimate_rpc::{PovInfo, TrieKeyValue};
+use sp_state_machine::{StateMachine, TrieBackendBuilder};
+use trie_db::{Trie, TrieDBBuilder};
+use up_common::types::opaque::RuntimeId;
+use up_pov_estimate_rpc::{PovEstimateApi as PovEstimateRuntimeApi, PovInfo, TrieKeyValue};
 
 use crate::define_struct_for_server_api;
 
modifiedcrates/struct-versioning/src/lib.rsdiffbeforeafterboth
--- a/crates/struct-versioning/src/lib.rs
+++ b/crates/struct-versioning/src/lib.rs
@@ -17,13 +17,12 @@
 #![doc = include_str!("../README.md")]
 
 use proc_macro::TokenStream;
-use quote::format_ident;
+use quote::{format_ident, quote};
 use syn::{
-	parse::{Parse, ParseStream},
-	Token, LitInt, parse_macro_input, ItemStruct, Error, Fields, Result, Field, Expr,
 	parenthesized,
+	parse::{Parse, ParseStream},
+	parse_macro_input, Error, Expr, Field, Fields, ItemStruct, LitInt, Result, Token,
 };
-use quote::quote;
 
 mod kw {
 	syn::custom_keyword!(version);
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -14,36 +14,35 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+use std::collections::BTreeMap;
+
+#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
+pub use opal_runtime as default_runtime;
+#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
+pub use quartz_runtime as default_runtime;
 use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
 use sc_service::ChainType;
+use serde::{Deserialize, Serialize};
+use serde_json::map::Map;
 use sp_core::{sr25519, Pair, Public};
 use sp_runtime::traits::{IdentifyAccount, Verify};
-use std::collections::BTreeMap;
-
-use serde::{Deserialize, Serialize};
-use serde_json::map::Map;
-
-use up_common::types::opaque::*;
-
 #[cfg(feature = "unique-runtime")]
 pub use unique_runtime as default_runtime;
-
-#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
-pub use quartz_runtime as default_runtime;
-
-#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
-pub use opal_runtime as default_runtime;
+use up_common::types::opaque::*;
 
 /// The `ChainSpec` parameterized for the unique runtime.
 #[cfg(feature = "unique-runtime")]
-pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;
+pub type UniqueChainSpec =
+	sc_service::GenericChainSpec<unique_runtime::RuntimeGenesisConfig, Extensions>;
 
 /// The `ChainSpec` parameterized for the quartz runtime.
 #[cfg(feature = "quartz-runtime")]
-pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;
+pub type QuartzChainSpec =
+	sc_service::GenericChainSpec<quartz_runtime::RuntimeGenesisConfig, Extensions>;
 
 /// The `ChainSpec` parameterized for the opal runtime.
-pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;
+pub type OpalChainSpec =
+	sc_service::GenericChainSpec<opal_runtime::RuntimeGenesisConfig, Extensions>;
 
 #[cfg(feature = "unique-runtime")]
 pub type DefaultChainSpec = UniqueChainSpec;
modifiednode/cli/src/cli.rsdiffbeforeafterboth
--- a/node/cli/src/cli.rs
+++ b/node/cli/src/cli.rs
@@ -14,10 +14,12 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use crate::chain_spec;
 use std::path::PathBuf;
+
 use clap::Parser;
 
+use crate::chain_spec;
+
 /// Sub-commands supported by the collator.
 #[derive(Debug, Parser)]
 pub enum Subcommand {
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -32,28 +32,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-use crate::{
-	chain_spec::{self, RuntimeIdentification, ServiceId, ServiceIdentification},
-	cli::{Cli, RelayChainCli, Subcommand},
-	service::{new_partial, start_node, start_dev_node},
-};
-#[cfg(feature = "runtime-benchmarks")]
-use crate::chain_spec::default_runtime;
-
-#[cfg(feature = "unique-runtime")]
-use crate::service::UniqueRuntimeExecutor;
-
-#[cfg(feature = "quartz-runtime")]
-use crate::service::QuartzRuntimeExecutor;
-
-use crate::service::OpalRuntimeExecutor;
-
-#[cfg(feature = "runtime-benchmarks")]
-use crate::service::DefaultRuntimeExecutor;
+use std::time::Duration;
 
 use codec::Encode;
-use cumulus_primitives_core::ParaId;
 use cumulus_client_cli::generate_genesis_block;
+use cumulus_primitives_core::ParaId;
 use log::{debug, info};
 use sc_cli::{
 	ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
@@ -62,8 +45,21 @@
 use sc_service::config::{BasePath, PrometheusConfig};
 use sp_core::hexdisplay::HexDisplay;
 use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
+use up_common::types::opaque::{Block, RuntimeId};
 
-use up_common::types::opaque::{Block, RuntimeId};
+#[cfg(feature = "runtime-benchmarks")]
+use crate::chain_spec::default_runtime;
+#[cfg(feature = "runtime-benchmarks")]
+use crate::service::DefaultRuntimeExecutor;
+#[cfg(feature = "quartz-runtime")]
+use crate::service::QuartzRuntimeExecutor;
+#[cfg(feature = "unique-runtime")]
+use crate::service::UniqueRuntimeExecutor;
+use crate::{
+	chain_spec::{self, RuntimeIdentification, ServiceId, ServiceIdentification},
+	cli::{Cli, RelayChainCli, Subcommand},
+	service::{new_partial, start_dev_node, start_node, OpalRuntimeExecutor},
+};
 
 macro_rules! no_runtime_err {
 	($runtime_id:expr) => {
deletednode/cli/src/lib.rsdiffbeforeafterboth
--- a/node/cli/src/lib.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network 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.
-
-// Unique Network 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 Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-pub mod chain_spec;
-pub mod service;
modifiednode/cli/src/main.rsdiffbeforeafterboth
--- a/node/cli/src/main.rs
+++ b/node/cli/src/main.rs
@@ -19,6 +19,7 @@
 mod service;
 mod cli;
 mod command;
+mod rpc;
 
 fn main() -> sc_cli::Result<()> {
 	command::run()
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -15,73 +15,72 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 // std
-use std::sync::Arc;
-use std::sync::Mutex;
-use std::collections::BTreeMap;
-use std::time::Duration;
-use std::pin::Pin;
-use fc_mapping_sync::EthereumBlockNotificationSinks;
-use fc_rpc::EthBlockDataCacheTask;
-use fc_rpc::EthTask;
-use fc_rpc_core::types::FeeHistoryCache;
-use futures::{
-	Stream, StreamExt,
-	stream::select,
-	task::{Context, Poll},
+use std::{
+	collections::BTreeMap,
+	marker::PhantomData,
+	pin::Pin,
+	sync::{Arc, Mutex},
+	time::Duration,
 };
-use sc_rpc::SubscriptionTaskExecutor;
-use sp_keystore::KeystorePtr;
-use tokio::time::Interval;
-use jsonrpsee::RpcModule;
-
-use serde::{Serialize, Deserialize};
 
-// Cumulus Imports
-use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
-use cumulus_client_consensus_common::{
-	ParachainConsensus, ParachainBlockImport as TParachainBlockImport,
+use cumulus_client_cli::CollatorOptions;
+use cumulus_client_collator::service::CollatorService;
+#[cfg(not(feature = "lookahead"))]
+use cumulus_client_consensus_aura::collators::basic::{
+	run as run_aura, Params as BuildAuraConsensusParams,
 };
+#[cfg(feature = "lookahead")]
+use cumulus_client_consensus_aura::collators::lookahead::{
+	run as run_aura, Params as BuildAuraConsensusParams,
+};
+use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
+use cumulus_client_consensus_proposer::Proposer;
+use cumulus_client_network::RequireSecondedInBlockAnnounce;
 use cumulus_client_service::{
-	prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
+	build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, DARecoveryProfile,
+	StartRelayChainTasksParams,
 };
-use cumulus_client_cli::CollatorOptions;
-use cumulus_client_network::BlockAnnounceValidator;
 use cumulus_primitives_core::ParaId;
-use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
-use cumulus_relay_chain_interface::{RelayChainInterface, RelayChainResult};
-use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node;
-
-// Substrate Imports
-use sp_api::{BlockT, HeaderT, ProvideRuntimeApi, StateBackend};
-use sc_executor::NativeElseWasmExecutor;
-use sc_executor::NativeExecutionDispatch;
+use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
+use fc_mapping_sync::{kv::MappingSyncWorker, EthereumBlockNotificationSinks, SyncStrategy};
+use fc_rpc::{
+	frontier_backend_client::SystemAccountId32StorageOverride, EthBlockDataCacheTask, EthConfig,
+	EthTask, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override, SchemaV2Override,
+	SchemaV3Override, StorageOverride,
+};
+use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
+use fp_rpc::EthereumRuntimeRPCApi;
+use fp_storage::EthereumStorageSchema;
+use futures::{
+	stream::select,
+	task::{Context, Poll},
+	Stream, StreamExt,
+};
+use jsonrpsee::RpcModule;
+use polkadot_service::CollatorPair;
+use sc_client_api::{AuxStore, Backend, BlockOf, BlockchainEvents, StorageProvider};
+use sc_consensus::ImportQueue;
+use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch};
 use sc_network::NetworkBlock;
 use sc_network_sync::SyncingService;
+use sc_rpc::SubscriptionTaskExecutor;
 use sc_service::{Configuration, PartialComponents, TaskManager};
 use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
+use serde::{Deserialize, Serialize};
+use sp_api::{ProvideRuntimeApi, StateBackend};
+use sp_block_builder::BlockBuilder;
+use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
+use sp_consensus_aura::sr25519::AuthorityPair as AuraAuthorityPair;
+use sp_keystore::KeystorePtr;
 use sp_runtime::traits::BlakeTwo256;
 use substrate_prometheus_endpoint::Registry;
-use sc_client_api::{BlockchainEvents, BlockOf, Backend, AuxStore, StorageProvider};
-use sp_blockchain::{HeaderBackend, HeaderMetadata, Error as BlockChainError};
-use sc_consensus::ImportQueue;
-use sp_core::H256;
-use sp_block_builder::BlockBuilder;
+use tokio::time::Interval;
+use up_common::types::{opaque::*, Nonce};
 
-use polkadot_service::CollatorPair;
-
-// Frontier Imports
-use fc_rpc_core::types::FilterPool;
-use fc_mapping_sync::{kv::MappingSyncWorker, SyncStrategy};
-use fc_rpc::{
-	StorageOverride, OverrideHandle, SchemaV1Override, SchemaV2Override, SchemaV3Override,
-	RuntimeApiStorageOverride,
+use crate::{
+	chain_spec::RuntimeIdentification,
+	rpc::{create_eth, create_full, EthDeps, FullDeps},
 };
-use fp_rpc::EthereumRuntimeRPCApi;
-use fp_storage::EthereumStorageSchema;
-
-use up_common::types::opaque::*;
-
-use crate::chain_spec::RuntimeIdentification;
 
 /// Unique native executor instance.
 #[cfg(feature = "unique-runtime")]
modifiedpallets/app-promotion/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/benchmarking.rs
+++ b/pallets/app-promotion/src/benchmarking.rs
@@ -16,16 +16,15 @@
 
 #![cfg(feature = "runtime-benchmarks")]
 
-use super::*;
-use crate::Pallet as PromototionPallet;
-use frame_support::traits::fungible::Unbalanced;
-use sp_runtime::traits::Bounded;
-
-use frame_benchmarking::{benchmarks, account};
-use frame_support::traits::OnInitialize;
+use frame_benchmarking::{account, benchmarks};
+use frame_support::traits::{fungible::Unbalanced, OnInitialize};
 use frame_system::RawOrigin;
+use pallet_evm_migration::Pallet as EvmMigrationPallet;
 use pallet_unique::benchmarking::create_nft_collection;
-use pallet_evm_migration::Pallet as EvmMigrationPallet;
+use sp_runtime::traits::Bounded;
+
+use super::*;
+use crate::Pallet as PromototionPallet;
 
 const SEED: u32 = 0;
 
modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -53,32 +53,32 @@
 pub mod types;
 pub mod weights;
 
-use sp_std::{vec::Vec, vec, iter::Sum, borrow::ToOwned, cell::RefCell};
-use sp_core::H160;
-use codec::EncodeLike;
-pub use types::*;
-
-use up_data_structs::CollectionId;
-
 use frame_support::{
-	dispatch::{DispatchResult},
+	dispatch::DispatchResult,
+	ensure,
+	pallet_prelude::*,
+	storage::Key,
 	traits::{
-		Get,
+		fungible::{Inspect, InspectFreeze, Mutate, MutateFreeze},
 		tokens::Balance,
-		fungible::{Inspect, InspectFreeze, Mutate, MutateFreeze},
+		Get,
 	},
-	ensure, BoundedVec,
+	weights::Weight,
+	Blake2_128Concat, BoundedVec, PalletId, Twox64Concat,
 };
-
-use weights::WeightInfo;
-
+use frame_system::pallet_prelude::*;
 pub use pallet::*;
 use pallet_evm::account::CrossAccountId;
+use parity_scale_codec::EncodeLike;
+use sp_core::H160;
 use sp_runtime::{
-	Perbill,
-	traits::{BlockNumberProvider, CheckedAdd, CheckedSub, AccountIdConversion, Zero},
-	ArithmeticError, DispatchError,
+	traits::{AccountIdConversion, BlockNumberProvider, CheckedAdd, CheckedSub, Zero},
+	ArithmeticError, DispatchError, Perbill,
 };
+use sp_std::{borrow::ToOwned, cell::RefCell, iter::Sum, vec, vec::Vec};
+pub use types::*;
+use up_data_structs::CollectionId;
+use weights::WeightInfo;
 
 const PENDING_LIMIT_PER_BLOCK: u32 = 3;
 
@@ -87,12 +87,8 @@
 
 #[frame_support::pallet]
 pub mod pallet {
+
 	use super::*;
-	use frame_support::{
-		Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key, PalletId, weights::Weight,
-	};
-	use frame_system::pallet_prelude::*;
-	use sp_runtime::DispatchError;
 
 	#[pallet::config]
 	pub trait Config:
modifiedpallets/app-promotion/src/types.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/types.rs
+++ b/pallets/app-promotion/src/types.rs
@@ -1,13 +1,12 @@
-use frame_support::{dispatch::DispatchResult};
-
+use frame_support::dispatch::DispatchResult;
+use frame_system::pallet_prelude::*;
 use pallet_common::CollectionHandle;
-
+use pallet_configuration::AppPromomotionConfigurationOverride;
+use pallet_evm_contract_helpers::{Config as EvmHelpersConfig, Pallet as EvmHelpersPallet};
+use sp_core::Get;
 use sp_runtime::{DispatchError, Perbill};
-use up_data_structs::{CollectionId};
 use sp_std::borrow::ToOwned;
-use pallet_evm_contract_helpers::{Pallet as EvmHelpersPallet, Config as EvmHelpersConfig};
-use pallet_configuration::{AppPromomotionConfigurationOverride};
-use sp_core::Get;
+use up_data_structs::CollectionId;
 
 const MAX_NUMBER_PAYOUTS: u8 = 100;
 pub(crate) const DEFAULT_NUMBER_PAYOUTS: u8 = 20;
modifiedpallets/balances-adapter/src/common.rsdiffbeforeafterboth
--- a/pallets/balances-adapter/src/common.rs
+++ b/pallets/balances-adapter/src/common.rs
@@ -1,11 +1,13 @@
 use alloc::{vec, vec::Vec};
 use core::marker::PhantomData;
-use crate::{Config, NativeFungibleHandle, Pallet};
+
 use frame_support::{fail, weights::Weight};
 use pallet_balances::{weights::SubstrateWeight as BalancesWeight, WeightInfo};
 use pallet_common::{CommonCollectionOperations, CommonWeightInfo};
 use up_data_structs::TokenId;
 
+use crate::{Config, NativeFungibleHandle, Pallet};
+
 pub struct CommonWeights<T: Config>(PhantomData<T>);
 
 // All implementations with `Weight::default` used in methods that return error `UnsupportedOperation`.
modifiedpallets/balances-adapter/src/erc.rsdiffbeforeafterboth
--- a/pallets/balances-adapter/src/erc.rs
+++ b/pallets/balances-adapter/src/erc.rs
@@ -1,4 +1,3 @@
-use crate::{Config, NativeFungibleHandle, Pallet, SelfWeightOf};
 use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*};
 use pallet_balances::WeightInfo;
 use pallet_common::{
@@ -10,8 +9,10 @@
 	execution::{PreDispatch, Result},
 	frontier_contract, WithRecorder,
 };
-use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
-use sp_core::{U256, Get};
+use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
+use sp_core::{Get, U256};
+
+use crate::{Config, NativeFungibleHandle, Pallet, SelfWeightOf};
 
 frontier_contract! {
 	macro_rules! NativeFungibleHandle_result {...}
modifiedpallets/balances-adapter/src/lib.rsdiffbeforeafterboth
--- a/pallets/balances-adapter/src/lib.rs
+++ b/pallets/balances-adapter/src/lib.rs
@@ -4,8 +4,8 @@
 use core::ops::Deref;
 
 use frame_support::sp_runtime::DispatchResult;
-use pallet_evm_coder_substrate::{WithRecorder, SubstrateRecorder};
 pub use pallet::*;
+use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
 
 pub mod common;
 pub mod erc;
@@ -55,16 +55,16 @@
 }
 #[frame_support::pallet]
 pub mod pallet {
-	use super::*;
 	use alloc::string::String;
+
 	use frame_support::{
 		dispatch::PostDispatchInfo,
 		ensure,
-		pallet_prelude::{DispatchResultWithPostInfo, Pays},
+		pallet_prelude::*,
 		traits::{
-			Get,
 			fungible::{Inspect, Mutate},
 			tokens::Preservation,
+			Get,
 		},
 	};
 	use pallet_balances::WeightInfo;
@@ -74,6 +74,8 @@
 	use sp_runtime::DispatchError;
 	use up_data_structs::{budget::Budget, mapping::TokenAddressMapping};
 
+	use super::*;
+
 	#[pallet::config]
 	pub trait Config:
 		frame_system::Config
modifiedpallets/collator-selection/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/benchmarking.rs
+++ b/pallets/collator-selection/src/benchmarking.rs
@@ -32,18 +32,13 @@
 
 //! Benchmarking setup for pallet-collator-selection
 
-use super::*;
-
-#[allow(unused)]
-use crate::{Pallet as CollatorSelection, BalanceOf};
 use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
 use frame_support::{
 	assert_ok,
-	codec::Decode,
+	parity_scale_codec::Decode,
 	traits::{
-		EnsureOrigin,
 		fungible::{Inspect, Mutate},
-		Get,
+		EnsureOrigin, Get,
 	},
 };
 use frame_system::{EventRecord, RawOrigin};
modifiedpallets/collator-selection/src/lib.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/lib.rs
+++ b/pallets/collator-selection/src/lib.rs
@@ -96,26 +96,27 @@
 	<<T as Config>::Currency as Inspect<<T as frame_system::Config>::AccountId>>::Balance;
 #[frame_support::pallet]
 pub mod pallet {
-	use super::*;
-	pub use crate::weights::WeightInfo;
 	use core::ops::Div;
+
 	use frame_support::{
 		dispatch::{DispatchClass, DispatchResultWithPostInfo},
-		inherent::Vec,
 		pallet_prelude::*,
 		sp_runtime::traits::{AccountIdConversion, CheckedSub, Saturating, Zero},
 		traits::{
-			EnsureOrigin,
-			fungible::{Balanced, BalancedHold, Inspect, InspectHold, Mutate, MutateHold},
-			ValidatorRegistration,
+			fungible::{Balanced, BalancedHold, Inspect, Mutate, MutateHold},
 			tokens::{Precision, Preservation},
+			EnsureOrigin, ValidatorRegistration,
 		},
 		BoundedVec, PalletId,
 	};
 	use frame_system::pallet_prelude::*;
 	use pallet_session::SessionManager;
-	use sp_runtime::{Perbill, traits::Convert};
+	use sp_runtime::{traits::Convert, Perbill};
 	use sp_staking::SessionIndex;
+	use sp_std::vec::Vec;
+
+	use super::*;
+	pub use crate::weights::WeightInfo;
 
 	/// A convertor from collators id. Since this pallet does not have stash/controller, this is
 	/// just identity.
modifiedpallets/collator-selection/src/mock.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/mock.rs
+++ b/pallets/collator-selection/src/mock.rs
@@ -30,8 +30,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-use super::*;
-use crate as collator_selection;
 use frame_support::{
 	ord_parameter_types, parameter_types,
 	traits::{FindAuthor, GenesisBuild, ValidatorRegistration},
@@ -46,6 +44,9 @@
 	Perbill, RuntimeAppPublic,
 };
 
+use super::*;
+use crate as collator_selection;
+
 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
 type Block = frame_system::mocking::MockBlock<Test>;
 
modifiedpallets/collator-selection/src/tests.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/tests.rs
+++ b/pallets/collator-selection/src/tests.rs
@@ -30,15 +30,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-use crate::{self as collator_selection, Config};
-use crate::{mock::*, Error};
 use frame_support::{
 	assert_noop, assert_ok,
 	traits::{fungible, GenesisBuild, OnInitialize},
 };
+use scale_info::prelude::*;
 use sp_runtime::{traits::BadOrigin, TokenError};
-use scale_info::prelude::*;
 
+use crate::{self as collator_selection, mock::*, Config, Error};
+
 fn get_license_and_onboard(account_id: <Test as frame_system::Config>::AccountId) {
 	assert_ok!(CollatorSelection::get_license(RuntimeOrigin::signed(
 		account_id
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -16,23 +16,25 @@
 
 #![allow(missing_docs)]
 
-use sp_std::vec::Vec;
-use crate::{Config, CollectionHandle, Pallet};
-use pallet_evm::account::CrossAccountId;
-use frame_benchmarking::{benchmarks, account};
-use up_data_structs::{
-	CollectionMode, CreateCollectionData, CollectionId, Property, PropertyKey, PropertyValue,
-	CollectionPermissions, NestingPermissions, AccessMode, PropertiesPermissionMap,
-	MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
-	MAX_PROPERTIES_PER_ITEM,
-};
+use core::convert::TryInto;
+
+use frame_benchmarking::{account, benchmarks};
 use frame_support::{
-	traits::{Get, fungible::Balanced, Imbalance, tokens::Precision},
 	pallet_prelude::ConstU32,
+	traits::{fungible::Balanced, tokens::Precision, Get, Imbalance},
 	BoundedVec,
 };
-use core::convert::TryInto;
-use sp_runtime::{DispatchError, traits::Zero};
+use pallet_evm::account::CrossAccountId;
+use sp_runtime::{traits::Zero, DispatchError};
+use sp_std::vec::Vec;
+use up_data_structs::{
+	AccessMode, CollectionId, CollectionMode, CollectionPermissions, CreateCollectionData,
+	NestingPermissions, PropertiesPermissionMap, Property, PropertyKey, PropertyValue,
+	MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_COLLECTION_NAME_LENGTH, MAX_PROPERTIES_PER_ITEM,
+	MAX_TOKEN_PREFIX_LENGTH,
+};
+
+use crate::{CollectionHandle, Config, Pallet};
 
 const SEED: u32 = 1;
 
modifiedpallets/common/src/dispatch.rsdiffbeforeafterboth
--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -2,13 +2,13 @@
 
 use frame_support::{
 	dispatch::{
-		DispatchResultWithPostInfo, PostDispatchInfo, Weight, DispatchErrorWithPostInfo,
-		DispatchResult,
+		DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, Pays,
+		PostDispatchInfo,
 	},
-	dispatch::Pays,
 	traits::Get,
 };
 use sp_runtime::DispatchError;
+use sp_weights::Weight;
 use up_data_structs::{CollectionId, CreateCollectionData};
 
 use crate::{pallet::Config, CommonCollectionOperations};
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -16,15 +16,17 @@
 
 //! This module contains the implementation of pallet methods for evm.
 
-pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};
+pub use pallet_evm::{
+	account::CrossAccountId, PrecompileHandle, PrecompileOutput, PrecompileResult,
+};
 use pallet_evm_coder_substrate::{
 	abi::AbiType,
-	solidity_interface, ToLog,
+	dispatch_to_evm,
+	execution::{Error, PreDispatch, Result},
+	frontier_contract, solidity_interface,
 	types::*,
-	execution::{Result, Error, PreDispatch},
-	frontier_contract,
+	ToLog,
 };
-use pallet_evm_coder_substrate::dispatch_to_evm;
 use sp_std::{vec, vec::Vec};
 use up_data_structs::{
 	CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property, SponsoringRateLimit,
@@ -32,7 +34,7 @@
 };
 
 use crate::{
-	Pallet, CollectionHandle, Config, CollectionProperties, eth, SelfWeightOf, weights::WeightInfo,
+	eth, weights::WeightInfo, CollectionHandle, CollectionProperties, Config, Pallet, SelfWeightOf,
 };
 
 frontier_contract! {
@@ -727,11 +729,10 @@
 
 /// Contains static property keys and values.
 pub mod static_property {
-	use pallet_evm_coder_substrate::{
-		execution::{Result, Error},
-	};
 	use alloc::format;
 
+	use pallet_evm_coder_substrate::execution::{Error, Result};
+
 	const EXPECT_CONVERT_ERROR: &str = "length < limit";
 
 	/// Keys.
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -17,15 +17,16 @@
 //! The module contains a number of functions for converting and checking ethereum identifiers.
 
 use alloc::format;
-use sp_std::{vec, vec::Vec};
+
 use evm_coder::{
+	types::{Address, String},
 	AbiCoder,
-	types::{Address, String},
 };
-pub use pallet_evm::{Config, account::CrossAccountId};
-use sp_core::{H160, U256};
-use up_data_structs::{CollectionId, CollectionFlags};
+pub use pallet_evm::{account::CrossAccountId, Config};
 use pallet_evm_coder_substrate::execution::Error;
+use sp_core::{H160, U256};
+use sp_std::{vec, vec::Vec};
+use up_data_structs::{CollectionFlags, CollectionId};
 
 // 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 1
 // TODO: Unhardcode prefix
modifiedpallets/common/src/helpers.rsdiffbeforeafterboth
--- a/pallets/common/src/helpers.rs
+++ b/pallets/common/src/helpers.rs
@@ -3,9 +3,9 @@
 //! The module contains helpers.
 //!
 use frame_support::{
+	dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo},
 	pallet_prelude::DispatchResultWithPostInfo,
 	weights::Weight,
-	dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo},
 };
 
 /// Add weight for a `DispatchResultWithPostInfo`
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
before · pallets/common/src/lib.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//! # Common pallet18//!19//! The Common pallet provides functionality for handling collections.20//!21//! ## Overview22//!23//! The Common pallet provides an interface for common collection operations for different collection types24//! (see [CommonCollectionOperations]), as well as a generic dispatcher for these, see [dispatch] module.25//! It also provides this functionality to EVM, see [erc] and [eth] modules.26//!27//! The Common pallet provides functions for:28//!29//! - Setting and approving collection sponsor.30//! - Get\set\delete allow list.31//! - Get\set\delete collection properties.32//! - Get\set\delete collection property permissions.33//! - Get\set\delete token property permissions.34//! - Get\set\delete collection administrators.35//! - Checking access permissions.36//!37//! ### Terminology38//! **Collection sponsor** - For the collection, you can set a sponsor, at whose expense it will39//! be possible to mint tokens.40//!41//! **Allow list** - List of users who have the right to minting tokens.42//!43//! **Collection properties** - Collection properties are simply key-value stores where various44//! metadata can be placed.45//!46//! **Permissions on token properties** - For each property in the token can be set permission47//! to change, see [`PropertyPermission`].48//!49//! **Collection administrator** - For a collection, you can set administrators who have the right50//! to most actions on the collection.5152#![warn(missing_docs)]53#![cfg_attr(not(feature = "std"), no_std)]54extern crate alloc;5556use core::{57	ops::{Deref, DerefMut},58	slice::from_ref,59	marker::PhantomData,60};61use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};62use sp_std::vec::Vec;63use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};64use evm_coder::ToLog;65use frame_support::{66	dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Weight, PostDispatchInfo},67	ensure,68	traits::{69		Get,70		fungible::{Balanced, Debt, Inspect},71		tokens::{Imbalance, Precision, Preservation},72	},73	dispatch::Pays,74	transactional, fail,75};76use up_data_structs::{77	AccessMode, COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, RpcCollectionFlags,78	CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH, COLLECTION_ADMINS_LIMIT, TokenId,79	TokenChild, CollectionStats, MAX_TOKEN_OWNERSHIP, CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT,80	FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT,81	CUSTOM_DATA_LIMIT, CollectionLimits, CreateCollectionData, SponsorshipState, CreateItemExData,82	SponsoringRateLimit, budget::Budget, PhantomType, Property,83	CollectionProperties as CollectionPropertiesT, TokenProperties, PropertiesPermissionMap,84	PropertyKey, PropertyValue, PropertyPermission, PropertiesError, TokenOwnerError,85	PropertyKeyPermission, TokenData, TrySetProperty, PropertyScope, CollectionPermissions,86};87use up_pov_estimate_rpc::PovInfo;8889pub use pallet::*;90use sp_core::H160;91use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, traits::Zero};9293#[cfg(feature = "runtime-benchmarks")]94pub mod benchmarking;95pub mod dispatch;96pub mod erc;97pub mod eth;98pub mod helpers;99#[allow(missing_docs)]100pub mod weights;101102use weights::WeightInfo;103104/// Weight info.105pub type SelfWeightOf<T> = <T as Config>::WeightInfo;106107/// Collection handle contains information about collection data and id.108/// Also provides functionality to count consumed gas.109///110/// CollectionHandle is used as a generic wrapper for collections of all types (except native fungible).111/// It allows to perform common operations and queries on any collection type,112/// both completely general for all, as well as their respective implementations of [`CommonCollectionOperations`].113#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]114pub struct CollectionHandle<T: Config> {115	/// Collection id116	pub id: CollectionId,117	collection: Collection<T::AccountId>,118	/// Substrate recorder for counting consumed gas119	pub recorder: SubstrateRecorder<T>,120}121122impl<T: Config> WithRecorder<T> for CollectionHandle<T> {123	fn recorder(&self) -> &SubstrateRecorder<T> {124		&self.recorder125	}126	fn into_recorder(self) -> SubstrateRecorder<T> {127		self.recorder128	}129}130131impl<T: Config> CollectionHandle<T> {132	/// Same as [CollectionHandle::new] but with an explicit gas limit.133	pub fn new_with_gas_limit(id: CollectionId, gas_limit: u64) -> Option<Self> {134		Self::new_with_recorder(id, SubstrateRecorder::new(gas_limit))135	}136137	/// Same as [CollectionHandle::new] but with an existed [`SubstrateRecorder`].138	pub fn new_with_recorder(id: CollectionId, recorder: SubstrateRecorder<T>) -> Option<Self> {139		<CollectionById<T>>::get(id).map(|collection| Self {140			id,141			collection,142			recorder,143		})144	}145146	/// Retrives collection data from storage and creates collection handle with default parameters.147	/// If collection not found return `None`148	pub fn new(id: CollectionId) -> Option<Self> {149		Self::new_with_gas_limit(id, u64::MAX)150	}151152	/// Same as [`CollectionHandle::new`] but if collection not found [CollectionNotFound](Error::CollectionNotFound) returned.153	pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {154		Ok(Self::new(id).ok_or(<Error<T>>::CollectionNotFound)?)155	}156157	/// Consume gas for reading.158	pub fn consume_store_reads(159		&self,160		reads: u64,161	) -> pallet_evm_coder_substrate::execution::Result<()> {162		self.recorder().consume_store_reads(reads)163	}164165	/// Consume gas for writing.166	pub fn consume_store_writes(167		&self,168		writes: u64,169	) -> pallet_evm_coder_substrate::execution::Result<()> {170		self.recorder().consume_store_writes(writes)171	}172173	/// Consume gas for reading and writing.174	pub fn consume_store_reads_and_writes(175		&self,176		reads: u64,177		writes: u64,178	) -> pallet_evm_coder_substrate::execution::Result<()> {179		self.recorder()180			.consume_store_reads_and_writes(reads, writes)181	}182183	/// Save collection to storage.184	pub fn save(&self) -> DispatchResult {185		<CollectionById<T>>::insert(self.id, &self.collection);186		Ok(())187	}188189	/// Set collection sponsor.190	///191	/// Unique collections allows sponsoring for certain actions.192	/// This method allows you to set the sponsor of the collection.193	/// In order for sponsorship to become active, it must be confirmed through [`Self::confirm_sponsorship`].194	pub fn set_sponsor(195		&mut self,196		sender: &T::CrossAccountId,197		sponsor: T::AccountId,198	) -> DispatchResult {199		self.check_is_internal()?;200		self.check_is_owner_or_admin(sender)?;201202		self.collection.sponsorship = SponsorshipState::Unconfirmed(sponsor.clone());203204		<Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorSet(self.id, sponsor));205		<PalletEvm<T>>::deposit_log(206			erc::CollectionHelpersEvents::CollectionChanged {207				collection_id: eth::collection_id_to_address(self.id),208			}209			.to_log(T::ContractAddress::get()),210		);211212		self.save()213	}214215	/// Force set `sponsor`.216	///217	/// Differs from [`set_sponsor`][`Self::set_sponsor`] in that confirmation218	/// from the `sponsor` is not required.219	///220	/// # Arguments221	///222	/// * `sponsor`: ID of the account of the sponsor-to-be.223	pub fn force_set_sponsor(&mut self, sponsor: T::AccountId) -> DispatchResult {224		self.check_is_internal()?;225226		self.collection.sponsorship = SponsorshipState::Confirmed(sponsor.clone());227228		<Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorSet(self.id, sponsor.clone()));229		<Pallet<T>>::deposit_event(Event::<T>::SponsorshipConfirmed(self.id, sponsor));230		<PalletEvm<T>>::deposit_log(231			erc::CollectionHelpersEvents::CollectionChanged {232				collection_id: eth::collection_id_to_address(self.id),233			}234			.to_log(T::ContractAddress::get()),235		);236237		self.save()238	}239240	/// Confirm sponsorship241	///242	/// In order for the sponsorship to become active, the user set as the sponsor must confirm their participation.243	/// Before confirming sponsorship, the user must be specified as the sponsor of the collection via [`Self::set_sponsor`].244	pub fn confirm_sponsorship(&mut self, sender: &T::AccountId) -> DispatchResult {245		self.check_is_internal()?;246		ensure!(247			self.collection.sponsorship.pending_sponsor() == Some(sender),248			Error::<T>::ConfirmSponsorshipFail249		);250251		self.collection.sponsorship = SponsorshipState::Confirmed(sender.clone());252253		<Pallet<T>>::deposit_event(Event::<T>::SponsorshipConfirmed(self.id, sender.clone()));254		<PalletEvm<T>>::deposit_log(255			erc::CollectionHelpersEvents::CollectionChanged {256				collection_id: eth::collection_id_to_address(self.id),257			}258			.to_log(T::ContractAddress::get()),259		);260261		self.save()262	}263264	/// Remove collection sponsor.265	pub fn remove_sponsor(&mut self, sender: &T::CrossAccountId) -> DispatchResult {266		self.check_is_internal()?;267		self.check_is_owner_or_admin(sender)?;268269		self.collection.sponsorship = SponsorshipState::Disabled;270271		<Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorRemoved(self.id));272		<PalletEvm<T>>::deposit_log(273			erc::CollectionHelpersEvents::CollectionChanged {274				collection_id: eth::collection_id_to_address(self.id),275			}276			.to_log(T::ContractAddress::get()),277		);278		self.save()279	}280281	/// Force remove `sponsor`.282	///283	/// Differs from `remove_sponsor` in that284	/// it doesn't require consent from the `owner` of the collection.285	pub fn force_remove_sponsor(&mut self) -> DispatchResult {286		self.check_is_internal()?;287288		self.collection.sponsorship = SponsorshipState::Disabled;289290		<Pallet<T>>::deposit_event(Event::<T>::CollectionSponsorRemoved(self.id));291		<PalletEvm<T>>::deposit_log(292			erc::CollectionHelpersEvents::CollectionChanged {293				collection_id: eth::collection_id_to_address(self.id),294			}295			.to_log(T::ContractAddress::get()),296		);297		self.save()298	}299300	/// Checks that the collection was created with, and must be operated upon through **Unique API**.301	/// Now check only the `external` flag and if it's **true**, then return [`Error::CollectionIsExternal`] error.302	pub fn check_is_internal(&self) -> DispatchResult {303		if self.flags.external {304			return Err(<Error<T>>::CollectionIsExternal)?;305		}306307		Ok(())308	}309310	/// Checks that the collection was created with, and must be operated upon through an **assimilated API**.311	/// Now check only the `external` flag and if it's **false**, then return [`Error::CollectionIsInternal`] error.312	pub fn check_is_external(&self) -> DispatchResult {313		if !self.flags.external {314			return Err(<Error<T>>::CollectionIsInternal)?;315		}316317		Ok(())318	}319}320321impl<T: Config> Deref for CollectionHandle<T> {322	type Target = Collection<T::AccountId>;323324	fn deref(&self) -> &Self::Target {325		&self.collection326	}327}328329impl<T: Config> DerefMut for CollectionHandle<T> {330	fn deref_mut(&mut self) -> &mut Self::Target {331		&mut self.collection332	}333}334335impl<T: Config> CollectionHandle<T> {336	/// Checks if the `user` is the owner of the collection.337	pub fn check_is_owner(&self, user: &T::CrossAccountId) -> DispatchResult {338		ensure!(*user.as_sub() == self.owner, <Error<T>>::NoPermission);339		Ok(())340	}341342	/// Returns **true** if the `user` is the owner or administrator of the collection.343	pub fn is_owner_or_admin(&self, user: &T::CrossAccountId) -> bool {344		*user.as_sub() == self.owner || <IsAdmin<T>>::get((self.id, user))345	}346347	/// Checks if the `user` is the owner or administrator of the collection.348	pub fn check_is_owner_or_admin(&self, user: &T::CrossAccountId) -> DispatchResult {349		ensure!(self.is_owner_or_admin(user), <Error<T>>::NoPermission);350		Ok(())351	}352353	/// Returns **true** if354	/// * the `user`is a collection owner or admin355	/// * the collection limits allow the owner/admins to transfer/burn any collection token356	pub fn ignores_token_restrictions(&self, user: &T::CrossAccountId) -> bool {357		self.limits.owner_can_transfer() && self.is_owner_or_admin(user)358	}359360	/// Return **true** if `user` does not have enough token parts, and he can ignore such restrictions.361	pub fn ignores_owned_amount(&self, user: &T::CrossAccountId) -> bool {362		self.limits.owner_can_transfer() && self.is_owner_or_admin(user)363	}364365	/// Checks if the user is in the allow list. If not [Error::AddressNotInAllowlist] returns.366	pub fn check_allowlist(&self, user: &T::CrossAccountId) -> DispatchResult {367		ensure!(368			<Allowlist<T>>::get((self.id, user)),369			<Error<T>>::AddressNotInAllowlist370		);371		Ok(())372	}373374	/// Changes collection owner to another account375	/// #### Store read/writes376	/// 1 writes377	pub fn change_owner(378		&mut self,379		caller: T::CrossAccountId,380		new_owner: T::CrossAccountId,381	) -> DispatchResult {382		self.check_is_internal()?;383		self.check_is_owner(&caller)?;384		self.collection.owner = new_owner.as_sub().clone();385386		<Pallet<T>>::deposit_event(Event::<T>::CollectionOwnerChanged(387			self.id,388			new_owner.as_sub().clone(),389		));390		<PalletEvm<T>>::deposit_log(391			erc::CollectionHelpersEvents::CollectionChanged {392				collection_id: eth::collection_id_to_address(self.id),393			}394			.to_log(T::ContractAddress::get()),395		);396397		self.save()398	}399}400401#[frame_support::pallet]402pub mod pallet {403404	use super::*;405	use dispatch::CollectionDispatch;406	use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key, traits::StorageVersion};407	use up_data_structs::{TokenId, mapping::TokenAddressMapping};408	use scale_info::TypeInfo;409	use weights::WeightInfo;410411	#[pallet::config]412	pub trait Config:413		frame_system::Config + pallet_evm_coder_substrate::Config + pallet_evm::Config + TypeInfo414	{415		/// Weight information for functions of this pallet.416		type WeightInfo: WeightInfo;417418		/// Events compatible with [`frame_system::Config::Event`].419		type RuntimeEvent: IsType<<Self as frame_system::Config>::RuntimeEvent> + From<Event<Self>>;420421		/// Handler of accounts and payment.422		type Currency: Balanced<Self::AccountId> + Inspect<Self::AccountId>;423424		/// Set price to create a collection.425		#[pallet::constant]426		type CollectionCreationPrice: Get<427			<<Self as Config>::Currency as Inspect<Self::AccountId>>::Balance,428		>;429430		/// Dispatcher of operations on collections.431		type CollectionDispatch: CollectionDispatch<Self>;432433		/// Account which holds the chain's treasury.434		type TreasuryAccountId: Get<Self::AccountId>;435436		/// Address under which the CollectionHelper contract would be available.437		#[pallet::constant]438		type ContractAddress: Get<H160>;439440		/// Mapper for token addresses to Ethereum addresses.441		type EvmTokenAddressMapping: TokenAddressMapping<H160>;442443		/// Mapper for token addresses to [`CrossAccountId`].444		type CrossTokenAddressMapping: TokenAddressMapping<Self::CrossAccountId>;445	}446447	const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);448	/// Collection id for native fungible collction.449	pub const NATIVE_FUNGIBLE_COLLECTION_ID: CollectionId = CollectionId(0);450451	#[pallet::pallet]452	#[pallet::storage_version(STORAGE_VERSION)]453	pub struct Pallet<T>(_);454455	#[pallet::extra_constants]456	impl<T: Config> Pallet<T> {457		/// Maximum admins per collection.458		pub fn collection_admins_limit() -> u32 {459			COLLECTION_ADMINS_LIMIT460		}461	}462463	#[pallet::genesis_config]464	pub struct GenesisConfig<T>(PhantomData<T>);465466	impl<T: Config> Default for GenesisConfig<T> {467		fn default() -> Self {468			Self(Default::default())469		}470	}471472	#[pallet::genesis_build]473	impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {474		fn build(&self) {475			StorageVersion::new(1).put::<Pallet<T>>();476		}477	}478479	impl<T: Config> Pallet<T> {480		/// Helper function that handles deposit events481		pub fn deposit_event(event: Event<T>) {482			let event = <T as Config>::RuntimeEvent::from(event);483			let event = event.into();484			<frame_system::Pallet<T>>::deposit_event(event)485		}486	}487488	#[pallet::event]489	pub enum Event<T: Config> {490		/// New collection was created491		CollectionCreated(492			/// Globally unique identifier of newly created collection.493			CollectionId,494			/// [`CollectionMode`] converted into _u8_.495			u8,496			/// Collection owner.497			T::AccountId,498		),499500		/// New collection was destroyed501		CollectionDestroyed(502			/// Globally unique identifier of collection.503			CollectionId,504		),505506		/// New item was created.507		ItemCreated(508			/// Id of the collection where item was created.509			CollectionId,510			/// Id of an item. Unique within the collection.511			TokenId,512			/// Owner of newly created item513			T::CrossAccountId,514			/// Always 1 for NFT515			u128,516		),517518		/// Collection item was burned.519		ItemDestroyed(520			/// Id of the collection where item was destroyed.521			CollectionId,522			/// Identifier of burned NFT.523			TokenId,524			/// Which user has destroyed its tokens.525			T::CrossAccountId,526			/// Amount of token pieces destroed. Always 1 for NFT.527			u128,528		),529530		/// Item was transferred531		Transfer(532			/// Id of collection to which item is belong.533			CollectionId,534			/// Id of an item.535			TokenId,536			/// Original owner of item.537			T::CrossAccountId,538			/// New owner of item.539			T::CrossAccountId,540			/// Amount of token pieces transfered. Always 1 for NFT.541			u128,542		),543544		/// Amount pieces of token owned by `sender` was approved for `spender`.545		Approved(546			/// Id of collection to which item is belong.547			CollectionId,548			/// Id of an item.549			TokenId,550			/// Original owner of item.551			T::CrossAccountId,552			/// Id for which the approval was granted.553			T::CrossAccountId,554			/// Amount of token pieces transfered. Always 1 for NFT.555			u128,556		),557558		/// A `sender` approves operations on all owned tokens for `spender`.559		ApprovedForAll(560			/// Id of collection to which item is belong.561			CollectionId,562			/// Owner of a wallet.563			T::CrossAccountId,564			/// Id for which operator status was granted or rewoked.565			T::CrossAccountId,566			/// Is operator status granted or revoked?567			bool,568		),569570		/// The colletion property has been added or edited.571		CollectionPropertySet(572			/// Id of collection to which property has been set.573			CollectionId,574			/// The property that was set.575			PropertyKey,576		),577578		/// The property has been deleted.579		CollectionPropertyDeleted(580			/// Id of collection to which property has been deleted.581			CollectionId,582			/// The property that was deleted.583			PropertyKey,584		),585586		/// The token property has been added or edited.587		TokenPropertySet(588			/// Identifier of the collection whose token has the property set.589			CollectionId,590			/// The token for which the property was set.591			TokenId,592			/// The property that was set.593			PropertyKey,594		),595596		/// The token property has been deleted.597		TokenPropertyDeleted(598			/// Identifier of the collection whose token has the property deleted.599			CollectionId,600			/// The token for which the property was deleted.601			TokenId,602			/// The property that was deleted.603			PropertyKey,604		),605606		/// The token property permission of a collection has been set.607		PropertyPermissionSet(608			/// ID of collection to which property permission has been set.609			CollectionId,610			/// The property permission that was set.611			PropertyKey,612		),613614		/// Address was added to the allow list.615		AllowListAddressAdded(616			/// ID of the affected collection.617			CollectionId,618			/// Address of the added account.619			T::CrossAccountId,620		),621622		/// Address was removed from the allow list.623		AllowListAddressRemoved(624			/// ID of the affected collection.625			CollectionId,626			/// Address of the removed account.627			T::CrossAccountId,628		),629630		/// Collection admin was added.631		CollectionAdminAdded(632			/// ID of the affected collection.633			CollectionId,634			/// Admin address.635			T::CrossAccountId,636		),637638		/// Collection admin was removed.639		CollectionAdminRemoved(640			/// ID of the affected collection.641			CollectionId,642			/// Removed admin address.643			T::CrossAccountId,644		),645646		/// Collection limits were set.647		CollectionLimitSet(648			/// ID of the affected collection.649			CollectionId,650		),651652		/// Collection owned was changed.653		CollectionOwnerChanged(654			/// ID of the affected collection.655			CollectionId,656			/// New owner address.657			T::AccountId,658		),659660		/// Collection permissions were set.661		CollectionPermissionSet(662			/// ID of the affected collection.663			CollectionId,664		),665666		/// Collection sponsor was set.667		CollectionSponsorSet(668			/// ID of the affected collection.669			CollectionId,670			/// New sponsor address.671			T::AccountId,672		),673674		/// New sponsor was confirm.675		SponsorshipConfirmed(676			/// ID of the affected collection.677			CollectionId,678			/// New sponsor address.679			T::AccountId,680		),681682		/// Collection sponsor was removed.683		CollectionSponsorRemoved(684			/// ID of the affected collection.685			CollectionId,686		),687	}688689	#[pallet::error]690	pub enum Error<T> {691		/// This collection does not exist.692		CollectionNotFound,693		/// Sender parameter and item owner must be equal.694		MustBeTokenOwner,695		/// No permission to perform action696		NoPermission,697		/// Destroying only empty collections is allowed698		CantDestroyNotEmptyCollection,699		/// Collection is not in mint mode.700		PublicMintingNotAllowed,701		/// Address is not in allow list.702		AddressNotInAllowlist,703704		/// Collection name can not be longer than 63 char.705		CollectionNameLimitExceeded,706		/// Collection description can not be longer than 255 char.707		CollectionDescriptionLimitExceeded,708		/// Token prefix can not be longer than 15 char.709		CollectionTokenPrefixLimitExceeded,710		/// Total collections bound exceeded.711		TotalCollectionsLimitExceeded,712		/// Exceeded max admin count713		CollectionAdminCountExceeded,714		/// Collection limit bounds per collection exceeded715		CollectionLimitBoundsExceeded,716		/// Tried to enable permissions which are only permitted to be disabled717		OwnerPermissionsCantBeReverted,718		/// Collection settings not allowing items transferring719		TransferNotAllowed,720		/// Account token limit exceeded per collection721		AccountTokenLimitExceeded,722		/// Collection token limit exceeded723		CollectionTokenLimitExceeded,724		/// Metadata flag frozen725		MetadataFlagFrozen,726727		/// Item does not exist728		TokenNotFound,729		/// Item is balance not enough730		TokenValueTooLow,731		/// Requested value is more than the approved732		ApprovedValueTooLow,733		/// Tried to approve more than owned734		CantApproveMoreThanOwned,735		/// Only spending from eth mirror could be approved736		AddressIsNotEthMirror,737738		/// Can't transfer tokens to ethereum zero address739		AddressIsZero,740741		/// The operation is not supported742		UnsupportedOperation,743744		/// Insufficient funds to perform an action745		NotSufficientFounds,746747		/// User does not satisfy the nesting rule748		UserIsNotAllowedToNest,749		/// Only tokens from specific collections may nest tokens under this one750		SourceCollectionIsNotAllowedToNest,751752		/// Tried to store more data than allowed in collection field753		CollectionFieldSizeExceeded,754755		/// Tried to store more property data than allowed756		NoSpaceForProperty,757758		/// Tried to store more property keys than allowed759		PropertyLimitReached,760761		/// Property key is too long762		PropertyKeyIsTooLong,763764		/// Only ASCII letters, digits, and symbols `_`, `-`, and `.` are allowed765		InvalidCharacterInPropertyKey,766767		/// Empty property keys are forbidden768		EmptyPropertyKey,769770		/// Tried to access an external collection with an internal API771		CollectionIsExternal,772773		/// Tried to access an internal collection with an external API774		CollectionIsInternal,775776		/// This address is not set as sponsor, use setCollectionSponsor first.777		ConfirmSponsorshipFail,778779		/// The user is not an administrator.780		UserIsNotCollectionAdmin,781	}782783	/// Storage of the count of created collections. Essentially contains the last collection ID.784	#[pallet::storage]785	pub type CreatedCollectionCount<T> = StorageValue<Value = CollectionId, QueryKind = ValueQuery>;786787	/// Storage of the count of deleted collections.788	#[pallet::storage]789	pub type DestroyedCollectionCount<T> =790		StorageValue<Value = CollectionId, QueryKind = ValueQuery>;791792	/// Storage of collection info.793	#[pallet::storage]794	pub type CollectionById<T> = StorageMap<795		Hasher = Blake2_128Concat,796		Key = CollectionId,797		Value = Collection<<T as frame_system::Config>::AccountId>,798		QueryKind = OptionQuery,799	>;800801	/// Storage of collection properties.802	#[pallet::storage]803	#[pallet::getter(fn collection_properties)]804	pub type CollectionProperties<T> = StorageMap<805		Hasher = Blake2_128Concat,806		Key = CollectionId,807		Value = CollectionPropertiesT,808		QueryKind = ValueQuery,809	>;810811	/// Storage of token property permissions of a collection.812	#[pallet::storage]813	#[pallet::getter(fn property_permissions)]814	pub type CollectionPropertyPermissions<T> = StorageMap<815		Hasher = Blake2_128Concat,816		Key = CollectionId,817		Value = PropertiesPermissionMap,818		QueryKind = ValueQuery,819	>;820821	/// Storage of the amount of collection admins.822	#[pallet::storage]823	pub type AdminAmount<T> = StorageMap<824		Hasher = Blake2_128Concat,825		Key = CollectionId,826		Value = u32,827		QueryKind = ValueQuery,828	>;829830	/// List of collection admins.831	#[pallet::storage]832	pub type IsAdmin<T: Config> = StorageNMap<833		Key = (834			Key<Blake2_128Concat, CollectionId>,835			Key<Blake2_128Concat, T::CrossAccountId>,836		),837		Value = bool,838		QueryKind = ValueQuery,839	>;840841	/// Allowlisted collection users.842	#[pallet::storage]843	pub type Allowlist<T: Config> = StorageNMap<844		Key = (845			Key<Blake2_128Concat, CollectionId>,846			Key<Blake2_128Concat, T::CrossAccountId>,847		),848		Value = bool,849		QueryKind = ValueQuery,850	>;851852	/// Not used by code, exists only to provide some types to metadata.853	#[pallet::storage]854	pub type DummyStorageValue<T: Config> = StorageValue<855		Value = (856			CollectionStats,857			CollectionId,858			TokenId,859			TokenChild,860			PhantomType<(861				TokenData<T::CrossAccountId>,862				RpcCollection<T::AccountId>,863				// PoV Estimate Info864				PovInfo,865			)>,866		),867		QueryKind = OptionQuery,868	>;869}870871/// Value representation with delayed initialization time.872pub struct LazyValue<T, F: FnOnce() -> T> {873	value: Option<T>,874	f: Option<F>,875}876877impl<T, F: FnOnce() -> T> LazyValue<T, F> {878	/// Create a new LazyValue.879	pub fn new(f: F) -> Self {880		Self {881			value: None,882			f: Some(f),883		}884	}885886	/// Get the value. If it is called the first time, the value will be initialized.887	pub fn value(&mut self) -> &T {888		self.compute_value_if_not_already();889		self.value.as_ref().unwrap()890	}891892	/// Get the value. If it is called the first time, the value will be initialized.893	pub fn value_mut(&mut self) -> &mut T {894		self.compute_value_if_not_already();895		self.value.as_mut().unwrap()896	}897898	fn into_inner(mut self) -> T {899		self.compute_value_if_not_already();900		self.value.unwrap()901	}902903	/// Is value initialized?904	pub fn has_value(&self) -> bool {905		self.value.is_some()906	}907908	fn compute_value_if_not_already(&mut self) {909		if self.value.is_none() {910			self.value = Some(self.f.take().unwrap()())911		}912	}913}914915fn check_token_permissions<T, FCA, FTO, FTE>(916	collection_admin_permitted: bool,917	token_owner_permitted: bool,918	is_collection_admin: &mut LazyValue<bool, FCA>,919	is_token_owner: &mut LazyValue<Result<bool, DispatchError>, FTO>,920	is_token_exist: &mut LazyValue<bool, FTE>,921) -> DispatchResult922where923	T: Config,924	FCA: FnOnce() -> bool,925	FTO: FnOnce() -> Result<bool, DispatchError>,926	FTE: FnOnce() -> bool,927{928	if !(collection_admin_permitted && *is_collection_admin.value()929		|| token_owner_permitted && (*is_token_owner.value())?)930	{931		fail!(<Error<T>>::NoPermission);932	}933934	let token_exist_due_to_owner_check_success =935		is_token_owner.has_value() && (*is_token_owner.value())?;936937	// If the token owner check has occurred and succeeded,938	// we know the token exists (otherwise, the owner check must fail).939	if !token_exist_due_to_owner_check_success {940		// If the token owner check didn't occur,941		// we must check the token's existence ourselves.942		if !is_token_exist.value() {943			fail!(<Error<T>>::TokenNotFound);944		}945	}946947	Ok(())948}949950impl<T: Config> Pallet<T> {951	/// Enshure that receiver address is correct.952	///953	/// Ethereum receiver 0x0000000000000000000000000000000000000000 is reserved, and shouldn't own tokens.954	pub fn ensure_correct_receiver(receiver: &T::CrossAccountId) -> DispatchResult {955		ensure!(956			&T::CrossAccountId::from_eth(H160([0; 20])) != receiver,957			<Error<T>>::AddressIsZero958		);959		Ok(())960	}961962	/// Get a vector of collection admins.963	pub fn adminlist(collection: CollectionId) -> Vec<T::CrossAccountId> {964		<IsAdmin<T>>::iter_prefix((collection,))965			.map(|(a, _)| a)966			.collect()967	}968969	/// Get a vector of users allowed to mint tokens.970	pub fn allowlist(collection: CollectionId) -> Vec<T::CrossAccountId> {971		<Allowlist<T>>::iter_prefix((collection,))972			.map(|(a, _)| a)973			.collect()974	}975976	/// Is `user` allowed to mint token in `collection`.977	pub fn allowed(collection: CollectionId, user: T::CrossAccountId) -> bool {978		<Allowlist<T>>::get((collection, user))979	}980981	/// Get statistics of collections.982	pub fn collection_stats() -> CollectionStats {983		let created = <CreatedCollectionCount<T>>::get();984		let destroyed = <DestroyedCollectionCount<T>>::get();985		CollectionStats {986			created: created.0,987			destroyed: destroyed.0,988			alive: created.0 - destroyed.0,989		}990	}991992	/// Get the effective limits for the collection.993	pub fn effective_collection_limits(collection: CollectionId) -> Option<CollectionLimits> {994		let collection = <CollectionById<T>>::get(collection)?;995		let limits = collection.limits;996		let effective_limits = CollectionLimits {997			account_token_ownership_limit: Some(limits.account_token_ownership_limit()),998			sponsored_data_size: Some(limits.sponsored_data_size()),999			sponsored_data_rate_limit: Some(1000				limits1001					.sponsored_data_rate_limit1002					.unwrap_or(SponsoringRateLimit::SponsoringDisabled),1003			),1004			token_limit: Some(limits.token_limit()),1005			sponsor_transfer_timeout: Some(limits.sponsor_transfer_timeout(1006				match collection.mode {1007					CollectionMode::NFT => NFT_SPONSOR_TRANSFER_TIMEOUT,1008					CollectionMode::Fungible(_) => FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,1009					CollectionMode::ReFungible => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,1010				},1011			)),1012			sponsor_approve_timeout: Some(limits.sponsor_approve_timeout()),1013			owner_can_transfer: Some(limits.owner_can_transfer()),1014			owner_can_destroy: Some(limits.owner_can_destroy()),1015			transfers_enabled: Some(limits.transfers_enabled()),1016		};10171018		Some(effective_limits)1019	}10201021	/// Returns information about the `collection` adapted for rpc.1022	pub fn rpc_collection(collection: CollectionId) -> Option<RpcCollection<T::AccountId>> {1023		let Collection {1024			name,1025			description,1026			owner,1027			mode,1028			token_prefix,1029			sponsorship,1030			limits,1031			permissions,1032			flags,1033		} = <CollectionById<T>>::get(collection)?;10341035		let token_property_permissions = <CollectionPropertyPermissions<T>>::get(collection)1036			.into_iter()1037			.map(|(key, permission)| PropertyKeyPermission { key, permission })1038			.collect();10391040		let properties = <CollectionProperties<T>>::get(collection)1041			.into_iter()1042			.map(|(key, value)| Property { key, value })1043			.collect();10441045		let permissions = CollectionPermissions {1046			access: Some(permissions.access()),1047			mint_mode: Some(permissions.mint_mode()),1048			nesting: Some(permissions.nesting().clone()),1049		};10501051		Some(RpcCollection {1052			name: name.into_inner(),1053			description: description.into_inner(),1054			owner,1055			mode,1056			token_prefix: token_prefix.into_inner(),1057			sponsorship,1058			limits,1059			permissions,1060			token_property_permissions,1061			properties,1062			read_only: flags.external,10631064			flags: RpcCollectionFlags {1065				foreign: flags.foreign,1066				erc721metadata: flags.erc721metadata,1067			},1068		})1069	}1070}10711072macro_rules! limit_default {1073	($old:ident, $new:ident, $($field:ident $(($arg:expr))? => $check:expr),* $(,)?) => {{1074		$(1075			if let Some($new) = $new.$field {1076				let $old = $old.$field($($arg)?);1077				let _ = $new;1078				let _ = $old;1079				$check1080			} else {1081				$new.$field = $old.$field1082			}1083		)*1084	}};1085}1086macro_rules! limit_default_clone {1087	($old:ident, $new:ident, $($field:ident $(($arg:expr))? => $check:expr),* $(,)?) => {{1088		$(1089			if let Some($new) = $new.$field.clone() {1090				let $old = $old.$field($($arg)?);1091				let _ = $new;1092				let _ = $old;1093				$check1094			} else {1095				$new.$field = $old.$field.clone()1096			}1097		)*1098	}};1099}11001101impl<T: Config> Pallet<T> {1102	/// Create new collection.1103	///1104	/// * `owner` - The owner of the collection.1105	/// * `data` - Description of the created collection.1106	/// * `flags` - Extra flags to store.1107	pub fn init_collection(1108		owner: T::CrossAccountId,1109		payer: T::CrossAccountId,1110		data: CreateCollectionData<T::CrossAccountId>,1111	) -> Result<CollectionId, DispatchError> {1112		ensure!(data.flags.is_allowed_for_user(), <Error<T>>::NoPermission);1113		Self::init_collection_internal(owner, payer, data)1114	}11151116	/// Initializes the collection with ForeignCollection flag. Returns [CollectionId] on success, [DispatchError] otherwise.1117	pub fn init_foreign_collection(1118		owner: T::CrossAccountId,1119		payer: T::CrossAccountId,1120		mut data: CreateCollectionData<T::CrossAccountId>,1121	) -> Result<CollectionId, DispatchError> {1122		data.flags.foreign = true;1123		let id = Self::init_collection_internal(owner, payer, data)?;1124		Ok(id)1125	}11261127	fn init_collection_internal(1128		owner: T::CrossAccountId,1129		payer: T::CrossAccountId,1130		data: CreateCollectionData<T::CrossAccountId>,1131	) -> Result<CollectionId, DispatchError> {1132		{1133			ensure!(1134				data.token_prefix.len() <= MAX_TOKEN_PREFIX_LENGTH as usize,1135				Error::<T>::CollectionTokenPrefixLimitExceeded1136			);1137		}11381139		let created_count = <CreatedCollectionCount<T>>::get()1140			.01141			.checked_add(1)1142			.ok_or(ArithmeticError::Overflow)?;1143		let destroyed_count = <DestroyedCollectionCount<T>>::get().0;1144		let id = CollectionId(created_count);11451146		// bound Total number of collections1147		ensure!(1148			created_count - destroyed_count <= COLLECTION_NUMBER_LIMIT,1149			<Error<T>>::TotalCollectionsLimitExceeded1150		);11511152		// =========11531154		let collection = Collection {1155			owner: owner.as_sub().clone(),1156			name: data.name,1157			mode: data.mode.clone(),1158			description: data.description,1159			token_prefix: data.token_prefix,1160			sponsorship: data1161				.pending_sponsor1162				.map(|sponsor| SponsorshipState::Unconfirmed(sponsor.as_sub().clone()))1163				.unwrap_or_default(),1164			limits: data1165				.limits1166				.map(|limits| Self::clamp_limits(data.mode.clone(), &Default::default(), limits))1167				.unwrap_or_else(|| Ok(CollectionLimits::default()))?,1168			permissions: data1169				.permissions1170				.map(|permissions| {1171					Self::clamp_permissions(data.mode.clone(), &Default::default(), permissions)1172				})1173				.unwrap_or_else(|| Ok(CollectionPermissions::default()))?,1174			flags: data.flags,1175		};11761177		let mut collection_properties = CollectionPropertiesT::new();1178		collection_properties1179			.try_set_from_iter(data.properties.into_iter())1180			.map_err(<Error<T>>::from)?;11811182		CollectionProperties::<T>::insert(id, collection_properties);11831184		let mut token_props_permissions = PropertiesPermissionMap::new();1185		token_props_permissions1186			.try_set_from_iter(data.token_property_permissions.into_iter())1187			.map_err(<Error<T>>::from)?;11881189		CollectionPropertyPermissions::<T>::insert(id, token_props_permissions);11901191		let mut admin_amount = 0u32;1192		for admin in data.admin_list.iter() {1193			if !<IsAdmin<T>>::get((id, admin)) {1194				<IsAdmin<T>>::insert((id, admin), true);1195				admin_amount = admin_amount1196					.checked_add(1)1197					.ok_or(<Error<T>>::CollectionAdminCountExceeded)?;1198			}1199		}1200		ensure!(1201			admin_amount <= Self::collection_admins_limit(),1202			<Error<T>>::CollectionAdminCountExceeded,1203		);1204		<AdminAmount<T>>::insert(id, admin_amount);12051206		// Take a (non-refundable) deposit of collection creation1207		{1208			let mut imbalance = <Debt<T::AccountId, <T as Config>::Currency>>::zero();1209			imbalance.subsume(<T as Config>::Currency::deposit(1210				&T::TreasuryAccountId::get(),1211				T::CollectionCreationPrice::get(),1212				Precision::Exact,1213			)?);1214			let credit =1215				<T as Config>::Currency::settle(payer.as_sub(), imbalance, Preservation::Preserve)1216					.map_err(|_| Error::<T>::NotSufficientFounds)?;12171218			debug_assert!(credit.peek().is_zero())1219		}12201221		<CreatedCollectionCount<T>>::put(created_count);1222		<Pallet<T>>::deposit_event(Event::CollectionCreated(1223			id,1224			data.mode.id(),1225			owner.as_sub().clone(),1226		));1227		<PalletEvm<T>>::deposit_log(1228			erc::CollectionHelpersEvents::CollectionCreated {1229				owner: *owner.as_eth(),1230				collection_id: eth::collection_id_to_address(id),1231			}1232			.to_log(T::ContractAddress::get()),1233		);1234		<CollectionById<T>>::insert(id, collection);1235		Ok(id)1236	}12371238	/// Destroy collection.1239	///1240	/// * `collection` - Collection handler.1241	/// * `sender` - The owner or administrator of the collection.1242	pub fn destroy_collection(1243		collection: CollectionHandle<T>,1244		sender: &T::CrossAccountId,1245	) -> DispatchResult {1246		ensure!(1247			collection.limits.owner_can_destroy(),1248			<Error<T>>::NoPermission,1249		);1250		collection.check_is_owner(sender)?;12511252		let destroyed_collections = <DestroyedCollectionCount<T>>::get()1253			.01254			.checked_add(1)1255			.ok_or(ArithmeticError::Overflow)?;12561257		// =========12581259		<DestroyedCollectionCount<T>>::put(destroyed_collections);1260		<CollectionById<T>>::remove(collection.id);1261		<AdminAmount<T>>::remove(collection.id);1262		let _ = <IsAdmin<T>>::clear_prefix((collection.id,), u32::MAX, None);1263		let _ = <Allowlist<T>>::clear_prefix((collection.id,), u32::MAX, None);1264		<CollectionProperties<T>>::remove(collection.id);12651266		<Pallet<T>>::deposit_event(Event::CollectionDestroyed(collection.id));12671268		<PalletEvm<T>>::deposit_log(1269			erc::CollectionHelpersEvents::CollectionDestroyed {1270				collection_id: eth::collection_id_to_address(collection.id),1271			}1272			.to_log(T::ContractAddress::get()),1273		);1274		Ok(())1275	}12761277	/// This function sets or removes a collection properties according to1278	/// `properties_updates` contents:1279	/// * sets a property under the <key> with the value provided `(<key>, Some(<value>))`1280	/// * removes a property under the <key> if the value is `None` `(<key>, None)`.1281	///1282	/// This function fires an event for each property change.1283	/// In case of an error, all the changes (including the events) will be reverted1284	/// since the function is transactional.1285	#[transactional]1286	fn modify_collection_properties(1287		collection: &CollectionHandle<T>,1288		sender: &T::CrossAccountId,1289		properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,1290	) -> DispatchResult {1291		collection.check_is_owner_or_admin(sender)?;12921293		let mut stored_properties = <CollectionProperties<T>>::get(collection.id);12941295		for (key, value) in properties_updates {1296			match value {1297				Some(value) => {1298					stored_properties1299						.try_set(key.clone(), value)1300						.map_err(<Error<T>>::from)?;13011302					Self::deposit_event(Event::CollectionPropertySet(collection.id, key));1303					<PalletEvm<T>>::deposit_log(1304						erc::CollectionHelpersEvents::CollectionChanged {1305							collection_id: eth::collection_id_to_address(collection.id),1306						}1307						.to_log(T::ContractAddress::get()),1308					);1309				}1310				None => {1311					stored_properties.remove(&key).map_err(<Error<T>>::from)?;13121313					Self::deposit_event(Event::CollectionPropertyDeleted(collection.id, key));1314					<PalletEvm<T>>::deposit_log(1315						erc::CollectionHelpersEvents::CollectionChanged {1316							collection_id: eth::collection_id_to_address(collection.id),1317						}1318						.to_log(T::ContractAddress::get()),1319					);1320				}1321			}1322		}13231324		<CollectionProperties<T>>::set(collection.id, stored_properties);13251326		Ok(())1327	}13281329	/// Sets or unsets the approval of a given operator.1330	///1331	/// The `operator` is allowed to transfer all token pieces of the `owner` on their behalf.1332	/// - `owner`: Token owner1333	/// - `operator`: Operator1334	/// - `approve`: Should operator status be granted or revoked?1335	pub fn set_allowance_for_all(1336		collection: &CollectionHandle<T>,1337		owner: &T::CrossAccountId,1338		operator: &T::CrossAccountId,1339		approve: bool,1340		set_allowance: impl FnOnce(),1341		log: evm_coder::ethereum::Log,1342	) -> DispatchResult {1343		if collection.permissions.access() == AccessMode::AllowList {1344			collection.check_allowlist(owner)?;1345			collection.check_allowlist(operator)?;1346		}13471348		Self::ensure_correct_receiver(operator)?;13491350		set_allowance();13511352		<PalletEvm<T>>::deposit_log(log);1353		Self::deposit_event(Event::ApprovedForAll(1354			collection.id,1355			owner.clone(),1356			operator.clone(),1357			approve,1358		));1359		Ok(())1360	}13611362	/// Set collection property.1363	///1364	/// * `collection` - Collection handler.1365	/// * `sender` - The owner or administrator of the collection.1366	/// * `property` - The property to set.1367	pub fn set_collection_property(1368		collection: &CollectionHandle<T>,1369		sender: &T::CrossAccountId,1370		property: Property,1371	) -> DispatchResult {1372		Self::set_collection_properties(collection, sender, [property].into_iter())1373	}13741375	/// Set a scoped collection property, where the scope is a special prefix1376	/// prohibiting a user access to change the property directly.1377	///1378	/// * `collection_id` - ID of the collection for which the property is being set.1379	/// * `scope` - Property scope.1380	/// * `property` - The property to set.1381	pub fn set_scoped_collection_property(1382		collection_id: CollectionId,1383		scope: PropertyScope,1384		property: Property,1385	) -> DispatchResult {1386		CollectionProperties::<T>::try_mutate(collection_id, |properties| {1387			properties.try_scoped_set(scope, property.key, property.value)1388		})1389		.map_err(<Error<T>>::from)?;13901391		Ok(())1392	}13931394	/// Set scoped collection properties, where the scope is a special prefix1395	/// prohibiting a user access to change the properties directly.1396	///1397	/// * `collection_id` - ID of the collection for which the properties is being set.1398	/// * `scope` - Property scope.1399	/// * `properties` - The properties to set.1400	pub fn set_scoped_collection_properties(1401		collection_id: CollectionId,1402		scope: PropertyScope,1403		properties: impl Iterator<Item = Property>,1404	) -> DispatchResult {1405		CollectionProperties::<T>::try_mutate(collection_id, |stored_properties| {1406			stored_properties.try_scoped_set_from_iter(scope, properties)1407		})1408		.map_err(<Error<T>>::from)?;14091410		Ok(())1411	}14121413	/// Set collection properties.1414	///1415	/// * `collection` - Collection handler.1416	/// * `sender` - The owner or administrator of the collection.1417	/// * `properties` - The properties to set.1418	pub fn set_collection_properties(1419		collection: &CollectionHandle<T>,1420		sender: &T::CrossAccountId,1421		properties: impl Iterator<Item = Property>,1422	) -> DispatchResult {1423		Self::modify_collection_properties(1424			collection,1425			sender,1426			properties.map(|property| (property.key, Some(property.value))),1427		)1428	}14291430	/// Delete collection property.1431	///1432	/// * `collection` - Collection handler.1433	/// * `sender` - The owner or administrator of the collection.1434	/// * `property` - The property to delete.1435	pub fn delete_collection_property(1436		collection: &CollectionHandle<T>,1437		sender: &T::CrossAccountId,1438		property_key: PropertyKey,1439	) -> DispatchResult {1440		Self::delete_collection_properties(collection, sender, [property_key].into_iter())1441	}14421443	/// Delete collection properties.1444	///1445	/// * `collection` - Collection handler.1446	/// * `sender` - The owner or administrator of the collection.1447	/// * `properties` - The properties to delete.1448	pub fn delete_collection_properties(1449		collection: &CollectionHandle<T>,1450		sender: &T::CrossAccountId,1451		property_keys: impl Iterator<Item = PropertyKey>,1452	) -> DispatchResult {1453		Self::modify_collection_properties(collection, sender, property_keys.map(|key| (key, None)))1454	}14551456	/// Set collection propetry permission without any checks.1457	///1458	/// Used for migrations.1459	///1460	/// * `collection` - Collection handler.1461	/// * `property_permissions` - Property permissions.1462	pub fn set_property_permission_unchecked(1463		collection: CollectionId,1464		property_permission: PropertyKeyPermission,1465	) -> DispatchResult {1466		<CollectionPropertyPermissions<T>>::try_mutate(collection, |permissions| {1467			permissions.try_set(property_permission.key, property_permission.permission)1468		})1469		.map_err(<Error<T>>::from)?;1470		Ok(())1471	}14721473	/// Set collection property permission.1474	///1475	/// * `collection` - Collection handler.1476	/// * `sender` - The owner or administrator of the collection.1477	/// * `property_permission` - Property permission.1478	pub fn set_property_permission(1479		collection: &CollectionHandle<T>,1480		sender: &T::CrossAccountId,1481		property_permission: PropertyKeyPermission,1482	) -> DispatchResult {1483		Self::set_scoped_property_permission(1484			collection,1485			sender,1486			PropertyScope::None,1487			property_permission,1488		)1489	}14901491	/// Set collection property permission with scope.1492	///1493	/// * `collection` - Collection handler.1494	/// * `sender` - The owner or administrator of the collection.1495	/// * `scope` - Property scope.1496	/// * `property_permission` - Property permission.1497	pub fn set_scoped_property_permission(1498		collection: &CollectionHandle<T>,1499		sender: &T::CrossAccountId,1500		scope: PropertyScope,1501		property_permission: PropertyKeyPermission,1502	) -> DispatchResult {1503		collection.check_is_owner_or_admin(sender)?;15041505		let all_permissions = CollectionPropertyPermissions::<T>::get(collection.id);1506		let current_permission = all_permissions.get(&property_permission.key);1507		if matches![1508			current_permission,1509			Some(PropertyPermission { mutable: false, .. })1510		] {1511			return Err(<Error<T>>::NoPermission.into());1512		}15131514		CollectionPropertyPermissions::<T>::try_mutate(collection.id, |permissions| {1515			let property_permission = property_permission.clone();1516			permissions.try_scoped_set(1517				scope,1518				property_permission.key,1519				property_permission.permission,1520			)1521		})1522		.map_err(<Error<T>>::from)?;15231524		Self::deposit_event(Event::PropertyPermissionSet(1525			collection.id,1526			property_permission.key,1527		));1528		<PalletEvm<T>>::deposit_log(1529			erc::CollectionHelpersEvents::CollectionChanged {1530				collection_id: eth::collection_id_to_address(collection.id),1531			}1532			.to_log(T::ContractAddress::get()),1533		);15341535		Ok(())1536	}15371538	/// Set token property permission.1539	///1540	/// * `collection` - Collection handler.1541	/// * `sender` - The owner or administrator of the collection.1542	/// * `property_permissions` - Property permissions.1543	#[transactional]1544	pub fn set_token_property_permissions(1545		collection: &CollectionHandle<T>,1546		sender: &T::CrossAccountId,1547		property_permissions: Vec<PropertyKeyPermission>,1548	) -> DispatchResult {1549		Self::set_scoped_token_property_permissions(1550			collection,1551			sender,1552			PropertyScope::None,1553			property_permissions,1554		)1555	}15561557	/// Set token property permission with scope.1558	///1559	/// * `collection` - Collection handler.1560	/// * `sender` - The owner or administrator of the collection.1561	/// * `scope` - Property scope.1562	/// * `property_permissions` - Property permissions.1563	#[transactional]1564	pub fn set_scoped_token_property_permissions(1565		collection: &CollectionHandle<T>,1566		sender: &T::CrossAccountId,1567		scope: PropertyScope,1568		property_permissions: Vec<PropertyKeyPermission>,1569	) -> DispatchResult {1570		for prop_pemission in property_permissions {1571			Self::set_scoped_property_permission(collection, sender, scope, prop_pemission)?;1572		}15731574		Ok(())1575	}15761577	/// Get collection property.1578	pub fn get_collection_property(1579		collection_id: CollectionId,1580		key: &PropertyKey,1581	) -> Option<PropertyValue> {1582		Self::collection_properties(collection_id).get(key).cloned()1583	}15841585	/// Convert byte vector to property key vector.1586	pub fn bytes_keys_to_property_keys(1587		keys: Vec<Vec<u8>>,1588	) -> Result<Vec<PropertyKey>, DispatchError> {1589		keys.into_iter()1590			.map(|key| -> Result<PropertyKey, DispatchError> {1591				key.try_into()1592					.map_err(|_| <Error<T>>::PropertyKeyIsTooLong.into())1593			})1594			.collect::<Result<Vec<PropertyKey>, DispatchError>>()1595	}15961597	/// Get properties according to given keys.1598	pub fn filter_collection_properties(1599		collection_id: CollectionId,1600		keys: Option<Vec<PropertyKey>>,1601	) -> Result<Vec<Property>, DispatchError> {1602		let properties = Self::collection_properties(collection_id);16031604		let properties = keys1605			.map(|keys| {1606				keys.into_iter()1607					.filter_map(|key| {1608						properties.get(&key).map(|value| Property {1609							key,1610							value: value.clone(),1611						})1612					})1613					.collect()1614			})1615			.unwrap_or_else(|| {1616				properties1617					.into_iter()1618					.map(|(key, value)| Property { key, value })1619					.collect()1620			});16211622		Ok(properties)1623	}16241625	/// Get property permissions according to given keys.1626	pub fn filter_property_permissions(1627		collection_id: CollectionId,1628		keys: Option<Vec<PropertyKey>>,1629	) -> Result<Vec<PropertyKeyPermission>, DispatchError> {1630		let permissions = Self::property_permissions(collection_id);16311632		let key_permissions = keys1633			.map(|keys| {1634				keys.into_iter()1635					.filter_map(|key| {1636						permissions1637							.get(&key)1638							.map(|permission| PropertyKeyPermission {1639								key,1640								permission: permission.clone(),1641							})1642					})1643					.collect()1644			})1645			.unwrap_or_else(|| {1646				permissions1647					.into_iter()1648					.map(|(key, permission)| PropertyKeyPermission { key, permission })1649					.collect()1650			});16511652		Ok(key_permissions)1653	}16541655	/// Toggle `user` participation in the `collection`'s allow list.1656	/// #### Store read/writes1657	/// 1 writes1658	pub fn toggle_allowlist(1659		collection: &CollectionHandle<T>,1660		sender: &T::CrossAccountId,1661		user: &T::CrossAccountId,1662		allowed: bool,1663	) -> DispatchResult {1664		collection.check_is_owner_or_admin(sender)?;16651666		// =========16671668		if allowed {1669			<Allowlist<T>>::insert((collection.id, user), true);1670			Self::deposit_event(Event::<T>::AllowListAddressAdded(1671				collection.id,1672				user.clone(),1673			));1674		} else {1675			<Allowlist<T>>::remove((collection.id, user));1676			Self::deposit_event(Event::<T>::AllowListAddressRemoved(1677				collection.id,1678				user.clone(),1679			));1680		}16811682		<PalletEvm<T>>::deposit_log(1683			erc::CollectionHelpersEvents::CollectionChanged {1684				collection_id: eth::collection_id_to_address(collection.id),1685			}1686			.to_log(T::ContractAddress::get()),1687		);16881689		Ok(())1690	}16911692	/// Toggle `user` participation in the `collection`'s admin list.1693	/// #### Store read/writes1694	/// 2 reads, 2 writes1695	pub fn toggle_admin(1696		collection: &CollectionHandle<T>,1697		sender: &T::CrossAccountId,1698		user: &T::CrossAccountId,1699		admin: bool,1700	) -> DispatchResult {1701		collection.check_is_internal()?;1702		collection.check_is_owner(sender)?;17031704		let is_admin = <IsAdmin<T>>::get((collection.id, user));1705		if is_admin == admin {1706			if admin {1707				return Ok(());1708			} else {1709				return Err(Error::<T>::UserIsNotCollectionAdmin.into());1710			}1711		}1712		let amount = <AdminAmount<T>>::get(collection.id);17131714		// =========17151716		if admin {1717			let amount = amount1718				.checked_add(1)1719				.ok_or(<Error<T>>::CollectionAdminCountExceeded)?;1720			ensure!(1721				amount <= Self::collection_admins_limit(),1722				<Error<T>>::CollectionAdminCountExceeded,1723			);17241725			<AdminAmount<T>>::insert(collection.id, amount);1726			<IsAdmin<T>>::insert((collection.id, user), true);17271728			Self::deposit_event(Event::<T>::CollectionAdminAdded(1729				collection.id,1730				user.clone(),1731			));1732		} else {1733			<AdminAmount<T>>::insert(collection.id, amount.saturating_sub(1));1734			<IsAdmin<T>>::remove((collection.id, user));17351736			Self::deposit_event(Event::<T>::CollectionAdminRemoved(1737				collection.id,1738				user.clone(),1739			));1740		}17411742		<PalletEvm<T>>::deposit_log(1743			erc::CollectionHelpersEvents::CollectionChanged {1744				collection_id: eth::collection_id_to_address(collection.id),1745			}1746			.to_log(T::ContractAddress::get()),1747		);17481749		Ok(())1750	}17511752	/// Update collection limits.1753	pub fn update_limits(1754		user: &T::CrossAccountId,1755		collection: &mut CollectionHandle<T>,1756		new_limit: CollectionLimits,1757	) -> DispatchResult {1758		collection.check_is_internal()?;1759		collection.check_is_owner_or_admin(user)?;17601761		collection.limits =1762			Self::clamp_limits(collection.mode.clone(), &collection.limits, new_limit)?;17631764		Self::deposit_event(Event::<T>::CollectionLimitSet(collection.id));1765		<PalletEvm<T>>::deposit_log(1766			erc::CollectionHelpersEvents::CollectionChanged {1767				collection_id: eth::collection_id_to_address(collection.id),1768			}1769			.to_log(T::ContractAddress::get()),1770		);17711772		collection.save()1773	}17741775	/// Merge set fields from `new_limit` to `old_limit`.1776	fn clamp_limits(1777		mode: CollectionMode,1778		old_limit: &CollectionLimits,1779		mut new_limit: CollectionLimits,1780	) -> Result<CollectionLimits, DispatchError> {1781		let limits = old_limit;1782		limit_default!(old_limit, new_limit,1783			account_token_ownership_limit => ensure!(1784				new_limit <= MAX_TOKEN_OWNERSHIP,1785				<Error<T>>::CollectionLimitBoundsExceeded,1786			),1787			sponsored_data_size => ensure!(1788				new_limit <= CUSTOM_DATA_LIMIT,1789				<Error<T>>::CollectionLimitBoundsExceeded,1790			),17911792			sponsored_data_rate_limit => {},1793			token_limit => ensure!(1794				old_limit >= new_limit && new_limit > 0,1795				<Error<T>>::CollectionTokenLimitExceeded1796			),17971798			sponsor_transfer_timeout(match mode {1799				CollectionMode::NFT => NFT_SPONSOR_TRANSFER_TIMEOUT,1800				CollectionMode::Fungible(_) => FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,1801				CollectionMode::ReFungible => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,1802			}) => ensure!(1803				new_limit <= MAX_SPONSOR_TIMEOUT,1804				<Error<T>>::CollectionLimitBoundsExceeded,1805			),1806			sponsor_approve_timeout => {},1807			owner_can_transfer => ensure!(1808				!limits.owner_can_transfer_instaled() ||1809				old_limit || !new_limit,1810				<Error<T>>::OwnerPermissionsCantBeReverted,1811			),1812			owner_can_destroy => ensure!(1813				old_limit || !new_limit,1814				<Error<T>>::OwnerPermissionsCantBeReverted,1815			),1816			transfers_enabled => {},1817		);1818		Ok(new_limit)1819	}18201821	/// Update collection permissions.1822	pub fn update_permissions(1823		user: &T::CrossAccountId,1824		collection: &mut CollectionHandle<T>,1825		new_permission: CollectionPermissions,1826	) -> DispatchResult {1827		collection.check_is_internal()?;1828		collection.check_is_owner_or_admin(user)?;1829		collection.permissions = Self::clamp_permissions(1830			collection.mode.clone(),1831			&collection.permissions,1832			new_permission,1833		)?;18341835		Self::deposit_event(Event::<T>::CollectionPermissionSet(collection.id));1836		<PalletEvm<T>>::deposit_log(1837			erc::CollectionHelpersEvents::CollectionChanged {1838				collection_id: eth::collection_id_to_address(collection.id),1839			}1840			.to_log(T::ContractAddress::get()),1841		);18421843		collection.save()1844	}18451846	/// Merge set fields from `new_permission` to `old_permission`.1847	fn clamp_permissions(1848		_mode: CollectionMode,1849		old_permission: &CollectionPermissions,1850		mut new_permission: CollectionPermissions,1851	) -> Result<CollectionPermissions, DispatchError> {1852		limit_default_clone!(old_permission, new_permission,1853			access => {},1854			mint_mode => {},1855			nesting => { /* todo check for permissive, if only it gets out of benchmarks */ },1856		);1857		Ok(new_permission)1858	}18591860	/// Repair possibly broken properties of a collection.1861	pub fn repair_collection(collection_id: CollectionId) -> DispatchResult {1862		CollectionProperties::<T>::mutate(collection_id, |properties| {1863			properties.recompute_consumed_space();1864		});18651866		Ok(())1867	}1868}18691870/// Indicates unsupported methods by returning [Error::UnsupportedOperation].1871#[macro_export]1872macro_rules! unsupported {1873	($runtime:path) => {1874		Err($crate::Error::<$runtime>::UnsupportedOperation.into())1875	};1876}18771878/// Return weights for various worst-case operations.1879pub trait CommonWeightInfo<CrossAccountId> {1880	/// Weight of item creation.1881	fn create_item(data: &CreateItemData) -> Weight {1882		Self::create_multiple_items(from_ref(data))1883	}18841885	/// Weight of items creation.1886	fn create_multiple_items(amount: &[CreateItemData]) -> Weight;18871888	/// Weight of items creation.1889	fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;18901891	/// The weight of the burning item.1892	fn burn_item() -> Weight;18931894	/// Property setting weight.1895	///1896	/// * `amount`- The number of properties to set.1897	fn set_collection_properties(amount: u32) -> Weight;18981899	/// Collection property deletion weight.1900	///1901	/// * `amount`- The number of properties to set.1902	fn delete_collection_properties(amount: u32) -> Weight;19031904	/// Token property setting weight.1905	///1906	/// * `amount`- The number of properties to set.1907	fn set_token_properties(amount: u32) -> Weight;19081909	/// Token property deletion weight.1910	///1911	/// * `amount`- The number of properties to delete.1912	fn delete_token_properties(amount: u32) -> Weight;19131914	/// Token property permissions set weight.1915	///1916	/// * `amount`- The number of property permissions to set.1917	fn set_token_property_permissions(amount: u32) -> Weight;19181919	/// Transfer price of the token or its parts.1920	fn transfer() -> Weight;19211922	/// The price of setting the permission of the operation from another user.1923	fn approve() -> Weight;19241925	/// The price of setting the permission of the operation from another user for eth mirror.1926	fn approve_from() -> Weight;19271928	/// Transfer price from another user.1929	fn transfer_from() -> Weight;19301931	/// The price of burning a token from another user.1932	fn burn_from() -> Weight;19331934	/// Differs from burn_item in case of Fungible and Refungible, as it should burn1935	/// whole users's balance.1936	///1937	/// This method shouldn't be used directly, as it doesn't count breadth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead1938	fn burn_recursively_self_raw() -> Weight;19391940	/// Cost of iterating over `amount` children while burning, without counting child burning itself.1941	///1942	/// This method shouldn't be used directly, as it doesn't count depth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead1943	fn burn_recursively_breadth_raw(amount: u32) -> Weight;19441945	/// The price of recursive burning a token.1946	///1947	/// `max_selfs` - The maximum burning weight of the token itself.1948	/// `max_breadth` - The maximum number of nested tokens to burn.1949	fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {1950		Self::burn_recursively_self_raw()1951			.saturating_mul(max_selfs.max(1) as u64)1952			.saturating_add(Self::burn_recursively_breadth_raw(max_breadth))1953	}19541955	/// The price of retrieving token owner1956	fn token_owner() -> Weight;19571958	/// The price of setting approval for all1959	fn set_allowance_for_all() -> Weight;19601961	/// The price of repairing an item.1962	fn force_repair_item() -> Weight;1963}19641965/// Weight info extension trait for refungible pallet.1966pub trait RefungibleExtensionsWeightInfo {1967	/// Weight of token repartition.1968	fn repartition() -> Weight;1969}19701971/// Common collection operations.1972///1973/// It wraps methods in Fungible, Nonfungible and Refungible pallets1974/// and adds weight info.1975pub trait CommonCollectionOperations<T: Config> {1976	/// Create token.1977	///1978	/// * `sender` - The user who mint the token and pays for the transaction.1979	/// * `to` - The user who will own the token.1980	/// * `data` - Token data.1981	/// * `nesting_budget` - A budget that can be spent on nesting tokens.1982	fn create_item(1983		&self,1984		sender: T::CrossAccountId,1985		to: T::CrossAccountId,1986		data: CreateItemData,1987		nesting_budget: &dyn Budget,1988	) -> DispatchResultWithPostInfo;19891990	/// Create multiple tokens.1991	///1992	/// * `sender` - The user who mint the token and pays for the transaction.1993	/// * `to` - The user who will own the token.1994	/// * `data` - Token data.1995	/// * `nesting_budget` - A budget that can be spent on nesting tokens.1996	fn create_multiple_items(1997		&self,1998		sender: T::CrossAccountId,1999		to: T::CrossAccountId,2000		data: Vec<CreateItemData>,2001		nesting_budget: &dyn Budget,2002	) -> DispatchResultWithPostInfo;20032004	/// Create multiple tokens.2005	///2006	/// * `sender` - The user who mint the token and pays for the transaction.2007	/// * `to` - The user who will own the token.2008	/// * `data` - Token data.2009	/// * `nesting_budget` - A budget that can be spent on nesting tokens.2010	fn create_multiple_items_ex(2011		&self,2012		sender: T::CrossAccountId,2013		data: CreateItemExData<T::CrossAccountId>,2014		nesting_budget: &dyn Budget,2015	) -> DispatchResultWithPostInfo;20162017	/// Burn token.2018	///2019	/// * `sender` - The user who owns the token.2020	/// * `token` - Token id that will burned.2021	/// * `amount` - The number of parts of the token that will be burned.2022	fn burn_item(2023		&self,2024		sender: T::CrossAccountId,2025		token: TokenId,2026		amount: u128,2027	) -> DispatchResultWithPostInfo;20282029	/// Burn token and all nested tokens recursievly.2030	///2031	/// * `sender` - The user who owns the token.2032	/// * `token` - Token id that will burned.2033	/// * `self_budget` - The budget that can be spent on burning tokens.2034	/// * `breadth_budget` - The budget that can be spent on burning nested tokens.2035	fn burn_item_recursively(2036		&self,2037		sender: T::CrossAccountId,2038		token: TokenId,2039		self_budget: &dyn Budget,2040		breadth_budget: &dyn Budget,2041	) -> DispatchResultWithPostInfo;20422043	/// Set collection properties.2044	///2045	/// * `sender` - Must be either the owner of the collection or its admin.2046	/// * `properties` - Properties to be set.2047	fn set_collection_properties(2048		&self,2049		sender: T::CrossAccountId,2050		properties: Vec<Property>,2051	) -> DispatchResultWithPostInfo;20522053	/// Delete collection properties.2054	///2055	/// * `sender` - Must be either the owner of the collection or its admin.2056	/// * `properties` - The properties to be removed.2057	fn delete_collection_properties(2058		&self,2059		sender: &T::CrossAccountId,2060		property_keys: Vec<PropertyKey>,2061	) -> DispatchResultWithPostInfo;20622063	/// Set token properties.2064	///2065	/// The appropriate [`PropertyPermission`] for the token property2066	/// must be set with [`Self::set_token_property_permissions`].2067	///2068	/// * `sender` - Must be either the owner of the token or its admin.2069	/// * `token_id` - The token for which the properties are being set.2070	/// * `properties` - Properties to be set.2071	/// * `budget` - Budget for setting properties.2072	fn set_token_properties(2073		&self,2074		sender: T::CrossAccountId,2075		token_id: TokenId,2076		properties: Vec<Property>,2077		budget: &dyn Budget,2078	) -> DispatchResultWithPostInfo;20792080	/// Remove token properties.2081	///2082	/// The appropriate [`PropertyPermission`] for the token property2083	/// must be set with [`Self::set_token_property_permissions`].2084	///2085	/// * `sender` - Must be either the owner of the token or its admin.2086	/// * `token_id` - The token for which the properties are being remove.2087	/// * `property_keys` - Keys to remove corresponding properties.2088	/// * `budget` - Budget for removing properties.2089	fn delete_token_properties(2090		&self,2091		sender: T::CrossAccountId,2092		token_id: TokenId,2093		property_keys: Vec<PropertyKey>,2094		budget: &dyn Budget,2095	) -> DispatchResultWithPostInfo;20962097	/// Get token properties raw map.2098	///2099	/// * `token_id` - The token which properties are needed.2100	fn get_token_properties_raw(&self, token_id: TokenId) -> Option<TokenProperties>;21012102	/// Set token properties raw map.2103	///2104	/// * `token_id` - The token for which the properties are being set.2105	/// * `map` - The raw map containing the token's properties.2106	fn set_token_properties_raw(&self, token_id: TokenId, map: TokenProperties);21072108	/// Set token property permissions.2109	///2110	/// * `sender` - Must be either the owner of the token or its admin.2111	/// * `token_id` - The token for which the properties are being set.2112	/// * `property_permissions` - Property permissions to be set.2113	/// * `budget` - Budget for setting properties.2114	fn set_token_property_permissions(2115		&self,2116		sender: &T::CrossAccountId,2117		property_permissions: Vec<PropertyKeyPermission>,2118	) -> DispatchResultWithPostInfo;21192120	/// Transfer amount of token pieces.2121	///2122	/// * `sender` - Donor user.2123	/// * `to` - Recepient user.2124	/// * `token` - The token of which parts are being sent.2125	/// * `amount` - The number of parts of the token that will be transferred.2126	/// * `budget` - The maximum budget that can be spent on the transfer.2127	fn transfer(2128		&self,2129		sender: T::CrossAccountId,2130		to: T::CrossAccountId,2131		token: TokenId,2132		amount: u128,2133		budget: &dyn Budget,2134	) -> DispatchResultWithPostInfo;21352136	/// Grant access to another account to transfer parts of the token owned by the calling user via [Self::transfer_from].2137	///2138	/// * `sender` - The user who grants access to the token.2139	/// * `spender` - The user to whom the rights are granted.2140	/// * `token` - The token to which access is granted.2141	/// * `amount` - The amount of pieces that another user can dispose of.2142	fn approve(2143		&self,2144		sender: T::CrossAccountId,2145		spender: T::CrossAccountId,2146		token: TokenId,2147		amount: u128,2148	) -> DispatchResultWithPostInfo;21492150	/// Grant access to another account to transfer parts of the token owned by the calling user's eth mirror via [Self::transfer_from].2151	///2152	/// * `sender` - The user who grants access to the token.2153	/// * `from` - Spender's eth mirror.2154	/// * `to` - The user to whom the rights are granted.2155	/// * `token` - The token to which access is granted.2156	/// * `amount` - The amount of pieces that another user can dispose of.2157	fn approve_from(2158		&self,2159		sender: T::CrossAccountId,2160		from: T::CrossAccountId,2161		to: T::CrossAccountId,2162		token: TokenId,2163		amount: u128,2164	) -> DispatchResultWithPostInfo;21652166	/// Send parts of a token owned by another user.2167	///2168	/// Before calling this method, you must grant rights to the calling user via [`Self::approve`].2169	///2170	/// * `sender` - The user who must have access to the token (see [`Self::approve`]).2171	/// * `from` - The user who owns the token.2172	/// * `to` - Recepient user.2173	/// * `token` - The token of which parts are being sent.2174	/// * `amount` - The number of parts of the token that will be transferred.2175	/// * `budget` - The maximum budget that can be spent on the transfer.2176	fn transfer_from(2177		&self,2178		sender: T::CrossAccountId,2179		from: T::CrossAccountId,2180		to: T::CrossAccountId,2181		token: TokenId,2182		amount: u128,2183		budget: &dyn Budget,2184	) -> DispatchResultWithPostInfo;21852186	/// Burn parts of a token owned by another user.2187	///2188	/// Before calling this method, you must grant rights to the calling user via [`Self::approve`].2189	///2190	/// * `sender` - The user who must have access to the token (see [`Self::approve`]).2191	/// * `from` - The user who owns the token.2192	/// * `token` - The token of which parts are being sent.2193	/// * `amount` - The number of parts of the token that will be transferred.2194	/// * `budget` - The maximum budget that can be spent on the burn.2195	fn burn_from(2196		&self,2197		sender: T::CrossAccountId,2198		from: T::CrossAccountId,2199		token: TokenId,2200		amount: u128,2201		budget: &dyn Budget,2202	) -> DispatchResultWithPostInfo;22032204	/// Check permission to nest token.2205	///2206	/// * `sender` - The user who initiated the check.2207	/// * `from` - The token that is checked for embedding.2208	/// * `under` - Token under which to check.2209	/// * `budget` - The maximum budget that can be spent on the check.2210	fn check_nesting(2211		&self,2212		sender: T::CrossAccountId,2213		from: (CollectionId, TokenId),2214		under: TokenId,2215		budget: &dyn Budget,2216	) -> DispatchResult;22172218	/// Nest one token into another.2219	///2220	/// * `under` - Token holder.2221	/// * `to_nest` - Nested token.2222	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId));22232224	/// Unnest token.2225	///2226	/// * `under` - Token holder.2227	/// * `to_nest` - Token to unnest.2228	fn unnest(&self, under: TokenId, to_nest: (CollectionId, TokenId));22292230	/// Get all user tokens.2231	///2232	/// * `account` - Account for which you need to get tokens.2233	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId>;22342235	/// Get all the tokens in the collection.2236	fn collection_tokens(&self) -> Vec<TokenId>;22372238	/// Check if the token exists.2239	///2240	/// * `token` - Id token to check.2241	fn token_exists(&self, token: TokenId) -> bool;22422243	/// Get the id of the last minted token.2244	fn last_token_id(&self) -> TokenId;22452246	/// Get the owner of the token.2247	///2248	/// * `token` - The token for which you need to find out the owner.2249	fn token_owner(&self, token: TokenId) -> Result<T::CrossAccountId, TokenOwnerError>;22502251	/// Checks if the `maybe_owner` is the indirect owner of the `token`.2252	///2253	/// * `token` - Id token to check.2254	/// * `maybe_owner` - The account to check.2255	/// * `nesting_budget` - A budget that can be spent on nesting tokens.2256	fn check_token_indirect_owner(2257		&self,2258		token: TokenId,2259		maybe_owner: &T::CrossAccountId,2260		nesting_budget: &dyn Budget,2261	) -> Result<bool, DispatchError>;22622263	/// Returns 10 tokens owners in no particular order.2264	///2265	/// * `token` - The token for which you need to find out the owners.2266	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId>;22672268	/// Get the value of the token property by key.2269	///2270	/// * `token` - Token with the property to get.2271	/// * `key` - Property name.2272	fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue>;22732274	/// Get a set of token properties by key vector.2275	///2276	/// * `token` - Token with the property to get.2277	/// * `keys` - Vector of property keys. If this parameter is [None](sp_std::result::Result),2278	/// then all properties are returned.2279	fn token_properties(&self, token: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property>;22802281	/// Amount of unique collection tokens2282	fn total_supply(&self) -> u32;22832284	/// Amount of different tokens account has.2285	///2286	/// * `account` - The account for which need to get the balance.2287	fn account_balance(&self, account: T::CrossAccountId) -> u32;22882289	/// Amount of specific token account have.2290	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128;22912292	/// Amount of token pieces2293	fn total_pieces(&self, token: TokenId) -> Option<u128>;22942295	/// Get the number of parts of the token that a trusted user can manage.2296	///2297	/// * `sender` - Trusted user.2298	/// * `spender` - Owner of the token.2299	/// * `token` - The token for which to get the value.2300	fn allowance(2301		&self,2302		sender: T::CrossAccountId,2303		spender: T::CrossAccountId,2304		token: TokenId,2305	) -> u128;23062307	/// Get extension for RFT collection.2308	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>>;23092310	/// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.2311	/// * `owner` - Token owner2312	/// * `operator` - Operator2313	/// * `approve` - Should operator status be granted or revoked?2314	fn set_allowance_for_all(2315		&self,2316		owner: T::CrossAccountId,2317		operator: T::CrossAccountId,2318		approve: bool,2319	) -> DispatchResultWithPostInfo;23202321	/// Tells whether the given `owner` approves the `operator`.2322	fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool;23232324	/// Repairs a possibly broken item.2325	fn repair_item(&self, token: TokenId) -> DispatchResultWithPostInfo;2326}23272328/// Extension for RFT collection.2329pub trait RefungibleExtensions<T>2330where2331	T: Config,2332{2333	/// Change the number of parts of the token.2334	///2335	/// When the value changes down, this function is equivalent to burning parts of the token.2336	///2337	/// * `sender` - The user calling the repartition operation. Must be the owner of the token.2338	/// * `token` - The token for which you want to change the number of parts.2339	/// * `amount` - The new value of the parts of the token.2340	fn repartition(2341		&self,2342		sender: &T::CrossAccountId,2343		token: TokenId,2344		amount: u128,2345	) -> DispatchResultWithPostInfo;2346}23472348/// Merge [`DispatchResult`] with [`Weight`] into [`DispatchResultWithPostInfo`].2349///2350/// Used for [`CommonCollectionOperations`] implementations and flexible enough to do so.2351pub fn with_weight(res: DispatchResult, weight: Weight) -> DispatchResultWithPostInfo {2352	let post_info = PostDispatchInfo {2353		actual_weight: Some(weight),2354		pays_fee: Pays::Yes,2355	};2356	match res {2357		Ok(()) => Ok(post_info),2358		Err(error) => Err(DispatchErrorWithPostInfo { post_info, error }),2359	}2360}23612362impl<T: Config> From<PropertiesError> for Error<T> {2363	fn from(error: PropertiesError) -> Self {2364		match error {2365			PropertiesError::NoSpaceForProperty => Self::NoSpaceForProperty,2366			PropertiesError::PropertyLimitReached => Self::PropertyLimitReached,2367			PropertiesError::InvalidCharacterInPropertyKey => Self::InvalidCharacterInPropertyKey,2368			PropertiesError::PropertyKeyIsTooLong => Self::PropertyKeyIsTooLong,2369			PropertiesError::EmptyPropertyKey => Self::EmptyPropertyKey,2370		}2371	}2372}23732374/// A marker structure that enables the writer implementation2375/// to provide the interface to write properties to **newly created** tokens.2376pub struct NewTokenPropertyWriter;23772378/// A marker structure that enables the writer implementation2379/// to provide the interface to write properties to **already existing** tokens.2380pub struct ExistingTokenPropertyWriter;23812382/// The type-safe interface for writing properties (setting or deleting) to tokens.2383/// It has two distinct implementations for newly created tokens and existing ones.2384///2385/// This type utilizes the lazy evaluation to avoid repeating the computation2386/// of several performance-heavy or PoV-heavy tasks,2387/// such as checking the indirect ownership or reading the token property permissions.2388pub struct PropertyWriter<2389	'a,2390	T,2391	Handle,2392	WriterVariant,2393	FIsAdmin,2394	FPropertyPermissions,2395	FCheckTokenExist,2396	FGetProperties,2397> where2398	T: Config,2399	FIsAdmin: FnOnce() -> bool,2400	FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,2401{2402	collection: &'a Handle,2403	is_collection_admin: LazyValue<bool, FIsAdmin>,2404	property_permissions: LazyValue<PropertiesPermissionMap, FPropertyPermissions>,2405	check_token_exist: FCheckTokenExist,2406	get_properties: FGetProperties,2407	_phantom: PhantomData<(T, WriterVariant)>,2408}24092410impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>2411	PropertyWriter<2412		'a,2413		T,2414		Handle,2415		NewTokenPropertyWriter,2416		FIsAdmin,2417		FPropertyPermissions,2418		FCheckTokenExist,2419		FGetProperties,2420	> where2421	T: Config,2422	Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2423	FIsAdmin: FnOnce() -> bool,2424	FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,2425	FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,2426	FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,2427{2428	/// A function to write properties to a **newly created** token.2429	pub fn write_token_properties(2430		&mut self,2431		mint_target_is_sender: bool,2432		token_id: TokenId,2433		properties_updates: impl Iterator<Item = Property>,2434		log: evm_coder::ethereum::Log,2435	) -> DispatchResult {2436		self.internal_write_token_properties(2437			token_id,2438			properties_updates.map(|p| (p.key, Some(p.value))),2439			|_| Ok(mint_target_is_sender),2440			log,2441		)2442	}2443}24442445impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>2446	PropertyWriter<2447		'a,2448		T,2449		Handle,2450		ExistingTokenPropertyWriter,2451		FIsAdmin,2452		FPropertyPermissions,2453		FCheckTokenExist,2454		FGetProperties,2455	> where2456	T: Config,2457	Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2458	FIsAdmin: FnOnce() -> bool,2459	FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,2460	FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,2461	FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,2462{2463	/// A function to write properties to an **already existing** token.2464	pub fn write_token_properties(2465		&mut self,2466		sender: &T::CrossAccountId,2467		token_id: TokenId,2468		properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,2469		nesting_budget: &dyn Budget,2470		log: evm_coder::ethereum::Log,2471	) -> DispatchResult {2472		self.internal_write_token_properties(2473			token_id,2474			properties_updates,2475			|collection| collection.check_token_indirect_owner(token_id, sender, nesting_budget),2476			log,2477		)2478	}2479}24802481impl<2482		'a,2483		T,2484		Handle,2485		WriterVariant,2486		FIsAdmin,2487		FPropertyPermissions,2488		FCheckTokenExist,2489		FGetProperties,2490	>2491	PropertyWriter<2492		'a,2493		T,2494		Handle,2495		WriterVariant,2496		FIsAdmin,2497		FPropertyPermissions,2498		FCheckTokenExist,2499		FGetProperties,2500	> where2501	T: Config,2502	Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2503	FIsAdmin: FnOnce() -> bool,2504	FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,2505	FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,2506	FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,2507{2508	fn internal_write_token_properties<FCheckTokenOwner>(2509		&mut self,2510		token_id: TokenId,2511		properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,2512		check_token_owner: FCheckTokenOwner,2513		log: evm_coder::ethereum::Log,2514	) -> DispatchResult2515	where2516		FCheckTokenOwner: FnOnce(&Handle) -> Result<bool, DispatchError>,2517	{2518		let get_properties = self.get_properties;2519		let mut stored_properties = LazyValue::new(move || get_properties(token_id));25202521		let mut is_token_owner = LazyValue::new(|| check_token_owner(self.collection));25222523		let check_token_exist = self.check_token_exist;2524		let mut is_token_exist = LazyValue::new(move || check_token_exist(token_id));25252526		for (key, value) in properties_updates {2527			let permission = self2528				.property_permissions2529				.value()2530				.get(&key)2531				.cloned()2532				.unwrap_or_else(PropertyPermission::none);25332534			match permission {2535				PropertyPermission { mutable: false, .. }2536					if stored_properties.value().get(&key).is_some() =>2537				{2538					return Err(<Error<T>>::NoPermission.into());2539				}25402541				PropertyPermission {2542					collection_admin,2543					token_owner,2544					..2545				} => check_token_permissions::<T, _, _, _>(2546					collection_admin,2547					token_owner,2548					&mut self.is_collection_admin,2549					&mut is_token_owner,2550					&mut is_token_exist,2551				)?,2552			}25532554			match value {2555				Some(value) => {2556					stored_properties2557						.value_mut()2558						.try_set(key.clone(), value)2559						.map_err(<Error<T>>::from)?;25602561					<Pallet<T>>::deposit_event(Event::TokenPropertySet(2562						self.collection.id,2563						token_id,2564						key,2565					));2566				}2567				None => {2568					stored_properties2569						.value_mut()2570						.remove(&key)2571						.map_err(<Error<T>>::from)?;25722573					<Pallet<T>>::deposit_event(Event::TokenPropertyDeleted(2574						self.collection.id,2575						token_id,2576						key,2577					));2578				}2579			}2580		}25812582		let properties_changed = stored_properties.has_value();2583		if properties_changed {2584			<PalletEvm<T>>::deposit_log(log);25852586			self.collection2587				.set_token_properties_raw(token_id, stored_properties.into_inner());2588		}25892590		Ok(())2591	}2592}25932594/// Create a [`PropertyWriter`] for newly created tokens.2595pub fn property_writer_for_new_token<'a, T, Handle>(2596	collection: &'a Handle,2597	sender: &'a T::CrossAccountId,2598) -> PropertyWriter<2599	'a,2600	T,2601	Handle,2602	NewTokenPropertyWriter,2603	impl FnOnce() -> bool + 'a,2604	impl FnOnce() -> PropertiesPermissionMap + 'a,2605	impl Copy + FnOnce(TokenId) -> bool + 'a,2606	impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,2607>2608where2609	T: Config,2610	Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2611{2612	PropertyWriter {2613		collection,2614		is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),2615		property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),2616		check_token_exist: |token_id| {2617			debug_assert!(collection.token_exists(token_id));2618			true2619		},2620		get_properties: |token_id| {2621			debug_assert!(collection.get_token_properties_raw(token_id).is_none());2622			TokenProperties::new()2623		},2624		_phantom: PhantomData,2625	}2626}26272628#[cfg(feature = "runtime-benchmarks")]2629/// Create a `PropertyWriter` with preloaded `is_collection_admin` and `property_permissions.2630/// Also:2631/// * it will return `true` for the token ownership check.2632/// * it will return empty stored properties without reading them from the storage.2633pub fn collection_info_loaded_property_writer<T, Handle>(2634	collection: &Handle,2635	is_collection_admin: bool,2636	property_permissions: PropertiesPermissionMap,2637) -> PropertyWriter<2638	T,2639	Handle,2640	NewTokenPropertyWriter,2641	impl FnOnce() -> bool,2642	impl FnOnce() -> PropertiesPermissionMap,2643	impl Copy + FnOnce(TokenId) -> bool,2644	impl Copy + FnOnce(TokenId) -> TokenProperties,2645>2646where2647	T: Config,2648	Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2649{2650	PropertyWriter {2651		collection,2652		is_collection_admin: LazyValue::new(move || is_collection_admin),2653		property_permissions: LazyValue::new(move || property_permissions),2654		check_token_exist: |_token_id| true,2655		get_properties: |_token_id| TokenProperties::new(),2656		_phantom: PhantomData,2657	}2658}26592660/// Create a [`PropertyWriter`] for already existing tokens.2661pub fn property_writer_for_existing_token<'a, T, Handle>(2662	collection: &'a Handle,2663	sender: &'a T::CrossAccountId,2664) -> PropertyWriter<2665	'a,2666	T,2667	Handle,2668	ExistingTokenPropertyWriter,2669	impl FnOnce() -> bool + 'a,2670	impl FnOnce() -> PropertiesPermissionMap + 'a,2671	impl Copy + FnOnce(TokenId) -> bool + 'a,2672	impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,2673>2674where2675	T: Config,2676	Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2677{2678	PropertyWriter {2679		collection,2680		is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),2681		property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),2682		check_token_exist: |token_id| collection.token_exists(token_id),2683		get_properties: |token_id| {2684			collection2685				.get_token_properties_raw(token_id)2686				.unwrap_or_default()2687		},2688		_phantom: PhantomData,2689	}2690}26912692/// Computes the weight delta for newly created tokens with properties.2693/// * `properties_nums` - The properties num of each created token.2694/// * `init_token_properties` - The function to obtain the weight from a token's properties num.2695pub fn init_token_properties_delta<T: Config, I: Fn(u32) -> Weight>(2696	properties_nums: impl Iterator<Item = u32>,2697	init_token_properties: I,2698) -> Weight {2699	let mut delta = properties_nums2700		.filter_map(|properties_num| {2701			if properties_num > 0 {2702				Some(init_token_properties(properties_num))2703			} else {2704				None2705			}2706		})2707		.fold(Weight::zero(), |a, b| a.saturating_add(b));27082709	// If at least once the `init_token_properties` was called,2710	// it means at least one newly created token has properties.2711	// Becuase of that, some common collection data also was loaded and we need to add this weight.2712	// However, these common data was loaded only once which is guaranteed by the `PropertyWriter`.2713	if !delta.is_zero() {2714		delta = delta.saturating_add(<SelfWeightOf<T>>::init_token_properties_common())2715	}27162717	delta2718}27192720#[cfg(any(feature = "tests", test))]2721#[allow(missing_docs)]2722pub mod tests {2723	use crate::{DispatchResult, DispatchError, LazyValue, Config};27242725	const fn to_bool(u: u8) -> bool {2726		u != 02727	}27282729	#[derive(Debug)]2730	pub struct TestCase {2731		pub collection_admin: bool,2732		pub is_collection_admin: bool,2733		pub token_owner: bool,2734		pub is_token_owner: bool,2735		pub no_permission: bool,2736	}27372738	impl TestCase {2739		const fn new(2740			collection_admin: u8,2741			is_collection_admin: u8,2742			token_owner: u8,2743			is_token_owner: u8,2744			no_permission: u8,2745		) -> Self {2746			Self {2747				collection_admin: to_bool(collection_admin),2748				is_collection_admin: to_bool(is_collection_admin),2749				token_owner: to_bool(token_owner),2750				is_token_owner: to_bool(is_token_owner),2751				no_permission: to_bool(no_permission),2752			}2753		}2754	}27552756	#[rustfmt::skip]2757	pub const TABLE: [TestCase; 16] = [2758		//                    ┌╴collection_admin2759		//                    │  ┌╴is_collection_admin2760		//                    │  │   ┌╴token_owner2761		//                    │  │   │  ┌╴is_token_ownership2762		//                    │  │   │  │   ┌╴no_permission2763		/*  0*/ TestCase::new(0, 0,  0, 0,  1),2764		/*  1*/ TestCase::new(0, 0,  0, 1,  1),2765		/*  2*/ TestCase::new(0, 0,  1, 0,  1),2766		/*  3*/ TestCase::new(0, 0,  1, 1,  0),2767		/*  4*/ TestCase::new(0, 1,  0, 0,  1),2768		/*  5*/ TestCase::new(0, 1,  0, 1,  1),2769		/*  6*/ TestCase::new(0, 1,  1, 0,  1),2770		/*  7*/ TestCase::new(0, 1,  1, 1,  0),2771		/*  8*/ TestCase::new(1, 0,  0, 0,  1),2772		/*  9*/ TestCase::new(1, 0,  0, 1,  1),2773		/* 10*/ TestCase::new(1, 0,  1, 0,  1),2774		/* 11*/ TestCase::new(1, 0,  1, 1,  0),2775		/* 12*/ TestCase::new(1, 1,  0, 0,  0),2776		/* 13*/ TestCase::new(1, 1,  0, 1,  0),2777		/* 14*/ TestCase::new(1, 1,  1, 0,  0),2778		/* 15*/ TestCase::new(1, 1,  1, 1,  0),2779	];27802781	pub fn check_token_permissions<T, FCA, FTO, FTE>(2782		collection_admin_permitted: bool,2783		token_owner_permitted: bool,2784		is_collection_admin: &mut LazyValue<bool, FCA>,2785		check_token_ownership: &mut LazyValue<Result<bool, DispatchError>, FTO>,2786		check_token_existence: &mut LazyValue<bool, FTE>,2787	) -> DispatchResult2788	where2789		T: Config,2790		FCA: FnOnce() -> bool,2791		FTO: FnOnce() -> Result<bool, DispatchError>,2792		FTE: FnOnce() -> bool,2793	{2794		crate::check_token_permissions::<T, FCA, FTO, FTE>(2795			collection_admin_permitted,2796			token_owner_permitted,2797			is_collection_admin,2798			check_token_ownership,2799			check_token_existence,2800		)2801	}2802}
modifiedpallets/configuration/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/configuration/src/benchmarking.rs
+++ b/pallets/configuration/src/benchmarking.rs
@@ -16,10 +16,11 @@
 
 //! Benchmarking setup for pallet-configuration
 
-use super::*;
 use frame_benchmarking::benchmarks;
-use frame_system::{EventRecord, RawOrigin};
 use frame_support::assert_ok;
+use frame_system::{EventRecord, RawOrigin};
+
+use super::*;
 
 fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
 	let events = frame_system::Pallet::<T>::events();
modifiedpallets/configuration/src/lib.rsdiffbeforeafterboth
--- a/pallets/configuration/src/lib.rs
+++ b/pallets/configuration/src/lib.rs
@@ -20,19 +20,17 @@
 
 use frame_support::{
 	pallet,
-	weights::{WeightToFeePolynomial, WeightToFeeCoefficients, WeightToFeeCoefficient, Weight},
 	traits::Get,
-	Parameter,
+	weights::{Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial},
 };
-use codec::{Decode, Encode, MaxEncodedLen};
+pub use pallet::*;
+use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
 use scale_info::TypeInfo;
+use smallvec::smallvec;
 use sp_arithmetic::{
-	per_things::{Perbill, PerThing},
+	per_things::{PerThing, Perbill},
 	traits::{BaseArithmetic, Unsigned},
 };
-use smallvec::smallvec;
-
-pub use pallet::*;
 use sp_core::U256;
 
 #[cfg(feature = "runtime-benchmarks")]
@@ -41,15 +39,14 @@
 
 #[pallet]
 mod pallet {
+	use core::fmt::Debug;
+
+	use frame_support::{pallet_prelude::*, traits::Get};
+	use frame_system::{ensure_root, pallet_prelude::*};
+	use parity_scale_codec::Codec;
+	use sp_arithmetic::{traits::AtLeast32BitUnsigned, FixedPointOperand, Permill};
+
 	use super::*;
-	use frame_support::{
-		traits::Get,
-		pallet_prelude::*,
-		log,
-		dispatch::{Codec, fmt::Debug},
-	};
-	use frame_system::{pallet_prelude::OriginFor, ensure_root, pallet_prelude::*};
-	use sp_arithmetic::{FixedPointOperand, traits::AtLeast32BitUnsigned, Permill};
 	pub use crate::weights::WeightInfo;
 
 	#[pallet::config]
modifiedpallets/evm-coder-substrate/procedural/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/procedural/src/lib.rs
+++ b/pallets/evm-coder-substrate/procedural/src/lib.rs
@@ -1,12 +1,12 @@
 use std::result;
 
-use proc_macro2::{TokenStream, Ident};
+use proc_macro2::{Ident, TokenStream};
 use quote::quote;
 use syn::{
-	Error, DeriveInput, Data, Attribute,
+	parenthesized,
 	parse::{Parse, ParseBuffer},
 	spanned::Spanned,
-	Expr, parenthesized,
+	Attribute, Data, DeriveInput, Error, Expr,
 };
 
 type Result<T = TokenStream, E = syn::Error> = result::Result<T, E>;
modifiedpallets/evm-coder-substrate/src/execution.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/src/execution.rs
+++ b/pallets/evm-coder-substrate/src/execution.rs
@@ -22,10 +22,9 @@
 use std::string::{String, ToString};
 
 use evm_coder::ERC165Call;
+pub use evm_coder_substrate_procedural::PreDispatch;
 use evm_core::{ExitError, ExitFatal};
-
 pub use frame_support::weights::Weight;
-pub use evm_coder_substrate_procedural::PreDispatch;
 
 /// Execution error, should be convertible between EVM and Substrate.
 #[derive(Debug, Clone)]
modifiedpallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -22,42 +22,39 @@
 extern crate alloc;
 #[cfg(not(feature = "std"))]
 use alloc::format;
-use execution::PreDispatch;
-use frame_support::dispatch::Weight;
-
 use core::marker::PhantomData;
-use sp_std::{cell::RefCell, vec::Vec};
 
-use codec::Decode;
-use frame_support::pallet_prelude::DispatchError;
-use frame_support::traits::PalletInfo;
-use frame_support::{ensure, sp_runtime::ModuleError};
-use up_data_structs::budget;
+use execution::PreDispatch;
+use frame_support::{
+	ensure, pallet_prelude::DispatchError, sp_runtime::ModuleError, traits::PalletInfo,
+};
 use pallet_evm::{
-	ExitError, ExitRevert, ExitSucceed, GasWeightMapping, PrecompileFailure, PrecompileOutput,
-	PrecompileResult, PrecompileHandle,
+	ExitError, ExitRevert, ExitSucceed, GasWeightMapping, PrecompileFailure, PrecompileHandle,
+	PrecompileOutput, PrecompileResult,
 };
+use parity_scale_codec::Decode;
 use sp_core::{Get, H160};
+use sp_std::{cell::RefCell, vec::Vec};
+use sp_weights::Weight;
+use up_data_structs::budget;
 // #[cfg(feature = "runtime-benchmarks")]
 // pub mod benchmarking;
 pub mod execution;
 
-#[doc(hidden)]
-pub use spez::spez;
-
+pub use evm_coder::{abi, solidity_interface, types, Contract, ResultWithPostInfoOf, ToLog};
 use evm_coder::{
 	types::{Msg, Value},
 	AbiEncode,
 };
-
 pub use pallet::*;
-pub use evm_coder::{ResultWithPostInfoOf, Contract, abi, solidity_interface, ToLog, types};
+#[doc(hidden)]
+pub use spez::spez;
 
 #[frame_support::pallet]
 pub mod pallet {
+	pub use frame_support::dispatch::DispatchResult;
+
 	use super::*;
-
-	pub use frame_support::dispatch::DispatchResult;
 
 	/// DispatchError is opaque, but we need to somehow extract correct error in case of OutOfGas failure
 	/// So we have this pallet, which defines OutOfGas error, and knews its own id to check if DispatchError
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -18,32 +18,35 @@
 
 extern crate alloc;
 use core::marker::PhantomData;
+
 use evm_coder::{
-	abi::{AbiType, AbiEncode},
+	abi::{AbiEncode, AbiType},
 	generate_stubgen, solidity_interface,
 	types::*,
 	ToLog,
 };
+use frame_support::traits::Get;
+use frame_system::pallet_prelude::*;
 use pallet_common::eth;
 use pallet_evm::{
-	ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,
-	account::CrossAccountId,
+	account::CrossAccountId, ExitRevert, OnCreate, OnMethodCall, PrecompileFailure,
+	PrecompileHandle, PrecompileResult,
 };
 use pallet_evm_coder_substrate::{
-	SubstrateRecorder, WithRecorder, dispatch_to_evm,
-	execution::{Result, PreDispatch},
-	frontier_contract,
+	dispatch_to_evm,
+	execution::{PreDispatch, Result},
+	frontier_contract, SubstrateRecorder, WithRecorder,
 };
 use pallet_evm_transaction_payment::CallContext;
 use sp_core::{H160, U256};
+use sp_std::vec::Vec;
 use up_data_structs::SponsorshipState;
+use up_sponsorship::SponsorshipHandler;
+
 use crate::{
-	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, SponsoringFeeLimit,
-	SponsoringRateLimit, SponsoringModeT, Sponsoring,
+	AllowlistEnabled, Config, Owner, Pallet, SponsorBasket, Sponsoring, SponsoringFeeLimit,
+	SponsoringModeT, SponsoringRateLimit,
 };
-use frame_support::traits::Get;
-use up_sponsorship::SponsorshipHandler;
-use sp_std::vec::Vec;
 
 frontier_contract! {
 	macro_rules! ContractHelpers_result {...}
modifiedpallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -18,12 +18,12 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 #![warn(missing_docs)]
 
-use codec::{Decode, Encode, MaxEncodedLen};
+pub use eth::*;
 use evm_coder::AbiCoder;
+use frame_support::storage::bounded_btree_map::BoundedBTreeMap;
 pub use pallet::*;
-pub use eth::*;
+use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
 use scale_info::TypeInfo;
-use frame_support::storage::bounded_btree_map::BoundedBTreeMap;
 pub mod eth;
 
 /// Maximum number of methods per contract that could have fee limit
@@ -31,15 +31,16 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	pub use super::*;
+	use evm_coder::ToLog;
 	use frame_support::{pallet_prelude::*, sp_runtime::DispatchResult};
-	use frame_system::{pallet_prelude::OriginFor, ensure_root};
+	use frame_system::{ensure_root, pallet_prelude::*};
+	use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 	use sp_core::{H160, U256};
 	use sp_std::vec::Vec;
-	use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 	use up_data_structs::SponsorshipState;
-	use evm_coder::ToLog;
 
+	pub use super::*;
+
 	#[pallet::config]
 	pub trait Config:
 		frame_system::Config + pallet_evm_coder_substrate::Config + pallet_evm::Config
modifiedpallets/evm-migration/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/evm-migration/src/benchmarking.rs
+++ b/pallets/evm-migration/src/benchmarking.rs
@@ -16,11 +16,12 @@
 
 #![allow(missing_docs)]
 
-use super::{Call, Config, Pallet};
 use frame_benchmarking::benchmarks;
 use frame_system::RawOrigin;
 use sp_core::{H160, H256};
-use sp_std::{vec::Vec, vec};
+use sp_std::{vec, vec::Vec};
+
+use super::{Call, Config, Pallet};
 
 benchmarks! {
 	where_clause { where <T as Config>::RuntimeEvent: parity_scale_codec::Encode }
modifiedpallets/evm-migration/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-migration/src/lib.rs
+++ b/pallets/evm-migration/src/lib.rs
@@ -26,15 +26,13 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	use frame_support::{
-		pallet_prelude::{*, DispatchResult},
-		traits::IsType,
-	};
-	use frame_system::pallet_prelude::{*, OriginFor};
+	use frame_support::{pallet_prelude::*, traits::IsType};
+	use frame_system::pallet_prelude::*;
+	use pallet_evm::{Pallet as PalletEvm, PrecompileHandle};
 	use sp_core::{H160, H256};
 	use sp_std::vec::Vec;
+
 	use super::weights::WeightInfo;
-	use pallet_evm::{PrecompileHandle, Pallet as PalletEvm};
 
 	#[pallet::config]
 	pub trait Config: frame_system::Config + pallet_evm::Config {
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -19,19 +19,26 @@
 #![deny(missing_docs)]
 
 use core::marker::PhantomData;
-use fp_evm::WithdrawReason;
-use frame_support::traits::IsSubType;
+
+use fp_evm::{CheckEvmTransaction, FeeCalculator, TransactionValidationError, WithdrawReason};
+use frame_support::{
+	storage::with_transaction,
+	traits::{Currency, Imbalance, IsSubType, OnUnbalanced},
+};
 pub use pallet::*;
-use pallet_evm::{account::CrossAccountId, EnsureAddressOrigin};
+use pallet_evm::{
+	account::CrossAccountId, EnsureAddressOrigin, NegativeImbalanceOf, OnChargeEVMTransaction,
+	OnCheckEvmTransaction,
+};
 use sp_core::{H160, U256};
-use sp_runtime::{TransactionOutcome, DispatchError};
+use sp_runtime::{traits::UniqueSaturatedInto, DispatchError, TransactionOutcome};
 use up_sponsorship::SponsorshipHandler;
 
 #[frame_support::pallet]
 pub mod pallet {
+	use sp_std::vec::Vec;
+
 	use super::*;
-
-	use sp_std::vec::Vec;
 
 	/// Contains call data
 	pub struct CallContext {
modifiedpallets/foreign-assets/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/benchmarking.rs
+++ b/pallets/foreign-assets/src/benchmarking.rs
@@ -16,15 +16,14 @@
 
 #![allow(missing_docs)]
 
-use super::{Config, Pallet, Call};
-use frame_benchmarking::{benchmarks, account};
+use frame_benchmarking::{account, benchmarks};
+use frame_support::traits::Currency;
 use frame_system::RawOrigin;
+use sp_std::{boxed::Box, vec::Vec};
+use staging_xcm::{opaque::latest::Junction::Parachain, v3::Junctions::X1, VersionedMultiLocation};
+
+use super::{Call, Config, Pallet};
 use crate::AssetMetadata;
-use xcm::opaque::latest::Junction::Parachain;
-use xcm::VersionedMultiLocation;
-use xcm::v3::Junctions::X1;
-use frame_support::traits::Currency;
-use sp_std::{vec::Vec, boxed::Box};
 
 fn bounded<T: TryFrom<Vec<u8>>>(slice: &[u8]) -> T {
 	T::try_from(slice.to_vec())
modifiedpallets/foreign-assets/src/impl_fungibles.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/impl_fungibles.rs
+++ b/pallets/foreign-assets/src/impl_fungibles.rs
@@ -16,18 +16,17 @@
 
 //! Implementations for fungibles trait.
 
-use super::*;
-use frame_system::Config as SystemConfig;
-
 use frame_support::traits::tokens::{
-	DepositConsequence, WithdrawConsequence, Preservation, Fortitude, Provenance, Precision,
+	DepositConsequence, Fortitude, Precision, Preservation, Provenance, WithdrawConsequence,
 };
-use pallet_common::CollectionHandle;
+use frame_system::Config as SystemConfig;
+use pallet_common::{CollectionHandle, CommonCollectionOperations};
 use pallet_fungible::FungibleHandle;
-use pallet_common::CommonCollectionOperations;
+use sp_runtime::traits::{CheckedAdd, CheckedSub};
 use up_data_structs::budget::Value;
-use sp_runtime::traits::{CheckedAdd, CheckedSub};
 
+use super::*;
+
 impl<T: Config> fungibles::Inspect<<T as SystemConfig>::AccountId> for Pallet<T>
 where
 	T: orml_tokens::Config<CurrencyId = AssetId>,
modifiedpallets/foreign-assets/src/lib.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/lib.rs
+++ b/pallets/foreign-assets/src/lib.rs
@@ -39,29 +39,26 @@
 	ensure,
 	pallet_prelude::*,
 	traits::{fungible, fungibles, Currency, EnsureOrigin},
-	RuntimeDebug,
 };
 use frame_system::pallet_prelude::*;
-use up_data_structs::CollectionMode;
+use pallet_common::erc::CrossAccountId;
 use pallet_fungible::Pallet as PalletFungible;
 use scale_info::TypeInfo;
+use serde::{Deserialize, Serialize};
 use sp_runtime::{
 	traits::{One, Zero},
 	ArithmeticError,
 };
 use sp_std::{boxed::Box, vec::Vec};
-use up_data_structs::{CollectionId, TokenId, CreateCollectionData};
-
+use staging_xcm::{latest::MultiLocation, VersionedMultiLocation};
 // NOTE: MultiLocation is used in storages, we will need to do migration if upgrade the
 // MultiLocation to the XCM v3.
-use xcm::opaque::latest::{prelude::XcmError, Weight};
-use xcm::{latest::MultiLocation, VersionedMultiLocation};
-use xcm_executor::{traits::WeightTrader, Assets};
-
-use pallet_common::erc::CrossAccountId;
-
-#[cfg(feature = "std")]
-use serde::{Deserialize, Serialize};
+use staging_xcm::{
+	opaque::latest::{prelude::XcmError, Weight},
+	v3::XcmContext,
+};
+use staging_xcm_executor::{traits::WeightTrader, Assets};
+use up_data_structs::{CollectionId, CollectionMode, CreateCollectionData, TokenId};
 
 // TODO: Move to primitives
 // Id of native currency.
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -14,14 +14,13 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use super::*;
-use crate::{Pallet, Config, FungibleHandle};
-
+use frame_benchmarking::{account, benchmarks};
+use pallet_common::{bench_init, benchmarking::create_collection_raw};
 use sp_std::prelude::*;
-use pallet_common::benchmarking::create_collection_raw;
-use frame_benchmarking::{benchmarks, account};
-use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH, budget::Unlimited};
-use pallet_common::bench_init;
+use up_data_structs::{budget::Unlimited, CollectionMode, MAX_ITEMS_PER_BATCH};
+
+use super::*;
+use crate::{Config, FungibleHandle, Pallet};
 
 const SEED: u32 = 1;
 
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -16,22 +16,24 @@
 
 use core::marker::PhantomData;
 
-use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, traits::Get};
-use up_data_structs::{
-	TokenId, CollectionId, CreateItemExData, budget::Budget, CreateItemData, TokenOwnerError,
+use frame_support::{
+	dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
 };
 use pallet_common::{
-	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
-	weights::WeightInfo as _, SelfWeightOf as PalletCommonWeightOf,
+	weights::WeightInfo as _, with_weight, CommonCollectionOperations, CommonWeightInfo,
+	RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,
 };
 use pallet_structure::Error as StructureError;
 use sp_runtime::{ArithmeticError, DispatchError};
-use sp_std::{vec::Vec, vec};
-use up_data_structs::{Property, PropertyKey, PropertyValue, PropertyKeyPermission};
+use sp_std::{vec, vec::Vec};
+use up_data_structs::{
+	budget::Budget, CollectionId, CreateItemData, CreateItemExData, Property, PropertyKey,
+	PropertyKeyPermission, PropertyValue, TokenId, TokenOwnerError,
+};
 
 use crate::{
-	Allowance, TotalSupply, Balance, Config, Error, FungibleHandle, Pallet, SelfWeightOf,
-	weights::WeightInfo,
+	weights::WeightInfo, Allowance, Balance, Config, Error, FungibleHandle, Pallet, SelfWeightOf,
+	TotalSupply,
 };
 
 pub struct CommonWeights<T: Config>(PhantomData<T>);
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -17,30 +17,31 @@
 //! ERC-20 standart support implementation.
 
 extern crate alloc;
-use core::char::{REPLACEMENT_CHARACTER, decode_utf16};
-use core::convert::TryInto;
-use evm_coder::AbiCoder;
-use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};
-use up_data_structs::CollectionMode;
+use core::{
+	char::{decode_utf16, REPLACEMENT_CHARACTER},
+	convert::TryInto,
+};
+
+use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*, AbiCoder, ToLog};
 use pallet_common::{
-	CollectionHandle,
-	erc::{CommonEvmHandler, PrecompileResult, CollectionCall},
+	erc::{CollectionCall, CommonEvmHandler, PrecompileResult},
 	eth::CrossAddress,
-	CommonWeightInfo as _,
+	CollectionHandle, CommonWeightInfo as _,
 };
-use sp_std::vec::Vec;
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{
 	call, dispatch_to_evm,
 	execution::{PreDispatch, Result},
 	frontier_contract,
 };
-use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
-use sp_core::{U256, Get};
+use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
+use sp_core::{Get, U256};
+use sp_std::vec::Vec;
+use up_data_structs::CollectionMode;
 
 use crate::{
-	Allowance, Balance, Config, FungibleHandle, Pallet, TotalSupply, SelfWeightOf,
-	weights::WeightInfo, common::CommonWeights,
+	common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, FungibleHandle, Pallet,
+	SelfWeightOf, TotalSupply,
 };
 
 frontier_contract! {
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -79,30 +79,26 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 
 use core::ops::Deref;
+
 use evm_coder::ToLog;
-use frame_support::{
-	ensure,
-	pallet_prelude::{DispatchResultWithPostInfo, Pays},
-	dispatch::PostDispatchInfo,
-};
-use pallet_evm::account::CrossAccountId;
-use up_data_structs::{
-	AccessMode, CollectionId, TokenId, CreateCollectionData, mapping::TokenAddressMapping,
-	budget::Budget, PropertyKey, Property,
-};
+use frame_support::{dispatch::PostDispatchInfo, ensure, pallet_prelude::*};
+pub use pallet::*;
 use pallet_common::{
-	Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,
-	eth::collection_id_to_address, SelfWeightOf as PalletCommonWeightOf,
-	weights::WeightInfo as CommonWeightInfo, helpers::add_weight_to_post_info,
+	eth::collection_id_to_address, helpers::add_weight_to_post_info,
+	weights::WeightInfo as CommonWeightInfo, Error as CommonError, Event as CommonEvent,
+	Pallet as PalletCommon, SelfWeightOf as PalletCommonWeightOf,
 };
-use pallet_evm::Pallet as PalletEvm;
+use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
+use pallet_evm_coder_substrate::WithRecorder;
 use pallet_structure::Pallet as PalletStructure;
-use pallet_evm_coder_substrate::WithRecorder;
 use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
 use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
+use up_data_structs::{
+	budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId, CreateCollectionData,
+	Property, PropertyKey, TokenId,
+};
 use weights::WeightInfo;
-pub use pallet::*;
 
 use crate::erc::ERC20Events;
 #[cfg(feature = "runtime-benchmarks")]
@@ -116,8 +112,11 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};
+	use frame_support::{
+		pallet_prelude::*, storage::Key, Blake2_128, Blake2_128Concat, Twox64Concat,
+	};
 	use up_data_structs::CollectionId;
+
 	use super::weights::WeightInfo;
 
 	#[pallet::error]
modifiedpallets/gov-origins/src/lib.rsdiffbeforeafterboth
--- a/pallets/gov-origins/src/lib.rs
+++ b/pallets/gov-origins/src/lib.rs
@@ -17,7 +17,6 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 
 use frame_support::pallet_prelude::*;
-
 pub use pallet::*;
 
 #[frame_support::pallet]
modifiedpallets/identity/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/identity/src/benchmarking.rs
+++ b/pallets/identity/src/benchmarking.rs
@@ -37,17 +37,17 @@
 #![cfg(feature = "runtime-benchmarks")]
 #![allow(clippy::no_effect)]
 
-use super::*;
-
-use crate::Pallet as Identity;
 use frame_benchmarking::{account, benchmarks, whitelisted_caller};
 use frame_support::{
-	ensure, assert_ok,
+	assert_ok, ensure,
 	traits::{EnsureOrigin, Get},
 };
 use frame_system::RawOrigin;
 use sp_runtime::traits::Bounded;
 
+use super::*;
+use crate::Pallet as Identity;
+
 const SEED: u32 = 0;
 
 fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
modifiedpallets/identity/src/lib.rsdiffbeforeafterboth
--- a/pallets/identity/src/lib.rs
+++ b/pallets/identity/src/lib.rs
@@ -95,21 +95,18 @@
 mod types;
 pub mod weights;
 
-use frame_support::{
-	traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency},
-};
+use frame_support::traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency};
+pub use pallet::*;
 use sp_runtime::{
-	BoundedVec,
 	traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero},
+	BoundedVec,
 };
 use sp_std::prelude::*;
-pub use weights::WeightInfo;
-
-pub use pallet::*;
 pub use types::{
 	Data, IdentityField, IdentityFields, IdentityInfo, Judgement, RegistrarIndex, RegistrarInfo,
 	Registration,
 };
+pub use weights::WeightInfo;
 
 pub type BalanceOf<T> =
 	<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
@@ -132,10 +129,11 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	use super::*;
 	use frame_support::pallet_prelude::*;
 	use frame_system::pallet_prelude::*;
 
+	use super::*;
+
 	#[pallet::config]
 	pub trait Config: frame_system::Config {
 		/// The overarching event type.
modifiedpallets/identity/src/tests.rsdiffbeforeafterboth
--- a/pallets/identity/src/tests.rs
+++ b/pallets/identity/src/tests.rs
@@ -34,22 +34,23 @@
 
 // Tests for Identity Pallet
 
-use super::*;
-use crate as pallet_identity;
-
-use codec::{Decode, Encode};
 use frame_support::{
 	assert_noop, assert_ok, ord_parameter_types, parameter_types,
 	traits::{ConstU32, ConstU64, EitherOfDiverse},
 	BoundedVec,
 };
 use frame_system::{EnsureRoot, EnsureSignedBy};
+use parity_scale_codec::{Decode, Encode};
 use sp_core::H256;
 use sp_runtime::{
 	testing::Header,
 	traits::{BadOrigin, BlakeTwo256, IdentityLookup},
+	BuildStorage,
 };
 
+use super::*;
+use crate as pallet_identity;
+
 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
 type Block = frame_system::mocking::MockBlock<Test>;
 
modifiedpallets/identity/src/types.rsdiffbeforeafterboth
--- a/pallets/identity/src/types.rs
+++ b/pallets/identity/src/types.rs
@@ -32,13 +32,12 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-use super::*;
-use codec::{Decode, Encode, MaxEncodedLen};
 use enumflags2::{bitflags, BitFlags};
 use frame_support::{
 	traits::{ConstU32, Get},
 	BoundedVec, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound,
 };
+use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
 use scale_info::{
 	build::{Fields, Variants},
 	meta_type, Path, Type, TypeInfo, TypeParameter,
@@ -46,6 +45,8 @@
 use sp_runtime::{traits::Zero, RuntimeDebug};
 use sp_std::{fmt::Debug, iter::once, ops::Add, prelude::*};
 
+use super::*;
+
 /// Either underlying data blob if it is at most 32 bytes, or a hash of it. If the data is greater
 /// than 32-bytes then it will be truncated when encoding.
 ///
modifiedpallets/inflation/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/inflation/src/benchmarking.rs
+++ b/pallets/inflation/src/benchmarking.rs
@@ -16,11 +16,11 @@
 
 #![cfg(feature = "runtime-benchmarks")]
 
+use frame_benchmarking::benchmarks;
+use frame_support::traits::OnInitialize;
+
 use super::*;
 use crate::Pallet as Inflation;
-
-use frame_benchmarking::{benchmarks};
-use frame_support::traits::OnInitialize;
 
 benchmarks! {
 
modifiedpallets/inflation/src/lib.rsdiffbeforeafterboth
--- a/pallets/inflation/src/lib.rs
+++ b/pallets/inflation/src/lib.rs
@@ -37,17 +37,14 @@
 #[cfg(test)]
 mod tests;
 
-use frame_support::{
-	dispatch::{DispatchResult},
-	traits::{
-		fungible::{Balanced, Inspect, Mutate},
-		Get,
-		tokens::Precision,
-	},
+use frame_support::traits::{
+	fungible::{Balanced, Inspect, Mutate},
+	tokens::Precision,
+	Get,
 };
+use frame_system::pallet_prelude::BlockNumberFor;
 pub use pallet::*;
-use sp_runtime::{Perbill, traits::BlockNumberProvider};
-
+use sp_runtime::{traits::BlockNumberProvider, Perbill};
 use sp_std::convert::TryInto;
 
 type BalanceOf<T> =
@@ -61,10 +58,11 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	use super::*;
 	use frame_support::pallet_prelude::*;
 	use frame_system::pallet_prelude::*;
 
+	use super::*;
+
 	#[pallet::config]
 	pub trait Config: frame_system::Config {
 		type Currency: Balanced<Self::AccountId>
modifiedpallets/inflation/src/tests.rsdiffbeforeafterboth
--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -16,14 +16,12 @@
 
 #![cfg(test)]
 #![allow(clippy::from_over_into)]
-use crate as pallet_inflation;
-
 use frame_support::{
 	assert_ok, parameter_types,
 	traits::{
 		fungible::{Balanced, Inspect},
-		OnInitialize, Everything, ConstU32,
 		tokens::Precision,
+		ConstU32, Everything, OnInitialize,
 	},
 	weights::Weight,
 };
@@ -31,9 +29,11 @@
 use sp_core::H256;
 use sp_runtime::{
 	traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup},
-	testing::Header,
+	BuildStorage,
 };
 
+use crate as pallet_inflation;
+
 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
 type Block = frame_system::mocking::MockBlock<Test>;
 
modifiedpallets/maintenance/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/maintenance/src/benchmarking.rs
+++ b/pallets/maintenance/src/benchmarking.rs
@@ -14,13 +14,13 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use super::*;
-use crate::{Pallet as Maintenance, Config};
-
-use codec::Encode;
 use frame_benchmarking::benchmarks;
+use frame_support::{ensure, pallet_prelude::Weight, traits::StorePreimage};
 use frame_system::RawOrigin;
-use frame_support::{ensure, pallet_prelude::Weight, traits::StorePreimage};
+use parity_scale_codec::Encode;
+
+use super::*;
+use crate::{Config, Pallet as Maintenance};
 
 benchmarks! {
 	enable {
modifiedpallets/maintenance/src/lib.rsdiffbeforeafterboth
--- a/pallets/maintenance/src/lib.rs
+++ b/pallets/maintenance/src/lib.rs
@@ -26,10 +26,14 @@
 #[frame_support::pallet]
 pub mod pallet {
 
-	use frame_support::{dispatch::*, pallet_prelude::*};
-	use frame_support::traits::{QueryPreimage, StorePreimage, EnsureOrigin};
+	use frame_support::{
+		dispatch::*,
+		pallet_prelude::*,
+		traits::{EnsureOrigin, QueryPreimage, StorePreimage},
+	};
 	use frame_system::pallet_prelude::*;
 	use sp_core::H256;
+	use sp_runtime::traits::Dispatchable;
 
 	use crate::weights::WeightInfo;
 
@@ -111,7 +115,7 @@
 			hash: H256,
 			weight_bound: Weight,
 		) -> DispatchResultWithPostInfo {
-			use codec::Decode;
+			use parity_scale_codec::Decode;
 
 			T::PreimageOrigin::ensure_origin(origin.clone())?;
 
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -14,10 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use super::*;
-use crate::{Pallet, Config, NonfungibleHandle};
-
-use frame_benchmarking::{benchmarks, account};
+use frame_benchmarking::{account, benchmarks};
 use pallet_common::{
 	bench_init,
 	benchmarking::{
@@ -27,10 +24,13 @@
 };
 use sp_std::prelude::*;
 use up_data_structs::{
-	CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, budget::Unlimited,
-	PropertyPermission,
+	budget::Unlimited, CollectionMode, PropertyPermission, MAX_ITEMS_PER_BATCH,
+	MAX_PROPERTIES_PER_ITEM,
 };
 
+use super::*;
+use crate::{Config, NonfungibleHandle, Pallet};
+
 const SEED: u32 = 1;
 
 fn create_max_item_data<T: Config>(owner: T::CrossAccountId) -> CreateItemData<T> {
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -17,21 +17,21 @@
 use core::marker::PhantomData;
 
 use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
-use up_data_structs::{
-	TokenId, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKey,
-	PropertyKeyPermission, PropertyValue, TokenOwnerError,
-};
 use pallet_common::{
-	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
-	weights::WeightInfo as _, SelfWeightOf as PalletCommonWeightOf, init_token_properties_delta,
+	init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,
+	CommonWeightInfo, RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,
 };
 use pallet_structure::Pallet as PalletStructure;
 use sp_runtime::DispatchError;
-use sp_std::{vec::Vec, vec};
+use sp_std::{vec, vec::Vec};
+use up_data_structs::{
+	budget::Budget, CollectionId, CreateItemExData, Property, PropertyKey, PropertyKeyPermission,
+	PropertyValue, TokenId, TokenOwnerError,
+};
 
 use crate::{
-	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,
-	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted, TokenProperties,
+	weights::WeightInfo, AccountBalance, Allowance, Config, CreateItemData, Error,
+	NonfungibleHandle, Owned, Pallet, SelfWeightOf, TokenData, TokenProperties, TokensMinted,
 };
 
 pub struct CommonWeights<T: Config>(PhantomData<T>);
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -23,34 +23,34 @@
 
 use alloc::string::ToString;
 use core::{
-	char::{REPLACEMENT_CHARACTER, decode_utf16},
+	char::{decode_utf16, REPLACEMENT_CHARACTER},
 	convert::TryInto,
 };
-use evm_coder::{abi::AbiType, AbiCoder, ToLog, generate_stubgen, solidity_interface, types::*};
+
+use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*, AbiCoder, ToLog};
 use frame_support::BoundedVec;
-use up_data_structs::{
-	TokenId, PropertyPermission, PropertyKeyPermission, Property, CollectionId, PropertyKey,
-	CollectionPropertiesVec,
+use pallet_common::{
+	erc::{static_property::key, CollectionCall, CommonEvmHandler, PrecompileResult},
+	eth::{self, TokenUri},
+	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations, CommonWeightInfo,
 };
+use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{
-	dispatch_to_evm, frontier_contract,
-	execution::{Result, PreDispatch, Error},
+	call, dispatch_to_evm,
+	execution::{Error, PreDispatch, Result},
+	frontier_contract,
 };
-use sp_std::{vec::Vec, vec};
-use pallet_common::{
-	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
-	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
-	eth::{self, TokenUri},
-	CommonWeightInfo,
+use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
+use sp_core::{Get, U256};
+use sp_std::{vec, vec::Vec};
+use up_data_structs::{
+	CollectionId, CollectionPropertiesVec, Property, PropertyKey, PropertyKeyPermission,
+	PropertyPermission, TokenId,
 };
-use pallet_evm::{account::CrossAccountId, PrecompileHandle};
-use pallet_evm_coder_substrate::call;
-use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
-use sp_core::{U256, Get};
 
 use crate::{
-	AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,
-	TokenProperties, SelfWeightOf, weights::WeightInfo, common::CommonWeights,
+	common::CommonWeights, weights::WeightInfo, AccountBalance, Config, CreateItemData,
+	NonfungibleHandle, Pallet, SelfWeightOf, TokenData, TokenProperties, TokensMinted,
 };
 
 /// Nft events.
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -14,12 +14,9 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use super::*;
-use crate::{Pallet, Config, RefungibleHandle};
+use core::{convert::TryInto, iter::IntoIterator};
 
-use core::convert::TryInto;
-use core::iter::IntoIterator;
-use frame_benchmarking::{benchmarks, account};
+use frame_benchmarking::{account, benchmarks};
 use pallet_common::{
 	bench_init,
 	benchmarking::{
@@ -28,10 +25,13 @@
 };
 use sp_std::prelude::*;
 use up_data_structs::{
-	CollectionMode, MAX_ITEMS_PER_BATCH, MAX_PROPERTIES_PER_ITEM, budget::Unlimited,
-	PropertyPermission,
+	budget::Unlimited, CollectionMode, PropertyPermission, MAX_ITEMS_PER_BATCH,
+	MAX_PROPERTIES_PER_ITEM,
 };
 
+use super::*;
+use crate::{Config, Pallet, RefungibleHandle};
+
 const SEED: u32 = 1;
 
 fn create_max_item_data<T: Config>(
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -16,24 +16,25 @@
 
 use core::marker::PhantomData;
 
-use sp_std::collections::btree_map::BTreeMap;
-use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, traits::Get};
-use up_data_structs::{
-	CollectionId, TokenId, CreateItemExData, budget::Budget, Property, PropertyKey, PropertyValue,
-	PropertyKeyPermission, CreateRefungibleExMultipleOwners, CreateRefungibleExSingleOwner,
-	TokenOwnerError,
+use frame_support::{
+	dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
 };
 use pallet_common::{
-	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
-	weights::WeightInfo as _, init_token_properties_delta,
+	init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,
+	CommonWeightInfo, RefungibleExtensions,
 };
-use pallet_structure::{Pallet as PalletStructure, Error as StructureError};
-use sp_runtime::{DispatchError};
-use sp_std::{vec::Vec, vec};
+use pallet_structure::{Error as StructureError, Pallet as PalletStructure};
+use sp_runtime::DispatchError;
+use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
+use up_data_structs::{
+	budget::Budget, CollectionId, CreateItemExData, CreateRefungibleExMultipleOwners,
+	CreateRefungibleExSingleOwner, Property, PropertyKey, PropertyKeyPermission, PropertyValue,
+	TokenId, TokenOwnerError,
+};
 
 use crate::{
-	AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle,
-	SelfWeightOf, weights::WeightInfo, TokensMinted, TotalSupply, CreateItemData, TokenProperties,
+	weights::WeightInfo, AccountBalance, Allowance, Balance, Config, CreateItemData, Error, Owned,
+	Pallet, RefungibleHandle, SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,
 };
 
 macro_rules! max_weight_of {
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -23,34 +23,35 @@
 
 use alloc::string::ToString;
 use core::{
-	char::{REPLACEMENT_CHARACTER, decode_utf16},
+	char::{decode_utf16, REPLACEMENT_CHARACTER},
 	convert::TryInto,
 };
-use evm_coder::{abi::AbiType, AbiCoder, ToLog, generate_stubgen, solidity_interface, types::*};
+
+use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*, AbiCoder, ToLog};
 use frame_support::{BoundedBTreeMap, BoundedVec};
 use pallet_common::{
+	erc::{static_property::key, CollectionCall, CommonEvmHandler},
+	eth::{self, TokenUri},
 	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
 	Error as CommonError,
-	erc::{CommonEvmHandler, CollectionCall, static_property::key},
-	eth::{self, TokenUri},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{
 	call, dispatch_to_evm,
-	execution::{PreDispatch, Result, Error},
+	execution::{Error, PreDispatch, Result},
 	frontier_contract,
 };
-use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
-use sp_core::{H160, U256, Get};
-use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};
+use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
+use sp_core::{Get, H160, U256};
+use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
 use up_data_structs::{
-	CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,
+	mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property, PropertyKey,
 	PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,
 };
 
 use crate::{
-	AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, TokenProperties,
-	TokensMinted, TotalSupply, SelfWeightOf, weights::WeightInfo,
+	weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle,
+	SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,
 };
 
 frontier_contract! {
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -20,11 +20,12 @@
 //! Method implementations are mostly doing parameter conversion and calling Nonfungible Pallet methods.
 
 use core::{
-	char::{REPLACEMENT_CHARACTER, decode_utf16},
+	char::{decode_utf16, REPLACEMENT_CHARACTER},
 	convert::TryInto,
 	ops::Deref,
 };
-use evm_coder::{abi::AbiType, ToLog, generate_stubgen, solidity_interface, types::*};
+
+use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*, ToLog};
 use pallet_common::{
 	erc::{CommonEvmHandler, PrecompileResult},
 	eth::{collection_id_to_address, CrossAddress},
@@ -32,17 +33,18 @@
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{
-	call, dispatch_to_evm, WithRecorder, frontier_contract,
-	execution::{Result, PreDispatch},
+	call, dispatch_to_evm,
+	execution::{PreDispatch, Result},
+	frontier_contract, WithRecorder,
 };
-use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
-use sp_std::vec::Vec;
+use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
 use sp_core::U256;
+use sp_std::vec::Vec;
 use up_data_structs::TokenId;
 
 use crate::{
-	Allowance, Balance, Config, Pallet, RefungibleHandle, TotalSupply, common::CommonWeights,
-	SelfWeightOf, weights::WeightInfo,
+	common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, Pallet,
+	RefungibleHandle, SelfWeightOf, TotalSupply,
 };
 
 /// Refungible token handle contains information about token's collection and id
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -87,30 +87,29 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use crate::erc_token::ERC20Events;
-use crate::erc::ERC721Events;
+use core::{cmp::Ordering, ops::Deref};
 
-use core::{ops::Deref, cmp::Ordering};
 use evm_coder::ToLog;
 use frame_support::{ensure, storage::with_transaction, transactional};
-use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
-use pallet_evm_coder_substrate::WithRecorder;
+pub use pallet::*;
 use pallet_common::{
-	Error as CommonError, eth::collection_id_to_address, Event as CommonEvent,
+	eth::collection_id_to_address, Error as CommonError, Event as CommonEvent,
 	Pallet as PalletCommon,
 };
+use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
+use pallet_evm_coder_substrate::WithRecorder;
 use pallet_structure::Pallet as PalletStructure;
 use sp_core::{Get, H160};
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};
-use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};
+use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
 use up_data_structs::{
-	AccessMode, budget::Budget, CollectionId, CreateCollectionData, mapping::TokenAddressMapping,
-	MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission, PropertyScope,
-	PropertyValue, TokenId, PropertiesPermissionMap, CreateRefungibleExMultipleOwners,
-	TokenOwnerError, TokenProperties as TokenPropertiesT,
+	budget::Budget, mapping::TokenAddressMapping, AccessMode, CollectionId, CreateCollectionData,
+	CreateRefungibleExMultipleOwners, PropertiesPermissionMap, Property, PropertyKey,
+	PropertyKeyPermission, PropertyScope, PropertyValue, TokenId, TokenOwnerError,
+	TokenProperties as TokenPropertiesT, TrySetProperty, MAX_REFUNGIBLE_PIECES,
 };
 
-pub use pallet::*;
+use crate::{erc::ERC721Events, erc_token::ERC20Events};
 #[cfg(feature = "runtime-benchmarks")]
 pub mod benchmarking;
 pub mod common;
@@ -124,14 +123,14 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	use super::*;
 	use frame_support::{
-		Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key,
-		traits::StorageVersion,
+		pallet_prelude::*, storage::Key, traits::StorageVersion, Blake2_128, Blake2_128Concat,
+		Twox64Concat,
 	};
 	use up_data_structs::{CollectionId, TokenId};
-	use super::weights::WeightInfo;
 
+	use super::{weights::WeightInfo, *};
+
 	#[pallet::error]
 	pub enum Error<T> {
 		/// Not Refungible item data used to mint in Refungible collection.
modifiedpallets/structure/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/structure/src/benchmarking.rs
+++ b/pallets/structure/src/benchmarking.rs
@@ -14,16 +14,16 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use super::*;
-
-use frame_benchmarking::{benchmarks, account};
-use frame_support::traits::{fungible::Balanced, Get, tokens::Precision};
+use frame_benchmarking::{account, benchmarks};
+use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};
+use pallet_common::Config as CommonConfig;
+use pallet_evm::account::CrossAccountId;
 use up_data_structs::{
-	CreateCollectionData, CollectionMode, CreateItemData, CreateNftData, budget::Unlimited,
+	budget::Unlimited, CollectionMode, CreateCollectionData, CreateItemData, CreateNftData,
 };
-use pallet_common::Config as CommonConfig;
-use pallet_evm::account::CrossAccountId;
 
+use super::*;
+
 const SEED: u32 = 1;
 
 benchmarks! {
modifiedpallets/structure/src/lib.rsdiffbeforeafterboth
--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -53,29 +53,31 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use pallet_common::CommonCollectionOperations;
-use pallet_common::{erc::CrossAccountId, eth::is_collection};
+use frame_support::{
+	dispatch::{DispatchResult, DispatchResultWithPostInfo},
+	fail,
+	pallet_prelude::*,
+};
+use pallet_common::{
+	dispatch::CollectionDispatch, erc::CrossAccountId, eth::is_collection,
+	CommonCollectionOperations,
+};
 use sp_std::collections::btree_set::BTreeSet;
-
-use frame_support::dispatch::{DispatchError, DispatchResult, DispatchResultWithPostInfo};
-use frame_support::fail;
-pub use pallet::*;
-use pallet_common::{dispatch::CollectionDispatch};
 use up_data_structs::{
-	CollectionId, TokenId, mapping::TokenAddressMapping, budget::Budget, TokenOwnerError,
+	budget::Budget, mapping::TokenAddressMapping, CollectionId, TokenId, TokenOwnerError,
 };
 
 #[cfg(feature = "runtime-benchmarks")]
 pub mod benchmarking;
 pub mod weights;
 
+pub use pallet::*;
+
 pub type SelfWeightOf<T> = <T as crate::Config>::WeightInfo;
 
 #[frame_support::pallet]
 pub mod pallet {
-	use frame_support::Parameter;
-	use frame_support::dispatch::{GetDispatchInfo, UnfilteredDispatchable};
-	use frame_support::pallet_prelude::*;
+	use frame_support::{dispatch::GetDispatchInfo, traits::UnfilteredDispatchable, Parameter};
 
 	use super::*;
 
modifiedpallets/unique/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/unique/src/benchmarking.rs
+++ b/pallets/unique/src/benchmarking.rs
@@ -16,22 +16,23 @@
 
 #![cfg(feature = "runtime-benchmarks")]
 
-use super::*;
-use crate::Pallet;
+use frame_benchmarking::{account, benchmarks};
+use frame_support::traits::{fungible::Balanced, tokens::Precision, Get};
 use frame_system::RawOrigin;
-use frame_support::traits::{fungible::Balanced, Get, tokens::Precision};
-use frame_benchmarking::{benchmarks, account};
-use sp_runtime::DispatchError;
 use pallet_common::{
-	Config as CommonConfig,
 	benchmarking::{create_data, create_u16_data},
+	erc::CrossAccountId,
+	Config as CommonConfig,
 };
+use sp_runtime::DispatchError;
 use up_data_structs::{
-	CollectionId, CollectionMode, MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
-	MAX_COLLECTION_DESCRIPTION_LENGTH, CollectionLimits,
+	CollectionId, CollectionLimits, CollectionMode, MAX_COLLECTION_DESCRIPTION_LENGTH,
+	MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
 };
-use pallet_common::erc::CrossAccountId;
 
+use super::*;
+use crate::Pallet;
+
 const SEED: u32 = 1;
 
 fn create_collection_helper<T: Config>(
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -16,32 +16,31 @@
 
 //! Implementation of CollectionHelpers contract.
 //!
+use alloc::{collections::BTreeSet, format};
 use core::marker::PhantomData;
+
 use ethereum as _;
 use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*};
-use frame_support::{BoundedVec, traits::Get};
+use frame_support::{traits::Get, BoundedVec};
 use pallet_common::{
-	CollectionById,
 	dispatch::CollectionDispatch,
-	erc::{CollectionHelpersEvents, static_property::key},
-	eth::{self, map_eth_to_id, collection_id_to_address},
-	Pallet as PalletCommon, CollectionHandle,
+	erc::{static_property::key, CollectionHelpersEvents},
+	eth::{self, collection_id_to_address, map_eth_to_id},
+	CollectionById, CollectionHandle, Pallet as PalletCommon,
 };
 use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
 use pallet_evm_coder_substrate::{
-	dispatch_to_evm, SubstrateRecorder, WithRecorder,
-	execution::{PreDispatch, Result, Error},
-	frontier_contract,
+	dispatch_to_evm,
+	execution::{Error, PreDispatch, Result},
+	frontier_contract, SubstrateRecorder, WithRecorder,
 };
+use sp_std::vec::Vec;
 use up_data_structs::{
 	CollectionDescription, CollectionMode, CollectionName, CollectionPermissions,
 	CollectionTokenPrefix, CreateCollectionData, NestingPermissions,
 };
 
 use crate::{weights::WeightInfo, Config, Pallet, SelfWeightOf};
-
-use alloc::{format, collections::BTreeSet};
-use sp_std::vec::Vec;
 
 frontier_contract! {
 	macro_rules! EvmCollectionHelpers_result {...}
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -73,9 +73,9 @@
 
 extern crate alloc;
 
-pub use pallet::*;
 use frame_support::pallet_prelude::*;
 use frame_system::pallet_prelude::*;
+pub use pallet::*;
 pub mod eth;
 
 #[cfg(feature = "runtime-benchmarks")]
@@ -84,27 +84,27 @@
 
 #[frame_support::pallet]
 pub mod pallet {
-	use super::*;
-
-	use frame_support::{dispatch::DispatchResult, ensure, fail, BoundedVec, storage::Key};
+	use frame_support::{dispatch::DispatchResult, ensure, fail, storage::Key, BoundedVec};
+	use frame_system::{ensure_root, ensure_signed};
+	use pallet_common::{
+		dispatch::{dispatch_tx, CollectionDispatch},
+		CollectionHandle, CommonWeightInfo, Pallet as PalletCommon, RefungibleExtensionsWeightInfo,
+	};
+	use pallet_evm::account::CrossAccountId;
 	use scale_info::TypeInfo;
-	use frame_system::{ensure_signed, ensure_root};
 	use sp_std::{vec, vec::Vec};
 	use up_data_structs::{
-		MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
-		MAX_PROPERTIES_PER_ITEM, MAX_PROPERTY_KEY_LENGTH, MAX_PROPERTY_VALUE_LENGTH,
-		MAX_COLLECTION_PROPERTIES_SIZE, COLLECTION_ADMINS_LIMIT, MAX_TOKEN_PROPERTIES_SIZE,
-		CreateItemData, CollectionLimits, CollectionPermissions, CollectionId, CollectionMode,
-		TokenId, CreateCollectionData, CreateItemExData, budget, Property, PropertyKey,
-		PropertyKeyPermission,
-	};
-	use pallet_evm::account::CrossAccountId;
-	use pallet_common::{
-		CollectionHandle, Pallet as PalletCommon, CommonWeightInfo, dispatch::dispatch_tx,
-		dispatch::CollectionDispatch, RefungibleExtensionsWeightInfo,
+		budget, CollectionId, CollectionLimits, CollectionMode, CollectionPermissions,
+		CreateCollectionData, CreateItemData, CreateItemExData, Property, PropertyKey,
+		PropertyKeyPermission, TokenId, COLLECTION_ADMINS_LIMIT, MAX_COLLECTION_DESCRIPTION_LENGTH,
+		MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_PROPERTIES_SIZE, MAX_PROPERTIES_PER_ITEM,
+		MAX_PROPERTY_KEY_LENGTH, MAX_PROPERTY_VALUE_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
+		MAX_TOKEN_PROPERTIES_SIZE,
 	};
 	use weights::WeightInfo;
 
+	use super::*;
+
 	/// A maximum number of levels of depth in the token nesting tree.
 	pub const NESTING_BUDGET: u32 = 5;
 
modifiedprimitives/app_promotion_rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/app_promotion_rpc/src/lib.rs
+++ b/primitives/app_promotion_rpc/src/lib.rs
@@ -16,12 +16,12 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use sp_std::vec::Vec;
-use codec::Decode;
+use parity_scale_codec::Decode;
 use sp_runtime::{
+	traits::{AtLeast32BitUnsigned, Member},
 	DispatchError,
-	traits::{AtLeast32BitUnsigned, Member},
 };
+use sp_std::vec::Vec;
 
 type Result<T> = core::result::Result<T, DispatchError>;
 
modifiedprimitives/common/src/constants.rsdiffbeforeafterboth
--- a/primitives/common/src/constants.rs
+++ b/primitives/common/src/constants.rs
@@ -14,13 +14,14 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use sp_runtime::Perbill;
+use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;
 use frame_support::{
 	parameter_types,
-	weights::{Weight, constants::WEIGHT_REF_TIME_PER_SECOND},
+	weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
 };
-use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;
-use crate::types::{BlockNumber, Balance};
+use sp_runtime::Perbill;
+
+use crate::types::{Balance, BlockNumber};
 
 pub const MILLISECS_PER_BLOCK: u64 = 12000;
 pub const MILLISECS_PER_RELAY_BLOCK: u64 = 6000;
modifiedprimitives/common/src/types.rsdiffbeforeafterboth
--- a/primitives/common/src/types.rs
+++ b/primitives/common/src/types.rs
@@ -16,7 +16,7 @@
 
 use sp_runtime::{
 	generic,
-	traits::{Verify, IdentifyAccount},
+	traits::{IdentifyAccount, Verify},
 	MultiSignature,
 };
 
@@ -27,7 +27,7 @@
 pub mod opaque {
 	pub use sp_runtime::{generic, traits::BlakeTwo256, OpaqueExtrinsic as UncheckedExtrinsic};
 
-	pub use super::{BlockNumber, Signature, AccountId, Balance, Index, Hash, AuraId};
+	pub use super::{AccountId, AuraId, Balance, BlockNumber, Hash, Signature};
 
 	#[derive(Debug, Clone)]
 	pub enum RuntimeId {
modifiedprimitives/data-structs/src/bounded.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/bounded.rs
+++ b/primitives/data-structs/src/bounded.rs
@@ -17,13 +17,15 @@
 //! This module contins implementations for support bounded structures ([`BoundedVec`], [`BoundedBTreeMap`], [`BoundedBTreeSet`]) in [`serde`].
 
 use core::fmt;
-use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
-use sp_std::vec::Vec;
 
 use frame_support::{
+	storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet},
 	BoundedVec,
-	storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet},
 };
+use sp_std::{
+	collections::{btree_map::BTreeMap, btree_set::BTreeSet},
+	vec::Vec,
+};
 
 /// [`serde`] implementations for [`BoundedVec`].
 pub mod vec_serde {
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -25,20 +25,21 @@
 	fmt,
 	ops::Deref,
 };
-use frame_support::storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet};
 
-#[cfg(feature = "serde")]
-use serde::{Serialize, Deserialize};
-
-use sp_core::U256;
-use sp_runtime::{ArithmeticError, sp_std::prelude::Vec};
-use sp_std::collections::btree_set::BTreeSet;
-use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};
-use frame_support::{BoundedVec, traits::ConstU32};
+use bondrewd::Bitfields;
 use derivative::Derivative;
-use scale_info::TypeInfo;
 use evm_coder::AbiCoderFlags;
-use bondrewd::Bitfields;
+use frame_support::{
+	storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet},
+	traits::ConstU32,
+	BoundedVec,
+};
+use parity_scale_codec::{Decode, Encode, EncodeLike, MaxEncodedLen};
+use scale_info::TypeInfo;
+use serde::{Deserialize, Serialize};
+use sp_core::U256;
+use sp_runtime::{sp_std::prelude::Vec, ArithmeticError};
+use sp_std::collections::btree_set::BTreeSet;
 
 mod bondrewd_codec;
 mod bounded;
modifiedprimitives/data-structs/src/mapping.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/mapping.rs
+++ b/primitives/data-structs/src/mapping.rs
@@ -18,10 +18,10 @@
 
 use core::marker::PhantomData;
 
+use pallet_evm::account::CrossAccountId;
 use sp_core::H160;
 
 use crate::{CollectionId, TokenId};
-use pallet_evm::account::CrossAccountId;
 
 /// Trait for mapping between token id and some `Address`.
 pub trait TokenAddressMapping<Address> {
modifiedprimitives/data-structs/src/migration.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/migration.rs
+++ b/primitives/data-structs/src/migration.rs
@@ -17,8 +17,9 @@
 /// Storage migration is not required for this change, as SponsoringRateLimit has same encoding as Option<u32>
 #[test]
 fn sponsoring_rate_limit_has_same_encoding_as_option_u32() {
+	use parity_scale_codec::Encode;
+
 	use crate::SponsoringRateLimit;
-	use codec::Encode;
 
 	fn limit_to_option(limit: SponsoringRateLimit) -> Option<u32> {
 		match limit {
@@ -41,8 +42,9 @@
 
 #[test]
 fn collection_flags_have_same_encoding_as_bool() {
+	use parity_scale_codec::Encode;
+
 	use crate::CollectionFlags;
-	use codec::Encode;
 
 	assert_eq!(
 		true.encode(),
modifiedprimitives/pov-estimate-rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/pov-estimate-rpc/src/lib.rs
+++ b/primitives/pov-estimate-rpc/src/lib.rs
@@ -17,12 +17,10 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 
 use scale_info::TypeInfo;
-use sp_std::vec::Vec;
-
 #[cfg(feature = "std")]
 use serde::Serialize;
-
 use sp_runtime::ApplyExtrinsicResult;
+use sp_std::vec::Vec;
 
 #[cfg_attr(feature = "std", derive(Serialize))]
 #[derive(Debug, TypeInfo)]
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -18,14 +18,13 @@
 
 extern crate alloc;
 
+use parity_scale_codec::Decode;
+use sp_runtime::DispatchError;
+use sp_std::vec::Vec;
 use up_data_structs::{
-	CollectionId, TokenId, RawEncoded, RpcCollection, CollectionStats, CollectionLimits, Property,
-	PropertyKeyPermission, TokenData, TokenChild, TokenDataVersion1,
+	CollectionId, CollectionLimits, CollectionStats, Property, PropertyKeyPermission,
+	RpcCollection, TokenChild, TokenData, TokenId,
 };
-
-use sp_std::vec::Vec;
-use codec::Decode;
-use sp_runtime::DispatchError;
 
 type Result<T> = core::result::Result<T, DispatchError>;
 
modifiedruntime/common/config/ethereum.rsdiffbeforeafterboth
--- a/runtime/common/config/ethereum.rs
+++ b/runtime/common/config/ethereum.rs
@@ -1,22 +1,24 @@
-use sp_core::{U256, H160};
 use frame_support::{
-	weights::{Weight, constants::WEIGHT_REF_TIME_PER_SECOND},
-	traits::{FindAuthor},
-	parameter_types, ConsensusEngineId,
+	parameter_types,
+	traits::FindAuthor,
+	weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
+	ConsensusEngineId,
 };
-use sp_runtime::{RuntimeAppPublic, Perbill, traits::ConstU32};
+use pallet_ethereum::PostLogContent;
+use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping};
+use sp_core::{H160, U256};
+use sp_runtime::{traits::ConstU32, Perbill, RuntimeAppPublic};
+use up_common::constants::*;
+
 use crate::{
 	runtime_common::{
 		config::sponsoring::DefaultSponsoringRateLimit,
-		DealWithFees,
 		dispatch::CollectionDispatchT,
 		ethereum::{precompiles::UniquePrecompiles, sponsoring::EvmSponsorshipHandler},
+		DealWithFees,
 	},
-	Runtime, Aura, Balances, RuntimeEvent, ChainId,
+	Aura, Balances, ChainId, Runtime, RuntimeEvent,
 };
-use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping};
-use pallet_ethereum::PostLogContent;
-use up_common::constants::*;
 
 pub type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;
 
modifiedruntime/common/config/governance/fellowship.rsdiffbeforeafterboth
--- a/runtime/common/config/governance/fellowship.rs
+++ b/runtime/common/config/governance/fellowship.rs
@@ -1,8 +1,11 @@
-use crate::{Preimage, Treasury, RuntimeCall, RuntimeEvent, Scheduler, FellowshipReferenda, Runtime};
-use super::*;
 use pallet_gov_origins::Origin as GovOrigins;
 use pallet_ranked_collective::{Config as RankedConfig, Rank, TallyOf};
 
+use super::*;
+use crate::{
+	FellowshipReferenda, Preimage, Runtime, RuntimeCall, RuntimeEvent, Scheduler, Treasury,
+};
+
 pub const FELLOWSHIP_MODULE_ID: PalletId = PalletId(*b"flowship");
 pub const DEMOCRACY_TRACK_ID: u16 = 10;
 
modifiedruntime/common/config/governance/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/governance/mod.rs
+++ b/runtime/common/config/governance/mod.rs
@@ -15,29 +15,31 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{
-	PalletId, parameter_types,
+	pallet_prelude::*,
+	parameter_types,
 	traits::{
-		EnsureOrigin, EqualPrivilegeOnly, EitherOfDiverse, EitherOf, MapSuccess, ConstU16, Polling,
+		ConstU16, EitherOf, EitherOfDiverse, EnsureOrigin, EqualPrivilegeOnly, MapSuccess, Polling,
 	},
 	weights::Weight,
-	pallet_prelude::*,
+	PalletId,
 };
-use frame_system::{EnsureRoot, EnsureNever};
+use frame_system::{EnsureNever, EnsureRoot};
+use pallet_collective::EnsureProportionAtLeast;
 use sp_runtime::{
+	morph_types,
+	traits::{AccountIdConversion, CheckedSub, ConstU32, Convert, Replace},
 	Perbill,
-	traits::{AccountIdConversion, ConstU32, Replace, CheckedSub, Convert},
-	morph_types,
 };
-use crate::{
-	Runtime, RuntimeOrigin, RuntimeEvent, RuntimeCall, OriginCaller, Preimage, Balances, Treasury,
-	Scheduler, Council, TechnicalCommittee,
-};
 pub use up_common::{
-	constants::{UNIQUE, DAYS, HOURS, MINUTES, CENTIUNIQUE},
+	constants::{CENTIUNIQUE, DAYS, HOURS, MINUTES, UNIQUE},
 	types::{AccountId, Balance, BlockNumber},
 };
-use pallet_collective::EnsureProportionAtLeast;
 
+use crate::{
+	Balances, Council, OriginCaller, Preimage, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
+	Scheduler, TechnicalCommittee, Treasury,
+};
+
 pub mod council;
 pub use council::*;
 
modifiedruntime/common/config/orml.rsdiffbeforeafterboth
--- a/runtime/common/config/orml.rs
+++ b/runtime/common/config/orml.rs
@@ -20,26 +20,26 @@
 };
 use frame_system::EnsureSigned;
 use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key};
+use pallet_foreign_assets::{CurrencyId, NativeCurrency};
 use sp_runtime::traits::Convert;
-use xcm::latest::{Weight, Junction::*, Junctions::*, MultiLocation};
-use xcm_executor::XcmExecutor;
 use sp_std::{vec, vec::Vec};
-use pallet_foreign_assets::{CurrencyId, NativeCurrency};
+use staging_xcm::latest::{Junction::*, Junctions::*, MultiLocation, Weight};
+use staging_xcm_executor::XcmExecutor;
+use up_common::{
+	constants::*,
+	types::{AccountId, Balance},
+};
+
 use crate::{
-	Runtime, RuntimeEvent, RelayChainBlockNumberProvider,
 	runtime_common::config::{
+		pallets::TreasuryAccountId,
+		substrate::{MaxLocks, MaxReserves},
 		xcm::{
-			SelfLocation, Weigher, XcmExecutorConfig, UniversalLocation,
-			xcm_assets::{CurrencyIdConvert},
+			xcm_assets::CurrencyIdConvert, SelfLocation, UniversalLocation, Weigher,
+			XcmExecutorConfig,
 		},
-		pallets::TreasuryAccountId,
-		substrate::{MaxLocks, MaxReserves},
 	},
-};
-
-use up_common::{
-	types::{AccountId, Balance},
-	constants::*,
+	RelayChainBlockNumberProvider, Runtime, RuntimeEvent,
 };
 
 // Signed version of balance
modifiedruntime/common/config/pallets/app_promotion.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/app_promotion.rs
+++ b/runtime/common/config/pallets/app_promotion.rs
@@ -14,18 +14,18 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use crate::{
-	runtime_common::config::pallets::{TreasuryAccountId, RelayChainBlockNumberProvider},
-	Runtime, Balances, BlockNumber, Unique, RuntimeEvent, EvmContractHelpers, Maintenance,
-};
-
 use frame_support::{parameter_types, PalletId};
 use sp_arithmetic::Perbill;
 use up_common::{
-	constants::{UNIQUE, DAYS, RELAY_DAYS},
+	constants::{DAYS, RELAY_DAYS, UNIQUE},
 	types::Balance,
 };
 
+use crate::{
+	runtime_common::config::pallets::{RelayChainBlockNumberProvider, TreasuryAccountId},
+	Balances, BlockNumber, EvmContractHelpers, Maintenance, Runtime, RuntimeEvent, Unique,
+};
+
 parameter_types! {
 	pub const AppPromotionId: PalletId = PalletId(*b"appstake");
 	pub const RecalculationInterval: BlockNumber = RELAY_DAYS;
modifiedruntime/common/config/pallets/collator_selection.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/collator_selection.rs
+++ b/runtime/common/config/pallets/collator_selection.rs
@@ -15,23 +15,21 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{parameter_types, PalletId};
-use crate::{
-	Balance, Balances, BlockNumber, Runtime, RuntimeEvent, Aura, Session, SessionKeys,
-	CollatorSelection, Treasury,
-	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},
+#[cfg(not(feature = "governance"))]
+use frame_system::EnsureRoot;
+use pallet_configuration::{
+	CollatorSelectionDesiredCollatorsOverride, CollatorSelectionKickThresholdOverride,
+	CollatorSelectionLicenseBondOverride,
 };
+use sp_runtime::Perbill;
+use up_common::constants::{MILLIUNIQUE, UNIQUE};
 
 #[cfg(feature = "governance")]
 use crate::config::governance;
-
-#[cfg(not(feature = "governance"))]
-use frame_system::EnsureRoot;
-
-use sp_runtime::Perbill;
-use up_common::constants::{UNIQUE, MILLIUNIQUE};
-use pallet_configuration::{
-	CollatorSelectionKickThresholdOverride, CollatorSelectionLicenseBondOverride,
-	CollatorSelectionDesiredCollatorsOverride,
+use crate::{
+	config::pallets::{MaxCollators, SessionPeriod, TreasuryAccountId},
+	Aura, Balance, Balances, BlockNumber, CollatorSelection, Runtime, RuntimeEvent,
+	RuntimeHoldReason, Session, SessionKeys, Treasury,
 };
 parameter_types! {
 	pub const SessionOffset: BlockNumber = 0;
modifiedruntime/common/config/pallets/foreign_asset.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/foreign_asset.rs
+++ b/runtime/common/config/pallets/foreign_asset.rs
@@ -1,6 +1,7 @@
-use crate::{Runtime, RuntimeEvent, Balances};
 use up_common::types::AccountId;
 
+use crate::{Balances, Runtime, RuntimeEvent};
+
 impl pallet_foreign_assets::Config for Runtime {
 	type RuntimeEvent = RuntimeEvent;
 	type Currency = Balances;
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -15,29 +15,30 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use alloc::string::{String, ToString};
-use frame_support::parameter_types;
+
+use frame_support::{
+	parameter_types,
+	traits::{ConstU32, ConstU64, Currency},
+};
+use sp_arithmetic::Perbill;
 use sp_runtime::traits::AccountIdConversion;
+use up_common::{
+	constants::*,
+	types::{AccountId, Balance, BlockNumber},
+};
+use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};
+
+#[cfg(feature = "governance")]
+use crate::runtime_common::config::governance;
 use crate::{
 	runtime_common::{
+		config::{ethereum::EvmCollectionHelpersAddress, substrate::TreasuryModuleId},
 		dispatch::CollectionDispatchT,
-		config::{substrate::TreasuryModuleId, ethereum::EvmCollectionHelpersAddress},
 		weights::CommonWeights,
 		RelayChainBlockNumberProvider,
 	},
-	Runtime, RuntimeEvent, RuntimeCall, VERSION, TOKEN_SYMBOL, DECIMALS, Balances,
-};
-use frame_support::traits::{ConstU32, ConstU64, Currency};
-use up_common::{
-	types::{AccountId, Balance, BlockNumber},
-	constants::*,
-};
-use up_data_structs::{
-	mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},
+	Balances, Runtime, RuntimeCall, RuntimeEvent, DECIMALS, TOKEN_SYMBOL, VERSION,
 };
-use sp_arithmetic::Perbill;
-
-#[cfg(feature = "governance")]
-use crate::runtime_common::config::governance;
 
 #[cfg(feature = "unique-scheduler")]
 pub mod scheduler;
modifiedruntime/common/config/pallets/preimage.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/preimage.rs
+++ b/runtime/common/config/pallets/preimage.rs
@@ -16,9 +16,10 @@
 
 use frame_support::parameter_types;
 use frame_system::EnsureRoot;
-use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent};
 use up_common::constants::*;
 
+use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent};
+
 parameter_types! {
 	pub PreimageBaseDeposit: Balance = 1000 * UNIQUE;
 }
modifiedruntime/common/config/pallets/scheduler.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/scheduler.rs
+++ b/runtime/common/config/pallets/scheduler.rs
@@ -14,21 +14,23 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+use core::cmp::Ordering;
+
 use frame_support::{
-	traits::{PrivilegeCmp, EnsureOrigin},
-	weights::Weight,
 	parameter_types,
+	traits::{EnsureOrigin, PrivilegeCmp},
+	weights::Weight,
 };
 use frame_system::{EnsureRoot, RawOrigin};
+use pallet_unique_scheduler_v2::ScheduledEnsureOriginSuccess;
+use parity_scale_codec::Decode;
 use sp_runtime::Perbill;
-use core::cmp::Ordering;
-use codec::Decode;
+use up_common::types::AccountId;
+
 use crate::{
-	runtime_common::{scheduler::SchedulerPaymentExecutor, config::substrate::RuntimeBlockWeights},
-	Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, OriginCaller,
+	runtime_common::{config::substrate::RuntimeBlockWeights, scheduler::SchedulerPaymentExecutor},
+	OriginCaller, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
 };
-use pallet_unique_scheduler_v2::ScheduledEnsureOriginSuccess;
-use up_common::types::AccountId;
 
 parameter_types! {
 	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *
modifiedruntime/common/config/parachain.rsdiffbeforeafterboth
--- a/runtime/common/config/parachain.rs
+++ b/runtime/common/config/parachain.rs
@@ -14,10 +14,11 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use frame_support::{weights::Weight, parameter_types};
-use crate::{Runtime, RuntimeEvent, XcmpQueue, DmpQueue};
+use frame_support::{parameter_types, weights::Weight};
 use up_common::constants::*;
 
+use crate::{DmpQueue, Runtime, RuntimeEvent, XcmpQueue};
+
 parameter_types! {
 	pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
 	pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
modifiedruntime/common/config/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/config/sponsoring.rs
+++ b/runtime/common/config/sponsoring.rs
@@ -14,14 +14,12 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use crate::{
-	runtime_common::{sponsoring::UniqueSponsorshipHandler},
-	Runtime,
-};
 use frame_support::parameter_types;
 use sp_core::U256;
 use up_common::{constants::*, types::BlockNumber};
 
+use crate::{runtime_common::sponsoring::UniqueSponsorshipHandler, Runtime};
+
 parameter_types! {
 	pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;
 	pub const DefaultSponsoringFeeLimit: U256 = U256::MAX;
modifiedruntime/common/config/substrate.rsdiffbeforeafterboth
--- a/runtime/common/config/substrate.rs
+++ b/runtime/common/config/substrate.rs
@@ -15,31 +15,32 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{
-	traits::{Everything, ConstU32, NeverEnsureOrigin},
+	dispatch::DispatchClass,
+	ord_parameter_types, parameter_types,
+	traits::{ConstBool, ConstU32, Everything, NeverEnsureOrigin},
 	weights::{
 		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
 		ConstantMultiplier,
 	},
-	dispatch::DispatchClass,
-	parameter_types, ord_parameter_types, PalletId,
-};
-use sp_runtime::{
-	generic,
-	traits::{BlakeTwo256, AccountIdLookup},
-	Perbill, Permill, Percent,
+	PalletId,
 };
-use sp_arithmetic::traits::One;
 use frame_system::{
 	limits::{BlockLength, BlockWeights},
 	EnsureRoot, EnsureSignedBy,
 };
-use pallet_transaction_payment::{Multiplier, ConstFeeMultiplier};
-use crate::{
-	runtime_common::DealWithFees, Runtime, RuntimeEvent, RuntimeCall, RuntimeOrigin, OriginCaller,
-	PalletInfo, System, Balances, SS58Prefix, Version,
+use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier};
+use sp_arithmetic::traits::One;
+use sp_runtime::{
+	traits::{AccountIdLookup, BlakeTwo256},
+	Perbill, Percent, Permill,
 };
-use up_common::{types::*, constants::*};
 use sp_std::vec;
+use up_common::{constants::*, types::*};
+
+use crate::{
+	runtime_common::DealWithFees, Balances, Block, OriginCaller, PalletInfo, Runtime, RuntimeCall,
+	RuntimeEvent, RuntimeHoldReason, RuntimeOrigin, SS58Prefix, System, Version,
+};
 
 parameter_types! {
 	pub const BlockHashCount: BlockNumber = 2400;
modifiedruntime/common/config/test_pallets.rsdiffbeforeafterboth
--- a/runtime/common/config/test_pallets.rs
+++ b/runtime/common/config/test_pallets.rs
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use crate::{Runtime, RuntimeEvent, RuntimeCall};
+use crate::{Runtime, RuntimeCall, RuntimeEvent};
 
 impl pallet_test_utils::Config for Runtime {
 	type RuntimeEvent = RuntimeEvent;
modifiedruntime/common/config/xcm/foreignassets.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/foreignassets.rs
+++ b/runtime/common/config/xcm/foreignassets.rs
@@ -14,23 +14,22 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use frame_support::{traits::Get, parameter_types};
-use sp_runtime::traits::Convert;
-use xcm::latest::{prelude::*, MultiAsset, MultiLocation};
-use xcm_builder::{FungiblesAdapter, NoChecking, ConvertedConcreteId};
-use xcm_executor::traits::{TransactAsset, Convert as ConvertXcm, JustTry};
-use pallet_foreign_assets::{
-	AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, NativeCurrency, FreeForAll, TryAsForeign,
-	ForeignAssetId, CurrencyId,
-};
-use sp_std::{borrow::Borrow, marker::PhantomData};
+use frame_support::{parameter_types, traits::Get};
 use orml_traits::location::AbsoluteReserveProvider;
 use orml_xcm_support::MultiNativeAsset;
-use crate::{Runtime, Balances, ParachainInfo, PolkadotXcm, ForeignAssets};
+use pallet_foreign_assets::{
+	AssetId, AssetIdMapping, CurrencyId, ForeignAssetId, FreeForAll, NativeCurrency, TryAsForeign,
+	XcmForeignAssetIdMapping,
+};
+use sp_runtime::traits::{Convert, MaybeEquivalence};
+use sp_std::marker::PhantomData;
+use staging_xcm::latest::{prelude::*, MultiAsset, MultiLocation};
+use staging_xcm_builder::{ConvertedConcreteId, FungiblesAdapter, NoChecking};
+use staging_xcm_executor::traits::{JustTry, TransactAsset};
+use up_common::types::{AccountId, Balance};
 
 use super::{LocationToAccountId, RelayLocation};
-
-use up_common::types::{AccountId, Balance};
+use crate::{Balances, ForeignAssets, ParachainInfo, PolkadotXcm, Runtime};
 
 parameter_types! {
 	pub CheckingAccount: AccountId = PolkadotXcm::check_account();
modifiedruntime/common/config/xcm/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -15,28 +15,33 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{
-	traits::{Everything, Nothing, Get, ConstU32, ProcessMessageError, Contains},
 	parameter_types,
+	traits::{ConstU32, Contains, Everything, Get, Nothing, ProcessMessageError},
 };
 use frame_system::EnsureRoot;
 use pallet_xcm::XcmPassthrough;
-use polkadot_parachain::primitives::Sibling;
-use xcm::latest::{prelude::*, Weight, MultiLocation};
-use xcm::v3::Instruction;
-use xcm_builder::{
-	AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, ParentAsSuperuser, RelayChainAsNative,
-	SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
-	SignedToAccountId32, SovereignSignedViaLocation, ParentIsPreset,
-};
-use xcm_executor::{XcmExecutor, traits::ShouldExecute};
+use polkadot_parachain_primitives::primitives::Sibling;
 use sp_std::marker::PhantomData;
-use crate::{
-	Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, ParachainInfo, ParachainSystem, PolkadotXcm,
-	XcmpQueue, xcm_barrier::Barrier, RelayNetwork, AllPalletsWithSystem, Balances,
+use staging_xcm::{
+	latest::{prelude::*, MultiLocation, Weight},
+	v3::Instruction,
+};
+use staging_xcm_builder::{
+	AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, ParentAsSuperuser, ParentIsPreset,
+	RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
+	SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
+};
+use staging_xcm_executor::{
+	traits::{Properties, ShouldExecute},
+	XcmExecutor,
 };
-
 use up_common::types::AccountId;
 
+use crate::{
+	xcm_barrier::Barrier, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem,
+	PolkadotXcm, RelayNetwork, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmpQueue,
+};
+
 #[cfg(feature = "foreign-assets")]
 pub mod foreignassets;
 
@@ -45,14 +50,12 @@
 
 #[cfg(feature = "foreign-assets")]
 pub use foreignassets as xcm_assets;
-
 #[cfg(not(feature = "foreign-assets"))]
 pub use nativeassets as xcm_assets;
+use xcm_assets::{AssetTransactor, IsReserve, Trader};
 
 #[cfg(feature = "governance")]
 use crate::runtime_common::config::governance;
-
-use xcm_assets::{AssetTransactor, IsReserve, Trader};
 
 parameter_types! {
 	pub const RelayLocation: MultiLocation = MultiLocation::parent();
modifiedruntime/common/config/xcm/nativeassets.rsdiffbeforeafterboth
--- a/runtime/common/config/xcm/nativeassets.rs
+++ b/runtime/common/config/xcm/nativeassets.rs
@@ -14,31 +14,28 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+use cumulus_primitives_core::XcmContext;
 use frame_support::{
-	traits::{tokens::currency::Currency as CurrencyT, OnUnbalanced as OnUnbalancedT, Get},
+	traits::{tokens::currency::Currency as CurrencyT, Get, OnUnbalanced as OnUnbalancedT},
 	weights::WeightToFeePolynomial,
 };
-use sp_runtime::traits::{CheckedConversion, Zero, Convert};
-use xcm::latest::{
-	AssetId::{Concrete},
-	Fungibility::Fungible as XcmFungible,
-	MultiAsset, Error as XcmError, Weight,
-	Junction::*,
-	MultiLocation,
-	Junctions::*,
+use pallet_foreign_assets::{AssetIds, NativeCurrency};
+use sp_runtime::traits::{CheckedConversion, Convert, Zero};
+use sp_std::marker::PhantomData;
+use staging_xcm::latest::{
+	AssetId::Concrete, Error as XcmError, Fungibility::Fungible as XcmFungible, Junction::*,
+	Junctions::*, MultiAsset, MultiLocation, Weight,
 };
-use xcm_builder::{CurrencyAdapter, NativeAsset};
-use xcm_executor::{
+use staging_xcm_builder::{CurrencyAdapter, NativeAsset};
+use staging_xcm_executor::{
+	traits::{MatchesFungible, WeightTrader},
 	Assets,
-	traits::{MatchesFungible, WeightTrader},
 };
-use pallet_foreign_assets::{AssetIds, NativeCurrency};
-use sp_std::marker::PhantomData;
-use crate::{Balances, ParachainInfo};
-use super::{LocationToAccountId, RelayLocation};
-
 use up_common::types::{AccountId, Balance};
 
+use super::{LocationToAccountId, RelayLocation};
+use crate::{Balances, ParachainInfo};
+
 pub struct OnlySelfCurrency;
 impl<B: TryFrom<u128>> MatchesFungible<B> for OnlySelfCurrency {
 	fn matches_fungible(a: &MultiAsset) -> Option<B> {
modifiedruntime/common/dispatch.rsdiffbeforeafterboth
--- a/runtime/common/dispatch.rs
+++ b/runtime/common/dispatch.rs
@@ -15,28 +15,27 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{dispatch::DispatchResult, ensure, fail};
-use pallet_evm::{PrecompileHandle, PrecompileResult};
-use sp_core::H160;
-use sp_runtime::DispatchError;
-use sp_std::{borrow::ToOwned, vec::Vec};
+use pallet_balances_adapter::NativeFungibleHandle;
+pub use pallet_common::dispatch::CollectionDispatch;
+#[cfg(not(feature = "refungible"))]
+use pallet_common::unsupported;
 use pallet_common::{
-	CollectionById, CollectionHandle, CommonCollectionOperations, erc::CommonEvmHandler,
-	eth::map_eth_to_id,
+	erc::CommonEvmHandler, eth::map_eth_to_id, CollectionById, CollectionHandle,
+	CommonCollectionOperations,
 };
-pub use pallet_common::dispatch::CollectionDispatch;
-use pallet_fungible::{Pallet as PalletFungible, FungibleHandle};
-use pallet_balances_adapter::NativeFungibleHandle;
-use pallet_nonfungible::{Pallet as PalletNonfungible, NonfungibleHandle};
+use pallet_evm::{PrecompileHandle, PrecompileResult};
+use pallet_fungible::{FungibleHandle, Pallet as PalletFungible};
+use pallet_nonfungible::{NonfungibleHandle, Pallet as PalletNonfungible};
 use pallet_refungible::{
-	Pallet as PalletRefungible, RefungibleHandle, erc_token::RefungibleTokenHandle,
+	erc_token::RefungibleTokenHandle, Pallet as PalletRefungible, RefungibleHandle,
 };
+use sp_core::H160;
+use sp_runtime::DispatchError;
+use sp_std::{borrow::ToOwned, vec::Vec};
 use up_data_structs::{
-	CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,
-	CollectionId,
+	mapping::TokenAddressMapping, CollectionId, CollectionMode, CreateCollectionData,
+	MAX_DECIMAL_POINTS,
 };
-
-#[cfg(not(feature = "refungible"))]
-use pallet_common::unsupported;
 
 pub enum CollectionDispatchT<T>
 where
modifiedruntime/common/ethereum/precompiles/mod.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/precompiles/mod.rs
+++ b/runtime/common/ethereum/precompiles/mod.rs
@@ -14,11 +14,12 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use pallet_evm::{Precompile, PrecompileHandle, PrecompileResult, PrecompileSet, IsPrecompileResult};
+use pallet_evm::{
+	IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult, PrecompileSet,
+};
+use pallet_evm_precompile_simple::ECRecover;
 use sp_core::H160;
 use sp_std::marker::PhantomData;
-
-use pallet_evm_precompile_simple::{ECRecover};
 use sr25519::Sr25519Precompile;
 
 mod sr25519;
modifiedruntime/common/ethereum/precompiles/sr25519.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/precompiles/sr25519.rs
+++ b/runtime/common/ethereum/precompiles/sr25519.rs
@@ -17,8 +17,7 @@
 use fp_evm::{Context, ExitSucceed, PrecompileHandle, PrecompileOutput};
 use pallet_evm::Precompile;
 use sp_core::{crypto::UncheckedFrom, sr25519, H256};
-use sp_std::marker::PhantomData;
-use sp_std::prelude::*;
+use sp_std::{marker::PhantomData, prelude::*};
 
 use super::utils::{Bytes, EvmDataReader, EvmDataWriter, EvmResult, FunctionModifier, Gasometer};
 
modifiedruntime/common/ethereum/precompiles/utils/data.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/precompiles/utils/data.rs
+++ b/runtime/common/ethereum/precompiles/utils/data.rs
@@ -16,12 +16,12 @@
 // You should have received a copy of the GNU General Public License
 // along with Utils.  If not, see <http://www.gnu.org/licenses/>.
 
-use super::{EvmResult, Gasometer};
+use core::{any::type_name, ops::Range};
 
-use sp_std::borrow::ToOwned;
-use core::{any::type_name, ops::Range};
 use sp_core::{H160, H256, U256};
-use sp_std::{convert::TryInto, vec, vec::Vec};
+use sp_std::{borrow::ToOwned, convert::TryInto, vec, vec::Vec};
+
+use super::{EvmResult, Gasometer};
 
 /// The `address` type of Solidity.
 /// H160 could represent 2 types of data (bytes20 and address) that are not encoded the same way.
modifiedruntime/common/ethereum/precompiles/utils/macro/src/lib.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/precompiles/utils/macro/src/lib.rs
+++ b/runtime/common/ethereum/precompiles/utils/macro/src/lib.rs
@@ -19,11 +19,12 @@
 #![crate_type = "proc-macro"]
 extern crate proc_macro;
 
+use std::convert::TryInto;
+
 use proc_macro::TokenStream;
 use proc_macro2::Literal;
 use quote::{quote, quote_spanned};
 use sha3::{Digest, Keccak256};
-use std::convert::TryInto;
 use syn::{parse_macro_input, spanned::Spanned, Expr, ExprLit, Ident, ItemEnum, Lit};
 
 /// This macro allows to associate to each variant of an enumeration a discriminant (of type u32
modifiedruntime/common/ethereum/precompiles/utils/mod.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/precompiles/utils/mod.rs
+++ b/runtime/common/ethereum/precompiles/utils/mod.rs
@@ -16,10 +16,9 @@
 // You should have received a copy of the GNU General Public License
 // along with Utils.  If not, see <http://www.gnu.org/licenses/>.
 
-use sp_std::borrow::ToOwned;
 use fp_evm::{Context, ExitRevert, PrecompileFailure};
 use sp_core::U256;
-use sp_std::marker::PhantomData;
+use sp_std::{borrow::ToOwned, marker::PhantomData};
 
 mod data;
 
modifiedruntime/common/ethereum/self_contained_call.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/self_contained_call.rs
+++ b/runtime/common/ethereum/self_contained_call.rs
@@ -16,11 +16,12 @@
 
 use sp_core::H160;
 use sp_runtime::{
-	traits::{Dispatchable, DispatchInfoOf, PostDispatchInfoOf},
-	transaction_validity::{TransactionValidityError, TransactionValidity, InvalidTransaction},
+	traits::{DispatchInfoOf, Dispatchable, PostDispatchInfoOf},
+	transaction_validity::{InvalidTransaction, TransactionValidity, TransactionValidityError},
 };
-use crate::{RuntimeOrigin, RuntimeCall, Maintenance};
 
+use crate::{Maintenance, RuntimeCall, RuntimeOrigin};
+
 impl fp_self_contained::SelfContainedCall for RuntimeCall {
 	type SignedInfo = H160;
 
modifiedruntime/common/ethereum/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring.rs
+++ b/runtime/common/ethereum/sponsoring.rs
@@ -17,35 +17,36 @@
 //! Implements EVM sponsoring logic via TransactionValidityHack
 
 use core::{convert::TryInto, marker::PhantomData};
-use evm_coder::{Call};
-use pallet_common::{CollectionHandle, eth::map_eth_to_id};
+
+use evm_coder::Call;
+use pallet_common::{eth::map_eth_to_id, CollectionHandle};
 use pallet_evm::account::CrossAccountId;
 use pallet_evm_transaction_payment::CallContext;
+use pallet_fungible::{
+	erc::{ERC20Call, UniqueFungibleCall},
+	Config as FungibleConfig,
+};
 use pallet_nonfungible::{
-	Config as NonfungibleConfig, Pallet as NonfungiblePallet, NonfungibleHandle,
 	erc::{
-		UniqueNFTCall, ERC721UniqueExtensionsCall, ERC721UniqueMintableCall, ERC721Call,
-		TokenPropertiesCall,
+		ERC721Call, ERC721UniqueExtensionsCall, ERC721UniqueMintableCall, TokenPropertiesCall,
+		UniqueNFTCall,
 	},
-};
-use pallet_fungible::{
-	Config as FungibleConfig,
-	erc::{UniqueFungibleCall, ERC20Call},
+	Config as NonfungibleConfig, NonfungibleHandle, Pallet as NonfungiblePallet,
 };
 use pallet_refungible::{
-	Config as RefungibleConfig,
 	erc::UniqueRefungibleCall,
 	erc_token::{RefungibleTokenHandle, UniqueRefungibleTokenCall},
-	RefungibleHandle,
+	Config as RefungibleConfig, RefungibleHandle,
 };
 use pallet_unique::Config as UniqueConfig;
 use sp_std::prelude::*;
 use up_data_structs::{
-	CollectionMode, CreateItemData, CreateNftData, mapping::TokenAddressMapping, TokenId,
+	mapping::TokenAddressMapping, CollectionMode, CreateItemData, CreateNftData, TokenId,
 };
 use up_sponsorship::SponsorshipHandler;
-use crate::{Runtime, runtime_common::sponsoring::*};
 
+use crate::{runtime_common::sponsoring::*, Runtime};
+
 mod refungible;
 
 pub type EvmSponsorshipHandler = (
@@ -206,9 +207,9 @@
 }
 
 mod common {
-	use super::*;
+	use pallet_common::erc::CollectionCall;
 
-	use pallet_common::erc::{CollectionCall};
+	use super::*;
 
 	pub fn collection_call_sponsor<T>(
 		call: CollectionCall<T>,
modifiedruntime/common/ethereum/sponsoring/refungible.rsdiffbeforeafterboth
--- a/runtime/common/ethereum/sponsoring/refungible.rs
+++ b/runtime/common/ethereum/sponsoring/refungible.rs
@@ -19,14 +19,7 @@
 use pallet_common::CollectionHandle;
 use pallet_evm::account::CrossAccountId;
 use pallet_fungible::Config as FungibleConfig;
-use pallet_refungible::Config as RefungibleConfig;
 use pallet_nonfungible::Config as NonfungibleConfig;
-use pallet_unique::Config as UniqueConfig;
-use up_data_structs::{CreateItemData, CreateNftData, TokenId};
-
-use super::common;
-use crate::runtime_common::sponsoring::*;
-
 use pallet_refungible::{
 	erc::{
 		ERC721BurnableCall, ERC721Call, ERC721EnumerableCall, ERC721MetadataCall,
@@ -37,7 +30,13 @@
 		ERC1633Call, ERC20Call, ERC20UniqueExtensionsCall, RefungibleTokenHandle,
 		UniqueRefungibleTokenCall,
 	},
+	Config as RefungibleConfig,
 };
+use pallet_unique::Config as UniqueConfig;
+use up_data_structs::{CreateItemData, CreateNftData, TokenId};
+
+use super::common;
+use crate::runtime_common::sponsoring::*;
 
 pub fn call_sponsor<T>(
 	call: UniqueRefungibleCall<T>,
modifiedruntime/common/identity.rsdiffbeforeafterboth
--- a/runtime/common/identity.rs
+++ b/runtime/common/identity.rs
@@ -14,18 +14,17 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+use parity_scale_codec::{Decode, Encode};
 use scale_info::TypeInfo;
-use codec::{Encode, Decode};
-use up_common::types::AccountId;
-use crate::RuntimeCall;
-
+#[cfg(feature = "collator-selection")]
+use sp_runtime::transaction_validity::InvalidTransaction;
 use sp_runtime::{
 	traits::{DispatchInfoOf, SignedExtension},
-	transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},
+	transaction_validity::{TransactionValidity, TransactionValidityError, ValidTransaction},
 };
+use up_common::types::AccountId;
 
-#[cfg(feature = "collator-selection")]
-use sp_runtime::transaction_validity::InvalidTransaction;
+use crate::RuntimeCall;
 
 #[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]
 pub struct DisableIdentityCalls;
modifiedruntime/common/instance.rsdiffbeforeafterboth
--- a/runtime/common/instance.rs
+++ b/runtime/common/instance.rs
@@ -1,9 +1,7 @@
-use crate::{
-	runtime_common::{config::ethereum::CrossAccountId},
-	Runtime,
-};
 use up_common::types::opaque::RuntimeInstance;
 
+use crate::{runtime_common::config::ethereum::CrossAccountId, Runtime};
+
 impl RuntimeInstance for Runtime {
 	type CrossAccountId = CrossAccountId;
 }
modifiedruntime/common/maintenance.rsdiffbeforeafterboth
--- a/runtime/common/maintenance.rs
+++ b/runtime/common/maintenance.rs
@@ -14,17 +14,17 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+use parity_scale_codec::{Decode, Encode};
 use scale_info::TypeInfo;
-use codec::{Encode, Decode};
-use up_common::types::AccountId;
-use crate::{RuntimeCall, Maintenance};
-
 use sp_runtime::{
 	traits::{DispatchInfoOf, SignedExtension},
 	transaction_validity::{
-		TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError,
+		InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
 	},
 };
+use up_common::types::AccountId;
+
+use crate::{Maintenance, RuntimeCall};
 
 #[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]
 pub struct CheckMaintenance;
modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -33,26 +33,23 @@
 #[cfg(test)]
 pub mod tests;
 
-use sp_core::H160;
 use frame_support::{
-	traits::{Currency, OnUnbalanced, Imbalance},
+	traits::{Currency, Imbalance, OnUnbalanced},
 	weights::Weight,
 };
 use sp_runtime::{
-	generic,
+	generic, impl_opaque_keys,
 	traits::{BlakeTwo256, BlockNumberProvider},
-	impl_opaque_keys,
 };
 use sp_std::vec::Vec;
-
 #[cfg(feature = "std")]
 use sp_version::NativeVersion;
+use up_common::types::{AccountId, BlockNumber};
 
 use crate::{
-	Runtime, RuntimeCall, Balances, Treasury, Aura, Signature, AllPalletsWithSystem,
-	InherentDataExt,
+	AllPalletsWithSystem, Aura, Balances, InherentDataExt, Runtime, RuntimeCall, Signature,
+	Treasury,
 };
-use up_common::types::{AccountId, BlockNumber};
 
 #[macro_export]
 macro_rules! unsupported {
@@ -175,7 +172,7 @@
 	}
 }
 
-#[derive(codec::Encode, codec::Decode)]
+#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode)]
 pub enum XCMPMessage<XAccountId, XBalance> {
 	/// Transfer tokens to the given account from the Parachain account.
 	TransferToken(XAccountId, XBalance),
@@ -186,9 +183,10 @@
 	fn on_runtime_upgrade() -> Weight {
 		#[cfg(feature = "collator-selection")]
 		{
-			use frame_support::{BoundedVec, storage::migration};
-			use sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic};
+			use frame_support::{storage::migration, BoundedVec};
 			use pallet_session::SessionManager;
+			use sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic};
+
 			use crate::config::pallets::MaxCollators;
 
 			let mut weight = <Runtime as frame_system::Config>::DbWeight::get().reads(1);
modifiedruntime/common/scheduler.rsdiffbeforeafterboth
--- a/runtime/common/scheduler.rs
+++ b/runtime/common/scheduler.rs
@@ -14,21 +14,20 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use frame_support::{
-	dispatch::{GetDispatchInfo, PostDispatchInfo, DispatchInfo},
-};
+use fp_self_contained::SelfContainedCall;
+use frame_support::dispatch::{DispatchInfo, GetDispatchInfo, PostDispatchInfo};
+use pallet_transaction_payment::ChargeTransactionPayment;
+use pallet_unique_scheduler_v2::DispatchCall;
+use parity_scale_codec::Encode;
 use sp_runtime::{
-	traits::{Dispatchable, Applyable, Member},
+	traits::{Applyable, Dispatchable, Member},
 	transaction_validity::TransactionValidityError,
 	DispatchErrorWithPostInfo,
 };
-use codec::Encode;
-use crate::{Runtime, RuntimeCall, RuntimeOrigin, maintenance};
 use up_common::types::AccountId;
-use fp_self_contained::SelfContainedCall;
-use pallet_unique_scheduler_v2::DispatchCall;
-use pallet_transaction_payment::ChargeTransactionPayment;
 
+use crate::{maintenance, Runtime, RuntimeCall, RuntimeOrigin};
+
 /// The SignedExtension to the basic transaction logic.
 pub type SignedExtraScheduler = (
 	frame_system::CheckWeight<Runtime>,
modifiedruntime/common/sponsoring.rsdiffbeforeafterboth
--- a/runtime/common/sponsoring.rs
+++ b/runtime/common/sponsoring.rs
@@ -15,25 +15,25 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use core::marker::PhantomData;
-use up_sponsorship::SponsorshipHandler;
-use frame_support::{
-	traits::{IsSubType},
-};
-use up_data_structs::{
-	CollectionId, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, NFT_SPONSOR_TRANSFER_TIMEOUT,
-	REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, TokenId, CollectionMode, CreateItemData,
-};
-use sp_runtime::traits::Saturating;
-use pallet_common::{CollectionHandle};
+
+use frame_support::traits::IsSubType;
+use frame_system::pallet_prelude::*;
+use pallet_common::CollectionHandle;
 use pallet_evm::account::CrossAccountId;
-use pallet_unique::{
-	Call as UniqueCall, Config as UniqueConfig, FungibleApproveBasket, RefungibleApproveBasket,
-	NftApproveBasket, CreateItemBasket, ReFungibleTransferBasket, FungibleTransferBasket,
-	NftTransferBasket, TokenPropertyBasket,
-};
 use pallet_fungible::Config as FungibleConfig;
 use pallet_nonfungible::Config as NonfungibleConfig;
 use pallet_refungible::Config as RefungibleConfig;
+use pallet_unique::{
+	Call as UniqueCall, Config as UniqueConfig, CreateItemBasket, FungibleApproveBasket,
+	FungibleTransferBasket, NftApproveBasket, NftTransferBasket, ReFungibleTransferBasket,
+	RefungibleApproveBasket, TokenPropertyBasket,
+};
+use sp_runtime::traits::Saturating;
+use up_data_structs::{
+	CollectionId, CollectionMode, CreateItemData, TokenId, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+	NFT_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+};
+use up_sponsorship::SponsorshipHandler;
 
 pub trait Config: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig {}
 impl<T> Config for T where T: UniqueConfig + FungibleConfig + NonfungibleConfig + RefungibleConfig {}
modifiedruntime/common/tests/mod.rsdiffbeforeafterboth
--- a/runtime/common/tests/mod.rs
+++ b/runtime/common/tests/mod.rs
@@ -14,12 +14,12 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+use sp_core::{Pair, Public};
+pub use sp_runtime::AccountId32 as AccountId;
 use sp_runtime::{BuildStorage, Storage};
-use sp_core::{Public, Pair};
 use up_common::types::AuraId;
-use crate::{Runtime, GenesisConfig, ParachainInfoConfig, RuntimeEvent, System};
 
-pub use sp_runtime::AccountId32 as AccountId;
+use crate::{BuildGenesisConfig, ParachainInfoConfig, Runtime, RuntimeEvent, System};
 pub type Balance = u128;
 
 pub mod xcm;
@@ -62,10 +62,11 @@
 
 #[cfg(feature = "collator-selection")]
 fn make_basic_storage() -> Storage {
-	use sp_core::{sr25519};
+	use sp_core::sr25519;
 	use sp_runtime::traits::{IdentifyAccount, Verify};
-	use crate::{AccountId, Signature, SessionKeys, CollatorSelectionConfig, SessionConfig};
 
+	use crate::{AccountId, CollatorSelectionConfig, SessionConfig, SessionKeys, Signature};
+
 	type AccountPublic = <Signature as Verify>::Signer;
 
 	fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
modifiedruntime/common/tests/xcm.rsdiffbeforeafterboth
--- a/runtime/common/tests/xcm.rs
+++ b/runtime/common/tests/xcm.rs
@@ -14,15 +14,16 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use xcm::{
-	VersionedXcm,
+use frame_support::pallet_prelude::Weight;
+use parity_scale_codec::Encode;
+use staging_xcm::{
 	latest::{prelude::*, Error},
+	VersionedXcm,
 };
-use codec::Encode;
-use crate::{Runtime, RuntimeCall, RuntimeOrigin, RuntimeEvent, PolkadotXcm};
-use super::{new_test_ext, last_events, AccountId};
-use frame_support::{pallet_prelude::Weight};
 
+use super::{last_events, new_test_ext, AccountId};
+use crate::{PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
+
 const ALICE: AccountId = AccountId::new([0u8; 32]);
 const BOB: AccountId = AccountId::new([1u8; 32]);
 
modifiedruntime/common/weights/mod.rsdiffbeforeafterboth
--- a/runtime/common/weights/mod.rs
+++ b/runtime/common/weights/mod.rs
@@ -15,20 +15,21 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use core::marker::PhantomData;
-use frame_support::{weights::Weight};
-use pallet_common::{CommonWeightInfo, dispatch::dispatch_weight, RefungibleExtensionsWeightInfo};
 
+use frame_support::weights::Weight;
 use pallet_balances_adapter::{
-	Config as NativeFungibleConfig, common::CommonWeights as NativeFungibleWeights,
+	common::CommonWeights as NativeFungibleWeights, Config as NativeFungibleConfig,
 };
-use pallet_fungible::{Config as FungibleConfig, common::CommonWeights as FungibleWeights};
-use pallet_nonfungible::{Config as NonfungibleConfig, common::CommonWeights as NonfungibleWeights};
-
+use pallet_common::{dispatch::dispatch_weight, CommonWeightInfo, RefungibleExtensionsWeightInfo};
+use pallet_fungible::{common::CommonWeights as FungibleWeights, Config as FungibleConfig};
+use pallet_nonfungible::{
+	common::CommonWeights as NonfungibleWeights, Config as NonfungibleConfig,
+};
 #[cfg(feature = "refungible")]
 use pallet_refungible::{
-	Config as RefungibleConfig, weights::WeightInfo, common::CommonWeights as RefungibleWeights,
+	common::CommonWeights as RefungibleWeights, weights::WeightInfo, Config as RefungibleConfig,
 };
-use up_data_structs::{CreateItemExData, CreateItemData};
+use up_data_structs::{CreateItemData, CreateItemExData};
 
 pub mod xcm;
 
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -27,14 +27,11 @@
 
 extern crate alloc;
 
+use ::staging_xcm::latest::NetworkId;
 use frame_support::parameter_types;
-
-use sp_version::RuntimeVersion;
 use sp_runtime::create_runtime_str;
-
+use sp_version::RuntimeVersion;
 use up_common::types::*;
-
-use ::xcm::latest::NetworkId;
 
 mod runtime_common;
 
modifiedruntime/opal/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/opal/src/xcm_barrier.rs
+++ b/runtime/opal/src/xcm_barrier.rs
@@ -16,7 +16,7 @@
 
 use frame_support::{match_types, traits::Everything};
 use xcm::latest::{Junctions::*, MultiLocation};
-use xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit, AllowExplicitUnpaidExecutionFrom};
+use staging_xcm_builder::{AllowTopLevelPaidExecutionFrom, TakeWeightCredit, AllowExplicitUnpaidExecutionFrom};
 
 match_types! {
 	pub type ParentOnly: impl Contains<MultiLocation> = {
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -27,14 +27,11 @@
 
 extern crate alloc;
 
+use ::staging_xcm::latest::NetworkId;
 use frame_support::parameter_types;
-
-use sp_version::RuntimeVersion;
 use sp_runtime::create_runtime_str;
-
+use sp_version::RuntimeVersion;
 use up_common::types::*;
-
-use ::xcm::latest::NetworkId;
 
 mod runtime_common;
 
modifiedruntime/quartz/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/quartz/src/xcm_barrier.rs
+++ b/runtime/quartz/src/xcm_barrier.rs
@@ -15,8 +15,8 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{match_types, traits::Everything};
-use xcm::latest::{Junctions::*, MultiLocation};
-use xcm_builder::{
+use staging_xcm::latest::{Junctions::*, MultiLocation};
+use staging_xcm_builder::{
 	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom,
 };
modifiedruntime/tests/src/lib.rsdiffbeforeafterboth
--- a/runtime/tests/src/lib.rs
+++ b/runtime/tests/src/lib.rs
@@ -16,27 +16,26 @@
 
 #![allow(clippy::from_over_into)]
 
-use sp_core::{H160, H256, U256};
 use frame_support::{
+	pallet_prelude::Weight,
 	parameter_types,
-	traits::{Everything, ConstU32, ConstU64, fungible::Inspect},
+	traits::{fungible::Inspect, ConstU32, ConstU64, Everything},
 	weights::IdentityFee,
-	pallet_prelude::Weight,
 };
-use sp_runtime::{
-	traits::{BlakeTwo256, IdentityLookup},
-	testing::Header,
-};
-use pallet_transaction_payment::CurrencyAdapter;
 use frame_system as system;
+use pallet_ethereum::PostLogContent;
 use pallet_evm::{
-	AddressMapping, account::CrossAccountId, EnsureAddressNever, SubstrateBlockHashMapping,
-	BackwardsAddressMapping,
+	account::CrossAccountId, AddressMapping, BackwardsAddressMapping, EnsureAddressNever,
+	SubstrateBlockHashMapping,
 };
-use pallet_ethereum::PostLogContent;
-use codec::{Encode, Decode, MaxEncodedLen};
+use pallet_transaction_payment::CurrencyAdapter;
+use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
 use scale_info::TypeInfo;
-
+use sp_core::{H160, H256, U256};
+use sp_runtime::{
+	testing::Header,
+	traits::{BlakeTwo256, IdentityLookup},
+};
 use up_data_structs::mapping::{CrossTokenAddressMapping, EvmTokenAddressMapping};
 
 #[path = "../../common/dispatch.rs"]
modifiedruntime/tests/src/tests.rsdiffbeforeafterboth
--- a/runtime/tests/src/tests.rs
+++ b/runtime/tests/src/tests.rs
@@ -15,19 +15,22 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 // Tests to be written here
-use crate::{Test, TestCrossAccountId, CollectionCreationPrice, RuntimeOrigin, Unique, new_test_ext};
+use frame_support::{assert_err, assert_noop, assert_ok};
+use pallet_common::Error as CommonError;
+use pallet_evm::account::CrossAccountId;
+use pallet_unique::Error as UniqueError;
+use sp_std::convert::TryInto;
 use up_data_structs::{
-	COLLECTION_NUMBER_LIMIT, CollectionId, CreateItemData, CreateFungibleData, CreateNftData,
-	CreateReFungibleData, MAX_DECIMAL_POINTS, COLLECTION_ADMINS_LIMIT, TokenId,
-	MAX_TOKEN_OWNERSHIP, CreateCollectionData, CollectionMode, AccessMode, CollectionPermissions,
-	PropertyKeyPermission, PropertyPermission, Property, CollectionPropertiesVec,
-	CollectionPropertiesPermissionsVec,
+	AccessMode, CollectionId, CollectionMode, CollectionPermissions,
+	CollectionPropertiesPermissionsVec, CollectionPropertiesVec, CreateCollectionData,
+	CreateFungibleData, CreateItemData, CreateNftData, CreateReFungibleData, Property,
+	PropertyKeyPermission, PropertyPermission, TokenId, COLLECTION_ADMINS_LIMIT,
+	COLLECTION_NUMBER_LIMIT, MAX_DECIMAL_POINTS, MAX_TOKEN_OWNERSHIP,
+};
+
+use crate::{
+	new_test_ext, CollectionCreationPrice, RuntimeOrigin, Test, TestCrossAccountId, Unique,
 };
-use frame_support::{assert_noop, assert_ok, assert_err};
-use sp_std::convert::TryInto;
-use pallet_evm::account::CrossAccountId;
-use pallet_common::Error as CommonError;
-use pallet_unique::Error as UniqueError;
 
 fn add_balance(user: u64, value: u64) {
 	const DONOR_USER: u64 = 999;
@@ -2617,9 +2620,10 @@
 }
 
 mod check_token_permissions {
-	use super::*;
 	use pallet_common::LazyValue;
 
+	use super::*;
+
 	fn test<FTE: FnOnce() -> bool>(
 		i: usize,
 		test_case: &pallet_common::tests::TestCase,
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -27,14 +27,11 @@
 
 extern crate alloc;
 
+use ::staging_xcm::latest::NetworkId;
 use frame_support::parameter_types;
-
-use sp_version::RuntimeVersion;
 use sp_runtime::create_runtime_str;
-
+use sp_version::RuntimeVersion;
 use up_common::types::*;
-
-use ::xcm::latest::NetworkId;
 
 mod runtime_common;
 
modifiedruntime/unique/src/xcm_barrier.rsdiffbeforeafterboth
--- a/runtime/unique/src/xcm_barrier.rs
+++ b/runtime/unique/src/xcm_barrier.rs
@@ -15,8 +15,8 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 use frame_support::{match_types, traits::Everything};
-use xcm::latest::{Junctions::*, MultiLocation};
-use xcm_builder::{
+use staging_xcm::latest::{Junctions::*, MultiLocation};
+use staging_xcm_builder::{
 	AllowKnownQueryResponses, AllowSubscriptionsFrom, TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom, AllowExplicitUnpaidExecutionFrom,
 };
modifiedtest-pallets/utils/src/lib.rsdiffbeforeafterboth
--- a/test-pallets/utils/src/lib.rs
+++ b/test-pallets/utils/src/lib.rs
@@ -16,18 +16,19 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-pub use pallet::*;
 use frame_support::pallet_prelude::*;
 use frame_system::pallet_prelude::*;
+pub use pallet::*;
 
 #[frame_support::pallet(dev_mode)]
 pub mod pallet {
 	use frame_support::{
+		dispatch::{GetDispatchInfo, PostDispatchInfo},
 		pallet_prelude::*,
-		dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo},
-		traits::{UnfilteredDispatchable, IsSubType, OriginTrait},
+		traits::{IsSubType, OriginTrait, UnfilteredDispatchable},
 	};
 	use frame_system::pallet_prelude::*;
+	use sp_runtime::traits::Dispatchable;
 	use sp_std::vec::Vec;
 
 	#[pallet::config]