1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, usingPlaygrounds} from './util';1920describe('Native fungible', () => {21 let alice: IKeyringPair;22 let bob: IKeyringPair;2324 before(async () => {25 await usingPlaygrounds(async (helper, privateKey) => {26 const donor = await privateKey({url: import.meta.url});27 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);28 });29 });3031 itSub('destroy_collection()', async ({helper}) => {32 const collection = helper.ft.getCollectionObject(0);33 await expect(collection.burn(alice)).to.be.rejectedWith('common.UnsupportedOperation');34 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.destroyCollection', [0])).to.be.rejectedWith('common.UnsupportedOperation');35 });3637 itSub('add_to_allow_list()', async ({helper}) => {38 const collection = helper.ft.getCollectionObject(0);39 await expect(collection.addToAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');40 });4142 itSub('remove_from_allow_list()', async ({helper}) => {43 const collection = helper.ft.getCollectionObject(0);44 await expect(collection.removeFromAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');45 });4647 itSub('change_collection_owner()', async ({helper}) => {48 const collection = helper.ft.getCollectionObject(0);49 await expect(collection.changeOwner(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');50 });5152 itSub('add_collection_admin()', async ({helper}) => {53 const collection = helper.ft.getCollectionObject(0);54 await expect(collection.addAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');55 });5657 itSub('remove_collection_admin()', async ({helper}) => {58 const collection = helper.ft.getCollectionObject(0);59 await expect(collection.removeAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');60 });6162 itSub('set_collection_sponsor()', async ({helper}) => {63 const collection = helper.ft.getCollectionObject(0);64 await expect(collection.setSponsor(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');65 });6667 itSub('confirm_sponsorship()', async ({helper}) => {68 const collection = helper.ft.getCollectionObject(0);69 await expect(collection.confirmSponsorship(alice)).to.be.rejectedWith('common.UnsupportedOperation');70 });7172 itSub('remove_collection_sponsor()', async ({helper}) => {73 const collection = helper.ft.getCollectionObject(0);74 await expect(collection.removeSponsor(alice)).to.be.rejectedWith('common.UnsupportedOperation');75 });7677 itSub('create_item()', async ({helper}) => {78 const collection = helper.ft.getCollectionObject(0);79 await expect(collection.mint(alice, 100n, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');80 });8182 itSub('set_collection_properties()', async ({helper}) => {83 const collection = helper.ft.getCollectionObject(0);84 await expect(collection.setProperties(alice, [{key: 'value'}])).to.be.rejectedWith('common.UnsupportedOperation');85 });8687 itSub('delete_collection_properties()', async ({helper}) => {88 const collection = helper.ft.getCollectionObject(0);89 await expect(collection.deleteProperties(alice, ['key'])).to.be.rejectedWith('common.UnsupportedOperation');90 });9192 itSub('set_token_properties()', async ({helper}) => {93 await expect(helper.executeExtrinsic(94 alice,95 'api.tx.unique.setTokenProperties',96 [0, 0, [{key: 'value'}]],97 true,98 )).to.be.rejectedWith('common.UnsupportedOperation');99 });100101 itSub('delete_token_properties()', async ({helper}) => {102 await expect(helper.executeExtrinsic(103 alice,104 'api.tx.unique.deleteTokenProperties',105 [0, 0, ['key']],106 true,107 )).to.be.rejectedWith('common.UnsupportedOperation');108 });109110 itSub('set_transfers_enabled_flag()', async ({helper}) => {111 await expect(helper.executeExtrinsic(112 alice,113 'api.tx.unique.setTransfersEnabledFlag',114 [0, true],115 true,116 )).to.be.rejectedWith('common.UnsupportedOperation');117 });118119 itSub('burn_item()', async ({helper}) => {120 await expect(helper.executeExtrinsic(121 alice,122 'api.tx.unique.burnItem',123 [0, 0, 100n],124 true,125 )).to.be.rejectedWith('common.UnsupportedOperation');126 });127128 itSub('burn_from()', async ({helper}) => {129 const collection = helper.ft.getCollectionObject(0);130 await expect(collection.burnTokens(alice, 100n)).to.be.rejectedWith('common.UnsupportedOperation');131 });132133 itSub('transfer()', async ({helper}) => {134 const collection = helper.ft.getCollectionObject(0);135 const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);136 const balanceBobBefore = await helper.balance.getSubstrate(bob.address);137 await collection.transfer(alice, {Substrate: bob.address}, 100n);138 const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);139 const balanceBobAfter = await helper.balance.getSubstrate(bob.address);140 expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;141 expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;142 });143144 itSub('transfer_from()', async ({helper}) => {145 const collection = helper.ft.getCollectionObject(0);146 const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);147 const balanceBobBefore = await helper.balance.getSubstrate(bob.address);148149 await collection.transferFrom(alice, {Substrate: alice.address}, {Substrate: bob.address}, 100n);150151 const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);152 const balanceBobAfter = await helper.balance.getSubstrate(bob.address);153 expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;154 expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;155156 await expect(collection.transferFrom(alice, {Substrate: bob.address}, {Substrate: alice.address}, 100n)).to.be.rejectedWith('common.ApprovedValueTooLow');157 });158159 itSub('approve()', async ({helper}) => {160 const collection = helper.ft.getCollectionObject(0);161 await expect(collection.approveTokens(alice, {Substrate: bob.address}, 100n)).to.be.rejectedWith('common.UnsupportedOperation');162 });163164 itSub('approve_from()', async ({helper}) => {165 await expect(helper.executeExtrinsic(166 alice,167 'api.tx.unique.approveFrom',168 [{Substrate: alice.address}, {Substrate: bob.address}, 0, 0, 100n],169 true,170 )).to.be.rejectedWith('common.UnsupportedOperation');171 });172173 itSub('set_collection_limits()', async ({helper}) => {174 const collection = helper.ft.getCollectionObject(0);175 await expect(collection.setLimits(alice, {accountTokenOwnershipLimit: 1})).to.be.rejectedWith('common.UnsupportedOperation');176 });177178 itSub('set_collection_permissions()', async ({helper}) => {179 const collection = helper.ft.getCollectionObject(0);180 await expect(collection.setPermissions(alice, {access: 'AllowList'})).to.be.rejectedWith('common.UnsupportedOperation');181 });182183 itSub('repartition()', async ({helper}) => {184 await expect(helper.executeExtrinsic(185 alice,186 'api.tx.unique.repartition',187 [0, 0, 100n],188 true,189 )).to.be.rejectedWith('unique.RepartitionCalledOnNonRefungibleCollection');190 });191192 itSub('force_repair_collection()', async ({helper}) => {193 await expect(helper.executeExtrinsic(194 alice,195 'api.tx.unique.forceRepairCollection',196 [0],197 true,198 )).to.be.rejectedWith('common.UnsupportedOperation');199 });200201 itSub('force_repair_item()', async ({helper}) => {202 await expect(helper.executeExtrinsic(203 alice,204 'api.tx.unique.forceRepairItem',205 [0, 0],206 true,207 )).to.be.rejectedWith('BadOrigin');208 });209210 itSub.only('Nest into NFT token()', async ({helper}) => {211 const nftCollection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});212 const targetToken = await nftCollection.mintToken(alice);213214 const collection = helper.ft.getCollectionObject(0);215 await collection.transfer(alice, targetToken.nestingAccount(), 100n);216217 await collection.transferFrom(alice, targetToken.nestingAccount(), {Substrate: alice.address}, 100n);218 });219});