difftreelog
unique-playgrounds to tests fungible, refungible and removeCollectionAdmin tests rewrited for example
in: master
5 files changed
tests/src/fungible.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {default as usingApi} from './substrate/substrate-api';18import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';19import {18import { U128_MAX } from './util/helpers';20 getBalance,21 createMultipleItemsExpectSuccess,22 isTokenExists,23 getLastTokenId,24 getAllowance,25 approve,26 transferFrom,27 createCollection,28 transfer,29 burnItem,30 normalizeAccountId,31 CrossAccountId,32 createFungibleItemExpectSuccess,33 U128_MAX,34 burnFromExpectSuccess,35} from './util/helpers';361920import { usingPlaygrounds } from './util/playgrounds';2137import chai from 'chai';22import chai from 'chai';38import chaiAsPromised from 'chai-as-promised';23import chaiAsPromised from 'chai-as-promised';39chai.use(chaiAsPromised);24chai.use(chaiAsPromised);442945describe('integration test: Fungible functionality:', () => {30describe('integration test: Fungible functionality:', () => {46 before(async () => {31 before(async () => {47 await usingApi(async (api, privateKeyWrapper) => {32 await usingPlaygrounds(async (helper, privateKey) => {48 alice = privateKeyWrapper('//Alice');33 alice = privateKey('//Alice');49 bob = privateKeyWrapper('//Bob');34 bob = privateKey('//Bob');50 });35 });51 });36 });523753 it('Create fungible collection and token', async () => {38 it('Create fungible collection and token', async () => {54 await usingApi(async api => {39 await usingPlaygrounds(async helper => {55 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});40 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'trest'});56 expect(createCollectionResult.success).to.be.true;41 const defaultTokenId = await collection.getLastTokenId();57 const collectionId = createCollectionResult.collectionId;58 const defaultTokenId = await getLastTokenId(api, collectionId);42 expect(defaultTokenId).to.be.equal(0);4359 const aliceTokenId = await createFungibleItemExpectSuccess(alice, collectionId, {Value: U128_MAX}, alice.address);44 await collection.mint(alice, {Substrate: alice.address}, U128_MAX);60 const aliceBalance = await getBalance(api, collectionId, alice, aliceTokenId); 45 const aliceBalance = await collection.getBalance({Substrate: alice.address});61 const itemCountAfter = await getLastTokenId(api, collectionId);46 const itemCountAfter = await collection.getLastTokenId();62 4763 // What to expect48 expect(itemCountAfter).to.be.equal(defaultTokenId);64 // tslint:disable-next-line:no-unused-expression65 expect(itemCountAfter).to.be.equal(defaultTokenId);66 expect(aliceBalance).to.be.equal(U128_MAX);49 expect(aliceBalance).to.be.equal(U128_MAX);67 });50 });68 });51 });69 52 70 it('RPC method tokenOnewrs for fungible collection and token', async () => {53 it('RPC method tokenOnewrs for fungible collection and token', async () => {71 await usingApi(async (api, privateKeyWrapper) => {54 await usingPlaygrounds(async (helper, privateKey) => {72 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};55 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};73 const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));56 const facelessCrowd = Array(7).fill(0).map((_, i) => ({Substrate: privateKey(`//Alice+${i}`).address}));5758 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});5960 await collection.mint(alice, {Substrate: alice.address}, U128_MAX);6162 await collection.transfer(alice, {Substrate: bob.address}, 1000n);63 await collection.transfer(alice, ethAcc, 900n);74 64 75 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});76 const collectionId = createCollectionResult.collectionId;77 const aliceTokenId = await createFungibleItemExpectSuccess(alice, collectionId, {Value: U128_MAX}, alice.address);78 79 await transfer(api, collectionId, aliceTokenId, alice, bob, 1000n);80 await transfer(api, collectionId, aliceTokenId, alice, ethAcc, 900n);81 82 for (let i = 0; i < 7; i++) {65 for (let i = 0; i < 7; i++) {83 await transfer(api, collectionId, aliceTokenId, alice, facelessCrowd[i], 1);66 await collection.transfer(alice, facelessCrowd[i], 1n);84 } 67 } 85 86 const owners = await api.rpc.unique.tokenOwners(collectionId, aliceTokenId);87 const ids = (owners.toJSON() as CrossAccountId[]).map(s => normalizeAccountId(s));88 const aliceID = normalizeAccountId(alice);89 const bobId = normalizeAccountId(bob);906869 const owners = await collection.getTop10Owners();7091 // What to expect71 // What to expect92 // tslint:disable-next-line:no-unused-expression72 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);93 expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);94 expect(owners.length == 10).to.be.true;73 expect(owners.length).to.be.equal(10);95 74 96 const eleven = privateKeyWrapper('11');75 const eleven = privateKey('//ALice+11');97 expect(await transfer(api, collectionId, aliceTokenId, alice, eleven, 10n)).to.be.true;76 expect(await collection.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;98 expect((await api.rpc.unique.tokenOwners(collectionId, aliceTokenId)).length).to.be.equal(10);77 expect((await collection.getTop10Owners()).length).to.be.equal(10);99 });78 });100 });79 });101 80 102 it('Transfer token', async () => {81 it('Transfer token', async () => {103 await usingApi(async api => {82 await usingPlaygrounds(async helper => {104 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};83 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};105 const collectionId = (await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}})).collectionId;84 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});106 const tokenId = await createFungibleItemExpectSuccess(alice, collectionId, {Value: 500n}, alice.address);85 await collection.mint(alice, {Substrate: alice.address}, 500n);10786108 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(500n);87 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(500n);109 expect(await transfer(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;88 expect(await collection.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;110 expect(await transfer(api, collectionId, tokenId, alice, ethAcc, 140n)).to.be.true;89 expect(await collection.transfer(alice, ethAcc, 140n)).to.be.true;11190112 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(300n);91 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(300n);113 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(60n);92 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(60n);114 expect(await getBalance(api, collectionId, ethAcc, tokenId)).to.be.equal(140n);93 expect(await collection.getBalance(ethAcc)).to.be.equal(140n);94115 await expect(transfer(api, collectionId, tokenId, alice, bob, 350n)).to.eventually.be.rejected;95 await expect(collection.transfer(alice, {Substrate: bob.address}, 350n)).to.eventually.be.rejected;116 });96 });117 });97 });11898119 it('Tokens multiple creation', async () => {99 it('Tokens multiple creation', async () => {120 await usingApi(async api => {100 await usingPlaygrounds(async helper => {121 const collectionId = (await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}})).collectionId;101 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});122 102123 const args = [103 await collection.mintWithOneOwner(alice, {Substrate: alice.address}, [124 {Fungible: {Value: 500n}},104 {value: 500n},125 {Fungible: {Value: 400n}},105 {value: 400n},126 {Fungible: {Value: 300n}},106 {value: 300n}127 ];107 ]);128 108129 await createMultipleItemsExpectSuccess(alice, collectionId, args);109 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(1200n);130 expect(await getBalance(api, collectionId, alice, 0)).to.be.equal(1200n);131 }); 110 });132 });111 });133112134 it('Burn some tokens ', async () => {113 it('Burn some tokens ', async () => {135 await usingApi(async api => { 114 await usingPlaygrounds(async helper => {136 const collectionId = (await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}})).collectionId;115 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});137 const tokenId = (await createFungibleItemExpectSuccess(alice, collectionId, {Value: 500n}, alice.address));116 await collection.mint(alice, {Substrate: alice.address}, 500n);117138 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;118 expect(await collection.isTokenExists(0)).to.be.true;139 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(500n);119 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(500n);140 expect(await burnItem(api, alice, collectionId, tokenId, 499n)).to.be.true;120 expect(await collection.burnTokens(alice, 499n)).to.be.true;141 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;121 expect(await collection.isTokenExists(0)).to.be.true;142 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(1n);122 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(1n);143 });123 });144 });124 });145 125 146 it('Burn all tokens ', async () => {126 it('Burn all tokens ', async () => {147 await usingApi(async api => { 127 await usingPlaygrounds(async helper => {148 const collectionId = (await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}})).collectionId;128 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});149 const tokenId = (await createFungibleItemExpectSuccess(alice, collectionId, {Value: 500n}, alice.address));129 await collection.mint(alice, {Substrate: alice.address}, 500n);130150 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;131 expect(await collection.isTokenExists(0)).to.be.true;151 expect(await burnItem(api, alice, collectionId, tokenId, 500n)).to.be.true;132 expect(await collection.burnTokens(alice, 500n)).to.be.true;152 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;133 expect(await collection.isTokenExists(0)).to.be.true;153 134154 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(0n);135 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(0n);155 expect((await api.rpc.unique.totalPieces(collectionId, tokenId)).value.toBigInt()).to.be.equal(0n);136 expect(await collection.getTotalPieces()).to.be.equal(0n);156 });137 });157 });138 });158139159 it('Set allowance for token', async () => {140 it('Set allowance for token', async () => {160 await usingApi(async api => {141 await usingPlaygrounds(async helper => {161 const collectionId = (await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}})).collectionId;142 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});162 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};143 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};144 await collection.mint(alice, {Substrate: alice.address}, 100n);145146 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(100n);163 147 164 const tokenId = (await createFungibleItemExpectSuccess(alice, collectionId, {Value: 100n}, alice.address));148 expect(await collection.approveTokens(alice, {Substrate: bob.address}, 60n)).to.be.true;149 expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(60n);165 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);150 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(0n);166151167 expect(await approve(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;152 expect(await collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: bob.address}, 20n)).to.be.true;168 expect(await getAllowance(api, collectionId, alice, bob, tokenId)).to.be.equal(60n);169 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(0n);170 171 expect(await transferFrom(api, collectionId, tokenId, bob, alice, bob, 20n)).to.be.true;172 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(80n);153 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(80n);173 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(20n);154 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(20n);174 expect(await getAllowance(api, collectionId, alice, bob, tokenId)).to.be.equal(40n);155 expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);175 156176 await burnFromExpectSuccess(bob, alice, collectionId, tokenId, 10n);157 await collection.burnTokensFrom(bob, {Substrate: alice.address}, 10n);177 158178 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(70n);159 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(70n);179 expect(await getAllowance(api, collectionId, alice, bob, tokenId)).to.be.equal(30n);160 expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(30n);180 expect(await transferFrom(api, collectionId, tokenId, bob, alice, ethAcc, 10n)).to.be.true;161 expect(await collection.transferFrom(bob, {Substrate: alice.address}, ethAcc, 10n)).to.be.true;181 expect(await getBalance(api, collectionId, ethAcc, tokenId)).to.be.equal(10n);162 expect(await collection.getBalance(ethAcc)).to.be.equal(10n);182 });163 });183 });164 });184});165});tests/src/refungible.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {default as usingApi, submitTransactionAsync} from './substrate/substrate-api';18import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';19import {20 createCollectionExpectSuccess,21 getBalance,22 createMultipleItemsExpectSuccess,23 isTokenExists,24 getLastTokenId,25 getAllowance,26 approve,27 transferFrom,28 createCollection,29 createRefungibleToken,30 transfer,31 burnItem,32 repartitionRFT,33 createCollectionWithPropsExpectSuccess,34 getDetailedCollectionInfo,35 normalizeAccountId,36 CrossAccountId,37 getCreateItemsResult,38 getDestroyItemsResult,39} from './util/helpers';401819import { usingPlaygrounds } from './util/playgrounds';2041import chai from 'chai';21import chai from 'chai';42import chaiAsPromised from 'chai-as-promised';22import chaiAsPromised from 'chai-as-promised';43chai.use(chaiAsPromised);23chai.use(chaiAsPromised);482849describe('integration test: Refungible functionality:', () => {29describe('integration test: Refungible functionality:', () => {50 before(async () => {30 before(async () => {51 await usingApi(async (api, privateKeyWrapper) => {31 await usingPlaygrounds(async (helper, privateKey) => {52 alice = privateKeyWrapper('//Alice');32 alice = privateKey('//Alice');53 bob = privateKeyWrapper('//Bob');33 bob = privateKey('//Bob');54 });34 });55 });35 });563657 it('Create refungible collection and token', async () => {37 it('Create refungible collection and token', async () => {58 await usingApi(async api => {38 await usingPlaygrounds(async helper => {59 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});39 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});4060 expect(createCollectionResult.success).to.be.true;41 const itemCountBefore = await collection.getLastTokenId();61 const collectionId = createCollectionResult.collectionId;42 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);62 43 63 const itemCountBefore = await getLastTokenId(api, collectionId);44 const itemCountAfter = await collection.getLastTokenId();64 const result = await createRefungibleToken(api, alice, collectionId, 100n);65 45 66 const itemCountAfter = await getLastTokenId(api, collectionId);67 68 // What to expect46 // What to expect69 // tslint:disable-next-line:no-unused-expression47 expect(token?.tokenId).to.be.gte(itemCountBefore);70 expect(result.success).to.be.true;71 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);48 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);72 expect(collectionId).to.be.equal(result.collectionId);49 expect(itemCountAfter.toString()).to.be.equal(token?.tokenId.toString());73 expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());74 });50 });75 });51 });76 52 77 it('RPC method tokenOnewrs for refungible collection and token', async () => {53 it('RPC method tokenOnewrs for refungible collection and token', async () => {78 await usingApi(async (api, privateKeyWrapper) => {54 await usingPlaygrounds(async (helper, privateKey) => {79 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};55 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};80 const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));56 const facelessCrowd = Array(7).fill(0).map((_, i) => ({Substrate: privateKey(`//Alice+${i}`).address}));5758 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});5960 const token = await collection.mintToken(alice, {Substrate: alice.address}, 10_000n);6162 await token.transfer(alice, {Substrate: bob.address}, 1000n);63 await token.transfer(alice, ethAcc, 900n);81 64 82 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});83 const collectionId = createCollectionResult.collectionId;84 85 const result = await createRefungibleToken(api, alice, collectionId, 10_000n);86 const aliceTokenId = result.itemId;87 88 89 await transfer(api, collectionId, aliceTokenId, alice, bob, 1000n);90 await transfer(api, collectionId, aliceTokenId, alice, ethAcc, 900n);91 92 for (let i = 0; i < 7; i++) {65 for (let i = 0; i < 7; i++) {93 await transfer(api, collectionId, aliceTokenId, alice, facelessCrowd[i], 50*(i+1));66 await token.transfer(alice, facelessCrowd[i], 50n * BigInt(i + 1));94 } 67 } 95 6896 const owners = await api.rpc.unique.tokenOwners(collectionId, aliceTokenId);69 const owners = await token.getTop10Owners();97 const ids = (owners.toJSON() as CrossAccountId[]).map(s => normalizeAccountId(s));7098 99 const aliceID = normalizeAccountId(alice);100 const bobId = normalizeAccountId(bob);101 102 // What to expect71 // What to expect103 // tslint:disable-next-line:no-unused-expression72 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);104 expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);105 expect(owners.length).to.be.equal(10);73 expect(owners.length).to.be.equal(10);106 74 107 const eleven = privateKeyWrapper('11');75 const eleven = privateKey('//ALice+11');108 expect(await transfer(api, collectionId, aliceTokenId, alice, eleven, 10n)).to.be.true;76 expect(await token.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;109 expect((await api.rpc.unique.tokenOwners(collectionId, aliceTokenId)).length).to.be.equal(10);77 expect((await token.getTop10Owners()).length).to.be.equal(10);110 });78 });111 });79 });112 80 113 it('Transfer token pieces', async () => {81 it('Transfer token pieces', async () => {114 await usingApi(async api => {82 await usingPlaygrounds(async helper => {115 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;83 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});116 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;84 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);11785118 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);86 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);119 expect(await transfer(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;87 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;12088 121 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(40n);89 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);122 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(60n);90 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);123 await expect(transfer(api, collectionId, tokenId, alice, bob, 41n)).to.eventually.be.rejected;91 92 await expect(token.transfer(alice, {Substrate: bob.address}, 41n)).to.eventually.be.rejected;124 });93 });125 });94 });12695127 it('Create multiple tokens', async () => {96 it('Create multiple tokens', async () => {128 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});97 await usingPlaygrounds(async helper => {98 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});129 const args = [99 // TODO: fix mintMultipleTokens100 // await collection.mintMultipleTokens(alice, [130 {ReFungible: {pieces: 1}},101 // {owner: {Substrate: alice.address}, pieces: 1n},131 {ReFungible: {pieces: 2}},102 // {owner: {Substrate: alice.address}, pieces: 2n},132 {ReFungible: {pieces: 100}},103 // {owner: {Substrate: alice.address}, pieces: 100n},133 ];104 // ]);134 await createMultipleItemsExpectSuccess(alice, collectionId, args);105 await helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, [135106 {pieces: 1n}, 136 await usingApi(async api => { 107 {pieces: 2n}, 108 {pieces: 100n}137 const tokenId = await getLastTokenId(api, collectionId);109 ]);110 const lastTokenId = await collection.getLastTokenId();138 expect(tokenId).to.be.equal(3);111 expect(lastTokenId).to.be.equal(3);139 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);112 expect(await collection.getTokenBalance(lastTokenId, {Substrate: alice.address})).to.be.equal(100n);140 });113 });141 });114 });142115143 it('Burn some pieces', async () => {116 it('Burn some pieces', async () => {144 await usingApi(async api => { 117 await usingPlaygrounds(async helper => {145 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;118 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});146 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;119 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);147 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;120 expect(await collection.isTokenExists(token.tokenId)).to.be.true;148 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);121 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);149 expect(await burnItem(api, alice, collectionId, tokenId, 99n)).to.be.true;122 expect((await token.burn(alice, 99n)).success).to.be.true;150 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;123 expect(await collection.isTokenExists(token.tokenId)).to.be.true;151 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(1n);124 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);152 });125 });153 });126 });154127155 it('Burn all pieces', async () => {128 it('Burn all pieces', async () => {156 await usingApi(async api => { 129 await usingPlaygrounds(async helper => { 157 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;130 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});158 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;131 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);159 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;132 133 expect(await collection.isTokenExists(token.tokenId)).to.be.true;160 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);134 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);135161 expect(await burnItem(api, alice, collectionId, tokenId, 100n)).to.be.true;136 expect((await token.burn(alice, 100n)).success).to.be.true;162 expect(await isTokenExists(api, collectionId, tokenId)).to.be.false;137 expect(await collection.isTokenExists(token.tokenId)).to.be.false;163 });138 });164 });139 });165140166 it('Burn some pieces for multiple users', async () => {141 it('Burn some pieces for multiple users', async () => {167 await usingApi(async api => { 142 await usingPlaygrounds(async helper => {168 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;143 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});169 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;144 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);170 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;171145172 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);146 expect(await collection.isTokenExists(token.tokenId)).to.be.true;173 expect(await transfer(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;174175 147 176 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(40n);148 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);177 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(60n);149 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;178 expect(await burnItem(api, alice, collectionId, tokenId, 40n)).to.be.true;179150180 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(0n);151 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);181 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;152 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);182 expect(await burnItem(api, bob, collectionId, tokenId, 59n)).to.be.true;183153184 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(1n);154 expect((await token.burn(alice, 40n)).success).to.be.true;155156 expect(await collection.isTokenExists(token.tokenId)).to.be.true;157 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);158185 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;159 expect((await token.burn(bob, 59n)).success).to.be.true;160186 expect(await burnItem(api, bob, collectionId, tokenId, 1n)).to.be.true;161 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);162 expect(await collection.isTokenExists(token.tokenId)).to.be.true;163187 164 expect((await token.burn(bob, 1n)).success).to.be.true;165188 expect(await isTokenExists(api, collectionId, tokenId)).to.be.false;166 expect(await collection.isTokenExists(token.tokenId)).to.be.false;189 });167 });190 });168 });191169192 it('Set allowance for token', async () => {170 it('Set allowance for token', async () => {193 await usingApi(async api => {171 await usingPlaygrounds(async helper => {194 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;172 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});195 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;173 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);174 175 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);196176197 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);177 expect(await token.approve(alice, {Substrate: bob.address}, 60n)).to.be.true;178 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(60n);198179199 expect(await approve(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;180 expect(await token.transferFrom(bob, {Substrate: alice.address}, {Substrate: bob.address}, 20n)).to.be.true;200 expect(await getAllowance(api, collectionId, alice, bob, tokenId)).to.be.equal(60n);201202 expect(await transferFrom(api, collectionId, tokenId, bob, alice, bob, 20n)).to.be.true;203 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(80n);181 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(80n);204 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(20n);182 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(20n);205 expect(await getAllowance(api, collectionId, alice, bob, tokenId)).to.be.equal(40n);183 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);206 });184 });207 });185 });208186209 it('Repartition', async () => {187 it('Repartition', async () => {210 await usingApi(async api => {188 await usingPlaygrounds(async helper => {211 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;189 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});212 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;190 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);213191214 expect(await repartitionRFT(api, collectionId, alice, tokenId, 200n)).to.be.true;192 expect(await token.repartition(alice, 200n)).to.be.true;193 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(200n);194 expect(await token.getTotalPieces()).to.be.equal(200n);195 196 expect(await token.transfer(alice, {Substrate: bob.address}, 110n)).to.be.true;215 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(200n);197 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(90n);198 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(110n);199 200 await expect(token.repartition(alice, 80n)).to.eventually.be.rejected;201 202 expect(await token.transfer(alice, {Substrate: bob.address}, 90n)).to.be.true;203 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);204 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(200n);216205217 expect(await transfer(api, collectionId, tokenId, alice, bob, 110n)).to.be.true;206 expect(await token.repartition(bob, 150n)).to.be.true;218 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(90n);207 await expect(token.transfer(bob, {Substrate: alice.address}, 160n)).to.eventually.be.rejected;219 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(110n);220208221 await expect(repartitionRFT(api, collectionId, alice, tokenId, 80n)).to.eventually.be.rejected;222223 expect(await transfer(api, collectionId, tokenId, alice, bob, 90n)).to.be.true;224 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(0n);225 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(200n);226227 expect(await repartitionRFT(api, collectionId, bob, tokenId, 150n)).to.be.true;228 await expect(transfer(api, collectionId, tokenId, bob, alice, 160n)).to.eventually.be.rejected;229 });209 });230 });210 });231211232 it('Repartition with increased amount', async () => {212 it('Repartition with increased amount', async () => {233 await usingApi(async api => {213 await usingPlaygrounds(async helper => {234 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;214 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});235 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;215 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);236237 const tx = api.tx.unique.repartition(collectionId, tokenId, 200n);216 await token.repartition(alice, 200n);238 const events = await submitTransactionAsync(alice, tx);217 const chainEvents = helper.chainLog.slice(-1)[0].events.map((x: any) => x.event);239 const substrateEvents = getCreateItemsResult(events);240 expect(substrateEvents).to.include.deep.members([218 expect(chainEvents).to.include.deep.members([{241 {219 method: 'ItemCreated',242 success: true,220 section: 'common',221 index: '0x4202',243 collectionId,222 data: [ 223 collection.collectionId.toString(), 244 itemId: tokenId,224 token.tokenId.toString(), 245 recipient: {Substrate: alice.address},225 {Substrate: alice.address}, 246 amount: 100,226 '100'247 },227 ]248 ]);228 }])249 });229 });250 });230 });251231252 it('Repartition with decreased amount', async () => {232 it('Repartition with decreased amount', async () => {253 await usingApi(async api => {233 await usingPlaygrounds(async helper => {254 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;234 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});255 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;235 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);256257 const tx = api.tx.unique.repartition(collectionId, tokenId, 50n);236 await token.repartition(alice, 50n);258 const events = await submitTransactionAsync(alice, tx);237 const chainEvents = helper.chainLog.slice(-1)[0].events.map((x: any) => x.event);259 const substrateEvents = getDestroyItemsResult(events);260 expect(substrateEvents).to.include.deep.members([238 expect(chainEvents).to.include.deep.members([{261 {239 method: 'ItemDestroyed',262 success: true,240 section: 'common',241 index: '0x4203',263 collectionId,242 data: [ 243 collection.collectionId.toString(), 264 itemId: tokenId,244 token.tokenId.toString(), 265 owner: {Substrate: alice.address},245 {Substrate: alice.address}, 266 amount: 50,246 '50'267 },247 ]268 ]);248 }])269 });249 });270 });250 });271});251});272252273describe('Test Refungible properties:', () => {253describe('Test Refungible properties:', () => {274 before(async () => {254 before(async () => {275 await usingApi(async (api, privateKeyWrapper) => {255 await usingPlaygrounds(async (helper, privateKey) => {276 alice = privateKeyWrapper('//Alice');256 alice = privateKey('//Alice');277 bob = privateKeyWrapper('//Bob');257 bob = privateKey('//Bob');278 });258 });279 });259 });280 260 281 it('Сreate new collection with properties', async () => {261 it('Сreate new collection with properties', async () => {282 await usingApi(async api => {262 await usingPlaygrounds(async helper => {283 const properties = [{key: 'key1', value: 'val1'}];263 const properties = [{key: 'key1', value: 'val1'}];284 const propertyPermissions = [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}];264 const tokenPropertyPermissions = [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}];285 const collectionId = await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'ReFungible'},265 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test', properties, tokenPropertyPermissions});286 properties: properties,287 propPerm: propertyPermissions, 288 });289 const collection = (await getDetailedCollectionInfo(api, collectionId))!;266 const info = await collection.getData();290 expect(collection.properties.toHuman()).to.be.deep.equal(properties);267 expect(info?.raw.properties).to.be.deep.equal(properties);291 expect(collection.tokenPropertyPermissions.toHuman()).to.be.deep.equal(propertyPermissions);268 expect(info?.raw.tokenPropertyPermissions).to.be.deep.equal(tokenPropertyPermissions);292 });269 });293 });270 });294});271});tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth161617import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';19import { usingPlaygrounds } from './util/playgrounds';212022chai.use(chaiAsPromised);21chai.use(chaiAsPromised);23const expect = chai.expect;22const expect = chai.expect;242325describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {24describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {26 it('Remove collection admin.', async () => {25 it('Remove collection admin.', async () => {27 await usingApi(async (api, privateKeyWrapper) => {26 await usingPlaygrounds(async (helper, privateKey) => {28 const collectionId = await createCollectionExpectSuccess();27 const alice = privateKey('//Alice');29 const alice = privateKeyWrapper('//Alice');28 const bob = privateKey('//Bob');30 const bob = privateKeyWrapper('//Bob');29 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});31 const collection = await queryCollectionExpectSuccess(api, collectionId);30 const collectionInfo = await collection.getData();32 expect(collection.owner.toString()).to.be.deep.eq(alice.address);31 expect(collectionInfo?.raw.owner.toString()).to.be.deep.eq(alice.address);33 // first - add collection admin Bob32 // first - add collection admin Bob34 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));33 await collection.addAdmin(alice, {Substrate: bob.address});35 await submitTransactionAsync(alice, addAdminTx);363437 const adminListAfterAddAdmin = await getAdminList(api, collectionId);35 const adminListAfterAddAdmin = await collection.getAdmins();38 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));36 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});393740 // then remove bob from admins of collection38 // then remove bob from admins of collection41 const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));39 await collection.removeAdmin(alice, {Substrate: bob.address});42 await submitTransactionAsync(alice, removeAdminTx);434044 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);41 const adminListAfterRemoveAdmin = await collection.getAdmins();45 expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(bob.address));42 expect(adminListAfterRemoveAdmin).not.to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});46 });43 });47 });44 });484549 it('Remove admin from collection that has no admins', async () => {46 it('Remove admin from collection that has no admins', async () => {50 await usingApi(async (api, privateKeyWrapper) => {47 await usingPlaygrounds(async (helper, privateKey) => {51 const alice = privateKeyWrapper('//Alice');48 const alice = privateKey('//Alice');52 const collectionId = await createCollectionExpectSuccess();49 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});535054 const adminListBeforeAddAdmin = await getAdminList(api, collectionId);51 const adminListBeforeAddAdmin = await collection.getAdmins();55 expect(adminListBeforeAddAdmin).to.have.lengthOf(0);52 expect(adminListBeforeAddAdmin).to.have.lengthOf(0);565354 // await expect(collection.removeAdmin(alice, {Substrate: alice.address})).to.be.rejectedWith('Unable to remove collection admin');57 const tx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(alice.address));55 await collection.removeAdmin(alice, {Substrate: alice.address});58 await submitTransactionAsync(alice, tx);59 });56 });60 });57 });61});58});625963describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {60describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {64 it('Can\'t remove collection admin from not existing collection', async () => {61 it('Can\'t remove collection admin from not existing collection', async () => {65 await usingApi(async (api, privateKeyWrapper) => {62 await usingPlaygrounds(async (helper, privateKey) => {66 // tslint:disable-next-line: no-bitwise63 // tslint:disable-next-line: no-bitwise67 const collectionId = (1 << 32) - 1;64 const collectionId = (1 << 32) - 1;68 const alice = privateKeyWrapper('//Alice');65 const alice = privateKey('//Alice');69 const bob = privateKeyWrapper('//Bob');66 const bob = privateKey('//Bob');706771 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));72 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;68 await expect(helper.collection.removeAdmin(alice, collectionId, {Substrate: bob.address})).to.be.rejected;736974 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)70 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)75 await createCollectionExpectSuccess();71 await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});76 });72 });77 });73 });787479 it('Can\'t remove collection admin from deleted collection', async () => {75 it('Can\'t remove collection admin from deleted collection', async () => {80 await usingApi(async (api, privateKeyWrapper) => {76 await usingPlaygrounds(async (helper, privateKey) => {81 // tslint:disable-next-line: no-bitwise82 const collectionId = await createCollectionExpectSuccess();83 const alice = privateKeyWrapper('//Alice');77 const alice = privateKey('//Alice');84 const bob = privateKeyWrapper('//Bob');78 const bob = privateKey('//Bob');8586 await destroyCollectionExpectSuccess(collectionId);79 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});878088 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));81 expect(await collection.burn(alice)).to.be.true;8289 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;83 await expect(helper.collection.removeAdmin(alice, collection.collectionId, {Substrate: bob.address})).to.be.rejected;908491 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)85 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)92 await createCollectionExpectSuccess();86 await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});93 });87 });94 });88 });958996 it('Regular user can\'t remove collection admin', async () => {90 it('Regular user can\'t remove collection admin', async () => {97 await usingApi(async (api, privateKeyWrapper) => {91 await usingPlaygrounds(async (helper, privateKey) => {98 const collectionId = await createCollectionExpectSuccess();99 const alice = privateKeyWrapper('//Alice');92 const alice = privateKey('//Alice');100 const bob = privateKeyWrapper('//Bob');93 const bob = privateKey('//Bob');101 const charlie = privateKeyWrapper('//Charlie');94 const charlie = privateKey('//Charlie');102103 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));95 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});104 await submitTransactionAsync(alice, addAdminTx);10596106 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));97 await collection.addAdmin(alice, {Substrate: bob.address});98107 await expect(submitTransactionExpectFailAsync(charlie, changeOwnerTx)).to.be.rejected;99 await expect(collection.removeAdmin(charlie, {Substrate: bob.address})).to.be.rejected;108100109 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)101 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)110 await createCollectionExpectSuccess();102 await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});111 });103 });112 });104 });113105114 it('Admin can\'t remove collection admin.', async () => {106 it('Admin can\'t remove collection admin.', async () => {115 await usingApi(async (api, privateKeyWrapper) => {107 await usingPlaygrounds(async (helper, privateKey) => {116 const collectionId = await createCollectionExpectSuccess();117 const alice = privateKeyWrapper('//Alice');108 const alice = privateKey('//Alice');118 const bob = privateKeyWrapper('//Bob');109 const bob = privateKey('//Bob');119 const charlie = privateKeyWrapper('//Charlie');110 const charlie = privateKey('//Charlie');120121 const addBobAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));111 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});112 122 await submitTransactionAsync(alice, addBobAdminTx);113 await collection.addAdmin(alice, {Substrate: bob.address});123 const addCharlieAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));114 await collection.addAdmin(alice, {Substrate: charlie.address});124 await submitTransactionAsync(alice, addCharlieAdminTx);125115126 const adminListAfterAddAdmin = await getAdminList(api, collectionId);116 const adminListAfterAddAdmin = await collection.getAdmins();127 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));117 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});128 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(charlie.address));118 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(charlie.address)});129119130 const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));131 await expect(submitTransactionExpectFailAsync(charlie, removeAdminTx)).to.be.rejected;120 await expect(collection.removeAdmin(charlie, {Substrate: bob.address})).to.be.rejected;132121133 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);122 const adminListAfterRemoveAdmin = await collection.getAdmins();134 expect(adminListAfterRemoveAdmin).to.be.deep.contains(normalizeAccountId(bob.address));123 expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(bob.address)});135 expect(adminListAfterRemoveAdmin).to.be.deep.contains(normalizeAccountId(charlie.address));124 expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: helper.address.normalizeSubstrate(charlie.address)});136 });125 });137 });126 });138});127});tests/src/util/playgrounds/index.tsdiffbeforeafterbothno changes
tests/src/util/playgrounds/unique.tsdiffbeforeafterbothno changes