difftreelog
added tests for `createRTCollection` , refactor `Unique` pallet code
in: master
9 files changed
pallets/unique/CHANGELOG.mddiffbeforeafterboth--- a/pallets/unique/CHANGELOG.md
+++ b/pallets/unique/CHANGELOG.md
@@ -8,7 +8,7 @@
### Changes
-- Addded **CollectionHelpers** method `destroyCollection`.
+- Added `destroyCollection` and `createFTCollection` methods to **CollectionHelpers**.
## [v0.2.0] 2022-09-13
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -18,7 +18,7 @@
use core::marker::PhantomData;
use ethereum as _;
-use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};
+use evm_coder::{execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
use frame_support::traits::Get;
use crate::Pallet;
@@ -27,23 +27,24 @@
CollectionById,
dispatch::CollectionDispatch,
erc::{
+ static_property::key,
CollectionHelpersEvents,
- static_property::{key},
},
Pallet as PalletCommon,
+
};
+use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
use pallet_evm_coder_substrate::{dispatch_to_evm, SubstrateRecorder, WithRecorder};
-use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};
use sp_std::vec;
use up_data_structs::{
- CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,
- CollectionMode, PropertyValue,
+ CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,
+ CreateCollectionData, PropertyValue,
};
-use crate::{Config, SelfWeightOf, weights::WeightInfo};
+use crate::{weights::WeightInfo, Config, SelfWeightOf};
-use sp_std::vec::Vec;
use alloc::format;
+use sp_std::vec::Vec;
/// See [`CollectionHelpersCall`]
pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);
@@ -104,6 +105,7 @@
)
}
+#[inline(always)]
fn create_collection_internal<T: Config>(
caller: caller,
value: value,
@@ -212,7 +214,14 @@
description: string,
token_prefix: string,
) -> Result<address> {
- self.create_nft_collection(caller, value, name, description, token_prefix)
+ create_collection_internal::<T>(
+ caller,
+ value,
+ name,
+ CollectionMode::NFT,
+ description,
+ token_prefix,
+ )
}
#[weight(<SelfWeightOf<T>>::create_collection())]
@@ -225,11 +234,39 @@
description: string,
token_prefix: string,
) -> Result<address> {
- create_refungible_collection_internal::<T>(caller, value, name, description, token_prefix)
+ create_collection_internal::<T>(
+ caller,
+ value,
+ name,
+ CollectionMode::ReFungible,
+ description,
+ token_prefix,
+ )
+ }
+
+ #[weight(<SelfWeightOf<T>>::create_collection())]
+ #[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]
+ fn create_refungible_collection_with_properties(
+ &mut self,
+ caller: caller,
+ value: value,
+ name: string,
+ description: string,
+ token_prefix: string,
+ base_uri: string,
+ ) -> Result<address> {
+ create_collection_internal::<T>(
+ caller,
+ value,
+ name,
+ CollectionMode::ReFungible,
+ description,
+ token_prefix,
+ )
}
#[weight(<SelfWeightOf<T>>::create_collection())]
- #[solidity(rename_selector = "createRTCollection")]
+ #[solidity(rename_selector = "createFTCollection")]
fn create_fungible_collection(
&mut self,
caller: caller,
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 0xa2c196ab
+/// @dev the ERC-165 identifier for this interface is 0xd8b36039
contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
/// Create an NFT collection
/// @param name Name of the collection
@@ -77,9 +77,26 @@
return 0x0000000000000000000000000000000000000000;
}
- /// @dev EVM selector for this function is: 0xac1e2285,
- /// or in textual repr: createRTCollection(string,uint8,string,string)
- function createRTCollection(
+ /// @dev EVM selector for this function is: 0xa5596388,
+ /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)
+ function createERC721MetadataCompatibleRFTCollection(
+ string memory name,
+ string memory description,
+ string memory tokenPrefix,
+ string memory baseUri
+ ) public payable returns (address) {
+ require(false, stub_error);
+ name;
+ description;
+ tokenPrefix;
+ baseUri;
+ dummy = 0;
+ return 0x0000000000000000000000000000000000000000;
+ }
+
+ /// @dev EVM selector for this function is: 0x7335b79f,
+ /// or in textual repr: createFTCollection(string,uint8,string,string)
+ function createFTCollection(
string memory name,
uint8 decimals,
string memory description,
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 0xa2c196ab
+/// @dev the ERC-165 identifier for this interface is 0xd8b36039
interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
/// Create an NFT collection
/// @param name Name of the collection
@@ -51,9 +51,18 @@
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(
+ /// @dev EVM selector for this function is: 0xa5596388,
+ /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)
+ function createERC721MetadataCompatibleRFTCollection(
+ string memory name,
+ string memory description,
+ string memory tokenPrefix,
+ string memory baseUri
+ ) external payable returns (address);
+
+ /// @dev EVM selector for this function is: 0x7335b79f,
+ /// or in textual repr: createFTCollection(string,uint8,string,string)
+ function createFTCollection(
string memory name,
uint8 decimals,
string memory description,
tests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth--- a/tests/src/eth/collectionHelpersAbi.json
+++ b/tests/src/eth/collectionHelpersAbi.json
@@ -42,9 +42,22 @@
"inputs": [
{ "internalType": "string", "name": "name", "type": "string" },
{ "internalType": "string", "name": "description", "type": "string" },
+ { "internalType": "string", "name": "tokenPrefix", "type": "string" },
+ { "internalType": "string", "name": "baseUri", "type": "string" }
+ ],
+ "name": "createERC721MetadataCompatibleRFTCollection",
+ "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
+ "stateMutability": "payable",
+ "type": "function"
+ },
+ {
+ "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": "createNFTCollection",
+ "name": "createFTCollection",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "payable",
"type": "function"
@@ -55,7 +68,7 @@
{ "internalType": "string", "name": "description", "type": "string" },
{ "internalType": "string", "name": "tokenPrefix", "type": "string" }
],
- "name": "createRFTCollection",
+ "name": "createNFTCollection",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "payable",
"type": "function"
@@ -63,11 +76,10 @@
{
"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",
+ "name": "createRFTCollection",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "payable",
"type": "function"
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import { evmToAddress } from '@polkadot/util-crypto';18import {Pallets, requirePalletsOrSkip} from '../util';19import {Pallets, requirePalletsOrSkip} from '../util';19import {expect, itEth, usingEthPlaygrounds} from './util';20import {expect, itEth, usingEthPlaygrounds} from './util';2021252626 before(async function() {27 before(async function() {27 await usingEthPlaygrounds(async (helper, privateKey) => {28 await usingEthPlaygrounds(async (helper, privateKey) => {28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);29 requirePalletsOrSkip(this, helper, [Pallets.Fungible]);29 donor = await privateKey('//Alice');30 donor = await privateKey('//Alice');30 });31 });31 });32 });40 // todo:playgrounds this might fail when in async environment.41 // todo:playgrounds this might fail when in async environment.41 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;42 const collectionCountBefore = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;42 4343 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);44 const {collectionId} = await helper.eth.createFungibleCollection(owner, name, DECIMALS, description, prefix);45 49 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;46 const collectionCountAfter = +(await helper.callRpc('api.rpc.unique.collectionStats')).created;58 expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});54 expect(data.raw.mode).to.be.deep.eq({Fungible: DECIMALS.toString()});59 });55 });605661 // // todo:playgrounds this test will fail when in async environment.57 // todo:playgrounds this test will fail when in async environment.62 // itEth('Check collection address exist', async ({helper}) => {58 itEth('Check collection address exist', async ({helper}) => {63 // const owner = await helper.eth.createAccountWithBalance(donor);59 const owner = await helper.eth.createAccountWithBalance(donor);646065 // const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;61 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;66 // const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);62 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);67 // const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);63 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);686469 // expect(await collectionHelpers.methods65 expect(await collectionHelpers.methods70 // .isCollectionExist(expectedCollectionAddress)66 .isCollectionExist(expectedCollectionAddress)71 // .call()).to.be.false;67 .call()).to.be.false;726873 // await collectionHelpers.methods69 74 // .createRFTCollection('A', 'A', 'A')70 await helper.eth.createFungibleCollection(owner, 'A', DECIMALS, 'A', 'A');75 // .send({value: Number(2n * helper.balance.getOneTokenNominal())});7176 72 77 // expect(await collectionHelpers.methods73 expect(await collectionHelpers.methods78 // .isCollectionExist(expectedCollectionAddress)74 .isCollectionExist(expectedCollectionAddress)79 // .call()).to.be.true;75 .call()).to.be.true;80 // });76 });81 77 82 // itEth('Set sponsorship', async ({helper}) => {78 itEth('Set sponsorship', async ({helper}) => {83 // const owner = await helper.eth.createAccountWithBalance(donor);79 const owner = await helper.eth.createAccountWithBalance(donor);84 // const sponsor = await helper.eth.createAccountWithBalance(donor);80 const sponsor = await helper.eth.createAccountWithBalance(donor);85 // const ss58Format = helper.chain.getChainProperties().ss58Format;81 const ss58Format = helper.chain.getChainProperties().ss58Format;86 // const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');82 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, 'absolutely anything', 'ENVY');878388 // const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);84 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);89 // await collection.methods.setCollectionSponsor(sponsor).send();85 await collection.methods.setCollectionSponsor(sponsor).send();908691 // let data = (await helper.rft.getData(collectionId))!;87 let data = (await helper.rft.getData(collectionId))!;92 // expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));88 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));938994 // await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');90 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');959196 // const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);92 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);97 // await sponsorCollection.methods.confirmCollectionSponsorship().send();93 await sponsorCollection.methods.confirmCollectionSponsorship().send();989499 // data = (await helper.rft.getData(collectionId))!;95 data = (await helper.rft.getData(collectionId))!;100 // expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));96 expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));101 // });97 });10298103 // itEth('Set limits', async ({helper}) => {99 itEth('Set limits', async ({helper}) => {104 // const owner = await helper.eth.createAccountWithBalance(donor);100 const owner = await helper.eth.createAccountWithBalance(donor);105 // const {collectionId, collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'INSI');101 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'INSI');106 // const limits = {102 const limits = {107 // accountTokenOwnershipLimit: 1000,103 accountTokenOwnershipLimit: 1000,108 // sponsoredDataSize: 1024,104 sponsoredDataSize: 1024,109 // sponsoredDataRateLimit: 30,105 sponsoredDataRateLimit: 30,110 // tokenLimit: 1000000,106 tokenLimit: 1000000,111 // sponsorTransferTimeout: 6,107 sponsorTransferTimeout: 6,112 // sponsorApproveTimeout: 6,108 sponsorApproveTimeout: 6,113 // ownerCanTransfer: false,109 ownerCanTransfer: false,114 // ownerCanDestroy: false,110 ownerCanDestroy: false,115 // transfersEnabled: false,111 transfersEnabled: false,116 // };112 };117113118 // const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);114 const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);119 // await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();115 await collection.methods['setCollectionLimit(string,uint32)']('accountTokenOwnershipLimit', limits.accountTokenOwnershipLimit).send();120 // await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();116 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataSize', limits.sponsoredDataSize).send();121 // await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();117 await collection.methods['setCollectionLimit(string,uint32)']('sponsoredDataRateLimit', limits.sponsoredDataRateLimit).send();122 // await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();118 await collection.methods['setCollectionLimit(string,uint32)']('tokenLimit', limits.tokenLimit).send();123 // await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();119 await collection.methods['setCollectionLimit(string,uint32)']('sponsorTransferTimeout', limits.sponsorTransferTimeout).send();124 // await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();120 await collection.methods['setCollectionLimit(string,uint32)']('sponsorApproveTimeout', limits.sponsorApproveTimeout).send();125 // await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();121 await collection.methods['setCollectionLimit(string,bool)']('ownerCanTransfer', limits.ownerCanTransfer).send();126 // await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();122 await collection.methods['setCollectionLimit(string,bool)']('ownerCanDestroy', limits.ownerCanDestroy).send();127 // await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();123 await collection.methods['setCollectionLimit(string,bool)']('transfersEnabled', limits.transfersEnabled).send();128 124 129 // const data = (await helper.rft.getData(collectionId))!;125 const data = (await helper.rft.getData(collectionId))!;130 // expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);126 expect(data.raw.limits.accountTokenOwnershipLimit).to.be.eq(limits.accountTokenOwnershipLimit);131 // expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);127 expect(data.raw.limits.sponsoredDataSize).to.be.eq(limits.sponsoredDataSize);132 // expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);128 expect(data.raw.limits.sponsoredDataRateLimit.blocks).to.be.eq(limits.sponsoredDataRateLimit);133 // expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);129 expect(data.raw.limits.tokenLimit).to.be.eq(limits.tokenLimit);134 // expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);130 expect(data.raw.limits.sponsorTransferTimeout).to.be.eq(limits.sponsorTransferTimeout);135 // expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);131 expect(data.raw.limits.sponsorApproveTimeout).to.be.eq(limits.sponsorApproveTimeout);136 // expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);132 expect(data.raw.limits.ownerCanTransfer).to.be.eq(limits.ownerCanTransfer);137 // expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);133 expect(data.raw.limits.ownerCanDestroy).to.be.eq(limits.ownerCanDestroy);138 // expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);134 expect(data.raw.limits.transfersEnabled).to.be.eq(limits.transfersEnabled);139 // });135 });140136141 // itEth('Collection address exist', async ({helper}) => {137 itEth('Collection address exist', async ({helper}) => {142 // const owner = await helper.eth.createAccountWithBalance(donor);138 const owner = await helper.eth.createAccountWithBalance(donor);143 // const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';139 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';144 // expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)140 expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)145 // .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())141 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())146 // .to.be.false;142 .to.be.false;147 143 148 // const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Exister', 'absolutely anything', 'WIWT');144 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');149 // expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)145 expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)150 // .methods.isCollectionExist(collectionAddress).call())146 .methods.isCollectionExist(collectionAddress).call())151 // .to.be.true;147 .to.be.true;152 // });148 });149 150 itEth('destroyCollection', async ({helper}) => {151 const owner = await helper.eth.createAccountWithBalance(donor);152 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');153 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);154155 const result = await collectionHelper.methods156 .destroyCollection(collectionAddress)157 .send({from: owner});158159 const events = helper.eth.normalizeEvents(result.events);160 161 expect(events).to.be.deep.equal([162 {163 address: collectionHelper.options.address,164 event: 'CollectionDestroyed',165 args: {166 collectionId: collectionAddress,167 },168 },169 ]);170171 expect(await collectionHelper.methods172 .isCollectionExist(collectionAddress)173 .call()).to.be.false;174 });153});175});154176155// describe('(!negative tests!) Create RFT collection from EVM', () => {177describe('(!negative tests!) Create FT collection from EVM', () => {156// let donor: IKeyringPair;178 let donor: IKeyringPair;157// let nominal: bigint;179 let nominal: bigint;158180159// before(async function() {181 before(async function() {160// await usingEthPlaygrounds(async (helper, privateKey) => {182 await usingEthPlaygrounds(async (helper, privateKey) => {161// requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);183 requirePalletsOrSkip(this, helper, [Pallets.Fungible]);162// donor = privateKey('//Alice');184 donor = await privateKey('//Alice');163// nominal = helper.balance.getOneTokenNominal();185 nominal = helper.balance.getOneTokenNominal();164// });186 });165// });187 });166188167// itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {189 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {168// const owner = await helper.eth.createAccountWithBalance(donor);190 const owner = await helper.eth.createAccountWithBalance(donor);169// const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);191 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);170// {192 {171// const MAX_NAME_LENGTH = 64;193 const MAX_NAME_LENGTH = 64;172// const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);194 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);173// const description = 'A';195 const description = 'A';174// const tokenPrefix = 'A';196 const tokenPrefix = 'A';175197176// await expect(collectionHelper.methods198 await expect(collectionHelper.methods177// .createRFTCollection(collectionName, description, tokenPrefix)199 .createFTCollection(collectionName, DECIMALS, description, tokenPrefix)178// .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);200 .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);179// }201 }180// {202 {181// const MAX_DESCRIPTION_LENGTH = 256;203 const MAX_DESCRIPTION_LENGTH = 256;182// const collectionName = 'A';204 const collectionName = 'A';183// const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);205 const description = 'A'.repeat(MAX_DESCRIPTION_LENGTH + 1);184// const tokenPrefix = 'A';206 const tokenPrefix = 'A';185// await expect(collectionHelper.methods207 await expect(collectionHelper.methods186// .createRFTCollection(collectionName, description, tokenPrefix)208 .createFTCollection(collectionName, DECIMALS, description, tokenPrefix)187// .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);209 .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);188// }210 }189// {211 {190// const MAX_TOKEN_PREFIX_LENGTH = 16;212 const MAX_TOKEN_PREFIX_LENGTH = 16;191// const collectionName = 'A';213 const collectionName = 'A';192// const description = 'A';214 const description = 'A';193// const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);215 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);194// await expect(collectionHelper.methods216 await expect(collectionHelper.methods195// .createRFTCollection(collectionName, description, tokenPrefix)217 .createFTCollection(collectionName, DECIMALS, description, tokenPrefix)196// .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);218 .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);197// }219 }198// });220 });199 221 200// itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {222 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {201// const owner = await helper.eth.createAccountWithBalance(donor);223 const owner = await helper.eth.createAccountWithBalance(donor);202// const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);224 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);203// await expect(collectionHelper.methods225 await expect(collectionHelper.methods204// .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')226 .createFTCollection('Peasantry', DECIMALS, 'absolutely anything', 'TWIW')205// .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');227 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');206// });228 });207229208// itEth('(!negative test!) Check owner', async ({helper}) => {230 itEth('(!negative test!) Check owner', async ({helper}) => {209// const owner = await helper.eth.createAccountWithBalance(donor);231 const owner = await helper.eth.createAccountWithBalance(donor);210// const peasant = helper.eth.createAccount();232 const peasant = helper.eth.createAccount();211// const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');233 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');212// const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);234 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant);213// const EXPECTED_ERROR = 'NoPermission';235 const EXPECTED_ERROR = 'NoPermission';214// {236 {215// const sponsor = await helper.eth.createAccountWithBalance(donor);237 const sponsor = await helper.eth.createAccountWithBalance(donor);216// await expect(peasantCollection.methods238 await expect(peasantCollection.methods217// .setCollectionSponsor(sponsor)239 .setCollectionSponsor(sponsor)218// .call()).to.be.rejectedWith(EXPECTED_ERROR);240 .call()).to.be.rejectedWith(EXPECTED_ERROR);219 241 220// const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);242 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor);221// await expect(sponsorCollection.methods243 await expect(sponsorCollection.methods222// .confirmCollectionSponsorship()244 .confirmCollectionSponsorship()223// .call()).to.be.rejectedWith('caller is not set as sponsor');245 .call()).to.be.rejectedWith('caller is not set as sponsor');224// }246 }225// {247 {226// await expect(peasantCollection.methods248 await expect(peasantCollection.methods227// .setCollectionLimit('account_token_ownership_limit', '1000')249 .setCollectionLimit('account_token_ownership_limit', '1000')228// .call()).to.be.rejectedWith(EXPECTED_ERROR);250 .call()).to.be.rejectedWith(EXPECTED_ERROR);229// }251 }230// });252 });231253232// itEth('(!negative test!) Set limits', async ({helper}) => {254 itEth('(!negative test!) Set limits', async ({helper}) => {233// const owner = await helper.eth.createAccountWithBalance(donor);255 const owner = await helper.eth.createAccountWithBalance(donor);234// const {collectionAddress} = await helper.eth.createRefungibleCollection(owner, 'Limits', 'absolutely anything', 'ISNI');256 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Limits', DECIMALS, 'absolutely anything', 'ISNI');235// const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);257 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);236// await expect(collectionEvm.methods258 await expect(collectionEvm.methods237// .setCollectionLimit('badLimit', 'true')259 .setCollectionLimit('badLimit', 'true')238// .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');260 .call()).to.be.rejectedWith('unknown boolean limit "badLimit"');239// });261 });240 262});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// });255263tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -264,7 +264,7 @@
.call()).to.be.rejectedWith('unknown boolean limit "badLimit"');
});
- itEth('destroyCollection test', async ({helper}) => {
+ itEth('destroyCollection', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');
const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
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
@@ -210,8 +210,7 @@
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 result = await collectionHelper.methods.createFTCollection(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);