1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub} from './util/playgrounds';1920describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {21 let alice: IKeyringPair;22 let bob: IKeyringPair;23 let charlie: IKeyringPair;2425 before(async () => {26 await usingPlaygrounds(async (helper, privateKey) => {27 const donor = await privateKey({filename: __filename});28 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);29 });30 });3132 itSub('admin transfers other user\'s token', async ({helper}) => {33 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});34 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});35 const limits = await helper.collection.getEffectiveLimits(collectionId);36 expect(limits.ownerCanTransfer).to.be.true;3738 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});39 const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});40 await expect(transferResult()).to.be.rejected;4142 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});43 const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);44 expect(newTokenOwner.Substrate).to.be.equal(charlie.address);45 });4647 itSub('admin burns other user\'s token', async ({helper}) => {48 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});4950 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});51 const limits = await helper.collection.getEffectiveLimits(collectionId);52 expect(limits.ownerCanTransfer).to.be.true;5354 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});55 const burnTxFailed = async () => helper.nft.burnToken(alice, collectionId, tokenId);5657 await expect(burnTxFailed()).to.be.rejected;5859 await helper.nft.burnToken(bob, collectionId, tokenId);60 const token = await helper.nft.getToken(collectionId, tokenId);61 expect(token).to.be.null;62 });63});