--- a/tests/src/nesting/nest.test.ts +++ b/tests/src/nesting/nest.test.ts @@ -10,7 +10,7 @@ enablePublicMintingExpectSuccess, getTokenOwner, getTopmostTokenOwner, - setCollectionPermissionsExceptSuccess, + setCollectionPermissionsExpectSuccess, transferExpectFailure, transferExpectSuccess, transferFromExpectSuccess, @@ -31,7 +31,7 @@ it('Performs the full suite: bundles a token, transfers, and allows to unnest', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); // Create a nested token @@ -63,7 +63,7 @@ it('NFT: allows an Owner to nest/unnest their token', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); // Create a nested token @@ -82,7 +82,7 @@ it('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); // Create a nested token @@ -103,7 +103,7 @@ it('Fungible: allows an Owner to nest/unnest their token', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address}); const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)}; @@ -130,7 +130,7 @@ const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted: [collectionFT]}}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted: [collectionFT]}}); // Create a nested token await expect(executeTransaction(api, alice, api.tx.unique.createItem( @@ -150,7 +150,7 @@ it('ReFungible: allows an Owner to nest/unnest their token', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address}); const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)}; @@ -177,7 +177,7 @@ const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}}); // Create a nested token await expect(executeTransaction(api, alice, api.tx.unique.createItem( @@ -204,7 +204,7 @@ it('Disallows excessive token nesting', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); const maxNestingLevel = 5; @@ -238,7 +238,7 @@ it('NFT: disallows to nest token if nesting is disabled', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Disabled'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Disabled'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); // Try to create a nested token @@ -260,7 +260,7 @@ it('NFT: disallows a non-Owner to nest someone else\'s token', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); await addToAllowListExpectSuccess(alice, collection, bob.address); await enableAllowListExpectSuccess(alice, collection); @@ -286,7 +286,7 @@ it('NFT: disallows a non-Owner to nest someone else\'s token (Restricted nesting)', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {OwnerRestricted:[collection]}}); await addToAllowListExpectSuccess(alice, collection, bob.address); await enableAllowListExpectSuccess(alice, collection); @@ -312,7 +312,7 @@ it('NFT: disallows to nest token in an unlisted collection', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: {OwnerRestricted:[]}}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: {OwnerRestricted:[]}}); // Create a token to attempt to be nested into const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); @@ -336,7 +336,7 @@ it('Fungible: disallows to nest token if nesting is disabled', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Disabled'}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Disabled'}); const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT'); const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)}; @@ -364,7 +364,7 @@ it('Fungible: disallows a non-Owner to nest someone else\'s token', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'}); await addToAllowListExpectSuccess(alice, collectionNFT, bob.address); await enableAllowListExpectSuccess(alice, collectionNFT); @@ -401,7 +401,7 @@ const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)}; const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionFT]}}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionFT]}}); // Try to create a nested token in the wrong collection await expect(executeTransaction(api, alice, api.tx.unique.createItem( @@ -419,7 +419,7 @@ it('Fungible: disallows to nest token in an unlisted collection', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}}); // Create a token to attempt to be nested into const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT'); @@ -445,7 +445,7 @@ it('ReFungible: disallows to nest token if nesting is disabled', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Disabled'}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Disabled'}); const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT'); const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)}; @@ -475,7 +475,7 @@ it('ReFungible: disallows a non-Owner to nest someone else\'s token', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: 'Owner'}); await addToAllowListExpectSuccess(alice, collectionNFT, bob.address); await enableAllowListExpectSuccess(alice, collectionNFT); @@ -512,7 +512,7 @@ const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)}; const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[collectionRFT]}}); // Try to create a nested token in the wrong collection await expect(executeTransaction(api, alice, api.tx.unique.createItem( @@ -530,7 +530,7 @@ it('ReFungible: disallows to nest token to an unlisted collection', async () => { await usingApi(async api => { const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}}); + await setCollectionPermissionsExpectSuccess(alice, collectionNFT, {nesting: {OwnerRestricted:[]}}); // Create a token to attempt to be nested into const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT'); --- a/tests/src/nesting/unnest.test.ts +++ b/tests/src/nesting/unnest.test.ts @@ -8,7 +8,7 @@ getBalance, getTokenOwner, normalizeAccountId, - setCollectionPermissionsExceptSuccess, + setCollectionPermissionsExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, } from '../util/helpers'; @@ -28,7 +28,7 @@ it('NFT: allows the owner to successfully unnest a token', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)}; @@ -57,7 +57,7 @@ it('Fungible: allows the owner to successfully unnest a token', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)}; @@ -84,7 +84,7 @@ it('ReFungible: allows the owner to successfully unnest a token', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)}; @@ -119,7 +119,7 @@ it('Disallows a non-owner to unnest/burn a token', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); const targetAddress = {Ethereum: tokenIdToAddress(collection, targetToken)}; @@ -149,7 +149,7 @@ // Recursive nesting it('Prevents Ouroboros creation', async () => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await setCollectionPermissionsExceptSuccess(alice, collection, {nesting: 'Owner'}); + await setCollectionPermissionsExpectSuccess(alice, collection, {nesting: 'Owner'}); const targetToken = await createItemExpectSuccess(alice, collection, 'NFT'); // Create a nested token ouroboros --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -554,7 +554,7 @@ }); } -export const setCollectionPermissionsExceptSuccess = async (sender: IKeyringPair, collectionId: number, permissions: {mintMode?: boolean, access?: 'Normal' | 'AllowList', nesting?: 'Disabled' | 'Owner' | {OwnerRestricted: number[]}}) => { +export const setCollectionPermissionsExpectSuccess = async (sender: IKeyringPair, collectionId: number, permissions: {mintMode?: boolean, access?: 'Normal' | 'AllowList', nesting?: 'Disabled' | 'Owner' | {OwnerRestricted: number[]}}) => { await usingApi(async(api) => { const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions); const events = await submitTransactionAsync(sender, tx); @@ -1298,7 +1298,7 @@ await usingApi(async (api) => { // Run the transaction - const tx = api.tx.unique.setPublicAccessMode(collectionId, accessMode); + const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode}); const events = await submitTransactionAsync(sender, tx); const result = getGenericResult(events); @@ -1319,7 +1319,7 @@ await usingApi(async (api) => { // Run the transaction - const tx = api.tx.unique.setPublicAccessMode(collectionId, accessMode); + const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode}); const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected; const result = getGenericResult(events); @@ -1345,7 +1345,7 @@ await usingApi(async (api) => { // Run the transaction - const tx = api.tx.unique.setMintPermission(collectionId, enabled); + const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled}); const events = await submitTransactionAsync(sender, tx); const result = getGenericResult(events); expect(result.success).to.be.true;