1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util';19import {ICollectionCreationOptions} from './util/playgrounds/types';2021describe('Native fungible', () => {22 let alice: IKeyringPair;23 let bob: IKeyringPair;2425 before(async () => {26 await usingPlaygrounds(async (helper, privateKey) => {27 const donor = await privateKey({url: import.meta.url});28 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);29 });30 });3132 itSub('destroy_collection()', async ({helper}) => {33 const collection = helper.ft.getCollectionObject(0);34 await expect(collection.burn(alice)).to.be.rejectedWith('common.UnsupportedOperation');35 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.destroyCollection', [0])).to.be.rejectedWith('common.UnsupportedOperation');36 });3738 itSub('add_to_allow_list()', async ({helper}) => {39 const collection = helper.ft.getCollectionObject(0);40 await expect(collection.addToAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');41 });4243 itSub('remove_from_allow_list()', async ({helper}) => {44 const collection = helper.ft.getCollectionObject(0);45 await expect(collection.removeFromAllowList(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');46 });4748 itSub('change_collection_owner()', async ({helper}) => {49 const collection = helper.ft.getCollectionObject(0);50 await expect(collection.changeOwner(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');51 });5253 itSub('add_collection_admin()', async ({helper}) => {54 const collection = helper.ft.getCollectionObject(0);55 await expect(collection.addAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');56 });5758 itSub('remove_collection_admin()', async ({helper}) => {59 const collection = helper.ft.getCollectionObject(0);60 await expect(collection.removeAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');61 });6263 itSub('set_collection_sponsor()', async ({helper}) => {64 const collection = helper.ft.getCollectionObject(0);65 await expect(collection.setSponsor(alice, bob.address)).to.be.rejectedWith('common.UnsupportedOperation');66 });6768 itSub('confirm_sponsorship()', async ({helper}) => {69 const collection = helper.ft.getCollectionObject(0);70 await expect(collection.confirmSponsorship(alice)).to.be.rejectedWith('common.UnsupportedOperation');71 });7273 itSub('remove_collection_sponsor()', async ({helper}) => {74 const collection = helper.ft.getCollectionObject(0);75 await expect(collection.removeSponsor(alice)).to.be.rejectedWith('common.UnsupportedOperation');76 });7778 itSub('create_item()', async ({helper}) => {79 const collection = helper.ft.getCollectionObject(0);80 await expect(collection.mint(alice, 100n, {Substrate: bob.address})).to.be.rejectedWith('common.UnsupportedOperation');81 });8283 itSub('set_collection_properties()', async ({helper}) => {84 const collection = helper.ft.getCollectionObject(0);85 await expect(collection.setProperties(alice, [{key: 'value'}])).to.be.rejectedWith('common.UnsupportedOperation');86 });8788 itSub('delete_collection_properties()', async ({helper}) => {89 const collection = helper.ft.getCollectionObject(0);90 await expect(collection.deleteProperties(alice, ['key'])).to.be.rejectedWith('common.UnsupportedOperation');91 });9293 itSub('set_token_properties()', async ({helper}) => {94 await expect(helper.executeExtrinsic(95 alice,96 'api.tx.unique.setTokenProperties',97 [0, 0, [{key: 'value'}]],98 true,99 )).to.be.rejectedWith('common.UnsupportedOperation');100 });101102 itSub('delete_token_properties()', async ({helper}) => {103 await expect(helper.executeExtrinsic(104 alice,105 'api.tx.unique.deleteTokenProperties',106 [0, 0, ['key']],107 true,108 )).to.be.rejectedWith('common.UnsupportedOperation');109 });110111 itSub('set_transfers_enabled_flag()', async ({helper}) => {112 await expect(helper.executeExtrinsic(113 alice,114 'api.tx.unique.setTransfersEnabledFlag',115 [0, true],116 true,117 )).to.be.rejectedWith('common.UnsupportedOperation');118 });119120 itSub('burn_item()', async ({helper}) => {121 await expect(helper.executeExtrinsic(122 alice,123 'api.tx.unique.burnItem',124 [0, 0, 100n],125 true,126 )).to.be.rejectedWith('common.UnsupportedOperation');127 });128129 itSub('burn_from()', async ({helper}) => {130 const collection = helper.ft.getCollectionObject(0);131 await expect(collection.burnTokens(alice, 100n)).to.be.rejectedWith('common.UnsupportedOperation');132 });133134 itSub('transfer()', async ({helper}) => {135 const collection = helper.ft.getCollectionObject(0);136 const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);137 const balanceBobBefore = await helper.balance.getSubstrate(bob.address);138 await collection.transfer(alice, {Substrate: bob.address}, 100n);139 const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);140 const balanceBobAfter = await helper.balance.getSubstrate(bob.address);141 expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;142 expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;143 });144145 itSub('transfer_from()', async ({helper}) => {146 const collection = helper.ft.getCollectionObject(0);147 const balanceAliceBefore = await helper.balance.getSubstrate(alice.address);148 const balanceBobBefore = await helper.balance.getSubstrate(bob.address);149150 await collection.transferFrom(alice, {Substrate: alice.address}, {Substrate: bob.address}, 100n);151152 const balanceAliceAfter = await helper.balance.getSubstrate(alice.address);153 const balanceBobAfter = await helper.balance.getSubstrate(bob.address);154 expect(balanceAliceBefore - balanceAliceAfter > 100n).to.be.true;155 expect(balanceBobAfter - balanceBobBefore === 100n).to.be.true;156157 await expect(collection.transferFrom(alice, {Substrate: bob.address}, {Substrate: alice.address}, 100n)).to.be.rejectedWith('common.NoPermission');158 });159160 itSub('approve()', async ({helper}) => {161 const collection = helper.ft.getCollectionObject(0);162 await expect(collection.approveTokens(alice, {Substrate: bob.address}, 100n)).to.be.rejectedWith('common.UnsupportedOperation');163 });164165 itSub('approve_from()', async ({helper}) => {166 await expect(helper.executeExtrinsic(167 alice,168 'api.tx.unique.approveFrom',169 [{Substrate: alice.address}, {Substrate: bob.address}, 0, 0, 100n],170 true,171 )).to.be.rejectedWith('common.UnsupportedOperation');172 });173174 itSub('set_collection_limits()', async ({helper}) => {175 const collection = helper.ft.getCollectionObject(0);176 await expect(collection.setLimits(alice, {accountTokenOwnershipLimit: 1})).to.be.rejectedWith('common.UnsupportedOperation');177 });178179 itSub('set_collection_permissions()', async ({helper}) => {180 const collection = helper.ft.getCollectionObject(0);181 await expect(collection.setPermissions(alice, {access: 'AllowList'})).to.be.rejectedWith('common.UnsupportedOperation');182 });183184 itSub('repartition()', async ({helper}) => {185 await expect(helper.executeExtrinsic(186 alice,187 'api.tx.unique.repartition',188 [0, 0, 100n],189 true,190 )).to.be.rejectedWith('unique.RepartitionCalledOnNonRefungibleCollection');191 });192193 itSub('force_repair_collection()', async ({helper}) => {194 await expect(helper.executeExtrinsic(195 alice,196 'api.tx.unique.forceRepairCollection',197 [0],198 true,199 )).to.be.rejectedWith('common.UnsupportedOperation');200 });201202 itSub('force_repair_item()', async ({helper}) => {203 await expect(helper.executeExtrinsic(204 alice,205 'api.tx.unique.forceRepairItem',206 [0, 0],207 true,208 )).to.be.rejectedWith('BadOrigin');209 });210});