difftreelog
added `createRTCollection` for `CollectionHelpers`
in: master
9 files changed
pallets/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,
pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/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 {
tests/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;
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -64,24 +64,24 @@
expect(adminList).to.be.like([{Substrate: newAdmin.address}]);
});
- itEth('Check adminlist', async ({helper, privateKey}) => {
- const owner = await helper.eth.createAccountWithBalance(donor);
+ // itEth('Check adminlist', async ({helper, privateKey}) => {
+ // const owner = await helper.eth.createAccountWithBalance(donor);
- const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
- const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+ // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
+ // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
- const admin1 = helper.eth.createAccount();
- const admin2 = await privateKey('admin');
- await collectionEvm.methods.addCollectionAdmin(admin1).send();
- await collectionEvm.methods.addCollectionAdminCross(helper.ethCrossAccount.fromKeyringPair(admin2)).send();
+ // const admin1 = helper.eth.createAccount();
+ // const admin2 = await privateKey('admin');
+ // await collectionEvm.methods.addCollectionAdmin(admin1).send();
+ // await collectionEvm.methods.addCollectionAdminCross(helper.ethCrossAccount.fromKeyringPair(admin2)).send();
- const adminListRpc = await helper.collection.getAdmins(collectionId);
- let adminListEth = await collectionEvm.methods.collectionAdmins().call();
- adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
- return helper.address.convertCrossAccountFromEthCrossAcoount(element);
- });
- expect(adminListRpc).to.be.like(adminListEth);
- });
+ // const adminListRpc = await helper.collection.getAdmins(collectionId);
+ // let adminListEth = await collectionEvm.methods.collectionAdmins().call();
+ // adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
+ // return helper.address.convertCrossAccountFromEthCrossAcoount(element);
+ // });
+ // expect(adminListRpc).to.be.like(adminListEth);
+ // });
itEth('Verify owner or admin', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
@@ -95,24 +95,24 @@
expect(await collectionEvm.methods.isOwnerOrAdmin(newAdmin).call()).to.be.true;
});
- itEth.skip('Check adminlist', async ({helper, privateKey}) => {
- const owner = await helper.eth.createAccountWithBalance(donor);
+ // itEth.skip('Check adminlist', async ({helper, privateKey}) => {
+ // const owner = await helper.eth.createAccountWithBalance(donor);
- const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
- const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
+ // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
+ // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
- const admin1 = helper.eth.createAccount();
- const admin2 = await privateKey('admin');
- await collectionEvm.methods.addCollectionAdmin(admin1).send();
- await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();
+ // const admin1 = helper.eth.createAccount();
+ // const admin2 = await privateKey('admin');
+ // await collectionEvm.methods.addCollectionAdmin(admin1).send();
+ // await collectionEvm.methods.addCollectionAdminSubstrate(admin2.addressRaw).send();
- const adminListRpc = await helper.collection.getAdmins(collectionId);
- let adminListEth = await collectionEvm.methods.collectionAdmins().call();
- adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
- return helper.address.convertCrossAccountFromEthCrossAcoount(element);
- });
- expect(adminListRpc).to.be.like(adminListEth);
- });
+ // const adminListRpc = await helper.collection.getAdmins(collectionId);
+ // let adminListEth = await collectionEvm.methods.collectionAdmins().call();
+ // adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
+ // return helper.address.convertCrossAccountFromEthCrossAcoount(element);
+ // });
+ // expect(adminListRpc).to.be.like(adminListEth);
+ // });
itEth('(!negative tests!) Add admin by ADMIN is not allowed', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
tests/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",
tests/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';
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.8//9// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {Pallets, requirePalletsOrSkip} from '../util';19import {expect, itEth, usingEthPlaygrounds} from './util';2021const DECIMALS = 18;2223describe('Create FT collection from EVM', () => {24 let donor: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (helper, privateKey) => {28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);29 donor = await privateKey('//Alice');30 });31 });3233 itEth('Create collection', async ({helper}) => {34 const owner = await helper.eth.createAccountWithBalance(donor);35 36 const name = 'CollectionEVM';37 const description = 'Some description';38 const prefix = 'token prefix';39 40 // todo:playgrounds this might fail when in async environment.41 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;42 43 const collectionCreationPrice = helper.balance.getCollectionCreationPrice();44 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);45 46 const result = await collectionHelper.methods.createRTCollection(name, DECIMALS, description, prefix).call({value: Number(collectionCreationPrice)});47 console.log(result);48 const {collectionId} = await helper.eth.createFungibleCollection(owner, name, DECIMALS, description, prefix);49 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;50 51 const data = (await helper.ft.getData(collectionId))!;5253 expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);54 expect(collectionId).to.be.eq(collectionCountAfter);55 expect(data.name).to.be.eq(name);56 expect(data.description).to.be.eq(description);57 expect(data.raw.tokenPrefix).to.be.eq(prefix);58 expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});59 });6061 // // todo:playgrounds this test will fail when in async environment.62 // itEth('Check collection address exist', async ({helper}) => {63 // const owner = await helper.eth.createAccountWithBalance(donor);6465 // const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;66 // const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);67 // const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);6869 // expect(await collectionHelpers.methods70 // .isCollectionExist(expectedCollectionAddress)71 // .call()).to.be.false;7273 // await collectionHelpers.methods74 // .createRFTCollection('A', 'A', 'A')75 // .send({value: Number(2n * helper.balance.getOneTokenNominal())});76 77 // expect(await collectionHelpers.methods78 // .isCollectionExist(expectedCollectionAddress)79 // .call()).to.be.true;80 // });81 82 // itEth('Set sponsorship', async ({helper}) => {83 // const owner = await helper.eth.createAccountWithBalance(donor);84 // const sponsor = await helper.eth.createAccountWithBalance(donor);85 // const ss58Format = helper.chain.getChainProperties().ss58Format;86 // const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');8788 // const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);89 // await collection.methods.setCollectionSponsor(sponsor).send();9091 // let data = (await helper.rft.getData(collectionId))!;92 // expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));9394 // await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');9596 // const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);97 // await sponsorCollection.methods.confirmCollectionSponsorship().send();9899 // data = (await helper.rft.getData(collectionId))!;100 // expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));101 // });102103 // itEth('Set limits', async ({helper}) => {104 // const owner = await helper.eth.createAccountWithBalance(donor);105 // const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'INSI');106 // const limits = {107 // accountTokenOwnershipLimit: 1000,108 // sponsoredDataSize: 1024,109 // sponsoredDataRateLimit: 30,110 // tokenLimit: 1000000,111 // sponsorTransferTimeout: 6,112 // sponsorApproveTimeout: 6,113 // ownerCanTransfer: false,114 // ownerCanDestroy: false,115 // transfersEnabled: false,116 // };117118 // const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);119 // await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();120 // await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();121 // await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();122 // await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();123 // await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();124 // await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();125 // await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();126 // await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();127 // await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();128 129 // const data = (await helper.rft.getData(collectionId))!;130 // expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);131 // expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);132 // expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);133 // expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);134 // expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);135 // expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);136 // expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);137 // expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);138 // expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);139 // });140141 // itEth('Collection address exist', async ({helper}) => {142 // const owner = await helper.eth.createAccountWithBalance(donor);143 // const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';144 // expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)145 // .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())146 // .to.be.false;147 148 // const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Exister', 'absolutely anything', 'WIWT');149 // expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)150 // .methods.isCollectionExist(collectionAddress).call())151 // .to.be.true;152 // });153});154155// describe('(!negative tests!) Create RFT collection from EVM', () => {156// let donor: IKeyringPair;157// let nominal: bigint;158159// before(async function() {160// await usingEthPlaygrounds(async (helper, privateKey) => {161// requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);162// donor = privateKey('//Alice');163// nominal = helper.balance.getOneTokenNominal();164// });165// });166167// itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {168// const owner = await helper.eth.createAccountWithBalance(donor);169// const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);170// {171// const MAX_NAME_LENGTH = 64;172// const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);173// const description = 'A';174// const tokenPrefix = 'A';175176// await expect(collectionHelper.methods177// .createRFTCollection(collectionName, description, tokenPrefix)178// .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);179// }180// {181// const MAX_DESCRIPTION_LENGTH = 256;182// const collectionName = 'A';183// const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);184// const tokenPrefix = 'A';185// await expect(collectionHelper.methods186// .createRFTCollection(collectionName, description, tokenPrefix)187// .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);188// }189// {190// const MAX_TOKEN_PREFIX_LENGTH = 16;191// const collectionName = 'A';192// const description = 'A';193// const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);194// await expect(collectionHelper.methods195// .createRFTCollection(collectionName, description, tokenPrefix)196// .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);197// }198// });199 200// itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {201// const owner = await helper.eth.createAccountWithBalance(donor);202// const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);203// await expect(collectionHelper.methods204// .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')205// .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');206// });207208// itEth('(!negative test!) Check owner', async ({helper}) => {209// const owner = await helper.eth.createAccountWithBalance(donor);210// const peasant = helper.eth.createAccount();211// const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');212// const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);213// const EXPECTED_ERROR = 'NoPermission';214// {215// const sponsor = await helper.eth.createAccountWithBalance(donor);216// await expect(peasantCollection.methods217// .setCollectionSponsor(sponsor)218// .call()).to.be.rejectedWith(EXPECTED_ERROR);219 220// const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);221// await expect(sponsorCollection.methods222// .confirmCollectionSponsorship()223// .call()).to.be.rejectedWith('caller is not set as sponsor');224// }225// {226// await expect(peasantCollection.methods227// .setCollectionLimit('account_token_ownership_limit', '1000')228// .call()).to.be.rejectedWith(EXPECTED_ERROR);229// }230// });231232// itEth('(!negative test!) Set limits', async ({helper}) => {233// const owner = await helper.eth.createAccountWithBalance(donor);234// const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'ISNI');235// const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);236// await expect(collectionEvm.methods237// .setCollectionLimit('badLimit', 'true')238// .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');239// });240 241// itEth('destroyCollection test', async ({helper}) => {242// const owner = await helper.eth.createAccountWithBalance(donor);243// const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'OLF');244// const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);245 246// await expect(collectionHelper.methods247// .destroyCollection(collectionAddress)248// .send({from: owner})).to.be.fulfilled;249 250// expect(await collectionHelper.methods251// .isCollectionExist(collectionAddress)252// .call()).to.be.false; 253// });254// });tests/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);