git.delta.rocks / unique-network / refs/commits / 98884c814ce4

difftreelog

refactor return CrossAccountId in backing storages

Yaroslav Bolyukin2021-11-04parent: #8ccb268.patch.diff
in: master

14 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -75,9 +75,17 @@
 	) -> Result<String>;
 
 	#[rpc(name = "nft_adminlist")]
-	fn adminlist(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<Vec<AccountId>>;
+	fn adminlist(
+		&self,
+		collection: CollectionId,
+		at: Option<BlockHash>,
+	) -> Result<Vec<CrossAccountId>>;
 	#[rpc(name = "nft_allowlist")]
-	fn allowlist(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<Vec<AccountId>>;
+	fn allowlist(
+		&self,
+		collection: CollectionId,
+		at: Option<BlockHash>,
+	) -> Result<Vec<CrossAccountId>>;
 	#[rpc(name = "nft_lastTokenId")]
 	fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;
 }
@@ -150,7 +158,7 @@
 	pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
 	pass_method!(allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
 
-	pass_method!(adminlist(collection: CollectionId) -> Vec<AccountId>);
-	pass_method!(allowlist(collection: CollectionId) -> Vec<AccountId>);
+	pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>);
+	pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>);
 	pass_method!(last_token_id(collection: CollectionId) -> TokenId);
 }
modifiedpallets/common/src/account.rsdiffbeforeafterboth
--- a/pallets/common/src/account.rs
+++ b/pallets/common/src/account.rs
@@ -19,6 +19,8 @@
 
 	fn from_sub(account: AccountId) -> Self;
 	fn from_eth(account: H160) -> Self;
+
+	fn conv_eq(&self, other: &Self) -> bool;
 }
 
 #[derive(Encode, Decode, Serialize, Deserialize, TypeInfo)]
@@ -28,7 +30,7 @@
 	Ethereum(H160),
 }
 
-#[derive(Eq)]
+#[derive(PartialEq, Eq)]
 pub struct BasicCrossAccountId<T: Config> {
 	/// If true - then ethereum is canonical encoding
 	from_ethereum: bool,
@@ -77,18 +79,6 @@
 	}
 }
 
-impl<T: Config> PartialEq for BasicCrossAccountId<T> {
-	fn eq(&self, other: &Self) -> bool {
-		if self.from_ethereum == other.from_ethereum {
-			self.substrate == other.substrate && self.ethereum == other.ethereum
-		} else if self.from_ethereum {
-			// ethereum is canonical encoding, but we need to compare derived address
-			self.substrate == other.substrate
-		} else {
-			self.ethereum == other.ethereum
-		}
-	}
-}
 impl<T: Config> Clone for BasicCrossAccountId<T> {
 	fn clone(&self) -> Self {
 		Self {
@@ -158,6 +148,16 @@
 			from_ethereum: true,
 		}
 	}
+	fn conv_eq(&self, other: &Self) -> bool {
+		if self.from_ethereum == other.from_ethereum {
+			self.substrate == other.substrate && self.ethereum == other.ethereum
+		} else if self.from_ethereum {
+			// ethereum is canonical encoding, but we need to compare derived address
+			self.substrate == other.substrate
+		} else {
+			self.ethereum == other.ethereum
+		}
+	}
 }
 impl<T: Config> From<BasicCrossAccountIdRepr<T::AccountId>> for BasicCrossAccountId<T> {
 	fn from(repr: BasicCrossAccountIdRepr<T::AccountId>) -> Self {
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -98,7 +98,7 @@
 	pub fn is_owner_or_admin(&self, subject: &T::CrossAccountId) -> Result<bool, DispatchError> {
 		self.consume_sload()?;
 
-		Ok(*subject.as_sub() == self.owner || <IsAdmin<T>>::get((self.id, subject.as_sub())))
+		Ok(*subject.as_sub() == self.owner || <IsAdmin<T>>::get((self.id, subject)))
 	}
 	pub fn check_is_owner_or_admin(&self, subject: &T::CrossAccountId) -> DispatchResult {
 		ensure!(self.is_owner_or_admin(subject)?, <Error<T>>::NoPermission);
@@ -114,7 +114,7 @@
 		self.consume_sload()?;
 
 		ensure!(
-			<Allowlist<T>>::get((self.id, user.as_sub())),
+			<Allowlist<T>>::get((self.id, user)),
 			<Error<T>>::AddressNotInAllowlist
 		);
 		Ok(())
@@ -139,8 +139,7 @@
 #[frame_support::pallet]
 pub mod pallet {
 	use super::*;
-	use frame_support::{pallet_prelude::*};
-	use frame_support::{Blake2_128Concat, storage::Key};
+	use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
 	use account::{EvmBackwardsAddressMapping, CrossAccountId};
 	use frame_support::traits::Currency;
 	use nft_data_structs::TokenId;
@@ -311,7 +310,7 @@
 	pub type IsAdmin<T: Config> = StorageNMap<
 		Key = (
 			Key<Blake2_128Concat, CollectionId>,
-			Key<Blake2_128Concat, T::AccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>,
 		),
 		Value = bool,
 		QueryKind = ValueQuery,
@@ -322,7 +321,7 @@
 	pub type Allowlist<T: Config> = StorageNMap<
 		Key = (
 			Key<Blake2_128Concat, CollectionId>,
-			Key<Blake2_128Concat, T::AccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>,
 		),
 		Value = bool,
 		QueryKind = ValueQuery,
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -2,9 +2,7 @@
 
 use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
 use nft_data_structs::TokenId;
-use pallet_common::{
-	CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,
-};
+use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::ArithmeticError;
 use sp_std::{vec::Vec, vec};
 
@@ -188,7 +186,7 @@
 	}
 
 	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
-		if <Balance<T>>::get((self.id, account.as_sub())) != 0 {
+		if <Balance<T>>::get((self.id, account)) != 0 {
 			vec![TokenId::default()]
 		} else {
 			vec![]
@@ -218,7 +216,7 @@
 	}
 
 	fn account_balance(&self, account: T::CrossAccountId) -> u32 {
-		if <Balance<T>>::get((self.id, account.as_sub())) != 0 {
+		if <Balance<T>>::get((self.id, account)) != 0 {
 			1
 		} else {
 			0
@@ -229,7 +227,7 @@
 		if token != TokenId::default() {
 			return 0;
 		}
-		<Balance<T>>::get((self.id, account.as_sub()))
+		<Balance<T>>::get((self.id, account))
 	}
 
 	fn allowance(
@@ -241,6 +239,6 @@
 		if token != TokenId::default() {
 			return 0;
 		}
-		<Allowance<T>>::get((self.id, sender.as_sub(), spender.as_sub()))
+		<Allowance<T>>::get((self.id, sender, spender))
 	}
 }
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -52,7 +52,7 @@
 	}
 	fn balance_of(&self, owner: address) -> Result<uint256> {
 		let owner = T::CrossAccountId::from_eth(owner);
-		let balance = <Balance<T>>::get((self.id, owner.as_sub()));
+		let balance = <Balance<T>>::get((self.id, owner));
 		Ok(balance.into())
 	}
 	fn transfer(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {
@@ -92,7 +92,7 @@
 		let owner = T::CrossAccountId::from_eth(owner);
 		let spender = T::CrossAccountId::from_eth(spender);
 
-		Ok(<Allowance<T>>::get((self.id, owner.as_sub(), spender.as_sub())).into())
+		Ok(<Allowance<T>>::get((self.id, owner, spender)).into())
 	}
 }
 
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
before · pallets/fungible/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23use core::ops::Deref;4use frame_support::{ensure};5use nft_data_structs::{AccessMode, Collection, CollectionId, TokenId};6use pallet_common::{7	Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, account::CrossAccountId,8};9use sp_core::H160;10use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};11use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};1213pub use pallet::*;1415use crate::erc::ERC20Events;16#[cfg(feature = "runtime-benchmarks")]17pub mod benchmarking;18pub mod common;19pub mod erc;20pub mod weights;2122pub type CreateItemData<T> = (<T as pallet_common::Config>::CrossAccountId, u128);23pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;2425#[frame_support::pallet]26pub mod pallet {27	use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};28	use nft_data_structs::CollectionId;29	use super::weights::WeightInfo;3031	#[pallet::error]32	pub enum Error<T> {33		/// Not Fungible item data used to mint in Fungible collection.34		NotFungibleDataUsedToMintFungibleCollectionToken,35		/// Not default id passed as TokenId argument36		FungibleItemsHaveNoId,37		/// Tried to set data for fungible item38		FungibleItemsHaveData,39	}4041	#[pallet::config]42	pub trait Config: frame_system::Config + pallet_common::Config {43		type WeightInfo: WeightInfo;44	}4546	#[pallet::pallet]47	#[pallet::generate_store(pub(super) trait Store)]48	pub struct Pallet<T>(_);4950	#[pallet::storage]51	pub(super) type TotalSupply<T: Config> =52		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u128, QueryKind = ValueQuery>;5354	#[pallet::storage]55	pub(super) type Balance<T: Config> = StorageNMap<56		Key = (57			Key<Twox64Concat, CollectionId>,58			Key<Blake2_128Concat, T::AccountId>,59		),60		Value = u128,61		QueryKind = ValueQuery,62	>;6364	#[pallet::storage]65	pub(super) type Allowance<T: Config> = StorageNMap<66		Key = (67			Key<Twox64Concat, CollectionId>,68			Key<Blake2_128, T::AccountId>,69			Key<Blake2_128Concat, T::AccountId>,70		),71		Value = u128,72		QueryKind = ValueQuery,73	>;74}7576pub struct FungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);77impl<T: Config> FungibleHandle<T> {78	pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {79		Self(inner)80	}81	pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {82		self.083	}84}85impl<T: Config> Deref for FungibleHandle<T> {86	type Target = pallet_common::CollectionHandle<T>;8788	fn deref(&self) -> &Self::Target {89		&self.090	}91}9293impl<T: Config> Pallet<T> {94	pub fn init_collection(data: Collection<T>) -> Result<CollectionId, DispatchError> {95		PalletCommon::init_collection(data)96	}97	pub fn destroy_collection(98		collection: FungibleHandle<T>,99		sender: &T::CrossAccountId,100	) -> DispatchResult {101		let id = collection.id;102103		// =========104105		PalletCommon::destroy_collection(collection.0, sender)?;106107		<TotalSupply<T>>::remove(id);108		<Balance<T>>::remove_prefix((id,), None);109		<Allowance<T>>::remove_prefix((id,), None);110		Ok(())111	}112113	pub fn burn(114		collection: &FungibleHandle<T>,115		owner: &T::CrossAccountId,116		amount: u128,117	) -> DispatchResult {118		let total_supply = <TotalSupply<T>>::get(collection.id)119			.checked_sub(amount)120			.ok_or(<CommonError<T>>::TokenValueTooLow)?;121122		let balance = <Balance<T>>::get((collection.id, owner.as_sub()))123			.checked_sub(amount)124			.ok_or(<CommonError<T>>::TokenValueTooLow)?;125126		if collection.access == AccessMode::WhiteList {127			collection.check_allowlist(owner)?;128		}129130		// =========131132		if balance == 0 {133			<Balance<T>>::remove((collection.id, owner.as_sub()));134		} else {135			<Balance<T>>::insert((collection.id, owner.as_sub()), balance);136		}137		<TotalSupply<T>>::insert(collection.id, total_supply);138139		collection.log_infallible(ERC20Events::Transfer {140			from: *owner.as_eth(),141			to: H160::default(),142			value: amount.into(),143		});144		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(145			collection.id,146			TokenId::default(),147			owner.clone(),148			amount,149		));150		Ok(())151	}152153	pub fn transfer(154		collection: &FungibleHandle<T>,155		from: &T::CrossAccountId,156		to: &T::CrossAccountId,157		amount: u128,158	) -> DispatchResult {159		ensure!(160			collection.limits.transfers_enabled(),161			<CommonError<T>>::TransferNotAllowed,162		);163164		if collection.access == AccessMode::WhiteList {165			collection.check_allowlist(from)?;166			collection.check_allowlist(to)?;167		}168		<PalletCommon<T>>::ensure_correct_receiver(to)?;169170		let balance_from = <Balance<T>>::get((collection.id, from.as_sub()))171			.checked_sub(amount)172			.ok_or(<CommonError<T>>::TokenValueTooLow)?;173		let balance_to = if from != to {174			Some(175				<Balance<T>>::get((collection.id, to.as_sub()))176					.checked_add(amount)177					.ok_or(ArithmeticError::Overflow)?,178			)179		} else {180			None181		};182183		collection.consume_sstore()?;184		collection.consume_sstore()?;185		collection.consume_log(2, 32)?;186		collection.consume_sstore()?;187188		// =========189190		if let Some(balance_to) = balance_to {191			// from != to192			if balance_from == 0 {193				<Balance<T>>::remove((collection.id, from.as_sub()));194			} else {195				<Balance<T>>::insert((collection.id, from.as_sub()), balance_from);196			}197			<Balance<T>>::insert((collection.id, to.as_sub()), balance_to);198		}199200		collection.log_infallible(ERC20Events::Transfer {201			from: *from.as_eth(),202			to: *to.as_eth(),203			value: amount.into(),204		});205		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(206			collection.id,207			TokenId::default(),208			from.clone(),209			to.clone(),210			amount,211		));212		Ok(())213	}214215	pub fn create_multiple_items(216		collection: &FungibleHandle<T>,217		sender: &T::CrossAccountId,218		data: Vec<CreateItemData<T>>,219	) -> DispatchResult {220		let unrestricted_minting = collection.is_owner_or_admin(sender)?;221		if !unrestricted_minting {222			ensure!(223				collection.mint_mode,224				<CommonError<T>>::PublicMintingNotAllowed225			);226			collection.check_allowlist(sender)?;227228			for (owner, _) in data.iter() {229				collection.check_allowlist(owner)?;230			}231		}232233		let mut balances = BTreeMap::new();234235		let total_supply = data236			.iter()237			.map(|u| u.1)238			.try_fold(0u128, |acc, v| acc.checked_add(v))239			.ok_or(ArithmeticError::Overflow)?;240241		for (user, amount) in data.into_iter() {242			collection.consume_sload()?;243			let balance = balances244				.entry(user.clone())245				.or_insert_with(|| <Balance<T>>::get((collection.id, user.as_sub())));246			*balance = (*balance)247				.checked_add(amount)248				.ok_or(ArithmeticError::Overflow)?;249		}250251		collection.consume_sstore()?;252		for _ in &balances {253			collection.consume_sstore()?;254			collection.consume_log(2, 32)?;255			collection.consume_sstore()?;256		}257258		// =========259260		<TotalSupply<T>>::insert(collection.id, total_supply);261		for (user, amount) in balances {262			<Balance<T>>::insert((collection.id, user.as_sub()), amount);263264			collection.log_infallible(ERC20Events::Transfer {265				from: H160::default(),266				to: *user.as_eth(),267				value: amount.into(),268			});269			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(270				collection.id,271				TokenId::default(),272				user.clone(),273				amount,274			));275		}276277		Ok(())278	}279280	fn set_allowance_unchecked(281		collection: &FungibleHandle<T>,282		owner: &T::CrossAccountId,283		spender: &T::CrossAccountId,284		amount: u128,285	) {286		<Allowance<T>>::insert((collection.id, owner.as_sub(), spender.as_sub()), amount);287288		collection.log_infallible(ERC20Events::Approval {289			owner: *owner.as_eth(),290			spender: *spender.as_eth(),291			value: amount.into(),292		});293		<PalletCommon<T>>::deposit_event(CommonEvent::Approved(294			collection.id,295			TokenId(0),296			owner.clone(),297			spender.clone(),298			amount,299		));300	}301302	pub fn set_allowance(303		collection: &FungibleHandle<T>,304		owner: &T::CrossAccountId,305		spender: &T::CrossAccountId,306		amount: u128,307	) -> DispatchResult {308		if collection.access == AccessMode::WhiteList {309			collection.check_allowlist(&owner)?;310			collection.check_allowlist(&spender)?;311		}312313		if <Balance<T>>::get((collection.id, owner.as_sub())) < amount {314			ensure!(315				collection.ignores_owned_amount(owner)?,316				<CommonError<T>>::CantApproveMoreThanOwned317			);318		}319320		// =========321322		Self::set_allowance_unchecked(collection, owner, spender, amount);323		Ok(())324	}325326	pub fn transfer_from(327		collection: &FungibleHandle<T>,328		spender: &T::CrossAccountId,329		from: &T::CrossAccountId,330		to: &T::CrossAccountId,331		amount: u128,332	) -> DispatchResult {333		if spender == from {334			return Self::transfer(collection, from, to, amount);335		}336		if collection.access == AccessMode::WhiteList {337			// `from`, `to` checked in [`transfer`]338			collection.check_allowlist(spender)?;339		}340341		let allowance = <Allowance<T>>::get((collection.id, from.as_sub(), spender.as_sub()))342			.checked_sub(amount);343		if allowance.is_none() {344			ensure!(345				collection.ignores_allowance(spender)?,346				<CommonError<T>>::TokenValueNotEnough347			);348		}349350		// =========351352		Self::transfer(collection, from, to, amount)?;353		if let Some(allowance) = allowance {354			Self::set_allowance_unchecked(collection, from, spender, allowance);355		}356		Ok(())357	}358359	pub fn burn_from(360		collection: &FungibleHandle<T>,361		spender: &T::CrossAccountId,362		from: &T::CrossAccountId,363		amount: u128,364	) -> DispatchResult {365		if spender == from {366			return Self::burn(collection, from, amount);367		}368		if collection.access == AccessMode::WhiteList {369			// `from` checked in [`burn`]370			collection.check_allowlist(spender)?;371		}372373		let allowance = <Allowance<T>>::get((collection.id, from.as_sub(), spender.as_sub()))374			.checked_sub(amount);375		if allowance.is_none() {376			ensure!(377				collection.ignores_allowance(spender)?,378				<CommonError<T>>::TokenValueNotEnough379			);380		}381382		// =========383384		Self::burn(collection, from, amount)?;385		if let Some(allowance) = allowance {386			Self::set_allowance_unchecked(collection, from, spender, allowance);387		}388		Ok(())389	}390391	/// Delegated to `create_multiple_items`392	pub fn create_item(393		collection: &FungibleHandle<T>,394		sender: &T::CrossAccountId,395		data: CreateItemData<T>,396	) -> DispatchResult {397		Self::create_multiple_items(collection, sender, vec![data])398	}399}
after · pallets/fungible/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23use core::ops::Deref;4use frame_support::{ensure};5use nft_data_structs::{AccessMode, Collection, CollectionId, TokenId};6use pallet_common::{7	Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, account::CrossAccountId,8};9use sp_core::H160;10use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};11use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};1213pub use pallet::*;1415use crate::erc::ERC20Events;16#[cfg(feature = "runtime-benchmarks")]17pub mod benchmarking;18pub mod common;19pub mod erc;20pub mod weights;2122pub type CreateItemData<T> = (<T as pallet_common::Config>::CrossAccountId, u128);23pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;2425#[frame_support::pallet]26pub mod pallet {27	use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};28	use nft_data_structs::CollectionId;29	use super::weights::WeightInfo;3031	#[pallet::error]32	pub enum Error<T> {33		/// Not Fungible item data used to mint in Fungible collection.34		NotFungibleDataUsedToMintFungibleCollectionToken,35		/// Not default id passed as TokenId argument36		FungibleItemsHaveNoId,37		/// Tried to set data for fungible item38		FungibleItemsHaveData,39	}4041	#[pallet::config]42	pub trait Config: frame_system::Config + pallet_common::Config {43		type WeightInfo: WeightInfo;44	}4546	#[pallet::pallet]47	#[pallet::generate_store(pub(super) trait Store)]48	pub struct Pallet<T>(_);4950	#[pallet::storage]51	pub(super) type TotalSupply<T: Config> =52		StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u128, QueryKind = ValueQuery>;5354	#[pallet::storage]55	pub(super) type Balance<T: Config> = StorageNMap<56		Key = (57			Key<Twox64Concat, CollectionId>,58			Key<Blake2_128Concat, T::CrossAccountId>,59		),60		Value = u128,61		QueryKind = ValueQuery,62	>;6364	#[pallet::storage]65	pub(super) type Allowance<T: Config> = StorageNMap<66		Key = (67			Key<Twox64Concat, CollectionId>,68			Key<Blake2_128, T::CrossAccountId>,69			Key<Blake2_128Concat, T::CrossAccountId>,70		),71		Value = u128,72		QueryKind = ValueQuery,73	>;74}7576pub struct FungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);77impl<T: Config> FungibleHandle<T> {78	pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {79		Self(inner)80	}81	pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {82		self.083	}84}85impl<T: Config> Deref for FungibleHandle<T> {86	type Target = pallet_common::CollectionHandle<T>;8788	fn deref(&self) -> &Self::Target {89		&self.090	}91}9293impl<T: Config> Pallet<T> {94	pub fn init_collection(data: Collection<T>) -> Result<CollectionId, DispatchError> {95		PalletCommon::init_collection(data)96	}97	pub fn destroy_collection(98		collection: FungibleHandle<T>,99		sender: &T::CrossAccountId,100	) -> DispatchResult {101		let id = collection.id;102103		// =========104105		PalletCommon::destroy_collection(collection.0, sender)?;106107		<TotalSupply<T>>::remove(id);108		<Balance<T>>::remove_prefix((id,), None);109		<Allowance<T>>::remove_prefix((id,), None);110		Ok(())111	}112113	pub fn burn(114		collection: &FungibleHandle<T>,115		owner: &T::CrossAccountId,116		amount: u128,117	) -> DispatchResult {118		let total_supply = <TotalSupply<T>>::get(collection.id)119			.checked_sub(amount)120			.ok_or(<CommonError<T>>::TokenValueTooLow)?;121122		let balance = <Balance<T>>::get((collection.id, owner))123			.checked_sub(amount)124			.ok_or(<CommonError<T>>::TokenValueTooLow)?;125126		if collection.access == AccessMode::WhiteList {127			collection.check_allowlist(owner)?;128		}129130		// =========131132		if balance == 0 {133			<Balance<T>>::remove((collection.id, owner));134		} else {135			<Balance<T>>::insert((collection.id, owner), balance);136		}137		<TotalSupply<T>>::insert(collection.id, total_supply);138139		collection.log_infallible(ERC20Events::Transfer {140			from: *owner.as_eth(),141			to: H160::default(),142			value: amount.into(),143		});144		<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(145			collection.id,146			TokenId::default(),147			owner.clone(),148			amount,149		));150		Ok(())151	}152153	pub fn transfer(154		collection: &FungibleHandle<T>,155		from: &T::CrossAccountId,156		to: &T::CrossAccountId,157		amount: u128,158	) -> DispatchResult {159		ensure!(160			collection.limits.transfers_enabled(),161			<CommonError<T>>::TransferNotAllowed,162		);163164		if collection.access == AccessMode::WhiteList {165			collection.check_allowlist(from)?;166			collection.check_allowlist(to)?;167		}168		<PalletCommon<T>>::ensure_correct_receiver(to)?;169170		let balance_from = <Balance<T>>::get((collection.id, from))171			.checked_sub(amount)172			.ok_or(<CommonError<T>>::TokenValueTooLow)?;173		let balance_to = if from != to {174			Some(175				<Balance<T>>::get((collection.id, to))176					.checked_add(amount)177					.ok_or(ArithmeticError::Overflow)?,178			)179		} else {180			None181		};182183		collection.consume_sstore()?;184		collection.consume_sstore()?;185		collection.consume_log(2, 32)?;186		collection.consume_sstore()?;187188		// =========189190		if let Some(balance_to) = balance_to {191			// from != to192			if balance_from == 0 {193				<Balance<T>>::remove((collection.id, from));194			} else {195				<Balance<T>>::insert((collection.id, from), balance_from);196			}197			<Balance<T>>::insert((collection.id, to), balance_to);198		}199200		collection.log_infallible(ERC20Events::Transfer {201			from: *from.as_eth(),202			to: *to.as_eth(),203			value: amount.into(),204		});205		<PalletCommon<T>>::deposit_event(CommonEvent::Transfer(206			collection.id,207			TokenId::default(),208			from.clone(),209			to.clone(),210			amount,211		));212		Ok(())213	}214215	pub fn create_multiple_items(216		collection: &FungibleHandle<T>,217		sender: &T::CrossAccountId,218		data: Vec<CreateItemData<T>>,219	) -> DispatchResult {220		let unrestricted_minting = collection.is_owner_or_admin(sender)?;221		if !unrestricted_minting {222			ensure!(223				collection.mint_mode,224				<CommonError<T>>::PublicMintingNotAllowed225			);226			collection.check_allowlist(sender)?;227228			for (owner, _) in data.iter() {229				collection.check_allowlist(owner)?;230			}231		}232233		let mut balances = BTreeMap::new();234235		let total_supply = data236			.iter()237			.map(|u| u.1)238			.try_fold(0u128, |acc, v| acc.checked_add(v))239			.ok_or(ArithmeticError::Overflow)?;240241		for (user, amount) in data.into_iter() {242			collection.consume_sload()?;243			let balance = balances244				.entry(user.clone())245				.or_insert_with(|| <Balance<T>>::get((collection.id, user)));246			*balance = (*balance)247				.checked_add(amount)248				.ok_or(ArithmeticError::Overflow)?;249		}250251		collection.consume_sstore()?;252		for _ in &balances {253			collection.consume_sstore()?;254			collection.consume_log(2, 32)?;255			collection.consume_sstore()?;256		}257258		// =========259260		<TotalSupply<T>>::insert(collection.id, total_supply);261		for (user, amount) in balances {262			<Balance<T>>::insert((collection.id, &user), amount);263264			collection.log_infallible(ERC20Events::Transfer {265				from: H160::default(),266				to: *user.as_eth(),267				value: amount.into(),268			});269			<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(270				collection.id,271				TokenId::default(),272				user.clone(),273				amount,274			));275		}276277		Ok(())278	}279280	fn set_allowance_unchecked(281		collection: &FungibleHandle<T>,282		owner: &T::CrossAccountId,283		spender: &T::CrossAccountId,284		amount: u128,285	) {286		<Allowance<T>>::insert((collection.id, owner, spender), amount);287288		collection.log_infallible(ERC20Events::Approval {289			owner: *owner.as_eth(),290			spender: *spender.as_eth(),291			value: amount.into(),292		});293		<PalletCommon<T>>::deposit_event(CommonEvent::Approved(294			collection.id,295			TokenId(0),296			owner.clone(),297			spender.clone(),298			amount,299		));300	}301302	pub fn set_allowance(303		collection: &FungibleHandle<T>,304		owner: &T::CrossAccountId,305		spender: &T::CrossAccountId,306		amount: u128,307	) -> DispatchResult {308		if collection.access == AccessMode::WhiteList {309			collection.check_allowlist(&owner)?;310			collection.check_allowlist(&spender)?;311		}312313		if <Balance<T>>::get((collection.id, owner)) < amount {314			ensure!(315				collection.ignores_owned_amount(owner)?,316				<CommonError<T>>::CantApproveMoreThanOwned317			);318		}319320		// =========321322		Self::set_allowance_unchecked(collection, owner, spender, amount);323		Ok(())324	}325326	pub fn transfer_from(327		collection: &FungibleHandle<T>,328		spender: &T::CrossAccountId,329		from: &T::CrossAccountId,330		to: &T::CrossAccountId,331		amount: u128,332	) -> DispatchResult {333		if spender.conv_eq(from) {334			return Self::transfer(collection, from, to, amount);335		}336		if collection.access == AccessMode::WhiteList {337			// `from`, `to` checked in [`transfer`]338			collection.check_allowlist(spender)?;339		}340341		let allowance = <Allowance<T>>::get((collection.id, from, spender)).checked_sub(amount);342		if allowance.is_none() {343			ensure!(344				collection.ignores_allowance(spender)?,345				<CommonError<T>>::TokenValueNotEnough346			);347		}348349		// =========350351		Self::transfer(collection, from, to, amount)?;352		if let Some(allowance) = allowance {353			Self::set_allowance_unchecked(collection, from, spender, allowance);354		}355		Ok(())356	}357358	pub fn burn_from(359		collection: &FungibleHandle<T>,360		spender: &T::CrossAccountId,361		from: &T::CrossAccountId,362		amount: u128,363	) -> DispatchResult {364		if spender.conv_eq(from) {365			return Self::burn(collection, from, amount);366		}367		if collection.access == AccessMode::WhiteList {368			// `from` checked in [`burn`]369			collection.check_allowlist(spender)?;370		}371372		let allowance = <Allowance<T>>::get((collection.id, from, spender)).checked_sub(amount);373		if allowance.is_none() {374			ensure!(375				collection.ignores_allowance(spender)?,376				<CommonError<T>>::TokenValueNotEnough377			);378		}379380		// =========381382		Self::burn(collection, from, amount)?;383		if let Some(allowance) = allowance {384			Self::set_allowance_unchecked(collection, from, spender, allowance);385		}386		Ok(())387	}388389	/// Delegated to `create_multiple_items`390	pub fn create_item(391		collection: &FungibleHandle<T>,392		sender: &T::CrossAccountId,393		data: CreateItemData<T>,394	) -> DispatchResult {395		Self::create_multiple_items(collection, sender, vec![data])396	}397}
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -948,12 +948,12 @@
 
 // TODO: limit returned entries?
 impl<T: Config> Pallet<T> {
-	pub fn adminlist(collection: CollectionId) -> Vec<T::AccountId> {
+	pub fn adminlist(collection: CollectionId) -> Vec<T::CrossAccountId> {
 		<IsAdmin<T>>::iter_prefix((collection,))
 			.map(|(a, _)| a)
 			.collect()
 	}
-	pub fn allowlist(collection: CollectionId) -> Vec<T::AccountId> {
+	pub fn allowlist(collection: CollectionId) -> Vec<T::CrossAccountId> {
 		<Allowlist<T>>::iter_prefix((collection,))
 			.map(|(a, _)| a)
 			.collect()
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -2,9 +2,7 @@
 
 use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
 use nft_data_structs::TokenId;
-use pallet_common::{
-	CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,
-};
+use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::DispatchError;
 use sp_std::vec::Vec;
 
@@ -200,7 +198,7 @@
 	}
 
 	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
-		<Owned<T>>::iter_prefix((self.id, account.as_sub()))
+		<Owned<T>>::iter_prefix((self.id, account))
 			.map(|(id, _)| id)
 			.collect()
 	}
@@ -234,7 +232,7 @@
 	}
 
 	fn account_balance(&self, account: T::CrossAccountId) -> u32 {
-		<AccountBalance<T>>::get((self.id, account.as_sub()))
+		<AccountBalance<T>>::get((self.id, account))
 	}
 
 	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -93,7 +93,7 @@
 impl<T: Config> NonfungibleHandle<T> {
 	fn balance_of(&self, owner: address) -> Result<uint256> {
 		let owner = T::CrossAccountId::from_eth(owner);
-		let balance = <AccountBalance<T>>::get((self.id, owner.as_sub()));
+		let balance = <AccountBalance<T>>::get((self.id, owner));
 		Ok(balance.into())
 	}
 	fn owner_of(&self, token_id: uint256) -> Result<address> {
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -80,7 +80,7 @@
 	pub(super) type Owned<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
-			Key<Blake2_128Concat, T::AccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>,
 			Key<Twox64Concat, TokenId>,
 		),
 		Value = bool,
@@ -91,7 +91,7 @@
 	pub(super) type AccountBalance<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
-			Key<Blake2_128Concat, T::AccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>,
 		),
 		Value = u32,
 		QueryKind = ValueQuery,
@@ -179,7 +179,7 @@
 
 		// =========
 
-		<Owned<T>>::remove((collection.id, token_data.owner.as_sub(), token));
+		<Owned<T>>::remove((collection.id, &token_data.owner, token));
 		<TokensBurnt<T>>::insert(collection.id, burnt);
 		<TokenData<T>>::remove((collection.id, token));
 		let old_spender = <Allowance<T>>::take((collection.id, token));
@@ -234,11 +234,11 @@
 		}
 		<PalletCommon<T>>::ensure_correct_receiver(to)?;
 
-		let balance_from = <AccountBalance<T>>::get((collection.id, from.as_sub()))
+		let balance_from = <AccountBalance<T>>::get((collection.id, from))
 			.checked_sub(1)
 			.ok_or(<CommonError<T>>::TokenValueTooLow)?;
 		let balance_to = if from != to {
-			let balance_to = <AccountBalance<T>>::get((collection.id, to.as_sub()))
+			let balance_to = <AccountBalance<T>>::get((collection.id, to))
 				.checked_add(1)
 				.ok_or(ArithmeticError::Overflow)?;
 
@@ -268,13 +268,13 @@
 		if let Some(balance_to) = balance_to {
 			// from != to
 			if balance_from == 0 {
-				<AccountBalance<T>>::remove((collection.id, from.as_sub()));
+				<AccountBalance<T>>::remove((collection.id, from));
 			} else {
-				<AccountBalance<T>>::insert((collection.id, from.as_sub()), balance_from);
+				<AccountBalance<T>>::insert((collection.id, from), balance_from);
 			}
-			<AccountBalance<T>>::insert((collection.id, to.as_sub()), balance_to);
-			<Owned<T>>::remove((collection.id, from.as_sub(), token));
-			<Owned<T>>::insert((collection.id, to.as_sub(), token), true);
+			<AccountBalance<T>>::insert((collection.id, to), balance_to);
+			<Owned<T>>::remove((collection.id, from, token));
+			<Owned<T>>::insert((collection.id, to, token), true);
 		}
 		Self::set_allowance_unchecked(collection, from, token, None, true);
 
@@ -336,8 +336,8 @@
 		let mut balances = BTreeMap::new();
 		for data in &data {
 			let balance = balances
-				.entry(data.owner.as_sub())
-				.or_insert_with(|| <AccountBalance<T>>::get((collection.id, data.owner.as_sub())));
+				.entry(&data.owner)
+				.or_insert_with(|| <AccountBalance<T>>::get((collection.id, &data.owner)));
 			*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;
 
 			ensure!(
@@ -364,7 +364,7 @@
 					owner: data.owner.clone(),
 				},
 			);
-			<Owned<T>>::insert((collection.id, data.owner.as_sub(), token), true);
+			<Owned<T>>::insert((collection.id, &data.owner, token), true);
 
 			collection.log_infallible(ERC721Events::Transfer {
 				from: H160::default(),
@@ -481,7 +481,7 @@
 		to: &T::CrossAccountId,
 		token: TokenId,
 	) -> DispatchResult {
-		if spender == from {
+		if spender.conv_eq(from) {
 			return Self::transfer(collection, from, to, token);
 		}
 		if collection.access == AccessMode::WhiteList {
@@ -509,7 +509,7 @@
 		from: &T::CrossAccountId,
 		token: TokenId,
 	) -> DispatchResult {
-		if spender == from {
+		if spender.conv_eq(from) {
 			return Self::burn(collection, from, token);
 		}
 		if collection.access == AccessMode::WhiteList {
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -3,9 +3,7 @@
 use sp_std::collections::btree_map::BTreeMap;
 use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};
 use nft_data_structs::TokenId;
-use pallet_common::{
-	CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,
-};
+use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
 use sp_runtime::DispatchError;
 use sp_std::vec::Vec;
 
@@ -196,7 +194,7 @@
 	}
 
 	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
-		<Owned<T>>::iter_prefix((self.id, account.as_sub()))
+		<Owned<T>>::iter_prefix((self.id, account))
 			.map(|(id, _)| id)
 			.collect()
 	}
@@ -224,11 +222,11 @@
 	}
 
 	fn account_balance(&self, account: T::CrossAccountId) -> u32 {
-		<AccountBalance<T>>::get((self.id, account.as_sub()))
+		<AccountBalance<T>>::get((self.id, account))
 	}
 
 	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {
-		<Balance<T>>::get((self.id, token, account.as_sub()))
+		<Balance<T>>::get((self.id, token, account))
 	}
 
 	fn allowance(
@@ -237,6 +235,6 @@
 		spender: T::CrossAccountId,
 		token: TokenId,
 	) -> u128 {
-		<Allowance<T>>::get((self.id, token, sender.as_sub(), spender))
+		<Allowance<T>>::get((self.id, token, sender, spender))
 	}
 }
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -83,7 +83,7 @@
 	pub(super) type Owned<T: Config> = StorageNMap<
 		Key = (
 			Key<Twox64Concat, CollectionId>,
-			Key<Blake2_128Concat, T::AccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>,
 			Key<Twox64Concat, TokenId>,
 		),
 		Value = bool,
@@ -95,7 +95,7 @@
 		Key = (
 			Key<Twox64Concat, CollectionId>,
 			// Owner
-			Key<Blake2_128Concat, T::AccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>,
 		),
 		Value = u32,
 		QueryKind = ValueQuery,
@@ -107,7 +107,7 @@
 			Key<Twox64Concat, CollectionId>,
 			Key<Twox64Concat, TokenId>,
 			// Owner
-			Key<Blake2_128Concat, T::AccountId>,
+			Key<Blake2_128Concat, T::CrossAccountId>,
 		),
 		Value = u128,
 		QueryKind = ValueQuery,
@@ -119,7 +119,7 @@
 			Key<Twox64Concat, CollectionId>,
 			Key<Twox64Concat, TokenId>,
 			// Owner
-			Key<Blake2_128, T::AccountId>,
+			Key<Blake2_128, T::CrossAccountId>,
 			// Spender
 			Key<Blake2_128Concat, T::CrossAccountId>,
 		),
@@ -206,18 +206,18 @@
 		if total_supply == 0 {
 			// Ensure user actually owns this amount
 			ensure!(
-				<Balance<T>>::get((collection.id, token, owner.as_sub())) == amount,
+				<Balance<T>>::get((collection.id, token, owner)) == amount,
 				<CommonError<T>>::TokenValueTooLow
 			);
-			let account_balance = <AccountBalance<T>>::get((collection.id, owner.as_sub()))
+			let account_balance = <AccountBalance<T>>::get((collection.id, owner))
 				.checked_sub(1)
 				// Should not occur
 				.ok_or(ArithmeticError::Underflow)?;
 
 			// =========
 
-			<Owned<T>>::remove((collection.id, owner.as_sub(), token));
-			<AccountBalance<T>>::insert((collection.id, owner.as_sub()), account_balance);
+			<Owned<T>>::remove((collection.id, owner, token));
+			<AccountBalance<T>>::insert((collection.id, owner), account_balance);
 			Self::burn_token(collection, token)?;
 			<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
 				collection.id,
@@ -228,11 +228,11 @@
 			return Ok(());
 		}
 
-		let balance = <Balance<T>>::get((collection.id, token, owner.as_sub()))
+		let balance = <Balance<T>>::get((collection.id, token, owner))
 			.checked_sub(amount)
 			.ok_or(<CommonError<T>>::TokenValueTooLow)?;
 		let account_balance = if balance == 0 {
-			<AccountBalance<T>>::get((collection.id, owner.as_sub()))
+			<AccountBalance<T>>::get((collection.id, owner))
 				.checked_sub(1)
 				// Should not occur
 				.ok_or(ArithmeticError::Underflow)?
@@ -243,11 +243,11 @@
 		// =========
 
 		if balance == 0 {
-			<Owned<T>>::remove((collection.id, owner.as_sub(), token));
-			<Balance<T>>::remove((collection.id, token, owner.as_sub()));
-			<AccountBalance<T>>::insert((collection.id, owner.as_sub()), account_balance);
+			<Owned<T>>::remove((collection.id, owner, token));
+			<Balance<T>>::remove((collection.id, token, owner));
+			<AccountBalance<T>>::insert((collection.id, owner), account_balance);
 		} else {
-			<Balance<T>>::insert((collection.id, token, owner.as_sub()), balance);
+			<Balance<T>>::insert((collection.id, token, owner), balance);
 		}
 		<TotalSupply<T>>::insert((collection.id, token), total_supply);
 		// TODO: ERC20 transfer event
@@ -278,13 +278,13 @@
 		}
 		<PalletCommon<T>>::ensure_correct_receiver(to)?;
 
-		let balance_from = <Balance<T>>::get((collection.id, token, from.as_sub()))
+		let balance_from = <Balance<T>>::get((collection.id, token, from))
 			.checked_sub(amount)
 			.ok_or(<CommonError<T>>::TokenValueTooLow)?;
 		let mut create_target = false;
 		let from_to_differ = from != to;
 		let balance_to = if from != to {
-			let old_balance = <Balance<T>>::get((collection.id, token, to.as_sub()));
+			let old_balance = <Balance<T>>::get((collection.id, token, to));
 			if old_balance == 0 {
 				create_target = true;
 			}
@@ -299,7 +299,7 @@
 
 		let account_balance_from = if balance_from == 0 {
 			Some(
-				<AccountBalance<T>>::get((collection.id, from.as_sub()))
+				<AccountBalance<T>>::get((collection.id, from))
 					.checked_sub(1)
 					// Should not occur
 					.ok_or(ArithmeticError::Underflow)?,
@@ -310,7 +310,7 @@
 		// Account data is created in token, AccountBalance should be increased
 		// But only if from != to as we shouldn't check overflow in this case
 		let account_balance_to = if create_target && from_to_differ {
-			let account_balance_to = <AccountBalance<T>>::get((collection.id, to.as_sub()))
+			let account_balance_to = <AccountBalance<T>>::get((collection.id, to))
 				.checked_add(1)
 				.ok_or(ArithmeticError::Overflow)?;
 			ensure!(
@@ -328,18 +328,18 @@
 		if let Some(balance_to) = balance_to {
 			// from != to
 			if balance_from == 0 {
-				<Balance<T>>::remove((collection.id, token, from.as_sub()));
+				<Balance<T>>::remove((collection.id, token, from));
 			} else {
-				<Balance<T>>::insert((collection.id, token, from.as_sub()), balance_from);
+				<Balance<T>>::insert((collection.id, token, from), balance_from);
 			}
-			<Balance<T>>::insert((collection.id, token, to.as_sub()), balance_to);
+			<Balance<T>>::insert((collection.id, token, to), balance_to);
 			if let Some(account_balance_from) = account_balance_from {
-				<AccountBalance<T>>::insert((collection.id, from.as_sub()), account_balance_from);
-				<Owned<T>>::remove((collection.id, from.as_sub(), token));
+				<AccountBalance<T>>::insert((collection.id, from), account_balance_from);
+				<Owned<T>>::remove((collection.id, from, token));
 			}
 			if let Some(account_balance_to) = account_balance_to {
-				<AccountBalance<T>>::insert((collection.id, to.as_sub()), account_balance_to);
-				<Owned<T>>::insert((collection.id, to.as_sub(), token), true);
+				<AccountBalance<T>>::insert((collection.id, to), account_balance_to);
+				<Owned<T>>::insert((collection.id, to, token), true);
 			}
 		}
 
@@ -412,8 +412,8 @@
 		for data in &data {
 			for (owner, _) in &data.users {
 				let balance = balances
-					.entry(owner.as_sub())
-					.or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner.as_sub())));
+					.entry(owner)
+					.or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner)));
 				*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;
 
 				ensure!(
@@ -444,8 +444,8 @@
 				if amount == 0 {
 					continue;
 				}
-				<Balance<T>>::insert((collection.id, token_id, user.as_sub()), amount);
-				<Owned<T>>::insert((collection.id, user.as_sub(), TokenId(token_id)), true);
+				<Balance<T>>::insert((collection.id, token_id, &user), amount);
+				<Owned<T>>::insert((collection.id, &user, TokenId(token_id)), true);
 				// TODO: ERC20 transfer event
 				<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
 					collection.id,
@@ -465,7 +465,7 @@
 		token: TokenId,
 		amount: u128,
 	) {
-		<Allowance<T>>::insert((collection.id, token, sender.as_sub(), spender), amount);
+		<Allowance<T>>::insert((collection.id, token, sender, spender), amount);
 		// TODO: ERC20 approval event
 		<PalletCommon<T>>::deposit_event(CommonEvent::Approved(
 			collection.id,
@@ -490,7 +490,7 @@
 
 		<PalletCommon<T>>::ensure_correct_receiver(spender)?;
 
-		if <Balance<T>>::get((collection.id, token, sender.as_sub())) < amount {
+		if <Balance<T>>::get((collection.id, token, sender)) < amount {
 			ensure!(
 				collection.ignores_owned_amount(sender)? && Self::token_exists(collection, token),
 				<CommonError<T>>::CantApproveMoreThanOwned
@@ -511,7 +511,7 @@
 		token: TokenId,
 		amount: u128,
 	) -> DispatchResult {
-		if spender == from {
+		if spender.conv_eq(from) {
 			return Self::transfer(collection, from, to, token, amount);
 		}
 		if collection.access == AccessMode::WhiteList {
@@ -519,8 +519,8 @@
 			collection.check_allowlist(spender)?;
 		}
 
-		let allowance = <Allowance<T>>::get((collection.id, token, from.as_sub(), &spender))
-			.checked_sub(amount);
+		let allowance =
+			<Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);
 		if allowance.is_none() {
 			ensure!(
 				collection.ignores_allowance(spender)?,
@@ -544,7 +544,7 @@
 		token: TokenId,
 		amount: u128,
 	) -> DispatchResult {
-		if spender == from {
+		if spender.conv_eq(from) {
 			return Self::burn(collection, from, token, amount);
 		}
 		if collection.access == AccessMode::WhiteList {
@@ -552,8 +552,8 @@
 			collection.check_allowlist(spender)?;
 		}
 
-		let allowance = <Allowance<T>>::get((collection.id, token, from.as_sub(), &spender))
-			.checked_sub(amount);
+		let allowance =
+			<Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);
 		if allowance.is_none() {
 			ensure!(
 				collection.ignores_allowance(spender)?,
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -30,8 +30,8 @@
 		/// Used for ethereum integration
 		fn eth_contract_code(account: H160) -> Option<Vec<u8>>;
 
-		fn adminlist(collection: CollectionId) -> Vec<AccountId>;
-		fn allowlist(collection: CollectionId) -> Vec<AccountId>;
+		fn adminlist(collection: CollectionId) -> Vec<CrossAccountId>;
+		fn allowlist(collection: CollectionId) -> Vec<CrossAccountId>;
 		fn last_token_id(collection: CollectionId) -> TokenId;
 	}
 }
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -1033,12 +1033,14 @@
 		}
 
 		fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
-			<pallet_nft::NftErcSupport<Runtime>>::get_code(&account).or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account)).or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
+			<pallet_nft::NftErcSupport<Runtime>>::get_code(&account)
+				.or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
+				.or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
 		}
-		fn adminlist(collection: CollectionId) -> Vec<AccountId> {
+		fn adminlist(collection: CollectionId) -> Vec<CrossAccountId> {
 			<pallet_nft::Pallet<Runtime>>::adminlist(collection)
 		}
-		fn allowlist(collection: CollectionId) -> Vec<AccountId> {
+		fn allowlist(collection: CollectionId) -> Vec<CrossAccountId> {
 			<pallet_nft::Pallet<Runtime>>::allowlist(collection)
 		}
 		fn last_token_id(collection: CollectionId) -> TokenId {