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

difftreelog

added `createRTCollection` for `CollectionHelpers`

PraetorP2022-10-24parent: #57a0938.patch.diff
in: master

9 files changed

modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -37,7 +37,7 @@
 use sp_std::vec;
 use up_data_structs::{
 	CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,
-	CollectionMode, PropertyValue, CollectionFlags,
+	CollectionMode, PropertyValue,
 };
 
 use crate::{Config, SelfWeightOf, weights::WeightInfo};
@@ -87,12 +87,28 @@
 	Ok((caller, name, description, token_prefix))
 }
 
-fn create_refungible_collection_internal<
-	T: Config + pallet_nonfungible::Config + pallet_refungible::Config,
->(
+fn create_refungible_collection_internal<T: Config>(
+	caller: caller,
+	value: value,
+	name: string,
+	description: string,
+	token_prefix: string,
+) -> Result<address> {
+	self::create_collection_internal::<T>(
+		caller,
+		value,
+		name,
+		CollectionMode::ReFungible,
+		description,
+		token_prefix
+	)
+}
+
+fn create_collection_internal<T: Config>(
 	caller: caller,
 	value: value,
 	name: string,
+	collection_mode: CollectionMode,
 	description: string,
 	token_prefix: string,
 ) -> Result<address> {
@@ -100,7 +116,7 @@
 		convert_data::<T>(caller, name, description, token_prefix)?;
 	let data = CreateCollectionData {
 		name,
-		mode: CollectionMode::ReFungible,
+		mode: collection_mode,
 		description,
 		token_prefix,
 		..Default::default()
@@ -212,6 +228,27 @@
 		create_refungible_collection_internal::<T>(caller, value, name, description, token_prefix)
 	}
 
+	#[weight(<SelfWeightOf<T>>::create_collection())]
+	#[solidity(rename_selector = "createRTCollection")]
+	fn create_fungible_collection(
+		&mut self,
+		caller: caller,
+		value: value,
+		name: string,
+		decimals: uint8,
+		description: string,
+		token_prefix: string,
+	) -> Result<address> {
+		create_collection_internal::<T>(
+			caller,
+			value,
+			name,
+			CollectionMode::Fungible(decimals),
+			description,
+			token_prefix,
+		)
+	}
+
 	#[solidity(rename_selector = "makeCollectionERC721MetadataCompatible")]
 	fn make_collection_metadata_compatible(
 		&mut self,
modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth
--- a/pallets/unique/src/eth/stubs/CollectionHelpers.sol
+++ b/pallets/unique/src/eth/stubs/CollectionHelpers.sol
@@ -24,7 +24,7 @@
 }
 
 /// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x0edfb42e
+/// @dev the ERC-165 identifier for this interface is 0xa2c196ab
 contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
 	/// Create an NFT collection
 	/// @param name Name of the collection
@@ -77,6 +77,23 @@
 		return 0x0000000000000000000000000000000000000000;
 	}
 
+	/// @dev EVM selector for this function is: 0xac1e2285,
+	///  or in textual repr: createRTCollection(string,uint8,string,string)
+	function createRTCollection(
+		string memory name,
+		uint8 decimals,
+		string memory description,
+		string memory tokenPrefix
+	) public payable returns (address) {
+		require(false, stub_error);
+		name;
+		decimals;
+		description;
+		tokenPrefix;
+		dummy = 0;
+		return 0x0000000000000000000000000000000000000000;
+	}
+
 	/// @dev EVM selector for this function is: 0x85624258,
 	///  or in textual repr: makeCollectionERC721MetadataCompatible(address,string)
 	function makeCollectionERC721MetadataCompatible(address collection, string memory baseUri) public {
modifiedtests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth
--- a/tests/src/eth/api/CollectionHelpers.sol
+++ b/tests/src/eth/api/CollectionHelpers.sol
@@ -19,7 +19,7 @@
 }
 
 /// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x0edfb42e
+/// @dev the ERC-165 identifier for this interface is 0xa2c196ab
 interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
 	/// Create an NFT collection
 	/// @param name Name of the collection
@@ -51,6 +51,15 @@
 		string memory tokenPrefix
 	) external payable returns (address);
 
+	/// @dev EVM selector for this function is: 0xac1e2285,
+	///  or in textual repr: createRTCollection(string,uint8,string,string)
+	function createRTCollection(
+		string memory name,
+		uint8 decimals,
+		string memory description,
+		string memory tokenPrefix
+	) external payable returns (address);
+
 	/// @dev EVM selector for this function is: 0x85624258,
 	///  or in textual repr: makeCollectionERC721MetadataCompatible(address,string)
 	function makeCollectionERC721MetadataCompatible(address collection, string memory baseUri) external;
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';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.createNFTCollection(owner, 'A', 'B', 'C');57    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);58    59    const newAdmin = await 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.createNFTCollection(owner, 'A', 'B', 'C');71    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);7273    const admin1 = helper.eth.createAccount();74    const admin2 = await privateKey('admin');75    await collectionEvm.methods.addCollectionAdmin(admin1).send();76    await collectionEvm.methods.addCollectionAdminCross(helper.ethCrossAccount.fromKeyringPair(admin2)).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  });9798  itEth.skip('Check adminlist', async ({helper, privateKey}) => {99    const owner = await helper.eth.createAccountWithBalance(donor);100        101    const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');102    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);103104    const admin1 = helper.eth.createAccount();105    const admin2 = await 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';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.createNFTCollection(owner, 'A', 'B', 'C');57    const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);58    59    const newAdmin = await 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.createNFTCollection(owner, 'A', 'B', 'C');71  //   const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);7273  //   const admin1 = helper.eth.createAccount();74  //   const admin2 = await privateKey('admin');75  //   await collectionEvm.methods.addCollectionAdmin(admin1).send();76  //   await collectionEvm.methods.addCollectionAdminCross(helper.ethCrossAccount.fromKeyringPair(admin2)).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  });9798  // itEth.skip('Check adminlist', async ({helper, privateKey}) => {99  //   const owner = await helper.eth.createAccountWithBalance(donor);100        101  //   const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');102  //   const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);103104  //   const admin1 = helper.eth.createAccount();105  //   const admin2 = await 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});
modifiedtests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth
--- a/tests/src/eth/collectionHelpersAbi.json
+++ b/tests/src/eth/collectionHelpersAbi.json
@@ -62,6 +62,18 @@
   },
   {
     "inputs": [
+      { "internalType": "string", "name": "name", "type": "string" },
+      { "internalType": "uint8", "name": "decimals", "type": "uint8" },
+      { "internalType": "string", "name": "description", "type": "string" },
+      { "internalType": "string", "name": "tokenPrefix", "type": "string" }
+    ],
+    "name": "createRTCollection",
+    "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+    "stateMutability": "payable",
+    "type": "function"
+  },
+  {
+    "inputs": [
       {
         "internalType": "address",
         "name": "collectionAddress",
modifiedtests/src/eth/collectionProperties.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -14,9 +14,9 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper, EthUniqueHelper} from './util';
+import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';
 import {Pallets} from '../util';
-import {IProperty, ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';
+import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';
 import {IKeyringPair} from '@polkadot/types/types';
 import {TCollectionMode} from '../util/playgrounds/types';
 
addedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -0,0 +1,254 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {IKeyringPair} from '@polkadot/types/types';
+import {Pallets, requirePalletsOrSkip} from '../util';
+import {expect, itEth, usingEthPlaygrounds} from './util';
+
+const DECIMALS = 18;
+
+describe('Create FT collection from EVM', () => {
+  let donor: IKeyringPair;
+
+  before(async function() {
+    await usingEthPlaygrounds(async (helper, privateKey) => {
+      requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+      donor = await privateKey('//Alice');
+    });
+  });
+
+  itEth('Create collection', async ({helper}) => {
+    const owner = await helper.eth.createAccountWithBalance(donor);
+    
+    const name = 'CollectionEVM';
+    const description = 'Some description';
+    const prefix = 'token prefix';
+  
+    // todo:playgrounds this might fail when in async environment.
+    const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
+    
+    const collectionCreationPrice = helper.balance.getCollectionCreationPrice();
+    const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+        
+    const result = await collectionHelper.methods.createRTCollection(name, DECIMALS, description, prefix).call({value: Number(collectionCreationPrice)});
+    console.log(result);
+    const {collectionId} = await helper.eth.createFungibleCollection(owner, name, DECIMALS,  description, prefix);
+    const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;
+  
+    const data = (await helper.ft.getData(collectionId))!;
+
+    expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);
+    expect(collectionId).to.be.eq(collectionCountAfter);
+    expect(data.name).to.be.eq(name);
+    expect(data.description).to.be.eq(description);
+    expect(data.raw.tokenPrefix).to.be.eq(prefix);
+    expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});
+  });
+
+  // // todo:playgrounds this test will fail when in async environment.
+  // itEth('Check collection address exist', async ({helper}) => {
+  //   const owner = await helper.eth.createAccountWithBalance(donor);
+
+  //   const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;
+  //   const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);
+  //   const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);
+
+  //   expect(await collectionHelpers.methods
+  //     .isCollectionExist(expectedCollectionAddress)
+  //     .call()).to.be.false;
+
+  //   await collectionHelpers.methods
+  //     .createRFTCollection('A', 'A', 'A')
+  //     .send({value: Number(2n * helper.balance.getOneTokenNominal())});
+    
+  //   expect(await collectionHelpers.methods
+  //     .isCollectionExist(expectedCollectionAddress)
+  //     .call()).to.be.true;
+  // });
+  
+  // itEth('Set sponsorship', async ({helper}) => {
+  //   const owner = await helper.eth.createAccountWithBalance(donor);
+  //   const sponsor = await helper.eth.createAccountWithBalance(donor);
+  //   const ss58Format = helper.chain.getChainProperties().ss58Format;
+  //   const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');
+
+  //   const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
+  //   await collection.methods.setCollectionSponsor(sponsor).send();
+
+  //   let data = (await helper.rft.getData(collectionId))!;
+  //   expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
+
+  //   await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
+
+  //   const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);
+  //   await sponsorCollection.methods.confirmCollectionSponsorship().send();
+
+  //   data = (await helper.rft.getData(collectionId))!;
+  //   expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
+  // });
+
+  // itEth('Set limits', async ({helper}) => {
+  //   const owner = await helper.eth.createAccountWithBalance(donor);
+  //   const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'INSI');
+  //   const limits = {
+  //     accountTokenOwnershipLimit: 1000,
+  //     sponsoredDataSize: 1024,
+  //     sponsoredDataRateLimit: 30,
+  //     tokenLimit: 1000000,
+  //     sponsorTransferTimeout: 6,
+  //     sponsorApproveTimeout: 6,
+  //     ownerCanTransfer: false,
+  //     ownerCanDestroy: false,
+  //     transfersEnabled: false,
+  //   };
+
+  //   const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
+  //   await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();
+  //   await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();
+  //   await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();
+  //   await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();
+  //   await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();
+  //   await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();
+  //   await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();
+  //   await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();
+  //   await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();
+    
+  //   const data = (await helper.rft.getData(collectionId))!;
+  //   expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);
+  //   expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);
+  //   expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);
+  //   expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);
+  //   expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);
+  //   expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);
+  //   expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);
+  //   expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);
+  //   expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);
+  // });
+
+  // itEth('Collection address exist', async ({helper}) => {
+  //   const owner = await helper.eth.createAccountWithBalance(donor);
+  //   const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';
+  //   expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)
+  //     .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())
+  //     .to.be.false;
+    
+  //   const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Exister', 'absolutely anything', 'WIWT');
+  //   expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)
+  //     .methods.isCollectionExist(collectionAddress).call())
+  //     .to.be.true;
+  // });
+});
+
+// describe('(!negative tests!) Create RFT collection from EVM', () => {
+//   let donor: IKeyringPair;
+//   let nominal: bigint;
+
+//   before(async function() {
+//     await usingEthPlaygrounds(async (helper, privateKey) => {
+//       requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);
+//       donor = privateKey('//Alice');
+//       nominal = helper.balance.getOneTokenNominal();
+//     });
+//   });
+
+//   itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {
+//     const owner = await helper.eth.createAccountWithBalance(donor);
+//     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+//     {
+//       const MAX_NAME_LENGTH = 64;
+//       const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);
+//       const description = 'A';
+//       const tokenPrefix = 'A';
+
+//       await expect(collectionHelper.methods
+//         .createRFTCollection(collectionName, description, tokenPrefix)
+//         .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
+//     }
+//     {
+//       const MAX_DESCRIPTION_LENGTH = 256;
+//       const collectionName = 'A';
+//       const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);
+//       const tokenPrefix = 'A';
+//       await expect(collectionHelper.methods
+//         .createRFTCollection(collectionName, description, tokenPrefix)
+//         .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
+//     }
+//     {
+//       const MAX_TOKEN_PREFIX_LENGTH = 16;
+//       const collectionName = 'A';
+//       const description = 'A';
+//       const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);
+//       await expect(collectionHelper.methods
+//         .createRFTCollection(collectionName, description, tokenPrefix)
+//         .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
+//     }
+//   });
+  
+//   itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {
+//     const owner = await helper.eth.createAccountWithBalance(donor);
+//     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+//     await expect(collectionHelper.methods
+//       .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')
+//       .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
+//   });
+
+//   itEth('(!negative test!) Check owner', async ({helper}) => {
+//     const owner = await helper.eth.createAccountWithBalance(donor);
+//     const peasant = helper.eth.createAccount();
+//     const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');
+//     const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);
+//     const EXPECTED_ERROR = 'NoPermission';
+//     {
+//       const sponsor = await helper.eth.createAccountWithBalance(donor);
+//       await expect(peasantCollection.methods
+//         .setCollectionSponsor(sponsor)
+//         .call()).to.be.rejectedWith(EXPECTED_ERROR);
+      
+//       const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);
+//       await expect(sponsorCollection.methods
+//         .confirmCollectionSponsorship()
+//         .call()).to.be.rejectedWith('caller is not set as sponsor');
+//     }
+//     {
+//       await expect(peasantCollection.methods
+//         .setCollectionLimit('account_token_ownership_limit', '1000')
+//         .call()).to.be.rejectedWith(EXPECTED_ERROR);
+//     }
+//   });
+
+//   itEth('(!negative test!) Set limits', async ({helper}) => {
+//     const owner = await helper.eth.createAccountWithBalance(donor);
+//     const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'ISNI');
+//     const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
+//     await expect(collectionEvm.methods
+//       .setCollectionLimit('badLimit', 'true')
+//       .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
+//   });
+  
+//   itEth('destroyCollection test', async ({helper}) => {
+//     const owner = await helper.eth.createAccountWithBalance(donor);
+//     const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'OLF');
+//     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
+    
+//     await expect(collectionHelper.methods
+//       .destroyCollection(collectionAddress)
+//       .send({from: owner})).to.be.fulfilled;
+    
+//     expect(await collectionHelper.methods
+//       .isCollectionExist(collectionAddress)
+//       .call()).to.be.false;  
+//   });
+// });
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -202,10 +202,24 @@
     return {collectionId, collectionAddress, events};
   }
 
-  async createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {
+  async createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {
     return this.createCollecion('createRFTCollection', signer, name, description, tokenPrefix);
   }
+  
+  async createFungibleCollection(signer: string, name: string, decimals: number, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {
+    const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();
+    const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);
+        
+    const result = await collectionHelper.methods.createRTCollection(name, decimals, description, tokenPrefix).send({value: Number(collectionCreationPrice)});
 
+    const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
+    const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);
+    
+    const events = this.helper.eth.normalizeEvents(result.events);
+    
+    return {collectionId, collectionAddress, events};
+  }
+  
   async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {
     const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);