1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';20import {usingPlaygrounds} from './util/playgrounds';2122chai.use(chaiAsPromised);23const expect = chai.expect;2425let donor: IKeyringPair;2627before(async () => {28 await usingPlaygrounds(async (_, privateKey) => {29 donor = privateKey('//Alice');30 });31});3233describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {34 let alice: IKeyringPair;35 let bob: IKeyringPair;36 let charlie: IKeyringPair;3738 before(async () => {39 await usingPlaygrounds(async (helper) => {40 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);41 });42 });4344 it('admin transfers other user\'s token', async () => {45 await usingPlaygrounds(async (helper) => {46 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});47 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});48 const limits = await helper.collection.getEffectiveLimits(collectionId);49 expect(limits.ownerCanTransfer).to.be.true;5051 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});52 const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});53 await expect(transferResult()).to.be.rejected;5455 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});56 const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);57 expect(newTokenOwner.Substrate).to.be.equal(charlie.address);58 });59 });6061 it('admin burns other user\'s token', async () => {62 await usingPlaygrounds(async (helper) => {63 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});6465 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});66 const limits = await helper.collection.getEffectiveLimits(collectionId);67 expect(limits.ownerCanTransfer).to.be.true;6869 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});70 const burnTxFailed = async () => helper.nft.burnToken(alice, collectionId, tokenId);7172 await expect(burnTxFailed()).to.be.rejected;7374 await helper.nft.burnToken(bob, collectionId, tokenId);75 const token = await helper.nft.getToken(collectionId, tokenId);76 expect(token).to.be.null;77 });78 });79});