difftreelog
fix tests cleanup
in: master
10 files changed
tests/src/eth/collectionLimits.test.tsdiffbeforeafterboth979798 const owner = await helper.eth.createAccountWithBalance(donor);98 const owner = await helper.eth.createAccountWithBalance(donor);99 const {collectionAddress} = await helper.eth.createCollection(owner, new CreateCollectionData('Limits', 'absolutely anything', 'ISNI', testCase.case, 18)).send();99 const {collectionAddress} = await helper.eth.createCollection(owner, new CreateCollectionData('Limits', 'absolutely anything', 'ISNI', testCase.case, 18)).send();100 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.case, owner);100 const collectionEvm = 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.methodstests/src/eth/createCollection.test.tsdiffbeforeafterboth232324const DECIMALS = 18;24const DECIMALS = 18;25const CREATE_COLLECTION_DATA_DEFAULTS_ARRAY = [25const CREATE_COLLECTION_DATA_DEFAULTS_ARRAY = [26 [],26 [], // properties27 [],27 [], // tokenPropertyPermissions28 [],28 [], // adminList29 [false, false, []],29 [false, false, []], // nestingSettings30 [],30 [], // limits31 [0],31 emptyAddress, // pendingSponsor32 [0], // flags32];33];333434type ElementOf<A> = A extends readonly (infer T)[] ? T : never;35type ElementOf<A> = A extends readonly (infer T)[] ? T : never;64 itEth('Collection address exist', async ({helper}) => {65 itEth('Collection address exist', async ({helper}) => {65 const owner = await helper.eth.createAccountWithBalance(donor);66 const owner = await helper.eth.createAccountWithBalance(donor);66 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';67 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';67 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);68 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);686969 expect(await collectionHelpers70 expect(await collectionHelpers70 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())71 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())76 .to.be.true;77 .to.be.true;777878 // check collectionOwner:79 // check collectionOwner:79 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);80 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);80 const collectionOwner = await collectionEvm.methods.collectionOwner().call();81 const collectionOwner = await collectionEvm.methods.collectionOwner().call();81 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));82 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));82 });83 });838484 itEth('destroyCollection', async ({helper}) => {85 itEth('destroyCollection', async ({helper}) => {85 const owner = await helper.eth.createAccountWithBalance(donor);86 const owner = await helper.eth.createAccountWithBalance(donor);86 const {collectionAddress, collectionId} = await helper.eth.createCollection(owner, new CreateCollectionData('Exister', 'absolutely anything', 'WIWT', 'ft', DECIMALS)).send();87 const {collectionAddress, collectionId} = await helper.eth.createCollection(owner, new CreateCollectionData('Exister', 'absolutely anything', 'WIWT', 'ft', DECIMALS)).send();87 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);88 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);888989 const result = await collectionHelper.methods90 const result = await collectionHelper.methods90 .destroyCollection(collectionAddress)91 .destroyCollection(collectionAddress)110111111 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {112 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {112 const owner = await helper.eth.createAccountWithBalance(donor);113 const owner = await helper.eth.createAccountWithBalance(donor);113 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);114 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);114 {115 {115 const MAX_NAME_LENGTH = 64;116 const MAX_NAME_LENGTH = 64;116 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);117 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);119120120 await expect(collectionHelper.methods121 await expect(collectionHelper.methods121 .createCollection([122 .createCollection([122 emptyAddress,123 collectionName,123 collectionName,124 description,124 description,125 tokenPrefix,125 tokenPrefix,136 const tokenPrefix = 'A';136 const tokenPrefix = 'A';137 await expect(collectionHelper.methods137 await expect(collectionHelper.methods138 .createCollection([138 .createCollection([139 emptyAddress,140 collectionName,139 collectionName,141 description,140 description,142 tokenPrefix,141 tokenPrefix,153 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);152 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);154 await expect(collectionHelper.methods153 await expect(collectionHelper.methods155 .createCollection([154 .createCollection([156 emptyAddress,157 collectionName,155 collectionName,158 description,156 description,159 tokenPrefix,157 tokenPrefix,167165168 itEth('(!negative test!) cannot create collection if value !== 2', async ({helper}) => {166 itEth('(!negative test!) cannot create collection if value !== 2', async ({helper}) => {169 const owner = await helper.eth.createAccountWithBalance(donor);167 const owner = await helper.eth.createAccountWithBalance(donor);170 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);168 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);171 const expects = [0n, 1n, 30n].map(async value => {169 const expects = [0n, 1n, 30n].map(async value => {172 await expect(collectionHelper.methods170 await expect(collectionHelper.methods173 .createCollection([171 .createCollection([174 emptyAddress,175 'Peasantry',172 'Peasantry',176 'absolutely anything',173 'absolutely anything',177 'TWIW',174 'TWIW',238235239 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;236 const expectedCollectionId = +(await helper.callRpc('api.rpc.unique.collectionStats')).created + 1;240 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);237 const expectedCollectionAddress = helper.ethAddress.fromCollectionId(expectedCollectionId);241 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);238 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);242239243 expect(await collectionHelpers.methods240 expect(await collectionHelpers.methods244 .isCollectionExist(expectedCollectionAddress)241 .isCollectionExist(expectedCollectionAddress)245 .call()).to.be.false;242 .call()).to.be.false;246243247 await collectionHelpers.methods244 await collectionHelpers.methods248 .createCollection([245 .createCollection([249 emptyAddress,250 'A',246 'A',251 'A',247 'A',252 'A',248 'A',331 const ss58Format = helper.chain.getChainProperties().ss58Format;327 const ss58Format = helper.chain.getChainProperties().ss58Format;332 const {collectionId, collectionAddress} = await helper.eth.createCollection(owner, new CreateCollectionData('Sponsor', 'absolutely anything', 'ENVY', 'rft')).send();328 const {collectionId, collectionAddress} = await helper.eth.createCollection(owner, new CreateCollectionData('Sponsor', 'absolutely anything', 'ENVY', 'rft')).send();333329334 const collection = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);330 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);335 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);331 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);336 await collection.methods.setCollectionSponsorCross(sponsorCross).send();332 await collection.methods.setCollectionSponsorCross(sponsorCross).send();337333340336341 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');337 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');342338343 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);339 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);344 await sponsorCollection.methods.confirmCollectionSponsorship().send();340 await sponsorCollection.methods.confirmCollectionSponsorship().send();345341346 data = (await helper.rft.getData(collectionId))!;342 data = (await helper.rft.getData(collectionId))!;350 itEth('Collection address exist', async ({helper}) => {346 itEth('Collection address exist', async ({helper}) => {351 const owner = await helper.eth.createAccountWithBalance(donor);347 const owner = await helper.eth.createAccountWithBalance(donor);352 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';348 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';353 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);349 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);354350355 expect(await collectionHelpers351 expect(await collectionHelpers356 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())352 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())362 .to.be.true;358 .to.be.true;363359364 // check collectionOwner:360 // check collectionOwner:365 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);361 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);366 const collectionOwner = await collectionEvm.methods.collectionOwner().call();362 const collectionOwner = await collectionEvm.methods.collectionOwner().call();367 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));363 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));368 });364 });369365370 itEth('destroyCollection', async ({helper}) => {366 itEth('destroyCollection', async ({helper}) => {371 const owner = await helper.eth.createAccountWithBalance(donor);367 const owner = await helper.eth.createAccountWithBalance(donor);372 const {collectionAddress, collectionId} = await helper.eth.createCollection(owner, new CreateCollectionData('Limits', 'absolutely anything', 'OLF', 'rft')).send();368 const {collectionAddress, collectionId} = await helper.eth.createCollection(owner, new CreateCollectionData('Limits', 'absolutely anything', 'OLF', 'rft')).send();373 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);369 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);374370375 await expect(collectionHelper.methods371 await expect(collectionHelper.methods376 .destroyCollection(collectionAddress)372 .destroyCollection(collectionAddress)384380385 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {381 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {386 const owner = await helper.eth.createAccountWithBalance(donor);382 const owner = await helper.eth.createAccountWithBalance(donor);387 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);383 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);388 {384 {389 const MAX_NAME_LENGTH = 64;385 const MAX_NAME_LENGTH = 64;390 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);386 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);393389394 await expect(collectionHelper.methods390 await expect(collectionHelper.methods395 .createCollection([391 .createCollection([396 emptyAddress,397 collectionName,392 collectionName,398 description,393 description,399 tokenPrefix,394 tokenPrefix,410 const tokenPrefix = 'A';405 const tokenPrefix = 'A';411 await expect(collectionHelper.methods406 await expect(collectionHelper.methods412 .createCollection([407 .createCollection([413 emptyAddress,414 collectionName,408 collectionName,415 description,409 description,416 tokenPrefix,410 tokenPrefix,427 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);421 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);428 await expect(collectionHelper.methods422 await expect(collectionHelper.methods429 .createCollection([423 .createCollection([430 emptyAddress,431 collectionName,424 collectionName,432 description,425 description,433 tokenPrefix,426 tokenPrefix,441434442 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {435 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {443 const owner = await helper.eth.createAccountWithBalance(donor);436 const owner = await helper.eth.createAccountWithBalance(donor);444 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);437 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);445 await expect(collectionHelper.methods438 await expect(collectionHelper.methods446 .createCollection([439 .createCollection([447 emptyAddress,448 'Peasantry',440 'Peasantry',449 'absolutely anything',441 'absolutely anything',450 'TWIW',442 'TWIW',473 pendingSponsor: sponsorCross,465 pendingSponsor: sponsorCross,474 },466 },475 ).send();467 ).send();476 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);468 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);477469478 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;470 expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;479471657 '',649 '',658 );650 );659 const collectionSub = helper.nft.getCollectionObject(collectionId);651 const collectionSub = helper.nft.getCollectionObject(collectionId);660 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);652 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);661653662 // Set and confirm sponsor:654 // Set and confirm sponsor:663 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});655 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsorEth});695 '',687 '',696 );688 );697 const receiver = await helper.eth.createAccountWithBalance(donor);689 const receiver = await helper.eth.createAccountWithBalance(donor);698 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);690 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);699691700 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});692 await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});701693764 adminList: [adminCrossSub, adminCrossEth],756 adminList: [adminCrossSub, adminCrossEth],765 },757 },766 ).send();758 ).send();767 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner, true);759 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner, true);768760769 // 1. Expect api.rpc.unique.adminlist returns admins:761 // 1. Expect api.rpc.unique.adminlist returns admins:770 const adminListRpc = await helper.collection.getAdmins(collectionId);762 const adminListRpc = await helper.collection.getAdmins(collectionId);801 },793 },802 'uri',794 'uri',803 );795 );804 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);796 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);805797806 // admin (sub and eth) can mint token:798 // admin (sub and eth) can mint token:807 await collectionEvm.methods.mint(owner).send({from: adminEth});799 await collectionEvm.methods.mint(owner).send({from: adminEth});852 },844 },853 ).send();845 ).send();854846855 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);847 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);856848857 {849 {858 const adminList = await helper.collection.getAdmins(collectionId);850 const adminList = await helper.collection.getAdmins(collectionId);1062 },1054 },1063 ).send();1055 ).send();106410561065 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, caller);1057 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, testCase.mode, caller);106610581067 await collectionEvm.methods.deleteCollectionProperties(['testKey1', 'testKey2']).send({from: caller});1059 await collectionEvm.methods.deleteCollectionProperties(['testKey1', 'testKey2']).send({from: caller});106810601162 ],1154 ],1163 },1155 },1164 ).send();1156 ).send();1165 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);1157 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);116611581167 expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{1159 expect(await helper[testCase.mode].getPropertyPermissions(collectionId)).to.be.deep.equal([{1168 key: 'testKey',1160 key: 'testKey',1287 },1279 },1288 ).send();1280 ).send();128912811290 const collection = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, caller);1282 const collection = helper.ethNativeContract.collection(collectionAddress, testCase.mode, caller);1291 const tokenId = (await collection.methods.mintCross(receiver, [{key: 'testKey', value: Buffer.from('testValue')}, {key: 'testKey_1', value: Buffer.from('testValue_1')}]).send()).events.Transfer.returnValues.tokenId;1283 const tokenId = (await collection.methods.mintCross(receiver, [{key: 'testKey', value: Buffer.from('testValue')}, {key: 'testKey_1', value: Buffer.from('testValue_1')}]).send()).events.Transfer.returnValues.tokenId;1292 expect(await collection.methods.properties(tokenId, ['testKey', 'testKey_1']).call()).to.has.length(2);1284 expect(await collection.methods.properties(tokenId, ['testKey', 'testKey_1']).call()).to.has.length(2);129312851311 },1303 },1312 ).send();1304 ).send();131313051314 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);1306 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);131513071316 // Create a token to be nested to1308 // Create a token to be nested to1317 const mintingTargetNFTTokenIdResult = await contract.methods.mint(owner).send({from: owner});1309 const mintingTargetNFTTokenIdResult = await contract.methods.mint(owner).send({from: owner});1342 new CreateCollectionData('A', 'B', 'C', 'nft'),1334 new CreateCollectionData('A', 'B', 'C', 'nft'),1343 ).send();1335 ).send();134413361345 const unnestedContract = await helper.ethNativeContract.collection(unnestedCollectionAddress, 'nft', owner);1337 const unnestedContract = helper.ethNativeContract.collection(unnestedCollectionAddress, 'nft', owner);1346 expect(await unnestedContract.methods.collectionNesting().call({from: owner})).to.be.like([false, false, []]);1338 expect(await unnestedContract.methods.collectionNesting().call({from: owner})).to.be.like([false, false, []]);134713391348 const {collectionAddress} = await helper.eth.createCollection(1340 const {collectionAddress} = await helper.eth.createCollection(1357 },1349 },1358 ).send();1350 ).send();135913511360 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);1352 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);1361 expect(await contract.methods.collectionNesting().call({from: owner})).to.be.like([true, false, [unnestedCollectionAddress.toString()]]);1353 expect(await contract.methods.collectionNesting().call({from: owner})).to.be.like([true, false, [unnestedCollectionAddress.toString()]]);1362 await contract.methods.setCollectionNesting([false, false, []]).send({from: owner});1354 await contract.methods.setCollectionNesting([false, false, []]).send({from: owner});1363 expect(await contract.methods.collectionNesting().call({from: owner})).to.be.like([false, false, []]);1355 expect(await contract.methods.collectionNesting().call({from: owner})).to.be.like([false, false, []]);1378 },1370 },1379 ).send();1371 ).send();138013721381 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);1373 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);138213741383 // Create a token to nest into1375 // Create a token to nest into1384 const mintingTargetTokenIdResult = await contract.methods.mint(owner).send({from: owner});1376 const mintingTargetTokenIdResult = await contract.methods.mint(owner).send({from: owner});1419 }1411 }1420 });1412 });142114131422 itEth('NFT: foreign flag number is ignored', async ({helper}) => {1414 itEth('NFT: can\'t set foreign flag number', async ({helper}) => {1423 const owner = await helper.eth.createAccountWithBalance(donor);1415 const owner = await helper.eth.createAccountWithBalance(donor);142414161425 {1417 {1426 const {collectionId} = await helper.eth.createCollection(owner, {...createCollectionData, flags: 128}).send();1418 await expect(helper.eth.createCollection(owner, {...createCollectionData, flags: 128}).call({from: owner})).to.be.rejectedWith(/internal flags were used/);1427 expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({foreign: false, erc721metadata: false});1428 }1419 }142914201430 {1421 {1431 const {collectionId} = await helper.eth.createCollection(owner, {...createCollectionData, flags: 192}).send();1422 await expect(helper.eth.createCollection(owner, {...createCollectionData, flags: 192}).call({from: owner})).to.be.rejectedWith(/internal flags were used/);1432 expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({foreign: false, erc721metadata: true});1433 }1423 }1434 });1424 });143514251446 const owner = await helper.eth.createAccountWithBalance(donor);1436 const owner = await helper.eth.createAccountWithBalance(donor);144714371448 {1438 {1449 const {collectionId} = await helper.eth.createCollection(owner, {...createCollectionData, flags: [CollectionFlag.Foreign]}).send();1439 await expect(helper.eth.createCollection(owner, {...createCollectionData, flags: [CollectionFlag.Foreign]}).call({from: owner})).to.be.rejectedWith(/internal flags were used/);1450 expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({foreign: false, erc721metadata: false});1451 }1440 }145214411453 {1442 {1454 const {collectionId} = await helper.eth.createCollection(owner, {...createCollectionData, flags: [CollectionFlag.Erc721metadata | CollectionFlag.Foreign]}).send();1443 await expect(helper.eth.createCollection(owner, {...createCollectionData, flags: [CollectionFlag.Erc721metadata | CollectionFlag.Foreign]}).call({from: owner})).to.be.rejectedWith(/internal flags were used/);1455 expect((await helper.nft.getData(collectionId))?.raw.flags).to.be.deep.equal({foreign: false, erc721metadata: true});1456 }1444 }1457 });1445 });1458 });1446 });tests/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 = await helper.ethNativeContract.collectionHelpers(owner);62 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);636364 expect(await collectionHelpers.methods64 expect(await collectionHelpers.methods65 .isCollectionExist(expectedCollectionAddress)65 .isCollectionExist(expectedCollectionAddress)tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth505051 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');51 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');525253 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);53 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);54 await sponsorCollection.methods.confirmCollectionSponsorship().send();54 await sponsorCollection.methods.confirmCollectionSponsorship().send();555556 data = (await helper.rft.getData(collectionId))!;56 data = (await helper.rft.getData(collectionId))!;64 const description = 'absolutely anything';64 const description = 'absolutely anything';65 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');65 const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');666667 const collection = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);67 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);68 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);68 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);69 await collection.methods.setCollectionSponsorCross(sponsorCross).send();69 await collection.methods.setCollectionSponsorCross(sponsorCross).send();7070737374 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');74 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');757576 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);76 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);77 await sponsorCollection.methods.confirmCollectionSponsorship().send();77 await sponsorCollection.methods.confirmCollectionSponsorship().send();787879 data = (await helper.rft.getData(collectionId))!;79 data = (await helper.rft.getData(collectionId))!;84 itEth('Collection address exist', async ({helper}) => {84 itEth('Collection address exist', async ({helper}) => {85 const owner = await helper.eth.createAccountWithBalance(donor);85 const owner = await helper.eth.createAccountWithBalance(donor);86 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';86 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';87 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);87 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);888889 expect(await collectionHelpers89 expect(await collectionHelpers90 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())90 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())96 .to.be.true;96 .to.be.true;979798 // check collectionOwner:98 // check collectionOwner:99 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);99 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);100 const collectionOwner = await collectionEvm.methods.collectionOwner().call();100 const collectionOwner = await collectionEvm.methods.collectionOwner().call();101 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));101 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));102 });102 });103103104 itEth('destroyCollection', async ({helper}) => {104 itEth('destroyCollection', async ({helper}) => {105 const owner = await helper.eth.createAccountWithBalance(donor);105 const owner = await helper.eth.createAccountWithBalance(donor);106 const {collectionAddress, collectionId} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');106 const {collectionAddress, collectionId} = await helper.eth.createFungibleCollection(owner, 'Exister', DECIMALS, 'absolutely anything', 'WIWT');107 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);107 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);108108109 const result = await collectionHelper.methods109 const result = await collectionHelper.methods110 .destroyCollection(collectionAddress)110 .destroyCollection(collectionAddress)143143144 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {144 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {145 const owner = await helper.eth.createAccountWithBalance(donor);145 const owner = await helper.eth.createAccountWithBalance(donor);146 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);146 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);147 {147 {148 const MAX_NAME_LENGTH = 64;148 const MAX_NAME_LENGTH = 64;149 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);149 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);176176177 itEth('(!negative test!) cannot create collection if value !== 2', async ({helper}) => {177 itEth('(!negative test!) cannot create collection if value !== 2', async ({helper}) => {178 const owner = await helper.eth.createAccountWithBalance(donor);178 const owner = await helper.eth.createAccountWithBalance(donor);179 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);179 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);180 const expects = [0n, 1n, 30n].map(async value => {180 const expects = [0n, 1n, 30n].map(async value => {181 await expect(collectionHelper.methods181 await expect(collectionHelper.methods182 .createFTCollection('Peasantry', DECIMALS, 'absolutely anything', 'TWIW')182 .createFTCollection('Peasantry', DECIMALS, 'absolutely anything', 'TWIW')190 const owner = await helper.eth.createAccountWithBalance(donor);190 const owner = await helper.eth.createAccountWithBalance(donor);191 const peasant = helper.eth.createAccount();191 const peasant = helper.eth.createAccount();192 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');192 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');193 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', peasant, true);193 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant, true);194 const EXPECTED_ERROR = 'NoPermission';194 const EXPECTED_ERROR = 'NoPermission';195 {195 {196 const sponsor = await helper.eth.createAccountWithBalance(donor);196 const sponsor = await helper.eth.createAccountWithBalance(donor);197 await expect(peasantCollection.methods197 await expect(peasantCollection.methods198 .setCollectionSponsor(sponsor)198 .setCollectionSponsor(sponsor)199 .call()).to.be.rejectedWith(EXPECTED_ERROR);199 .call()).to.be.rejectedWith(EXPECTED_ERROR);200200201 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor, true);201 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor, true);202 await expect(sponsorCollection.methods202 await expect(sponsorCollection.methods203 .confirmCollectionSponsorship()203 .confirmCollectionSponsorship()204 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');204 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');214 const owner = await helper.eth.createAccountWithBalance(donor);214 const owner = await helper.eth.createAccountWithBalance(donor);215 const peasant = helper.eth.createAccount();215 const peasant = helper.eth.createAccount();216 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');216 const {collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Transgressed', DECIMALS, 'absolutely anything', 'YVNE');217 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', peasant);217 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', peasant);218 const EXPECTED_ERROR = 'NoPermission';218 const EXPECTED_ERROR = 'NoPermission';219 {219 {220 const sponsor = await helper.eth.createAccountWithBalance(donor);220 const sponsor = await helper.eth.createAccountWithBalance(donor);223 .setCollectionSponsorCross(sponsorCross)223 .setCollectionSponsorCross(sponsorCross)224 .call()).to.be.rejectedWith(EXPECTED_ERROR);224 .call()).to.be.rejectedWith(EXPECTED_ERROR);225225226 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor);226 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'ft', sponsor);227 await expect(sponsorCollection.methods227 await expect(sponsorCollection.methods228 .confirmCollectionSponsorship()228 .confirmCollectionSponsorship()229 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');229 .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 = await helper.ethNativeContract.collectionHelpers(owner);75 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);767677 expect(await collectionHelpers.methods77 expect(await collectionHelpers.methods78 .isCollectionExist(expectedCollectionAddress)78 .isCollectionExist(expectedCollectionAddress)tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth39 const baseUri = 'BaseURI';39 const baseUri = 'BaseURI';404041 const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);41 const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);42 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft');42 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');434344 expect(events).to.be.deep.equal([44 expect(events).to.be.deep.equal([45 {45 {82 const ss58Format = helper.chain.getChainProperties().ss58Format;82 const ss58Format = helper.chain.getChainProperties().ss58Format;83 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');83 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');848485 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);85 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner, true);86 await collection.methods.setCollectionSponsor(sponsor).send();86 await collection.methods.setCollectionSponsor(sponsor).send();878788 let data = (await helper.nft.getData(collectionId))!;88 let data = (await helper.nft.getData(collectionId))!;89 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));89 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));909091 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');91 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');929293 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);93 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);94 await sponsorCollection.methods.confirmCollectionSponsorship().send();94 await sponsorCollection.methods.confirmCollectionSponsorship().send();959596 data = (await helper.nft.getData(collectionId))!;96 data = (await helper.nft.getData(collectionId))!;104 const description = 'absolutely anything';104 const description = 'absolutely anything';105 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');105 const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');106106107 const collection = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);107 const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);108 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);108 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);109 await collection.methods.setCollectionSponsorCross(sponsorCross).send();109 await collection.methods.setCollectionSponsorCross(sponsorCross).send();110110125 itEth('Collection address exist', async ({helper}) => {125 itEth('Collection address exist', async ({helper}) => {126 const owner = await helper.eth.createAccountWithBalance(donor);126 const owner = await helper.eth.createAccountWithBalance(donor);127 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';127 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';128 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);128 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);129129130 expect(await collectionHelpers130 expect(await collectionHelpers131 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())131 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())137 .to.be.true;137 .to.be.true;138138139 // check collectionOwner:139 // check collectionOwner:140 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);140 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);141 const collectionOwner = await collectionEvm.methods.collectionOwner().call();141 const collectionOwner = await collectionEvm.methods.collectionOwner().call();142 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));142 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));143 });143 });156156157 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {157 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {158 const owner = await helper.eth.createAccountWithBalance(donor);158 const owner = await helper.eth.createAccountWithBalance(donor);159 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);159 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);160 {160 {161 const MAX_NAME_LENGTH = 64;161 const MAX_NAME_LENGTH = 64;162 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);162 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);190190191 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {191 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {192 const owner = await helper.eth.createAccountWithBalance(donor);192 const owner = await helper.eth.createAccountWithBalance(donor);193 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);193 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);194 await expect(collectionHelper.methods194 await expect(collectionHelper.methods195 .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')195 .createNFTCollection('Peasantry', 'absolutely anything', 'CVE')196 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');196 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');209 .setCollectionSponsor(sponsor)209 .setCollectionSponsor(sponsor)210 .call()).to.be.rejectedWith(EXPECTED_ERROR);210 .call()).to.be.rejectedWith(EXPECTED_ERROR);211211212 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);212 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor, true);213 await expect(sponsorCollection.methods213 await expect(sponsorCollection.methods214 .confirmCollectionSponsorship()214 .confirmCollectionSponsorship()215 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');215 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');225 const owner = await helper.eth.createAccountWithBalance(donor);225 const owner = await helper.eth.createAccountWithBalance(donor);226 const malfeasant = helper.eth.createAccount();226 const malfeasant = helper.eth.createAccount();227 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');227 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'Transgressed', 'absolutely anything', 'COR');228 const malfeasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);228 const malfeasantCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', malfeasant);229 const EXPECTED_ERROR = 'NoPermission';229 const EXPECTED_ERROR = 'NoPermission';230 {230 {231 const sponsor = await helper.eth.createAccountWithBalance(donor);231 const sponsor = await helper.eth.createAccountWithBalance(donor);234 .setCollectionSponsorCross(sponsorCross)234 .setCollectionSponsorCross(sponsorCross)235 .call()).to.be.rejectedWith(EXPECTED_ERROR);235 .call()).to.be.rejectedWith(EXPECTED_ERROR);236236237 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);237 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'nft', sponsor);238 await expect(sponsorCollection.methods238 await expect(sponsorCollection.methods239 .confirmCollectionSponsorship()239 .confirmCollectionSponsorship()240 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');240 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');249 itEth('destroyCollection', async ({helper}) => {249 itEth('destroyCollection', async ({helper}) => {250 const owner = await helper.eth.createAccountWithBalance(donor);250 const owner = await helper.eth.createAccountWithBalance(donor);251 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');251 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');252 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);252 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);253253254254255 const result = await collectionHelper.methods255 const result = await collectionHelper.methodstests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth95 const ss58Format = helper.chain.getChainProperties().ss58Format;95 const ss58Format = helper.chain.getChainProperties().ss58Format;96 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');96 const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(owner, 'Sponsor', 'absolutely anything', 'ENVY');979798 const collection = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);98 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);99 await collection.methods.setCollectionSponsor(sponsor).send();99 await collection.methods.setCollectionSponsor(sponsor).send();100100101 let data = (await helper.rft.getData(collectionId))!;101 let data = (await helper.rft.getData(collectionId))!;102 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));102 expect(data.raw.sponsorship.Unconfirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));103103104 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');104 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');105105106 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);106 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);107 await sponsorCollection.methods.confirmCollectionSponsorship().send();107 await sponsorCollection.methods.confirmCollectionSponsorship().send();108108109 data = (await helper.rft.getData(collectionId))!;109 data = (await helper.rft.getData(collectionId))!;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 = await helper.ethNativeContract.collection(collectionAddress, 'rft', owner);119 const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);120 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);120 const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);121 await collection.methods.setCollectionSponsorCross(sponsorCross).send();121 await collection.methods.setCollectionSponsorCross(sponsorCross).send();122122125125126 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');126 await expect(collection.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('ConfirmSponsorshipFail');127127128 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);128 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);129 await sponsorCollection.methods.confirmCollectionSponsorship().send();129 await sponsorCollection.methods.confirmCollectionSponsorship().send();130130131 data = (await helper.rft.getData(collectionId))!;131 data = (await helper.rft.getData(collectionId))!;135 itEth('Collection address exist', async ({helper}) => {135 itEth('Collection address exist', async ({helper}) => {136 const owner = await helper.eth.createAccountWithBalance(donor);136 const owner = await helper.eth.createAccountWithBalance(donor);137 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';137 const collectionAddressForNonexistentCollection = '0x17C4E6453CC49AAAAEACA894E6D9683E00112233';138 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(owner);138 const collectionHelpers = helper.ethNativeContract.collectionHelpers(owner);139139140 expect(await collectionHelpers140 expect(await collectionHelpers141 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())141 .methods.isCollectionExist(collectionAddressForNonexistentCollection).call())147 .to.be.true;147 .to.be.true;148148149 // check collectionOwner:149 // check collectionOwner:150 const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);150 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);151 const collectionOwner = await collectionEvm.methods.collectionOwner().call();151 const collectionOwner = await collectionEvm.methods.collectionOwner().call();152 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));152 expect(helper.address.restoreCrossAccountFromBigInt(BigInt(collectionOwner.sub))).to.eq(helper.address.ethToSubstrate(owner, true));153 });153 });167167168 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {168 itEth('(!negative test!) Create collection (bad lengths)', async ({helper}) => {169 const owner = await helper.eth.createAccountWithBalance(donor);169 const owner = await helper.eth.createAccountWithBalance(donor);170 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);170 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);171 {171 {172 const MAX_NAME_LENGTH = 64;172 const MAX_NAME_LENGTH = 64;173 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);173 const collectionName = 'A'.repeat(MAX_NAME_LENGTH + 1);200200201 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {201 itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {202 const owner = await helper.eth.createAccountWithBalance(donor);202 const owner = await helper.eth.createAccountWithBalance(donor);203 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);203 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);204 await expect(collectionHelper.methods204 await expect(collectionHelper.methods205 .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')205 .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')206 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');206 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');211 const owner = await helper.eth.createAccountWithBalance(donor);211 const owner = await helper.eth.createAccountWithBalance(donor);212 const peasant = helper.eth.createAccount();212 const peasant = helper.eth.createAccount();213 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');213 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');214 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', peasant, true);214 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant, true);215 const EXPECTED_ERROR = 'NoPermission';215 const EXPECTED_ERROR = 'NoPermission';216 {216 {217 const sponsor = await helper.eth.createAccountWithBalance(donor);217 const sponsor = await helper.eth.createAccountWithBalance(donor);218 await expect(peasantCollection.methods218 await expect(peasantCollection.methods219 .setCollectionSponsor(sponsor)219 .setCollectionSponsor(sponsor)220 .call()).to.be.rejectedWith(EXPECTED_ERROR);220 .call()).to.be.rejectedWith(EXPECTED_ERROR);221221222 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);222 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor, true);223 await expect(sponsorCollection.methods223 await expect(sponsorCollection.methods224 .confirmCollectionSponsorship()224 .confirmCollectionSponsorship()225 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');225 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');235 const owner = await helper.eth.createAccountWithBalance(donor);235 const owner = await helper.eth.createAccountWithBalance(donor);236 const peasant = helper.eth.createAccount();236 const peasant = helper.eth.createAccount();237 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');237 const {collectionAddress} = await helper.eth.createRFTCollection(owner, 'Transgressed', 'absolutely anything', 'YVNE');238 const peasantCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);238 const peasantCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', peasant);239 const EXPECTED_ERROR = 'NoPermission';239 const EXPECTED_ERROR = 'NoPermission';240 {240 {241 const sponsor = await helper.eth.createAccountWithBalance(donor);241 const sponsor = await helper.eth.createAccountWithBalance(donor);244 .setCollectionSponsorCross(sponsorCross)244 .setCollectionSponsorCross(sponsorCross)245 .call()).to.be.rejectedWith(EXPECTED_ERROR);245 .call()).to.be.rejectedWith(EXPECTED_ERROR);246246247 const sponsorCollection = await helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);247 const sponsorCollection = helper.ethNativeContract.collection(collectionAddress, 'rft', sponsor);248 await expect(sponsorCollection.methods248 await expect(sponsorCollection.methods249 .confirmCollectionSponsorship()249 .confirmCollectionSponsorship()250 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');250 .call()).to.be.rejectedWith('ConfirmSponsorshipFail');259 itEth('destroyCollection', async ({helper}) => {259 itEth('destroyCollection', async ({helper}) => {260 const owner = await helper.eth.createAccountWithBalance(donor);260 const owner = await helper.eth.createAccountWithBalance(donor);261 const {collectionAddress, collectionId} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');261 const {collectionAddress, collectionId} = await helper.eth.createRFTCollection(owner, 'Limits', 'absolutely anything', 'OLF');262 const collectionHelper = await helper.ethNativeContract.collectionHelpers(owner);262 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);263263264 await expect(collectionHelper.methods264 await expect(collectionHelper.methods265 .destroyCollection(collectionAddress)265 .destroyCollection(collectionAddress)tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth207 }207 }208208209 private async createTransaction() {209 private async createTransaction() {210 const collectionHelper = await this.helper.ethNativeContract.collectionHelpers(this.signer);210 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(this.signer);211 let collectionMode;211 let collectionMode;212 switch (this.data.collectionMode) {212 switch (this.data.collectionMode) {213 case 'nft': collectionMode = CollectionMode.Nonfungible; break;213 case 'nft': collectionMode = CollectionMode.Nonfungible; break;tests/src/util/index.tsdiffbeforeafterboth15import {dirname} from 'path';15import {dirname} from 'path';16import {fileURLToPath} from 'url';16import {fileURLToPath} from 'url';171718chai.config.truncateThreshold = 0;18chai.use(chaiAsPromised);19chai.use(chaiAsPromised);19chai.use(chaiSubset);20chai.use(chaiSubset);20export const expect = chai.expect;21export const expect = chai.expect;tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth41 for(const arg of args) {41 for(const arg of args) {42 if(typeof arg !== 'string')42 if(typeof arg !== 'string')43 continue;43 continue;44 const skippedWarnings = ['1000:: Normal connection closure', 'Not decorating unknown runtime apis:', 'RPC methods not decorated:', 'Not decorating runtime apis'];44 if(arg.includes('1000:: Normal connection closure') || arg.includes('Not decorating unknown runtime apis:') || arg.includes('RPC methods not decorated:') || arg === 'Normal connection closure')45 const needToSkip = skippedWarnings.reduce((a, b) => a || arg.includes(b), false);45 return;46 if(needToSkip || arg === 'Normal connection closure')47 return;46 }48 }47 printer(...args);49 printer(...args);48 };50 };