difftreelog
test explicit gas price
in: master
37 files changed
tests/.eslintrc.jsondiffbeforeafterboth10 "parser": "@typescript-eslint/parser",10 "parser": "@typescript-eslint/parser",11 "parserOptions": {11 "parserOptions": {12 "ecmaVersion": 11,12 "ecmaVersion": 11,13 "sourceType": "module"13 "sourceType": "module",14 "project": "**/tsconfig.json"14 },15 },15 "plugins": [16 "plugins": [16 "@typescript-eslint",17 "@typescript-eslint",24 "SwitchCase": 125 "SwitchCase": 125 }26 }26 ],27 ],28 "no-trailing-spaces": "warn",27 "function-call-argument-newline": [29 "function-call-argument-newline": [28 "error",30 "error",29 "consistent"31 "consistent"tests/src/app-promotion.test.tsdiffbeforeafterboth62 6263 expect(await helper.staking.getTotalStaked({Substrate: staker.address})).to.be.equal(100n * nominal);63 expect(await helper.staking.getTotalStaked({Substrate: staker.address})).to.be.equal(100n * nominal);64 expect(await helper.balance.getSubstrate(staker.address) / nominal).to.be.equal(999n);64 expect(await helper.balance.getSubstrate(staker.address) / nominal).to.be.equal(999n);65 // it is potentially flaky test. Promotion can credited some tokens. Maybe we need to use closeTo? 65 // it is potentially flaky test. Promotion can credited some tokens. Maybe we need to use closeTo?66 expect(await helper.staking.getTotalStaked()).to.be.equal(totalStakedBefore + 100n * nominal); // total tokens amount staked in app-promotion increased 66 expect(await helper.staking.getTotalStaked()).to.be.equal(totalStakedBefore + 100n * nominal); // total tokens amount staked in app-promotion increased67 6768 6869 await helper.staking.stake(staker, 200n * nominal);69 await helper.staking.stake(staker, 200n * nominal);122 await helper.staking.unstake(staker);122 await helper.staking.unstake(staker);123 123124 // Right after unstake balance is reserved124 // Right after unstake balance is reserved125 // Staker can not transfer 125 // Staker can not transfer126 expect(await helper.balance.getSubstrateFull(staker.address)).to.deep.contain({reserved: 900n * nominal, miscFrozen: 0n, feeFrozen: 0n});126 expect(await helper.balance.getSubstrateFull(staker.address)).to.deep.contain({reserved: 900n * nominal, miscFrozen: 0n, feeFrozen: 0n});127 await expect(helper.balance.transferToSubstrate(staker, recepient.address, 100n * nominal)).to.be.rejectedWith('balances.InsufficientBalance');127 await expect(helper.balance.transferToSubstrate(staker, recepient.address, 100n * nominal)).to.be.rejectedWith('balances.InsufficientBalance');128 expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(900n * nominal);128 expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(900n * nominal);368 itEth('should set palletes address as a sponsor', async ({helper}) => {368 itEth('should set palletes address as a sponsor', async ({helper}) => {369 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();369 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();370 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);370 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);371 const contractHelper = helper.ethNativeContract.contractHelpers(contractOwner);371 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);372 372373 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address]);373 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address]);374 374384 itEth('should overwrite sponsoring mode and existed sponsor', async ({helper}) => {384 itEth('should overwrite sponsoring mode and existed sponsor', async ({helper}) => {385 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();385 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();386 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);386 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);387 const contractHelper = helper.ethNativeContract.contractHelpers(contractOwner);387 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);388 388389 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;389 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;390 390411 itEth('can be overwritten by contract owner', async ({helper}) => {411 itEth('can be overwritten by contract owner', async ({helper}) => {412 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();412 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();413 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);413 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);414 const contractHelper = helper.ethNativeContract.contractHelpers(contractOwner);414 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);415 415416 // contract sponsored by pallet416 // contract sponsored by pallet417 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true);417 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true);432 const nonAdmin = accounts.pop()!;432 const nonAdmin = accounts.pop()!;433 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();433 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();434 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);434 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);435 const contractHelper = helper.ethNativeContract.contractHelpers(contractOwner);435 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);436 436437 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;437 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;438 438439 // nonAdmin calls sponsorContract439 // nonAdmin calls sponsorContract440 await expect(helper.executeExtrinsic(nonAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true)).to.be.rejectedWith('appPromotion.NoPermission');440 await expect(helper.executeExtrinsic(nonAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true)).to.be.rejectedWith('appPromotion.NoPermission');441 441442 // contract still self-sponsored 442 // contract still self-sponsored443 expect((await helper.callRpc('api.query.evmContractHelpers.sponsoring', [flipper.options.address])).toJSON()).to.deep.equal({443 expect((await helper.callRpc('api.query.evmContractHelpers.sponsoring', [flipper.options.address])).toJSON()).to.deep.equal({444 confirmed: {444 confirmed: {445 ethereum: flipper.options.address.toLowerCase(),445 ethereum: flipper.options.address.toLowerCase(),455 // Deploy flipper455 // Deploy flipper456 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();456 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();457 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);457 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);458 const contractHelper = helper.ethNativeContract.contractHelpers(contractOwner);458 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);459 459460 // Owner sets to sponsor every tx460 // Owner sets to sponsor every tx461 await contractHelper.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: contractOwner});461 await contractHelper.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: contractOwner});487 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();487 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();488 const flipper = await helper.eth.deployFlipper(contractOwner);488 const flipper = await helper.eth.deployFlipper(contractOwner);489 await helper.eth.transferBalanceFromSubstrate(donor, flipper.options.address);489 await helper.eth.transferBalanceFromSubstrate(donor, flipper.options.address);490 const contractHelper = helper.ethNativeContract.contractHelpers(contractOwner);490 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);491 491492 await contractHelper.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Generous).send({from: contractOwner});492 await contractHelper.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Generous).send({from: contractOwner});493 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true);493 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true);524 const nonAdmin = accounts.pop()!;524 const nonAdmin = accounts.pop()!;525 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();525 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();526 const flipper = await helper.eth.deployFlipper(contractOwner);526 const flipper = await helper.eth.deployFlipper(contractOwner);527 const contractHelper = helper.ethNativeContract.contractHelpers(contractOwner);527 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);528 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;528 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;529 529530 await expect(helper.executeExtrinsic(nonAdmin, 'api.tx.appPromotion.stopSponsoringContract', [flipper.options.address], true)).to.be.rejectedWith('appPromotion.NoPermission');530 await expect(helper.executeExtrinsic(nonAdmin, 'api.tx.appPromotion.stopSponsoringContract', [flipper.options.address], true)).to.be.rejectedWith('appPromotion.NoPermission');650 const crowd = await helper.arrange.createCrowd(500, 300n, donor);650 const crowd = await helper.arrange.createCrowd(500, 300n, donor);651 await Promise.all(crowd.map(account => helper.staking.stake(account, 100n * nominal)));651 await Promise.all(crowd.map(account => helper.staking.stake(account, 100n * nominal)));652 await Promise.all(crowd.map(account => helper.staking.stake(account, 100n * nominal)));652 await Promise.all(crowd.map(account => helper.staking.stake(account, 100n * nominal)));653 // 653 //654 };654 };655 655656 for (let i = 0; i < 40; i++) {656 for (let i = 0; i < 40; i++) {tests/src/benchmarks/mintFee/benchmark.tsdiffbeforeafterboth210 );210 );211211212 const collectionEthAddress = helper.ethAddress.fromCollectionId(collection.collectionId);212 const collectionEthAddress = helper.ethAddress.fromCollectionId(collection.collectionId);213 const collectionContract = helper.ethNativeContract.collection(213 const collectionContract = await helper.ethNativeContract.collection(214 collectionEthAddress,214 collectionEthAddress,215 'nft',215 'nft',216 );216 );290 ethSigner,290 ethSigner,291 proxyContract.options.address,291 proxyContract.options.address,292 async (collection) => {292 async (collection) => {293 const evmContract = helper.ethNativeContract.collection(293 const evmContract = await helper.ethNativeContract.collection(294 helper.ethAddress.fromCollectionId(collection.collectionId),294 helper.ethAddress.fromCollectionId(collection.collectionId),295 'nft',295 'nft',296 );296 );330 ethSigner,330 ethSigner,331 proxyContract.options.address,331 proxyContract.options.address,332 async (collection) => {332 async (collection) => {333 const evmContract = helper.ethNativeContract.collection(333 const evmContract = await helper.ethNativeContract.collection(334 helper.ethAddress.fromCollectionId(collection.collectionId),334 helper.ethAddress.fromCollectionId(collection.collectionId),335 'nft',335 'nft',336 );336 );tests/src/calibrate.tsdiffbeforeafterboth246 const token = await collection.mintToken(alice, {Ethereum: caller});246 const token = await collection.mintToken(alice, {Ethereum: caller});247247248 const address = helper.ethAddress.fromCollectionId(collection.collectionId);248 const address = helper.ethAddress.fromCollectionId(collection.collectionId);249 const contract = helper.ethNativeContract.collection(address, 'nft', caller);249 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);250250251 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS}));251 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS}));252252266 const token = await collection.mintToken(alice, {Ethereum: caller});266 const token = await collection.mintToken(alice, {Ethereum: caller});267267268 const address = helper.ethAddress.fromCollectionId(collection.collectionId);268 const address = helper.ethAddress.fromCollectionId(collection.collectionId);269 const contract = helper.ethNativeContract.collection(address, 'nft', caller);269 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);270270271 const transferPrice = new Fract(await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gasPrice: gasPriceStr, gas: helper.eth.DEFAULT_GAS})));271 const transferPrice = new Fract(await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gasPrice: gasPriceStr, gas: helper.eth.DEFAULT_GAS})));272272287 const token = await collection.mintToken(alice, {Ethereum: caller});287 const token = await collection.mintToken(alice, {Ethereum: caller});288288289 const address = helper.ethAddress.fromCollectionId(collection.collectionId);289 const address = helper.ethAddress.fromCollectionId(collection.collectionId);290 const contract = helper.ethNativeContract.collection(address, 'nft', caller);290 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);291291292 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS}));292 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS}));293293tests/src/eth/allowlist.test.tsdiffbeforeafterboth30 itEth('Contract allowlist can be toggled', async ({helper}) => {30 itEth('Contract allowlist can be toggled', async ({helper}) => {31 const owner = await helper.eth.createAccountWithBalance(donor);31 const owner = await helper.eth.createAccountWithBalance(donor);32 const flipper = await helper.eth.deployFlipper(owner);32 const flipper = await helper.eth.deployFlipper(owner);33 const helpers = helper.ethNativeContract.contractHelpers(owner);33 const helpers = await helper.ethNativeContract.contractHelpers(owner);343435 // Any user is allowed by default35 // Any user is allowed by default36 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;36 expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;48 const owner = await helper.eth.createAccountWithBalance(donor);48 const owner = await helper.eth.createAccountWithBalance(donor);49 const caller = await helper.eth.createAccountWithBalance(donor);49 const caller = await helper.eth.createAccountWithBalance(donor);50 const flipper = await helper.eth.deployFlipper(owner);50 const flipper = await helper.eth.deployFlipper(owner);51 const helpers = helper.ethNativeContract.contractHelpers(owner);51 const helpers = await helper.ethNativeContract.contractHelpers(owner);525253 // User can flip with allowlist disabled53 // User can flip with allowlist disabled54 await flipper.methods.flip().send({from: caller});54 await flipper.methods.flip().send({from: caller});82 const crossUser = helper.ethCrossAccount.fromAddress(user);82 const crossUser = helper.ethCrossAccount.fromAddress(user);83 8384 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');84 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');85 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);85 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);868687 expect(await collectionEvm.methods.allowlistedCross(crossUser).call({from: owner})).to.be.false;87 expect(await collectionEvm.methods.allowlistedCross(crossUser).call({from: owner})).to.be.false;88 await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});88 await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});105 const mintParams = testCase.mode === 'ft' ? [userEth, 100] : [userEth];105 const mintParams = testCase.mode === 'ft' ? [userEth, 100] : [userEth];106 106107 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');107 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');108 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);108 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);109 const userCrossSub = helper.ethCrossAccount.fromKeyringPair(userSub);109 const userCrossSub = helper.ethCrossAccount.fromKeyringPair(userSub);110 const userCrossEth = helper.ethCrossAccount.fromAddress(userEth);110 const userCrossEth = helper.ethCrossAccount.fromAddress(userEth);111 const ownerCrossEth = helper.ethCrossAccount.fromAddress(owner);111 const ownerCrossEth = helper.ethCrossAccount.fromAddress(owner);179 const userCrossEth = helper.ethCrossAccount.fromAddress(userEth);179 const userCrossEth = helper.ethCrossAccount.fromAddress(userEth);180180181 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');181 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');182 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner, !testCase.cross);182 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner, !testCase.cross);183 183184 expect(await helper.collection.allowed(collectionId, {Substrate: userSub.address})).to.be.false;184 expect(await helper.collection.allowed(collectionId, {Substrate: userSub.address})).to.be.false;185 expect(await helper.collection.allowed(collectionId, {Ethereum: userEth})).to.be.false;185 expect(await helper.collection.allowed(collectionId, {Ethereum: userEth})).to.be.false;tests/src/eth/base.test.tsdiffbeforeafterboth57 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});57 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});585859 const address = helper.ethAddress.fromCollectionId(collection.collectionId);59 const address = helper.ethAddress.fromCollectionId(collection.collectionId);60 const contract = helper.ethNativeContract.collection(address, 'nft', caller);60 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);616162 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, tokenId).send(caller));62 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, tokenId).send(caller));636379 const BASE_URI = 'base/';79 const BASE_URI = 'base/';808081 async function checkInterface(helper: EthUniqueHelper, interfaceId: string, simpleResult: boolean, compatibleResult: boolean) {81 async function checkInterface(helper: EthUniqueHelper, interfaceId: string, simpleResult: boolean, compatibleResult: boolean) {82 const simple = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(simpleNftCollectionId), 'nft', minter);82 const simple = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(simpleNftCollectionId), 'nft', minter);83 const compatible = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(erc721MetadataCompatibleNftCollectionId), 'nft', minter);83 const compatible = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(erc721MetadataCompatibleNftCollectionId), 'nft', minter);848485 expect(await simple.methods.supportsInterface(interfaceId).call()).to.equal(simpleResult, `empty (not ERC721Metadata compatible) NFT collection returns not ${simpleResult}`);85 expect(await simple.methods.supportsInterface(interfaceId).call()).to.equal(simpleResult, `empty (not ERC721Metadata compatible) NFT collection returns not ${simpleResult}`);86 expect(await compatible.methods.supportsInterface(interfaceId).call()).to.equal(compatibleResult, `ERC721Metadata compatible NFT collection returns not ${compatibleResult}`);86 expect(await compatible.methods.supportsInterface(interfaceId).call()).to.equal(compatibleResult, `ERC721Metadata compatible NFT collection returns not ${compatibleResult}`);tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth56 const adminCrossEth = helper.ethCrossAccount.fromAddress(adminEth);56 const adminCrossEth = helper.ethCrossAccount.fromAddress(adminEth);57 5758 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');58 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');59 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner, true);59 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner, true);606061 // Check isOwnerOrAdminCross returns false:61 // Check isOwnerOrAdminCross returns false:62 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossSub).call()).to.be.false;62 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossSub).call()).to.be.false;63 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossEth).call()).to.be.false;63 expect(await collectionEvm.methods.isOwnerOrAdminCross(adminCrossEth).call()).to.be.false;64 expect(await collectionEvm.methods.isOwnerOrAdminCross(helper.ethCrossAccount.fromAddress(adminDeprecated)).call()).to.be.false;64 expect(await collectionEvm.methods.isOwnerOrAdminCross(helper.ethCrossAccount.fromAddress(adminDeprecated)).call()).to.be.false;65 6566 // Soft-deprecated: can addCollectionAdmin 66 // Soft-deprecated: can addCollectionAdmin67 await collectionEvm.methods.addCollectionAdmin(adminDeprecated).send();67 await collectionEvm.methods.addCollectionAdmin(adminDeprecated).send();68 // Can addCollectionAdminCross for substrate and ethereum address68 // Can addCollectionAdminCross for substrate and ethereum address69 await collectionEvm.methods.addCollectionAdminCross(adminCrossSub).send();69 await collectionEvm.methods.addCollectionAdminCross(adminCrossSub).send();96 const adminCrossEth = helper.ethCrossAccount.fromAddress(adminEth);96 const adminCrossEth = helper.ethCrossAccount.fromAddress(adminEth);97 const [adminSub] = await helper.arrange.createAccounts([100n], donor);97 const [adminSub] = await helper.arrange.createAccounts([100n], donor);98 const adminCrossSub = helper.ethCrossAccount.fromKeyringPair(adminSub);98 const adminCrossSub = helper.ethCrossAccount.fromKeyringPair(adminSub);99 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);99 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);100 100101 // cannot mint while not admin101 // cannot mint while not admin102 await expect(collectionEvm.methods.mint(owner).send({from: adminEth})).to.be.rejected;102 await expect(collectionEvm.methods.mint(owner).send({from: adminEth})).to.be.rejected;116 const [admin] = await helper.arrange.createAccounts([100n, 100n], donor);116 const [admin] = await helper.arrange.createAccounts([100n, 100n], donor);117117118 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');118 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');119 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);119 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);120120121 const adminCross = {121 const adminCross = {122 eth: helper.address.substrateToEth(admin.address),122 eth: helper.address.substrateToEth(admin.address),132 const adminDeprecated = helper.eth.createAccount();132 const adminDeprecated = helper.eth.createAccount();133 const admin1Cross = helper.ethCrossAccount.fromKeyringPair(await privateKey('admin'));133 const admin1Cross = helper.ethCrossAccount.fromKeyringPair(await privateKey('admin'));134 const admin2Cross = helper.ethCrossAccount.fromAddress(helper.address.substrateToEth((await privateKey('admin3')).address));134 const admin2Cross = helper.ethCrossAccount.fromAddress(helper.address.substrateToEth((await privateKey('admin3')).address));135 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);135 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);136 136137 // Soft-deprecated:137 // Soft-deprecated:138 expect(await collectionEvm.methods.isOwnerOrAdmin(adminDeprecated).call()).to.be.false;138 expect(await collectionEvm.methods.isOwnerOrAdmin(adminDeprecated).call()).to.be.false;156 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');156 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');157157158 const admin = await helper.eth.createAccountWithBalance(donor);158 const admin = await helper.eth.createAccountWithBalance(donor);159 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);159 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);160 await collectionEvm.methods.addCollectionAdmin(admin).send();160 await collectionEvm.methods.addCollectionAdmin(admin).send();161161162 const user = helper.eth.createAccount();162 const user = helper.eth.createAccount();175 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');175 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');176176177 const notAdmin = await helper.eth.createAccountWithBalance(donor);177 const notAdmin = await helper.eth.createAccountWithBalance(donor);178 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);178 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);179179180 const user = helper.eth.createAccount();180 const user = helper.eth.createAccount();181 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))181 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))191191192 const [admin, notAdmin] = await helper.arrange.createAccounts([10n, 10n], donor);192 const [admin, notAdmin] = await helper.arrange.createAccounts([10n, 10n], donor);193 const adminCross = helper.ethCrossAccount.fromKeyringPair(admin);193 const adminCross = helper.ethCrossAccount.fromKeyringPair(admin);194 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);194 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);195 await collectionEvm.methods.addCollectionAdminCross(adminCross).send();195 await collectionEvm.methods.addCollectionAdminCross(adminCross).send();196196197 const notAdminCross = helper.ethCrossAccount.fromKeyringPair(notAdmin);197 const notAdminCross = helper.ethCrossAccount.fromKeyringPair(notAdmin);211 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');211 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');212212213 const notAdmin0 = await helper.eth.createAccountWithBalance(donor);213 const notAdmin0 = await helper.eth.createAccountWithBalance(donor);214 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);214 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);215 const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);215 const [notAdmin1] = await helper.arrange.createAccounts([10n], donor);216 const notAdmin1Cross = helper.ethCrossAccount.fromKeyringPair(notAdmin1);216 const notAdmin1Cross = helper.ethCrossAccount.fromKeyringPair(notAdmin1);217 await expect(collectionEvm.methods.addCollectionAdminCross(notAdmin1Cross).call({from: notAdmin0}))217 await expect(collectionEvm.methods.addCollectionAdminCross(notAdmin1Cross).call({from: notAdmin0}))237 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');237 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');238238239 const newAdmin = helper.eth.createAccount();239 const newAdmin = helper.eth.createAccount();240 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);240 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);241 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();241 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();242242243 {243 {261 const adminCrossSub = helper.ethCrossAccount.fromKeyringPair(adminSub);261 const adminCrossSub = helper.ethCrossAccount.fromKeyringPair(adminSub);262 const adminCrossEth = helper.ethCrossAccount.fromAddress(adminEth);262 const adminCrossEth = helper.ethCrossAccount.fromAddress(adminEth);263263264 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);264 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);265 await collectionEvm.methods.addCollectionAdminCross(adminCrossSub).send();265 await collectionEvm.methods.addCollectionAdminCross(adminCrossSub).send();266 await collectionEvm.methods.addCollectionAdminCross(adminCrossEth).send();266 await collectionEvm.methods.addCollectionAdminCross(adminCrossEth).send();267267286 const owner = await helper.eth.createAccountWithBalance(donor);286 const owner = await helper.eth.createAccountWithBalance(donor);287 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');287 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');288288289 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);289 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);290290291 const admin0 = await helper.eth.createAccountWithBalance(donor);291 const admin0 = await helper.eth.createAccountWithBalance(donor);292 await collectionEvm.methods.addCollectionAdmin(admin0).send();292 await collectionEvm.methods.addCollectionAdmin(admin0).send();309 const owner = await helper.eth.createAccountWithBalance(donor);309 const owner = await helper.eth.createAccountWithBalance(donor);310 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');310 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');311311312 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);312 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);313313314 const admin = await helper.eth.createAccountWithBalance(donor);314 const admin = await helper.eth.createAccountWithBalance(donor);315 await collectionEvm.methods.addCollectionAdmin(admin).send();315 await collectionEvm.methods.addCollectionAdmin(admin).send();331331332 const [admin1] = await helper.arrange.createAccounts([10n], donor);332 const [admin1] = await helper.arrange.createAccounts([10n], donor);333 const admin1Cross = helper.ethCrossAccount.fromKeyringPair(admin1);333 const admin1Cross = helper.ethCrossAccount.fromKeyringPair(admin1);334 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);334 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);335 await collectionEvm.methods.addCollectionAdminCross(admin1Cross).send();335 await collectionEvm.methods.addCollectionAdminCross(admin1Cross).send();336 336337 const [admin2] = await helper.arrange.createAccounts([10n], donor);337 const [admin2] = await helper.arrange.createAccounts([10n], donor);354354355 const [adminSub] = await helper.arrange.createAccounts([10n], donor);355 const [adminSub] = await helper.arrange.createAccounts([10n], donor);356 const adminSubCross = helper.ethCrossAccount.fromKeyringPair(adminSub);356 const adminSubCross = helper.ethCrossAccount.fromKeyringPair(adminSub);357 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);357 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);358 await collectionEvm.methods.addCollectionAdminCross(adminSubCross).send();358 await collectionEvm.methods.addCollectionAdminCross(adminSubCross).send();359 const notAdminEth = await helper.eth.createAccountWithBalance(donor);359 const notAdminEth = await helper.eth.createAccountWithBalance(donor);360360382 const owner = await helper.eth.createAccountWithBalance(donor);382 const owner = await helper.eth.createAccountWithBalance(donor);383 const newOwner = await helper.eth.createAccountWithBalance(donor);383 const newOwner = await helper.eth.createAccountWithBalance(donor);384 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');384 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');385 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);385 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);386386387 await collectionEvm.methods.changeCollectionOwner(newOwner).send();387 await collectionEvm.methods.changeCollectionOwner(newOwner).send();388388394 const owner = await helper.eth.createAccountWithBalance(donor);394 const owner = await helper.eth.createAccountWithBalance(donor);395 const newOwner = await helper.eth.createAccountWithBalance(donor);395 const newOwner = await helper.eth.createAccountWithBalance(donor);396 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');396 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');397 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);397 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);398 const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.changeCollectionOwner(newOwner).send());398 const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.changeCollectionOwner(newOwner).send());399 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));399 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));400 expect(cost > 0);400 expect(cost > 0);404 const owner = await helper.eth.createAccountWithBalance(donor);404 const owner = await helper.eth.createAccountWithBalance(donor);405 const newOwner = await helper.eth.createAccountWithBalance(donor);405 const newOwner = await helper.eth.createAccountWithBalance(donor);406 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');406 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');407 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);407 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);408408409 await expect(collectionEvm.methods.changeCollectionOwner(newOwner).send({from: newOwner})).to.be.rejected;409 await expect(collectionEvm.methods.changeCollectionOwner(newOwner).send({from: newOwner})).to.be.rejected;410 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;410 expect(await collectionEvm.methods.isOwnerOrAdmin(newOwner).call()).to.be.false;428 const ownerCrossSub = helper.ethCrossAccount.fromKeyringPair(ownerSub);428 const ownerCrossSub = helper.ethCrossAccount.fromKeyringPair(ownerSub);429429430 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');430 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');431 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);431 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);432432433 expect(await collectionEvm.methods.isOwnerOrAdminCross(ownerCrossSub).call()).to.be.false;433 expect(await collectionEvm.methods.isOwnerOrAdminCross(ownerCrossSub).call()).to.be.false;434434449 const owner = await helper.eth.createAccountWithBalance(donor);449 const owner = await helper.eth.createAccountWithBalance(donor);450 const [newOwner] = await helper.arrange.createAccounts([10n], donor);450 const [newOwner] = await helper.arrange.createAccounts([10n], donor);451 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');451 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');452 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);452 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);453453454 const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());454 const cost = await recordEthFee(helper, owner, () => collectionEvm.methods.setOwnerSubstrate(newOwner.addressRaw).send());455 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));455 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));462 const [newOwner] = await helper.arrange.createAccounts([10n], donor);462 const [newOwner] = await helper.arrange.createAccounts([10n], donor);463 const newOwnerCross = helper.ethCrossAccount.fromKeyringPair(newOwner);463 const newOwnerCross = helper.ethCrossAccount.fromKeyringPair(newOwner);464 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');464 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');465 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);465 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);466466467 await expect(collectionEvm.methods.changeCollectionOwnerCross(newOwnerCross).send({from: otherReceiver})).to.be.rejected;467 await expect(collectionEvm.methods.changeCollectionOwnerCross(newOwnerCross).send({from: otherReceiver})).to.be.rejected;468 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;468 expect(await collectionEvm.methods.isOwnerOrAdminCross(newOwnerCross).call()).to.be.false;tests/src/eth/collectionHelperAddress.test.tsdiffbeforeafterboth33 const owner = await helper.eth.createAccountWithBalance(donor);33 const owner = await helper.eth.createAccountWithBalance(donor);34 3435 const {collectionAddress: nftCollectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');35 const {collectionAddress: nftCollectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');36 const nftCollection = helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);36 const nftCollection = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);37 3738 expect((await nftCollection.methods.collectionHelperAddress().call())38 expect((await nftCollection.methods.collectionHelperAddress().call())39 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);39 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);444445 const {collectionAddress: rftCollectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');45 const {collectionAddress: rftCollectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');464647 const rftCollection = helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);47 const rftCollection = await helper.ethNativeContract.collection(rftCollectionAddress, 'rft', owner);48 expect((await rftCollection.methods.collectionHelperAddress().call())48 expect((await rftCollection.methods.collectionHelperAddress().call())49 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);49 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);50 });50 });53 const owner = await helper.eth.createAccountWithBalance(donor);53 const owner = await helper.eth.createAccountWithBalance(donor);545455 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', 18, 'absolutely anything', 'ROC');55 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', 18, 'absolutely anything', 'ROC');56 const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);56 const collection = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);57 5758 expect((await collection.methods.collectionHelperAddress().call())58 expect((await collection.methods.collectionHelperAddress().call())59 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);59 .toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS);63 const owner = await helper.eth.createAccountWithBalance(donor);63 const owner = await helper.eth.createAccountWithBalance(donor);64 const collectionId = 7;64 const collectionId = 7;65 const collectionAddress = helper.ethAddress.fromCollectionId(collectionId);65 const collectionAddress = helper.ethAddress.fromCollectionId(collectionId);66 const helperContract = helper.ethNativeContract.collectionHelpers(owner);66 const helperContract = await helper.ethNativeContract.collectionHelpers(owner);67 6768 expect(await helperContract.methods.collectionAddress(collectionId).call()).to.be.equal(collectionAddress);68 expect(await helperContract.methods.collectionAddress(collectionId).call()).to.be.equal(collectionAddress);69 expect(parseInt(await helperContract.methods.collectionId(collectionAddress).call())).to.be.equal(collectionId);69 expect(parseInt(await helperContract.methods.collectionId(collectionAddress).call())).to.be.equal(collectionId);tests/src/eth/collectionLimits.test.tsdiffbeforeafterboth45 transfersEnabled: false,45 transfersEnabled: false,46 };46 };47 4748 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);48 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);49 await collectionEvm.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();49 await collectionEvm.methods.setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, limits.accountTokenOwnershipLimit).send();50 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();50 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataSize, true, limits.sponsoredDataSize).send();51 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();51 await collectionEvm.methods.setCollectionLimit(CollectionLimits.SponsoredDataRateLimit, true, limits.sponsoredDataRateLimit).send();979798 const owner = await helper.eth.createAccountWithBalance(donor);98 const owner = await helper.eth.createAccountWithBalance(donor);99 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'ISNI', 18);99 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'ISNI', 18);100 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);100 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);101101102 // Cannot set non-existing limit102 // Cannot set non-existing limit103 await expect(collectionEvm.methods103 await expect(collectionEvm.methods131 const nonOwner = await helper.eth.createAccountWithBalance(donor);131 const nonOwner = await helper.eth.createAccountWithBalance(donor);132 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'FLO', 18);132 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, 'Limits', 'absolutely anything', 'FLO', 18);133133134 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);134 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);135 await expect(collectionEvm.methods135 await expect(collectionEvm.methods136 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)136 .setCollectionLimit(CollectionLimits.AccountTokenOwnership, true, 1000)137 .call({from: nonOwner}))137 .call({from: nonOwner}))tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth43 await collection.addAdmin(alice, {Ethereum: caller});43 await collection.addAdmin(alice, {Ethereum: caller});44 4445 const address = helper.ethAddress.fromCollectionId(collection.collectionId);45 const address = helper.ethAddress.fromCollectionId(collection.collectionId);46 const collectionEvm = helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'setCollectionProperty');46 const collectionEvm = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'setCollectionProperty');474748 // collectionProperties returns an empty array if no properties: 48 // collectionProperties returns an empty array if no properties:49 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like([]);49 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like([]);50 expect(await collectionEvm.methods.collectionProperties(['NonExistingKey']).call()).to.be.like([]);50 expect(await collectionEvm.methods.collectionProperties(['NonExistingKey']).call()).to.be.like([]);515154 const raw = (await collection.getData())?.raw;54 const raw = (await collection.getData())?.raw;55 expect(raw.properties).to.deep.equal(testCase.expectedProps);55 expect(raw.properties).to.deep.equal(testCase.expectedProps);565657 // collectionProperties returns properties: 57 // collectionProperties returns properties:58 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like(testCase.expectedProps.map(prop => helper.ethProperty.property(prop.key, prop.value)));58 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like(testCase.expectedProps.map(prop => helper.ethProperty.property(prop.key, prop.value)));59 }));59 }));606064 await collection.addAdmin(alice, {Ethereum: caller});64 await collection.addAdmin(alice, {Ethereum: caller});656566 const address = helper.ethAddress.fromCollectionId(collection.collectionId);66 const address = helper.ethAddress.fromCollectionId(collection.collectionId);67 const contract = helper.ethNativeContract.collection(address, 'nft', caller);67 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);686869 await expect(contract.methods.setCollectionProperties([{key: '', value: Buffer.from('val1')}]).send({from: caller})).to.be.rejected;69 await expect(contract.methods.setCollectionProperties([{key: '', value: Buffer.from('val1')}]).send({from: caller})).to.be.rejected;70 await expect(contract.methods.setCollectionProperties([{key: 'déjà vu', value: Buffer.from('hmm...')}]).send({from: caller})).to.be.rejected;70 await expect(contract.methods.setCollectionProperties([{key: 'déjà vu', value: Buffer.from('hmm...')}]).send({from: caller})).to.be.rejected;93 await collection.addAdmin(alice, {Ethereum: caller});93 await collection.addAdmin(alice, {Ethereum: caller});94 9495 const address = helper.ethAddress.fromCollectionId(collection.collectionId);95 const address = helper.ethAddress.fromCollectionId(collection.collectionId);96 const contract = helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');96 const contract = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');97 9798 await contract.methods[testCase.method](...testCase.methodParams).send({from: caller});98 await contract.methods[testCase.method](...testCase.methodParams).send({from: caller});99 99116 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});116 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});117117118 const address = helper.ethAddress.fromCollectionId(collection.collectionId);118 const address = helper.ethAddress.fromCollectionId(collection.collectionId);119 const collectionEvm = helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');119 const collectionEvm = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');120120121 await expect(collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller})).to.be.rejected;121 await expect(collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller})).to.be.rejected;122 expect(await collection.getProperties()).to.deep.eq(properties);122 expect(await collection.getProperties()).to.deep.eq(properties);127 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});127 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});128128129 const address = helper.ethAddress.fromCollectionId(collection.collectionId);129 const address = helper.ethAddress.fromCollectionId(collection.collectionId);130 const contract = helper.ethNativeContract.collection(address, 'nft', caller);130 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);131131132 const value = await contract.methods.collectionProperty('testKey').call();132 const value = await contract.methods.collectionProperty('testKey').call();133 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));133 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));155 const SUFFIX = 'suffix1';155 const SUFFIX = 'suffix1';156 const URI = 'uri1';156 const URI = 'uri1';157 157158 const collectionHelpers = helper.ethNativeContract.collectionHelpers(caller);158 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(caller);159 const creatorMethod = testCase.case === 'rft' ? 'createRFTCollection' : 'createNFTCollection';159 const creatorMethod = testCase.case === 'rft' ? 'createRFTCollection' : 'createNFTCollection';160 160161 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');161 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');162 const bruhCross = helper.ethCrossAccount.fromAddress(bruh);162 const bruhCross = helper.ethCrossAccount.fromAddress(bruh);163 163164 const contract = helper.ethNativeContract.collectionById(collectionId, testCase.case, caller);164 const contract = await helper.ethNativeContract.collectionById(collectionId, testCase.case, caller);165 await contract.methods.addCollectionAdminCross(bruhCross).send(); // to check that admin will work too165 await contract.methods.addCollectionAdminCross(bruhCross).send(); // to check that admin will work too166 166167 const collection1 = helper.nft.getCollectionObject(collectionId);167 const collection1 = helper.nft.getCollectionObject(collectionId);tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth41 expect(await helper.balance.getEthereum(minter)).to.equal(0n);41 expect(await helper.balance.getEthereum(minter)).to.equal(0n);424243 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);43 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);44 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', minter);44 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', minter);454546 await collection.addToAllowList(alice, {Ethereum: minter});46 await collection.addToAllowList(alice, {Ethereum: minter});474788 ].map(testCase => 88 ].map(testCase =>89 itEth(`[${testCase}] can remove collection sponsor`, async ({helper}) => {89 itEth(`[${testCase}] can remove collection sponsor`, async ({helper}) => {90 const owner = await helper.eth.createAccountWithBalance(donor);90 const owner = await helper.eth.createAccountWithBalance(donor);91 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);91 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);92 9293 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});93 let result = await collectionHelpers.methods.createNFTCollection('Sponsor collection', '1', '1').send({value: Number(2n * nominal)});94 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);94 const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);95 const sponsor = await helper.eth.createAccountWithBalance(donor);95 const sponsor = await helper.eth.createAccountWithBalance(donor);96 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);96 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);97 const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, testCase === 'setCollectionSponsor');97 const collectionEvm = await helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner, testCase === 'setCollectionSponsor');98 9899 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;99 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;100 result = await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send({from: owner});100 result = await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send({from: owner});121 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');121 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Sponsor collection', '1', '1', '');122 122123 const collectionSub = helper.nft.getCollectionObject(collectionId);123 const collectionSub = helper.nft.getCollectionObject(collectionId);124 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');124 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');125 125126 // Set collection sponsor:126 // Set collection sponsor:127 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsorEth : sponsorCrossEth).send({from: owner});127 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsorEth : sponsorCrossEth).send({from: owner});252 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');252 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');253253254 const collectionSub = helper.nft.getCollectionObject(collectionId);254 const collectionSub = helper.nft.getCollectionObject(collectionId);255 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');255 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, testCase === 'setCollectionSponsor');256 // Set collection sponsor:256 // Set collection sponsor:257 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();257 await collectionEvm.methods[testCase](testCase === 'setCollectionSponsor' ? sponsor : sponsorCross).send();258 let collectionData = (await collectionSub.getData())!;258 let collectionData = (await collectionSub.getData())!;303303304 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');304 const {collectionAddress, collectionId} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner,'Sponsor collection', '1', '1', '');305 const collectionSub = helper.nft.getCollectionObject(collectionId);305 const collectionSub = helper.nft.getCollectionObject(collectionId);306 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);306 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);307307308 // Set and confirm sponsor:308 // Set and confirm sponsor:309 await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossEth).send({from: owner});309 await collectionEvm.methods.setCollectionSponsorCross(sponsorCrossEth).send({from: owner});tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth34 itEth('Self sponsoring can be set by the address that deployed the contract', async ({helper}) => {34 itEth('Self sponsoring can be set by the address that deployed the contract', async ({helper}) => {35 const owner = await helper.eth.createAccountWithBalance(donor);35 const owner = await helper.eth.createAccountWithBalance(donor);36 const flipper = await helper.eth.deployFlipper(owner);36 const flipper = await helper.eth.deployFlipper(owner);37 const helpers = helper.ethNativeContract.contractHelpers(owner);37 const helpers = await helper.ethNativeContract.contractHelpers(owner);383839 // 1. owner can set selfSponsoring:39 // 1. owner can set selfSponsoring:40 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;40 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;71 itEth('Self sponsoring cannot be set by the address that did not deployed the contract', async ({helper}) => {71 itEth('Self sponsoring cannot be set by the address that did not deployed the contract', async ({helper}) => {72 const owner = await helper.eth.createAccountWithBalance(donor);72 const owner = await helper.eth.createAccountWithBalance(donor);73 const notOwner = await helper.eth.createAccountWithBalance(donor);73 const notOwner = await helper.eth.createAccountWithBalance(donor);74 const helpers = helper.ethNativeContract.contractHelpers(owner);74 const helpers = await helper.ethNativeContract.contractHelpers(owner);75 const flipper = await helper.eth.deployFlipper(owner);75 const flipper = await helper.eth.deployFlipper(owner);767677 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;77 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;818182 itEth('Sponsoring can be set by the address that has deployed the contract', async ({helper}) => {82 itEth('Sponsoring can be set by the address that has deployed the contract', async ({helper}) => {83 const owner = await helper.eth.createAccountWithBalance(donor);83 const owner = await helper.eth.createAccountWithBalance(donor);84 const helpers = helper.ethNativeContract.contractHelpers(owner);84 const helpers = await helper.ethNativeContract.contractHelpers(owner);85 const flipper = await helper.eth.deployFlipper(owner);85 const flipper = await helper.eth.deployFlipper(owner);868687 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;87 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;92 itEth('Sponsoring cannot be set by the address that did not deployed the contract', async ({helper}) => {92 itEth('Sponsoring cannot be set by the address that did not deployed the contract', async ({helper}) => {93 const owner = await helper.eth.createAccountWithBalance(donor);93 const owner = await helper.eth.createAccountWithBalance(donor);94 const notOwner = await helper.eth.createAccountWithBalance(donor);94 const notOwner = await helper.eth.createAccountWithBalance(donor);95 const helpers = helper.ethNativeContract.contractHelpers(owner);95 const helpers = await helper.ethNativeContract.contractHelpers(owner);96 const flipper = await helper.eth.deployFlipper(owner);96 const flipper = await helper.eth.deployFlipper(owner);979798 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;98 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;103 itEth('Sponsor can be set by the address that deployed the contract', async ({helper}) => {103 itEth('Sponsor can be set by the address that deployed the contract', async ({helper}) => {104 const owner = await helper.eth.createAccountWithBalance(donor);104 const owner = await helper.eth.createAccountWithBalance(donor);105 const sponsor = await helper.eth.createAccountWithBalance(donor);105 const sponsor = await helper.eth.createAccountWithBalance(donor);106 const helpers = helper.ethNativeContract.contractHelpers(owner);106 const helpers = await helper.ethNativeContract.contractHelpers(owner);107 const flipper = await helper.eth.deployFlipper(owner);107 const flipper = await helper.eth.deployFlipper(owner);108108109 // 1. owner can set a sponsor:109 // 1. owner can set a sponsor:129 const owner = await helper.eth.createAccountWithBalance(donor);129 const owner = await helper.eth.createAccountWithBalance(donor);130 const sponsor = await helper.eth.createAccountWithBalance(donor);130 const sponsor = await helper.eth.createAccountWithBalance(donor);131 const notOwner = await helper.eth.createAccountWithBalance(donor);131 const notOwner = await helper.eth.createAccountWithBalance(donor);132 const helpers = helper.ethNativeContract.contractHelpers(owner);132 const helpers = await helper.ethNativeContract.contractHelpers(owner);133 const flipper = await helper.eth.deployFlipper(owner);133 const flipper = await helper.eth.deployFlipper(owner);134134135 expect(await helpers.methods.hasPendingSponsor(flipper.options.address).call()).to.be.false;135 expect(await helpers.methods.hasPendingSponsor(flipper.options.address).call()).to.be.false;140 itEth('Sponsorship can be confirmed by the address that pending as sponsor', async ({helper}) => {140 itEth('Sponsorship can be confirmed by the address that pending as sponsor', async ({helper}) => {141 const owner = await helper.eth.createAccountWithBalance(donor);141 const owner = await helper.eth.createAccountWithBalance(donor);142 const sponsor = await helper.eth.createAccountWithBalance(donor);142 const sponsor = await helper.eth.createAccountWithBalance(donor);143 const helpers = helper.ethNativeContract.contractHelpers(owner);143 const helpers = await helper.ethNativeContract.contractHelpers(owner);144 const flipper = await helper.eth.deployFlipper(owner);144 const flipper = await helper.eth.deployFlipper(owner);145145146 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;146 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;173 const owner = await helper.eth.createAccountWithBalance(donor);173 const owner = await helper.eth.createAccountWithBalance(donor);174 const sponsor = await helper.eth.createAccountWithBalance(donor);174 const sponsor = await helper.eth.createAccountWithBalance(donor);175 const notSponsor = await helper.eth.createAccountWithBalance(donor);175 const notSponsor = await helper.eth.createAccountWithBalance(donor);176 const helpers = helper.ethNativeContract.contractHelpers(owner);176 const helpers = await helper.ethNativeContract.contractHelpers(owner);177 const flipper = await helper.eth.deployFlipper(owner);177 const flipper = await helper.eth.deployFlipper(owner);178178179 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;179 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;185 itEth('Sponsorship can not be confirmed by the address that not set as sponsor', async ({helper}) => {185 itEth('Sponsorship can not be confirmed by the address that not set as sponsor', async ({helper}) => {186 const owner = await helper.eth.createAccountWithBalance(donor);186 const owner = await helper.eth.createAccountWithBalance(donor);187 const notSponsor = await helper.eth.createAccountWithBalance(donor);187 const notSponsor = await helper.eth.createAccountWithBalance(donor);188 const helpers = helper.ethNativeContract.contractHelpers(owner);188 const helpers = await helper.ethNativeContract.contractHelpers(owner);189 const flipper = await helper.eth.deployFlipper(owner);189 const flipper = await helper.eth.deployFlipper(owner);190190191 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;191 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;196 itEth('Sponsor can be removed by the address that deployed the contract', async ({helper}) => {196 itEth('Sponsor can be removed by the address that deployed the contract', async ({helper}) => {197 const owner = await helper.eth.createAccountWithBalance(donor);197 const owner = await helper.eth.createAccountWithBalance(donor);198 const sponsor = await helper.eth.createAccountWithBalance(donor);198 const sponsor = await helper.eth.createAccountWithBalance(donor);199 const helpers = helper.ethNativeContract.contractHelpers(owner);199 const helpers = await helper.ethNativeContract.contractHelpers(owner);200 const flipper = await helper.eth.deployFlipper(owner);200 const flipper = await helper.eth.deployFlipper(owner);201201202 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;202 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;229 const owner = await helper.eth.createAccountWithBalance(donor);229 const owner = await helper.eth.createAccountWithBalance(donor);230 const notOwner = await helper.eth.createAccountWithBalance(donor);230 const notOwner = await helper.eth.createAccountWithBalance(donor);231 const sponsor = await helper.eth.createAccountWithBalance(donor);231 const sponsor = await helper.eth.createAccountWithBalance(donor);232 const helpers = helper.ethNativeContract.contractHelpers(owner);232 const helpers = await helper.ethNativeContract.contractHelpers(owner);233 const flipper = await helper.eth.deployFlipper(owner);233 const flipper = await helper.eth.deployFlipper(owner);234234235 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;235 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.false;246 const owner = await helper.eth.createAccountWithBalance(donor);246 const owner = await helper.eth.createAccountWithBalance(donor);247 const sponsor = await helper.eth.createAccountWithBalance(donor);247 const sponsor = await helper.eth.createAccountWithBalance(donor);248 const caller = await helper.eth.createAccountWithBalance(donor);248 const caller = await helper.eth.createAccountWithBalance(donor);249 const helpers = helper.ethNativeContract.contractHelpers(owner);249 const helpers = await helper.ethNativeContract.contractHelpers(owner);250 const flipper = await helper.eth.deployFlipper(owner);250 const flipper = await helper.eth.deployFlipper(owner);251251252 await helpers.methods.setSponsor(flipper.options.address, sponsor).send();252 await helpers.methods.setSponsor(flipper.options.address, sponsor).send();271 itEth('In generous mode, non-allowlisted user transaction will be self sponsored', async ({helper}) => {271 itEth('In generous mode, non-allowlisted user transaction will be self sponsored', async ({helper}) => {272 const owner = await helper.eth.createAccountWithBalance(donor);272 const owner = await helper.eth.createAccountWithBalance(donor);273 const caller = await helper.eth.createAccountWithBalance(donor);273 const caller = await helper.eth.createAccountWithBalance(donor);274 const helpers = helper.ethNativeContract.contractHelpers(owner);274 const helpers = await helper.ethNativeContract.contractHelpers(owner);275 const flipper = await helper.eth.deployFlipper(owner);275 const flipper = await helper.eth.deployFlipper(owner);276276277 await helpers.methods.selfSponsoredEnable(flipper.options.address).send();277 await helpers.methods.selfSponsoredEnable(flipper.options.address).send();303 const sponsor = await helper.eth.createAccountWithBalance(donor);303 const sponsor = await helper.eth.createAccountWithBalance(donor);304 const caller = helper.eth.createAccount();304 const caller = helper.eth.createAccount();305 await helper.eth.transferBalanceFromSubstrate(donor, caller, testCase.balance);305 await helper.eth.transferBalanceFromSubstrate(donor, caller, testCase.balance);306 const helpers = helper.ethNativeContract.contractHelpers(owner);306 const helpers = await helper.ethNativeContract.contractHelpers(owner);307 const flipper = await helper.eth.deployFlipper(owner);307 const flipper = await helper.eth.deployFlipper(owner);308 308309 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});309 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});333 itEth('Non-allow-listed address can call a contract. Sponsor balance should not decrease', async ({helper}) => {333 itEth('Non-allow-listed address can call a contract. Sponsor balance should not decrease', async ({helper}) => {334 const owner = await helper.eth.createAccountWithBalance(donor);334 const owner = await helper.eth.createAccountWithBalance(donor);335 const caller = helper.eth.createAccount();335 const caller = helper.eth.createAccount();336 const contractHelpers = helper.ethNativeContract.contractHelpers(owner);336 const contractHelpers = await helper.ethNativeContract.contractHelpers(owner);337337338 // Deploy flipper and send some tokens:338 // Deploy flipper and send some tokens:339 const flipper = await helper.eth.deployFlipper(owner);339 const flipper = await helper.eth.deployFlipper(owner);348 await contractHelpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});348 await contractHelpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});349 await contractHelpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});349 await contractHelpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});350350351 // 1. Caller has no UNQ and is not in allow list. So he cannot flip: 351 // 1. Caller has no UNQ and is not in allow list. So he cannot flip:352 await expect(flipper.methods.flip().send({from: caller})).to.be.rejectedWith(/Returned error: insufficient funds for gas \* price \+ value/);352 await expect(flipper.methods.flip().send({from: caller})).to.be.rejectedWith(/Returned error: insufficient funds for gas \* price \+ value/);353 expect(await flipper.methods.getValue().call()).to.be.false;353 expect(await flipper.methods.getValue().call()).to.be.false;354354361 const owner = await helper.eth.createAccountWithBalance(donor);361 const owner = await helper.eth.createAccountWithBalance(donor);362 const sponsor = await helper.eth.createAccountWithBalance(donor);362 const sponsor = await helper.eth.createAccountWithBalance(donor);363 const caller = await helper.eth.createAccountWithBalance(donor);363 const caller = await helper.eth.createAccountWithBalance(donor);364 const helpers = helper.ethNativeContract.contractHelpers(owner);364 const helpers = await helper.ethNativeContract.contractHelpers(owner);365 const flipper = await helper.eth.deployFlipper(owner);365 const flipper = await helper.eth.deployFlipper(owner);366 366367 const originalCallerBalance = await helper.balance.getEthereum(caller);367 const originalCallerBalance = await helper.balance.getEthereum(caller);393 // TODO: Find a way to calculate default rate limit393 // TODO: Find a way to calculate default rate limit394 itEth('Default rate limit equal 7200', async ({helper}) => {394 itEth('Default rate limit equal 7200', async ({helper}) => {395 const owner = await helper.eth.createAccountWithBalance(donor);395 const owner = await helper.eth.createAccountWithBalance(donor);396 const helpers = helper.ethNativeContract.contractHelpers(owner);396 const helpers = await helper.ethNativeContract.contractHelpers(owner);397 const flipper = await helper.eth.deployFlipper(owner);397 const flipper = await helper.eth.deployFlipper(owner);398398399 expect(await helpers.methods.sponsoringRateLimit(flipper.options.address).call()).to.be.equal('7200');399 expect(await helpers.methods.sponsoringRateLimit(flipper.options.address).call()).to.be.equal('7200');409 if (!testContract) {409 if (!testContract) {410 testContract = await helper.ethContract.compile(410 testContract = await helper.ethContract.compile(411 'TestContract',411 'TestContract',412 `412 `413 // SPDX-License-Identifier: MIT413 // SPDX-License-Identifier: MIT414 pragma solidity ^0.8.0;414 pragma solidity ^0.8.0;415 415416 contract TestContract {416 contract TestContract {417 event Result(bool);417 event Result(bool);418418419 function test(uint32 cycles) public {419 function test(uint32 cycles) public {420 uint256 counter = 0;420 uint256 counter = 0;421 while(true) {421 while(true) {422 counter ++;422 counter ++;423 if (counter > cycles){423 if (counter > cycles){424 break;424 break;425 }425 }426 }426 }427 emit Result(true);427 emit Result(true);428 }428 }429 }429 }430 `,430 `,431 );431 );432 }432 }433 return testContract;433 return testContract;447447448 itEth('Default fee limit', async ({helper}) => {448 itEth('Default fee limit', async ({helper}) => {449 const owner = await helper.eth.createAccountWithBalance(donor);449 const owner = await helper.eth.createAccountWithBalance(donor);450 const helpers = helper.ethNativeContract.contractHelpers(owner);450 const helpers = await helper.ethNativeContract.contractHelpers(owner);451 const flipper = await helper.eth.deployFlipper(owner);451 const flipper = await helper.eth.deployFlipper(owner);452452453 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equal('115792089237316195423570985008687907853269984665640564039457584007913129639935');453 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equal('115792089237316195423570985008687907853269984665640564039457584007913129639935');454 });454 });455455456 itEth('Set fee limit', async ({helper}) => {456 itEth('Set fee limit', async ({helper}) => {457 const owner = await helper.eth.createAccountWithBalance(donor);457 const owner = await helper.eth.createAccountWithBalance(donor);458 const helpers = helper.ethNativeContract.contractHelpers(owner);458 const helpers = await helper.ethNativeContract.contractHelpers(owner);459 const flipper = await helper.eth.deployFlipper(owner);459 const flipper = await helper.eth.deployFlipper(owner);460460461 await helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send();461 await helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send();465 itEth('Negative test - set fee limit by non-owner', async ({helper}) => {465 itEth('Negative test - set fee limit by non-owner', async ({helper}) => {466 const owner = await helper.eth.createAccountWithBalance(donor);466 const owner = await helper.eth.createAccountWithBalance(donor);467 const stranger = await helper.eth.createAccountWithBalance(donor);467 const stranger = await helper.eth.createAccountWithBalance(donor);468 const helpers = helper.ethNativeContract.contractHelpers(owner);468 const helpers = await helper.ethNativeContract.contractHelpers(owner);469 const flipper = await helper.eth.deployFlipper(owner);469 const flipper = await helper.eth.deployFlipper(owner);470470471 await expect(helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send({from: stranger})).to.be.rejected;471 await expect(helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send({from: stranger})).to.be.rejected;475 const owner = await helper.eth.createAccountWithBalance(donor);475 const owner = await helper.eth.createAccountWithBalance(donor);476 const sponsor = await helper.eth.createAccountWithBalance(donor);476 const sponsor = await helper.eth.createAccountWithBalance(donor);477 const user = await helper.eth.createAccountWithBalance(donor);477 const user = await helper.eth.createAccountWithBalance(donor);478 const helpers = helper.ethNativeContract.contractHelpers(owner);478 const helpers = await helper.ethNativeContract.contractHelpers(owner);479479480 const testContract = await deployTestContract(helper, owner);480 const testContract = await deployTestContract(helper, owner);481 481500 itEth('Negative test - check that evm.call transactions exceeding fee limit are not executed', async ({helper}) => {500 itEth('Negative test - check that evm.call transactions exceeding fee limit are not executed', async ({helper}) => {501 const owner = await helper.eth.createAccountWithBalance(donor);501 const owner = await helper.eth.createAccountWithBalance(donor);502 const sponsor = await helper.eth.createAccountWithBalance(donor);502 const sponsor = await helper.eth.createAccountWithBalance(donor);503 const helpers = helper.ethNativeContract.contractHelpers(owner);503 const helpers = await helper.ethNativeContract.contractHelpers(owner);504504505 const testContract = await deployTestContract(helper, owner);505 const testContract = await deployTestContract(helper, owner);506 506tests/src/eth/createFTCollection.seqtest.tsdiffbeforeafterboth595960 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;60 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;61 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);61 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);62 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);62 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);636364 expect(await collectionHelpers.methods64 expect(await collectionHelpers.methods65 .isCollectionExist(expectedCollectionAddress)65 .isCollectionExist(expectedCollectionAddress)tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth41 4142 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');42 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');434344 const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);44 const collection = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);45 await collection.methods.setCollectionSponsor(sponsor).send();45 await collection.methods.setCollectionSponsor(sponsor).send();464647 let data = (await helper.rft.getData(collectionId))!;47 let data = (await helper.rft.getData(collectionId))!;48 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));48 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));494950 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');50 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');515152 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);52 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);53 await sponsorCollection.methods.confirmCollectionSponsorship().send();53 await sponsorCollection.methods.confirmCollectionSponsorship().send();545455 data = (await helper.rft.getData(collectionId))!;55 data = (await helper.rft.getData(collectionId))!;63 const description = 'absolutely anything';63 const description = 'absolutely anything';64 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');64 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');65 6566 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);66 const collection = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);67 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);67 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);68 await collection.methods.setCollectionSponsorCross(sponsorCross).send();68 await collection.methods.setCollectionSponsorCross(sponsorCross).send();6969727273 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');73 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');747475 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);75 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);76 await sponsorCollection.methods.confirmCollectionSponsorship().send();76 await sponsorCollection.methods.confirmCollectionSponsorship().send();777778 data = (await helper.rft.getData(collectionId))!;78 data = (await helper.rft.getData(collectionId))!;83 itEth('Collection address exist', async ({helper}) => {83 itEth('Collection address exist', async ({helper}) => {84 const owner = await helper.eth.createAccountWithBalance(donor);84 const owner = await helper.eth.createAccountWithBalance(donor);85 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';85 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';86 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);8786 expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)88 expect(await collectionHelpers87 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())89 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())88 .to.be.false;90 .to.be.false;89 9190 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');92 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');91 expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)93 expect(await collectionHelpers92 .methods.isCollectionExist(collectionAddress).call())94 .methods.isCollectionExist(collectionAddress).call())93 .to.be.true;95 .to.be.true;94 });96 });95 9796 itEth('destroyCollection', async ({helper}) => {98 itEth('destroyCollection', async ({helper}) => {97 const owner = await helper.eth.createAccountWithBalance(donor);99 const owner = await helper.eth.createAccountWithBalance(donor);98 const {collectionAddress, collectionId} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');100 const {collectionAddress, collectionId} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');99 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);101 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);100102101 const result = await collectionHelper.methods103 const result = await collectionHelper.methods102 .destroyCollection(collectionAddress)104 .destroyCollection(collectionAddress)135137136 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {138 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {137 const owner = await helper.eth.createAccountWithBalance(donor);139 const owner = await helper.eth.createAccountWithBalance(donor);138 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);140 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);139 {141 {140 const MAX_NAME_LENGTH = 64;142 const MAX_NAME_LENGTH = 64;141 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);143 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);168 170169 itEth('(!negative test!) cannot create collection if value !== 2', async ({helper}) => {171 itEth('(!negative test!) cannot create collection if value !== 2', async ({helper}) => {170 const owner = await helper.eth.createAccountWithBalance(donor);172 const owner = await helper.eth.createAccountWithBalance(donor);171 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);173 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);172 const expects = [0n, 1n, 30n].map(async value => {174 const expects = [0n, 1n, 30n].map(async value => {173 await expect(collectionHelper.methods175 await expect(collectionHelper.methods174 .createFTCollection('Peasantry', DECIMALS, 'absolutely anything', 'TWIW')176 .createFTCollection('Peasantry', DECIMALS, 'absolutely anything', 'TWIW')182 const owner = await helper.eth.createAccountWithBalance(donor);184 const owner = await helper.eth.createAccountWithBalance(donor);183 const peasant = helper.eth.createAccount();185 const peasant = helper.eth.createAccount();184 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');186 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');185 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant, true);187 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', peasant, true);186 const EXPECTED_ERROR = 'NoPermission';188 const EXPECTED_ERROR = 'NoPermission';187 {189 {188 const sponsor = await helper.eth.createAccountWithBalance(donor);190 const sponsor = await helper.eth.createAccountWithBalance(donor);189 await expect(peasantCollection.methods191 await expect(peasantCollection.methods190 .setCollectionSponsor(sponsor)192 .setCollectionSponsor(sponsor)191 .call()).to.be.rejectedWith(EXPECTED_ERROR);193 .call()).to.be.rejectedWith(EXPECTED_ERROR);192 194193 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor, true);195 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor, true);194 await expect(sponsorCollection.methods196 await expect(sponsorCollection.methods195 .confirmCollectionSponsorship()197 .confirmCollectionSponsorship()196 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');198 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');206 const owner = await helper.eth.createAccountWithBalance(donor);208 const owner = await helper.eth.createAccountWithBalance(donor);207 const peasant = helper.eth.createAccount();209 const peasant = helper.eth.createAccount();208 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');210 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');209 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant);211 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', peasant);210 const EXPECTED_ERROR = 'NoPermission';212 const EXPECTED_ERROR = 'NoPermission';211 {213 {212 const sponsor = await helper.eth.createAccountWithBalance(donor);214 const sponsor = await helper.eth.createAccountWithBalance(donor);215 .setCollectionSponsorCross(sponsorCross)217 .setCollectionSponsorCross(sponsorCross)216 .call()).to.be.rejectedWith(EXPECTED_ERROR);218 .call()).to.be.rejectedWith(EXPECTED_ERROR);217 219218 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor);220 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor);219 await expect(sponsorCollection.methods221 await expect(sponsorCollection.methods220 .confirmCollectionSponsorship()222 .confirmCollectionSponsorship()221 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');223 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');tests/src/eth/createNFTCollection.seqtest.tsdiffbeforeafterboth727273 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;73 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;74 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);74 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);75 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);75 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);767677 expect(await collectionHelpers.methods77 expect(await collectionHelpers.methods78 .isCollectionExist(expectedCollectionAddress)78 .isCollectionExist(expectedCollectionAddress)tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth38 const baseUri = 'BaseURI';38 const baseUri = 'BaseURI';393940 const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);40 const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);41 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');41 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');42 4243 expect(events).to.be.deep.equal([43 expect(events).to.be.deep.equal([44 {44 {81 const ss58Format = helper.chain.getChainProperties().ss58Format;81 const ss58Format = helper.chain.getChainProperties().ss58Format;82 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');82 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');838384 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);84 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);85 await collection.methods.setCollectionSponsor(sponsor).send();85 await collection.methods.setCollectionSponsor(sponsor).send();868687 let data = (await helper.nft.getData(collectionId))!;87 let data = (await helper.nft.getData(collectionId))!;88 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)));898990 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');90 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');919192 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);92 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);93 await sponsorCollection.methods.confirmCollectionSponsorship().send();93 await sponsorCollection.methods.confirmCollectionSponsorship().send();949495 data = (await helper.nft.getData(collectionId))!;95 data = (await helper.nft.getData(collectionId))!;103 const description = 'absolutely anything';103 const description = 'absolutely anything';104 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');104 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');105105106 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);106 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);107 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);107 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);108 await collection.methods.setCollectionSponsorCross(sponsorCross).send();108 await collection.methods.setCollectionSponsorCross(sponsorCross).send();109109112112113 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');113 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');114114115 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);115 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);116 await sponsorCollection.methods.confirmCollectionSponsorship().send();116 await sponsorCollection.methods.confirmCollectionSponsorship().send();117117118 data = (await helper.nft.getData(collectionId))!;118 data = (await helper.nft.getData(collectionId))!;124 itEth('Collection address exist', async ({helper}) => {124 itEth('Collection address exist', async ({helper}) => {125 const owner = await helper.eth.createAccountWithBalance(donor);125 const owner = await helper.eth.createAccountWithBalance(donor);126 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';126 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';127 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);128127 expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)129 expect(await collectionHelpers128 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())130 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())129 .to.be.false;131 .to.be.false;130132131 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');133 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Exister', 'absolutely anything', 'EVC');132 expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)134 expect(await collectionHelpers133 .methods.isCollectionExist(collectionAddress).call())135 .methods.isCollectionExist(collectionAddress).call())134 .to.be.true;136 .to.be.true;135 });137 });148150149 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {151 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {150 const owner = await helper.eth.createAccountWithBalance(donor);152 const owner = await helper.eth.createAccountWithBalance(donor);151 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);153 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);152 {154 {153 const MAX_NAME_LENGTH = 64;155 const MAX_NAME_LENGTH = 64;154 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);156 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);182184183 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {185 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {184 const owner = await helper.eth.createAccountWithBalance(donor);186 const owner = await helper.eth.createAccountWithBalance(donor);185 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);187 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);186 await expect(collectionHelper.methods188 await expect(collectionHelper.methods187 .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')189 .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')188 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');190 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');193 const owner = await helper.eth.createAccountWithBalance(donor);195 const owner = await helper.eth.createAccountWithBalance(donor);194 const malfeasant = helper.eth.createAccount();196 const malfeasant = helper.eth.createAccount();195 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');197 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');196 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);198 const malfeasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant, true);197 const EXPECTED_ERROR = 'NoPermission';199 const EXPECTED_ERROR = 'NoPermission';198 {200 {199 const sponsor = await helper.eth.createAccountWithBalance(donor);201 const sponsor = await helper.eth.createAccountWithBalance(donor);200 await expect(malfeasantCollection.methods202 await expect(malfeasantCollection.methods201 .setCollectionSponsor(sponsor)203 .setCollectionSponsor(sponsor)202 .call()).to.be.rejectedWith(EXPECTED_ERROR);204 .call()).to.be.rejectedWith(EXPECTED_ERROR);203205204 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);206 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);205 await expect(sponsorCollection.methods207 await expect(sponsorCollection.methods206 .confirmCollectionSponsorship()208 .confirmCollectionSponsorship()207 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');209 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');217 const owner = await helper.eth.createAccountWithBalance(donor);219 const owner = await helper.eth.createAccountWithBalance(donor);218 const malfeasant = helper.eth.createAccount();220 const malfeasant = helper.eth.createAccount();219 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');221 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');220 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);222 const malfeasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);221 const EXPECTED_ERROR = 'NoPermission';223 const EXPECTED_ERROR = 'NoPermission';222 {224 {223 const sponsor = await helper.eth.createAccountWithBalance(donor);225 const sponsor = await helper.eth.createAccountWithBalance(donor);226 .setCollectionSponsorCross(sponsorCross)228 .setCollectionSponsorCross(sponsorCross)227 .call()).to.be.rejectedWith(EXPECTED_ERROR);229 .call()).to.be.rejectedWith(EXPECTED_ERROR);228230229 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);231 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);230 await expect(sponsorCollection.methods232 await expect(sponsorCollection.methods231 .confirmCollectionSponsorship()233 .confirmCollectionSponsorship()232 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');234 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');241 itEth('destroyCollection', async ({helper}) => {243 itEth('destroyCollection', async ({helper}) => {242 const owner = await helper.eth.createAccountWithBalance(donor);244 const owner = await helper.eth.createAccountWithBalance(donor);243 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');245 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');244 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);246 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);245247246248247 const result = await collectionHelper.methods249 const result = await collectionHelper.methodstests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth63 const baseUri = 'BaseURI';63 const baseUri = 'BaseURI';646465 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);65 const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);66 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');66 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');676768 const collection = helper.rft.getCollectionObject(collectionId);68 const collection = helper.rft.getCollectionObject(collectionId);69 const data = (await collection.getData())!;69 const data = (await collection.getData())!;949495 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;95 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;96 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);96 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);97 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);97 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);989899 expect(await collectionHelpers.methods99 expect(await collectionHelpers.methods100 .isCollectionExist(expectedCollectionAddress)100 .isCollectionExist(expectedCollectionAddress)116 const ss58Format = helper.chain.getChainProperties().ss58Format;116 const ss58Format = helper.chain.getChainProperties().ss58Format;117 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');117 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');118118119 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);119 const collection = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);120 await collection.methods.setCollectionSponsor(sponsor).send();120 await collection.methods.setCollectionSponsor(sponsor).send();121121122 let data = (await helper.rft.getData(collectionId))!;122 let data = (await helper.rft.getData(collectionId))!;123 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));123 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));124124125 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');125 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');126126127 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);127 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);128 await sponsorCollection.methods.confirmCollectionSponsorship().send();128 await sponsorCollection.methods.confirmCollectionSponsorship().send();129129130 data = (await helper.rft.getData(collectionId))!;130 data = (await helper.rft.getData(collectionId))!;137 const ss58Format = helper.chain.getChainProperties().ss58Format;137 const ss58Format = helper.chain.getChainProperties().ss58Format;138 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');138 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');139139140 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);140 const collection = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);141 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);141 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);142 await collection.methods.setCollectionSponsorCross(sponsorCross).send();142 await collection.methods.setCollectionSponsorCross(sponsorCross).send();143143146146147 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');147 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');148148149 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);149 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);150 await sponsorCollection.methods.confirmCollectionSponsorship().send();150 await sponsorCollection.methods.confirmCollectionSponsorship().send();151151152 data = (await helper.rft.getData(collectionId))!;152 data = (await helper.rft.getData(collectionId))!;156 itEth('Collection address exist', async ({helper}) => {156 itEth('Collection address exist', async ({helper}) => {157 const owner = await helper.eth.createAccountWithBalance(donor);157 const owner = await helper.eth.createAccountWithBalance(donor);158 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';158 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';159 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);160159 expect(await helper.ethNativeContract.collectionHelpers(collectionAddressForNonexistentCollection)161 expect(await collectionHelpers160 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())162 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())161 .to.be.false;163 .to.be.false;162 164163 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Exister', 'absolutely anything', 'WIWT');165 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Exister', 'absolutely anything', 'WIWT');164 expect(await helper.ethNativeContract.collectionHelpers(collectionAddress)166 expect(await collectionHelpers165 .methods.isCollectionExist(collectionAddress).call())167 .methods.isCollectionExist(collectionAddress).call())166 .to.be.true;168 .to.be.true;167 });169 });181183182 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {184 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {183 const owner = await helper.eth.createAccountWithBalance(donor);185 const owner = await helper.eth.createAccountWithBalance(donor);184 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);186 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);185 {187 {186 const MAX_NAME_LENGTH = 64;188 const MAX_NAME_LENGTH = 64;187 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);189 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);214 216215 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {217 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {216 const owner = await helper.eth.createAccountWithBalance(donor);218 const owner = await helper.eth.createAccountWithBalance(donor);217 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);219 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);218 await expect(collectionHelper.methods220 await expect(collectionHelper.methods219 .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')221 .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')220 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');222 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');225 const owner = await helper.eth.createAccountWithBalance(donor);227 const owner = await helper.eth.createAccountWithBalance(donor);226 const peasant = helper.eth.createAccount();228 const peasant = helper.eth.createAccount();227 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');229 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');228 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant, true);230 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', peasant, true);229 const EXPECTED_ERROR = 'NoPermission';231 const EXPECTED_ERROR = 'NoPermission';230 {232 {231 const sponsor = await helper.eth.createAccountWithBalance(donor);233 const sponsor = await helper.eth.createAccountWithBalance(donor);232 await expect(peasantCollection.methods234 await expect(peasantCollection.methods233 .setCollectionSponsor(sponsor)235 .setCollectionSponsor(sponsor)234 .call()).to.be.rejectedWith(EXPECTED_ERROR);236 .call()).to.be.rejectedWith(EXPECTED_ERROR);235 237236 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);238 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);237 await expect(sponsorCollection.methods239 await expect(sponsorCollection.methods238 .confirmCollectionSponsorship()240 .confirmCollectionSponsorship()239 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');241 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');249 const owner = await helper.eth.createAccountWithBalance(donor);251 const owner = await helper.eth.createAccountWithBalance(donor);250 const peasant = helper.eth.createAccount();252 const peasant = helper.eth.createAccount();251 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');253 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');252 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);254 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);253 const EXPECTED_ERROR = 'NoPermission';255 const EXPECTED_ERROR = 'NoPermission';254 {256 {255 const sponsor = await helper.eth.createAccountWithBalance(donor);257 const sponsor = await helper.eth.createAccountWithBalance(donor);258 .setCollectionSponsorCross(sponsorCross)260 .setCollectionSponsorCross(sponsorCross)259 .call()).to.be.rejectedWith(EXPECTED_ERROR);261 .call()).to.be.rejectedWith(EXPECTED_ERROR);260 262261 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);263 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);262 await expect(sponsorCollection.methods264 await expect(sponsorCollection.methods263 .confirmCollectionSponsorship()265 .confirmCollectionSponsorship()264 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');266 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');273 itEth('destroyCollection', async ({helper}) => {275 itEth('destroyCollection', async ({helper}) => {274 const owner = await helper.eth.createAccountWithBalance(donor);276 const owner = await helper.eth.createAccountWithBalance(donor);275 const {collectionAddress, collectionId} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');277 const {collectionAddress, collectionId} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');276 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);278 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);277 279278 await expect(collectionHelper.methods280 await expect(collectionHelper.methods279 .destroyCollection(collectionAddress)281 .destroyCollection(collectionAddress)tests/src/eth/crossTransfer.test.tsdiffbeforeafterboth52 await collection.setLimits(alice, {ownerCanTransfer: true});52 await collection.setLimits(alice, {ownerCanTransfer: true});535354 const address = helper.ethAddress.fromCollectionId(collection.collectionId);54 const address = helper.ethAddress.fromCollectionId(collection.collectionId);55 const contract = helper.ethNativeContract.collection(address, 'ft', aliceProxy);55 const contract = await helper.ethNativeContract.collection(address, 'ft', aliceProxy);565657 await collection.mint(alice, 200n, {Ethereum: aliceProxy});57 await collection.mint(alice, 200n, {Ethereum: aliceProxy});58 await contract.methods.transfer(bobProxy, 50).send({from: aliceProxy});58 await contract.methods.transfer(bobProxy, 50).send({from: aliceProxy});93 await collection.setLimits(alice, {ownerCanTransfer: true});93 await collection.setLimits(alice, {ownerCanTransfer: true});949495 const address = helper.ethAddress.fromCollectionId(collection.collectionId);95 const address = helper.ethAddress.fromCollectionId(collection.collectionId);96 const contract = helper.ethNativeContract.collection(address, 'nft', aliceProxy);96 const contract = await helper.ethNativeContract.collection(address, 'nft', aliceProxy);979798 const token = await collection.mintToken(alice);98 const token = await collection.mintToken(alice);99 await token.transfer(alice, {Ethereum: aliceProxy});99 await token.transfer(alice, {Ethereum: aliceProxy});tests/src/eth/destroyCollection.test.tsdiffbeforeafterboth39 3940 const unexistedCollection = helper.ethAddress.fromCollectionId(1000000);40 const unexistedCollection = helper.ethAddress.fromCollectionId(1000000);41 4142 const collectionHelpers = helper.ethNativeContract.collectionHelpers(signer);42 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(signer);43 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, ...testCase.params as [string, string, string, number?]);43 const {collectionAddress} = await helper.eth.createCollection(testCase.case, owner, ...testCase.params as [string, string, string, number?]);444445 // cannot burn collec45 // cannot burn collectests/src/eth/ethFeesAreCorrect.test.tsdiffbeforeafterboth41 const {tokenId: tokenB} = await collection.mintToken(minter, {Ethereum: aliceEth});41 const {tokenId: tokenB} = await collection.mintToken(minter, {Ethereum: aliceEth});424243 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);43 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);44 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);44 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);454546 const balanceBeforeWeb3Transfer = await helper.balance.getEthereum(owner);46 const balanceBeforeWeb3Transfer = await helper.balance.getEthereum(owner);47 await contract.methods.transfer(receiver, tokenA).send({from: owner});47 await contract.methods.transfer(receiver, tokenA).send({from: owner});tests/src/eth/events.test.tsdiffbeforeafterboth53 clearEvents(ethEvents, subEvents);53 clearEvents(ethEvents, subEvents);54 }54 }55 {55 {56 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);56 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);57 const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});57 const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});58 await helper.wait.newBlocks(1);58 await helper.wait.newBlocks(1);59 expect(result.events).to.containSubset({59 expect(result.events).to.containSubset({71async function testCollectionPropertySetAndDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {71async function testCollectionPropertySetAndDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {72 const owner = await helper.eth.createAccountWithBalance(donor);72 const owner = await helper.eth.createAccountWithBalance(donor);73 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');73 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');74 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);74 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);75 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);75 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);76 7677 const ethEvents: any = [];77 const ethEvents: any = [];78 collectionHelper.events.allEvents((_: any, event: any) => {78 collectionHelper.events.allEvents((_: any, event: any) => {112async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {112async function testPropertyPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {113 const owner = await helper.eth.createAccountWithBalance(donor);113 const owner = await helper.eth.createAccountWithBalance(donor);114 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');114 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');115 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);115 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);116 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);116 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);117 const ethEvents: any = [];117 const ethEvents: any = [];118 collectionHelper.events.allEvents((_: any, event: any) => {118 collectionHelper.events.allEvents((_: any, event: any) => {119 ethEvents.push(event);119 ethEvents.push(event);143 const owner = await helper.eth.createAccountWithBalance(donor);143 const owner = await helper.eth.createAccountWithBalance(donor);144 const user = helper.ethCrossAccount.createAccount();144 const user = helper.ethCrossAccount.createAccount();145 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');145 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');146 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);146 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);147 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);147 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);148 const ethEvents: any[] = [];148 const ethEvents: any[] = [];149 collectionHelper.events.allEvents((_: any, event: any) => {149 collectionHelper.events.allEvents((_: any, event: any) => {150 ethEvents.push(event);150 ethEvents.push(event);185 const owner = await helper.eth.createAccountWithBalance(donor);185 const owner = await helper.eth.createAccountWithBalance(donor);186 const user = helper.ethCrossAccount.createAccount();186 const user = helper.ethCrossAccount.createAccount();187 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');187 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');188 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);188 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);189 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);189 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);190 const ethEvents: any = [];190 const ethEvents: any = [];191 collectionHelper.events.allEvents((_: any, event: any) => {191 collectionHelper.events.allEvents((_: any, event: any) => {192 ethEvents.push(event);192 ethEvents.push(event);225async function testCollectionLimitSet(helper: EthUniqueHelper, mode: TCollectionMode) {225async function testCollectionLimitSet(helper: EthUniqueHelper, mode: TCollectionMode) {226 const owner = await helper.eth.createAccountWithBalance(donor);226 const owner = await helper.eth.createAccountWithBalance(donor);227 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');227 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');228 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);228 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);229 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);229 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);230 const ethEvents: any = [];230 const ethEvents: any = [];231 collectionHelper.events.allEvents((_: any, event: any) => {231 collectionHelper.events.allEvents((_: any, event: any) => {232 ethEvents.push(event);232 ethEvents.push(event);252 const owner = await helper.eth.createAccountWithBalance(donor);252 const owner = await helper.eth.createAccountWithBalance(donor);253 const newOwner = helper.ethCrossAccount.createAccount();253 const newOwner = helper.ethCrossAccount.createAccount();254 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');254 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');255 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);255 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);256 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);256 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);257 const ethEvents: any = [];257 const ethEvents: any = [];258 collectionHelper.events.allEvents((_: any, event: any) => {258 collectionHelper.events.allEvents((_: any, event: any) => {259 ethEvents.push(event);259 ethEvents.push(event);278async function testCollectionPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {278async function testCollectionPermissionSet(helper: EthUniqueHelper, mode: TCollectionMode) {279 const owner = await helper.eth.createAccountWithBalance(donor);279 const owner = await helper.eth.createAccountWithBalance(donor);280 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');280 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');281 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);281 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);282 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);282 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);283 const ethEvents: any = [];283 const ethEvents: any = [];284 collectionHelper.events.allEvents((_: any, event: any) => {284 collectionHelper.events.allEvents((_: any, event: any) => {285 ethEvents.push(event);285 ethEvents.push(event);319 const owner = await helper.eth.createAccountWithBalance(donor);319 const owner = await helper.eth.createAccountWithBalance(donor);320 const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);320 const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);321 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');321 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');322 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);322 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);323 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);323 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);324 const ethEvents: any = [];324 const ethEvents: any = [];325 collectionHelper.events.allEvents((_: any, event: any) => {325 collectionHelper.events.allEvents((_: any, event: any) => {326 ethEvents.push(event);326 ethEvents.push(event);373async function testTokenPropertySetAndDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {373async function testTokenPropertySetAndDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {374 const owner = await helper.eth.createAccountWithBalance(donor);374 const owner = await helper.eth.createAccountWithBalance(donor);375 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');375 const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');376 const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);376 const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);377 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);377 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);378 const result = await collection.methods.mint(owner).send({from: owner});378 const result = await collection.methods.mint(owner).send({from: owner});379 const tokenId = result.events.Transfer.returnValues.tokenId;379 const tokenId = result.events.Transfer.returnValues.tokenId;380 await collection.methods.setTokenPropertyPermissions([380 await collection.methods.setTokenPropertyPermissions([tests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth63 nftCollectionAddress: string, nftTokenId: number, rftTokenAddress: string63 nftCollectionAddress: string, nftTokenId: number, rftTokenAddress: string64}> => {64}> => {65 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');65 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');66 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);66 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);67 const mintResult = await nftContract.methods.mint(owner).send({from: owner});67 const mintResult = await nftContract.methods.mint(owner).send({from: owner});68 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;68 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;696993 const owner = await helper.eth.createAccountWithBalance(donor, 10n);93 const owner = await helper.eth.createAccountWithBalance(donor, 10n);94 const fractionalizer = await deployContract(helper, owner);94 const fractionalizer = await deployContract(helper, owner);95 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');95 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');96 const rftContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);96 const rftContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);979798 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);98 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);99 await rftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});99 await rftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});148 const owner = await helper.eth.createAccountWithBalance(donor, 20n);148 const owner = await helper.eth.createAccountWithBalance(donor, 20n);149149150 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');150 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');151 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);151 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);152 const mintResult = await nftContract.methods.mint(owner).send({from: owner});152 const mintResult = await nftContract.methods.mint(owner).send({from: owner});153 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;153 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;154154168 });168 });169 const rftTokenAddress = result.events.Fractionalized.returnValues._rftToken;169 const rftTokenAddress = result.events.Fractionalized.returnValues._rftToken;170170171 const rftTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress);171 const rftTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress);172 expect(await rftTokenContract.methods.balanceOf(owner).call()).to.equal('100');172 expect(await rftTokenContract.methods.balanceOf(owner).call()).to.equal('100');173 });173 });174174181 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);181 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);182 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);182 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);183 expect(rftCollectionAddress).to.be.equal(refungibleAddress);183 expect(rftCollectionAddress).to.be.equal(refungibleAddress);184 const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);184 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);185 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});185 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});186 const result = await fractionalizer.methods.rft2nft(refungibleAddress, tokenId).send({from: owner});186 const result = await fractionalizer.methods.rft2nft(refungibleAddress, tokenId).send({from: owner});187 expect(result.events).to.be.like({187 expect(result.events).to.be.like({204 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);204 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);205 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);205 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);206 expect(rftCollectionAddress).to.be.equal(refungibleAddress);206 expect(rftCollectionAddress).to.be.equal(refungibleAddress);207 const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);207 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);208 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});208 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});209209210 const rft2nft = await fractionalizer.methods.rft2nftMapping(rftTokenAddress).call();210 const rft2nft = await fractionalizer.methods.rft2nftMapping(rftTokenAddress).call();233 itEth('call setRFTCollection twice', async ({helper}) => {233 itEth('call setRFTCollection twice', async ({helper}) => {234 const owner = await helper.eth.createAccountWithBalance(donor, 20n);234 const owner = await helper.eth.createAccountWithBalance(donor, 20n);235 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');235 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');236 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);236 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);237237238 const fractionalizer = await deployContract(helper, owner);238 const fractionalizer = await deployContract(helper, owner);239 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);239 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);247 itEth('call setRFTCollection with NFT collection', async ({helper}) => {247 itEth('call setRFTCollection with NFT collection', async ({helper}) => {248 const owner = await helper.eth.createAccountWithBalance(donor, 20n);248 const owner = await helper.eth.createAccountWithBalance(donor, 20n);249 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');249 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');250 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);250 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);251251252 const fractionalizer = await deployContract(helper, owner);252 const fractionalizer = await deployContract(helper, owner);253 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);253 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);282 const owner = await helper.eth.createAccountWithBalance(donor, 20n);282 const owner = await helper.eth.createAccountWithBalance(donor, 20n);283283284 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');284 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');285 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);285 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);286 const mintResult = await nftContract.methods.mint(owner).send({from: owner});286 const mintResult = await nftContract.methods.mint(owner).send({from: owner});287 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;287 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;288288297 const nftOwner = await helper.eth.createAccountWithBalance(donor, 10n);297 const nftOwner = await helper.eth.createAccountWithBalance(donor, 10n);298298299 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');299 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');300 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);300 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);301 const mintResult = await nftContract.methods.mint(owner).send({from: owner});301 const mintResult = await nftContract.methods.mint(owner).send({from: owner});302 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;302 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;303 await nftContract.methods.transfer(nftOwner, 1).send({from: owner});303 await nftContract.methods.transfer(nftOwner, 1).send({from: owner});314 const owner = await helper.eth.createAccountWithBalance(donor, 20n);314 const owner = await helper.eth.createAccountWithBalance(donor, 20n);315315316 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');316 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');317 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);317 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);318 const mintResult = await nftContract.methods.mint(owner).send({from: owner});318 const mintResult = await nftContract.methods.mint(owner).send({from: owner});319 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;319 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;320320329 const owner = await helper.eth.createAccountWithBalance(donor, 20n);329 const owner = await helper.eth.createAccountWithBalance(donor, 20n);330330331 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');331 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');332 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);332 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);333 const mintResult = await nftContract.methods.mint(owner).send({from: owner});333 const mintResult = await nftContract.methods.mint(owner).send({from: owner});334 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;334 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;335335345345346 const fractionalizer = await deployContract(helper, owner);346 const fractionalizer = await deployContract(helper, owner);347 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');347 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');348 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);348 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);349 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});349 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});350 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;350 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;351351358358359 const {contract: fractionalizer} = await initContract(helper, owner);359 const {contract: fractionalizer} = await initContract(helper, owner);360 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');360 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');361 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);361 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);362 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});362 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});363 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;363 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;364364369 itEth('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({helper}) => {369 itEth('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({helper}) => {370 const owner = await helper.eth.createAccountWithBalance(donor, 20n);370 const owner = await helper.eth.createAccountWithBalance(donor, 20n);371 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');371 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');372 const refungibleContract = helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);372 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);373373374 const fractionalizer = await deployContract(helper, owner);374 const fractionalizer = await deployContract(helper, owner);375375392 const {rftTokenAddress} = await mintRFTToken(helper, owner, fractionalizer, 100n);392 const {rftTokenAddress} = await mintRFTToken(helper, owner, fractionalizer, 100n);393393394 const {tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);394 const {tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);395 const refungibleTokenContract = helper.ethNativeContract.rftToken(rftTokenAddress, owner);395 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);396 await refungibleTokenContract.methods.transfer(receiver, 50).send({from: owner});396 await refungibleTokenContract.methods.transfer(receiver, 50).send({from: owner});397 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 50).send({from: receiver});397 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 50).send({from: receiver});398 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, tokenId).call({from: receiver}))398 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, tokenId).call({from: receiver}))419 const {contract: fractionalizer} = await initContract(helper, owner);419 const {contract: fractionalizer} = await initContract(helper, owner);420 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send({from: owner});420 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send({from: owner});421421422 const nftContract = helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);422 const nftContract = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);423 await nftContract.methods.approve(fractionalizer.options.address, nftToken.tokenId).send({from: owner});423 await nftContract.methods.approve(fractionalizer.options.address, nftToken.tokenId).send({from: owner});424 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftToken.tokenId, 100).call())424 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftToken.tokenId, 100).call())425 .to.be.rejectedWith(/TransferNotAllowed$/g);425 .to.be.rejectedWith(/TransferNotAllowed$/g);437 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [rftCollection.collectionId, false], true);437 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [rftCollection.collectionId, false], true);438438439 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');439 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');440 const nftContract = helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);440 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);441 const mintResult = await nftContract.methods.mint(owner).send({from: owner});441 const mintResult = await nftContract.methods.mint(owner).send({from: owner});442 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;442 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;443443tests/src/eth/fungible.test.tsdiffbeforeafterboth33 const collection = await helper.ft.mintCollection(alice);33 const collection = await helper.ft.mintCollection(alice);34 await collection.mint(alice, 200n);34 await collection.mint(alice, 200n);353536 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);36 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);37 const totalSupply = await contract.methods.totalSupply().call();37 const totalSupply = await contract.methods.totalSupply().call();38 expect(totalSupply).to.equal('200');38 expect(totalSupply).to.equal('200');39 });39 });43 const collection = await helper.ft.mintCollection(alice);43 const collection = await helper.ft.mintCollection(alice);44 await collection.mint(alice, 200n, {Ethereum: caller});44 await collection.mint(alice, 200n, {Ethereum: caller});454546 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);46 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'ft', caller);47 const balance = await contract.methods.balanceOf(caller).call();47 const balance = await contract.methods.balanceOf(caller).call();48 expect(balance).to.equal('200');48 expect(balance).to.equal('200');49 });49 });68 await collection.addAdmin(alice, {Ethereum: owner});68 await collection.addAdmin(alice, {Ethereum: owner});696970 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);70 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);71 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);71 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);727273 const result = await contract.methods.mint(receiver, 100).send();73 const result = await contract.methods.mint(receiver, 100).send();74 7495 await collection.addAdmin(alice, {Ethereum: ethOwner});95 await collection.addAdmin(alice, {Ethereum: ethOwner});96 9697 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);97 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);98 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', ethOwner);98 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', ethOwner);99 99100 // 2. Mint tokens:100 // 2. Mint tokens:101 const result = await collectionEvm.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, 100).send();101 const result = await collectionEvm.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, 100).send();123 await collection.addAdmin(alice, {Ethereum: owner});123 await collection.addAdmin(alice, {Ethereum: owner});124124125 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);125 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);126 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);126 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);127127128 const result = await contract.methods.mintBulk(Array.from({length: bulkSize}, (_, i) => (128 const result = await contract.methods.mintBulk(Array.from({length: bulkSize}, (_, i) => (129 [receivers[i], (i + 1) * 10]129 [receivers[i], (i + 1) * 10]146 await collection.addAdmin(alice, {Ethereum: owner});146 await collection.addAdmin(alice, {Ethereum: owner});147147148 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);148 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);149 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);149 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);150 await contract.methods.mint(receiver, 100).send();150 await contract.methods.mint(receiver, 100).send();151151152 const result = await contract.methods.burnFrom(receiver, 49).send({from: receiver});152 const result = await contract.methods.burnFrom(receiver, 49).send({from: receiver});168 await collection.mint(alice, 200n, {Ethereum: owner});168 await collection.mint(alice, 200n, {Ethereum: owner});169169170 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);170 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);171 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);171 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);172172173 {173 {174 const result = await contract.methods.approve(spender, 100).send({from: owner});174 const result = await contract.methods.approve(spender, 100).send({from: owner});198 await collection.mint(alice, 200n, {Ethereum: owner});198 await collection.mint(alice, 200n, {Ethereum: owner});199199200 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);200 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);201 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);201 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);202202203 {203 {204 const result = await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});204 const result = await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});242 await collection.mint(alice, 100n, {Ethereum: owner});242 await collection.mint(alice, 100n, {Ethereum: owner});243243244 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);244 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);245 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);245 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);246246247 await expect(collectionEvm.methods.approveCross(nonOwnerCross, 20).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');247 await expect(collectionEvm.methods.approveCross(nonOwnerCross, 20).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');248 });248 });257 await collection.approveTokens(owner, {Ethereum: sender}, 100n);257 await collection.approveTokens(owner, {Ethereum: sender}, 100n);258258259 const address = helper.ethAddress.fromCollectionId(collection.collectionId);259 const address = helper.ethAddress.fromCollectionId(collection.collectionId);260 const contract = helper.ethNativeContract.collection(address, 'ft');260 const contract = await helper.ethNativeContract.collection(address, 'ft');261261262 const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});262 const fromBalanceBefore = await collection.getBalance({Substrate: owner.address});263 263298 await collection.mint(alice, 200n, {Ethereum: owner});298 await collection.mint(alice, 200n, {Ethereum: owner});299299300 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);300 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);301 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);301 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);302302303 await contract.methods.approve(spender, 100).send();303 await contract.methods.approve(spender, 100).send();304304338 await collection.mint(alice, 200n, {Ethereum: sender});338 await collection.mint(alice, 200n, {Ethereum: sender});339339340 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);340 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);341 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', sender);341 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', sender);342342343 {343 {344 // Can transferCross to ethereum address:344 // Can transferCross to ethereum address:385 const collection = await helper.ft.mintCollection(alice);385 const collection = await helper.ft.mintCollection(alice);386 await collection.mint(alice, BALANCE, {Ethereum: sender});386 await collection.mint(alice, BALANCE, {Ethereum: sender});387 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);387 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);388 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', sender);388 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', sender);389389390 // 1. Cannot transfer more than have390 // 1. Cannot transfer more than have391 const receiver = testCase === 'transfer' ? receiverEth : receiverCrossEth;391 const receiver = testCase === 'transfer' ? receiverEth : receiverCrossEth;402 await collection.mint(alice, 200n, {Ethereum: owner});402 await collection.mint(alice, 200n, {Ethereum: owner});403403404 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);404 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);405 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);405 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);406406407 {407 {408 const result = await contract.methods.transfer(receiver, 50).send({from: owner});408 const result = await contract.methods.transfer(receiver, 50).send({from: owner});436 await collection.approveTokens(owner, {Ethereum: sender}, 100n);436 await collection.approveTokens(owner, {Ethereum: sender}, 100n);437437438 const address = helper.ethAddress.fromCollectionId(collection.collectionId);438 const address = helper.ethAddress.fromCollectionId(collection.collectionId);439 const contract = helper.ethNativeContract.collection(address, 'ft');439 const contract = await helper.ethNativeContract.collection(address, 'ft');440440441 const from = helper.ethCrossAccount.fromKeyringPair(owner);441 const from = helper.ethCrossAccount.fromKeyringPair(owner);442 const to = helper.ethCrossAccount.fromAddress(receiver);442 const to = helper.ethCrossAccount.fromAddress(receiver);491 await collection.mint(alice, 200n, {Ethereum: owner});491 await collection.mint(alice, 200n, {Ethereum: owner});492492493 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);493 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);494 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);494 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);495495496 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));496 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));497 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));497 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));504 await collection.mint(alice, 200n, {Ethereum: owner});504 await collection.mint(alice, 200n, {Ethereum: owner});505505506 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);506 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);507 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);507 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);508508509 await contract.methods.approve(spender, 100).send({from: owner});509 await contract.methods.approve(spender, 100).send({from: owner});510510519 await collection.mint(alice, 200n, {Ethereum: owner});519 await collection.mint(alice, 200n, {Ethereum: owner});520520521 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);521 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);522 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', owner);522 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);523523524 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));524 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));525 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));525 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));544 await collection.mint(alice, 200n);544 await collection.mint(alice, 200n);545545546 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);546 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);547 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft');547 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');548548549 const events: any = [];549 const events: any = [];550 contract.events.allEvents((_: any, event: any) => {550 contract.events.allEvents((_: any, event: any) => {570 await collection.approveTokens(alice, {Substrate: bob.address}, 100n);570 await collection.approveTokens(alice, {Substrate: bob.address}, 100n);571571572 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);572 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);573 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft');573 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');574574575 const events: any = [];575 const events: any = [];576 contract.events.allEvents((_: any, event: any) => {576 contract.events.allEvents((_: any, event: any) => {601 await collection.mint(alice, 200n);601 await collection.mint(alice, 200n);602602603 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);603 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);604 const contract = helper.ethNativeContract.collection(collectionAddress, 'ft');604 const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft');605605606 const events: any = [];606 const events: any = [];607 contract.events.allEvents((_: any, event: any) => {607 contract.events.allEvents((_: any, event: any) => {630 await collection.approveTokens(owner, {Ethereum: sender}, 100n);630 await collection.approveTokens(owner, {Ethereum: sender}, 100n);631631632 const address = helper.ethAddress.fromCollectionId(collection.collectionId);632 const address = helper.ethAddress.fromCollectionId(collection.collectionId);633 const contract = helper.ethNativeContract.collection(address, 'ft');633 const contract = await helper.ethNativeContract.collection(address, 'ft');634634635 const from = helper.ethCrossAccount.fromKeyringPair(owner);635 const from = helper.ethCrossAccount.fromKeyringPair(owner);636 const to = helper.ethCrossAccount.fromAddress(receiver);636 const to = helper.ethCrossAccount.fromAddress(receiver);tests/src/eth/helpersSmoke.test.tsdiffbeforeafterboth313132 const flipper = await helper.eth.deployFlipper(owner);32 const flipper = await helper.eth.deployFlipper(owner);333334 expect(await helper.ethNativeContract.contractHelpers(owner).methods.contractOwner(flipper.options.address).call()).to.be.equal(owner);34 expect(await (await helper.ethNativeContract.contractHelpers(owner)).methods.contractOwner(flipper.options.address).call()).to.be.equal(owner);35 });35 });363637 itEth('Flipper is working', async ({helper}) => {37 itEth('Flipper is working', async ({helper}) => {tests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth50 const matcher = await helper.ethContract.deployByCode(matcherOwner, 'MarketPlace', (await readFile(`${__dirname}/MarketPlace.sol`)).toString(), [{solPath: 'api/UniqueNFT.sol', fsPath: `${__dirname}/../api/UniqueNFT.sol`}], helper.eth.DEFAULT_GAS * 2);50 const matcher = await helper.ethContract.deployByCode(matcherOwner, 'MarketPlace', (await readFile(`${__dirname}/MarketPlace.sol`)).toString(), [{solPath: 'api/UniqueNFT.sol', fsPath: `${__dirname}/../api/UniqueNFT.sol`}], helper.eth.DEFAULT_GAS * 2);515152 const sponsor = await helper.eth.createAccountWithBalance(donor);52 const sponsor = await helper.eth.createAccountWithBalance(donor);53 const helpers = helper.ethNativeContract.contractHelpers(matcherOwner);53 const helpers = await helper.ethNativeContract.contractHelpers(matcherOwner);54 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});54 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});55 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});55 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});56 5660 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});60 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});61 await collection.confirmSponsorship(alice);61 await collection.confirmSponsorship(alice);62 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});62 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});63 const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');63 const evmCollection = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');64 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);64 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);656566 await helpers.methods.toggleAllowed(matcher.options.address, aliceMirror, true).send({from: matcherOwner});66 await helpers.methods.toggleAllowed(matcher.options.address, aliceMirror, true).send({from: matcherOwner});104 const sponsor = await helper.eth.createAccountWithBalance(donor);104 const sponsor = await helper.eth.createAccountWithBalance(donor);105 const escrow = await helper.eth.createAccountWithBalance(donor);105 const escrow = await helper.eth.createAccountWithBalance(donor);106 await matcher.methods.setEscrow(escrow, true).send({from: matcherOwner});106 await matcher.methods.setEscrow(escrow, true).send({from: matcherOwner});107 const helpers = helper.ethNativeContract.contractHelpers(matcherOwner);107 const helpers = await helper.ethNativeContract.contractHelpers(matcherOwner);108 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});108 await helpers.methods.setSponsoringMode(matcher.options.address, SponsoringMode.Allowlisted).send({from: matcherOwner});109 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});109 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});110 110114 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});114 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}, pendingSponsor: alice.address});115 await collection.confirmSponsorship(alice);115 await collection.confirmSponsorship(alice);116 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});116 await collection.addToAllowList(alice, {Substrate: aliceDoubleMirror});117 const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');117 const evmCollection = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');118 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);118 await helper.eth.transferBalanceFromSubstrate(donor, aliceMirror);119119120120168 await helper.eth.transferBalanceFromSubstrate(donor, matcher.options.address);168 await helper.eth.transferBalanceFromSubstrate(donor, matcher.options.address);169169170 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}});170 const collection = await helper.nft.mintCollection(alice, {limits: {sponsorApproveTimeout: 1}});171 const evmCollection = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');171 const evmCollection = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');172172173 await helper.balance.transferToSubstrate(donor, seller.address, 100_000_000_000_000_000_000n);173 await helper.balance.transferToSubstrate(donor, seller.address, 100_000_000_000_000_000_000n);174 174tests/src/eth/migration.seqtest.tsdiffbeforeafterboth165 const collection = await helper.nft.mintCollection(superuser);165 const collection = await helper.nft.mintCollection(superuser);166 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);166 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);167 const caller = await helper.eth.createAccountWithBalance(superuser);167 const caller = await helper.eth.createAccountWithBalance(superuser);168 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);168 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);169169170 const events: any = [];170 const events: any = [];171 contract.events.allEvents((_: any, event: any) => {171 contract.events.allEvents((_: any, event: any) => {tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth9): Promise<{ collectionId: number, collectionAddress: string, contract: Contract }> => {9): Promise<{ collectionId: number, collectionAddress: string, contract: Contract }> => {10 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');10 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');111112 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);12 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);13 await contract.methods.setCollectionNesting(true).send({from: owner});13 await contract.methods.setCollectionNesting(true).send({from: owner});141415 return {collectionId, collectionAddress, contract};15 return {collectionId, collectionAddress, contract};55 itEth('NFT: collectionNestingRestrictedCollectionIds() & collectionNestingPermissions', async ({helper}) => {55 itEth('NFT: collectionNestingRestrictedCollectionIds() & collectionNestingPermissions', async ({helper}) => {56 const owner = await helper.eth.createAccountWithBalance(donor);56 const owner = await helper.eth.createAccountWithBalance(donor);57 const {collectionId: unnestedCollsectionId, collectionAddress: unnsetedCollectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');57 const {collectionId: unnestedCollsectionId, collectionAddress: unnsetedCollectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');58 const unnestedContract = helper.ethNativeContract.collection(unnsetedCollectionAddress, 'nft', owner);58 const unnestedContract = await helper.ethNativeContract.collection(unnsetedCollectionAddress, 'nft', owner);59 expect(await unnestedContract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([false, []]);59 expect(await unnestedContract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([false, []]);60 6061 const {contract} = await createNestingCollection(helper, owner);61 const {contract} = await createNestingCollection(helper, owner);tests/src/eth/nonFungible.test.tsdiffbeforeafterboth373738 const caller = await helper.eth.createAccountWithBalance(donor);38 const caller = await helper.eth.createAccountWithBalance(donor);393940 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);40 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);41 const totalSupply = await contract.methods.totalSupply().call();41 const totalSupply = await contract.methods.totalSupply().call();424243 expect(totalSupply).to.equal('1');43 expect(totalSupply).to.equal('1');51 await collection.mintToken(alice, {Ethereum: caller});51 await collection.mintToken(alice, {Ethereum: caller});52 await collection.mintToken(alice, {Ethereum: caller});52 await collection.mintToken(alice, {Ethereum: caller});535354 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);54 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);55 const balance = await contract.methods.balanceOf(caller).call();55 const balance = await contract.methods.balanceOf(caller).call();565657 expect(balance).to.equal('3');57 expect(balance).to.equal('3');636364 const token = await collection.mintToken(alice, {Ethereum: caller});64 const token = await collection.mintToken(alice, {Ethereum: caller});656566 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);66 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);676768 const owner = await contract.methods.ownerOf(token.tokenId).call();68 const owner = await contract.methods.ownerOf(token.tokenId).call();696974 const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});74 const collection = await helper.nft.mintCollection(alice, {name: 'test', tokenPrefix: 'TEST'});75 const caller = helper.eth.createAccount();75 const caller = helper.eth.createAccount();767677 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);77 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);787879 expect(await contract.methods.name().call()).to.equal('test');79 expect(await contract.methods.name().call()).to.equal('test');80 expect(await contract.methods.symbol().call()).to.equal('TEST');80 expect(await contract.methods.symbol().call()).to.equal('TEST');95 const receiver = helper.eth.createAccount();95 const receiver = helper.eth.createAccount();969697 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);97 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);98 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);98 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);9999100 const result = await contract.methods.mint(receiver).send();100 const result = await contract.methods.mint(receiver).send();101 const tokenId = result.events.Transfer.returnValues.tokenId;101 const tokenId = result.events.Transfer.returnValues.tokenId;155 const receiver = helper.eth.createAccount();155 const receiver = helper.eth.createAccount();156156157 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');157 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');158 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);158 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);159159160 const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();160 const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();161 const tokenId = result.events.Transfer.returnValues.tokenId;161 const tokenId = result.events.Transfer.returnValues.tokenId;209 await collection.addAdmin(minter, {Ethereum: collectionAdmin});209 await collection.addAdmin(minter, {Ethereum: collectionAdmin});210 210211 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);211 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);212 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', collectionAdmin, true);212 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', collectionAdmin, true);213 let expectedTokenId = await contract.methods.nextTokenId().call();213 let expectedTokenId = await contract.methods.nextTokenId().call();214 let result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, []).send();214 let result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, []).send();215 let tokenId = result.events.Transfer.returnValues.tokenId;215 let tokenId = result.events.Transfer.returnValues.tokenId;247247248 const collection = await helper.nft.mintCollection(minter);248 const collection = await helper.nft.mintCollection(minter);249 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);249 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);250 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft');250 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft');251251252 await expect(collectionEvm.methods.mintCross(nonOwnerCross, []).call({from: nonOwner}))252 await expect(collectionEvm.methods.mintCross(nonOwnerCross, []).call({from: nonOwner}))253 .to.be.rejectedWith('PublicMintingNotAllowed');253 .to.be.rejectedWith('PublicMintingNotAllowed');262 await collection.addAdmin(minter, {Ethereum: caller});262 await collection.addAdmin(minter, {Ethereum: caller});263263264 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);264 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);265 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);265 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);266 {266 {267 const bulkSize = 3;267 const bulkSize = 3;268 const nextTokenId = await contract.methods.nextTokenId().call();268 const nextTokenId = await contract.methods.nextTokenId().call();294 const {tokenId} = await collection.mintToken(minter, {Ethereum: caller});294 const {tokenId} = await collection.mintToken(minter, {Ethereum: caller});295295296 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);296 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);297 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);297 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);298298299 {299 {300 const result = await contract.methods.burn(tokenId).send({from: caller});300 const result = await contract.methods.burn(tokenId).send({from: caller});315 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});315 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});316316317 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);317 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);318 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);318 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);319319320 {320 {321 const result = await contract.methods.approve(spender, tokenId).send({from: owner});321 const result = await contract.methods.approve(spender, tokenId).send({from: owner});335 const collection = await helper.nft.mintCollection(minter, {});335 const collection = await helper.nft.mintCollection(minter, {});336336337 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);337 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);338 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);338 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);339339340 const approvedBefore = await contract.methods.isApprovedForAll(owner, operator).call();340 const approvedBefore = await contract.methods.isApprovedForAll(owner, operator).call();341 expect(approvedBefore).to.be.equal(false);341 expect(approvedBefore).to.be.equal(false);384 const token = await collection.mintToken(minter, {Ethereum: owner});384 const token = await collection.mintToken(minter, {Ethereum: owner});385385386 const address = helper.ethAddress.fromCollectionId(collection.collectionId);386 const address = helper.ethAddress.fromCollectionId(collection.collectionId);387 const contract = helper.ethNativeContract.collection(address, 'nft');387 const contract = await helper.ethNativeContract.collection(address, 'nft');388388389 {389 {390 await contract.methods.setApprovalForAll(operator, true).send({from: owner});390 await contract.methods.setApprovalForAll(operator, true).send({from: owner});416 const token = await collection.mintToken(minter, {Ethereum: owner});416 const token = await collection.mintToken(minter, {Ethereum: owner});417417418 const address = helper.ethAddress.fromCollectionId(collection.collectionId);418 const address = helper.ethAddress.fromCollectionId(collection.collectionId);419 const contract = helper.ethNativeContract.collection(address, 'nft');419 const contract = await helper.ethNativeContract.collection(address, 'nft');420420421 {421 {422 await contract.methods.setApprovalForAll(operator, true).send({from: owner});422 await contract.methods.setApprovalForAll(operator, true).send({from: owner});452 const token2 = await collection.mintToken(minter, {Ethereum: ownerEth});452 const token2 = await collection.mintToken(minter, {Ethereum: ownerEth});453453454 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);454 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);455 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft');455 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft');456456457 // Approve tokens from substrate and ethereum:457 // Approve tokens from substrate and ethereum:458 await token1.approve(ownerSub, {Ethereum: burnerEth});458 await token1.approve(ownerSub, {Ethereum: burnerEth});499 const token1 = await collection.mintToken(minter, {Ethereum: owner});499 const token1 = await collection.mintToken(minter, {Ethereum: owner});500 const token2 = await collection.mintToken(minter, {Ethereum: owner});500 const token2 = await collection.mintToken(minter, {Ethereum: owner});501501502 const collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');502 const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');503503504 // Can approveCross substrate and ethereum address:504 // Can approveCross substrate and ethereum address:505 const resultSub = await collectionEvm.methods.approveCross(recieverCrossSub, token1.tokenId).send({from: owner});505 const resultSub = await collectionEvm.methods.approveCross(recieverCrossSub, token1.tokenId).send({from: owner});538 const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);538 const nonOwnerCross = helper.ethCrossAccount.fromAddress(nonOwner);539 const owner = await helper.eth.createAccountWithBalance(donor);539 const owner = await helper.eth.createAccountWithBalance(donor);540 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});540 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});541 const collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');541 const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');542 const token = await collection.mintToken(minter, {Ethereum: owner});542 const token = await collection.mintToken(minter, {Ethereum: owner});543543544 await expect(collectionEvm.methods.approveCross(nonOwnerCross, token.tokenId).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');544 await expect(collectionEvm.methods.approveCross(nonOwnerCross, token.tokenId).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');553 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});553 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});554 const token1 = await collection.mintToken(minter, {Ethereum: owner});554 const token1 = await collection.mintToken(minter, {Ethereum: owner});555 const token2 = await collection.mintToken(minter, {Ethereum: owner});555 const token2 = await collection.mintToken(minter, {Ethereum: owner});556 const collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');556 const collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');557557558 // Can approve and reaffirm approved address:558 // Can approve and reaffirm approved address:559 await collectionEvm.methods.approveCross(receiver1Cross, token1.tokenId).send({from: owner});559 await collectionEvm.methods.approveCross(receiver1Cross, token1.tokenId).send({from: owner});581 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});581 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});582582583 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);583 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);584 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);584 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);585585586 await contract.methods.approve(spender, tokenId).send({from: owner});586 await contract.methods.approve(spender, tokenId).send({from: owner});587587615 const token = await collection.mintToken(minter, {Substrate: owner.address});615 const token = await collection.mintToken(minter, {Substrate: owner.address});616616617 const address = helper.ethAddress.fromCollectionId(collection.collectionId);617 const address = helper.ethAddress.fromCollectionId(collection.collectionId);618 const contract = helper.ethNativeContract.collection(address, 'nft');618 const contract = await helper.ethNativeContract.collection(address, 'nft');619619620 await token.approve(owner, {Ethereum: spender});620 await token.approve(owner, {Ethereum: spender});621621646 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});646 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});647647648 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);648 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);649 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);649 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);650650651 {651 {652 const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});652 const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});679 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});679 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});680680681 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);681 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);682 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);682 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);683683684 {684 {685 // Can transferCross to ethereum address:685 // Can transferCross to ethereum address:727727728 const collection = await helper.nft.mintCollection(minter, {});728 const collection = await helper.nft.mintCollection(minter, {});729 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);729 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);730 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', sender);730 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', sender);731731732 await collection.mintToken(minter, {Ethereum: sender});732 await collection.mintToken(minter, {Ethereum: sender});733 const nonSendersToken = await collection.mintToken(minter, {Ethereum: tokenOwner});733 const nonSendersToken = await collection.mintToken(minter, {Ethereum: tokenOwner});760 const collection = await helper.nft.mintCollection(alice, {});760 const collection = await helper.nft.mintCollection(alice, {});761 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});761 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});762762763 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);763 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);764764765 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));765 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));766 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));766 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));773 const collection = await helper.nft.mintCollection(alice, {});773 const collection = await helper.nft.mintCollection(alice, {});774 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});774 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});775775776 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);776 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);777777778 await contract.methods.approve(spender, tokenId).send({from: owner});778 await contract.methods.approve(spender, tokenId).send({from: owner});779779792 const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});792 const token = await collection.mintToken(collectionMinter, {Substrate: owner.address});793793794 const address = helper.ethAddress.fromCollectionId(collection.collectionId);794 const address = helper.ethAddress.fromCollectionId(collection.collectionId);795 const contract = helper.ethNativeContract.collection(address, 'nft');795 const contract = await helper.ethNativeContract.collection(address, 'nft');796796797 await token.approve(owner, {Ethereum: spender});797 await token.approve(owner, {Ethereum: spender});798798822 const collection = await helper.nft.mintCollection(alice, {});822 const collection = await helper.nft.mintCollection(alice, {});823 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});823 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});824824825 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);825 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', owner);826826827 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));827 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));828 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));828 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));843 itEth('Events emitted for mint()', async ({helper}) => {843 itEth('Events emitted for mint()', async ({helper}) => {844 const collection = await helper.nft.mintCollection(alice, {});844 const collection = await helper.nft.mintCollection(alice, {});845 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);845 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);846 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');846 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');847847848 const events: any = [];848 const events: any = [];849 contract.events.allEvents((_: any, event: any) => {849 contract.events.allEvents((_: any, event: any) => {866 const token = await collection.mintToken(alice);866 const token = await collection.mintToken(alice);867867868 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);868 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);869 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');869 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');870870871 const events: any = [];871 const events: any = [];872 contract.events.allEvents((_: any, event: any) => {872 contract.events.allEvents((_: any, event: any) => {891 const token = await collection.mintToken(alice);891 const token = await collection.mintToken(alice);892892893 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);893 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);894 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');894 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');895895896 const events: any = [];896 const events: any = [];897 contract.events.allEvents((_: any, event: any) => {897 contract.events.allEvents((_: any, event: any) => {918 await token.approve(alice, {Substrate: bob.address});918 await token.approve(alice, {Substrate: bob.address});919919920 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);920 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);921 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');921 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');922922923 const events: any = [];923 const events: any = [];924 contract.events.allEvents((_: any, event: any) => {924 contract.events.allEvents((_: any, event: any) => {943 const token = await collection.mintToken(alice);943 const token = await collection.mintToken(alice);944944945 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);945 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);946 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');946 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');947947948 const events: any = [];948 const events: any = [];949 contract.events.allEvents((_: any, event: any) => {949 contract.events.allEvents((_: any, event: any) => {993 },993 },994 );994 );995995996 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);996 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);997 const name = await contract.methods.name().call();997 const name = await contract.methods.name().call();998 expect(name).to.equal('oh River');998 expect(name).to.equal('oh River');999 });999 });1018 },1018 },1019 );1019 );102010201021 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);1021 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller);1022 const symbol = await contract.methods.symbol().call();1022 const symbol = await contract.methods.symbol().call();1023 expect(symbol).to.equal('CHANGE');1023 expect(symbol).to.equal('CHANGE');1024 });1024 });1045 const token = await collection.mintToken(minter, {Ethereum: owner});1045 const token = await collection.mintToken(minter, {Ethereum: owner});104610461047 const address = helper.ethAddress.fromCollectionId(collection.collectionId);1047 const address = helper.ethAddress.fromCollectionId(collection.collectionId);1048 const contract = helper.ethNativeContract.collection(address, 'nft');1048 const contract = await helper.ethNativeContract.collection(address, 'nft');104910491050 const ownerCross = helper.ethCrossAccount.fromAddress(owner);1050 const ownerCross = helper.ethCrossAccount.fromAddress(owner);1051 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;1051 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;1066 const token = await collection.mintToken(minter, {Ethereum: owner});1066 const token = await collection.mintToken(minter, {Ethereum: owner});106710671068 const address = helper.ethAddress.fromCollectionId(collection.collectionId);1068 const address = helper.ethAddress.fromCollectionId(collection.collectionId);1069 const contract = helper.ethNativeContract.collection(address, 'nft');1069 const contract = await helper.ethNativeContract.collection(address, 'nft');107010701071 const ownerCross = helper.ethCrossAccount.fromAddress(owner);1071 const ownerCross = helper.ethCrossAccount.fromAddress(owner);1072 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);1072 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);tests/src/eth/payable.test.tsdiffbeforeafterboth175 const SMALL_FEE = 1n * helper.balance.getOneTokenNominal();175 const SMALL_FEE = 1n * helper.balance.getOneTokenNominal();176 const BIG_FEE = 3n * helper.balance.getOneTokenNominal();176 const BIG_FEE = 3n * helper.balance.getOneTokenNominal();177 const caller = await helper.eth.createAccountWithBalance(donor);177 const caller = await helper.eth.createAccountWithBalance(donor);178 const collectionHelper = helper.ethNativeContract.collectionHelpers(caller);178 const collectionHelper = await helper.ethNativeContract.collectionHelpers(caller);179179180 await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');180 await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');181 await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');181 await expect(collectionHelper.methods.createNFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');185 const SMALL_FEE = 1n * helper.balance.getOneTokenNominal();185 const SMALL_FEE = 1n * helper.balance.getOneTokenNominal();186 const BIG_FEE = 3n * helper.balance.getOneTokenNominal();186 const BIG_FEE = 3n * helper.balance.getOneTokenNominal();187 const caller = await helper.eth.createAccountWithBalance(donor);187 const caller = await helper.eth.createAccountWithBalance(donor);188 const collectionHelper = helper.ethNativeContract.collectionHelpers(caller);188 const collectionHelper = await helper.ethNativeContract.collectionHelpers(caller);189189190 await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');190 await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(SMALL_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');191 await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');191 await expect(collectionHelper.methods.createRFTCollection('A', 'B', 'C').call({value: Number(BIG_FEE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');tests/src/eth/proxy/fungibleProxy.test.tsdiffbeforeafterboth48 await collection.mint(alice, 200n, {Substrate: alice.address});48 await collection.mint(alice, 200n, {Substrate: alice.address});494950 const address = helper.ethAddress.fromCollectionId(collection.collectionId);50 const address = helper.ethAddress.fromCollectionId(collection.collectionId);51 const evmCollection = helper.ethNativeContract.collection(address, 'ft', caller);51 const evmCollection = await helper.ethNativeContract.collection(address, 'ft', caller);52 const contract = await proxyWrap(helper, evmCollection, donor);52 const contract = await proxyWrap(helper, evmCollection, donor);53 const totalSupply = await contract.methods.totalSupply().call();53 const totalSupply = await contract.methods.totalSupply().call();545462 await collection.mint(alice, 200n, {Ethereum: caller});62 await collection.mint(alice, 200n, {Ethereum: caller});636364 const address = helper.ethAddress.fromCollectionId(collection.collectionId);64 const address = helper.ethAddress.fromCollectionId(collection.collectionId);65 const evmCollection = helper.ethNativeContract.collection(address, 'ft', caller);65 const evmCollection = await helper.ethNativeContract.collection(address, 'ft', caller);66 const contract = await proxyWrap(helper, evmCollection, donor);66 const contract = await proxyWrap(helper, evmCollection, donor);67 const balance = await contract.methods.balanceOf(caller).call();67 const balance = await contract.methods.balanceOf(caller).call();686887 const spender = helper.eth.createAccount();87 const spender = helper.eth.createAccount();888889 const address = helper.ethAddress.fromCollectionId(collection.collectionId);89 const address = helper.ethAddress.fromCollectionId(collection.collectionId);90 const evmCollection = helper.ethNativeContract.collection(address, 'ft', caller);90 const evmCollection = await helper.ethNativeContract.collection(address, 'ft', caller);91 const contract = await proxyWrap(helper, evmCollection, donor);91 const contract = await proxyWrap(helper, evmCollection, donor);92 await collection.mint(alice, 200n, {Ethereum: contract.options.address});92 await collection.mint(alice, 200n, {Ethereum: contract.options.address});9393123 const receiver = helper.eth.createAccount();123 const receiver = helper.eth.createAccount();124124125 const address = helper.ethAddress.fromCollectionId(collection.collectionId);125 const address = helper.ethAddress.fromCollectionId(collection.collectionId);126 const evmCollection = helper.ethNativeContract.collection(address, 'ft', caller);126 const evmCollection = await helper.ethNativeContract.collection(address, 'ft', caller);127 const contract = await proxyWrap(helper, evmCollection, donor);127 const contract = await proxyWrap(helper, evmCollection, donor);128128129 await evmCollection.methods.approve(contract.options.address, 100).send({from: owner});129 await evmCollection.methods.approve(contract.options.address, 100).send({from: owner});170 const receiver = await helper.eth.createAccountWithBalance(donor);170 const receiver = await helper.eth.createAccountWithBalance(donor);171171172 const address = helper.ethAddress.fromCollectionId(collection.collectionId);172 const address = helper.ethAddress.fromCollectionId(collection.collectionId);173 const evmCollection = helper.ethNativeContract.collection(address, 'ft', caller);173 const evmCollection = await helper.ethNativeContract.collection(address, 'ft', caller);174 const contract = await proxyWrap(helper, evmCollection, donor);174 const contract = await proxyWrap(helper, evmCollection, donor);175 await collection.mint(alice, 200n, {Ethereum: contract.options.address});175 await collection.mint(alice, 200n, {Ethereum: contract.options.address});176176tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth48 await collection.mintToken(alice, {Substrate: alice.address});48 await collection.mintToken(alice, {Substrate: alice.address});494950 const address = helper.ethAddress.fromCollectionId(collection.collectionId);50 const address = helper.ethAddress.fromCollectionId(collection.collectionId);51 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);51 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);52 const contract = await proxyWrap(helper, evmCollection, donor);52 const contract = await proxyWrap(helper, evmCollection, donor);53 const totalSupply = await contract.methods.totalSupply().call();53 const totalSupply = await contract.methods.totalSupply().call();545466 ]);66 ]);676768 const address = helper.ethAddress.fromCollectionId(collection.collectionId);68 const address = helper.ethAddress.fromCollectionId(collection.collectionId);69 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);69 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);70 const contract = await proxyWrap(helper, evmCollection, donor);70 const contract = await proxyWrap(helper, evmCollection, donor);71 const balance = await contract.methods.balanceOf(caller).call();71 const balance = await contract.methods.balanceOf(caller).call();727280 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});80 const {tokenId} = await collection.mintToken(alice, {Ethereum: caller});818182 const address = helper.ethAddress.fromCollectionId(collection.collectionId);82 const address = helper.ethAddress.fromCollectionId(collection.collectionId);83 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);83 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);84 const contract = await proxyWrap(helper, evmCollection, donor);84 const contract = await proxyWrap(helper, evmCollection, donor);85 const owner = await contract.methods.ownerOf(tokenId).call();85 const owner = await contract.methods.ownerOf(tokenId).call();8686106 const caller = await helper.eth.createAccountWithBalance(donor);106 const caller = await helper.eth.createAccountWithBalance(donor);107 const receiver = helper.eth.createAccount();107 const receiver = helper.eth.createAccount();108108109 const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);109 const collectionEvmOwned = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);110 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller, true);110 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller, true);111 const contract = await proxyWrap(helper, collectionEvm, donor);111 const contract = await proxyWrap(helper, collectionEvm, donor);112 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();112 await collectionEvmOwned.methods.addCollectionAdmin(contract.options.address).send();113113141 const caller = await helper.eth.createAccountWithBalance(donor);141 const caller = await helper.eth.createAccountWithBalance(donor);142 const receiver = helper.eth.createAccount();142 const receiver = helper.eth.createAccount();143143144 const collectionEvmOwned = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);144 const collectionEvmOwned = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);145 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', caller);145 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', caller);146 const contract = await proxyWrap(helper, collectionEvm, donor);146 const contract = await proxyWrap(helper, collectionEvm, donor);147 const contractAddressCross = helper.ethCrossAccount.fromAddress(contract.options.address);147 const contractAddressCross = helper.ethCrossAccount.fromAddress(contract.options.address);148 await collectionEvmOwned.methods.addCollectionAdminCross(contractAddressCross).send();148 await collectionEvmOwned.methods.addCollectionAdminCross(contractAddressCross).send();179 const receiver = helper.eth.createAccount();179 const receiver = helper.eth.createAccount();180180181 const address = helper.ethAddress.fromCollectionId(collection.collectionId);181 const address = helper.ethAddress.fromCollectionId(collection.collectionId);182 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);182 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);183 const contract = await proxyWrap(helper, evmCollection, donor);183 const contract = await proxyWrap(helper, evmCollection, donor);184 await collection.addAdmin(donor, {Ethereum: contract.options.address});184 await collection.addAdmin(donor, {Ethereum: contract.options.address});185185237 const caller = await helper.eth.createAccountWithBalance(donor);237 const caller = await helper.eth.createAccountWithBalance(donor);238238239 const address = helper.ethAddress.fromCollectionId(collection.collectionId);239 const address = helper.ethAddress.fromCollectionId(collection.collectionId);240 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);240 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);241 const contract = await proxyWrap(helper, evmCollection, donor);241 const contract = await proxyWrap(helper, evmCollection, donor);242 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});242 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});243 await collection.addAdmin(alice, {Ethereum: contract.options.address});243 await collection.addAdmin(alice, {Ethereum: contract.options.address});266 const spender = helper.eth.createAccount();266 const spender = helper.eth.createAccount();267267268 const address = helper.ethAddress.fromCollectionId(collection.collectionId);268 const address = helper.ethAddress.fromCollectionId(collection.collectionId);269 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);269 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);270 const contract = await proxyWrap(helper, evmCollection, donor);270 const contract = await proxyWrap(helper, evmCollection, donor);271 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});271 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});272272296 const receiver = helper.eth.createAccount();296 const receiver = helper.eth.createAccount();297297298 const address = helper.ethAddress.fromCollectionId(collection.collectionId);298 const address = helper.ethAddress.fromCollectionId(collection.collectionId);299 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);299 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);300 const contract = await proxyWrap(helper, evmCollection, donor);300 const contract = await proxyWrap(helper, evmCollection, donor);301 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});301 const {tokenId} = await collection.mintToken(alice, {Ethereum: owner});302302335 const receiver = helper.eth.createAccount();335 const receiver = helper.eth.createAccount();336336337 const address = helper.ethAddress.fromCollectionId(collection.collectionId);337 const address = helper.ethAddress.fromCollectionId(collection.collectionId);338 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);338 const evmCollection = await helper.ethNativeContract.collection(address, 'nft', caller);339 const contract = await proxyWrap(helper, evmCollection, donor);339 const contract = await proxyWrap(helper, evmCollection, donor);340 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});340 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});341341tests/src/eth/reFungible.test.tsdiffbeforeafterboth33 itEth('totalSupply', async ({helper}) => {33 itEth('totalSupply', async ({helper}) => {34 const caller = await helper.eth.createAccountWithBalance(donor);34 const caller = await helper.eth.createAccountWithBalance(donor);35 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'TotalSupply', '6', '6');35 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'TotalSupply', '6', '6');36 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);36 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);373738 await contract.methods.mint(caller).send();38 await contract.methods.mint(caller).send();393944 itEth('balanceOf', async ({helper}) => {44 itEth('balanceOf', async ({helper}) => {45 const caller = await helper.eth.createAccountWithBalance(donor);45 const caller = await helper.eth.createAccountWithBalance(donor);46 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'BalanceOf', '6', '6');46 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'BalanceOf', '6', '6');47 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);47 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);484849 await contract.methods.mint(caller).send();49 await contract.methods.mint(caller).send();50 await contract.methods.mint(caller).send();50 await contract.methods.mint(caller).send();57 itEth('ownerOf', async ({helper}) => {57 itEth('ownerOf', async ({helper}) => {58 const caller = await helper.eth.createAccountWithBalance(donor);58 const caller = await helper.eth.createAccountWithBalance(donor);59 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf', '6', '6');59 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf', '6', '6');60 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);60 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);616162 const result = await contract.methods.mint(caller).send();62 const result = await contract.methods.mint(caller).send();63 const tokenId = result.events.Transfer.returnValues.tokenId;63 const tokenId = result.events.Transfer.returnValues.tokenId;70 const caller = await helper.eth.createAccountWithBalance(donor);70 const caller = await helper.eth.createAccountWithBalance(donor);71 const receiver = helper.eth.createAccount();71 const receiver = helper.eth.createAccount();72 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf-AfterBurn', '6', '6');72 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'OwnerOf-AfterBurn', '6', '6');73 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);73 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);747475 const result = await contract.methods.mint(caller).send();75 const result = await contract.methods.mint(caller).send();76 const tokenId = result.events.Transfer.returnValues.tokenId;76 const tokenId = result.events.Transfer.returnValues.tokenId;77 const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);77 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);787879 await tokenContract.methods.repartition(2).send();79 await tokenContract.methods.repartition(2).send();80 await tokenContract.methods.transfer(receiver, 1).send();80 await tokenContract.methods.transfer(receiver, 1).send();89 const caller = await helper.eth.createAccountWithBalance(donor);89 const caller = await helper.eth.createAccountWithBalance(donor);90 const receiver = helper.eth.createAccount();90 const receiver = helper.eth.createAccount();91 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');91 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');92 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);92 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);939394 const result = await contract.methods.mint(caller).send();94 const result = await contract.methods.mint(caller).send();95 const tokenId = result.events.Transfer.returnValues.tokenId;95 const tokenId = result.events.Transfer.returnValues.tokenId;96 const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);96 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);979798 await tokenContract.methods.repartition(2).send();98 await tokenContract.methods.repartition(2).send();99 await tokenContract.methods.transfer(receiver, 1).send();99 await tokenContract.methods.transfer(receiver, 1).send();122 const owner = await helper.eth.createAccountWithBalance(donor);122 const owner = await helper.eth.createAccountWithBalance(donor);123 const receiver = helper.eth.createAccount();123 const receiver = helper.eth.createAccount();124 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Minty', '6', '6', '');124 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Minty', '6', '6', '');125 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);125 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);126126127 const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();127 const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();128128164 await collection.addAdmin(minter, {Ethereum: collectionAdmin});164 await collection.addAdmin(minter, {Ethereum: collectionAdmin});165 165166 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);166 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);167 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', collectionAdmin, true);167 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', collectionAdmin, true);168 let expectedTokenId = await contract.methods.nextTokenId().call();168 let expectedTokenId = await contract.methods.nextTokenId().call();169 let result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, []).send();169 let result = await contract.methods.mintCross(testCase === 'ethereum' ? receiverCrossEth : receiverCrossSub, []).send();170 let tokenId = result.events.Transfer.returnValues.tokenId;170 let tokenId = result.events.Transfer.returnValues.tokenId;200 const owner = await helper.eth.createAccountWithBalance(donor);200 const owner = await helper.eth.createAccountWithBalance(donor);201 const receiver = helper.eth.createAccount();201 const receiver = helper.eth.createAccount();202 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'MintBulky', '6', '6', '');202 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'MintBulky', '6', '6', '');203 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);203 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);204204205 {205 {206 const nextTokenId = await contract.methods.nextTokenId().call();206 const nextTokenId = await contract.methods.nextTokenId().call();236 const collection = await helper.rft.mintCollection(minter, {});236 const collection = await helper.rft.mintCollection(minter, {});237237238 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);238 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);239 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);239 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);240240241 const approvedBefore = await contract.methods.isApprovedForAll(owner, operator).call();241 const approvedBefore = await contract.methods.isApprovedForAll(owner, operator).call();242 expect(approvedBefore).to.be.equal(false);242 expect(approvedBefore).to.be.equal(false);285 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});285 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});286286287 const address = helper.ethAddress.fromCollectionId(collection.collectionId);287 const address = helper.ethAddress.fromCollectionId(collection.collectionId);288 const contract = helper.ethNativeContract.collection(address, 'rft');288 const contract = await helper.ethNativeContract.collection(address, 'rft');289289290 {290 {291 await contract.methods.setApprovalForAll(operator, true).send({from: owner});291 await contract.methods.setApprovalForAll(operator, true).send({from: owner});314 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});314 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});315315316 const address = helper.ethAddress.fromCollectionId(collection.collectionId);316 const address = helper.ethAddress.fromCollectionId(collection.collectionId);317 const contract = helper.ethNativeContract.collection(address, 'rft');317 const contract = await helper.ethNativeContract.collection(address, 'rft');318318319 const rftToken = helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner);319 const rftToken = await helper.ethNativeContract.rftTokenById(token.collectionId, token.tokenId, owner);320320321 {321 {322 await rftToken.methods.approve(operator, 15n).send({from: owner});322 await rftToken.methods.approve(operator, 15n).send({from: owner});337 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});337 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});338338339 const address = helper.ethAddress.fromCollectionId(collection.collectionId);339 const address = helper.ethAddress.fromCollectionId(collection.collectionId);340 const contract = helper.ethNativeContract.collection(address, 'rft');340 const contract = await helper.ethNativeContract.collection(address, 'rft');341341342 {342 {343 await contract.methods.setApprovalForAll(operator, true).send({from: owner});343 await contract.methods.setApprovalForAll(operator, true).send({from: owner});362 itEth('Can perform burn()', async ({helper}) => {362 itEth('Can perform burn()', async ({helper}) => {363 const caller = await helper.eth.createAccountWithBalance(donor);363 const caller = await helper.eth.createAccountWithBalance(donor);364 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Burny', '6', '6');364 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Burny', '6', '6');365 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);365 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);366366367 const result = await contract.methods.mint(caller).send();367 const result = await contract.methods.mint(caller).send();368 const tokenId = result.events.Transfer.returnValues.tokenId;368 const tokenId = result.events.Transfer.returnValues.tokenId;380 const caller = await helper.eth.createAccountWithBalance(donor);380 const caller = await helper.eth.createAccountWithBalance(donor);381 const receiver = helper.eth.createAccount();381 const receiver = helper.eth.createAccount();382 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'TransferFromy', '6', '6');382 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'TransferFromy', '6', '6');383 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);383 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);384384385 const result = await contract.methods.mint(caller).send();385 const result = await contract.methods.mint(caller).send();386 const tokenId = result.events.Transfer.returnValues.tokenId;386 const tokenId = result.events.Transfer.returnValues.tokenId;387387388 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);388 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);389389390 const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);390 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller);391 await tokenContract.methods.repartition(15).send();391 await tokenContract.methods.repartition(15).send();392392393 {393 {432 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});432 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});433433434 const address = helper.ethAddress.fromCollectionId(collection.collectionId);434 const address = helper.ethAddress.fromCollectionId(collection.collectionId);435 const contract = helper.ethNativeContract.collection(address, 'rft', spender, true);435 const contract = await helper.ethNativeContract.collection(address, 'rft', spender, true);436436437 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);437 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);438 const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);438 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, owner);439 await tokenContract.methods.repartition(15).send();439 await tokenContract.methods.repartition(15).send();440 await tokenContract.methods.approve(spender, 15).send();440 await tokenContract.methods.approve(spender, 15).send();441441465 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});465 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});466466467 const address = helper.ethAddress.fromCollectionId(collection.collectionId);467 const address = helper.ethAddress.fromCollectionId(collection.collectionId);468 const contract = helper.ethNativeContract.collection(address, 'rft');468 const contract = await helper.ethNativeContract.collection(address, 'rft');469469470 await token.repartition(owner, 15n);470 await token.repartition(owner, 15n);471 await token.approve(owner, {Ethereum: spender}, 15n);471 await token.approve(owner, {Ethereum: spender}, 15n);498 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});498 const token = await collection.mintToken(minter, 100n, {Substrate: owner.address});499499500 const address = helper.ethAddress.fromCollectionId(collection.collectionId);500 const address = helper.ethAddress.fromCollectionId(collection.collectionId);501 const contract = helper.ethNativeContract.collection(address, 'rft');501 const contract = await helper.ethNativeContract.collection(address, 'rft');502502503 await token.repartition(owner, 15n);503 await token.repartition(owner, 15n);504 await token.approve(owner, {Ethereum: spender}, 15n);504 await token.approve(owner, {Ethereum: spender}, 15n);526 const caller = await helper.eth.createAccountWithBalance(donor);526 const caller = await helper.eth.createAccountWithBalance(donor);527 const receiver = helper.eth.createAccount();527 const receiver = helper.eth.createAccount();528 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry', '6', '6');528 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry', '6', '6');529 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);529 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);530530531 const result = await contract.methods.mint(caller).send();531 const result = await contract.methods.mint(caller).send();532 const tokenId = result.events.Transfer.returnValues.tokenId;532 const tokenId = result.events.Transfer.returnValues.tokenId;560560561 const collection = await helper.rft.mintCollection(minter, {});561 const collection = await helper.rft.mintCollection(minter, {});562 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);562 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);563 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);563 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'rft', sender);564564565 const token = await collection.mintToken(minter, 50n, {Ethereum: sender});565 const token = await collection.mintToken(minter, 50n, {Ethereum: sender});566566611611612 const collection = await helper.rft.mintCollection(minter, {});612 const collection = await helper.rft.mintCollection(minter, {});613 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);613 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);614 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', sender);614 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'rft', sender);615615616 await collection.mintToken(minter, 50n, {Ethereum: sender});616 await collection.mintToken(minter, 50n, {Ethereum: sender});617 const nonSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});617 const nonSendersToken = await collection.mintToken(minter, 50n, {Ethereum: tokenOwner});627 const caller = await helper.eth.createAccountWithBalance(donor);627 const caller = await helper.eth.createAccountWithBalance(donor);628 const receiver = helper.eth.createAccount();628 const receiver = helper.eth.createAccount();629 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Partial-to-Full', '6', '6');629 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Partial-to-Full', '6', '6');630 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);630 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);631631632 const result = await contract.methods.mint(caller).send();632 const result = await contract.methods.mint(caller).send();633 const tokenId = result.events.Transfer.returnValues.tokenId;633 const tokenId = result.events.Transfer.returnValues.tokenId;634634635 const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);635 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);636636637 await tokenContract.methods.repartition(2).send();637 await tokenContract.methods.repartition(2).send();638 await tokenContract.methods.transfer(receiver, 1).send();638 await tokenContract.methods.transfer(receiver, 1).send();656 const caller = await helper.eth.createAccountWithBalance(donor);656 const caller = await helper.eth.createAccountWithBalance(donor);657 const receiver = helper.eth.createAccount();657 const receiver = helper.eth.createAccount();658 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Full-to-Partial', '6', '6');658 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry-Full-to-Partial', '6', '6');659 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);659 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);660660661 const result = await contract.methods.mint(caller).send();661 const result = await contract.methods.mint(caller).send();662 const tokenId = result.events.Transfer.returnValues.tokenId;662 const tokenId = result.events.Transfer.returnValues.tokenId;663663664 const tokenContract = helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);664 const tokenContract = await helper.ethNativeContract.rftTokenById(collectionId, tokenId, caller);665665666 await tokenContract.methods.repartition(2).send();666 await tokenContract.methods.repartition(2).send();667667696 const caller = await helper.eth.createAccountWithBalance(donor);696 const caller = await helper.eth.createAccountWithBalance(donor);697 const receiver = helper.eth.createAccount();697 const receiver = helper.eth.createAccount();698 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer-From', '6', '6');698 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer-From', '6', '6');699 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);699 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);700700701 const result = await contract.methods.mint(caller).send();701 const result = await contract.methods.mint(caller).send();702 const tokenId = result.events.Transfer.returnValues.tokenId;702 const tokenId = result.events.Transfer.returnValues.tokenId;710 const caller = await helper.eth.createAccountWithBalance(donor);710 const caller = await helper.eth.createAccountWithBalance(donor);711 const receiver = helper.eth.createAccount();711 const receiver = helper.eth.createAccount();712 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer', '6', '6');712 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Feeful-Transfer', '6', '6');713 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);713 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);714714715 const result = await contract.methods.mint(caller).send();715 const result = await contract.methods.mint(caller).send();716 const tokenId = result.events.Transfer.returnValues.tokenId;716 const tokenId = result.events.Transfer.returnValues.tokenId;754 },754 },755 );755 );756756757 const contract = helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);757 const contract = await helper.ethNativeContract.collectionById(collection.collectionId, 'rft', caller);758 const name = await contract.methods.name().call();758 const name = await contract.methods.name().call();759 expect(name).to.equal('Leviathan');759 expect(name).to.equal('Leviathan');760 });760 });779 },779 },780 );780 );781781782 const contract = helper.ethNativeContract.collectionById(collectionId, 'rft', caller);782 const contract = await helper.ethNativeContract.collectionById(collectionId, 'rft', caller);783 const symbol = await contract.methods.symbol().call();783 const symbol = await contract.methods.symbol().call();784 expect(symbol).to.equal('12');784 expect(symbol).to.equal('12');785 });785 });808 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});808 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});809809810 const address = helper.ethAddress.fromCollectionId(collection.collectionId);810 const address = helper.ethAddress.fromCollectionId(collection.collectionId);811 const contract = helper.ethNativeContract.collection(address, 'rft');811 const contract = await helper.ethNativeContract.collection(address, 'rft');812812813 const ownerCross = helper.ethCrossAccount.fromAddress(owner);813 const ownerCross = helper.ethCrossAccount.fromAddress(owner);814814830 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});830 const token = await collection.mintToken(minter, 100n, {Ethereum: owner});831831832 const address = helper.ethAddress.fromCollectionId(collection.collectionId);832 const address = helper.ethAddress.fromCollectionId(collection.collectionId);833 const contract = helper.ethNativeContract.collection(address, 'rft');833 const contract = await helper.ethNativeContract.collection(address, 'rft');834834835 const ownerCross = helper.ethCrossAccount.fromAddress(owner);835 const ownerCross = helper.ethCrossAccount.fromAddress(owner);836 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);836 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth38 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});38 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});39 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});39 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});404041 const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);41 const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);42 const totalSupply = await contract.methods.totalSupply().call();42 const totalSupply = await contract.methods.totalSupply().call();43 expect(totalSupply).to.equal('200');43 expect(totalSupply).to.equal('200');44 });44 });48 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});48 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});49 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});49 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});505051 const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);51 const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);52 const balance = await contract.methods.balanceOf(caller).call();52 const balance = await contract.methods.balanceOf(caller).call();53 expect(balance).to.equal('200');53 expect(balance).to.equal('200');54 });54 });58 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});58 const collection = await helper.rft.mintCollection(alice, {tokenPrefix: 'MUON'});59 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});59 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: caller});606061 const contract = helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);61 const contract = await helper.ethNativeContract.rftTokenById(collection.collectionId, tokenId, caller);62 const decimals = await contract.methods.decimals().call();62 const decimals = await contract.methods.decimals().call();63 expect(decimals).to.equal('0');63 expect(decimals).to.equal('0');64 });64 });81 const receiver = helper.eth.createAccount();81 const receiver = helper.eth.createAccount();828283 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);83 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);84 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);84 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);858586 const result = await contract.methods.mint(receiver).send();86 const result = await contract.methods.mint(receiver).send();8787143 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});143 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});144144145 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);145 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);146 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);146 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);147147148 {148 {149 const result = await contract.methods.approve(spender, 100).send({from: owner});149 const result = await contract.methods.approve(spender, 100).send({from: owner});172 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});172 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});173173174 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);174 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);175 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);175 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);176176177 {177 {178 const result = await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});178 const result = await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});216 const token = await collection.mintToken(alice, 100n, {Ethereum: owner});216 const token = await collection.mintToken(alice, 100n, {Ethereum: owner});217217218 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);218 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);219 const tokenEvm = helper.ethNativeContract.rftToken(tokenAddress, owner);219 const tokenEvm = await helper.ethNativeContract.rftToken(tokenAddress, owner);220220221 await expect(tokenEvm.methods.approveCross(nonOwnerCross, 20).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');221 await expect(tokenEvm.methods.approveCross(nonOwnerCross, 20).call({from: nonOwner})).to.be.rejectedWith('CantApproveMoreThanOwned');222 });222 });239 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});239 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});240240241 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);241 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);242 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);242 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);243243244 await contract.methods.approve(spender, 100).send({from: owner});244 await contract.methods.approve(spender, 100).send({from: owner});245 245312 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});312 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});313313314 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);314 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);315 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);315 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);316316317 // 1. Can transfer to plain ethereum or cross-ethereum account:317 // 1. Can transfer to plain ethereum or cross-ethereum account:318 {318 {330 expect(+receiverBalance).to.equal(50);330 expect(+receiverBalance).to.equal(50);331 }331 }332 332333 // 2. Can transfer to cross-substrate account: 333 // 2. Can transfer to cross-substrate account:334 if(isCross) {334 if(isCross) {335 const result = await contract.methods.transferCross(receiverCrossSub, 50).send({from: owner});335 const result = await contract.methods.transferCross(receiverCrossSub, 50).send({from: owner});336 // Check events:336 // Check events:365 const tokenAddress1 = helper.ethAddress.fromTokenId(collection.collectionId, rftOwner.tokenId);365 const tokenAddress1 = helper.ethAddress.fromTokenId(collection.collectionId, rftOwner.tokenId);366 const tokenAddress2 = helper.ethAddress.fromTokenId(collection.collectionId, rftReceiver.tokenId);366 const tokenAddress2 = helper.ethAddress.fromTokenId(collection.collectionId, rftReceiver.tokenId);367 const tokenAddressNonExist = helper.ethAddress.fromTokenId(collection.collectionId, tokenIdNonExist);367 const tokenAddressNonExist = helper.ethAddress.fromTokenId(collection.collectionId, tokenIdNonExist);368 const tokenEvmOwner = helper.ethNativeContract.rftToken(tokenAddress1, owner);368 const tokenEvmOwner = await helper.ethNativeContract.rftToken(tokenAddress1, owner);369 const tokenEvmReceiver = helper.ethNativeContract.rftToken(tokenAddress2, owner);369 const tokenEvmReceiver = await helper.ethNativeContract.rftToken(tokenAddress2, owner);370 const tokenEvmNonExist = helper.ethNativeContract.rftToken(tokenAddressNonExist, owner);370 const tokenEvmNonExist = await helper.ethNativeContract.rftToken(tokenAddressNonExist, owner);371 371372 // 1. Can transfer zero amount (EIP-20):372 // 1. Can transfer zero amount (EIP-20):373 await tokenEvmOwner.methods[testCase](isCross ? receiverCrossEth : receiverEth, 0).send({from: owner});373 await tokenEvmOwner.methods[testCase](isCross ? receiverCrossEth : receiverEth, 0).send({from: owner});397 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});397 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});398398399 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);399 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);400 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);400 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);401401402 await contract.methods.repartition(200).send({from: owner});402 await contract.methods.repartition(200).send({from: owner});403 expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(200);403 expect(+await contract.methods.balanceOf(owner).call()).to.be.equal(200);422 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});422 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});423423424 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);424 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);425 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);425 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);426426427 const result = await contract.methods.repartition(200).send();427 const result = await contract.methods.repartition(200).send();428428439 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});439 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});440440441 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);441 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);442 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);442 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);443443444 const result = await contract.methods.repartition(50).send();444 const result = await contract.methods.repartition(50).send();445 const event = result.events.Transfer;445 const event = result.events.Transfer;453 const caller = await helper.eth.createAccountWithBalance(donor);453 const caller = await helper.eth.createAccountWithBalance(donor);454 const receiver = await helper.eth.createAccountWithBalance(donor);454 const receiver = await helper.eth.createAccountWithBalance(donor);455 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Devastation', '6', '6');455 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Devastation', '6', '6');456 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);456 const contract = await helper.ethNativeContract.collection(collectionAddress, 'rft', caller);457457458 const result = await contract.methods.mint(caller).send();458 const result = await contract.methods.mint(caller).send();459 const tokenId = result.events.Transfer.returnValues.tokenId;459 const tokenId = result.events.Transfer.returnValues.tokenId;460 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);460 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);461 const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, caller);461 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, caller);462462463 await tokenContract.methods.repartition(2).send();463 await tokenContract.methods.repartition(2).send();464 await tokenContract.methods.transfer(receiver, 1).send();464 await tokenContract.methods.transfer(receiver, 1).send();491 491492492493 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);493 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);494 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);494 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);495495496 {496 {497 await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});497 await contract.methods.approveCross(spenderCrossEth, 100).send({from: owner});504 const {tokenId} = await collection.mintToken(alice, 200n, {Substrate: ownerSub.address});504 const {tokenId} = await collection.mintToken(alice, 200n, {Substrate: ownerSub.address});505 await collection.approveToken(ownerSub, tokenId, {Ethereum: spender}, 100n);505 await collection.approveToken(ownerSub, tokenId, {Ethereum: spender}, 100n);506 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);506 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);507 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);507 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);508 508509 await expect(contract.methods.burnFromCross(ownerSubCross, 50).send({from: spender})).to.be.fulfilled;509 await expect(contract.methods.burnFromCross(ownerSubCross, 50).send({from: spender})).to.be.fulfilled;510 await expect(contract.methods.burnFromCross(ownerSubCross, 100).send({from: spender})).to.be.rejected;510 await expect(contract.methods.burnFromCross(ownerSubCross, 100).send({from: spender})).to.be.rejected;533 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});533 const {tokenId} = await collection.mintToken(alice, 100n, {Ethereum: owner});534534535 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);535 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);536 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);536 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);537537538 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));538 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.approve(spender, 100).send({from: owner}));539 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));539 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));546 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});546 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});547547548 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);548 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);549 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);549 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);550550551 await contract.methods.approve(spender, 100).send({from: owner});551 await contract.methods.approve(spender, 100).send({from: owner});552552561 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});561 const {tokenId} = await collection.mintToken(alice, 200n, {Ethereum: owner});562562563 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);563 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, tokenId);564 const contract = helper.ethNativeContract.rftToken(tokenAddress, owner);564 const contract = await helper.ethNativeContract.rftToken(tokenAddress, owner);565565566 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));566 const cost = await helper.eth.recordCallFee(owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));567 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));567 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal())));587 const token = await collection.mintToken(alice, 200n);587 const token = await collection.mintToken(alice, 200n);588588589 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);589 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);590 const contract = helper.ethNativeContract.rftToken(tokenAddress);590 const contract = await helper.ethNativeContract.rftToken(tokenAddress);591591592 const events: any = [];592 const events: any = [];593 contract.events.allEvents((_: any, event: any) => {593 contract.events.allEvents((_: any, event: any) => {613 await token.approve(alice, {Substrate: bob.address}, 100n);613 await token.approve(alice, {Substrate: bob.address}, 100n);614614615 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);615 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);616 const contract = helper.ethNativeContract.rftToken(tokenAddress);616 const contract = await helper.ethNativeContract.rftToken(tokenAddress);617617618 const events: any = [];618 const events: any = [];619 contract.events.allEvents((_: any, event: any) => {619 contract.events.allEvents((_: any, event: any) => {644 const token = await collection.mintToken(alice, 200n);644 const token = await collection.mintToken(alice, 200n);645645646 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);646 const tokenAddress = helper.ethAddress.fromTokenId(collection.collectionId, token.tokenId);647 const contract = helper.ethNativeContract.rftToken(tokenAddress);647 const contract = await helper.ethNativeContract.rftToken(tokenAddress);648648649 const events: any = [];649 const events: any = [];650 contract.events.allEvents((_: any, event: any) => {650 contract.events.allEvents((_: any, event: any) => {678 const owner = await helper.eth.createAccountWithBalance(donor);678 const owner = await helper.eth.createAccountWithBalance(donor);679679680 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sands', '', 'GRAIN');680 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sands', '', 'GRAIN');681 const collectionContract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);681 const collectionContract = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);682682683 const result = await collectionContract.methods.mint(owner).send();683 const result = await collectionContract.methods.mint(owner).send();684 const tokenId = result.events.Transfer.returnValues.tokenId;684 const tokenId = result.events.Transfer.returnValues.tokenId;685685686 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);686 const tokenAddress = helper.ethAddress.fromTokenId(collectionId, tokenId);687 const tokenContract = helper.ethNativeContract.rftToken(tokenAddress, owner);687 const tokenContract = await helper.ethNativeContract.rftToken(tokenAddress, owner);688688689 expect(await tokenContract.methods.parentToken().call()).to.be.equal(collectionAddress);689 expect(await tokenContract.methods.parentToken().call()).to.be.equal(collectionAddress);690 expect(await tokenContract.methods.parentTokenId().call()).to.be.equal(tokenId);690 expect(await tokenContract.methods.parentTokenId().call()).to.be.equal(tokenId);tests/src/eth/sponsoring.test.tsdiffbeforeafterboth373738 const flipper = await helper.eth.deployFlipper(owner);38 const flipper = await helper.eth.deployFlipper(owner);393940 const helpers = helper.ethNativeContract.contractHelpers(owner);40 const helpers = await helper.ethNativeContract.contractHelpers(owner);414142 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});42 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});43 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});43 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});717172 const collector = await helper.eth.deployCollectorContract(owner);72 const collector = await helper.eth.deployCollectorContract(owner);737374 const helpers = helper.ethNativeContract.contractHelpers(owner);74 const helpers = await helper.ethNativeContract.contractHelpers(owner);757576 await helpers.methods.toggleAllowlist(collector.options.address, true).send({from: owner});76 await helpers.methods.toggleAllowlist(collector.options.address, true).send({from: owner});77 await helpers.methods.toggleAllowed(collector.options.address, caller, true).send({from: owner});77 await helpers.methods.toggleAllowed(collector.options.address, caller, true).send({from: owner});tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth76 const owner = await helper.eth.createAccountWithBalance(donor);76 const owner = await helper.eth.createAccountWithBalance(donor);77 7778 const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');78 const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');79 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);79 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);808081 await collection.methods.setTokenPropertyPermissions([81 await collection.methods.setTokenPropertyPermissions([82 ['testKey_0', [82 ['testKey_0', [139 const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);139 const caller = await helper.ethCrossAccount.createAccountWithBalance(donor);140 140141 const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');141 const {collectionId, collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');142 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);142 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);143 await collection.methods.addCollectionAdminCross(caller).send({from: owner});143 await collection.methods.addCollectionAdminCross(caller).send({from: owner});144144145 await collection.methods.setTokenPropertyPermissions([145 await collection.methods.setTokenPropertyPermissions([226 await collection.addAdmin(alice, {Ethereum: caller});226 await collection.addAdmin(alice, {Ethereum: caller});227 const token = await collection.mintToken(alice);227 const token = await collection.mintToken(alice);228 228229 const collectionEvm = helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller, testCase.method === 'setProperty');229 const collectionEvm = await helper.ethNativeContract.collectionById(collection.collectionId, 'nft', caller, testCase.method === 'setProperty');230 230231 await collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller});231 await collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller});232 232260 await collection.addAdmin(alice, {Ethereum: caller});260 await collection.addAdmin(alice, {Ethereum: caller});261 261262 const address = helper.ethAddress.fromCollectionId(collection.collectionId);262 const address = helper.ethAddress.fromCollectionId(collection.collectionId);263 const contract = helper.ethNativeContract.collection(address, testCase.mode, caller);263 const contract = await helper.ethNativeContract.collection(address, testCase.mode, caller);264 264265 expect(await contract.methods.properties(token.tokenId, []).call()).to.be.deep.equal([]);265 expect(await contract.methods.properties(token.tokenId, []).call()).to.be.deep.equal([]);266 266306 await collection.addAdmin(alice, {Ethereum: caller});306 await collection.addAdmin(alice, {Ethereum: caller});307307308 const address = helper.ethAddress.fromCollectionId(collection.collectionId);308 const address = helper.ethAddress.fromCollectionId(collection.collectionId);309 const contract = helper.ethNativeContract.collection(address, testCase.mode, caller);309 const contract = await helper.ethNativeContract.collection(address, testCase.mode, caller);310310311 await contract.methods.deleteProperties(token.tokenId, ['testKey', 'testKey_1']).send({from: caller});311 await contract.methods.deleteProperties(token.tokenId, ['testKey', 'testKey_1']).send({from: caller});312312329 await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);329 await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);330330331 const address = helper.ethAddress.fromCollectionId(collection.collectionId);331 const address = helper.ethAddress.fromCollectionId(collection.collectionId);332 const contract = helper.ethNativeContract.collection(address, 'nft', caller);332 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);333333334 const value = await contract.methods.property(token.tokenId, 'testKey').call();334 const value = await contract.methods.property(token.tokenId, 'testKey').call();335 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));335 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));374 }); 374 });375 token = await aliceCollection.mintToken(alice);375 token = await aliceCollection.mintToken(alice);376 await token.setProperties(alice, tokenProps);376 await token.setProperties(alice, tokenProps);377 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);377 collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);378 });378 });379 });379 });380380384 ].map(testCase =>384 ].map(testCase =>385 itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {385 itEth(`[${testCase.method}] Cannot set properties of non-owned collection`, async ({helper}) => {386 caller = await helper.eth.createAccountWithBalance(donor);386 caller = await helper.eth.createAccountWithBalance(donor);387 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);387 collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);388 // Caller not an owner and not an admin, so he cannot set properties:388 // Caller not an owner and not an admin, so he cannot set properties:389 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');389 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');390 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;390 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;401 ].map(testCase =>401 ].map(testCase =>402 itEth(`[${testCase.method}] Cannot set non-existing properties`, async ({helper}) => {402 itEth(`[${testCase.method}] Cannot set non-existing properties`, async ({helper}) => {403 caller = await helper.eth.createAccountWithBalance(donor);403 caller = await helper.eth.createAccountWithBalance(donor);404 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);404 collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, true);405 await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});405 await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});406406407 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');407 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');419 ].map(testCase => 419 ].map(testCase =>420 itEth(`[${testCase.method}] Cannot delete properties of non-owned collection`, async ({helper}) => {420 itEth(`[${testCase.method}] Cannot delete properties of non-owned collection`, async ({helper}) => {421 caller = await helper.eth.createAccountWithBalance(donor);421 caller = await helper.eth.createAccountWithBalance(donor);422 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');422 collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');423 // Caller not an owner and not an admin, so he cannot set properties:423 // Caller not an owner and not an admin, so he cannot set properties:424 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');424 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');425 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;425 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).send({from: caller})).to.be.rejected;436 ].map(testCase => 436 ].map(testCase =>437 itEth(`[${testCase.method}] Cannot delete non-existing properties`, async ({helper}) => {437 itEth(`[${testCase.method}] Cannot delete non-existing properties`, async ({helper}) => {438 caller = await helper.eth.createAccountWithBalance(donor);438 caller = await helper.eth.createAccountWithBalance(donor);439 collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');439 collectionEvm = await helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(aliceCollection.collectionId), 'nft', caller, testCase.method == 'deleteProperty');440 await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});440 await helper.collection.addAdmin(alice, aliceCollection.collectionId, {Ethereum: caller});441 // Caller cannot delete non-existing properties:441 // Caller cannot delete non-existing properties:442 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');442 await expect(collectionEvm.methods[testCase.method](token.tokenId, ...testCase.methodParams).call({from: caller})).to.be.rejectedWith('NoPermission');456 const caller = await helper.eth.createAccountWithBalance(donor);456 const caller = await helper.eth.createAccountWithBalance(donor);457 457458 const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');458 const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');459 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);459 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);460 460461 await expect(collection.methods.setTokenPropertyPermissions([461 await expect(collection.methods.setTokenPropertyPermissions([462 ['testKey_0', [462 ['testKey_0', [475 const owner = await helper.eth.createAccountWithBalance(donor);475 const owner = await helper.eth.createAccountWithBalance(donor);476 476477 const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');477 const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');478 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);478 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);479 479480 await expect(collection.methods.setTokenPropertyPermissions([480 await expect(collection.methods.setTokenPropertyPermissions([481 // "Space" is invalid character481 // "Space" is invalid character495 const owner = await helper.eth.createAccountWithBalance(donor);495 const owner = await helper.eth.createAccountWithBalance(donor);496 496497 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');497 const {collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');498 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);498 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);499 499500 // 1. Owner sets strict property-permissions:500 // 1. Owner sets strict property-permissions:501 await collection.methods.setTokenPropertyPermissions([501 await collection.methods.setTokenPropertyPermissions([531 const owner = await helper.eth.createAccountWithBalance(donor);531 const owner = await helper.eth.createAccountWithBalance(donor);532 532533 const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');533 const {collectionAddress} = await helper.eth.createCollection(testCase.mode, owner, 'A', 'B', 'C');534 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);534 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);535 535536 // 1. Owner sets strict property-permissions:536 // 1. Owner sets strict property-permissions:537 await collection.methods.setTokenPropertyPermissions([537 await collection.methods.setTokenPropertyPermissions([tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth353536class EthGroupBase {36class EthGroupBase {37 helper: EthUniqueHelper;37 helper: EthUniqueHelper;38 gasPrice?: string;383939 constructor(helper: EthUniqueHelper) {40 constructor(helper: EthUniqueHelper) {40 this.helper = helper;41 this.helper = helper;41 }42 }43 async getGasPrice() {44 if (this.gasPrice)45 return this.gasPrice;46 this.gasPrice = await this.helper.getWeb3().eth.getGasPrice();47 return this.gasPrice;48 }42}49}435051function unlimitedMoneyHack<C>(_contract: C): C {52 const contract = _contract as any;53 // Hack: fight against gasPrice override54 for (const method in contract.methods) {55 const _method = contract.methods[method];56 contract.methods[method] = function (...args: any) {57 const encodedCall = _method.call(this, ...args);58 const _call = encodedCall.call;59 encodedCall.call = function (...args: any) {60 if (args.length === 0) {61 return _call.call(this, {gasPrice: '0'});62 }63 // No support for callback/defaultBlock, they may be placed as first argument64 if (typeof args[0] !== 'object')65 throw new Error('only options are supported');66 args[0].gasPrice = '0';67 return _call.call(this, ...args);68 };69 return encodedCall;70 };71 }72 return contract;73}447445class ContractGroup extends EthGroupBase {75class ContractGroup extends EthGroupBase {46 async findImports(imports?: ContractImports[]){76 async findImports(imports?: ContractImports[]){104 data: object,134 data: object,105 from: signer,135 from: signer,106 gas: gas ?? this.helper.eth.DEFAULT_GAS,136 gas: gas ?? this.helper.eth.DEFAULT_GAS,137 gasPrice: await this.getGasPrice(),107 });138 });108 return await contract.deploy({data: object}).send({from: signer});139 return unlimitedMoneyHack(await contract.deploy({data: object}).send({from: signer}));109 }140 }110141111}142}112143113class NativeContractGroup extends EthGroupBase {144class NativeContractGroup extends EthGroupBase {114145115 contractHelpers(caller: string): Contract {146 async contractHelpers(caller: string): Promise<Contract> {116 const web3 = this.helper.getWeb3();147 const web3 = this.helper.getWeb3();117 return new web3.eth.Contract(contractHelpersAbi as any, this.helper.getApi().consts.evmContractHelpers.contractAddress.toString(), {from: caller, gas: this.helper.eth.DEFAULT_GAS});148 return unlimitedMoneyHack(new web3.eth.Contract(contractHelpersAbi as any, this.helper.getApi().consts.evmContractHelpers.contractAddress.toString(), {149 from: caller,150 gas: this.helper.eth.DEFAULT_GAS,151 gasPrice: await this.getGasPrice(),152 }));118 }153 }119154120 collectionHelpers(caller: string) {155 async collectionHelpers(caller: string) {121 const web3 = this.helper.getWeb3();156 const web3 = this.helper.getWeb3();122 return new web3.eth.Contract(collectionHelpersAbi as any, this.helper.getApi().consts.common.contractAddress.toString(), {from: caller, gas: this.helper.eth.DEFAULT_GAS});157 return unlimitedMoneyHack(new web3.eth.Contract(collectionHelpersAbi as any, this.helper.getApi().consts.common.contractAddress.toString(), {158 from: caller,159 gas: this.helper.eth.DEFAULT_GAS,160 gasPrice: await this.getGasPrice(),161 }));123 }162 }124163125 collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false): Contract {164 async collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false) {126 let abi = {165 let abi = {127 'nft': nonFungibleAbi,166 'nft': nonFungibleAbi,128 'rft': refungibleAbi,167 'rft': refungibleAbi,137 abi = [...abi,...deprecated];176 abi = [...abi,...deprecated];138 }177 }139 const web3 = this.helper.getWeb3();178 const web3 = this.helper.getWeb3();140 return new web3.eth.Contract(abi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});179 return unlimitedMoneyHack(new web3.eth.Contract(abi as any, address, {180 gas: this.helper.eth.DEFAULT_GAS,181 gasPrice: await this.getGasPrice(),182 ...(caller ? {from: caller} : {}),183 }));141 }184 }142185143 collectionById(collectionId: number, mode: 'nft' | 'rft' | 'ft', caller?: string, mergeDeprecated = false): Contract {186 collectionById(collectionId: number, mode: 'nft' | 'rft' | 'ft', caller?: string, mergeDeprecated = false) {144 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);187 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller, mergeDeprecated);145 }188 }146189147 rftToken(address: string, caller?: string): Contract {190 async rftToken(address: string, caller?: string) {148 const web3 = this.helper.getWeb3();191 const web3 = this.helper.getWeb3();149 return new web3.eth.Contract(refungibleTokenAbi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});192 return unlimitedMoneyHack(new web3.eth.Contract(refungibleTokenAbi as any, address, {193 gas: this.helper.eth.DEFAULT_GAS,194 gasPrice: await this.getGasPrice(),195 ...(caller ? {from: caller} : {}),196 }));150 }197 }151198152 rftTokenById(collectionId: number, tokenId: number, caller?: string): Contract {199 rftTokenById(collectionId: number, tokenId: number, caller?: string) {153 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);200 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);154 }201 }155}202}177 }224 }178225179 async getCollectionCreationFee(signer: string) {226 async getCollectionCreationFee(signer: string) {180 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);227 const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(signer);181 return await collectionHelper.methods.collectionCreationFee().call();228 return await collectionHelper.methods.collectionCreationFee().call();182 }229 }183230210257211 async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {258 async createCollection(mode: TCollectionMode, signer: string, name: string, description: string, tokenPrefix: string, decimals = 18): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {212 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();259 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();213 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);260 const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(signer);214 const functionName: string = this.createCollectionMethodName(mode);261 const functionName: string = this.createCollectionMethodName(mode);215262216 const functionParams = mode === 'ft' ? [name, decimals, description, tokenPrefix] : [name, description, tokenPrefix];263 const functionParams = mode === 'ft' ? [name, decimals, description, tokenPrefix] : [name, description, tokenPrefix];228 }275 }229276230 async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {277 async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {231 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);278 const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(signer);232279233 const {collectionId, collectionAddress, events} = await this.createCollection('nft', signer, name, description, tokenPrefix);280 const {collectionId, collectionAddress, events} = await this.createCollection('nft', signer, name, description, tokenPrefix);234281246 }293 }247294248 async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {295 async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {249 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);296 const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(signer);250297251 const {collectionId, collectionAddress, events} = await this.createCollection('rft', signer, name, description, tokenPrefix);298 const {collectionId, collectionAddress, events} = await this.createCollection('rft', signer, name, description, tokenPrefix);252299tests/src/maintenanceMode.seqtest.tsdiffbeforeafterboth232 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);232 await helper.getSudo().executeExtrinsic(superuser, 'api.tx.maintenance.enable', []);233 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;233 expect(await maintenanceEnabled(helper.getApi()), 'MM is OFF when it should be ON').to.be.true;234234235 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);235 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);236 const tokenId = await contract.methods.nextTokenId().call();236 const tokenId = await contract.methods.nextTokenId().call();237 expect(tokenId).to.be.equal('1');237 expect(tokenId).to.be.equal('1');238238