git.delta.rocks / unique-network / refs/commits / af2ec6bdf5db

difftreelog

source

js-packages/tests/adminTransferAndBurn.test.ts2.9 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import type {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub} from '@unique/test-utils/util.js';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({url: import.meta.url});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    await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address})).to.be.rejected;4041    await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});42    const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);43    expect(newTokenOwner).to.be.deep.equal({Substrate: charlie.address});44  });4546  itSub('admin burns other user\'s token', async ({helper}) => {47    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});4849    await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});50    const limits = await helper.collection.getEffectiveLimits(collectionId);51    expect(limits.ownerCanTransfer).to.be.true;5253    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});5455    await expect(helper.nft.burnToken(alice, collectionId, tokenId)).to.be.rejected;5657    await helper.nft.burnToken(bob, collectionId, tokenId);58    const token = await helper.nft.getToken(collectionId, tokenId);59    expect(token).to.be.null;60  });61});