git.delta.rocks / unique-network / refs/commits / 846b9101586a

difftreelog

feat Using EthCrossAccount in appropriate functions

Trubnikov Sergey2022-10-25parent: #1fe3f60.patch.diff
in: master

11 files changed

modifiedcrates/evm-coder/src/abi.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi.rs
+++ b/crates/evm-coder/src/abi.rs
@@ -450,7 +450,7 @@
 	}
 }
 
-impl AbiWrite for &EthCrossAccount {
+impl AbiWrite for EthCrossAccount {
 	fn abi_write(&self, writer: &mut AbiWriter) {
 		self.eth.abi_write(writer);
 		self.sub.abi_write(writer);
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -218,7 +218,7 @@
 		}
 	}
 
-	#[derive(Debug)]
+	#[derive(Debug, Default)]
 	pub struct EthCrossAccount {
 		pub(crate) eth: address,
 		pub(crate) sub: uint256,
modifiedcrates/evm-coder/src/solidity.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity.rs
+++ b/crates/evm-coder/src/solidity.rs
@@ -203,7 +203,7 @@
 	}
 
 	fn solidity_default(writer: &mut impl fmt::Write, tc: &TypeCollector) -> fmt::Result {
-		write!(writer, "{}(", tc.collect_tuple::<Self>())?;
+		write!(writer, "{}(", tc.collect_struct::<Self>())?;
 		address::solidity_default(writer, tc)?;
 		write!(writer, ",")?;
 		uint256::solidity_default(writer, tc)?;
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -231,13 +231,13 @@
 	fn set_collection_sponsor_cross(
 		&mut self,
 		caller: caller,
-		sponsor: (address, uint256),
+		sponsor: EthCrossAccount,
 	) -> Result<void> {
 		self.consume_store_reads_and_writes(1, 1)?;
 
 		check_is_owner_or_admin(caller, self)?;
 
-		let sponsor = convert_tuple_to_cross_account::<T>(sponsor)?;
+		let sponsor = sponsor.into_sub_cross_account::<T>()?;
 		self.set_sponsor(sponsor.as_sub().clone())
 			.map_err(dispatch_to_evm::<T>)?;
 		save(self)
@@ -388,12 +388,12 @@
 	fn add_collection_admin_cross(
 		&mut self,
 		caller: caller,
-		new_admin: (address, uint256),
+		new_admin: EthCrossAccount,
 	) -> Result<void> {
 		self.consume_store_writes(2)?;
 
 		let caller = T::CrossAccountId::from_eth(caller);
-		let new_admin = convert_tuple_to_cross_account::<T>(new_admin)?;
+		let new_admin = new_admin.into_sub_cross_account::<T>()?;
 		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
@@ -403,12 +403,12 @@
 	fn remove_collection_admin_cross(
 		&mut self,
 		caller: caller,
-		admin: (address, uint256),
+		admin: EthCrossAccount,
 	) -> Result<void> {
 		self.consume_store_writes(2)?;
 
 		let caller = T::CrossAccountId::from_eth(caller);
-		let admin = convert_tuple_to_cross_account::<T>(admin)?;
+		let admin = admin.into_sub_cross_account::<T>()?;
 		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
@@ -566,12 +566,12 @@
 	fn add_to_collection_allow_list_cross(
 		&mut self,
 		caller: caller,
-		user: (address, uint256),
+		user: EthCrossAccount,
 	) -> Result<void> {
 		self.consume_store_writes(1)?;
 
 		let caller = T::CrossAccountId::from_eth(caller);
-		let user = convert_tuple_to_cross_account::<T>(user)?;
+		let user = user.into_sub_cross_account::<T>()?;
 		Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
@@ -594,12 +594,12 @@
 	fn remove_from_collection_allow_list_cross(
 		&mut self,
 		caller: caller,
-		user: (address, uint256),
+		user: EthCrossAccount,
 	) -> Result<void> {
 		self.consume_store_writes(1)?;
 
 		let caller = T::CrossAccountId::from_eth(caller);
-		let user = convert_tuple_to_cross_account::<T>(user)?;
+		let user = user.into_sub_cross_account::<T>()?;
 		Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
@@ -639,8 +639,8 @@
 	///
 	/// @param user User cross account to verify
 	/// @return "true" if account is the owner or admin
-	fn is_owner_or_admin_cross(&self, user: (address, uint256)) -> Result<bool> {
-		let user = convert_tuple_to_cross_account::<T>(user)?;
+	fn is_owner_or_admin_cross(&self, user: EthCrossAccount) -> Result<bool> {
+		let user = user.into_sub_cross_account::<T>()?;
 		Ok(self.is_owner_or_admin(&user))
 	}
 
@@ -660,8 +660,8 @@
 	///
 	/// @return Tuble with sponsor address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
-	fn collection_owner(&self) -> Result<(address, uint256)> {
-		Ok(convert_cross_account_to_tuple::<T>(
+	fn collection_owner(&self) -> Result<EthCrossAccount> {
+		Ok(EthCrossAccount::from_sub_cross_account::<T>(
 			&T::CrossAccountId::from_sub(self.owner.clone()),
 		))
 	}
@@ -684,9 +684,9 @@
 	///
 	/// @return Vector of tuples with admins address and his substrate mirror.
 	/// If address is canonical then substrate mirror is zero and vice versa.
-	fn collection_admins(&self) -> Result<Vec<(address, uint256)>> {
+	fn collection_admins(&self) -> Result<Vec<EthCrossAccount>> {
 		let result = crate::IsAdmin::<T>::iter_prefix((self.id,))
-			.map(|(admin, _)| crate::eth::convert_cross_account_to_tuple::<T>(&admin))
+			.map(|(admin, _)| EthCrossAccount::from_sub_cross_account::<T>(&admin))
 			.collect();
 		Ok(result)
 	}
@@ -695,11 +695,11 @@
 	///
 	/// @dev Owner can be changed only by current owner
 	/// @param newOwner new owner cross account
-	fn set_owner_cross(&mut self, caller: caller, new_owner: (address, uint256)) -> Result<void> {
+	fn set_owner_cross(&mut self, caller: caller, new_owner: EthCrossAccount) -> Result<void> {
 		self.consume_store_writes(1)?;
 
 		let caller = T::CrossAccountId::from_eth(caller);
-		let new_owner = convert_tuple_to_cross_account::<T>(new_owner)?;
+		let new_owner = new_owner.into_sub_cross_account::<T>()?;
 		self.set_owner_internal(caller, new_owner)
 			.map_err(dispatch_to_evm::<T>)
 	}
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -167,11 +167,11 @@
 	fn approve_cross(
 		&mut self,
 		caller: caller,
-		spender: (address, uint256),
+		spender: EthCrossAccount,
 		amount: uint256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let spender = convert_tuple_to_cross_account::<T>(spender)?;
+		let spender = spender.into_sub_cross_account::<T>()?;
 		let amount = amount.try_into().map_err(|_| "amount overflow")?;
 
 		<Pallet<T>>::set_allowance(self, &caller, &spender, amount)
@@ -207,11 +207,11 @@
 	fn burn_from_cross(
 		&mut self,
 		caller: caller,
-		from: (address, uint256),
+		from: EthCrossAccount,
 		amount: uint256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let from = convert_tuple_to_cross_account::<T>(from)?;
+		let from = from.into_sub_cross_account::<T>()?;
 		let amount = amount.try_into().map_err(|_| "amount overflow")?;
 		let budget = self
 			.recorder
@@ -249,13 +249,13 @@
 	fn transfer_from_cross(
 		&mut self,
 		caller: caller,
-		from: (address, uint256),
-		to: (address, uint256),
+		from: EthCrossAccount,
+		to: EthCrossAccount,
 		amount: uint256,
 	) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let from = convert_tuple_to_cross_account::<T>(from)?;
-		let to = convert_tuple_to_cross_account::<T>(to)?;
+		let from = from.into_sub_cross_account::<T>()?;
+		let to = to.into_sub_cross_account::<T>()?;
 		let amount = amount.try_into().map_err(|_| "amount overflow")?;
 		let budget = self
 			.recorder
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -684,11 +684,11 @@
 	fn approve_cross(
 		&mut self,
 		caller: caller,
-		approved: (address, uint256),
+		approved: EthCrossAccount,
 		token_id: uint256,
 	) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let approved = convert_tuple_to_cross_account::<T>(approved)?;
+		let approved = approved.into_sub_cross_account::<T>()?;
 		let token = token_id.try_into()?;
 
 		<Pallet<T>>::set_allowance(self, &caller, token, Some(&approved))
@@ -770,11 +770,11 @@
 	fn burn_from_cross(
 		&mut self,
 		caller: caller,
-		from: (address, uint256),
+		from: EthCrossAccount,
 		token_id: uint256,
 	) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let from = convert_tuple_to_cross_account::<T>(from)?;
+		let from = from.into_sub_cross_account::<T>()?;
 		let token = token_id.try_into()?;
 		let budget = self
 			.recorder
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -734,23 +734,23 @@
 	fn transfer_from_cross(
 		&mut self,
 		caller: caller,
-		from: (address, uint256),
-		to: (address, uint256),
+		from: EthCrossAccount,
+		to: EthCrossAccount,
 		token_id: uint256,
 	) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		// let from = convert_tuple_to_cross_account::<T>(from)?;
-		// let to = convert_tuple_to_cross_account::<T>(to)?;
-		// let token_id = token_id.try_into()?;
-		// let budget = self
-		// 	.recorder
-		// 	.weight_calls_budget(<StructureWeight<T>>::find_parent());
+		let from = from.into_sub_cross_account::<T>()?;
+		let to = to.into_sub_cross_account::<T>()?;
+		let token_id = token_id.try_into()?;
+		let budget = self
+			.recorder
+			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
-		// let balance = balance(self, token_id, &from)?;
-		// ensure_single_owner(self, token_id, balance)?;
+		let balance = balance(self, token_id, &from)?;
+		ensure_single_owner(self, token_id, balance)?;
 
-		// Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)
-		// 	.map_err(dispatch_to_evm::<T>)?;
+		Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)
+			.map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
 
@@ -789,11 +789,11 @@
 	fn burn_from_cross(
 		&mut self,
 		caller: caller,
-		from: (address, uint256),
+		from: EthCrossAccount,
 		token_id: uint256,
 	) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let from = convert_tuple_to_cross_account::<T>(from)?;
+		let from = from.into_sub_cross_account::<T>()?;
 		let token = token_id.try_into()?;
 		let budget = self
 			.recorder
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
before · tests/src/eth/collectionAdmin.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.3// Unique Network is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// Unique Network is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the11// GNU General Public License for more details.1213// You should have received a copy of the GNU General Public License14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1516import {IKeyringPair} from '@polkadot/types/types';17import {IEthCrossAccountId} from '../util/playgrounds/types';18import {usingEthPlaygrounds, itEth, expect, EthUniqueHelper} from './util/playgrounds';1920async function recordEthFee(helper: EthUniqueHelper, userAddress: string, call: () => Promise<any>) {21  const before = await helper.balance.getSubstrate(helper.address.ethToSubstrate(userAddress));22  await call();23  await helper.wait.newBlocks(1);24  const after = await helper.balance.getSubstrate(helper.address.ethToSubstrate(userAddress));2526  expect(after < before).to.be.true;2728  return before - after;29}3031describe('Add collection admins', () => {32  let donor: IKeyringPair;3334  before(async function() {35    await usingEthPlaygrounds(async (_helper, privateKey) => {36      donor = await privateKey({filename: __filename});37    });38  });3940  itEth('Add admin by owner', async ({helper}) => {41    const owner = await helper.eth.createAccountWithBalance(donor);42    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');43    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);4445    const newAdmin = helper.eth.createAccount();4647    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();48    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);49    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())50      .to.be.eq(newAdmin.toLocaleLowerCase());51  });5253  itEth('Add cross account admin by owner', async ({helper, privateKey}) => {54    const owner = await helper.eth.createAccountWithBalance(donor);55        56    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');57    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);58    59    const newAdmin = privateKey('//Bob');60    const newAdminCross = helper.ethCrossAccount.fromKeyringPair(newAdmin);61    await collectionEvm.methods.addCollectionAdminCross(newAdminCross).send();6263    const adminList = await helper.collection.getAdmins(collectionId);64    expect(adminList).to.be.like([{Substrate: newAdmin.address}]);65  });6667  itEth('Check adminlist', async ({helper, privateKey}) => {68    const owner = await helper.eth.createAccountWithBalance(donor);69        70    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');71    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);7273    const admin1 = helper.eth.createAccount();74    const admin2 = privateKey('admin');75    await collectionEvm.methods.addCollectionAdmin(admin1).send();76    await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();7778    const adminListRpc = await helper.collection.getAdmins(collectionId);79    let adminListEth = await collectionEvm.methods.collectionAdmins().call();80    adminListEth = adminListEth.map((element: IEthCrossAccountId) => {81      return helper.address.convertCrossAccountFromEthCrossAcoount(element);82    });83    expect(adminListRpc).to.be.like(adminListEth);84  });8586  itEth('Verify owner or admin', async ({helper}) => {87    const owner = await helper.eth.createAccountWithBalance(donor);88    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');8990    const newAdmin = helper.eth.createAccount();91    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);92  93    expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;94    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();95    expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;96  });97  98  itEth.skip('Check adminlist', async ({helper, privateKey}) => {99    const owner = await helper.eth.createAccountWithBalance(donor);100        101    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');102    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);103104    const admin1 = helper.eth.createAccount();105    const admin2 = privateKey('admin');106    await collectionEvm.methods.addCollectionAdmin(admin1).send();107    await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();108109    const adminListRpc = await helper.collection.getAdmins(collectionId);110    let adminListEth = await collectionEvm.methods.collectionAdmins().call();111    adminListEth = adminListEth.map((element: IEthCrossAccountId) => {112      return helper.address.convertCrossAccountFromEthCrossAcoount(element);113    });114    expect(adminListRpc).to.be.like(adminListEth);115  });  116    117  itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {118    const owner = await helper.eth.createAccountWithBalance(donor);119    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');120121    const admin = await helper.eth.createAccountWithBalance(donor);122    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);123    await collectionEvm.methods.addCollectionAdmin(admin).send();124125    const user = helper.eth.createAccount();126    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))127      .to.be.rejectedWith('NoPermission');128129    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);130    expect(adminList.length).to.be.eq(1);131    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())132      .to.be.eq(admin.toLocaleLowerCase());133  });134135  itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {136    const owner = await helper.eth.createAccountWithBalance(donor);137    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');138139    const notAdmin = await helper.eth.createAccountWithBalance(donor);140    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);141142    const user = helper.eth.createAccount();143    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))144      .to.be.rejectedWith('NoPermission');145146    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);147    expect(adminList.length).to.be.eq(0);148  });149150  itEth.skip('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({helper}) => {151    const owner = await helper.eth.createAccountWithBalance(donor);152    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');153154    const admin = await helper.eth.createAccountWithBalance(donor);155    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);156    await collectionEvm.methods.addCollectionAdmin(admin).send();157158    const [notAdmin] = await helper.arrange.createAccounts([10n], donor);159    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))160      .to.be.rejectedWith('NoPermission');161162    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);163    expect(adminList.length).to.be.eq(1);164    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())165      .to.be.eq(admin.toLocaleLowerCase());166  });167168  itEth.skip('(!negative tests!) Add substrate admin by USER is not allowed', async ({helper}) => {169    const owner = await helper.eth.createAccountWithBalance(donor);170    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');171172    const notAdmin0 = await helper.eth.createAccountWithBalance(donor);173    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);174    const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);175    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))176      .to.be.rejectedWith('NoPermission');177178    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);179    expect(adminList.length).to.be.eq(0);180  });181});182183describe('Remove collection admins', () => {184  let donor: IKeyringPair;185186  before(async function() {187    await usingEthPlaygrounds(async (_helper, privateKey) => {188      donor = await privateKey({filename: __filename});189    });190  });191192  itEth('Remove admin by owner', async ({helper}) => {193    const owner = await helper.eth.createAccountWithBalance(donor);194    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');195196    const newAdmin = helper.eth.createAccount();197    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);198    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();199200    {201      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);202      expect(adminList.length).to.be.eq(1);203      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())204        .to.be.eq(newAdmin.toLocaleLowerCase());205    }206207    await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();208    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);209    expect(adminList.length).to.be.eq(0);210  });211212  itEth.skip('Remove substrate admin by owner', async ({helper}) => {213    const owner = await helper.eth.createAccountWithBalance(donor);214    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');215216    const [newAdmin] = await helper.arrange.createAccounts([10n], donor);217    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);218    await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();219    {220      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);221      expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())222        .to.be.eq(newAdmin.address.toLocaleLowerCase());223    }224225    await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();226    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);227    expect(adminList.length).to.be.eq(0);228  });229230  itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {231    const owner = await helper.eth.createAccountWithBalance(donor);232    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');233234    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);235236    const admin0 = await helper.eth.createAccountWithBalance(donor);237    await collectionEvm.methods.addCollectionAdmin(admin0).send();238    const admin1 = await helper.eth.createAccountWithBalance(donor);239    await collectionEvm.methods.addCollectionAdmin(admin1).send();240241    await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))242      .to.be.rejectedWith('NoPermission');243    {244      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);245      expect(adminList.length).to.be.eq(2);246      expect(adminList.toString().toLocaleLowerCase())247        .to.be.deep.contains(admin0.toLocaleLowerCase())248        .to.be.deep.contains(admin1.toLocaleLowerCase());249    }250  });251252  itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {253    const owner = await helper.eth.createAccountWithBalance(donor);254    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');255256    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);257258    const admin = await helper.eth.createAccountWithBalance(donor);259    await collectionEvm.methods.addCollectionAdmin(admin).send();260    const notAdmin = helper.eth.createAccount();261262    await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))263      .to.be.rejectedWith('NoPermission');264    {265      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);266      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())267        .to.be.eq(admin.toLocaleLowerCase());268      expect(adminList.length).to.be.eq(1);269    }270  });271272  itEth.skip('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({helper}) => {273    const owner = await helper.eth.createAccountWithBalance(donor);274    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');275276    const [adminSub] = await helper.arrange.createAccounts([10n], donor);277    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);278    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();279    const adminEth = await helper.eth.createAccountWithBalance(donor);280    await collectionEvm.methods.addCollectionAdmin(adminEth).send();281282    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))283      .to.be.rejectedWith('NoPermission');284285    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);286    expect(adminList.length).to.be.eq(2);287    expect(adminList.toString().toLocaleLowerCase())288      .to.be.deep.contains(adminSub.address.toLocaleLowerCase())289      .to.be.deep.contains(adminEth.toLocaleLowerCase());290  });291292  itEth.skip('(!negative tests!) Remove substrate admin by USER is not allowed', async ({helper}) => {293    const owner = await helper.eth.createAccountWithBalance(donor);294    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');295296    const [adminSub] = await helper.arrange.createAccounts([10n], donor);297    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);298    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();299    const notAdminEth = await helper.eth.createAccountWithBalance(donor);300301    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))302      .to.be.rejectedWith('NoPermission');303304    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);305    expect(adminList.length).to.be.eq(1);306    expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())307      .to.be.eq(adminSub.address.toLocaleLowerCase());308  });309});310311describe('Change owner tests', () => {312  let donor: IKeyringPair;313314  before(async function() {315    await usingEthPlaygrounds(async (_helper, privateKey) => {316      donor = await privateKey({filename: __filename});317    });318  });319320  itEth('Change owner', async ({helper}) => {321    const owner = await helper.eth.createAccountWithBalance(donor);322    const newOwner = await helper.eth.createAccountWithBalance(donor);323    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');324    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);325326    await collectionEvm.methods.changeCollectionOwner(newOwner).send();327328    expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;329    expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.true;330  });331332  itEth('change owner call fee', async ({helper}) => {333    const owner = await helper.eth.createAccountWithBalance(donor);334    const newOwner = await helper.eth.createAccountWithBalance(donor);335    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');336    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);337    const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.changeCollectionOwner(newOwner).send());338    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));339    expect(cost > 0);340  });341342  itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {343    const owner = await helper.eth.createAccountWithBalance(donor);344    const newOwner = await helper.eth.createAccountWithBalance(donor);345    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');346    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);347348    await expect(collectionEvm.methods.changeCollectionOwner(newOwner).send({from: newOwner})).to.be.rejected;349    expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;350  });351});352353describe('Change substrate owner tests', () => {354  let donor: IKeyringPair;355356  before(async function() {357    await usingEthPlaygrounds(async (_helper, privateKey) => {358      donor = await privateKey({filename: __filename});359    });360  });361362  itEth.skip('Change owner', async ({helper}) => {363    const owner = await helper.eth.createAccountWithBalance(donor);364    const [newOwner] = await helper.arrange.createAccounts([10n], donor);365    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');366    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);367368    expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;369    expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;370371    await collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send();372373    expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;374    expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;375  });376377  itEth.skip('change owner call fee', async ({helper}) => {378    const owner = await helper.eth.createAccountWithBalance(donor);379    const [newOwner] = await helper.arrange.createAccounts([10n], donor);380    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');381    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);382383    const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());384    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));385    expect(cost > 0);386  });387388  itEth.skip('(!negative tests!) call setOwner by non owner', async ({helper}) => {389    const owner = await helper.eth.createAccountWithBalance(donor);390    const otherReceiver = await helper.eth.createAccountWithBalance(donor);391    const [newOwner] = await helper.arrange.createAccounts([10n], donor);392    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');393    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);394395    await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;396    expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;397  });398});
after · tests/src/eth/collectionAdmin.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.3// Unique Network is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// Unique Network is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the11// GNU General Public License for more details.1213// You should have received a copy of the GNU General Public License14// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1516import {IKeyringPair} from '@polkadot/types/types';17import {IEthCrossAccountId} from '../util/playgrounds/types';18import {usingEthPlaygrounds, itEth, expect, EthUniqueHelper} from './util/playgrounds';1920async function recordEthFee(helper: EthUniqueHelper, userAddress: string, call: () => Promise<any>) {21  const before = await helper.balance.getSubstrate(helper.address.ethToSubstrate(userAddress));22  await call();23  await helper.wait.newBlocks(1);24  const after = await helper.balance.getSubstrate(helper.address.ethToSubstrate(userAddress));2526  expect(after < before).to.be.true;2728  return before - after;29}3031describe('Add collection admins', () => {32  let donor: IKeyringPair;3334  before(async function() {35    await usingEthPlaygrounds(async (_helper, privateKey) => {36      donor = await privateKey({filename: __filename});37    });38  });3940  itEth('Add admin by owner', async ({helper}) => {41    const owner = await helper.eth.createAccountWithBalance(donor);42    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');43    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);4445    const newAdmin = helper.eth.createAccount();4647    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();48    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);49    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())50      .to.be.eq(newAdmin.toLocaleLowerCase());51  });5253  itEth('Add cross account admin by owner', async ({helper, privateKey}) => {54    const owner = await helper.eth.createAccountWithBalance(donor);55        56    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');57    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);58    59    const newAdmin = privateKey('//Bob');60    const newAdminCross = helper.ethCrossAccount.fromKeyringPair(newAdmin);61    await collectionEvm.methods.addCollectionAdminCross(newAdminCross).send();6263    const adminList = await helper.collection.getAdmins(collectionId);64    expect(adminList).to.be.like([{Substrate: newAdmin.address}]);65  });6667  itEth('Check adminlist', async ({helper, privateKey}) => {68    const owner = await helper.eth.createAccountWithBalance(donor);69        70    const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');71    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);7273    const admin1 = helper.eth.createAccount();74    const admin2 = privateKey('admin');75    await collectionEvm.methods.addCollectionAdmin(admin1).send();76    await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();7778    const adminListRpc = await helper.collection.getAdmins(collectionId);79    let adminListEth = await collectionEvm.methods.collectionAdmins().call();80    adminListEth = adminListEth.map((element: IEthCrossAccountId) => {81      return helper.address.convertCrossAccountFromEthCrossAcoount(element);82    });83    expect(adminListRpc).to.be.like(adminListEth);84  });8586  itEth('Verify owner or admin', async ({helper}) => {87    const owner = await helper.eth.createAccountWithBalance(donor);88    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');8990    const newAdmin = helper.eth.createAccount();91    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);92  93    expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.false;94    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();95    expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;96  });97    98  itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {99    const owner = await helper.eth.createAccountWithBalance(donor);100    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');101102    const admin = await helper.eth.createAccountWithBalance(donor);103    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);104    await collectionEvm.methods.addCollectionAdmin(admin).send();105106    const user = helper.eth.createAccount();107    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))108      .to.be.rejectedWith('NoPermission');109110    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);111    expect(adminList.length).to.be.eq(1);112    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())113      .to.be.eq(admin.toLocaleLowerCase());114  });115116  itEth('(!negative tests!) Add admin by USER is not allowed', async ({helper}) => {117    const owner = await helper.eth.createAccountWithBalance(donor);118    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');119120    const notAdmin = await helper.eth.createAccountWithBalance(donor);121    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);122123    const user = helper.eth.createAccount();124    await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))125      .to.be.rejectedWith('NoPermission');126127    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);128    expect(adminList.length).to.be.eq(0);129  });130131  itEth.skip('(!negative tests!) Add substrate admin by ADMIN is not allowed', async ({helper}) => {132    const owner = await helper.eth.createAccountWithBalance(donor);133    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');134135    const admin = await helper.eth.createAccountWithBalance(donor);136    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);137    await collectionEvm.methods.addCollectionAdmin(admin).send();138139    const [notAdmin] = await helper.arrange.createAccounts([10n], donor);140    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin.addressRaw).call({from: admin}))141      .to.be.rejectedWith('NoPermission');142143    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);144    expect(adminList.length).to.be.eq(1);145    expect(adminList[0].asEthereum.toString().toLocaleLowerCase())146      .to.be.eq(admin.toLocaleLowerCase());147  });148149  itEth.skip('(!negative tests!) Add substrate admin by USER is not allowed', async ({helper}) => {150    const owner = await helper.eth.createAccountWithBalance(donor);151    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');152153    const notAdmin0 = await helper.eth.createAccountWithBalance(donor);154    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);155    const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);156    await expect(collectionEvm.methods.addCollectionAdminSubstrate(notAdmin1.addressRaw).call({from: notAdmin0}))157      .to.be.rejectedWith('NoPermission');158159    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);160    expect(adminList.length).to.be.eq(0);161  });162});163164describe('Remove collection admins', () => {165  let donor: IKeyringPair;166167  before(async function() {168    await usingEthPlaygrounds(async (_helper, privateKey) => {169      donor = await privateKey({filename: __filename});170    });171  });172173  itEth('Remove admin by owner', async ({helper}) => {174    const owner = await helper.eth.createAccountWithBalance(donor);175    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');176177    const newAdmin = helper.eth.createAccount();178    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);179    await collectionEvm.methods.addCollectionAdmin(newAdmin).send();180181    {182      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);183      expect(adminList.length).to.be.eq(1);184      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())185        .to.be.eq(newAdmin.toLocaleLowerCase());186    }187188    await collectionEvm.methods.removeCollectionAdmin(newAdmin).send();189    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);190    expect(adminList.length).to.be.eq(0);191  });192193  itEth.skip('Remove substrate admin by owner', async ({helper}) => {194    const owner = await helper.eth.createAccountWithBalance(donor);195    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');196197    const [newAdmin] = await helper.arrange.createAccounts([10n], donor);198    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);199    await collectionEvm.methods.addCollectionAdminSubstrate(newAdmin.addressRaw).send();200    {201      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);202      expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())203        .to.be.eq(newAdmin.address.toLocaleLowerCase());204    }205206    await collectionEvm.methods.removeCollectionAdminSubstrate(newAdmin.addressRaw).send();207    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);208    expect(adminList.length).to.be.eq(0);209  });210211  itEth('(!negative tests!) Remove admin by ADMIN is not allowed', async ({helper}) => {212    const owner = await helper.eth.createAccountWithBalance(donor);213    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');214215    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);216217    const admin0 = await helper.eth.createAccountWithBalance(donor);218    await collectionEvm.methods.addCollectionAdmin(admin0).send();219    const admin1 = await helper.eth.createAccountWithBalance(donor);220    await collectionEvm.methods.addCollectionAdmin(admin1).send();221222    await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))223      .to.be.rejectedWith('NoPermission');224    {225      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);226      expect(adminList.length).to.be.eq(2);227      expect(adminList.toString().toLocaleLowerCase())228        .to.be.deep.contains(admin0.toLocaleLowerCase())229        .to.be.deep.contains(admin1.toLocaleLowerCase());230    }231  });232233  itEth('(!negative tests!) Remove admin by USER is not allowed', async ({helper}) => {234    const owner = await helper.eth.createAccountWithBalance(donor);235    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');236237    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);238239    const admin = await helper.eth.createAccountWithBalance(donor);240    await collectionEvm.methods.addCollectionAdmin(admin).send();241    const notAdmin = helper.eth.createAccount();242243    await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))244      .to.be.rejectedWith('NoPermission');245    {246      const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);247      expect(adminList[0].asEthereum.toString().toLocaleLowerCase())248        .to.be.eq(admin.toLocaleLowerCase());249      expect(adminList.length).to.be.eq(1);250    }251  });252253  itEth.skip('(!negative tests!) Remove substrate admin by ADMIN is not allowed', async ({helper}) => {254    const owner = await helper.eth.createAccountWithBalance(donor);255    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');256257    const [adminSub] = await helper.arrange.createAccounts([10n], donor);258    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);259    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();260    const adminEth = await helper.eth.createAccountWithBalance(donor);261    await collectionEvm.methods.addCollectionAdmin(adminEth).send();262263    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: adminEth}))264      .to.be.rejectedWith('NoPermission');265266    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);267    expect(adminList.length).to.be.eq(2);268    expect(adminList.toString().toLocaleLowerCase())269      .to.be.deep.contains(adminSub.address.toLocaleLowerCase())270      .to.be.deep.contains(adminEth.toLocaleLowerCase());271  });272273  itEth.skip('(!negative tests!) Remove substrate admin by USER is not allowed', async ({helper}) => {274    const owner = await helper.eth.createAccountWithBalance(donor);275    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');276277    const [adminSub] = await helper.arrange.createAccounts([10n], donor);278    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);279    await collectionEvm.methods.addCollectionAdminSubstrate(adminSub.addressRaw).send();280    const notAdminEth = await helper.eth.createAccountWithBalance(donor);281282    await expect(collectionEvm.methods.removeCollectionAdminSubstrate(adminSub.addressRaw).call({from: notAdminEth}))283      .to.be.rejectedWith('NoPermission');284285    const adminList = await helper.callRpc('api.rpc.unique.adminlist', [collectionId]);286    expect(adminList.length).to.be.eq(1);287    expect(adminList[0].asSubstrate.toString().toLocaleLowerCase())288      .to.be.eq(adminSub.address.toLocaleLowerCase());289  });290});291292describe('Change owner tests', () => {293  let donor: IKeyringPair;294295  before(async function() {296    await usingEthPlaygrounds(async (_helper, privateKey) => {297      donor = await privateKey({filename: __filename});298    });299  });300301  itEth('Change owner', async ({helper}) => {302    const owner = await helper.eth.createAccountWithBalance(donor);303    const newOwner = await helper.eth.createAccountWithBalance(donor);304    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');305    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);306307    await collectionEvm.methods.changeCollectionOwner(newOwner).send();308309    expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;310    expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.true;311  });312313  itEth('change owner call fee', async ({helper}) => {314    const owner = await helper.eth.createAccountWithBalance(donor);315    const newOwner = await helper.eth.createAccountWithBalance(donor);316    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');317    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);318    const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.changeCollectionOwner(newOwner).send());319    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));320    expect(cost > 0);321  });322323  itEth('(!negative tests!) call setOwner by non owner', async ({helper}) => {324    const owner = await helper.eth.createAccountWithBalance(donor);325    const newOwner = await helper.eth.createAccountWithBalance(donor);326    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');327    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);328329    await expect(collectionEvm.methods.changeCollectionOwner(newOwner).send({from: newOwner})).to.be.rejected;330    expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;331  });332});333334describe('Change substrate owner tests', () => {335  let donor: IKeyringPair;336337  before(async function() {338    await usingEthPlaygrounds(async (_helper, privateKey) => {339      donor = await privateKey({filename: __filename});340    });341  });342343  itEth.skip('Change owner', async ({helper}) => {344    const owner = await helper.eth.createAccountWithBalance(donor);345    const [newOwner] = await helper.arrange.createAccounts([10n], donor);346    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');347    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);348349    expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.true;350    expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;351352    await collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send();353354    expect(await collectionEvm.methods.isOwnerOrAdmin(owner).call()).to.be.false;355    expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.true;356  });357358  itEth.skip('change owner call fee', async ({helper}) => {359    const owner = await helper.eth.createAccountWithBalance(donor);360    const [newOwner] = await helper.arrange.createAccounts([10n], donor);361    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');362    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);363364    const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());365    expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));366    expect(cost > 0);367  });368369  itEth.skip('(!negative tests!) call setOwner by non owner', async ({helper}) => {370    const owner = await helper.eth.createAccountWithBalance(donor);371    const otherReceiver = await helper.eth.createAccountWithBalance(donor);372    const [newOwner] = await helper.arrange.createAccounts([10n], donor);373    const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');374    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);375376    await expect(collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send({from: otherReceiver})).to.be.rejected;377    expect(await collectionEvm.methods.isOwnerOrAdminSubstrate(newOwner.addressRaw).call()).to.be.false;378  });379});
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -409,7 +409,7 @@
     expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));
   });
 
-  itEth.only('Can perform transferFromCross()', async ({helper, privateKey}) => {
+  itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
     const alice = privateKey('//Alice');
     const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
 
modifiedtests/src/util/playgrounds/types.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/types.ts
+++ b/tests/src/util/playgrounds/types.ts
@@ -73,8 +73,8 @@
 export interface IEthCrossAccountId {
   0: TEthereumAccount;
   1: TSubstrateAccount;
-  field_0: TEthereumAccount;
-  field_1: TSubstrateAccount;
+  eth: TEthereumAccount;
+  sub: TSubstrateAccount;
 }
 
 export interface ICollectionLimits {
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2430,11 +2430,11 @@
    * @returns substrate cross account id
    */
   convertCrossAccountFromEthCrossAcoount(ethCrossAccount: IEthCrossAccountId): ICrossAccountId {
-    if (ethCrossAccount.field_1 === '0') {
-      return {Ethereum: ethCrossAccount.field_0.toLocaleLowerCase()};
+    if (ethCrossAccount.sub === '0') {
+      return {Ethereum: ethCrossAccount.eth.toLocaleLowerCase()};
     }
     
-    const ss58 = this.restoreCrossAccountFromBigInt(BigInt(ethCrossAccount.field_1));
+    const ss58 = this.restoreCrossAccountFromBigInt(BigInt(ethCrossAccount.sub));
     return {Substrate: ss58};
   }