difftreelog
Merge pull request #479 from UniqueNetwork/feature/playgrounds
in: master
Feature/playgrounds
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 expect64 // tslint:disable-next-line:no-unused-expression65 expect(itemCountAfter).to.be.equal(defaultTokenId);48 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';1819import { usingPlaygrounds } from './util/playgrounds';19import {20import {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 getModuleNames,21 getModuleNames,40 Pallets,22 Pallets,41 requirePallets,23 requirePallets,49let alice: IKeyringPair;31let alice: IKeyringPair;50let bob: IKeyringPair;32let bob: IKeyringPair;5133525354describe('integration test: Refungible functionality:', async () => {34describe('integration test: Refungible functionality:', async () => {55 before(async function() {35 before(async function() {56 await requirePallets(this, [Pallets.ReFungible]);36 await requirePallets(this, [Pallets.ReFungible]);573758 await usingApi(async (api, privateKeyWrapper) => {38 await usingPlaygrounds(async (helper, privateKey) => {59 alice = privateKeyWrapper('//Alice');39 alice = privateKey('//Alice');60 bob = privateKeyWrapper('//Bob');40 bob = privateKey('//Bob');61 if (!getModuleNames(api).includes(Pallets.ReFungible)) this.skip();41 if (!getModuleNames(helper.api!).includes(Pallets.ReFungible)) this.skip();62 });42 });63 64 });43 });65 44 66 it('Create refungible collection and token', async () => {45 it('Create refungible collection and token', async () => {67 await usingApi(async api => {46 await usingPlaygrounds(async helper => {68 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});47 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});4869 expect(createCollectionResult.success).to.be.true;49 const itemCountBefore = await collection.getLastTokenId();70 const collectionId = createCollectionResult.collectionId;50 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);71 51 72 const itemCountBefore = await getLastTokenId(api, collectionId);52 const itemCountAfter = await collection.getLastTokenId();73 const result = await createRefungibleToken(api, alice, collectionId, 100n);74 53 75 const itemCountAfter = await getLastTokenId(api, collectionId);76 77 // What to expect54 // What to expect78 // tslint:disable-next-line:no-unused-expression55 expect(token?.tokenId).to.be.gte(itemCountBefore);79 expect(result.success).to.be.true;80 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);56 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);81 expect(collectionId).to.be.equal(result.collectionId);57 expect(itemCountAfter.toString()).to.be.equal(token?.tokenId.toString());82 expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());83 });58 });84 });59 });85 60 86 it('RPC method tokenOnewrs for refungible collection and token', async () => {61 it('RPC method tokenOnewrs for refungible collection and token', async () => {87 await usingApi(async (api, privateKeyWrapper) => {62 await usingPlaygrounds(async (helper, privateKey) => {88 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};63 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};89 const facelessCrowd = Array.from(Array(7).keys()).map(i => normalizeAccountId(privateKeyWrapper(i.toString())));64 const facelessCrowd = Array(7).fill(0).map((_, i) => ({Substrate: privateKey(`//Alice+${i}`).address}));6566 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});6768 const token = await collection.mintToken(alice, {Substrate: alice.address}, 10_000n);6970 await token.transfer(alice, {Substrate: bob.address}, 1000n);71 await token.transfer(alice, ethAcc, 900n);90 72 91 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});92 const collectionId = createCollectionResult.collectionId;93 94 const result = await createRefungibleToken(api, alice, collectionId, 10_000n);95 const aliceTokenId = result.itemId;96 97 98 await transfer(api, collectionId, aliceTokenId, alice, bob, 1000n);99 await transfer(api, collectionId, aliceTokenId, alice, ethAcc, 900n);100 101 for (let i = 0; i < 7; i++) {73 for (let i = 0; i < 7; i++) {102 await transfer(api, collectionId, aliceTokenId, alice, facelessCrowd[i], 50*(i+1));74 await token.transfer(alice, facelessCrowd[i], 50n * BigInt(i + 1));103 } 75 } 104 76105 const owners = await api.rpc.unique.tokenOwners(collectionId, aliceTokenId);77 const owners = await token.getTop10Owners();106 const ids = (owners.toJSON() as CrossAccountId[]).map(s => normalizeAccountId(s));78107 108 const aliceID = normalizeAccountId(alice);109 const bobId = normalizeAccountId(bob);110 111 // What to expect79 // What to expect112 // tslint:disable-next-line:no-unused-expression80 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);113 expect(ids).to.deep.include.members([aliceID, ethAcc, bobId, ...facelessCrowd]);114 expect(owners.length).to.be.equal(10);81 expect(owners.length).to.be.equal(10);115 82 116 const eleven = privateKeyWrapper('11');83 const eleven = privateKey('//ALice+11');117 expect(await transfer(api, collectionId, aliceTokenId, alice, eleven, 10n)).to.be.true;84 expect(await token.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;118 expect((await api.rpc.unique.tokenOwners(collectionId, aliceTokenId)).length).to.be.equal(10);85 expect((await token.getTop10Owners()).length).to.be.equal(10);119 });86 });120 });87 });121 88 122 it('Transfer token pieces', async () => {89 it('Transfer token pieces', async () => {123 await usingApi(async api => {90 await usingPlaygrounds(async helper => {124 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;91 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});125 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;92 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);12693127 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);94 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);128 expect(await transfer(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;95 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;12996 130 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(40n);97 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);131 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(60n);98 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);132 await expect(transfer(api, collectionId, tokenId, alice, bob, 41n)).to.eventually.be.rejected;99 100 await expect(token.transfer(alice, {Substrate: bob.address}, 41n)).to.eventually.be.rejected;133 });101 });134 });102 });135103136 it('Create multiple tokens', async () => {104 it('Create multiple tokens', async () => {137 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});105 await usingPlaygrounds(async helper => {106 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});138 const args = [107 // TODO: fix mintMultipleTokens108 // await collection.mintMultipleTokens(alice, [139 {ReFungible: {pieces: 1}},109 // {owner: {Substrate: alice.address}, pieces: 1n},140 {ReFungible: {pieces: 2}},110 // {owner: {Substrate: alice.address}, pieces: 2n},141 {ReFungible: {pieces: 100}},111 // {owner: {Substrate: alice.address}, pieces: 100n},142 ];112 // ]);143 await createMultipleItemsExpectSuccess(alice, collectionId, args);113 await helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, [144114 {pieces: 1n}, 145 await usingApi(async api => { 115 {pieces: 2n}, 116 {pieces: 100n},146 const tokenId = await getLastTokenId(api, collectionId);117 ]);118 const lastTokenId = await collection.getLastTokenId();147 expect(tokenId).to.be.equal(3);119 expect(lastTokenId).to.be.equal(3);148 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);120 expect(await collection.getTokenBalance(lastTokenId, {Substrate: alice.address})).to.be.equal(100n);149 });121 });150 });122 });151123152 it('Burn some pieces', async () => {124 it('Burn some pieces', async () => {153 await usingApi(async api => { 125 await usingPlaygrounds(async helper => {154 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;126 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});155 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;127 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);156 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;128 expect(await collection.isTokenExists(token.tokenId)).to.be.true;157 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);129 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);158 expect(await burnItem(api, alice, collectionId, tokenId, 99n)).to.be.true;130 expect((await token.burn(alice, 99n)).success).to.be.true;159 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;131 expect(await collection.isTokenExists(token.tokenId)).to.be.true;160 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(1n);132 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);161 });133 });162 });134 });163135164 it('Burn all pieces', async () => {136 it('Burn all pieces', async () => {165 await usingApi(async api => { 137 await usingPlaygrounds(async helper => { 166 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;138 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});167 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;139 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);168 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;140 141 expect(await collection.isTokenExists(token.tokenId)).to.be.true;169 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);142 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);143170 expect(await burnItem(api, alice, collectionId, tokenId, 100n)).to.be.true;144 expect((await token.burn(alice, 100n)).success).to.be.true;171 expect(await isTokenExists(api, collectionId, tokenId)).to.be.false;145 expect(await collection.isTokenExists(token.tokenId)).to.be.false;172 });146 });173 });147 });174148175 it('Burn some pieces for multiple users', async () => {149 it('Burn some pieces for multiple users', async () => {176 await usingApi(async api => { 150 await usingPlaygrounds(async helper => {177 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;151 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});178 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;152 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);179 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;180153181 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);154 expect(await collection.isTokenExists(token.tokenId)).to.be.true;182 expect(await transfer(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;183184 155 185 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(40n);156 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);186 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(60n);157 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;187 expect(await burnItem(api, alice, collectionId, tokenId, 40n)).to.be.true;188158189 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(0n);159 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);190 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;160 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);191 expect(await burnItem(api, bob, collectionId, tokenId, 59n)).to.be.true;192161193 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(1n);162 expect((await token.burn(alice, 40n)).success).to.be.true;163164 expect(await collection.isTokenExists(token.tokenId)).to.be.true;165 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);166194 expect(await isTokenExists(api, collectionId, tokenId)).to.be.true;167 expect((await token.burn(bob, 59n)).success).to.be.true;168195 expect(await burnItem(api, bob, collectionId, tokenId, 1n)).to.be.true;169 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);170 expect(await collection.isTokenExists(token.tokenId)).to.be.true;171196 172 expect((await token.burn(bob, 1n)).success).to.be.true;173197 expect(await isTokenExists(api, collectionId, tokenId)).to.be.false;174 expect(await collection.isTokenExists(token.tokenId)).to.be.false;198 });175 });199 });176 });200177201 it('Set allowance for token', async () => {178 it('Set allowance for token', async () => {202 await usingApi(async api => {179 await usingPlaygrounds(async helper => {203 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;180 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});204 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;181 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);182 183 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);205184206 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(100n);185 expect(await token.approve(alice, {Substrate: bob.address}, 60n)).to.be.true;186 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(60n);207187208 expect(await approve(api, collectionId, tokenId, alice, bob, 60n)).to.be.true;188 expect(await token.transferFrom(bob, {Substrate: alice.address}, {Substrate: bob.address}, 20n)).to.be.true;209 expect(await getAllowance(api, collectionId, alice, bob, tokenId)).to.be.equal(60n);210211 expect(await transferFrom(api, collectionId, tokenId, bob, alice, bob, 20n)).to.be.true;212 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(80n);189 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(80n);213 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(20n);190 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(20n);214 expect(await getAllowance(api, collectionId, alice, bob, tokenId)).to.be.equal(40n);191 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);215 });192 });216 });193 });217194218 it('Repartition', async () => {195 it('Repartition', async () => {219 await usingApi(async api => {196 await usingPlaygrounds(async helper => {220 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;197 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});221 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;198 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);222199223 expect(await repartitionRFT(api, collectionId, alice, tokenId, 200n)).to.be.true;200 expect(await token.repartition(alice, 200n)).to.be.true;201 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(200n);202 expect(await token.getTotalPieces()).to.be.equal(200n);203 204 expect(await token.transfer(alice, {Substrate: bob.address}, 110n)).to.be.true;224 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(200n);205 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(90n);206 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(110n);207 208 await expect(token.repartition(alice, 80n)).to.eventually.be.rejected;209 210 expect(await token.transfer(alice, {Substrate: bob.address}, 90n)).to.be.true;211 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);212 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(200n);225213226 expect(await transfer(api, collectionId, tokenId, alice, bob, 110n)).to.be.true;214 expect(await token.repartition(bob, 150n)).to.be.true;227 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(90n);215 await expect(token.transfer(bob, {Substrate: alice.address}, 160n)).to.eventually.be.rejected;228 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(110n);229216230 await expect(repartitionRFT(api, collectionId, alice, tokenId, 80n)).to.eventually.be.rejected;231232 expect(await transfer(api, collectionId, tokenId, alice, bob, 90n)).to.be.true;233 expect(await getBalance(api, collectionId, alice, tokenId)).to.be.equal(0n);234 expect(await getBalance(api, collectionId, bob, tokenId)).to.be.equal(200n);235236 expect(await repartitionRFT(api, collectionId, bob, tokenId, 150n)).to.be.true;237 await expect(transfer(api, collectionId, tokenId, bob, alice, 160n)).to.eventually.be.rejected;238 });217 });239 });218 });240219241 it('Repartition with increased amount', async () => {220 it('Repartition with increased amount', async () => {242 await usingApi(async api => {221 await usingPlaygrounds(async helper => {243 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;222 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});244 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;223 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);245246 const tx = api.tx.unique.repartition(collectionId, tokenId, 200n);224 await token.repartition(alice, 200n);247 const events = await submitTransactionAsync(alice, tx);225 const chainEvents = helper.chainLog.slice(-1)[0].events.map((x: any) => x.event);248 const substrateEvents = getCreateItemsResult(events);249 expect(substrateEvents).to.include.deep.members([226 expect(chainEvents).to.include.deep.members([{250 {227 method: 'ItemCreated',251 success: true,228 section: 'common',229 index: '0x4202',252 collectionId,230 data: [ 231 collection.collectionId.toString(), 253 itemId: tokenId,232 token.tokenId.toString(), 254 recipient: {Substrate: alice.address},233 {Substrate: alice.address}, 255 amount: 100,234 '100',256 },235 ],257 ]);236 }]);258 });237 });259 });238 });260239261 it('Repartition with decreased amount', async () => {240 it('Repartition with decreased amount', async () => {262 await usingApi(async api => {241 await usingPlaygrounds(async helper => {263 const collectionId = (await createCollection(api, alice, {mode: {type: 'ReFungible'}})).collectionId;242 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});264 const tokenId = (await createRefungibleToken(api, alice, collectionId, 100n)).itemId;243 const token = await collection.mintToken(alice, {Substrate: alice.address}, 100n);265266 const tx = api.tx.unique.repartition(collectionId, tokenId, 50n);244 await token.repartition(alice, 50n);267 const events = await submitTransactionAsync(alice, tx);245 const chainEvents = helper.chainLog.slice(-1)[0].events.map((x: any) => x.event);268 const substrateEvents = getDestroyItemsResult(events);269 expect(substrateEvents).to.include.deep.members([246 expect(chainEvents).to.include.deep.members([{270 {247 method: 'ItemDestroyed',271 success: true,248 section: 'common',249 index: '0x4203',272 collectionId,250 data: [ 251 collection.collectionId.toString(), 273 itemId: tokenId,252 token.tokenId.toString(), 274 owner: {Substrate: alice.address},253 {Substrate: alice.address}, 275 amount: 50,254 '50',276 },255 ],277 ]);256 }]);278 });257 });279 });258 });280 259 281 it('Сreate new collection with properties', async () => {260 it('Create new collection with properties', async () => {282 await usingApi(async api => {261 await usingPlaygrounds(async helper => {283 const properties = [{key: 'key1', value: 'val1'}];262 const properties = [{key: 'key1', value: 'val1'}];284 const propertyPermissions = [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}];263 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'},264 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))!;265 const info = await collection.getData();290 expect(collection.properties.toHuman()).to.be.deep.equal(properties);266 expect(info?.raw.properties).to.be.deep.equal(properties);291 expect(collection.tokenPropertyPermissions.toHuman()).to.be.deep.equal(propertyPermissions);267 expect(info?.raw.tokenPropertyPermissions).to.be.deep.equal(tokenPropertyPermissions);292 });268 });293 });269 });294});270});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