1import {expect} from 'chai';2import {tokenIdToAddress} from '../eth/util/helpers';3import privateKey from '../substrate/privateKey';4import usingApi, {executeTransaction} from '../substrate/substrate-api';5import {6 addToAllowListExpectSuccess,7 createCollectionExpectSuccess,8 createItemExpectSuccess,9 enableAllowListExpectSuccess,10 enablePublicMintingExpectSuccess,11 getTokenOwner, 12 getTopmostTokenOwner, 13 normalizeAccountId, 14 setCollectionLimitsExpectSuccess, 15 transferExpectFailure, 16 transferExpectSuccess, 17 transferFromExpectSuccess,18} from '../util/helpers';19import {IKeyringPair} from '@polkadot/types/types';2021let alice: IKeyringPair;22let bob: IKeyringPair;2324describe('Integration Test: Nesting', () => {25 before(async () => {26 await usingApi(async api => {27 alice = privateKey('//Alice');28 bob = privateKey('//Bob');29 });30 });3132 it('Performs the full suite: bundles a token, transfers, and allows to unnest', async () => {33 await usingApi(async api => {34 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});35 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});36 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');3738 39 const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});40 expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: alice.address});41 expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});4243 44 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');45 46 47 await transferExpectSuccess(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});48 expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});49 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});5051 52 await transferExpectSuccess(collection, targetToken, alice, {Substrate: bob.address});53 expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: bob.address});54 expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});5556 57 await transferFromExpectSuccess(collection, newToken, bob, {Ethereum: tokenIdToAddress(collection, targetToken)}, {Substrate: bob.address});58 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});59 });60 });6162 6364 it('NFT: allows an Owner to nest/unnest their token', async () => {65 await usingApi(async api => {66 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});67 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});68 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');6970 71 const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});72 expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: alice.address});73 expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});7475 76 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');77 await transferExpectSuccess(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});78 expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});79 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});80 });81 });8283 it('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async () => {84 await usingApi(async api => {85 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});86 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[collection]}});87 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');8889 90 const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});91 expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: alice.address});92 expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});9394 95 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');96 await transferExpectSuccess(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});97 expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});98 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});99 });100 });101102 103104 it('Fungible: allows an Owner to nest/unnest their token', async () => {105 await usingApi(async api => {106 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});107 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});108 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});109 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};110111 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});112113 114 await expect(executeTransaction(api, alice, api.tx.unique.createItem(115 collectionFT, 116 targetAddress, 117 {Fungible: {Value: 10}},118 ))).to.not.be.rejected;119120 121 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');122 await transferExpectSuccess(collectionFT, newToken, alice, targetAddress, 1, 'Fungible');123 });124 });125126 it('Fungible: allows an Owner to nest/unnest their token (Restricted nesting)', async () => {127 await usingApi(async api => {128 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});129 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});130 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};131132 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});133134 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionFT]}});135136 137 await expect(executeTransaction(api, alice, api.tx.unique.createItem(138 collectionFT, 139 targetAddress, 140 {Fungible: {Value: 10}},141 ))).to.not.be.rejected;142143 144 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');145 await transferExpectSuccess(collectionFT, newToken, alice, targetAddress, 1, 'Fungible');146 });147 });148149 150151 it('ReFungible: allows an Owner to nest/unnest their token', async () => {152 await usingApi(async api => {153 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});154 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});155 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});156 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};157158 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});159160 161 await expect(executeTransaction(api, alice, api.tx.unique.createItem(162 collectionRFT, 163 targetAddress, 164 {ReFungible: {const_data: [], pieces: 100}},165 ))).to.not.be.rejected;166167 168 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');169 await transferExpectSuccess(collectionRFT, newToken, alice, targetAddress, 100, 'ReFungible');170 });171 });172173 it('ReFungible: allows an Owner to nest/unnest their token (Restricted nesting)', async () => {174 await usingApi(async api => {175 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});176 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});177 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};178179 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});180181 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionRFT]}});182183 184 await expect(executeTransaction(api, alice, api.tx.unique.createItem(185 collectionRFT, 186 targetAddress,187 {ReFungible: {const_data: [], pieces: 100}},188 ))).to.not.be.rejected;189190 191 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');192 await transferExpectSuccess(collectionRFT, newToken, alice, targetAddress, 100, 'ReFungible');193 });194 });195});196197describe('Negative Test: Nesting', async() => {198 before(async () => {199 await usingApi(async api => {200 alice = privateKey('//Alice');201 bob = privateKey('//Bob');202 });203 });204205 it('Disallows excessive token nesting', async () => {206 await usingApi(async api => {207 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});208 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});209 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');210211 212 const nestedToken1 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});213 const nestedToken2 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, nestedToken1)});214 215 await expect(executeTransaction(216 api, alice, 217 api.tx.unique.createItem(218 collection, 219 {Ethereum: tokenIdToAddress(collection, nestedToken2)}, 220 {nft: {const_data: [], variable_data: []}} as any,221 ),222 ), 'while creating nested token').to.be.rejectedWith(/^structure\.DepthLimit$/); 223224 expect(await getTopmostTokenOwner(api, collection, nestedToken2)).to.be.deep.equal({Substrate: alice.address});225 });226 });227228 229230 it('NFT: disallows to nest token if nesting is disabled', async () => {231 await usingApi(async api => {232 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});233 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Disabled'});234 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');235236 237 await expect(executeTransaction(238 api, alice, 239 api.tx.unique.createItem(240 collection, 241 {Ethereum: tokenIdToAddress(collection, targetToken)}, 242 {nft: {const_data: [], variable_data: []}} as any,243 ),244 ), 'while creating nested token').to.be.rejectedWith(/^common\.NestingIsDisabled$/);245246 247 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');248 249 await expect(executeTransaction(250 api, alice, 251 api.tx.unique.transfer(252 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,253 ),254 ), 'while nesting new token').to.be.rejectedWith(/common\.NestingIsDisabled/); 255 expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});256 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});257 });258 });259260 it('NFT: disallows a non-Owner to nest someone else\'s token', async () => {261 await usingApi(async api => {262 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});263 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});264265 await addToAllowListExpectSuccess(alice, collection, bob.address);266 await enableAllowListExpectSuccess(alice, collection);267 await enablePublicMintingExpectSuccess(alice, collection);268269 270 const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');271272 273 await expect(executeTransaction(274 api, alice, 275 api.tx.unique.createItem(276 collection, 277 {Ethereum: tokenIdToAddress(collection, targetToken)}, 278 {nft: {const_data: [], variable_data: []}} as any,279 ),280 ), 'while creating nested token').to.be.rejectedWith(/structure\.DepthLimit/); 281282 283 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');284 await expect(executeTransaction(285 api, alice, 286 api.tx.unique.transfer(287 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,288 ),289 ), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);290 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});291 });292 });293294 it('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {295 await usingApi(async api => {296 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});297 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[collection]}});298299 await addToAllowListExpectSuccess(alice, collection, bob.address);300 await enableAllowListExpectSuccess(alice, collection);301 await enablePublicMintingExpectSuccess(alice, collection);302303 304 const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');305306 307 await expect(executeTransaction(308 api, alice, 309 api.tx.unique.createItem(310 collection, 311 {Ethereum: tokenIdToAddress(collection, targetToken)}, 312 {nft: {const_data: [], variable_data: []}} as any,313 ),314 ), 'while creating nested token').to.be.rejectedWith(/structure\.DepthLimit/);315316 317 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');318 await expect(executeTransaction(319 api, alice, 320 api.tx.unique.transfer(321 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,322 ),323 ), 'while nesting new token').to.be.rejectedWith(/common\.AddressNotInAllowlist/);324 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});325 });326 });327328 it('NFT: disallows to nest token in an unlisted collection', async () => {329 await usingApi(async api => {330 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});331 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[]}});332333 334 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');335336 337 await expect(executeTransaction(338 api, alice, 339 api.tx.unique.createItem(340 collection, 341 {Ethereum: tokenIdToAddress(collection, targetToken)}, 342 {nft: {const_data: [], variable_data: []}} as any,343 ),344 ), 'while creating nested token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);345346 347 const newToken = await createItemExpectSuccess(alice, collection, 'NFT');348 await expect(executeTransaction(349 api, alice, 350 api.tx.unique.transfer(351 normalizeAccountId({Ethereum: tokenIdToAddress(collection, targetToken)}), collection, newToken, 1,352 ),353 ), 'while nesting new token').to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);354 expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});355 });356 });357358 359360 it('Fungible: disallows to nest token if nesting is disabled', async () => {361 await usingApi(async api => {362 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});363 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Disabled'});364 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');365 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};366367 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});368369 370 await expect(executeTransaction(371 api, alice, 372 api.tx.unique.createItem(373 collectionFT, 374 targetAddress, 375 {Fungible: {Value: 10}},376 )377 ), 'while creating nested token').to.be.rejectedWith(/^common\.NestingIsDisabled$/);378379 380 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');381 382 await expect(executeTransaction(383 api, alice, 384 api.tx.unique.transfer(385 normalizeAccountId({Ethereum: tokenIdToAddress(collectionFT, targetToken)}), collectionFT, newToken, 1,386 ),387 ), 'while nesting new token').to.be.rejectedWith(/fungible\.FungibleDisallowsNesting/);388 });389 });390391 it('Fungible: disallows a non-Owner to nest someone else\'s token', async () => {392 await usingApi(async api => {393 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});394 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});395396 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);397 await enableAllowListExpectSuccess(alice, collectionNFT);398 await enablePublicMintingExpectSuccess(alice, collectionNFT);399400 401 const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');402 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};403404 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});405406 407 await expect(executeTransaction(408 api, alice, 409 api.tx.unique.createItem(410 collectionFT, 411 targetAddress, 412 {Fungible: {Value: 10}},413 )414 ), 'while creating nested token').to.be.rejectedWith(/structure\.DepthLimit/);415416 417 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');418 await expect(executeTransaction(419 api, alice, 420 api.tx.unique.transfer(421 normalizeAccountId({Ethereum: tokenIdToAddress(collectionFT, targetToken)}), collectionFT, newToken, 1,422 ),423 ), 'while nesting new token').to.be.rejectedWith(/fungible\.FungibleDisallowsNesting/);424 });425 });426427 it('Fungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {428 await usingApi(async api => {429 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});430 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionNFT]}}); 431432 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);433 await enableAllowListExpectSuccess(alice, collectionNFT);434 await enablePublicMintingExpectSuccess(alice, collectionNFT);435436 437 const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');438 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};439440 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});441442 443 await expect(executeTransaction(api, alice, api.tx.unique.createItem(444 collectionFT, 445 targetAddress, 446 {Fungible: {Value: 10}},447 ))).to.be.rejected;448449 450 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');451 await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);452 });453 });454455 it('Fungible: disallows to nest token in an unlisted collection', async () => {456 await usingApi(async api => {457 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});458 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[]}});459460 461 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');462 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};463464 const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});465466 467 await expect(executeTransaction(api, alice, api.tx.unique.createItem(468 collectionFT, 469 targetAddress, 470 {Fungible: {Value: 10}},471 ))).to.be.rejected;472473 474 const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');475 await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);476 });477 });478479 480481 it('ReFungible: disallows to nest token if nesting is disabled', async () => {482 await usingApi(async api => {483 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});484 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Disabled'});485 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');486 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};487488 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});489490 491 await expect(executeTransaction(api, alice, api.tx.unique.createItem(492 collectionRFT, 493 targetAddress, 494 {ReFungible: {const_data: [], pieces: 100}},495 ))).to.be.rejectedWith(/^common\.NestingIsDisabled$/);496497 498 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');499 500 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);501 });502 });503504 it('ReFungible: disallows a non-Owner to nest someone else\'s token', async () => {505 await usingApi(async api => {506 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});507 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});508509 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);510 await enableAllowListExpectSuccess(alice, collectionNFT);511 await enablePublicMintingExpectSuccess(alice, collectionNFT);512513 514 const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');515 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};516517 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});518519 520 await expect(executeTransaction(api, alice, api.tx.unique.createItem(521 collectionRFT, 522 targetAddress, 523 {ReFungible: {const_data: [], pieces: 100}},524 ))).to.be.rejected;525526 527 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');528 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);529 });530 });531532 it('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => {533 await usingApi(async api => {534 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});535 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionNFT]}});536537 await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);538 await enableAllowListExpectSuccess(alice, collectionNFT);539 await enablePublicMintingExpectSuccess(alice, collectionNFT);540541 542 const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');543 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};544545 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});546547 548 await expect(executeTransaction(api, alice, api.tx.unique.createItem(549 collectionRFT, 550 targetAddress, 551 {ReFungible: {const_data: [], pieces: 100}},552 ))).to.be.rejected;553554 555 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');556 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);557 });558 });559560 it('ReFungible: disallows to nest token to an unlisted collection', async () => {561 await usingApi(async api => {562 const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});563 await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[]}});564565 566 const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');567 const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};568569 const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});570571 572 await expect(executeTransaction(api, alice, api.tx.unique.createItem(573 collectionRFT, 574 targetAddress, 575 {ReFungible: {const_data: [], pieces: 100}},576 ))).to.be.rejected;577578 579 const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');580 await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);581 });582 });583});