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
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -58,37 +58,37 @@
 	slice::from_ref,
 	marker::PhantomData,
 };
-use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use sp_std::vec::Vec;
-use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
+
 use evm_coder::ToLog;
 use frame_support::{
-	dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Weight, PostDispatchInfo},
-	ensure,
+	dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, Pays, PostDispatchInfo},
+	ensure, fail,
 	traits::{
-		Get,
 		fungible::{Balanced, Debt, Inspect},
 		tokens::{Imbalance, Precision, Preservation},
+		Get,
 	},
-	dispatch::Pays,
-	transactional, fail,
+	transactional,
 };
+pub use pallet::*;
+use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
+use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
+use sp_core::H160;
+use sp_runtime::{traits::Zero, ArithmeticError, DispatchError, DispatchResult};
+use sp_std::vec::Vec;
+use sp_weights::Weight;
 use up_data_structs::{
-	AccessMode, COLLECTION_NUMBER_LIMIT, Collection, RpcCollection, RpcCollectionFlags,
-	CollectionId, CreateItemData, MAX_TOKEN_PREFIX_LENGTH, COLLECTION_ADMINS_LIMIT, TokenId,
-	TokenChild, CollectionStats, MAX_TOKEN_OWNERSHIP, CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT,
-	FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT,
-	CUSTOM_DATA_LIMIT, CollectionLimits, CreateCollectionData, SponsorshipState, CreateItemExData,
-	SponsoringRateLimit, budget::Budget, PhantomType, Property,
-	CollectionProperties as CollectionPropertiesT, TokenProperties, PropertiesPermissionMap,
-	PropertyKey, PropertyValue, PropertyPermission, PropertiesError, TokenOwnerError,
-	PropertyKeyPermission, TokenData, TrySetProperty, PropertyScope, CollectionPermissions,
+	budget::Budget, AccessMode, Collection, CollectionId, CollectionLimits, CollectionMode,
+	CollectionPermissions, CollectionProperties as CollectionPropertiesT, CollectionStats,
+	CreateCollectionData, CreateItemData, CreateItemExData, PhantomType, PropertiesError,
+	PropertiesPermissionMap, Property, PropertyKey, PropertyKeyPermission, PropertyPermission,
+	PropertyScope, PropertyValue, RpcCollection, RpcCollectionFlags, SponsoringRateLimit,
+	SponsorshipState, TokenChild, TokenData, TokenId, TokenOwnerError, TokenProperties,
+	TrySetProperty, COLLECTION_ADMINS_LIMIT, COLLECTION_NUMBER_LIMIT, CUSTOM_DATA_LIMIT,
+	FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, MAX_TOKEN_OWNERSHIP,
+	MAX_TOKEN_PREFIX_LENGTH, NFT_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
 };
 use up_pov_estimate_rpc::PovInfo;
-
-pub use pallet::*;
-use sp_core::H160;
-use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, traits::Zero};
 
 #[cfg(feature = "runtime-benchmarks")]
 pub mod benchmarking;
@@ -401,13 +401,16 @@
 #[frame_support::pallet]
 pub mod pallet {
 
-	use super::*;
 	use dispatch::CollectionDispatch;
-	use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key, traits::StorageVersion};
-	use up_data_structs::{TokenId, mapping::TokenAddressMapping};
+	use frame_support::{
+		pallet_prelude::*, storage::Key, traits::StorageVersion, Blake2_128Concat,
+	};
 	use scale_info::TypeInfo;
+	use up_data_structs::{mapping::TokenAddressMapping, TokenId};
 	use weights::WeightInfo;
 
+	use super::*;
+
 	#[pallet::config]
 	pub trait Config:
 		frame_system::Config + pallet_evm_coder_substrate::Config + pallet_evm::Config + TypeInfo
@@ -2720,7 +2723,7 @@
 #[cfg(any(feature = "tests", test))]
 #[allow(missing_docs)]
 pub mod tests {
-	use crate::{DispatchResult, DispatchError, LazyValue, Config};
+	use crate::{Config, DispatchError, DispatchResult, LazyValue};
 
 	const fn to_bool(u: u8) -> bool {
 		u != 0
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
before · pallets/refungible/src/erc.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//! # Refungible Pallet EVM API for tokens18//!19//! Provides ERC-721 standart support implementation and EVM API for unique extensions for Refungible Pallet.20//! Method implementations are mostly doing parameter conversion and calling Refungible Pallet methods.2122extern crate alloc;2324use alloc::string::ToString;25use core::{26	char::{REPLACEMENT_CHARACTER, decode_utf16},27	convert::TryInto,28};29use evm_coder::{abi::AbiType, AbiCoder, ToLog, generate_stubgen, solidity_interface, types::*};30use frame_support::{BoundedBTreeMap, BoundedVec};31use pallet_common::{32	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,33	Error as CommonError,34	erc::{CommonEvmHandler, CollectionCall, static_property::key},35	eth::{self, TokenUri},36};37use pallet_evm::{account::CrossAccountId, PrecompileHandle};38use pallet_evm_coder_substrate::{39	call, dispatch_to_evm,40	execution::{PreDispatch, Result, Error},41	frontier_contract,42};43use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};44use sp_core::{H160, U256, Get};45use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};46use up_data_structs::{47	CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,48	PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,49};5051use crate::{52	AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, TokenProperties,53	TokensMinted, TotalSupply, SelfWeightOf, weights::WeightInfo,54};5556frontier_contract! {57	macro_rules! RefungibleHandle_result {...}58	impl<T: Config> Contract for RefungibleHandle<T> {...}59}6061pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);6263/// Rft events.64#[derive(ToLog)]65pub enum ERC721TokenEvent {66	/// The token has been changed.67	TokenChanged {68		/// Token ID.69		#[indexed]70		token_id: U256,71	},72}7374/// Token minting parameters75#[derive(AbiCoder, Default, Debug)]76pub struct OwnerPieces {77	/// Minted token owner78	pub owner: eth::CrossAddress,79	/// Number of token pieces80	pub pieces: u128,81}8283/// Token minting parameters84#[derive(AbiCoder, Default, Debug)]85pub struct MintTokenData {86	/// Minted token owner and number of pieces87	pub owners: Vec<OwnerPieces>,88	/// Minted token properties89	pub properties: Vec<eth::Property>,90}9192/// @title A contract that allows to set and delete token properties and change token property permissions.93#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]94impl<T: Config> RefungibleHandle<T> {95	/// @notice Set permissions for token property.96	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.97	/// @param key Property key.98	/// @param isMutable Permission to mutate property.99	/// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.100	/// @param tokenOwner Permission to mutate property by token owner if property is mutable.101	#[solidity(hide)]102	#[weight(<SelfWeightOf<T>>::set_token_property_permissions(1))]103	fn set_token_property_permission(104		&mut self,105		caller: Caller,106		key: String,107		is_mutable: bool,108		collection_admin: bool,109		token_owner: bool,110	) -> Result<()> {111		let caller = T::CrossAccountId::from_eth(caller);112		<Pallet<T>>::set_token_property_permissions(113			self,114			&caller,115			vec![PropertyKeyPermission {116				key: <Vec<u8>>::from(key)117					.try_into()118					.map_err(|_| "too long key")?,119				permission: PropertyPermission {120					mutable: is_mutable,121					collection_admin,122					token_owner,123				},124			}],125		)126		.map_err(dispatch_to_evm::<T>)127	}128129	/// @notice Set permissions for token property.130	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.131	/// @param permissions Permissions for keys.132	#[weight(<SelfWeightOf<T>>::set_token_property_permissions(permissions.len() as u32))]133	fn set_token_property_permissions(134		&mut self,135		caller: Caller,136		permissions: Vec<eth::TokenPropertyPermission>,137	) -> Result<()> {138		let caller = T::CrossAccountId::from_eth(caller);139		let perms = eth::TokenPropertyPermission::into_property_key_permissions(permissions)?;140141		<Pallet<T>>::set_token_property_permissions(self, &caller, perms)142			.map_err(dispatch_to_evm::<T>)143	}144145	/// @notice Get permissions for token properties.146	fn token_property_permissions(&self) -> Result<Vec<eth::TokenPropertyPermission>> {147		let perms = <Pallet<T>>::token_property_permission(self.id);148		Ok(perms149			.into_iter()150			.map(eth::TokenPropertyPermission::from)151			.collect())152	}153154	/// @notice Set token property value.155	/// @dev Throws error if `msg.sender` has no permission to edit the property.156	/// @param tokenId ID of the token.157	/// @param key Property key.158	/// @param value Property value.159	#[solidity(hide)]160	#[weight(<SelfWeightOf<T>>::set_token_properties(1))]161	fn set_property(162		&mut self,163		caller: Caller,164		token_id: U256,165		key: String,166		value: Bytes,167	) -> Result<()> {168		let caller = T::CrossAccountId::from_eth(caller);169		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;170		let key = <Vec<u8>>::from(key)171			.try_into()172			.map_err(|_| "key too long")?;173		let value = value.0.try_into().map_err(|_| "value too long")?;174175		let nesting_budget = self176			.recorder177			.weight_calls_budget(<StructureWeight<T>>::find_parent());178179		<Pallet<T>>::set_token_property(180			self,181			&caller,182			TokenId(token_id),183			Property { key, value },184			&nesting_budget,185		)186		.map_err(dispatch_to_evm::<T>)187	}188189	/// @notice Set token properties value.190	/// @dev Throws error if `msg.sender` has no permission to edit the property.191	/// @param tokenId ID of the token.192	/// @param properties settable properties193	#[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]194	fn set_properties(195		&mut self,196		caller: Caller,197		token_id: U256,198		properties: Vec<eth::Property>,199	) -> Result<()> {200		let caller = T::CrossAccountId::from_eth(caller);201		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;202203		let nesting_budget = self204			.recorder205			.weight_calls_budget(<StructureWeight<T>>::find_parent());206207		let properties = properties208			.into_iter()209			.map(eth::Property::try_into)210			.collect::<Result<Vec<_>>>()?;211212		<Pallet<T>>::set_token_properties(213			self,214			&caller,215			TokenId(token_id),216			properties.into_iter(),217			&nesting_budget,218		)219		.map_err(dispatch_to_evm::<T>)220	}221222	/// @notice Delete token property value.223	/// @dev Throws error if `msg.sender` has no permission to edit the property.224	/// @param tokenId ID of the token.225	/// @param key Property key.226	#[solidity(hide)]227	#[weight(<SelfWeightOf<T>>::delete_token_properties(1))]228	fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {229		let caller = T::CrossAccountId::from_eth(caller);230		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;231		let key = <Vec<u8>>::from(key)232			.try_into()233			.map_err(|_| "key too long")?;234235		let nesting_budget = self236			.recorder237			.weight_calls_budget(<StructureWeight<T>>::find_parent());238239		<Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)240			.map_err(dispatch_to_evm::<T>)241	}242243	/// @notice Delete token properties value.244	/// @dev Throws error if `msg.sender` has no permission to edit the property.245	/// @param tokenId ID of the token.246	/// @param keys Properties key.247	#[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]248	fn delete_properties(249		&mut self,250		token_id: U256,251		caller: Caller,252		keys: Vec<String>,253	) -> Result<()> {254		let caller = T::CrossAccountId::from_eth(caller);255		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;256		let keys = keys257			.into_iter()258			.map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))259			.collect::<Result<Vec<_>>>()?;260261		let nesting_budget = self262			.recorder263			.weight_calls_budget(<StructureWeight<T>>::find_parent());264265		<Pallet<T>>::delete_token_properties(266			self,267			&caller,268			TokenId(token_id),269			keys.into_iter(),270			&nesting_budget,271		)272		.map_err(dispatch_to_evm::<T>)273	}274275	/// @notice Get token property value.276	/// @dev Throws error if key not found277	/// @param tokenId ID of the token.278	/// @param key Property key.279	/// @return Property value bytes280	fn property(&self, token_id: U256, key: String) -> Result<Bytes> {281		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;282		let key = <Vec<u8>>::from(key)283			.try_into()284			.map_err(|_| "key too long")?;285286		let props =287			<TokenProperties<T>>::get((self.id, token_id)).ok_or("token properties not found")?;288		let prop = props.get(&key).ok_or("key not found")?;289290		Ok(prop.to_vec().into())291	}292}293294#[derive(ToLog)]295pub enum ERC721Events {296	/// @dev This event emits when NFTs are created (`from` == 0) and destroyed297	///  (`to` == 0). Exception: during contract creation, any number of RFTs298	///  may be created and assigned without emitting Transfer.299	Transfer {300		#[indexed]301		from: Address,302		#[indexed]303		to: Address,304		#[indexed]305		token_id: U256,306	},307	/// @dev Not supported308	Approval {309		#[indexed]310		owner: Address,311		#[indexed]312		approved: Address,313		#[indexed]314		token_id: U256,315	},316	/// @dev Not supported317	#[allow(dead_code)]318	ApprovalForAll {319		#[indexed]320		owner: Address,321		#[indexed]322		operator: Address,323		approved: bool,324	},325}326327/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension328/// @dev See https://eips.ethereum.org/EIPS/eip-721329#[solidity_interface(name = ERC721Metadata, enum(derive(PreDispatch)), expect_selector = 0x5b5e139f)]330impl<T: Config> RefungibleHandle<T>331where332	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,333{334	/// @notice A descriptive name for a collection of NFTs in this contract335	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`336	#[solidity(hide, rename_selector = "name")]337	fn name_proxy(&self) -> Result<String> {338		self.name()339	}340341	/// @notice An abbreviated name for NFTs in this contract342	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`343	#[solidity(hide, rename_selector = "symbol")]344	fn symbol_proxy(&self) -> Result<String> {345		self.symbol()346	}347348	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.349	///350	/// @dev If the token has a `url` property and it is not empty, it is returned.351	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.352	///  If the collection property `baseURI` is empty or absent, return "" (empty string)353	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix354	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).355	///356	/// @return token's const_metadata357	#[solidity(rename_selector = "tokenURI")]358	fn token_uri(&self, token_id: U256) -> Result<String> {359		let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;360361		match get_token_property(self, token_id_u32, &key::url()).as_deref() {362			Err(_) | Ok("") => (),363			Ok(url) => {364				return Ok(url.into());365			}366		};367368		let base_uri =369			pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())370				.map(BoundedVec::into_inner)371				.map(String::from_utf8)372				.transpose()373				.map_err(|e| {374					Error::Revert(alloc::format!(375						"can not convert value \"baseURI\" to string with error \"{e}\""376					))377				})?;378379		let base_uri = match base_uri.as_deref() {380			None | Some("") => {381				return Ok("".into());382			}383			Some(base_uri) => base_uri.into(),384		};385386		Ok(387			match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {388				Err(_) | Ok("") => base_uri,389				Ok(suffix) => base_uri + suffix,390			},391		)392	}393}394395/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension396/// @dev See https://eips.ethereum.org/EIPS/eip-721397#[solidity_interface(name = ERC721Enumerable, enum(derive(PreDispatch)), expect_selector = 0x780e9d63)]398impl<T: Config> RefungibleHandle<T> {399	/// @notice Enumerate valid RFTs400	/// @param index A counter less than `totalSupply()`401	/// @return The token identifier for the `index`th NFT,402	///  (sort order not specified)403	fn token_by_index(&self, index: U256) -> U256 {404		index405	}406407	/// Not implemented408	fn token_of_owner_by_index(&self, _owner: Address, _index: U256) -> Result<U256> {409		// TODO: Not implemetable410		Err("not implemented".into())411	}412413	/// @notice Count RFTs tracked by this contract414	/// @return A count of valid RFTs tracked by this contract, where each one of415	///  them has an assigned and queryable owner not equal to the zero address416	fn total_supply(&self) -> Result<U256> {417		self.consume_store_reads(1)?;418		Ok(<Pallet<T>>::total_supply(self).into())419	}420}421422/// @title ERC-721 Non-Fungible Token Standard423/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md424#[solidity_interface(name = ERC721, events(ERC721Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x80ac58cd)]425impl<T: Config> RefungibleHandle<T> {426	/// @notice Count all RFTs assigned to an owner427	/// @dev RFTs assigned to the zero address are considered invalid, and this428	///  function throws for queries about the zero address.429	/// @param owner An address for whom to query the balance430	/// @return The number of RFTs owned by `owner`, possibly zero431	fn balance_of(&self, owner: Address) -> Result<U256> {432		self.consume_store_reads(1)?;433		let owner = T::CrossAccountId::from_eth(owner);434		let balance = <AccountBalance<T>>::get((self.id, owner));435		Ok(balance.into())436	}437438	/// @notice Find the owner of an RFT439	/// @dev RFTs assigned to zero address are considered invalid, and queries440	///  about them do throw.441	///  Returns special 0xffffffffffffffffffffffffffffffffffffffff address for442	///  the tokens that are partially owned.443	/// @param tokenId The identifier for an RFT444	/// @return The address of the owner of the RFT445	fn owner_of(&self, token_id: U256) -> Result<Address> {446		self.consume_store_reads(2)?;447		let token = token_id.try_into()?;448		let owner = <Pallet<T>>::token_owner(self.id, token);449		owner450			.map(|address| *address.as_eth())451			.or_else(|err| match err {452				TokenOwnerError::NotFound => Err(Error::Revert("token not found".into())),453				TokenOwnerError::MultipleOwners => Ok(ADDRESS_FOR_PARTIALLY_OWNED_TOKENS),454			})455	}456457	/// @dev Not implemented458	#[solidity(rename_selector = "safeTransferFrom")]459	fn safe_transfer_from_with_data(460		&mut self,461		_from: Address,462		_to: Address,463		_token_id: U256,464		_data: Bytes,465	) -> Result<()> {466		// TODO: Not implemetable467		Err("not implemented".into())468	}469470	/// @dev Not implemented471	#[solidity(rename_selector = "safeTransferFrom")]472	fn safe_transfer_from(&mut self, _from: Address, _to: Address, _token_id: U256) -> Result<()> {473		// TODO: Not implemetable474		Err("not implemented".into())475	}476477	/// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE478	///  TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE479	///  THEY MAY BE PERMANENTLY LOST480	/// @dev Throws unless `msg.sender` is the current owner or an authorized481	///  operator for this RFT. Throws if `from` is not the current owner. Throws482	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.483	///  Throws if RFT pieces have multiple owners.484	/// @param from The current owner of the NFT485	/// @param to The new owner486	/// @param tokenId The NFT to transfer487	#[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]488	fn transfer_from(489		&mut self,490		caller: Caller,491		from: Address,492		to: Address,493		token_id: U256,494	) -> Result<()> {495		let caller = T::CrossAccountId::from_eth(caller);496		let from = T::CrossAccountId::from_eth(from);497		let to = T::CrossAccountId::from_eth(to);498		let token = token_id.try_into()?;499		let budget = self500			.recorder501			.weight_calls_budget(<StructureWeight<T>>::find_parent());502503		let balance = balance(self, token, &from)?;504		ensure_single_owner(self, token, balance)?;505506		<Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)507			.map_err(dispatch_to_evm::<T>)?;508509		Ok(())510	}511512	/// @dev Not implemented513	fn approve(&mut self, _caller: Caller, _approved: Address, _token_id: U256) -> Result<()> {514		Err("not implemented".into())515	}516517	/// @notice Sets or unsets the approval of a given operator.518	///  The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.519	/// @param operator Operator520	/// @param approved Should operator status be granted or revoked?521	#[weight(<SelfWeightOf<T>>::set_allowance_for_all())]522	fn set_approval_for_all(523		&mut self,524		caller: Caller,525		operator: Address,526		approved: bool,527	) -> Result<()> {528		let caller = T::CrossAccountId::from_eth(caller);529		let operator = T::CrossAccountId::from_eth(operator);530531		<Pallet<T>>::set_allowance_for_all(self, &caller, &operator, approved)532			.map_err(dispatch_to_evm::<T>)?;533		Ok(())534	}535536	/// @dev Not implemented537	fn get_approved(&self, _token_id: U256) -> Result<Address> {538		// TODO: Not implemetable539		Err("not implemented".into())540	}541542	/// @notice Tells whether the given `owner` approves the `operator`.543	#[weight(<SelfWeightOf<T>>::allowance_for_all())]544	fn is_approved_for_all(&self, owner: Address, operator: Address) -> Result<bool> {545		let owner = T::CrossAccountId::from_eth(owner);546		let operator = T::CrossAccountId::from_eth(operator);547548		Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))549	}550}551552/// Returns amount of pieces of `token` that `owner` have553pub fn balance<T: Config>(554	collection: &RefungibleHandle<T>,555	token: TokenId,556	owner: &T::CrossAccountId,557) -> Result<u128> {558	collection.consume_store_reads(1)?;559	let balance = <Balance<T>>::get((collection.id, token, &owner));560	Ok(balance)561}562563/// Throws if `owner_balance` is lower than total amount of `token` pieces564pub fn ensure_single_owner<T: Config>(565	collection: &RefungibleHandle<T>,566	token: TokenId,567	owner_balance: u128,568) -> Result<()> {569	collection.consume_store_reads(1)?;570	let total_supply = <TotalSupply<T>>::get((collection.id, token));571572	if owner_balance == 0 {573		return Err(dispatch_to_evm::<T>(574			<CommonError<T>>::MustBeTokenOwner.into(),575		));576	}577578	if total_supply != owner_balance {579		return Err("token has multiple owners".into());580	}581	Ok(())582}583584/// @title ERC721 Token that can be irreversibly burned (destroyed).585#[solidity_interface(name = ERC721Burnable, enum(derive(PreDispatch)), enum_attr(weight))]586impl<T: Config> RefungibleHandle<T> {587	/// @notice Burns a specific ERC721 token.588	/// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized589	///  operator of the current owner.590	/// @param tokenId The RFT to approve591	#[weight(<SelfWeightOf<T>>::burn_item_fully())]592	fn burn(&mut self, caller: Caller, token_id: U256) -> Result<()> {593		let caller = T::CrossAccountId::from_eth(caller);594		let token = token_id.try_into()?;595596		let balance = balance(self, token, &caller)?;597		ensure_single_owner(self, token, balance)?;598599		<Pallet<T>>::burn(self, &caller, token, balance).map_err(dispatch_to_evm::<T>)?;600		Ok(())601	}602}603604/// @title ERC721 minting logic.605#[solidity_interface(name = ERC721UniqueMintable, enum(derive(PreDispatch)), enum_attr(weight))]606impl<T: Config> RefungibleHandle<T> {607	/// @notice Function to mint a token.608	/// @param to The new owner609	/// @return uint256 The id of the newly minted token610	#[weight(<SelfWeightOf<T>>::create_item())]611	fn mint(&mut self, caller: Caller, to: Address) -> Result<U256> {612		let token_id: U256 = <TokensMinted<T>>::get(self.id)613			.checked_add(1)614			.ok_or("item id overflow")?615			.into();616		self.mint_check_id(caller, to, token_id)?;617		Ok(token_id)618	}619620	/// @notice Function to mint a token.621	/// @dev `tokenId` should be obtained with `nextTokenId` method,622	///  unlike standard, you can't specify it manually623	/// @param to The new owner624	/// @param tokenId ID of the minted RFT625	#[solidity(hide, rename_selector = "mint")]626	#[weight(<SelfWeightOf<T>>::create_item())]627	fn mint_check_id(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<bool> {628		let caller = T::CrossAccountId::from_eth(caller);629		let to = T::CrossAccountId::from_eth(to);630		let token_id: u32 = token_id.try_into()?;631		let budget = self632			.recorder633			.weight_calls_budget(<StructureWeight<T>>::find_parent());634635		if <TokensMinted<T>>::get(self.id)636			.checked_add(1)637			.ok_or("item id overflow")?638			!= token_id639		{640			return Err("item id should be next".into());641		}642643		let users = [(to, 1)]644			.into_iter()645			.collect::<BTreeMap<_, _>>()646			.try_into()647			.unwrap();648		<Pallet<T>>::create_item(649			self,650			&caller,651			CreateItemData::<T> {652				users,653				properties: CollectionPropertiesVec::default(),654			},655			&budget,656		)657		.map_err(dispatch_to_evm::<T>)?;658659		Ok(true)660	}661662	/// @notice Function to mint token with the given tokenUri.663	/// @param to The new owner664	/// @param tokenUri Token URI that would be stored in the NFT properties665	/// @return uint256 The id of the newly minted token666	#[solidity(rename_selector = "mintWithTokenURI")]667	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]668	fn mint_with_token_uri(669		&mut self,670		caller: Caller,671		to: Address,672		token_uri: String,673	) -> Result<U256> {674		let token_id: U256 = <TokensMinted<T>>::get(self.id)675			.checked_add(1)676			.ok_or("item id overflow")?677			.into();678		self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;679		Ok(token_id)680	}681682	/// @notice Function to mint token with the given tokenUri.683	/// @dev `tokenId` should be obtained with `nextTokenId` method,684	///  unlike standard, you can't specify it manually685	/// @param to The new owner686	/// @param tokenId ID of the minted RFT687	/// @param tokenUri Token URI that would be stored in the RFT properties688	#[solidity(hide, rename_selector = "mintWithTokenURI")]689	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]690	fn mint_with_token_uri_check_id(691		&mut self,692		caller: Caller,693		to: Address,694		token_id: U256,695		token_uri: String,696	) -> Result<bool> {697		let key = key::url();698		let permission = get_token_permission::<T>(self.id, &key)?;699		if !permission.collection_admin {700			return Err("operation is not allowed".into());701		}702703		let caller = T::CrossAccountId::from_eth(caller);704		let to = T::CrossAccountId::from_eth(to);705		let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;706		let budget = self707			.recorder708			.weight_calls_budget(<StructureWeight<T>>::find_parent());709710		if <TokensMinted<T>>::get(self.id)711			.checked_add(1)712			.ok_or("item id overflow")?713			!= token_id714		{715			return Err("item id should be next".into());716		}717718		let mut properties = CollectionPropertiesVec::default();719		properties720			.try_push(Property {721				key,722				value: token_uri723					.into_bytes()724					.try_into()725					.map_err(|_| "token uri is too long")?,726			})727			.map_err(|e| Error::Revert(alloc::format!("can't add property: {e:?}")))?;728729		let users = [(to, 1)]730			.into_iter()731			.collect::<BTreeMap<_, _>>()732			.try_into()733			.unwrap();734		<Pallet<T>>::create_item(735			self,736			&caller,737			CreateItemData::<T> { users, properties },738			&budget,739		)740		.map_err(dispatch_to_evm::<T>)?;741		Ok(true)742	}743}744745fn get_token_property<T: Config>(746	collection: &CollectionHandle<T>,747	token_id: u32,748	key: &up_data_structs::PropertyKey,749) -> Result<String> {750	collection.consume_store_reads(1)?;751	let properties = <TokenProperties<T>>::try_get((collection.id, token_id))752		.map_err(|_| Error::Revert("token properties not found".into()))?;753	if let Some(property) = properties.get(key) {754		return Ok(String::from_utf8_lossy(property).into());755	}756757	Err("property tokenURI not found".into())758}759760fn get_token_permission<T: Config>(761	collection_id: CollectionId,762	key: &PropertyKey,763) -> Result<PropertyPermission> {764	let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)765		.map_err(|_| Error::Revert("no permissions for collection".into()))?;766	let a = token_property_permissions767		.get(key)768		.map(Clone::clone)769		.ok_or_else(|| {770			let key = String::from_utf8(key.clone().into_inner()).unwrap_or_default();771			Error::Revert(alloc::format!("no permission for key {key}"))772		})?;773	Ok(a)774}775776/// @title Unique extensions for ERC721.777#[solidity_interface(name = ERC721UniqueExtensions, enum(derive(PreDispatch)), enum_attr(weight))]778impl<T: Config> RefungibleHandle<T>779where780	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,781{782	/// @notice A descriptive name for a collection of NFTs in this contract783	fn name(&self) -> Result<String> {784		Ok(decode_utf16(self.name.iter().copied())785			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))786			.collect::<String>())787	}788789	/// @notice An abbreviated name for NFTs in this contract790	fn symbol(&self) -> Result<String> {791		Ok(String::from_utf8_lossy(&self.token_prefix).into())792	}793794	/// @notice A description for the collection.795	fn description(&self) -> Result<String> {796		Ok(decode_utf16(self.description.iter().copied())797			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))798			.collect::<String>())799	}800801	/// Returns the owner (in cross format) of the token.802	///803	/// @param tokenId Id for the token.804	#[solidity(hide)]805	fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {806		Self::owner_of_cross(self, token_id)807	}808809	/// Returns the owner (in cross format) of the token.810	///811	/// @param tokenId Id for the token.812	fn owner_of_cross(&self, token_id: U256) -> Result<eth::CrossAddress> {813		Self::token_owner(self, token_id.try_into()?)814			.map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))815			.or_else(|err| match err {816				TokenOwnerError::NotFound => Err(Error::Revert("token not found".into())),817				TokenOwnerError::MultipleOwners => Ok(eth::CrossAddress::from_eth(818					ADDRESS_FOR_PARTIALLY_OWNED_TOKENS,819				)),820			})821	}822823	/// @notice Count all RFTs assigned to an owner824	/// @param owner An cross address for whom to query the balance825	/// @return The number of RFTs owned by `owner`, possibly zero826	fn balance_of_cross(&self, owner: eth::CrossAddress) -> Result<U256> {827		self.consume_store_reads(1)?;828		let balance = <AccountBalance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));829		Ok(balance.into())830	}831832	/// Returns the token properties.833	///834	/// @param tokenId Id for the token.835	/// @param keys Properties keys. Empty keys for all propertyes.836	/// @return Vector of properties key/value pairs.837	fn properties(&self, token_id: U256, keys: Vec<String>) -> Result<Vec<eth::Property>> {838		let keys = keys839			.into_iter()840			.map(|key| {841				<Vec<u8>>::from(key)842					.try_into()843					.map_err(|_| Error::Revert("key too large".into()))844			})845			.collect::<Result<Vec<_>>>()?;846847		<Self as CommonCollectionOperations<T>>::token_properties(848			self,849			token_id.try_into()?,850			if keys.is_empty() { None } else { Some(keys) },851		)852		.into_iter()853		.map(eth::Property::try_from)854		.collect::<Result<Vec<_>>>()855	}856	/// @notice Transfer ownership of an RFT857	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`858	///  is the zero address. Throws if `tokenId` is not a valid RFT.859	///  Throws if RFT pieces have multiple owners.860	/// @param to The new owner861	/// @param tokenId The RFT to transfer862	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]863	fn transfer(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<()> {864		let caller = T::CrossAccountId::from_eth(caller);865		let to = T::CrossAccountId::from_eth(to);866		let token = token_id.try_into()?;867		let budget = self868			.recorder869			.weight_calls_budget(<StructureWeight<T>>::find_parent());870871		let balance = balance(self, token, &caller)?;872		ensure_single_owner(self, token, balance)?;873874		<Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)875			.map_err(dispatch_to_evm::<T>)?;876		Ok(())877	}878879	/// @notice Transfer ownership of an RFT880	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`881	///  is the zero address. Throws if `tokenId` is not a valid RFT.882	///  Throws if RFT pieces have multiple owners.883	/// @param to The new owner884	/// @param tokenId The RFT to transfer885	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]886	fn transfer_cross(887		&mut self,888		caller: Caller,889		to: eth::CrossAddress,890		token_id: U256,891	) -> Result<()> {892		let caller = T::CrossAccountId::from_eth(caller);893		let to = to.into_sub_cross_account::<T>()?;894		let token = token_id.try_into()?;895		let budget = self896			.recorder897			.weight_calls_budget(<StructureWeight<T>>::find_parent());898899		let balance = balance(self, token, &caller)?;900		ensure_single_owner(self, token, balance)?;901902		<Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)903			.map_err(dispatch_to_evm::<T>)?;904		Ok(())905	}906907	/// @notice Transfer ownership of an RFT908	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`909	///  is the zero address. Throws if `tokenId` is not a valid RFT.910	///  Throws if RFT pieces have multiple owners.911	/// @param to The new owner912	/// @param tokenId The RFT to transfer913	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]914	fn transfer_from_cross(915		&mut self,916		caller: Caller,917		from: eth::CrossAddress,918		to: eth::CrossAddress,919		token_id: U256,920	) -> Result<()> {921		let caller = T::CrossAccountId::from_eth(caller);922		let from = from.into_sub_cross_account::<T>()?;923		let to = to.into_sub_cross_account::<T>()?;924		let token_id = token_id.try_into()?;925		let budget = self926			.recorder927			.weight_calls_budget(<StructureWeight<T>>::find_parent());928929		let balance = balance(self, token_id, &from)?;930		ensure_single_owner(self, token_id, balance)?;931932		Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)933			.map_err(dispatch_to_evm::<T>)?;934		Ok(())935	}936937	/// @notice Burns a specific ERC721 token.938	/// @dev Throws unless `msg.sender` is the current owner or an authorized939	///  operator for this RFT. Throws if `from` is not the current owner. Throws940	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.941	///  Throws if RFT pieces have multiple owners.942	/// @param from The current owner of the RFT943	/// @param tokenId The RFT to transfer944	#[solidity(hide)]945	#[weight(<SelfWeightOf<T>>::burn_from())]946	fn burn_from(&mut self, caller: Caller, from: Address, token_id: U256) -> Result<()> {947		let caller = T::CrossAccountId::from_eth(caller);948		let from = T::CrossAccountId::from_eth(from);949		let token = token_id.try_into()?;950		let budget = self951			.recorder952			.weight_calls_budget(<StructureWeight<T>>::find_parent());953954		let balance = balance(self, token, &from)?;955		ensure_single_owner(self, token, balance)?;956957		<Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)958			.map_err(dispatch_to_evm::<T>)?;959		Ok(())960	}961962	/// @notice Burns a specific ERC721 token.963	/// @dev Throws unless `msg.sender` is the current owner or an authorized964	///  operator for this RFT. Throws if `from` is not the current owner. Throws965	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.966	///  Throws if RFT pieces have multiple owners.967	/// @param from The current owner of the RFT968	/// @param tokenId The RFT to transfer969	#[weight(<SelfWeightOf<T>>::burn_from())]970	fn burn_from_cross(971		&mut self,972		caller: Caller,973		from: eth::CrossAddress,974		token_id: U256,975	) -> Result<()> {976		let caller = T::CrossAccountId::from_eth(caller);977		let from = from.into_sub_cross_account::<T>()?;978		let token = token_id.try_into()?;979		let budget = self980			.recorder981			.weight_calls_budget(<StructureWeight<T>>::find_parent());982983		let balance = balance(self, token, &from)?;984		ensure_single_owner(self, token, balance)?;985986		<Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)987			.map_err(dispatch_to_evm::<T>)?;988		Ok(())989	}990991	/// @notice Returns next free RFT ID.992	fn next_token_id(&self) -> Result<U256> {993		self.consume_store_reads(1)?;994		Ok(<Pallet<T>>::next_token_id(self)995			.map_err(dispatch_to_evm::<T>)?996			.into())997	}998999	/// @notice Function to mint multiple tokens.1000	/// @dev `tokenIds` should be an array of consecutive numbers and first number1001	///  should be obtained with `nextTokenId` method1002	/// @param to The new owner1003	/// @param tokenIds IDs of the minted RFTs1004	#[solidity(hide)]1005	#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]1006	fn mint_bulk(&mut self, caller: Caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {1007		let caller = T::CrossAccountId::from_eth(caller);1008		let to = T::CrossAccountId::from_eth(to);1009		let mut expected_index = <TokensMinted<T>>::get(self.id)1010			.checked_add(1)1011			.ok_or("item id overflow")?;1012		let budget = self1013			.recorder1014			.weight_calls_budget(<StructureWeight<T>>::find_parent());10151016		let total_tokens = token_ids.len();1017		for id in token_ids.into_iter() {1018			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;1019			if id != expected_index {1020				return Err("item id should be next".into());1021			}1022			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;1023		}1024		let users = [(to, 1)]1025			.into_iter()1026			.collect::<BTreeMap<_, _>>()1027			.try_into()1028			.unwrap();1029		let create_item_data = CreateItemData::<T> {1030			users,1031			properties: CollectionPropertiesVec::default(),1032		};1033		let data = (0..total_tokens)1034			.map(|_| create_item_data.clone())1035			.collect();10361037		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)1038			.map_err(dispatch_to_evm::<T>)?;1039		Ok(true)1040	}10411042	/// @notice Function to mint a token.1043	/// @param tokenProperties Properties of minted token1044	#[weight(if token_properties.len() == 1 {1045		<SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(token_properties.iter().next().unwrap().owners.len() as u32)1046	} else {1047		<SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(token_properties.len() as u32)1048	} + <SelfWeightOf<T>>::set_token_properties(token_properties.len() as u32))]1049	fn mint_bulk_cross(1050		&mut self,1051		caller: Caller,1052		token_properties: Vec<MintTokenData>,1053	) -> Result<bool> {1054		let caller = T::CrossAccountId::from_eth(caller);1055		let budget = self1056			.recorder1057			.weight_calls_budget(<StructureWeight<T>>::find_parent());1058		let has_multiple_tokens = token_properties.len() > 1;10591060		let mut create_rft_data = Vec::with_capacity(token_properties.len());1061		for MintTokenData { owners, properties } in token_properties {1062			let has_multiple_owners = owners.len() > 1;1063			if has_multiple_tokens & has_multiple_owners {1064				return Err(1065					"creation of multiple tokens supported only if they have single owner each"1066						.into(),1067				);1068			}1069			let users: BoundedBTreeMap<_, _, _> = owners1070				.into_iter()1071				.map(|data| Ok((data.owner.into_sub_cross_account::<T>()?, data.pieces)))1072				.collect::<Result<BTreeMap<_, _>>>()?1073				.try_into()1074				.map_err(|_| "too many users")?;1075			create_rft_data.push(CreateItemData::<T> {1076				properties: properties1077					.into_iter()1078					.map(|property| property.try_into())1079					.collect::<Result<Vec<_>>>()?1080					.try_into()1081					.map_err(|_| "too many properties")?,1082				users,1083			});1084		}10851086		<Pallet<T>>::create_multiple_items(self, &caller, create_rft_data, &budget)1087			.map_err(dispatch_to_evm::<T>)?;1088		Ok(true)1089	}10901091	/// @notice Function to mint multiple tokens with the given tokenUris.1092	/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive1093	///  numbers and first number should be obtained with `nextTokenId` method1094	/// @param to The new owner1095	/// @param tokens array of pairs of token ID and token URI for minted tokens1096	#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]1097	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]1098	fn mint_bulk_with_token_uri(1099		&mut self,1100		caller: Caller,1101		to: Address,1102		tokens: Vec<TokenUri>,1103	) -> Result<bool> {1104		let key = key::url();1105		let caller = T::CrossAccountId::from_eth(caller);1106		let to = T::CrossAccountId::from_eth(to);1107		let mut expected_index = <TokensMinted<T>>::get(self.id)1108			.checked_add(1)1109			.ok_or("item id overflow")?;1110		let budget = self1111			.recorder1112			.weight_calls_budget(<StructureWeight<T>>::find_parent());11131114		let mut data = Vec::with_capacity(tokens.len());1115		let users: BoundedBTreeMap<_, _, _> = [(to, 1)]1116			.into_iter()1117			.collect::<BTreeMap<_, _>>()1118			.try_into()1119			.unwrap();1120		for TokenUri { id, uri } in tokens {1121			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;1122			if id != expected_index {1123				return Err("item id should be next".into());1124			}1125			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;11261127			let mut properties = CollectionPropertiesVec::default();1128			properties1129				.try_push(Property {1130					key: key.clone(),1131					value: uri1132						.into_bytes()1133						.try_into()1134						.map_err(|_| "token uri is too long")?,1135				})1136				.map_err(|e| Error::Revert(alloc::format!("can't add property: {e:?}")))?;11371138			let create_item_data = CreateItemData::<T> {1139				users: users.clone(),1140				properties,1141			};1142			data.push(create_item_data);1143		}11441145		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)1146			.map_err(dispatch_to_evm::<T>)?;1147		Ok(true)1148	}11491150	/// @notice Function to mint a token.1151	/// @param to The new owner crossAccountId1152	/// @param properties Properties of minted token1153	/// @return uint256 The id of the newly minted token1154	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]1155	fn mint_cross(1156		&mut self,1157		caller: Caller,1158		to: eth::CrossAddress,1159		properties: Vec<eth::Property>,1160	) -> Result<U256> {1161		let token_id = <TokensMinted<T>>::get(self.id)1162			.checked_add(1)1163			.ok_or("item id overflow")?;11641165		let to = to.into_sub_cross_account::<T>()?;11661167		let properties = properties1168			.into_iter()1169			.map(eth::Property::try_into)1170			.collect::<Result<Vec<_>>>()?1171			.try_into()1172			.map_err(|_| Error::Revert("too many properties".to_string()))?;11731174		let caller = T::CrossAccountId::from_eth(caller);11751176		let budget = self1177			.recorder1178			.weight_calls_budget(<StructureWeight<T>>::find_parent());11791180		let users = [(to, 1)]1181			.into_iter()1182			.collect::<BTreeMap<_, _>>()1183			.try_into()1184			.unwrap();1185		<Pallet<T>>::create_item(1186			self,1187			&caller,1188			CreateItemData::<T> { users, properties },1189			&budget,1190		)1191		.map_err(dispatch_to_evm::<T>)?;11921193		Ok(token_id.into())1194	}11951196	/// Returns EVM address for refungible token1197	///1198	/// @param token ID of the token1199	fn token_contract_address(&self, token: U256) -> Result<Address> {1200		Ok(T::EvmTokenAddressMapping::token_to_address(1201			self.id,1202			token.try_into().map_err(|_| "token id overflow")?,1203		))1204	}12051206	/// @notice Returns collection helper contract address1207	fn collection_helper_address(&self) -> Result<Address> {1208		Ok(T::ContractAddress::get())1209	}1210}12111212#[solidity_interface(1213	name = UniqueRefungible,1214	is(1215		ERC721,1216		ERC721Enumerable,1217		ERC721UniqueExtensions,1218		ERC721UniqueMintable,1219		ERC721Burnable,1220		ERC721Metadata(if(this.flags.erc721metadata)),1221		Collection(via(common_mut returns CollectionHandle<T>)),1222		TokenProperties,1223	),1224	enum(derive(PreDispatch)),1225)]1226impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}12271228// Not a tests, but code generators1229generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);1230generate_stubgen!(gen_iface, UniqueRefungibleCall<()>, false);12311232impl<T: Config> CommonEvmHandler for RefungibleHandle<T>1233where1234	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,1235{1236	const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");1237	fn call(1238		self,1239		handle: &mut impl PrecompileHandle,1240	) -> Option<pallet_common::erc::PrecompileResult> {1241		call::<T, UniqueRefungibleCall<T>, _, _>(handle, self)1242	}1243}
after · pallets/refungible/src/erc.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//! # Refungible Pallet EVM API for tokens18//!19//! Provides ERC-721 standart support implementation and EVM API for unique extensions for Refungible Pallet.20//! Method implementations are mostly doing parameter conversion and calling Refungible Pallet methods.2122extern crate alloc;2324use alloc::string::ToString;25use core::{26	char::{decode_utf16, REPLACEMENT_CHARACTER},27	convert::TryInto,28};2930use evm_coder::{abi::AbiType, generate_stubgen, solidity_interface, types::*, AbiCoder, ToLog};31use frame_support::{BoundedBTreeMap, BoundedVec};32use pallet_common::{33	erc::{static_property::key, CollectionCall, CommonEvmHandler},34	eth::{self, TokenUri},35	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,36	Error as CommonError,37};38use pallet_evm::{account::CrossAccountId, PrecompileHandle};39use pallet_evm_coder_substrate::{40	call, dispatch_to_evm,41	execution::{Error, PreDispatch, Result},42	frontier_contract,43};44use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};45use sp_core::{Get, H160, U256};46use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};47use up_data_structs::{48	mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property, PropertyKey,49	PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,50};5152use crate::{53	weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle,54	SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,55};5657frontier_contract! {58	macro_rules! RefungibleHandle_result {...}59	impl<T: Config> Contract for RefungibleHandle<T> {...}60}6162pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);6364/// Rft events.65#[derive(ToLog)]66pub enum ERC721TokenEvent {67	/// The token has been changed.68	TokenChanged {69		/// Token ID.70		#[indexed]71		token_id: U256,72	},73}7475/// Token minting parameters76#[derive(AbiCoder, Default, Debug)]77pub struct OwnerPieces {78	/// Minted token owner79	pub owner: eth::CrossAddress,80	/// Number of token pieces81	pub pieces: u128,82}8384/// Token minting parameters85#[derive(AbiCoder, Default, Debug)]86pub struct MintTokenData {87	/// Minted token owner and number of pieces88	pub owners: Vec<OwnerPieces>,89	/// Minted token properties90	pub properties: Vec<eth::Property>,91}9293/// @title A contract that allows to set and delete token properties and change token property permissions.94#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]95impl<T: Config> RefungibleHandle<T> {96	/// @notice Set permissions for token property.97	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.98	/// @param key Property key.99	/// @param isMutable Permission to mutate property.100	/// @param collectionAdmin Permission to mutate property by collection admin if property is mutable.101	/// @param tokenOwner Permission to mutate property by token owner if property is mutable.102	#[solidity(hide)]103	#[weight(<SelfWeightOf<T>>::set_token_property_permissions(1))]104	fn set_token_property_permission(105		&mut self,106		caller: Caller,107		key: String,108		is_mutable: bool,109		collection_admin: bool,110		token_owner: bool,111	) -> Result<()> {112		let caller = T::CrossAccountId::from_eth(caller);113		<Pallet<T>>::set_token_property_permissions(114			self,115			&caller,116			vec![PropertyKeyPermission {117				key: <Vec<u8>>::from(key)118					.try_into()119					.map_err(|_| "too long key")?,120				permission: PropertyPermission {121					mutable: is_mutable,122					collection_admin,123					token_owner,124				},125			}],126		)127		.map_err(dispatch_to_evm::<T>)128	}129130	/// @notice Set permissions for token property.131	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.132	/// @param permissions Permissions for keys.133	#[weight(<SelfWeightOf<T>>::set_token_property_permissions(permissions.len() as u32))]134	fn set_token_property_permissions(135		&mut self,136		caller: Caller,137		permissions: Vec<eth::TokenPropertyPermission>,138	) -> Result<()> {139		let caller = T::CrossAccountId::from_eth(caller);140		let perms = eth::TokenPropertyPermission::into_property_key_permissions(permissions)?;141142		<Pallet<T>>::set_token_property_permissions(self, &caller, perms)143			.map_err(dispatch_to_evm::<T>)144	}145146	/// @notice Get permissions for token properties.147	fn token_property_permissions(&self) -> Result<Vec<eth::TokenPropertyPermission>> {148		let perms = <Pallet<T>>::token_property_permission(self.id);149		Ok(perms150			.into_iter()151			.map(eth::TokenPropertyPermission::from)152			.collect())153	}154155	/// @notice Set token property value.156	/// @dev Throws error if `msg.sender` has no permission to edit the property.157	/// @param tokenId ID of the token.158	/// @param key Property key.159	/// @param value Property value.160	#[solidity(hide)]161	#[weight(<SelfWeightOf<T>>::set_token_properties(1))]162	fn set_property(163		&mut self,164		caller: Caller,165		token_id: U256,166		key: String,167		value: Bytes,168	) -> Result<()> {169		let caller = T::CrossAccountId::from_eth(caller);170		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;171		let key = <Vec<u8>>::from(key)172			.try_into()173			.map_err(|_| "key too long")?;174		let value = value.0.try_into().map_err(|_| "value too long")?;175176		let nesting_budget = self177			.recorder178			.weight_calls_budget(<StructureWeight<T>>::find_parent());179180		<Pallet<T>>::set_token_property(181			self,182			&caller,183			TokenId(token_id),184			Property { key, value },185			&nesting_budget,186		)187		.map_err(dispatch_to_evm::<T>)188	}189190	/// @notice Set token properties value.191	/// @dev Throws error if `msg.sender` has no permission to edit the property.192	/// @param tokenId ID of the token.193	/// @param properties settable properties194	#[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]195	fn set_properties(196		&mut self,197		caller: Caller,198		token_id: U256,199		properties: Vec<eth::Property>,200	) -> Result<()> {201		let caller = T::CrossAccountId::from_eth(caller);202		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;203204		let nesting_budget = self205			.recorder206			.weight_calls_budget(<StructureWeight<T>>::find_parent());207208		let properties = properties209			.into_iter()210			.map(eth::Property::try_into)211			.collect::<Result<Vec<_>>>()?;212213		<Pallet<T>>::set_token_properties(214			self,215			&caller,216			TokenId(token_id),217			properties.into_iter(),218			&nesting_budget,219		)220		.map_err(dispatch_to_evm::<T>)221	}222223	/// @notice Delete token property value.224	/// @dev Throws error if `msg.sender` has no permission to edit the property.225	/// @param tokenId ID of the token.226	/// @param key Property key.227	#[solidity(hide)]228	#[weight(<SelfWeightOf<T>>::delete_token_properties(1))]229	fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {230		let caller = T::CrossAccountId::from_eth(caller);231		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;232		let key = <Vec<u8>>::from(key)233			.try_into()234			.map_err(|_| "key too long")?;235236		let nesting_budget = self237			.recorder238			.weight_calls_budget(<StructureWeight<T>>::find_parent());239240		<Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)241			.map_err(dispatch_to_evm::<T>)242	}243244	/// @notice Delete token properties value.245	/// @dev Throws error if `msg.sender` has no permission to edit the property.246	/// @param tokenId ID of the token.247	/// @param keys Properties key.248	#[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]249	fn delete_properties(250		&mut self,251		token_id: U256,252		caller: Caller,253		keys: Vec<String>,254	) -> Result<()> {255		let caller = T::CrossAccountId::from_eth(caller);256		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;257		let keys = keys258			.into_iter()259			.map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))260			.collect::<Result<Vec<_>>>()?;261262		let nesting_budget = self263			.recorder264			.weight_calls_budget(<StructureWeight<T>>::find_parent());265266		<Pallet<T>>::delete_token_properties(267			self,268			&caller,269			TokenId(token_id),270			keys.into_iter(),271			&nesting_budget,272		)273		.map_err(dispatch_to_evm::<T>)274	}275276	/// @notice Get token property value.277	/// @dev Throws error if key not found278	/// @param tokenId ID of the token.279	/// @param key Property key.280	/// @return Property value bytes281	fn property(&self, token_id: U256, key: String) -> Result<Bytes> {282		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;283		let key = <Vec<u8>>::from(key)284			.try_into()285			.map_err(|_| "key too long")?;286287		let props =288			<TokenProperties<T>>::get((self.id, token_id)).ok_or("token properties not found")?;289		let prop = props.get(&key).ok_or("key not found")?;290291		Ok(prop.to_vec().into())292	}293}294295#[derive(ToLog)]296pub enum ERC721Events {297	/// @dev This event emits when NFTs are created (`from` == 0) and destroyed298	///  (`to` == 0). Exception: during contract creation, any number of RFTs299	///  may be created and assigned without emitting Transfer.300	Transfer {301		#[indexed]302		from: Address,303		#[indexed]304		to: Address,305		#[indexed]306		token_id: U256,307	},308	/// @dev Not supported309	Approval {310		#[indexed]311		owner: Address,312		#[indexed]313		approved: Address,314		#[indexed]315		token_id: U256,316	},317	/// @dev Not supported318	#[allow(dead_code)]319	ApprovalForAll {320		#[indexed]321		owner: Address,322		#[indexed]323		operator: Address,324		approved: bool,325	},326}327328/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension329/// @dev See https://eips.ethereum.org/EIPS/eip-721330#[solidity_interface(name = ERC721Metadata, enum(derive(PreDispatch)), expect_selector = 0x5b5e139f)]331impl<T: Config> RefungibleHandle<T>332where333	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,334{335	/// @notice A descriptive name for a collection of NFTs in this contract336	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`337	#[solidity(hide, rename_selector = "name")]338	fn name_proxy(&self) -> Result<String> {339		self.name()340	}341342	/// @notice An abbreviated name for NFTs in this contract343	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`344	#[solidity(hide, rename_selector = "symbol")]345	fn symbol_proxy(&self) -> Result<String> {346		self.symbol()347	}348349	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.350	///351	/// @dev If the token has a `url` property and it is not empty, it is returned.352	///  Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.353	///  If the collection property `baseURI` is empty or absent, return "" (empty string)354	///  otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix355	///  otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).356	///357	/// @return token's const_metadata358	#[solidity(rename_selector = "tokenURI")]359	fn token_uri(&self, token_id: U256) -> Result<String> {360		let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;361362		match get_token_property(self, token_id_u32, &key::url()).as_deref() {363			Err(_) | Ok("") => (),364			Ok(url) => {365				return Ok(url.into());366			}367		};368369		let base_uri =370			pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())371				.map(BoundedVec::into_inner)372				.map(String::from_utf8)373				.transpose()374				.map_err(|e| {375					Error::Revert(alloc::format!(376						"can not convert value \"baseURI\" to string with error \"{e}\""377					))378				})?;379380		let base_uri = match base_uri.as_deref() {381			None | Some("") => {382				return Ok("".into());383			}384			Some(base_uri) => base_uri.into(),385		};386387		Ok(388			match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {389				Err(_) | Ok("") => base_uri,390				Ok(suffix) => base_uri + suffix,391			},392		)393	}394}395396/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension397/// @dev See https://eips.ethereum.org/EIPS/eip-721398#[solidity_interface(name = ERC721Enumerable, enum(derive(PreDispatch)), expect_selector = 0x780e9d63)]399impl<T: Config> RefungibleHandle<T> {400	/// @notice Enumerate valid RFTs401	/// @param index A counter less than `totalSupply()`402	/// @return The token identifier for the `index`th NFT,403	///  (sort order not specified)404	fn token_by_index(&self, index: U256) -> U256 {405		index406	}407408	/// Not implemented409	fn token_of_owner_by_index(&self, _owner: Address, _index: U256) -> Result<U256> {410		// TODO: Not implemetable411		Err("not implemented".into())412	}413414	/// @notice Count RFTs tracked by this contract415	/// @return A count of valid RFTs tracked by this contract, where each one of416	///  them has an assigned and queryable owner not equal to the zero address417	fn total_supply(&self) -> Result<U256> {418		self.consume_store_reads(1)?;419		Ok(<Pallet<T>>::total_supply(self).into())420	}421}422423/// @title ERC-721 Non-Fungible Token Standard424/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md425#[solidity_interface(name = ERC721, events(ERC721Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x80ac58cd)]426impl<T: Config> RefungibleHandle<T> {427	/// @notice Count all RFTs assigned to an owner428	/// @dev RFTs assigned to the zero address are considered invalid, and this429	///  function throws for queries about the zero address.430	/// @param owner An address for whom to query the balance431	/// @return The number of RFTs owned by `owner`, possibly zero432	fn balance_of(&self, owner: Address) -> Result<U256> {433		self.consume_store_reads(1)?;434		let owner = T::CrossAccountId::from_eth(owner);435		let balance = <AccountBalance<T>>::get((self.id, owner));436		Ok(balance.into())437	}438439	/// @notice Find the owner of an RFT440	/// @dev RFTs assigned to zero address are considered invalid, and queries441	///  about them do throw.442	///  Returns special 0xffffffffffffffffffffffffffffffffffffffff address for443	///  the tokens that are partially owned.444	/// @param tokenId The identifier for an RFT445	/// @return The address of the owner of the RFT446	fn owner_of(&self, token_id: U256) -> Result<Address> {447		self.consume_store_reads(2)?;448		let token = token_id.try_into()?;449		let owner = <Pallet<T>>::token_owner(self.id, token);450		owner451			.map(|address| *address.as_eth())452			.or_else(|err| match err {453				TokenOwnerError::NotFound => Err(Error::Revert("token not found".into())),454				TokenOwnerError::MultipleOwners => Ok(ADDRESS_FOR_PARTIALLY_OWNED_TOKENS),455			})456	}457458	/// @dev Not implemented459	#[solidity(rename_selector = "safeTransferFrom")]460	fn safe_transfer_from_with_data(461		&mut self,462		_from: Address,463		_to: Address,464		_token_id: U256,465		_data: Bytes,466	) -> Result<()> {467		// TODO: Not implemetable468		Err("not implemented".into())469	}470471	/// @dev Not implemented472	#[solidity(rename_selector = "safeTransferFrom")]473	fn safe_transfer_from(&mut self, _from: Address, _to: Address, _token_id: U256) -> Result<()> {474		// TODO: Not implemetable475		Err("not implemented".into())476	}477478	/// @notice Transfer ownership of an RFT -- THE CALLER IS RESPONSIBLE479	///  TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE480	///  THEY MAY BE PERMANENTLY LOST481	/// @dev Throws unless `msg.sender` is the current owner or an authorized482	///  operator for this RFT. Throws if `from` is not the current owner. Throws483	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.484	///  Throws if RFT pieces have multiple owners.485	/// @param from The current owner of the NFT486	/// @param to The new owner487	/// @param tokenId The NFT to transfer488	#[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]489	fn transfer_from(490		&mut self,491		caller: Caller,492		from: Address,493		to: Address,494		token_id: U256,495	) -> Result<()> {496		let caller = T::CrossAccountId::from_eth(caller);497		let from = T::CrossAccountId::from_eth(from);498		let to = T::CrossAccountId::from_eth(to);499		let token = token_id.try_into()?;500		let budget = self501			.recorder502			.weight_calls_budget(<StructureWeight<T>>::find_parent());503504		let balance = balance(self, token, &from)?;505		ensure_single_owner(self, token, balance)?;506507		<Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)508			.map_err(dispatch_to_evm::<T>)?;509510		Ok(())511	}512513	/// @dev Not implemented514	fn approve(&mut self, _caller: Caller, _approved: Address, _token_id: U256) -> Result<()> {515		Err("not implemented".into())516	}517518	/// @notice Sets or unsets the approval of a given operator.519	///  The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.520	/// @param operator Operator521	/// @param approved Should operator status be granted or revoked?522	#[weight(<SelfWeightOf<T>>::set_allowance_for_all())]523	fn set_approval_for_all(524		&mut self,525		caller: Caller,526		operator: Address,527		approved: bool,528	) -> Result<()> {529		let caller = T::CrossAccountId::from_eth(caller);530		let operator = T::CrossAccountId::from_eth(operator);531532		<Pallet<T>>::set_allowance_for_all(self, &caller, &operator, approved)533			.map_err(dispatch_to_evm::<T>)?;534		Ok(())535	}536537	/// @dev Not implemented538	fn get_approved(&self, _token_id: U256) -> Result<Address> {539		// TODO: Not implemetable540		Err("not implemented".into())541	}542543	/// @notice Tells whether the given `owner` approves the `operator`.544	#[weight(<SelfWeightOf<T>>::allowance_for_all())]545	fn is_approved_for_all(&self, owner: Address, operator: Address) -> Result<bool> {546		let owner = T::CrossAccountId::from_eth(owner);547		let operator = T::CrossAccountId::from_eth(operator);548549		Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))550	}551}552553/// Returns amount of pieces of `token` that `owner` have554pub fn balance<T: Config>(555	collection: &RefungibleHandle<T>,556	token: TokenId,557	owner: &T::CrossAccountId,558) -> Result<u128> {559	collection.consume_store_reads(1)?;560	let balance = <Balance<T>>::get((collection.id, token, &owner));561	Ok(balance)562}563564/// Throws if `owner_balance` is lower than total amount of `token` pieces565pub fn ensure_single_owner<T: Config>(566	collection: &RefungibleHandle<T>,567	token: TokenId,568	owner_balance: u128,569) -> Result<()> {570	collection.consume_store_reads(1)?;571	let total_supply = <TotalSupply<T>>::get((collection.id, token));572573	if owner_balance == 0 {574		return Err(dispatch_to_evm::<T>(575			<CommonError<T>>::MustBeTokenOwner.into(),576		));577	}578579	if total_supply != owner_balance {580		return Err("token has multiple owners".into());581	}582	Ok(())583}584585/// @title ERC721 Token that can be irreversibly burned (destroyed).586#[solidity_interface(name = ERC721Burnable, enum(derive(PreDispatch)), enum_attr(weight))]587impl<T: Config> RefungibleHandle<T> {588	/// @notice Burns a specific ERC721 token.589	/// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized590	///  operator of the current owner.591	/// @param tokenId The RFT to approve592	#[weight(<SelfWeightOf<T>>::burn_item_fully())]593	fn burn(&mut self, caller: Caller, token_id: U256) -> Result<()> {594		let caller = T::CrossAccountId::from_eth(caller);595		let token = token_id.try_into()?;596597		let balance = balance(self, token, &caller)?;598		ensure_single_owner(self, token, balance)?;599600		<Pallet<T>>::burn(self, &caller, token, balance).map_err(dispatch_to_evm::<T>)?;601		Ok(())602	}603}604605/// @title ERC721 minting logic.606#[solidity_interface(name = ERC721UniqueMintable, enum(derive(PreDispatch)), enum_attr(weight))]607impl<T: Config> RefungibleHandle<T> {608	/// @notice Function to mint a token.609	/// @param to The new owner610	/// @return uint256 The id of the newly minted token611	#[weight(<SelfWeightOf<T>>::create_item())]612	fn mint(&mut self, caller: Caller, to: Address) -> Result<U256> {613		let token_id: U256 = <TokensMinted<T>>::get(self.id)614			.checked_add(1)615			.ok_or("item id overflow")?616			.into();617		self.mint_check_id(caller, to, token_id)?;618		Ok(token_id)619	}620621	/// @notice Function to mint a token.622	/// @dev `tokenId` should be obtained with `nextTokenId` method,623	///  unlike standard, you can't specify it manually624	/// @param to The new owner625	/// @param tokenId ID of the minted RFT626	#[solidity(hide, rename_selector = "mint")]627	#[weight(<SelfWeightOf<T>>::create_item())]628	fn mint_check_id(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<bool> {629		let caller = T::CrossAccountId::from_eth(caller);630		let to = T::CrossAccountId::from_eth(to);631		let token_id: u32 = token_id.try_into()?;632		let budget = self633			.recorder634			.weight_calls_budget(<StructureWeight<T>>::find_parent());635636		if <TokensMinted<T>>::get(self.id)637			.checked_add(1)638			.ok_or("item id overflow")?639			!= token_id640		{641			return Err("item id should be next".into());642		}643644		let users = [(to, 1)]645			.into_iter()646			.collect::<BTreeMap<_, _>>()647			.try_into()648			.unwrap();649		<Pallet<T>>::create_item(650			self,651			&caller,652			CreateItemData::<T> {653				users,654				properties: CollectionPropertiesVec::default(),655			},656			&budget,657		)658		.map_err(dispatch_to_evm::<T>)?;659660		Ok(true)661	}662663	/// @notice Function to mint token with the given tokenUri.664	/// @param to The new owner665	/// @param tokenUri Token URI that would be stored in the NFT properties666	/// @return uint256 The id of the newly minted token667	#[solidity(rename_selector = "mintWithTokenURI")]668	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]669	fn mint_with_token_uri(670		&mut self,671		caller: Caller,672		to: Address,673		token_uri: String,674	) -> Result<U256> {675		let token_id: U256 = <TokensMinted<T>>::get(self.id)676			.checked_add(1)677			.ok_or("item id overflow")?678			.into();679		self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;680		Ok(token_id)681	}682683	/// @notice Function to mint token with the given tokenUri.684	/// @dev `tokenId` should be obtained with `nextTokenId` method,685	///  unlike standard, you can't specify it manually686	/// @param to The new owner687	/// @param tokenId ID of the minted RFT688	/// @param tokenUri Token URI that would be stored in the RFT properties689	#[solidity(hide, rename_selector = "mintWithTokenURI")]690	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]691	fn mint_with_token_uri_check_id(692		&mut self,693		caller: Caller,694		to: Address,695		token_id: U256,696		token_uri: String,697	) -> Result<bool> {698		let key = key::url();699		let permission = get_token_permission::<T>(self.id, &key)?;700		if !permission.collection_admin {701			return Err("operation is not allowed".into());702		}703704		let caller = T::CrossAccountId::from_eth(caller);705		let to = T::CrossAccountId::from_eth(to);706		let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;707		let budget = self708			.recorder709			.weight_calls_budget(<StructureWeight<T>>::find_parent());710711		if <TokensMinted<T>>::get(self.id)712			.checked_add(1)713			.ok_or("item id overflow")?714			!= token_id715		{716			return Err("item id should be next".into());717		}718719		let mut properties = CollectionPropertiesVec::default();720		properties721			.try_push(Property {722				key,723				value: token_uri724					.into_bytes()725					.try_into()726					.map_err(|_| "token uri is too long")?,727			})728			.map_err(|e| Error::Revert(alloc::format!("can't add property: {e:?}")))?;729730		let users = [(to, 1)]731			.into_iter()732			.collect::<BTreeMap<_, _>>()733			.try_into()734			.unwrap();735		<Pallet<T>>::create_item(736			self,737			&caller,738			CreateItemData::<T> { users, properties },739			&budget,740		)741		.map_err(dispatch_to_evm::<T>)?;742		Ok(true)743	}744}745746fn get_token_property<T: Config>(747	collection: &CollectionHandle<T>,748	token_id: u32,749	key: &up_data_structs::PropertyKey,750) -> Result<String> {751	collection.consume_store_reads(1)?;752	let properties = <TokenProperties<T>>::try_get((collection.id, token_id))753		.map_err(|_| Error::Revert("token properties not found".into()))?;754	if let Some(property) = properties.get(key) {755		return Ok(String::from_utf8_lossy(property).into());756	}757758	Err("property tokenURI not found".into())759}760761fn get_token_permission<T: Config>(762	collection_id: CollectionId,763	key: &PropertyKey,764) -> Result<PropertyPermission> {765	let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)766		.map_err(|_| Error::Revert("no permissions for collection".into()))?;767	let a = token_property_permissions768		.get(key)769		.map(Clone::clone)770		.ok_or_else(|| {771			let key = String::from_utf8(key.clone().into_inner()).unwrap_or_default();772			Error::Revert(alloc::format!("no permission for key {key}"))773		})?;774	Ok(a)775}776777/// @title Unique extensions for ERC721.778#[solidity_interface(name = ERC721UniqueExtensions, enum(derive(PreDispatch)), enum_attr(weight))]779impl<T: Config> RefungibleHandle<T>780where781	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,782{783	/// @notice A descriptive name for a collection of NFTs in this contract784	fn name(&self) -> Result<String> {785		Ok(decode_utf16(self.name.iter().copied())786			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))787			.collect::<String>())788	}789790	/// @notice An abbreviated name for NFTs in this contract791	fn symbol(&self) -> Result<String> {792		Ok(String::from_utf8_lossy(&self.token_prefix).into())793	}794795	/// @notice A description for the collection.796	fn description(&self) -> Result<String> {797		Ok(decode_utf16(self.description.iter().copied())798			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))799			.collect::<String>())800	}801802	/// Returns the owner (in cross format) of the token.803	///804	/// @param tokenId Id for the token.805	#[solidity(hide)]806	fn cross_owner_of(&self, token_id: U256) -> Result<eth::CrossAddress> {807		Self::owner_of_cross(self, token_id)808	}809810	/// Returns the owner (in cross format) of the token.811	///812	/// @param tokenId Id for the token.813	fn owner_of_cross(&self, token_id: U256) -> Result<eth::CrossAddress> {814		Self::token_owner(self, token_id.try_into()?)815			.map(|o| eth::CrossAddress::from_sub_cross_account::<T>(&o))816			.or_else(|err| match err {817				TokenOwnerError::NotFound => Err(Error::Revert("token not found".into())),818				TokenOwnerError::MultipleOwners => Ok(eth::CrossAddress::from_eth(819					ADDRESS_FOR_PARTIALLY_OWNED_TOKENS,820				)),821			})822	}823824	/// @notice Count all RFTs assigned to an owner825	/// @param owner An cross address for whom to query the balance826	/// @return The number of RFTs owned by `owner`, possibly zero827	fn balance_of_cross(&self, owner: eth::CrossAddress) -> Result<U256> {828		self.consume_store_reads(1)?;829		let balance = <AccountBalance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));830		Ok(balance.into())831	}832833	/// Returns the token properties.834	///835	/// @param tokenId Id for the token.836	/// @param keys Properties keys. Empty keys for all propertyes.837	/// @return Vector of properties key/value pairs.838	fn properties(&self, token_id: U256, keys: Vec<String>) -> Result<Vec<eth::Property>> {839		let keys = keys840			.into_iter()841			.map(|key| {842				<Vec<u8>>::from(key)843					.try_into()844					.map_err(|_| Error::Revert("key too large".into()))845			})846			.collect::<Result<Vec<_>>>()?;847848		<Self as CommonCollectionOperations<T>>::token_properties(849			self,850			token_id.try_into()?,851			if keys.is_empty() { None } else { Some(keys) },852		)853		.into_iter()854		.map(eth::Property::try_from)855		.collect::<Result<Vec<_>>>()856	}857	/// @notice Transfer ownership of an RFT858	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`859	///  is the zero address. Throws if `tokenId` is not a valid RFT.860	///  Throws if RFT pieces have multiple owners.861	/// @param to The new owner862	/// @param tokenId The RFT to transfer863	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]864	fn transfer(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<()> {865		let caller = T::CrossAccountId::from_eth(caller);866		let to = T::CrossAccountId::from_eth(to);867		let token = token_id.try_into()?;868		let budget = self869			.recorder870			.weight_calls_budget(<StructureWeight<T>>::find_parent());871872		let balance = balance(self, token, &caller)?;873		ensure_single_owner(self, token, balance)?;874875		<Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)876			.map_err(dispatch_to_evm::<T>)?;877		Ok(())878	}879880	/// @notice Transfer ownership of an RFT881	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`882	///  is the zero address. Throws if `tokenId` is not a valid RFT.883	///  Throws if RFT pieces have multiple owners.884	/// @param to The new owner885	/// @param tokenId The RFT to transfer886	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]887	fn transfer_cross(888		&mut self,889		caller: Caller,890		to: eth::CrossAddress,891		token_id: U256,892	) -> Result<()> {893		let caller = T::CrossAccountId::from_eth(caller);894		let to = to.into_sub_cross_account::<T>()?;895		let token = token_id.try_into()?;896		let budget = self897			.recorder898			.weight_calls_budget(<StructureWeight<T>>::find_parent());899900		let balance = balance(self, token, &caller)?;901		ensure_single_owner(self, token, balance)?;902903		<Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)904			.map_err(dispatch_to_evm::<T>)?;905		Ok(())906	}907908	/// @notice Transfer ownership of an RFT909	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`910	///  is the zero address. Throws if `tokenId` is not a valid RFT.911	///  Throws if RFT pieces have multiple owners.912	/// @param to The new owner913	/// @param tokenId The RFT to transfer914	#[weight(<SelfWeightOf<T>>::transfer_creating_removing())]915	fn transfer_from_cross(916		&mut self,917		caller: Caller,918		from: eth::CrossAddress,919		to: eth::CrossAddress,920		token_id: U256,921	) -> Result<()> {922		let caller = T::CrossAccountId::from_eth(caller);923		let from = from.into_sub_cross_account::<T>()?;924		let to = to.into_sub_cross_account::<T>()?;925		let token_id = token_id.try_into()?;926		let budget = self927			.recorder928			.weight_calls_budget(<StructureWeight<T>>::find_parent());929930		let balance = balance(self, token_id, &from)?;931		ensure_single_owner(self, token_id, balance)?;932933		Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)934			.map_err(dispatch_to_evm::<T>)?;935		Ok(())936	}937938	/// @notice Burns a specific ERC721 token.939	/// @dev Throws unless `msg.sender` is the current owner or an authorized940	///  operator for this RFT. Throws if `from` is not the current owner. Throws941	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.942	///  Throws if RFT pieces have multiple owners.943	/// @param from The current owner of the RFT944	/// @param tokenId The RFT to transfer945	#[solidity(hide)]946	#[weight(<SelfWeightOf<T>>::burn_from())]947	fn burn_from(&mut self, caller: Caller, from: Address, token_id: U256) -> Result<()> {948		let caller = T::CrossAccountId::from_eth(caller);949		let from = T::CrossAccountId::from_eth(from);950		let token = token_id.try_into()?;951		let budget = self952			.recorder953			.weight_calls_budget(<StructureWeight<T>>::find_parent());954955		let balance = balance(self, token, &from)?;956		ensure_single_owner(self, token, balance)?;957958		<Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)959			.map_err(dispatch_to_evm::<T>)?;960		Ok(())961	}962963	/// @notice Burns a specific ERC721 token.964	/// @dev Throws unless `msg.sender` is the current owner or an authorized965	///  operator for this RFT. Throws if `from` is not the current owner. Throws966	///  if `to` is the zero address. Throws if `tokenId` is not a valid RFT.967	///  Throws if RFT pieces have multiple owners.968	/// @param from The current owner of the RFT969	/// @param tokenId The RFT to transfer970	#[weight(<SelfWeightOf<T>>::burn_from())]971	fn burn_from_cross(972		&mut self,973		caller: Caller,974		from: eth::CrossAddress,975		token_id: U256,976	) -> Result<()> {977		let caller = T::CrossAccountId::from_eth(caller);978		let from = from.into_sub_cross_account::<T>()?;979		let token = token_id.try_into()?;980		let budget = self981			.recorder982			.weight_calls_budget(<StructureWeight<T>>::find_parent());983984		let balance = balance(self, token, &from)?;985		ensure_single_owner(self, token, balance)?;986987		<Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)988			.map_err(dispatch_to_evm::<T>)?;989		Ok(())990	}991992	/// @notice Returns next free RFT ID.993	fn next_token_id(&self) -> Result<U256> {994		self.consume_store_reads(1)?;995		Ok(<Pallet<T>>::next_token_id(self)996			.map_err(dispatch_to_evm::<T>)?997			.into())998	}9991000	/// @notice Function to mint multiple tokens.1001	/// @dev `tokenIds` should be an array of consecutive numbers and first number1002	///  should be obtained with `nextTokenId` method1003	/// @param to The new owner1004	/// @param tokenIds IDs of the minted RFTs1005	#[solidity(hide)]1006	#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]1007	fn mint_bulk(&mut self, caller: Caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {1008		let caller = T::CrossAccountId::from_eth(caller);1009		let to = T::CrossAccountId::from_eth(to);1010		let mut expected_index = <TokensMinted<T>>::get(self.id)1011			.checked_add(1)1012			.ok_or("item id overflow")?;1013		let budget = self1014			.recorder1015			.weight_calls_budget(<StructureWeight<T>>::find_parent());10161017		let total_tokens = token_ids.len();1018		for id in token_ids.into_iter() {1019			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;1020			if id != expected_index {1021				return Err("item id should be next".into());1022			}1023			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;1024		}1025		let users = [(to, 1)]1026			.into_iter()1027			.collect::<BTreeMap<_, _>>()1028			.try_into()1029			.unwrap();1030		let create_item_data = CreateItemData::<T> {1031			users,1032			properties: CollectionPropertiesVec::default(),1033		};1034		let data = (0..total_tokens)1035			.map(|_| create_item_data.clone())1036			.collect();10371038		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)1039			.map_err(dispatch_to_evm::<T>)?;1040		Ok(true)1041	}10421043	/// @notice Function to mint a token.1044	/// @param tokenProperties Properties of minted token1045	#[weight(if token_properties.len() == 1 {1046		<SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(token_properties.iter().next().unwrap().owners.len() as u32)1047	} else {1048		<SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(token_properties.len() as u32)1049	} + <SelfWeightOf<T>>::set_token_properties(token_properties.len() as u32))]1050	fn mint_bulk_cross(1051		&mut self,1052		caller: Caller,1053		token_properties: Vec<MintTokenData>,1054	) -> Result<bool> {1055		let caller = T::CrossAccountId::from_eth(caller);1056		let budget = self1057			.recorder1058			.weight_calls_budget(<StructureWeight<T>>::find_parent());1059		let has_multiple_tokens = token_properties.len() > 1;10601061		let mut create_rft_data = Vec::with_capacity(token_properties.len());1062		for MintTokenData { owners, properties } in token_properties {1063			let has_multiple_owners = owners.len() > 1;1064			if has_multiple_tokens & has_multiple_owners {1065				return Err(1066					"creation of multiple tokens supported only if they have single owner each"1067						.into(),1068				);1069			}1070			let users: BoundedBTreeMap<_, _, _> = owners1071				.into_iter()1072				.map(|data| Ok((data.owner.into_sub_cross_account::<T>()?, data.pieces)))1073				.collect::<Result<BTreeMap<_, _>>>()?1074				.try_into()1075				.map_err(|_| "too many users")?;1076			create_rft_data.push(CreateItemData::<T> {1077				properties: properties1078					.into_iter()1079					.map(|property| property.try_into())1080					.collect::<Result<Vec<_>>>()?1081					.try_into()1082					.map_err(|_| "too many properties")?,1083				users,1084			});1085		}10861087		<Pallet<T>>::create_multiple_items(self, &caller, create_rft_data, &budget)1088			.map_err(dispatch_to_evm::<T>)?;1089		Ok(true)1090	}10911092	/// @notice Function to mint multiple tokens with the given tokenUris.1093	/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive1094	///  numbers and first number should be obtained with `nextTokenId` method1095	/// @param to The new owner1096	/// @param tokens array of pairs of token ID and token URI for minted tokens1097	#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]1098	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]1099	fn mint_bulk_with_token_uri(1100		&mut self,1101		caller: Caller,1102		to: Address,1103		tokens: Vec<TokenUri>,1104	) -> Result<bool> {1105		let key = key::url();1106		let caller = T::CrossAccountId::from_eth(caller);1107		let to = T::CrossAccountId::from_eth(to);1108		let mut expected_index = <TokensMinted<T>>::get(self.id)1109			.checked_add(1)1110			.ok_or("item id overflow")?;1111		let budget = self1112			.recorder1113			.weight_calls_budget(<StructureWeight<T>>::find_parent());11141115		let mut data = Vec::with_capacity(tokens.len());1116		let users: BoundedBTreeMap<_, _, _> = [(to, 1)]1117			.into_iter()1118			.collect::<BTreeMap<_, _>>()1119			.try_into()1120			.unwrap();1121		for TokenUri { id, uri } in tokens {1122			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;1123			if id != expected_index {1124				return Err("item id should be next".into());1125			}1126			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;11271128			let mut properties = CollectionPropertiesVec::default();1129			properties1130				.try_push(Property {1131					key: key.clone(),1132					value: uri1133						.into_bytes()1134						.try_into()1135						.map_err(|_| "token uri is too long")?,1136				})1137				.map_err(|e| Error::Revert(alloc::format!("can't add property: {e:?}")))?;11381139			let create_item_data = CreateItemData::<T> {1140				users: users.clone(),1141				properties,1142			};1143			data.push(create_item_data);1144		}11451146		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)1147			.map_err(dispatch_to_evm::<T>)?;1148		Ok(true)1149	}11501151	/// @notice Function to mint a token.1152	/// @param to The new owner crossAccountId1153	/// @param properties Properties of minted token1154	/// @return uint256 The id of the newly minted token1155	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]1156	fn mint_cross(1157		&mut self,1158		caller: Caller,1159		to: eth::CrossAddress,1160		properties: Vec<eth::Property>,1161	) -> Result<U256> {1162		let token_id = <TokensMinted<T>>::get(self.id)1163			.checked_add(1)1164			.ok_or("item id overflow")?;11651166		let to = to.into_sub_cross_account::<T>()?;11671168		let properties = properties1169			.into_iter()1170			.map(eth::Property::try_into)1171			.collect::<Result<Vec<_>>>()?1172			.try_into()1173			.map_err(|_| Error::Revert("too many properties".to_string()))?;11741175		let caller = T::CrossAccountId::from_eth(caller);11761177		let budget = self1178			.recorder1179			.weight_calls_budget(<StructureWeight<T>>::find_parent());11801181		let users = [(to, 1)]1182			.into_iter()1183			.collect::<BTreeMap<_, _>>()1184			.try_into()1185			.unwrap();1186		<Pallet<T>>::create_item(1187			self,1188			&caller,1189			CreateItemData::<T> { users, properties },1190			&budget,1191		)1192		.map_err(dispatch_to_evm::<T>)?;11931194		Ok(token_id.into())1195	}11961197	/// Returns EVM address for refungible token1198	///1199	/// @param token ID of the token1200	fn token_contract_address(&self, token: U256) -> Result<Address> {1201		Ok(T::EvmTokenAddressMapping::token_to_address(1202			self.id,1203			token.try_into().map_err(|_| "token id overflow")?,1204		))1205	}12061207	/// @notice Returns collection helper contract address1208	fn collection_helper_address(&self) -> Result<Address> {1209		Ok(T::ContractAddress::get())1210	}1211}12121213#[solidity_interface(1214	name = UniqueRefungible,1215	is(1216		ERC721,1217		ERC721Enumerable,1218		ERC721UniqueExtensions,1219		ERC721UniqueMintable,1220		ERC721Burnable,1221		ERC721Metadata(if(this.flags.erc721metadata)),1222		Collection(via(common_mut returns CollectionHandle<T>)),1223		TokenProperties,1224	),1225	enum(derive(PreDispatch)),1226)]1227impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}12281229// Not a tests, but code generators1230generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);1231generate_stubgen!(gen_iface, UniqueRefungibleCall<()>, false);12321233impl<T: Config> CommonEvmHandler for RefungibleHandle<T>1234where1235	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,1236{1237	const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");1238	fn call(1239		self,1240		handle: &mut impl PrecompileHandle,1241	) -> Option<pallet_common::erc::PrecompileResult> {1242		call::<T, UniqueRefungibleCall<T>, _, _>(handle, self)1243	}1244}
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]