difftreelog
tests(nesting): refactor naming conventions for token addresses
in: master
7 files changed
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -240,7 +240,7 @@
}
fromTokenId(collectionId: number, tokenId: number): string {
- return this.helper.util.getNestingTokenAddressRaw({collectionId, tokenId});
+ return this.helper.util.getTokenAddress({collectionId, tokenId});
}
normalizeAddress(address: string): string {
tests/src/nesting/graphs.test.tsdiffbeforeafterboth--- a/tests/src/nesting/graphs.test.ts
+++ b/tests/src/nesting/graphs.test.ts
@@ -64,7 +64,7 @@
'second transaction',
).to.be.rejectedWith(/structure\.OuroborosDetected/);
await expect(
- tokens[1].transferFrom(alice, tokens[0].nestingAddress(), tokens[7].nestingAddress()),
+ tokens[1].transferFrom(alice, tokens[0].nestingAccount(), tokens[7].nestingAccount()),
'third transaction',
).to.be.rejectedWith(/structure\.OuroborosDetected/);
});
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -33,9 +33,9 @@
const targetToken = await collection.mintToken(alice);
// Create an immediately nested token
- const nestedToken = await collection.mintToken(alice, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(alice, targetToken.nestingAccount());
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: alice.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Create a token to be nested
const newToken = await collection.mintToken(alice);
@@ -43,14 +43,14 @@
// Nest
await newToken.nest(alice, targetToken);
expect(await newToken.getTopmostOwner()).to.be.deep.equal({Substrate: alice.address});
- expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Move bundle to different user
await targetToken.transfer(alice, {Substrate: bob.address});
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: bob.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
expect(await newToken.getTopmostOwner()).to.be.deep.equal({Substrate: bob.address});
- expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Unnest
await newToken.unnest(bob, targetToken, {Substrate: bob.address});
@@ -64,13 +64,13 @@
const tokenB = await collection.mintToken(alice);
// Create a nested token
- const tokenC = await collection.mintToken(alice, tokenA.nestingAddress());
- expect(await tokenC.getOwner()).to.be.deep.equal(tokenA.nestingAddress());
+ const tokenC = await collection.mintToken(alice, tokenA.nestingAccount());
+ expect(await tokenC.getOwner()).to.be.deep.equal(tokenA.nestingAccount());
// Transfer the nested token to another token
- await expect(tokenC.transferFrom(alice, tokenA.nestingAddress(), tokenB.nestingAddress())).to.be.fulfilled;
+ await expect(tokenC.transferFrom(alice, tokenA.nestingAccount(), tokenB.nestingAccount())).to.be.fulfilled;
expect(await tokenC.getTopmostOwner()).to.be.deep.equal({Substrate: alice.address});
- expect(await tokenC.getOwner()).to.be.deep.equal(tokenB.nestingAddress());
+ expect(await tokenC.getOwner()).to.be.deep.equal(tokenB.nestingAccount());
});
itSub('Checks token children', async ({helper}) => {
@@ -81,7 +81,7 @@
expect((await targetToken.getChildren()).length).to.be.equal(0, 'Children length check at creation');
// Create a nested NFT token
- const tokenA = await collectionA.mintToken(alice, targetToken.nestingAddress());
+ const tokenA = await collectionA.mintToken(alice, targetToken.nestingAccount());
expect(await targetToken.getChildren()).to.have.deep.members([
{tokenId: tokenA.tokenId, collectionId: collectionA.collectionId},
], 'Children contents check at nesting #1').and.be.length(1, 'Children length check at nesting #1');
@@ -102,7 +102,7 @@
// Create a fungible token in another collection and then nest
await collectionB.mint(alice, 10n);
- await collectionB.transfer(alice, targetToken.nestingAddress(), 2n);
+ await collectionB.transfer(alice, targetToken.nestingAccount(), 2n);
expect(await targetToken.getChildren()).to.be.have.deep.members([
{tokenId: tokenA.tokenId, collectionId: collectionA.collectionId},
{tokenId: 0, collectionId: collectionB.collectionId},
@@ -110,7 +110,7 @@
.and.be.length(2, 'Children length check at nesting #4 (from another collection)');
// Move part of the fungible token inside token A deeper in the nesting tree
- await collectionB.transferFrom(alice, targetToken.nestingAddress(), tokenA.nestingAddress(), 1n);
+ await collectionB.transferFrom(alice, targetToken.nestingAccount(), tokenA.nestingAccount(), 1n);
expect(await targetToken.getChildren()).to.be.have.deep.members([
{tokenId: tokenA.tokenId, collectionId: collectionA.collectionId},
{tokenId: 0, collectionId: collectionB.collectionId},
@@ -120,7 +120,7 @@
], 'Children contents check at nesting #5.5 (deeper)').and.be.length(1, 'Children length check at nesting #5.5 (deeper)');
// Move the remaining part of the fungible token inside token A deeper in the nesting tree
- await collectionB.transferFrom(alice, targetToken.nestingAddress(), tokenA.nestingAddress(), 1n);
+ await collectionB.transferFrom(alice, targetToken.nestingAccount(), tokenA.nestingAccount(), 1n);
expect(await targetToken.getChildren()).to.be.have.deep.members([
{tokenId: tokenA.tokenId, collectionId: collectionA.collectionId},
], 'Children contents check at nesting #6 (deeper)').and.be.length(1, 'Children length check at nesting #6 (deeper)');
@@ -148,15 +148,15 @@
const targetToken = await collection.mintToken(alice, {Substrate: charlie.address});
// Create an immediately nested token
- const nestedToken = await collection.mintToken(bob, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(bob, targetToken.nestingAccount());
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Create a token to be nested and nest
const newToken = await collection.mintToken(bob);
await newToken.nest(bob, targetToken);
expect(await newToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
});
itSub('Admin (NFT): Admin and Token Owner can operate together', async ({helper}) => {
@@ -165,15 +165,15 @@
const targetToken = await collection.mintToken(alice, {Substrate: charlie.address});
// Create an immediately nested token by an administrator
- const nestedToken = await collection.mintToken(bob, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(bob, targetToken.nestingAccount());
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Create a token to be nested and nest
const newToken = await collection.mintToken(alice, {Substrate: charlie.address});
await newToken.nest(charlie, targetToken);
expect(await newToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
});
itSub('Admin (NFT): allows an Admin to nest a token (Restricted nesting)', async ({helper}) => {
@@ -185,15 +185,15 @@
const targetToken = await collectionA.mintToken(alice, {Substrate: charlie.address});
// Create an immediately nested token
- const nestedToken = await collectionB.mintToken(bob, targetToken.nestingAddress());
+ const nestedToken = await collectionB.mintToken(bob, targetToken.nestingAccount());
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Create a token to be nested and nest
const newToken = await collectionB.mintToken(bob);
await newToken.nest(bob, targetToken);
expect(await newToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
});
// ---------- Non-Fungible ----------
@@ -202,18 +202,18 @@
const collection = await helper.nft.mintCollection(alice, {permissions: {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}}});
await collection.addToAllowList(alice, {Substrate: charlie.address});
const targetToken = await collection.mintToken(charlie);
- await collection.addToAllowList(alice, targetToken.nestingAddress());
+ await collection.addToAllowList(alice, targetToken.nestingAccount());
// Create an immediately nested token
- const nestedToken = await collection.mintToken(charlie, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(charlie, targetToken.nestingAccount());
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Create a token to be nested and nest
const newToken = await collection.mintToken(charlie);
await newToken.nest(charlie, targetToken);
expect(await newToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
});
itSub('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {
@@ -224,22 +224,22 @@
await collectionA.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted:[collectionB.collectionId]}});
await collectionA.addToAllowList(alice, {Substrate: charlie.address});
- await collectionA.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionA.addToAllowList(alice, targetToken.nestingAccount());
await collectionB.setPermissions(alice, {access: 'AllowList', mintMode: true});
await collectionB.addToAllowList(alice, {Substrate: charlie.address});
- await collectionB.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionB.addToAllowList(alice, targetToken.nestingAccount());
// Create an immediately nested token
- const nestedToken = await collectionB.mintToken(charlie, targetToken.nestingAddress());
+ const nestedToken = await collectionB.mintToken(charlie, targetToken.nestingAccount());
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Create a token to be nested and nest
const newToken = await collectionB.mintToken(charlie);
await newToken.nest(charlie, targetToken);
expect(await newToken.getTopmostOwner()).to.be.deep.equal({Substrate: charlie.address});
- expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await newToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
});
// ---------- Fungible ----------
@@ -250,20 +250,20 @@
const targetToken = await collectionNFT.mintToken(alice, {Substrate: charlie.address});
await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionNFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
await collectionFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
await collectionFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionFT.addToAllowList(alice, targetToken.nestingAccount());
// Create an immediately nested token
- await collectionFT.mint(charlie, 5n, targetToken.nestingAddress());
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(5n);
+ await collectionFT.mint(charlie, 5n, targetToken.nestingAccount());
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
// Create a token to be nested and nest
await collectionFT.mint(charlie, 5n);
- await collectionFT.transfer(charlie, targetToken.nestingAddress(), 2n);
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(7n);
+ await collectionFT.transfer(charlie, targetToken.nestingAccount(), 2n);
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n);
});
itSub('Fungible: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {
@@ -273,20 +273,20 @@
await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted:[collectionFT.collectionId]}});
await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionNFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
await collectionFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
await collectionFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionFT.addToAllowList(alice, targetToken.nestingAccount());
// Create an immediately nested token
- await collectionFT.mint(charlie, 5n, targetToken.nestingAddress());
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(5n);
+ await collectionFT.mint(charlie, 5n, targetToken.nestingAccount());
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
// Create a token to be nested and nest
await collectionFT.mint(charlie, 5n);
- await collectionFT.transfer(charlie, targetToken.nestingAddress(), 2n);
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(7n);
+ await collectionFT.transfer(charlie, targetToken.nestingAccount(), 2n);
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n);
});
// ---------- Re-Fungible ----------
@@ -297,20 +297,20 @@
const targetToken = await collectionNFT.mintToken(alice, {Substrate: charlie.address});
await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionNFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
await collectionRFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
await collectionRFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionRFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionRFT.addToAllowList(alice, targetToken.nestingAccount());
// Create an immediately nested token
- const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAddress());
- expect(await nestedToken.getBalance(targetToken.nestingAddress())).to.be.equal(5n);
+ const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAccount());
+ expect(await nestedToken.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
// Create a token to be nested and nest
const newToken = await collectionRFT.mintToken(charlie, 5n);
- await newToken.transfer(charlie, targetToken.nestingAddress(), 2n);
- expect(await newToken.getBalance(targetToken.nestingAddress())).to.be.equal(2n);
+ await newToken.transfer(charlie, targetToken.nestingAccount(), 2n);
+ expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(2n);
});
itSub.ifWithPallets('ReFungible: allows an Owner to nest/unnest their token (Restricted nesting)', [Pallets.ReFungible], async ({helper}) => {
@@ -320,20 +320,20 @@
await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted:[collectionRFT.collectionId]}});
await collectionNFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionNFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
await collectionRFT.setPermissions(alice, {access: 'AllowList', mintMode: true});
await collectionRFT.addToAllowList(alice, {Substrate: charlie.address});
- await collectionRFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionRFT.addToAllowList(alice, targetToken.nestingAccount());
// Create an immediately nested token
- const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAddress());
- expect(await nestedToken.getBalance(targetToken.nestingAddress())).to.be.equal(5n);
+ const nestedToken = await collectionRFT.mintToken(charlie, 5n, targetToken.nestingAccount());
+ expect(await nestedToken.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
// Create a token to be nested and nest
const newToken = await collectionRFT.mintToken(charlie, 5n);
- await newToken.transfer(charlie, targetToken.nestingAddress(), 2n);
- expect(await newToken.getBalance(targetToken.nestingAddress())).to.be.equal(2n);
+ await newToken.transfer(charlie, targetToken.nestingAccount(), 2n);
+ expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(2n);
});
});
@@ -356,11 +356,11 @@
// Create a nested-token matryoshka
for (let i = 0; i < maxNestingLevel; i++) {
- token = await collection.mintToken(alice, token.nestingAddress());
+ token = await collection.mintToken(alice, token.nestingAccount());
}
// The nesting depth is limited by `maxNestingLevel`
- await expect(collection.mintToken(alice, token.nestingAddress()))
+ await expect(collection.mintToken(alice, token.nestingAccount()))
.to.be.rejectedWith(/structure\.DepthLimit/);
expect(await token.getTopmostOwner()).to.be.deep.equal({Substrate: alice.address});
expect(await token.getChildren()).to.be.length(0);
@@ -374,7 +374,7 @@
const targetToken = await collection.mintToken(alice);
// Try to create an immediately nested token as collection admin when it's disallowed
- await expect(collection.mintToken(bob, targetToken.nestingAddress()))
+ await expect(collection.mintToken(bob, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create a token to be nested and nest
@@ -390,10 +390,10 @@
const collection = await helper.nft.mintCollection(alice, {permissions: {access: 'AllowList', mintMode: true, nesting: {collectionAdmin: true}}});
const targetToken = await collection.mintToken(alice, {Substrate: bob.address});
await collection.addToAllowList(alice, {Substrate: bob.address});
- await collection.addToAllowList(alice, targetToken.nestingAddress());
+ await collection.addToAllowList(alice, targetToken.nestingAccount());
// Try to create a nested token as token owner when it's disallowed
- await expect(collection.mintToken(bob, targetToken.nestingAddress()))
+ await expect(collection.mintToken(bob, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create a token to be nested and nest
@@ -410,7 +410,7 @@
//await collection.addAdmin(alice, {Substrate: bob.address});
const targetToken = await collection.mintToken(alice, {Substrate: bob.address});
await collection.addToAllowList(alice, {Substrate: bob.address});
- await collection.addToAllowList(alice, targetToken.nestingAddress());
+ await collection.addToAllowList(alice, targetToken.nestingAccount());
// Try to nest somebody else's token
const newToken = await collection.mintToken(bob);
@@ -418,13 +418,13 @@
.to.be.rejectedWith(/common\.NoPermission/);
// Try to unnest a token belonging to someone else as collection admin
- const nestedToken = await collection.mintToken(alice, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(alice, targetToken.nestingAccount());
await expect(nestedToken.unnest(alice, targetToken, {Substrate: bob.address}))
.to.be.rejectedWith(/common\.AddressNotInAllowlist/);
expect(await targetToken.getChildren()).to.be.length(1);
expect(await nestedToken.getTopmostOwner()).to.be.deep.equal({Substrate: bob.address});
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
});
itSub('Admin (NFT): disallows an Admin to nest a token from an unlisted collection (Restricted nesting)', async ({helper}) => {
@@ -434,7 +434,7 @@
const targetToken = await collectionA.mintToken(alice);
// Try to create a nested token from another collection
- await expect(collectionB.mintToken(alice, targetToken.nestingAddress()))
+ await expect(collectionB.mintToken(alice, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
// Create a token in another collection yet to be nested and try to nest
@@ -454,7 +454,7 @@
const targetToken = await collection.mintToken(alice);
// Try to create a nested token as token owner when it's disallowed
- await expect(collection.mintToken(alice, targetToken.nestingAddress()))
+ await expect(collection.mintToken(alice, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create a token to be nested and nest
@@ -472,7 +472,7 @@
await collection.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}});
await collection.addToAllowList(alice, {Substrate: bob.address});
- await collection.addToAllowList(alice, targetToken.nestingAddress());
+ await collection.addToAllowList(alice, targetToken.nestingAccount());
// Try to create a token to be nested and nest
const newToken = await collection.mintToken(alice);
@@ -488,11 +488,11 @@
await collection.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}});
await collection.addToAllowList(alice, {Substrate: bob.address});
- await collection.addToAllowList(alice, targetToken.nestingAddress());
+ await collection.addToAllowList(alice, targetToken.nestingAccount());
const collectionB = await helper.nft.mintCollection(alice, {permissions: {access: 'AllowList', mintMode: true}});
await collectionB.addToAllowList(alice, {Substrate: bob.address});
- await collectionB.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionB.addToAllowList(alice, targetToken.nestingAccount());
// Try to create a token to be nested and nest
const newToken = await collectionB.mintToken(alice);
@@ -508,10 +508,10 @@
const targetToken = await collection.mintToken(alice, {Substrate: bob.address});
await collection.addToAllowList(alice, {Substrate: bob.address});
- await collection.addToAllowList(alice, targetToken.nestingAddress());
+ await collection.addToAllowList(alice, targetToken.nestingAccount());
// Try to mint in own collection after allowlisting the accounts
- await expect(collection.mintToken(bob, targetToken.nestingAddress()))
+ await expect(collection.mintToken(bob, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
});
@@ -523,12 +523,12 @@
const targetToken = await collectionNFT.mintToken(alice);
// Try to create an immediately nested token
- await expect(collectionFT.mint(alice, 5n, targetToken.nestingAddress()))
+ await expect(collectionFT.mint(alice, 5n, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create a token to be nested and nest
await collectionFT.mint(alice, 5n);
- await expect(collectionFT.transfer(alice, targetToken.nestingAddress(), 2n))
+ await expect(collectionFT.transfer(alice, targetToken.nestingAccount(), 2n))
.to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
expect(await collectionFT.getBalance({Substrate: alice.address})).to.be.equal(5n);
});
@@ -539,12 +539,12 @@
const targetToken = await collectionNFT.mintToken(alice, {Substrate: bob.address});
// Nest some tokens as Alice into Bob's token
- await collectionFT.mint(alice, 5n, targetToken.nestingAddress());
+ await collectionFT.mint(alice, 5n, targetToken.nestingAccount());
// Try to pull it out
- await expect(collectionFT.transferFrom(alice, targetToken.nestingAddress(), {Substrate: bob.address}, 1n))
+ await expect(collectionFT.transferFrom(alice, targetToken.nestingAccount(), {Substrate: bob.address}, 1n))
.to.be.rejectedWith(/common\.ApprovedValueTooLow/);
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(5n);
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
});
itSub('Fungible: disallows a non-Owner to unnest someone else\'s token (Restricted nesting)', async ({helper}) => {
@@ -555,12 +555,12 @@
await collectionNFT.setPermissions(alice, {nesting: {collectionAdmin: true, tokenOwner: true, restricted: [collectionFT.collectionId]}});
// Nest some tokens as Alice into Bob's token
- await collectionFT.mint(alice, 5n, targetToken.nestingAddress());
+ await collectionFT.mint(alice, 5n, targetToken.nestingAccount());
// Try to pull it out as Alice still
- await expect(collectionFT.transferFrom(alice, targetToken.nestingAddress(), {Substrate: bob.address}, 1n))
+ await expect(collectionFT.transferFrom(alice, targetToken.nestingAccount(), {Substrate: bob.address}, 1n))
.to.be.rejectedWith(/common\.ApprovedValueTooLow/);
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(5n);
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(5n);
});
itSub('Fungible: disallows to nest token in an unlisted collection', async ({helper}) => {
@@ -569,15 +569,15 @@
const targetToken = await collectionNFT.mintToken(alice);
// Try to mint an immediately nested token
- await expect(collectionFT.mint(alice, 5n, targetToken.nestingAddress()))
+ await expect(collectionFT.mint(alice, 5n, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
// Mint a token and try to nest it
await collectionFT.mint(alice, 5n);
- await expect(collectionFT.transfer(alice, targetToken.nestingAddress(), 1n))
+ await expect(collectionFT.transfer(alice, targetToken.nestingAccount(), 1n))
.to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(0n);
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
expect(await collectionFT.getBalance({Substrate: alice.address})).to.be.equal(5n);
});
@@ -589,12 +589,12 @@
const targetToken = await collectionNFT.mintToken(alice);
// Try to create an immediately nested token
- await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAddress()))
+ await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
// Try to create a token to be nested and nest
const token = await collectionRFT.mintToken(alice, 5n);
- await expect(token.transfer(alice, targetToken.nestingAddress(), 2n))
+ await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
.to.be.rejectedWith(/common\.UserIsNotAllowedToNest/);
expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
});
@@ -606,22 +606,22 @@
await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true}});
await collectionNFT.addToAllowList(alice, {Substrate: bob.address});
- await collectionNFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
// Try to create a token to be nested and nest
const newToken = await collectionRFT.mintToken(alice);
- await expect(newToken.transfer(bob, targetToken.nestingAddress())).to.be.rejectedWith(/common\.TokenValueTooLow/);
+ await expect(newToken.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.TokenValueTooLow/);
expect(await targetToken.getChildren()).to.be.length(0);
expect(await newToken.getBalance({Substrate: alice.address})).to.be.equal(1n);
// Nest some tokens as Alice into Bob's token
- await newToken.transfer(alice, targetToken.nestingAddress());
+ await newToken.transfer(alice, targetToken.nestingAccount());
// Try to pull it out
- await expect(newToken.transferFrom(bob, targetToken.nestingAddress(), {Substrate: alice.address}, 1n))
+ await expect(newToken.transferFrom(bob, targetToken.nestingAccount(), {Substrate: alice.address}, 1n))
.to.be.rejectedWith(/common\.ApprovedValueTooLow/);
- expect(await newToken.getBalance(targetToken.nestingAddress())).to.be.equal(1n);
+ expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
});
itSub.ifWithPallets('ReFungible: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', [Pallets.ReFungible], async ({helper}) => {
@@ -631,22 +631,22 @@
await collectionNFT.setPermissions(alice, {access: 'AllowList', mintMode: true, nesting: {tokenOwner: true, restricted: [collectionRFT.collectionId]}});
await collectionNFT.addToAllowList(alice, {Substrate: bob.address});
- await collectionNFT.addToAllowList(alice, targetToken.nestingAddress());
+ await collectionNFT.addToAllowList(alice, targetToken.nestingAccount());
// Try to create a token to be nested and nest
const newToken = await collectionRFT.mintToken(alice);
- await expect(newToken.transfer(bob, targetToken.nestingAddress())).to.be.rejectedWith(/common\.TokenValueTooLow/);
+ await expect(newToken.transfer(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.TokenValueTooLow/);
expect(await targetToken.getChildren()).to.be.length(0);
expect(await newToken.getBalance({Substrate: alice.address})).to.be.equal(1n);
// Nest some tokens as Alice into Bob's token
- await newToken.transfer(alice, targetToken.nestingAddress());
+ await newToken.transfer(alice, targetToken.nestingAccount());
// Try to pull it out
- await expect(newToken.transferFrom(bob, targetToken.nestingAddress(), {Substrate: alice.address}, 1n))
+ await expect(newToken.transferFrom(bob, targetToken.nestingAccount(), {Substrate: alice.address}, 1n))
.to.be.rejectedWith(/common\.ApprovedValueTooLow/);
- expect(await newToken.getBalance(targetToken.nestingAddress())).to.be.equal(1n);
+ expect(await newToken.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
});
itSub.ifWithPallets('ReFungible: disallows to nest token to an unlisted collection', [Pallets.ReFungible], async ({helper}) => {
@@ -655,12 +655,12 @@
const targetToken = await collectionNFT.mintToken(alice);
// Try to create an immediately nested token
- await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAddress()))
+ await expect(collectionRFT.mintToken(alice, 5n, targetToken.nestingAccount()))
.to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
// Try to create a token to be nested and nest
const token = await collectionRFT.mintToken(alice, 5n);
- await expect(token.transfer(alice, targetToken.nestingAddress(), 2n))
+ await expect(token.transfer(alice, targetToken.nestingAccount(), 2n))
.to.be.rejectedWith(/common\.SourceCollectionIsNotAllowedToNest/);
expect(await token.getBalance({Substrate: alice.address})).to.be.equal(5n);
});
tests/src/nesting/properties.test.tsdiffbeforeafterboth651 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});651 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});652 const collectionB = await helper.nft.mintCollection(alice);652 const collectionB = await helper.nft.mintCollection(alice);653 const targetToken = await collectionA.mintToken(alice);653 const targetToken = await collectionA.mintToken(alice);654 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAddress());654 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());655655656 await collectionB.addAdmin(alice, {Substrate: bob.address});656 await collectionB.addAdmin(alice, {Substrate: bob.address});657 await targetToken.transfer(alice, {Substrate: charlie.address});657 await targetToken.transfer(alice, {Substrate: charlie.address});692 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});692 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});693 const collectionB = await helper.nft.mintCollection(alice);693 const collectionB = await helper.nft.mintCollection(alice);694 const targetToken = await collectionA.mintToken(alice);694 const targetToken = await collectionA.mintToken(alice);695 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAddress());695 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());696696697 await collectionB.addAdmin(alice, {Substrate: bob.address});697 await collectionB.addAdmin(alice, {Substrate: bob.address});698 await targetToken.transfer(alice, {Substrate: charlie.address});698 await targetToken.transfer(alice, {Substrate: charlie.address});739 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});739 const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});740 const collectionB = await helper.nft.mintCollection(alice);740 const collectionB = await helper.nft.mintCollection(alice);741 const targetToken = await collectionA.mintToken(alice);741 const targetToken = await collectionA.mintToken(alice);742 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAddress());742 const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());743743744 await collectionB.addAdmin(alice, {Substrate: bob.address});744 await collectionB.addAdmin(alice, {Substrate: bob.address});745 await targetToken.transfer(alice, {Substrate: charlie.address});745 await targetToken.transfer(alice, {Substrate: charlie.address});tests/src/nesting/unnest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/unnest.test.ts
+++ b/tests/src/nesting/unnest.test.ts
@@ -32,15 +32,15 @@
const targetToken = await collection.mintToken(alice);
// Create a nested token
- const nestedToken = await collection.mintToken(alice, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(alice, targetToken.nestingAccount());
// Unnest
- await expect(nestedToken.transferFrom(alice, targetToken.nestingAddress(), {Substrate: alice.address}), 'while unnesting').to.be.fulfilled;
+ await expect(nestedToken.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}), 'while unnesting').to.be.fulfilled;
expect(await nestedToken.getOwner()).to.be.deep.equal({Substrate: alice.address});
// Nest and burn
await nestedToken.nest(alice, targetToken);
- await expect(nestedToken.burnFrom(alice, targetToken.nestingAddress()), 'while burning').to.be.fulfilled;
+ await expect(nestedToken.burnFrom(alice, targetToken.nestingAccount()), 'while burning').to.be.fulfilled;
await expect(nestedToken.getOwner()).to.be.rejected;
});
@@ -51,16 +51,16 @@
const collectionFT = await helper.ft.mintCollection(alice);
// Nest and unnest
- await collectionFT.mint(alice, 10n, targetToken.nestingAddress());
- await expect(collectionFT.transferFrom(alice, targetToken.nestingAddress(), {Substrate: alice.address}, 9n), 'while unnesting').to.be.fulfilled;
+ await collectionFT.mint(alice, 10n, targetToken.nestingAccount());
+ await expect(collectionFT.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 9n), 'while unnesting').to.be.fulfilled;
expect(await collectionFT.getBalance({Substrate: alice.address})).to.be.equal(9n);
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(1n);
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
// Nest and burn
- await collectionFT.transfer(alice, targetToken.nestingAddress(), 5n);
- await expect(collectionFT.burnTokensFrom(alice, targetToken.nestingAddress(), 6n), 'while burning').to.be.fulfilled;
+ await collectionFT.transfer(alice, targetToken.nestingAccount(), 5n);
+ await expect(collectionFT.burnTokensFrom(alice, targetToken.nestingAccount(), 6n), 'while burning').to.be.fulfilled;
expect(await collectionFT.getBalance({Substrate: alice.address})).to.be.equal(4n);
- expect(await collectionFT.getBalance(targetToken.nestingAddress())).to.be.equal(0n);
+ expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
expect(await targetToken.getChildren()).to.be.length(0);
});
@@ -71,16 +71,16 @@
const collectionRFT = await helper.rft.mintCollection(alice);
// Nest and unnest
- const token = await collectionRFT.mintToken(alice, 10n, targetToken.nestingAddress());
- await expect(token.transferFrom(alice, targetToken.nestingAddress(), {Substrate: alice.address}, 9n), 'while unnesting').to.be.fulfilled;
+ const token = await collectionRFT.mintToken(alice, 10n, targetToken.nestingAccount());
+ await expect(token.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 9n), 'while unnesting').to.be.fulfilled;
expect(await token.getBalance({Substrate: alice.address})).to.be.equal(9n);
- expect(await token.getBalance(targetToken.nestingAddress())).to.be.equal(1n);
+ expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(1n);
// Nest and burn
- await token.transfer(alice, targetToken.nestingAddress(), 5n);
- await expect(token.burnFrom(alice, targetToken.nestingAddress(), 6n), 'while burning').to.be.fulfilled;
+ await token.transfer(alice, targetToken.nestingAccount(), 5n);
+ await expect(token.burnFrom(alice, targetToken.nestingAccount(), 6n), 'while burning').to.be.fulfilled;
expect(await token.getBalance({Substrate: alice.address})).to.be.equal(4n);
- expect(await token.getBalance(targetToken.nestingAddress())).to.be.equal(0n);
+ expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
expect(await targetToken.getChildren()).to.be.length(0);
});
});
@@ -101,15 +101,15 @@
const targetToken = await collection.mintToken(alice);
// Create a nested token
- const nestedToken = await collection.mintToken(alice, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(alice, targetToken.nestingAccount());
// Try to unnest
await expect(nestedToken.unnest(bob, targetToken, {Substrate: alice.address})).to.be.rejectedWith(/common\.ApprovedValueTooLow/);
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
// Try to burn
- await expect(nestedToken.burnFrom(bob, targetToken.nestingAddress())).to.be.rejectedWith(/common\.ApprovedValueTooLow/);
- expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAddress());
+ await expect(nestedToken.burnFrom(bob, targetToken.nestingAccount())).to.be.rejectedWith(/common\.ApprovedValueTooLow/);
+ expect(await nestedToken.getOwner()).to.be.deep.equal(targetToken.nestingAccount());
});
// todo another test for creating excessive depth matryoshka with Ethereum?
@@ -120,7 +120,7 @@
const targetToken = await collection.mintToken(alice);
// Fail to create a nested token ouroboros
- const nestedToken = await collection.mintToken(alice, targetToken.nestingAddress());
+ const nestedToken = await collection.mintToken(alice, targetToken.nestingAccount());
await expect(targetToken.nest(alice, nestedToken)).to.be.rejectedWith(/^structure\.OuroborosDetected$/);
});
});
tests/src/util/playgrounds/types.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/types.ts
+++ b/tests/src/util/playgrounds/types.ts
@@ -109,7 +109,6 @@
export interface IToken {
collectionId: number;
tokenId: number;
- //nestingAddress: () => {Ethereum: string};
}
export interface IBlock {
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -55,11 +55,11 @@
RPC: 'rpc',
};
- static getNestingTokenAddress(token: IToken) {
- return {Ethereum: this.getNestingTokenAddressRaw(token).toLowerCase()};
+ static getTokenAccount(token: IToken) {
+ return {Ethereum: this.getTokenAddress(token).toLowerCase()};
}
- static getNestingTokenAddressRaw(token: IToken) {
+ static getTokenAddress(token: IToken) {
return nesting.tokenIdToAddress(token.collectionId, token.tokenId);
}
@@ -1370,7 +1370,7 @@
* @returns ```true``` if extrinsic success, otherwise ```false```
*/
async nestToken(signer: TSigner, tokenObj: IToken, rootTokenObj: IToken): Promise<boolean> {
- const rootTokenAddress = this.helper.util.getNestingTokenAddress(rootTokenObj);
+ const rootTokenAddress = this.helper.util.getTokenAccount(rootTokenObj);
const result = await this.transferToken(signer, tokenObj.collectionId, tokenObj.tokenId, rootTokenAddress);
if(!result) {
throw Error('Unable to nest token!');
@@ -1388,7 +1388,7 @@
* @returns ```true``` if extrinsic success, otherwise ```false```
*/
async unnestToken(signer: TSigner, tokenObj: IToken, rootTokenObj: IToken, toAddressObj: ICrossAccountId): Promise<boolean> {
- const rootTokenAddress = this.helper.util.getNestingTokenAddress(rootTokenObj);
+ const rootTokenAddress = this.helper.util.getTokenAccount(rootTokenObj);
const result = await this.transferTokenFrom(signer, tokenObj.collectionId, tokenObj.tokenId, rootTokenAddress, toAddressObj);
if(!result) {
throw Error('Unable to unnest token!');
@@ -2566,8 +2566,8 @@
return await this.collection.deleteTokenProperties(signer, this.tokenId, propertyKeys);
}
- nestingAddress() {
- return this.collection.helper.util.getNestingTokenAddress(this);
+ nestingAccount() {
+ return this.collection.helper.util.getTokenAccount(this);
}
}