difftreelog
test(ss58Format) transfer all tests to the new privateKeyWrapper method
in: master
62 files changed
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth17import {ApiPromise} from '@polkadot/api';17import {ApiPromise} from '@polkadot/api';18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';22import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';21import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';2322262527describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {26describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {28 it('Add collection admin.', async () => {27 it('Add collection admin.', async () => {29 await usingApi(async (api) => {28 await usingApi(async (api, privateKeyWrapper) => {30 const collectionId = await createCollectionExpectSuccess();29 const collectionId = await createCollectionExpectSuccess();31 const alice = privateKey('//Alice');30 const alice = privateKeyWrapper!('//Alice');32 const bob = privateKey('//Bob');31 const bob = privateKeyWrapper!('//Bob');333234 const collection = await queryCollectionExpectSuccess(api, collectionId);33 const collection = await queryCollectionExpectSuccess(api, collectionId);35 expect(collection.owner.toString()).to.be.equal(alice.address);34 expect(collection.owner.toString()).to.be.equal(alice.address);43 });42 });444345 it('Add admin using added collection admin.', async () => {44 it('Add admin using added collection admin.', async () => {46 await usingApi(async (api) => {45 await usingApi(async (api, privateKeyWrapper) => {47 const collectionId = await createCollectionExpectSuccess();46 const collectionId = await createCollectionExpectSuccess();48 const alice = privateKey('//Alice');47 const alice = privateKeyWrapper!('//Alice');49 const bob = privateKey('//Bob');48 const bob = privateKeyWrapper!('//Bob');50 const charlie = privateKey('//CHARLIE');49 const charlie = privateKeyWrapper!('//CHARLIE');515052 const collection = await queryCollectionExpectSuccess(api, collectionId);51 const collection = await queryCollectionExpectSuccess(api, collectionId);53 expect(collection.owner.toString()).to.be.equal(alice.address);52 expect(collection.owner.toString()).to.be.equal(alice.address);696870describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {69describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {71 it("Not owner can't add collection admin.", async () => {70 it("Not owner can't add collection admin.", async () => {72 await usingApi(async (api) => {71 await usingApi(async (api, privateKeyWrapper) => {73 const collectionId = await createCollectionExpectSuccess();72 const collectionId = await createCollectionExpectSuccess();74 const alice = privateKey('//Alice');73 const alice = privateKeyWrapper!('//Alice');75 const nonOwner = privateKey('//Bob_stash');74 const nonOwner = privateKeyWrapper!('//Bob_stash');767577 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));76 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));78 await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;77 await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;85 });84 });86 });85 });87 it("Can't add collection admin of not existing collection.", async () => {86 it("Can't add collection admin of not existing collection.", async () => {88 await usingApi(async (api) => {87 await usingApi(async (api, privateKeyWrapper) => {89 // tslint:disable-next-line: no-bitwise88 // tslint:disable-next-line: no-bitwise90 const collectionId = (1 << 32) - 1;89 const collectionId = (1 << 32) - 1;91 const alice = privateKey('//Alice');90 const alice = privateKeyWrapper!('//Alice');92 const bob = privateKey('//Bob');91 const bob = privateKeyWrapper!('//Bob');939294 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));93 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));95 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;94 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;100 });99 });101100102 it("Can't add an admin to a destroyed collection.", async () => {101 it("Can't add an admin to a destroyed collection.", async () => {103 await usingApi(async (api) => {102 await usingApi(async (api, privateKeyWrapper) => {104 const collectionId = await createCollectionExpectSuccess();103 const collectionId = await createCollectionExpectSuccess();105 const alice = privateKey('//Alice');104 const alice = privateKeyWrapper!('//Alice');106 const bob = privateKey('//Bob');105 const bob = privateKeyWrapper!('//Bob');107 await destroyCollectionExpectSuccess(collectionId);106 await destroyCollectionExpectSuccess(collectionId);108 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));107 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));109 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;108 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;114 });113 });115114116 it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {115 it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {117 await usingApi(async (api: ApiPromise) => {116 await usingApi(async (api: ApiPromise, privateKeyWrapper) => {118 const alice = privateKey('//Alice');117 const alice = privateKeyWrapper!('//Alice');119 const accounts = [118 const accounts = [120 privateKey('//AdminTest/1').address,119 privateKeyWrapper!('//AdminTest/1').address,121 privateKey('//AdminTest/2').address,120 privateKeyWrapper!('//AdminTest/2').address,122 privateKey('//AdminTest/3').address,121 privateKeyWrapper!('//AdminTest/3').address,123 privateKey('//AdminTest/4').address,122 privateKeyWrapper!('//AdminTest/4').address,124 privateKey('//AdminTest/5').address,123 privateKeyWrapper!('//AdminTest/5').address,125 privateKey('//AdminTest/6').address,124 privateKeyWrapper!('//AdminTest/6').address,126 privateKey('//AdminTest/7').address,125 privateKeyWrapper!('//AdminTest/7').address,127 ];126 ];128 const collectionId = await createCollectionExpectSuccess();127 const collectionId = await createCollectionExpectSuccess();129128tests/src/addToAllowList.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';20import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';22import {21import {23 addToAllowListExpectSuccess,22 addToAllowListExpectSuccess,42describe('Integration Test ext. addToAllowList()', () => {41describe('Integration Test ext. addToAllowList()', () => {434244 before(async () => {43 before(async () => {45 await usingApi(async () => {44 await usingApi(async (api, privateKeyWrapper) => {46 alice = privateKey('//Alice');45 alice = privateKeyWrapper!('//Alice');47 bob = privateKey('//Bob');46 bob = privateKeyWrapper!('//Bob');48 });47 });49 });48 });504965describe('Negative Integration Test ext. addToAllowList()', () => {64describe('Negative Integration Test ext. addToAllowList()', () => {666567 it('Allow list an address in the collection that does not exist', async () => {66 it('Allow list an address in the collection that does not exist', async () => {68 await usingApi(async (api) => {67 await usingApi(async (api, privateKeyWrapper) => {69 // tslint:disable-next-line: no-bitwise68 // tslint:disable-next-line: no-bitwise70 const collectionId = await getCreatedCollectionCount(api) + 1;69 const collectionId = await getCreatedCollectionCount(api) + 1;71 const bob = privateKey('//Bob');70 const bob = privateKeyWrapper!('//Bob');727173 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));72 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));74 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;73 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;75 });74 });76 });75 });777678 it('Allow list an address in the collection that was destroyed', async () => {77 it('Allow list an address in the collection that was destroyed', async () => {79 await usingApi(async (api) => {78 await usingApi(async (api, privateKeyWrapper) => {80 const alice = privateKey('//Alice');79 const alice = privateKeyWrapper!('//Alice');81 const bob = privateKey('//Bob');80 const bob = privateKeyWrapper!('//Bob');82 // tslint:disable-next-line: no-bitwise81 // tslint:disable-next-line: no-bitwise83 const collectionId = await createCollectionExpectSuccess();82 const collectionId = await createCollectionExpectSuccess();84 await destroyCollectionExpectSuccess(collectionId);83 await destroyCollectionExpectSuccess(collectionId);88 });87 });898890 it('Allow list an address in the collection that does not have allow list access enabled', async () => {89 it('Allow list an address in the collection that does not have allow list access enabled', async () => {91 await usingApi(async (api) => {90 await usingApi(async (api, privateKeyWrapper) => {92 const alice = privateKey('//Alice');91 const alice = privateKeyWrapper!('//Alice');93 const ferdie = privateKey('//Ferdie');92 const ferdie = privateKeyWrapper!('//Ferdie');94 const collectionId = await createCollectionExpectSuccess();93 const collectionId = await createCollectionExpectSuccess();95 await enableAllowListExpectSuccess(alice, collectionId);94 await enableAllowListExpectSuccess(alice, collectionId);96 await enablePublicMintingExpectSuccess(alice, collectionId);95 await enablePublicMintingExpectSuccess(alice, collectionId);104describe('Integration Test ext. addToAllowList() with collection admin permissions:', () => {103describe('Integration Test ext. addToAllowList() with collection admin permissions:', () => {105104106 before(async () => {105 before(async () => {107 await usingApi(async () => {106 await usingApi(async (api, privateKeyWrapper) => {108 alice = privateKey('//Alice');107 alice = privateKeyWrapper!('//Alice');109 bob = privateKey('//Bob');108 bob = privateKeyWrapper!('//Bob');110 charlie = privateKey('//Charlie');109 charlie = privateKeyWrapper!('//Charlie');111 });110 });112 });111 });113112tests/src/addToContractAllowList.test.tsdiffbeforeafterboth17import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';19import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import privateKey from './substrate/privateKey';21import {20import {22 deployFlipper,21 deployFlipper,23} from './util/contracthelpers';22} from './util/contracthelpers';31describe.skip('Integration Test addToContractAllowList', () => {30describe.skip('Integration Test addToContractAllowList', () => {323133 it('Add an address to a contract allow list', async () => {32 it('Add an address to a contract allow list', async () => {34 await usingApi(async api => {33 await usingApi(async (api, privateKeyWrapper) => {35 const bob = privateKey('//Bob');34 const bob = privateKeyWrapper!('//Bob');36 const [contract, deployer] = await deployFlipper(api);35 const [contract, deployer] = await deployFlipper(api);373638 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();37 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();47 });46 });484749 it('Adding same address to allow list repeatedly should not produce errors', async () => {48 it('Adding same address to allow list repeatedly should not produce errors', async () => {50 await usingApi(async api => {49 await usingApi(async (api, privateKeyWrapper) => {51 const bob = privateKey('//Bob');50 const bob = privateKeyWrapper!('//Bob');52 const [contract, deployer] = await deployFlipper(api);51 const [contract, deployer] = await deployFlipper(api);535254 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();53 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();70describe.skip('Negative Integration Test addToContractAllowList', () => {69describe.skip('Negative Integration Test addToContractAllowList', () => {717072 it('Add an address to a allow list of a non-contract', async () => {71 it('Add an address to a allow list of a non-contract', async () => {73 await usingApi(async api => {72 await usingApi(async (api, privateKeyWrapper) => {74 const alice = privateKey('//Bob');73 const alice = privateKeyWrapper!('//Bob');75 const bob = privateKey('//Bob');74 const bob = privateKeyWrapper!('//Bob');76 const charlieGuineaPig = privateKey('//Charlie');75 const charlieGuineaPig = privateKeyWrapper!('//Charlie');777678 const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();77 const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();79 const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);78 const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);86 });85 });878688 it('Add to a contract allow list using a non-owner address', async () => {87 it('Add to a contract allow list using a non-owner address', async () => {89 await usingApi(async api => {88 await usingApi(async (api, privateKeyWrapper) => {90 const bob = privateKey('//Bob');89 const bob = privateKeyWrapper!('//Bob');91 const [contract] = await deployFlipper(api);90 const [contract] = await deployFlipper(api);929193 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();92 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();tests/src/allowLists.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';20import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';22import {21import {23 addToAllowListExpectSuccess,22 addToAllowListExpectSuccess,50describe('Integration Test ext. Allow list tests', () => {49describe('Integration Test ext. Allow list tests', () => {515052 before(async () => {51 before(async () => {53 await usingApi(async () => {52 await usingApi(async (api, privateKeyWrapper) => {54 alice = privateKey('//Alice');53 alice = privateKeyWrapper!('//Alice');55 bob = privateKey('//Bob');54 bob = privateKeyWrapper!('//Bob');56 charlie = privateKey('//Charlie');55 charlie = privateKeyWrapper!('//Charlie');57 });56 });58 });57 });5958tests/src/approve.test.tsdiffbeforeafterboth18import {ApiPromise} from '@polkadot/api';18import {ApiPromise} from '@polkadot/api';19import chai from 'chai';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi} from './substrate/substrate-api';21import {default as usingApi} from './substrate/substrate-api';23import {22import {24 approveExpectFail,23 approveExpectFail,43 let charlie: IKeyringPair;42 let charlie: IKeyringPair;444345 before(async () => {44 before(async () => {46 await usingApi(async () => {45 await usingApi(async (api, privateKeyWrapper) => {47 alice = privateKey('//Alice');46 alice = privateKeyWrapper!('//Alice');48 bob = privateKey('//Bob');47 bob = privateKeyWrapper!('//Bob');49 charlie = privateKey('//Charlie');48 charlie = privateKeyWrapper!('//Charlie');50 });49 });51 });50 });525199 let charlie: IKeyringPair;98 let charlie: IKeyringPair;10099101 before(async () => {100 before(async () => {102 await usingApi(async () => {101 await usingApi(async (api, privateKeyWrapper) => {103 alice = privateKey('//Alice');102 alice = privateKeyWrapper!('//Alice');104 bob = privateKey('//Bob');103 bob = privateKeyWrapper!('//Bob');105 charlie = privateKey('//Charlie');104 charlie = privateKeyWrapper!('//Charlie');106 });105 });107 }); 106 }); 108107131 let charlie: IKeyringPair;130 let charlie: IKeyringPair;132131133 before(async () => {132 before(async () => {134 await usingApi(async () => {133 await usingApi(async (api, privateKeyWrapper) => {135 alice = privateKey('//Alice');134 alice = privateKeyWrapper!('//Alice');136 bob = privateKey('//Bob');135 bob = privateKeyWrapper!('//Bob');137 charlie = privateKey('//Charlie');136 charlie = privateKeyWrapper!('//Charlie');138 });137 });139 }); 138 }); 140139166 let charlie: IKeyringPair;165 let charlie: IKeyringPair;167166168 before(async () => {167 before(async () => {169 await usingApi(async () => {168 await usingApi(async (api, privateKeyWrapper) => {170 alice = privateKey('//Alice');169 alice = privateKeyWrapper!('//Alice');171 bob = privateKey('//Bob');170 bob = privateKeyWrapper!('//Bob');172 charlie = privateKey('//Charlie');171 charlie = privateKeyWrapper!('//Charlie');173 });172 });174 }); 173 }); 175174205 let dave: IKeyringPair;204 let dave: IKeyringPair;206205207 before(async () => {206 before(async () => {208 await usingApi(async () => {207 await usingApi(async (api, privateKeyWrapper) => {209 alice = privateKey('//Alice');208 alice = privateKeyWrapper!('//Alice');210 bob = privateKey('//Bob');209 bob = privateKeyWrapper!('//Bob');211 charlie = privateKey('//Charlie');210 charlie = privateKeyWrapper!('//Charlie');212 dave = privateKey('//Dave');211 dave = privateKeyWrapper!('//Dave');213 });212 });214 }); 213 }); 215214228 let charlie: IKeyringPair;227 let charlie: IKeyringPair;229228230 before(async () => {229 before(async () => {231 await usingApi(async () => {230 await usingApi(async (api, privateKeyWrapper) => {232 alice = privateKey('//Alice');231 alice = privateKeyWrapper!('//Alice');233 bob = privateKey('//Bob');232 bob = privateKeyWrapper!('//Bob');234 charlie = privateKey('//Charlie');233 charlie = privateKeyWrapper!('//Charlie');235 });234 });236 });235 });237236267 let charlie: IKeyringPair;266 let charlie: IKeyringPair;268267269 before(async () => {268 before(async () => {270 await usingApi(async () => {269 await usingApi(async (api, privateKeyWrapper) => {271 alice = privateKey('//Alice');270 alice = privateKeyWrapper!('//Alice');272 bob = privateKey('//Bob');271 bob = privateKeyWrapper!('//Bob');273 charlie = privateKey('//Charlie');272 charlie = privateKeyWrapper!('//Charlie');274 });273 });275 });274 });276275300 let dave: IKeyringPair;299 let dave: IKeyringPair;301300302 before(async () => {301 before(async () => {303 await usingApi(async () => {302 await usingApi(async (api, privateKeyWrapper) => {304 alice = privateKey('//Alice');303 alice = privateKeyWrapper!('//Alice');305 bob = privateKey('//Bob');304 bob = privateKeyWrapper!('//Bob');306 charlie = privateKey('//Charlie');305 charlie = privateKeyWrapper!('//Charlie');307 dave = privateKey('//Dave');306 dave = privateKeyWrapper!('//Dave');308 });307 });309 }); 308 }); 310309340 let dave: IKeyringPair;339 let dave: IKeyringPair;341340342 before(async () => {341 before(async () => {343 await usingApi(async () => {342 await usingApi(async (api, privateKeyWrapper) => {344 alice = privateKey('//Alice');343 alice = privateKeyWrapper!('//Alice');345 bob = privateKey('//Bob');344 bob = privateKeyWrapper!('//Bob');346 charlie = privateKey('//Charlie');345 charlie = privateKeyWrapper!('//Charlie');347 dave = privateKey('//Dave');346 dave = privateKeyWrapper!('//Dave');348 });347 });349 }); 348 }); 350349391 let charlie: IKeyringPair;390 let charlie: IKeyringPair;392391393 before(async () => {392 before(async () => {394 await usingApi(async () => {393 await usingApi(async (api, privateKeyWrapper) => {395 alice = privateKey('//Alice');394 alice = privateKeyWrapper!('//Alice');396 bob = privateKey('//Bob');395 bob = privateKeyWrapper!('//Bob');397 charlie = privateKey('//Charlie');396 charlie = privateKeyWrapper!('//Charlie');398 });397 });399 });398 });400399413 let charlie: IKeyringPair;412 let charlie: IKeyringPair;414413415 before(async () => {414 before(async () => {416 await usingApi(async () => {415 await usingApi(async (api, privateKeyWrapper) => {417 alice = privateKey('//Alice');416 alice = privateKeyWrapper!('//Alice');418 bob = privateKey('//Bob');417 bob = privateKeyWrapper!('//Bob');419 charlie = privateKey('//Charlie');418 charlie = privateKeyWrapper!('//Charlie');420 });419 });421 });420 });422421tests/src/change-collection-owner.test.tsdiffbeforeafterboth161617import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import privateKey from './substrate/privateKey';20import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';19import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';21import {createCollectionExpectSuccess,20import {createCollectionExpectSuccess,22 addCollectionAdminExpectSuccess,21 addCollectionAdminExpectSuccess,414042describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {41describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {43 it('Changing owner changes owner address', async () => {42 it('Changing owner changes owner address', async () => {44 await usingApi(async api => {43 await usingApi(async (api, privateKeyWrapper) => {45 const collectionId = await createCollectionExpectSuccess();44 const collectionId = await createCollectionExpectSuccess();46 const alice = privateKey('//Alice');45 const alice = privateKeyWrapper!('//Alice');47 const bob = privateKey('//Bob');46 const bob = privateKeyWrapper!('//Bob');484749 const collection =await queryCollectionExpectSuccess(api, collectionId);48 const collection =await queryCollectionExpectSuccess(api, collectionId);50 expect(collection.owner.toString()).to.be.deep.eq(alice.address);49 expect(collection.owner.toString()).to.be.deep.eq(alice.address);605961describe('Integration Test changeCollectionOwner(collection_id, new_owner) special checks for exOwner:', () => {60describe('Integration Test changeCollectionOwner(collection_id, new_owner) special checks for exOwner:', () => {62 it('Changing the owner of the collection is not allowed for the former owner', async () => {61 it('Changing the owner of the collection is not allowed for the former owner', async () => {63 await usingApi(async api => {62 await usingApi(async (api, privateKeyWrapper) => {64 const collectionId = await createCollectionExpectSuccess();63 const collectionId = await createCollectionExpectSuccess();65 const alice = privateKey('//Alice');64 const alice = privateKeyWrapper!('//Alice');66 const bob = privateKey('//Bob');65 const bob = privateKeyWrapper!('//Bob');676668 const collection = await queryCollectionExpectSuccess(api, collectionId);67 const collection = await queryCollectionExpectSuccess(api, collectionId);69 expect(collection.owner.toString()).to.be.deep.eq(alice.address);68 expect(collection.owner.toString()).to.be.deep.eq(alice.address);80 });79 });818082 it('New collectionOwner has access to sponsorship management operations in the collection', async () => {81 it('New collectionOwner has access to sponsorship management operations in the collection', async () => {83 await usingApi(async api => {82 await usingApi(async (api, privateKeyWrapper) => {84 const collectionId = await createCollectionExpectSuccess();83 const collectionId = await createCollectionExpectSuccess();85 const alice = privateKey('//Alice');84 const alice = privateKeyWrapper!('//Alice');86 const bob = privateKey('//Bob');85 const bob = privateKeyWrapper!('//Bob');87 const charlie = privateKey('//Charlie');86 const charlie = privateKeyWrapper!('//Charlie');888789 const collection = await queryCollectionExpectSuccess(api, collectionId);88 const collection = await queryCollectionExpectSuccess(api, collectionId);90 expect(collection.owner.toString()).to.be.deep.eq(alice.address);89 expect(collection.owner.toString()).to.be.deep.eq(alice.address);124 });123 });125124126 it('New collectionOwner has access to changeCollectionOwner', async () => {125 it('New collectionOwner has access to changeCollectionOwner', async () => {127 await usingApi(async api => {126 await usingApi(async (api, privateKeyWrapper) => {128 const collectionId = await createCollectionExpectSuccess();127 const collectionId = await createCollectionExpectSuccess();129 const alice = privateKey('//Alice');128 const alice = privateKeyWrapper!('//Alice');130 const bob = privateKey('//Bob');129 const bob = privateKeyWrapper!('//Bob');131 const charlie = privateKey('//Charlie');130 const charlie = privateKeyWrapper!('//Charlie');132131133 const collection = await queryCollectionExpectSuccess(api, collectionId);132 const collection = await queryCollectionExpectSuccess(api, collectionId);134 expect(collection.owner.toString()).to.be.deep.eq(alice.address);133 expect(collection.owner.toString()).to.be.deep.eq(alice.address);151150152describe('Negative Integration Test changeCollectionOwner(collection_id, new_owner):', () => {151describe('Negative Integration Test changeCollectionOwner(collection_id, new_owner):', () => {153 it('Not owner can\'t change owner.', async () => {152 it('Not owner can\'t change owner.', async () => {154 await usingApi(async api => {153 await usingApi(async (api, privateKeyWrapper) => {155 const collectionId = await createCollectionExpectSuccess();154 const collectionId = await createCollectionExpectSuccess();156 const alice = privateKey('//Alice');155 const alice = privateKeyWrapper!('//Alice');157 const bob = privateKey('//Bob');156 const bob = privateKeyWrapper!('//Bob');158157159 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);158 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);160 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;159 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;168 });167 });169168170 it('Collection admin can\'t change owner.', async () => {169 it('Collection admin can\'t change owner.', async () => {171 await usingApi(async api => {170 await usingApi(async (api, privateKeyWrapper) => {172 const collectionId = await createCollectionExpectSuccess();171 const collectionId = await createCollectionExpectSuccess();173 const alice = privateKey('//Alice');172 const alice = privateKeyWrapper!('//Alice');174 const bob = privateKey('//Bob');173 const bob = privateKeyWrapper!('//Bob');175174176 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);175 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);177176187 });186 });188187189 it('Can\'t change owner of a non-existing collection.', async () => {188 it('Can\'t change owner of a non-existing collection.', async () => {190 await usingApi(async api => {189 await usingApi(async (api, privateKeyWrapper) => {191 const collectionId = (1<<32) - 1;190 const collectionId = (1<<32) - 1;192 const alice = privateKey('//Alice');191 const alice = privateKeyWrapper!('//Alice');193 const bob = privateKey('//Bob');192 const bob = privateKeyWrapper!('//Bob');194193195 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);194 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);196 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;195 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;201 });200 });202201203 it('Former collectionOwner not allowed to sponsorship management operations in the collection', async () => {202 it('Former collectionOwner not allowed to sponsorship management operations in the collection', async () => {204 await usingApi(async api => {203 await usingApi(async (api, privateKeyWrapper) => {205 const collectionId = await createCollectionExpectSuccess();204 const collectionId = await createCollectionExpectSuccess();206 const alice = privateKey('//Alice');205 const alice = privateKeyWrapper!('//Alice');207 const bob = privateKey('//Bob');206 const bob = privateKeyWrapper!('//Bob');208 const charlie = privateKey('//Charlie');207 const charlie = privateKeyWrapper!('//Charlie');209208210 const collection = await queryCollectionExpectSuccess(api, collectionId);209 const collection = await queryCollectionExpectSuccess(api, collectionId);211 expect(collection.owner.toString()).to.be.deep.eq(alice.address);210 expect(collection.owner.toString()).to.be.deep.eq(alice.address);tests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from '../substrate/privateKey';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage} from '../util/helpers';23import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage} from '../util/helpers';252432 const checkTreasury = 'Deposit';31 const checkTreasury = 'Deposit';33 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';34 before(async () => {33 before(async () => {35 await usingApi(async () => {34 await usingApi(async (api, privateKeyWrapper) => {36 alice = privateKey('//Alice');35 alice = privateKeyWrapper!('//Alice');37 });36 });38 });37 });39 it('Check event from burnItem(): ', async () => {38 it('Check event from burnItem(): ', async () => {tests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from '../substrate/privateKey';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {uniqueEventMessage} from '../util/helpers';23import {uniqueEventMessage} from '../util/helpers';252432 const checkTreasury = 'Deposit';31 const checkTreasury = 'Deposit';33 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';34 before(async () => {33 before(async () => {35 await usingApi(async () => {34 await usingApi(async (api, privateKeyWrapper) => {36 alice = privateKey('//Alice');35 alice = privateKeyWrapper!('//Alice');37 });36 });38 });37 });39 it('Check event from createCollection(): ', async () => {38 it('Check event from createCollection(): ', async () => {tests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from '../substrate/privateKey';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';23import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';252432 const checkTreasury = 'Deposit';31 const checkTreasury = 'Deposit';33 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';34 before(async () => {33 before(async () => {35 await usingApi(async () => {34 await usingApi(async (api, privateKeyWrapper) => {36 alice = privateKey('//Alice');35 alice = privateKeyWrapper!('//Alice');37 });36 });38 });37 });39 it('Check event from createItem(): ', async () => {38 it('Check event from createItem(): ', async () => {tests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from '../substrate/privateKey';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';23import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';252432 const checkTreasury = 'Deposit';31 const checkTreasury = 'Deposit';33 const checkSystem = 'ExtrinsicSuccess';32 const checkSystem = 'ExtrinsicSuccess';34 before(async () => {33 before(async () => {35 await usingApi(async () => {34 await usingApi(async (api, privateKeyWrapper) => {36 alice = privateKey('//Alice');35 alice = privateKeyWrapper!('//Alice');37 });36 });38 });37 });39 it('Check event from createMultipleItems(): ', async () => {38 it('Check event from createMultipleItems(): ', async () => {tests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from '../substrate/privateKey';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {createCollectionExpectSuccess, uniqueEventMessage} from '../util/helpers';23import {createCollectionExpectSuccess, uniqueEventMessage} from '../util/helpers';252431 const checkTreasury = 'Deposit';30 const checkTreasury = 'Deposit';32 const checkSystem = 'ExtrinsicSuccess';31 const checkSystem = 'ExtrinsicSuccess';33 before(async () => {32 before(async () => {34 await usingApi(async () => {33 await usingApi(async (api, privateKeyWrapper) => {35 alice = privateKey('//Alice');34 alice = privateKeyWrapper!('//Alice');36 });35 });37 });36 });38 it('Check event from destroyCollection(): ', async () => {37 it('Check event from destroyCollection(): ', async () => {tests/src/check-event/transferEvent.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from '../substrate/privateKey';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';23import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';252433 const checkTreasury = 'Deposit';32 const checkTreasury = 'Deposit';34 const checkSystem = 'ExtrinsicSuccess';33 const checkSystem = 'ExtrinsicSuccess';35 before(async () => {34 before(async () => {36 await usingApi(async () => {35 await usingApi(async (api, privateKeyWrapper) => {37 alice = privateKey('//Alice');36 alice = privateKeyWrapper!('//Alice');38 bob = privateKey('//Bob');37 bob = privateKeyWrapper!('//Bob');39 });38 });40 });39 });41 it('Check event from transfer(): ', async () => {40 it('Check event from transfer(): ', async () => {tests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from '../substrate/privateKey';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';22import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';23import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';252433 const checkTreasury = 'Deposit';32 const checkTreasury = 'Deposit';34 const checkSystem = 'ExtrinsicSuccess';33 const checkSystem = 'ExtrinsicSuccess';35 before(async () => {34 before(async () => {36 await usingApi(async () => {35 await usingApi(async (api, privateKeyWrapper) => {37 alice = privateKey('//Alice');36 alice = privateKeyWrapper!('//Alice');38 bob = privateKey('//Bob');37 bob = privateKeyWrapper!('//Bob');39 });38 });40 });39 });41 it('Check event from transferFrom(): ', async () => {40 it('Check event from transferFrom(): ', async () => {tests/src/contracts.test.tsdiffbeforeafterboth505051describe.skip('Contracts', () => {51describe.skip('Contracts', () => {52 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {52 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {53 await usingApi(async api => {53 await usingApi(async (api, privateKeyWrapper) => {54 const [contract, deployer] = await deployFlipper(api);54 const [contract, deployer] = await deployFlipper(api);55 const initialGetResponse = await getFlipValue(contract, deployer);55 const initialGetResponse = await getFlipValue(contract, deployer);565657 const bob = privateKey('//Bob');57 const bob = privateKeyWrapper!('//Bob');58 const flip = contract.tx.flip(value, gasLimit);58 const flip = contract.tx.flip(value, gasLimit);59 await submitTransactionAsync(bob, flip);59 await submitTransactionAsync(bob, flip);6060767677describe.skip('Chain extensions', () => {77describe.skip('Chain extensions', () => {78 it('Transfer CE', async () => {78 it('Transfer CE', async () => {79 await usingApi(async api => {79 await usingApi(async (api, privateKeyWrapper) => {80 const alice = privateKey('//Alice');80 const alice = privateKeyWrapper!('//Alice');81 const bob = privateKey('//Bob');81 const bob = privateKeyWrapper!('//Bob');828283 // Prep work83 // Prep work84 const collectionId = await createCollectionExpectSuccess();84 const collectionId = await createCollectionExpectSuccess();100 });100 });101101102 it('Mint CE', async () => {102 it('Mint CE', async () => {103 await usingApi(async api => {103 await usingApi(async (api, privateKeyWrapper) => {104 const alice = privateKey('//Alice');104 const alice = privateKeyWrapper!('//Alice');105 const bob = privateKey('//Bob');105 const bob = privateKeyWrapper!('//Bob');106106107 const collectionId = await createCollectionExpectSuccess();107 const collectionId = await createCollectionExpectSuccess();108 const [contract] = await deployTransferContract(api);108 const [contract] = await deployTransferContract(api);127 });127 });128128129 it('Bulk mint CE', async () => {129 it('Bulk mint CE', async () => {130 await usingApi(async api => {130 await usingApi(async (api, privateKeyWrapper) => {131 const alice = privateKey('//Alice');131 const alice = privateKeyWrapper!('//Alice');132 const bob = privateKey('//Bob');132 const bob = privateKeyWrapper!('//Bob');133133134 const collectionId = await createCollectionExpectSuccess();134 const collectionId = await createCollectionExpectSuccess();135 const [contract] = await deployTransferContract(api);135 const [contract] = await deployTransferContract(api);168 });168 });169169170 it('Approve CE', async () => {170 it('Approve CE', async () => {171 await usingApi(async api => {171 await usingApi(async (api, privateKeyWrapper) => {172 const alice = privateKey('//Alice');172 const alice = privateKeyWrapper!('//Alice');173 const bob = privateKey('//Bob');173 const bob = privateKeyWrapper!('//Bob');174 const charlie = privateKey('//Charlie');174 const charlie = privateKeyWrapper!('//Charlie');175175176 const collectionId = await createCollectionExpectSuccess();176 const collectionId = await createCollectionExpectSuccess();177 const [contract] = await deployTransferContract(api);177 const [contract] = await deployTransferContract(api);187 });187 });188188189 it('TransferFrom CE', async () => {189 it('TransferFrom CE', async () => {190 await usingApi(async api => {190 await usingApi(async (api, privateKeyWrapper) => {191 const alice = privateKey('//Alice');191 const alice = privateKeyWrapper!('//Alice');192 const bob = privateKey('//Bob');192 const bob = privateKeyWrapper!('//Bob');193 const charlie = privateKey('//Charlie');193 const charlie = privateKeyWrapper!('//Charlie');194194195 const collectionId = await createCollectionExpectSuccess();195 const collectionId = await createCollectionExpectSuccess();196 const [contract] = await deployTransferContract(api);196 const [contract] = await deployTransferContract(api);208 });208 });209209210 it('ToggleAllowList CE', async () => {210 it('ToggleAllowList CE', async () => {211 await usingApi(async api => {211 await usingApi(async (api, privateKeyWrapper) => {212 const alice = privateKey('//Alice');212 const alice = privateKeyWrapper!('//Alice');213 const bob = privateKey('//Bob');213 const bob = privateKeyWrapper!('//Bob');214214215 const collectionId = await createCollectionExpectSuccess();215 const collectionId = await createCollectionExpectSuccess();216 const [contract] = await deployTransferContract(api);216 const [contract] = await deployTransferContract(api);tests/src/createCollection.test.tsdiffbeforeafterboth15// 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 {expect} from 'chai';17import {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';18import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';20import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';19import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';212058 });57 });595860 it('Create new collection with extra fields', async () => {59 it('Create new collection with extra fields', async () => {61 await usingApi(async api => {60 await usingApi(async (api, privateKeyWrapper) => {62 const alice = privateKey('//Alice');61 const alice = privateKeyWrapper!('//Alice');63 const bob = privateKey('//Bob');62 const bob = privateKeyWrapper!('//Bob');64 const tx = api.tx.unique.createCollectionEx({63 const tx = api.tx.unique.createCollectionEx({65 mode: {Fungible: 8},64 mode: {Fungible: 8},66 permissions: {65 permissions: {101 await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});100 await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});102 });101 });103 it('fails when bad limits are set', async () => {102 it('fails when bad limits are set', async () => {104 await usingApi(async api => {103 await usingApi(async (api, privateKeyWrapper) => {105 const alice = privateKey('//Alice');104 const alice = privateKeyWrapper!('//Alice');106 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});105 const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});107 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);106 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);108 });107 });tests/src/createMultipleItems.test.tsdiffbeforeafterboth18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';21import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';23import {22import {24 createCollectionExpectSuccess,23 createCollectionExpectSuccess,414042describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {41describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {43 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {42 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {44 await usingApi(async (api: ApiPromise) => {43 await usingApi(async (api, privateKeyWrapper) => {45 const collectionId = await createCollectionExpectSuccess();44 const collectionId = await createCollectionExpectSuccess();46 const itemsListIndexBefore = await getLastTokenId(api, collectionId);45 const itemsListIndexBefore = await getLastTokenId(api, collectionId);47 expect(itemsListIndexBefore).to.be.equal(0);46 expect(itemsListIndexBefore).to.be.equal(0);484749 const alice = privateKey('//Alice');48 const alice = privateKeyWrapper!('//Alice');50 await submitTransactionAsync(49 await submitTransactionAsync(51 alice, 50 alice, 52 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),51 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),73 });72 });747375 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {74 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {76 await usingApi(async (api: ApiPromise) => {75 await usingApi(async (api, privateKeyWrapper) => {77 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});76 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});78 const itemsListIndexBefore = await getLastTokenId(api, collectionId);77 const itemsListIndexBefore = await getLastTokenId(api, collectionId);79 expect(itemsListIndexBefore).to.be.equal(0);78 expect(itemsListIndexBefore).to.be.equal(0);80 const alice = privateKey('//Alice');79 const alice = privateKeyWrapper!('//Alice');81 const args = [80 const args = [82 {Fungible: {value: 1}},81 {Fungible: {value: 1}},83 {Fungible: {value: 2}},82 {Fungible: {value: 2}},93 });92 });949395 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {94 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {96 await usingApi(async (api: ApiPromise) => {95 await usingApi(async (api, privateKeyWrapper) => {97 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});96 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});98 const itemsListIndexBefore = await getLastTokenId(api, collectionId);97 const itemsListIndexBefore = await getLastTokenId(api, collectionId);99 expect(itemsListIndexBefore).to.be.equal(0);98 expect(itemsListIndexBefore).to.be.equal(0);100 const alice = privateKey('//Alice');99 const alice = privateKeyWrapper!('//Alice');101 const args = [100 const args = [102 {ReFungible: {pieces: 1}},101 {ReFungible: {pieces: 1}},103 {ReFungible: {pieces: 2}},102 {ReFungible: {pieces: 2}},116 });115 });117116118 it('Can mint amount of items equals to collection limits', async () => {117 it('Can mint amount of items equals to collection limits', async () => {119 await usingApi(async (api) => {118 await usingApi(async (api, privateKeyWrapper) => {120 const alice = privateKey('//Alice');119 const alice = privateKeyWrapper!('//Alice');121120122 const collectionId = await createCollectionExpectSuccess();121 const collectionId = await createCollectionExpectSuccess();123 await setCollectionLimitsExpectSuccess(alice, collectionId, {122 await setCollectionLimitsExpectSuccess(alice, collectionId, {135 });134 });136135137 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {136 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {138 await usingApi(async (api: ApiPromise) => {137 await usingApi(async (api, privateKeyWrapper) => {139 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});138 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});140 const itemsListIndexBefore = await getLastTokenId(api, collectionId);139 const itemsListIndexBefore = await getLastTokenId(api, collectionId);141 expect(itemsListIndexBefore).to.be.equal(0);140 expect(itemsListIndexBefore).to.be.equal(0);142 const alice = privateKey('//Alice');141 const alice = privateKeyWrapper!('//Alice');143 const args = [142 const args = [144 {NFT: {properties: [{key: 'k', value: 'v1'}]}},143 {NFT: {properties: [{key: 'k', value: 'v1'}]}},145 {NFT: {properties: [{key: 'k', value: 'v2'}]}},144 {NFT: {properties: [{key: 'k', value: 'v2'}]}},161 });160 });162161163 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {162 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {164 await usingApi(async (api: ApiPromise) => {163 await usingApi(async (api, privateKeyWrapper) => {165 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});164 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});166 const itemsListIndexBefore = await getLastTokenId(api, collectionId);165 const itemsListIndexBefore = await getLastTokenId(api, collectionId);167 expect(itemsListIndexBefore).to.be.equal(0);166 expect(itemsListIndexBefore).to.be.equal(0);168 const alice = privateKey('//Alice');167 const alice = privateKeyWrapper!('//Alice');169 const bob = privateKey('//Bob');168 const bob = privateKeyWrapper!('//Bob');170 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);169 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);171 const args = [170 const args = [172 {NFT: {properties: [{key: 'k', value: 'v1'}]}},171 {NFT: {properties: [{key: 'k', value: 'v1'}]}},189 });188 });190189191 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {190 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {192 await usingApi(async (api: ApiPromise) => {191 await usingApi(async (api, privateKeyWrapper) => {193 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});192 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});194 const itemsListIndexBefore = await getLastTokenId(api, collectionId);193 const itemsListIndexBefore = await getLastTokenId(api, collectionId);195 expect(itemsListIndexBefore).to.be.equal(0);194 expect(itemsListIndexBefore).to.be.equal(0);196 const alice = privateKey('//Alice');195 const alice = privateKeyWrapper!('//Alice');197 const args = [196 const args = [198 {NFT: {properties: [{key: 'k', value: 'v1'}]}},197 {NFT: {properties: [{key: 'k', value: 'v1'}]}},199 {NFT: {properties: [{key: 'k', value: 'v2'}]}},198 {NFT: {properties: [{key: 'k', value: 'v2'}]}},220 let bob: IKeyringPair;219 let bob: IKeyringPair;221220222 before(async () => {221 before(async () => {223 await usingApi(async () => {222 await usingApi(async (api, privateKeyWrapper) => {224 alice = privateKey('//Alice');223 alice = privateKeyWrapper!('//Alice');225 bob = privateKey('//Bob');224 bob = privateKeyWrapper!('//Bob');226 });225 });227 });226 });228227302 let bob: IKeyringPair;301 let bob: IKeyringPair;303302304 before(async () => {303 before(async () => {305 await usingApi(async () => {304 await usingApi(async (api, privateKeyWrapper) => {306 alice = privateKey('//Alice');305 alice = privateKeyWrapper!('//Alice');307 bob = privateKey('//Bob');306 bob = privateKeyWrapper!('//Bob');308 });307 });309 });308 });310309360 });359 });361360362 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {361 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {363 await usingApi(async (api: ApiPromise) => {362 await usingApi(async (api, privateKeyWrapper) => {364 // NFT363 // NFT365 const collectionId = await createCollectionWithPropsExpectSuccess({364 const collectionId = await createCollectionWithPropsExpectSuccess({366 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],365 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],367 });366 });368 const alice = privateKey('//Alice');367 const alice = privateKeyWrapper!('//Alice');369 const args = [368 const args = [370 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},369 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},371 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},370 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth15// 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 {expect} from 'chai';17import {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction} from './substrate/substrate-api';18import usingApi, {executeTransaction} from './substrate/substrate-api';20import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess} from './util/helpers';19import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess} from './util/helpers';212022describe('createMultipleItemsEx', () => {21describe('createMultipleItemsEx', () => {23 it('can initialize multiple NFT with different owners', async () => {22 it('can initialize multiple NFT with different owners', async () => {24 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});23 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});25 const alice = privateKey('//Alice');24 await usingApi(async (api, privateKeyWrapper) => {25 const alice = privateKeyWrapper!('//Alice');26 const bob = privateKey('//Bob');26 const bob = privateKeyWrapper!('//Bob');27 const charlie = privateKey('//Charlie');27 const charlie = privateKeyWrapper!('//Charlie');28 await usingApi(async (api) => {29 const data = [28 const data = [30 {29 {31 owner: {substrate: alice.address},30 owner: {substrate: alice.address},474648 it('createMultipleItemsEx with property Admin', async () => {47 it('createMultipleItemsEx with property Admin', async () => {49 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});48 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});50 const alice = privateKey('//Alice');49 await usingApi(async (api, privateKeyWrapper) => {50 const alice = privateKeyWrapper!('//Alice');51 const bob = privateKey('//Bob');51 const bob = privateKeyWrapper!('//Bob');52 const charlie = privateKey('//Charlie');52 const charlie = privateKeyWrapper!('//Charlie');53 await usingApi(async (api) => {54 const data = [53 const data = [55 {54 {56 owner: {substrate: alice.address},55 owner: {substrate: alice.address},757476 it('createMultipleItemsEx with property AdminConst', async () => {75 it('createMultipleItemsEx with property AdminConst', async () => {77 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});76 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});78 const alice = privateKey('//Alice');77 await usingApi(async (api, privateKeyWrapper) => {78 const alice = privateKeyWrapper!('//Alice');79 const bob = privateKey('//Bob');79 const bob = privateKeyWrapper!('//Bob');80 const charlie = privateKey('//Charlie');80 const charlie = privateKeyWrapper!('//Charlie');81 await usingApi(async (api) => {82 const data = [81 const data = [83 {82 {84 owner: {substrate: alice.address},83 owner: {substrate: alice.address},103102104 it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {103 it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {105 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});104 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});106 const alice = privateKey('//Alice');105 await usingApi(async (api, privateKeyWrapper) => {106 const alice = privateKeyWrapper!('//Alice');107 const bob = privateKey('//Bob');107 const bob = privateKeyWrapper!('//Bob');108 const charlie = privateKey('//Charlie');108 const charlie = privateKeyWrapper!('//Charlie');109 await usingApi(async (api) => {110 const data = [109 const data = [111 {110 {112 owner: {substrate: alice.address},111 owner: {substrate: alice.address},132 it('No editing rights', async () => {131 it('No editing rights', async () => {133 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],132 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],134 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});133 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});135 const alice = privateKey('//Alice');134 await usingApi(async (api, privateKeyWrapper) => {135 const alice = privateKeyWrapper!('//Alice');136 const bob = privateKey('//Bob');136 const bob = privateKeyWrapper!('//Bob');137 const charlie = privateKey('//Charlie');137 const charlie = privateKeyWrapper!('//Charlie');138 await addCollectionAdminExpectSuccess(alice, collection, bob.address);138 await addCollectionAdminExpectSuccess(alice, collection, bob.address);139 await usingApi(async (api) => {140 const data = [139 const data = [141 {140 {142 owner: {substrate: alice.address},141 owner: {substrate: alice.address},161 it('User doesnt have editing rights', async () => {160 it('User doesnt have editing rights', async () => {162 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],161 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],163 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});162 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});164 const alice = privateKey('//Alice');163 await usingApi(async (api, privateKeyWrapper) => {164 const alice = privateKeyWrapper!('//Alice');165 const bob = privateKey('//Bob');165 const bob = privateKeyWrapper!('//Bob');166 await addCollectionAdminExpectSuccess(alice, collection, bob.address);166 await addCollectionAdminExpectSuccess(alice, collection, bob.address);167 await usingApi(async (api) => {168 const data = [167 const data = [169 {168 {170 owner: {substrate: alice.address},169 owner: {substrate: alice.address},188187189 it('Adding property without access rights', async () => {188 it('Adding property without access rights', async () => {190 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});189 const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});191 const alice = privateKey('//Alice');190 await usingApi(async (api, privateKeyWrapper) => {191 const alice = privateKeyWrapper!('//Alice');192 const bob = privateKey('//Bob');192 const bob = privateKeyWrapper!('//Bob');193 const charlie = privateKey('//Charlie');193 const charlie = privateKeyWrapper!('//Charlie');194 await addCollectionAdminExpectSuccess(alice, collection, bob.address);194 await addCollectionAdminExpectSuccess(alice, collection, bob.address);195 await usingApi(async (api) => {196 const data = [195 const data = [197 {196 {198 owner: {substrate: alice.address},197 owner: {substrate: alice.address},220 propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});219 propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});221 }220 }222221223 const alice = privateKey('//Alice');224 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});222 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});225 await usingApi(async (api) => {223 await usingApi(async (api, privateKeyWrapper) => {224 const alice = privateKeyWrapper!('//Alice');226 await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);225 await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);227 });226 });228 });227 });229228230 it('Trying to add bigger property than allowed', async () => {229 it('Trying to add bigger property than allowed', async () => {231 const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});230 const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});232 const alice = privateKey('//Alice');231 await usingApi(async (api, privateKeyWrapper) => {232 const alice = privateKeyWrapper!('//Alice');233 const bob = privateKey('//Bob');233 const bob = privateKeyWrapper!('//Bob');234 const charlie = privateKey('//Charlie');234 const charlie = privateKeyWrapper!('//Charlie');235 await addCollectionAdminExpectSuccess(alice, collection, bob.address);235 await addCollectionAdminExpectSuccess(alice, collection, bob.address);236 await usingApi(async (api) => {237 const data = [236 const data = [238 {237 {239 owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],238 owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],253252254 it('can initialize multiple NFT with different owners', async () => {253 it('can initialize multiple NFT with different owners', async () => {255 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});254 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});256 const alice = privateKey('//Alice');255 await usingApi(async (api, privateKeyWrapper) => {256 const alice = privateKeyWrapper!('//Alice');257 const bob = privateKey('//Bob');257 const bob = privateKeyWrapper!('//Bob');258 const charlie = privateKey('//Charlie');258 const charlie = privateKeyWrapper!('//Charlie');259 await usingApi(async (api) => {260 const data = [259 const data = [261 {260 {262 owner: {substrate: alice.address},261 owner: {substrate: alice.address},278277279 it('can initialize multiple NFT with different owners', async () => {278 it('can initialize multiple NFT with different owners', async () => {280 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});279 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});281 const alice = privateKey('//Alice');280 await usingApi(async (api, privateKeyWrapper) => {281 const alice = privateKeyWrapper!('//Alice');282 const bob = privateKey('//Bob');282 const bob = privateKeyWrapper!('//Bob');283 const charlie = privateKey('//Charlie');283 const charlie = privateKeyWrapper!('//Charlie');284 await usingApi(async (api) => {285 const data = [284 const data = [286 {285 {287 owner: {substrate: alice.address},286 owner: {substrate: alice.address},303302304 it('fails when trying to set multiple owners when creating multiple refungibles', async () => {303 it('fails when trying to set multiple owners when creating multiple refungibles', async () => {305 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});304 const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});306 const alice = privateKey('//Alice');305 306 await usingApi(async (api, privateKeyWrapper) => {307 const alice = privateKeyWrapper!('//Alice');307 const bob = privateKey('//Bob');308 const bob = privateKeyWrapper!('//Bob');308309 await usingApi(async (api) => {310 // Polkadot requires map, and yet requires keys to be JSON encoded309 // Polkadot requires map, and yet requires keys to be JSON encoded311 const users = new Map();310 const users = new Map();312 users.set(JSON.stringify({substrate: alice.address}), 1);311 users.set(JSON.stringify({substrate: alice.address}), 1);tests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';21import {alicesPublicKey, bobsPublicKey} from './accounts';21import {alicesPublicKey, bobsPublicKey} from './accounts';22import privateKey from './substrate/privateKey';23import {IKeyringPair} from '@polkadot/types/types';22import {IKeyringPair} from '@polkadot/types/types';24import {23import {25 createCollectionExpectSuccess,24 createCollectionExpectSuccess,656466describe('integration test: Fees must be credited to Treasury:', () => {65describe('integration test: Fees must be credited to Treasury:', () => {67 before(async () => {66 before(async () => {68 await usingApi(async () => {67 await usingApi(async (api, privateKeyWrapper) => {69 alice = privateKey('//Alice');68 alice = privateKeyWrapper!('//Alice');70 bob = privateKey('//Bob');69 bob = privateKeyWrapper!('//Bob');71 });70 });72 });71 });737274 it('Total issuance does not change', async () => {73 it('Total issuance does not change', async () => {75 await usingApi(async (api) => {74 await usingApi(async (api, privateKeyWrapper) => {76 await skipInflationBlock(api);75 await skipInflationBlock(api);77 await waitNewBlocks(api, 1);76 await waitNewBlocks(api, 1);787779 const totalBefore = (await api.query.balances.totalIssuance()).toBigInt();78 const totalBefore = (await api.query.balances.totalIssuance()).toBigInt();807981 const alicePrivateKey = privateKey('//Alice');80 const alicePrivateKey = privateKeyWrapper!('//Alice');82 const amount = 1n;81 const amount = 1n;83 const transfer = api.tx.balances.transfer(bobsPublicKey, amount);82 const transfer = api.tx.balances.transfer(bobsPublicKey, amount);848392 });91 });939294 it('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async () => {93 it('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async () => {95 await usingApi(async (api) => {94 await usingApi(async (api, privateKeyWrapper) => {96 await skipInflationBlock(api);95 await skipInflationBlock(api);97 await waitNewBlocks(api, 1);96 await waitNewBlocks(api, 1);989799 const alicePrivateKey = privateKey('//Alice');98 const alicePrivateKey = privateKeyWrapper!('//Alice');100 const treasuryBalanceBefore: bigint = (await api.query.system.account(TREASURY)).data.free.toBigInt();99 const treasuryBalanceBefore: bigint = (await api.query.system.account(TREASURY)).data.free.toBigInt();101 const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();100 const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();102101115 });114 });116115117 it('Treasury balance increased by failed tx fee', async () => {116 it('Treasury balance increased by failed tx fee', async () => {118 await usingApi(async (api) => {117 await usingApi(async (api, privateKeyWrapper) => {119 //await skipInflationBlock(api);118 //await skipInflationBlock(api);120 await waitNewBlocks(api, 1);119 await waitNewBlocks(api, 1);121120122 const bobPrivateKey = privateKey('//Bob');121 const bobPrivateKey = privateKeyWrapper!('//Bob');123 const treasuryBalanceBefore = (await api.query.system.account(TREASURY)).data.free.toBigInt();122 const treasuryBalanceBefore = (await api.query.system.account(TREASURY)).data.free.toBigInt();124 const bobBalanceBefore = (await api.query.system.account(bobsPublicKey)).data.free.toBigInt();123 const bobBalanceBefore = (await api.query.system.account(bobsPublicKey)).data.free.toBigInt();125124tests/src/destroyCollection.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import {default as usingApi} from './substrate/substrate-api';20import {default as usingApi} from './substrate/substrate-api';22import {createCollectionExpectSuccess,21import {createCollectionExpectSuccess,23 destroyCollectionExpectSuccess,22 destroyCollectionExpectSuccess,50 let bob: IKeyringPair;49 let bob: IKeyringPair;515052 before(async () => {51 before(async () => {53 await usingApi(async () => {52 await usingApi(async (api, privateKeyWrapper) => {54 alice = privateKey('//Alice');53 alice = privateKeyWrapper!('//Alice');55 bob = privateKey('//Bob');54 bob = privateKeyWrapper!('//Bob');56 });55 });57 });56 });5857tests/src/enableContractSponsoring.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import usingApi from './substrate/substrate-api';20import usingApi from './substrate/substrate-api';22import {deployFlipper, getFlipValue, toggleFlipValueExpectSuccess} from './util/contracthelpers';21import {deployFlipper, getFlipValue, toggleFlipValueExpectSuccess} from './util/contracthelpers';23import {22import {79 let alice: IKeyringPair;78 let alice: IKeyringPair;807981 before(async () => {80 before(async () => {81 await usingApi(async (api, privateKeyWrapper) => {82 alice = privateKey('//Alice');82 alice = privateKeyWrapper!('//Alice');83 });83 });84 });848585 it('fails when called for non-contract address', async () => {86 it('fails when called for non-contract address', async () => {tests/src/enableDisableTransfer.test.tsdiffbeforeafterboth161617import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import privateKey from './substrate/privateKey';20import usingApi from './substrate/substrate-api';19import usingApi from './substrate/substrate-api';21import {20import {22 createItemExpectSuccess,21 createItemExpectSuccess,313032describe('Enable/Disable Transfers', () => {31describe('Enable/Disable Transfers', () => {33 it('User can transfer token with enabled transfer flag', async () => {32 it('User can transfer token with enabled transfer flag', async () => {34 await usingApi(async () => {33 await usingApi(async (api, privateKeyWrapper) => {35 const alice = privateKey('//Alice');34 const alice = privateKeyWrapper!('//Alice');36 const bob = privateKey('//Bob');35 const bob = privateKeyWrapper!('//Bob');37 // nft36 // nft38 const nftCollectionId = await createCollectionExpectSuccess();37 const nftCollectionId = await createCollectionExpectSuccess();39 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');38 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');46 });45 });474648 it('User can\'n transfer token with disabled transfer flag', async () => {47 it('User can\'n transfer token with disabled transfer flag', async () => {49 await usingApi(async () => {48 await usingApi(async (api, privateKeyWrapper) => {50 const alice = privateKey('//Alice');49 const alice = privateKeyWrapper!('//Alice');51 const bob = privateKey('//Bob');50 const bob = privateKeyWrapper!('//Bob');52 // nft51 // nft53 const nftCollectionId = await createCollectionExpectSuccess();52 const nftCollectionId = await createCollectionExpectSuccess();54 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');53 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');636264describe('Negative Enable/Disable Transfers', () => {63describe('Negative Enable/Disable Transfers', () => {65 it('Non-owner cannot change transfer flag', async () => {64 it('Non-owner cannot change transfer flag', async () => {66 await usingApi(async () => {65 await usingApi(async (api, privateKeyWrapper) => {67 const bob = privateKey('//Bob');66 const bob = privateKeyWrapper!('//Bob');68 // nft67 // nft69 const nftCollectionId = await createCollectionExpectSuccess();68 const nftCollectionId = await createCollectionExpectSuccess();7069tests/src/eth/base.test.tsdiffbeforeafterboth28import {expect} from 'chai';28import {expect} from 'chai';29import {createCollectionExpectSuccess, createItemExpectSuccess, UNIQUE} from '../util/helpers';29import {createCollectionExpectSuccess, createItemExpectSuccess, UNIQUE} from '../util/helpers';30import nonFungibleAbi from './nonFungibleAbi.json';30import nonFungibleAbi from './nonFungibleAbi.json';31import privateKey from '../substrate/privateKey';32import {Contract} from 'web3-eth-contract';31import {Contract} from 'web3-eth-contract';33import Web3 from 'web3';32import Web3 from 'web3';343350 expect(cost - balanceB < BigInt(0.2 * Number(UNIQUE))).to.be.true;49 expect(cost - balanceB < BigInt(0.2 * Number(UNIQUE))).to.be.true;51 });50 });525153 itWeb3('NFT transfer is close to 0.15 UNQ', async ({web3, api}) => {52 itWeb3('NFT transfer is close to 0.15 UNQ', async ({web3, api, privateKeyWrapper}) => {54 const caller = await createEthAccountWithBalance(api, web3);53 const caller = await createEthAccountWithBalance(api, web3);55 const receiver = createEthAccount(web3);54 const receiver = createEthAccount(web3);565557 const alice = privateKey('//Alice');56 const alice = privateKeyWrapper!('//Alice');58 const collection = await createCollectionExpectSuccess({57 const collection = await createCollectionExpectSuccess({59 mode: {type: 'NFT'},58 mode: {type: 'NFT'},60 });59 });tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth1import privateKey from '../substrate/privateKey';2import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess} from '../util/helpers';1import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess} from '../util/helpers';3import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';2import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';4import nonFungibleAbi from './nonFungibleAbi.json';3import nonFungibleAbi from './nonFungibleAbi.json';5import {expect} from 'chai';4import {expect} from 'chai';6import {executeTransaction} from '../substrate/substrate-api';5import {executeTransaction} from '../substrate/substrate-api';768describe('EVM collection properties', () => {7describe('EVM collection properties', () => {9 itWeb3('Can be set', async({web3, api}) => {8 itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {10 const alice = privateKey('//Alice');9 const alice = privateKeyWrapper!('//Alice');11 const caller = await createEthAccountWithBalance(api, web3);10 const caller = await createEthAccountWithBalance(api, web3);12 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});11 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});131221 const [{value}] = (await api.rpc.unique.collectionProperties(collection, ['testKey'])).toHuman()! as any;20 const [{value}] = (await api.rpc.unique.collectionProperties(collection, ['testKey'])).toHuman()! as any;22 expect(value).to.equal('testValue');21 expect(value).to.equal('testValue');23 });22 });24 itWeb3('Can be deleted', async({web3, api}) => {23 itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {25 const alice = privateKey('//Alice');24 const alice = privateKeyWrapper!('//Alice');26 const caller = await createEthAccountWithBalance(api, web3);25 const caller = await createEthAccountWithBalance(api, web3);27 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});26 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});282738 const result = (await api.rpc.unique.collectionProperties(collection, ['testKey'])).toJSON()! as any;37 const result = (await api.rpc.unique.collectionProperties(collection, ['testKey'])).toJSON()! as any;39 expect(result.length).to.equal(0);38 expect(result.length).to.equal(0);40 });39 });41 itWeb3('Can be read', async({web3, api}) => {40 itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {42 const alice = privateKey('//Alice');41 const alice = privateKeyWrapper!('//Alice');43 const caller = createEthAccount(web3);42 const caller = createEthAccount(web3);44 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});43 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});4544tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth1import privateKey from '../substrate/privateKey';2import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, setCollectionSponsorExpectSuccess} from '../util/helpers';1import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, setCollectionSponsorExpectSuccess} from '../util/helpers';3import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents} from './util/helpers';2import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents} from './util/helpers';4import nonFungibleAbi from './nonFungibleAbi.json';3import nonFungibleAbi from './nonFungibleAbi.json';5import {expect} from 'chai';4import {expect} from 'chai';657describe('evm collection sponsoring', () => {6describe('evm collection sponsoring', () => {8 itWeb3('sponsors mint transactions', async ({web3}) => {7 itWeb3('sponsors mint transactions', async ({web3, privateKeyWrapper}) => {9 const alice = privateKey('//Alice');8 const alice = privateKeyWrapper!('//Alice');10911 const collection = await createCollectionExpectSuccess();10 const collection = await createCollectionExpectSuccess();12 await setCollectionSponsorExpectSuccess(collection, alice.address);11 await setCollectionSponsorExpectSuccess(collection, alice.address);tests/src/eth/contractSponsoring.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 privateKey from '../substrate/privateKey';18import {expect} from 'chai';17import {expect} from 'chai';19import {18import {20 contractHelpers,19 contractHelpers,63 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;62 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;64 });63 });656466 itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3}) => {65 itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3, privateKeyWrapper}) => {67 const alice = privateKey('//Alice');66 const alice = privateKeyWrapper!('//Alice');686769 const owner = await createEthAccountWithBalance(api, web3);68 const owner = await createEthAccountWithBalance(api, web3);70 const caller = await createEthAccountWithBalance(api, web3);69 const caller = await createEthAccountWithBalance(api, web3);91 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);90 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);92 });91 });939294 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3}) => {93 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3, privateKeyWrapper}) => {95 const alice = privateKey('//Alice');94 const alice = privateKeyWrapper!('//Alice');969597 const owner = await createEthAccountWithBalance(api, web3);96 const owner = await createEthAccountWithBalance(api, web3);98 const caller = createEthAccount(web3);97 const caller = createEthAccount(web3);121 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);120 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);122 });121 });123122124 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3}) => {123 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3, privateKeyWrapper}) => {125 const alice = privateKey('//Alice');124 const alice = privateKeyWrapper!('//Alice');126125127 const owner = await createEthAccountWithBalance(api, web3);126 const owner = await createEthAccountWithBalance(api, web3);128 const caller = createEthAccount(web3);127 const caller = createEthAccount(web3);149 expect(+balanceAfter).to.be.equals(+originalFlipperBalance);148 expect(+balanceAfter).to.be.equals(+originalFlipperBalance);150 });149 });151150152 itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3}) => {151 itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3, privateKeyWrapper}) => {153 const alice = privateKey('//Alice');152 const alice = privateKeyWrapper!('//Alice');154153155 const owner = await createEthAccountWithBalance(api, web3);154 const owner = await createEthAccountWithBalance(api, web3);156 const caller = await createEthAccountWithBalance(api, web3);155 const caller = await createEthAccountWithBalance(api, web3);178 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);177 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);179 });178 });180179181 itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3}) => {180 itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3, privateKeyWrapper}) => {182 const alice = privateKey('//Alice');181 const alice = privateKeyWrapper!('//Alice');183182184 const owner = await createEthAccountWithBalance(api, web3);183 const owner = await createEthAccountWithBalance(api, web3);185 const caller = await createEthAccountWithBalance(api, web3);184 const caller = await createEthAccountWithBalance(api, web3);301 });300 });302301303 //TODO: CORE-302 add eth methods302 //TODO: CORE-302 add eth methods304 itWeb3.skip('Check that transaction via EVM spend money from substrate address', async ({api, web3}) => {303 itWeb3.skip('Check that transaction via EVM spend money from substrate address', async ({api, web3, privateKeyWrapper}) => {305 const owner = privateKey('//Alice');304 const owner = privateKeyWrapper!('//Alice');306 const user = privateKey(`//User/${Date.now()}`);305 const user = privateKeyWrapper!(`//User/${Date.now()}`);307 const userEth = subToEth(user.address);306 const userEth = subToEth(user.address);308 const collectionId = await createCollectionExpectSuccess();307 const collectionId = await createCollectionExpectSuccess();309 await addCollectionAdminExpectSuccess(owner, collectionId, {Ethereum: userEth});308 await addCollectionAdminExpectSuccess(owner, collectionId, {Ethereum: userEth});tests/src/eth/crossTransfer.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 privateKey from '../substrate/privateKey';18import {createCollectionExpectSuccess,17import {createCollectionExpectSuccess,19 createFungibleItemExpectSuccess,18 createFungibleItemExpectSuccess,20 transferExpectSuccess,19 transferExpectSuccess,28import nonFungibleAbi from './nonFungibleAbi.json';27import nonFungibleAbi from './nonFungibleAbi.json';292830describe('Token transfer between substrate address and EVM address. Fungible', () => {29describe('Token transfer between substrate address and EVM address. Fungible', () => {31 itWeb3('The private key X create a substrate address. Alice sends a token to the corresponding EVM address, and X can send it to Bob in the substrate', async () => {30 itWeb3('The private key X create a substrate address. Alice sends a token to the corresponding EVM address, and X can send it to Bob in the substrate', async ({privateKeyWrapper}) => {32 const collection = await createCollectionExpectSuccess({31 const collection = await createCollectionExpectSuccess({33 name: 'token name',32 name: 'token name',34 mode: {type: 'Fungible', decimalPoints: 0},33 mode: {type: 'Fungible', decimalPoints: 0},35 });34 });36 const alice = privateKey('//Alice');35 const alice = privateKeyWrapper!('//Alice');37 const bob = privateKey('//Bob');36 const bob = privateKeyWrapper!('//Bob');38 const charlie = privateKey('//Charlie');37 const charlie = privateKeyWrapper!('//Charlie');39 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});38 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});40 await transferExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)} , 200, 'Fungible');39 await transferExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)} , 200, 'Fungible');41 await transferFromExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');40 await transferFromExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');42 await transferExpectSuccess(collection, 0, charlie, bob, 50, 'Fungible');41 await transferExpectSuccess(collection, 0, charlie, bob, 50, 'Fungible');43 });42 });444345 itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({api, web3}) => {44 itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({api, web3, privateKeyWrapper}) => {46 const collection = await createCollectionExpectSuccess({45 const collection = await createCollectionExpectSuccess({47 name: 'token name',46 name: 'token name',48 mode: {type: 'Fungible', decimalPoints: 0},47 mode: {type: 'Fungible', decimalPoints: 0},49 });48 });50 const alice = privateKey('//Alice');49 const alice = privateKeyWrapper!('//Alice');51 const bob = privateKey('//Bob');50 const bob = privateKeyWrapper!('//Bob');52 const bobProxy = await createEthAccountWithBalance(api, web3);51 const bobProxy = await createEthAccountWithBalance(api, web3);53 const aliceProxy = await createEthAccountWithBalance(api, web3);52 const aliceProxy = await createEthAccountWithBalance(api, web3);545364});63});656466describe('Token transfer between substrate address and EVM address. NFT', () => {65describe('Token transfer between substrate address and EVM address. NFT', () => {67 itWeb3('The private key X create a substrate address. Alice sends a token to the corresponding EVM address, and X can send it to Bob in the substrate', async () => {66 itWeb3('The private key X create a substrate address. Alice sends a token to the corresponding EVM address, and X can send it to Bob in the substrate', async ({privateKeyWrapper}) => {68 const collection = await createCollectionExpectSuccess({67 const collection = await createCollectionExpectSuccess({69 name: 'token name',68 name: 'token name',70 mode: {type: 'NFT'},69 mode: {type: 'NFT'},71 });70 });72 const alice = privateKey('//Alice');71 const alice = privateKeyWrapper!('//Alice');73 const bob = privateKey('//Bob');72 const bob = privateKeyWrapper!('//Bob');74 const charlie = privateKey('//Charlie');73 const charlie = privateKeyWrapper!('//Charlie');75 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});74 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});76 await transferExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, 1, 'NFT');75 await transferExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, 1, 'NFT');77 await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');76 await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');78 await transferExpectSuccess(collection, tokenId, charlie, bob, 1, 'NFT');77 await transferExpectSuccess(collection, tokenId, charlie, bob, 1, 'NFT');79 });78 });807981 itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({api, web3}) => {80 itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({api, web3, privateKeyWrapper}) => {82 const collection = await createCollectionExpectSuccess({81 const collection = await createCollectionExpectSuccess({83 name: 'token name',82 name: 'token name',84 mode: {type: 'NFT'},83 mode: {type: 'NFT'},85 });84 });86 const alice = privateKey('//Alice');85 const alice = privateKeyWrapper!('//Alice');87 const bob = privateKey('//Bob');86 const bob = privateKeyWrapper!('//Bob');88 const charlie = privateKey('//Charlie');87 const charlie = privateKeyWrapper!('//Charlie');89 const bobProxy = await createEthAccountWithBalance(api, web3);88 const bobProxy = await createEthAccountWithBalance(api, web3);90 const aliceProxy = await createEthAccountWithBalance(api, web3);89 const aliceProxy = await createEthAccountWithBalance(api, web3);91 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});90 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});tests/src/eth/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 privateKey from '../substrate/privateKey';18import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';17import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';19import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';20import fungibleAbi from './fungibleAbi.json';19import fungibleAbi from './fungibleAbi.json';21import {expect} from 'chai';20import {expect} from 'chai';222123describe('Fungible: Information getting', () => {22describe('Fungible: Information getting', () => {24 itWeb3('totalSupply', async ({api, web3}) => {23 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {25 const collection = await createCollectionExpectSuccess({24 const collection = await createCollectionExpectSuccess({26 name: 'token name',25 name: 'token name',27 mode: {type: 'Fungible', decimalPoints: 0},26 mode: {type: 'Fungible', decimalPoints: 0},28 });27 });29 const alice = privateKey('//Alice');28 const alice = privateKeyWrapper!('//Alice');302931 const caller = await createEthAccountWithBalance(api, web3);30 const caller = await createEthAccountWithBalance(api, web3);323139 expect(totalSupply).to.equal('200');38 expect(totalSupply).to.equal('200');40 });39 });414042 itWeb3('balanceOf', async ({api, web3}) => {41 itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {43 const collection = await createCollectionExpectSuccess({42 const collection = await createCollectionExpectSuccess({44 name: 'token name',43 name: 'token name',45 mode: {type: 'Fungible', decimalPoints: 0},44 mode: {type: 'Fungible', decimalPoints: 0},46 });45 });47 const alice = privateKey('//Alice');46 const alice = privateKeyWrapper!('//Alice');484749 const caller = await createEthAccountWithBalance(api, web3);48 const caller = await createEthAccountWithBalance(api, web3);504959});58});605961describe('Fungible: Plain calls', () => {60describe('Fungible: Plain calls', () => {62 itWeb3('Can perform approve()', async ({web3, api}) => {61 itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {63 const collection = await createCollectionExpectSuccess({62 const collection = await createCollectionExpectSuccess({64 name: 'token name',63 name: 'token name',65 mode: {type: 'Fungible', decimalPoints: 0},64 mode: {type: 'Fungible', decimalPoints: 0},66 });65 });67 const alice = privateKey('//Alice');66 const alice = privateKeyWrapper!('//Alice');686769 const owner = await createEthAccountWithBalance(api, web3);68 const owner = await createEthAccountWithBalance(api, web3);706998 }97 }99 });98 });10099101 itWeb3('Can perform transferFrom()', async ({web3, api}) => {100 itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {102 const collection = await createCollectionExpectSuccess({101 const collection = await createCollectionExpectSuccess({103 name: 'token name',102 name: 'token name',104 mode: {type: 'Fungible', decimalPoints: 0},103 mode: {type: 'Fungible', decimalPoints: 0},105 });104 });106 const alice = privateKey('//Alice');105 const alice = privateKeyWrapper!('//Alice');107106108 const owner = createEthAccount(web3);107 const owner = createEthAccount(web3);109 await transferBalanceToEth(api, alice, owner);108 await transferBalanceToEth(api, alice, owner);156 }155 }157 });156 });158157159 itWeb3('Can perform transfer()', async ({web3, api}) => {158 itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {160 const collection = await createCollectionExpectSuccess({159 const collection = await createCollectionExpectSuccess({161 name: 'token name',160 name: 'token name',162 mode: {type: 'Fungible', decimalPoints: 0},161 mode: {type: 'Fungible', decimalPoints: 0},163 });162 });164 const alice = privateKey('//Alice');163 const alice = privateKeyWrapper!('//Alice');165164166 const owner = createEthAccount(web3);165 const owner = createEthAccount(web3);167 await transferBalanceToEth(api, alice, owner);166 await transferBalanceToEth(api, alice, owner);203});202});204203205describe('Fungible: Fees', () => {204describe('Fungible: Fees', () => {206 itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api}) => {205 itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {207 const collection = await createCollectionExpectSuccess({206 const collection = await createCollectionExpectSuccess({208 mode: {type: 'Fungible', decimalPoints: 0},207 mode: {type: 'Fungible', decimalPoints: 0},209 });208 });210 const alice = privateKey('//Alice');209 const alice = privateKeyWrapper!('//Alice');211210212 const owner = await createEthAccountWithBalance(api, web3);211 const owner = await createEthAccountWithBalance(api, web3);213 const spender = createEthAccount(web3);212 const spender = createEthAccount(web3);221 expect(cost < BigInt(0.2 * Number(UNIQUE)));220 expect(cost < BigInt(0.2 * Number(UNIQUE)));222 });221 });223222224 itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api}) => {223 itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {225 const collection = await createCollectionExpectSuccess({224 const collection = await createCollectionExpectSuccess({226 mode: {type: 'Fungible', decimalPoints: 0},225 mode: {type: 'Fungible', decimalPoints: 0},227 });226 });228 const alice = privateKey('//Alice');227 const alice = privateKeyWrapper!('//Alice');229228230 const owner = await createEthAccountWithBalance(api, web3);229 const owner = await createEthAccountWithBalance(api, web3);231 const spender = await createEthAccountWithBalance(api, web3);230 const spender = await createEthAccountWithBalance(api, web3);241 expect(cost < BigInt(0.2 * Number(UNIQUE)));240 expect(cost < BigInt(0.2 * Number(UNIQUE)));242 });241 });243242244 itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api}) => {243 itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {245 const collection = await createCollectionExpectSuccess({244 const collection = await createCollectionExpectSuccess({246 mode: {type: 'Fungible', decimalPoints: 0},245 mode: {type: 'Fungible', decimalPoints: 0},247 });246 });248 const alice = privateKey('//Alice');247 const alice = privateKeyWrapper!('//Alice');249248250 const owner = await createEthAccountWithBalance(api, web3);249 const owner = await createEthAccountWithBalance(api, web3);251 const receiver = createEthAccount(web3);250 const receiver = createEthAccount(web3);261});260});262261263describe('Fungible: Substrate calls', () => {262describe('Fungible: Substrate calls', () => {264 itWeb3('Events emitted for approve()', async ({web3}) => {263 itWeb3('Events emitted for approve()', async ({web3, privateKeyWrapper}) => {265 const collection = await createCollectionExpectSuccess({264 const collection = await createCollectionExpectSuccess({266 mode: {type: 'Fungible', decimalPoints: 0},265 mode: {type: 'Fungible', decimalPoints: 0},267 });266 });268 const alice = privateKey('//Alice');267 const alice = privateKeyWrapper!('//Alice');269268270 const receiver = createEthAccount(web3);269 const receiver = createEthAccount(web3);271270291 ]);290 ]);292 });291 });293292294 itWeb3('Events emitted for transferFrom()', async ({web3}) => {293 itWeb3('Events emitted for transferFrom()', async ({web3, privateKeyWrapper}) => {295 const collection = await createCollectionExpectSuccess({294 const collection = await createCollectionExpectSuccess({296 mode: {type: 'Fungible', decimalPoints: 0},295 mode: {type: 'Fungible', decimalPoints: 0},297 });296 });298 const alice = privateKey('//Alice');297 const alice = privateKeyWrapper!('//Alice');299 const bob = privateKey('//Bob');298 const bob = privateKeyWrapper!('//Bob');300299301 const receiver = createEthAccount(web3);300 const receiver = createEthAccount(web3);302301332 ]);331 ]);333 });332 });334333335 itWeb3('Events emitted for transfer()', async ({web3}) => {334 itWeb3('Events emitted for transfer()', async ({web3, privateKeyWrapper}) => {336 const collection = await createCollectionExpectSuccess({335 const collection = await createCollectionExpectSuccess({337 mode: {type: 'Fungible', decimalPoints: 0},336 mode: {type: 'Fungible', decimalPoints: 0},338 });337 });339 const alice = privateKey('//Alice');338 const alice = privateKeyWrapper!('//Alice');340339341 const receiver = createEthAccount(web3);340 const receiver = createEthAccount(web3);342341tests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth161617import {readFile} from 'fs/promises';17import {readFile} from 'fs/promises';18import {getBalanceSingle} from '../../substrate/get-balance';18import {getBalanceSingle} from '../../substrate/get-balance';19import privateKey from '../../substrate/privateKey';20import {19import {21 addToAllowListExpectSuccess, 20 addToAllowListExpectSuccess, 22 confirmSponsorshipExpectSuccess, 21 confirmSponsorshipExpectSuccess, 38const PRICE = 2000n;37const PRICE = 2000n;393840describe('Matcher contract usage', () => {39describe('Matcher contract usage', () => {41 itWeb3('With UNQ', async ({api, web3}) => {40 itWeb3('With UNQ', async ({api, web3, privateKeyWrapper}) => {42 const alice = privateKey('//Alice');41 const alice = privateKeyWrapper!('//Alice');43 const matcherOwner = await createEthAccountWithBalance(api, web3);42 const matcherOwner = await createEthAccountWithBalance(api, web3);44 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {43 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {45 from: matcherOwner,44 from: matcherOwner,61 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});60 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});62 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));61 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));636264 const seller = privateKey(`//Seller/${Date.now()}`);63 const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);65 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});64 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});666567 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);66 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);99 });98 });10099101100102 itWeb3('With escrow', async ({api, web3}) => {101 itWeb3('With escrow', async ({api, web3, privateKeyWrapper}) => {103 const alice = privateKey('//Alice');102 const alice = privateKeyWrapper!('//Alice');104 const matcherOwner = await createEthAccountWithBalance(api, web3);103 const matcherOwner = await createEthAccountWithBalance(api, web3);105 const escrow = await createEthAccountWithBalance(api, web3);104 const escrow = await createEthAccountWithBalance(api, web3);106 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {105 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {124 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});123 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});125 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));124 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));126125127 const seller = privateKey(`//Seller/${Date.now()}`);126 const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);128 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});127 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});129128130 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);129 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);170 });169 });171170172171173 itWeb3('Sell tokens from substrate user via EVM contract', async ({api, web3}) => {172 itWeb3('Sell tokens from substrate user via EVM contract', async ({api, web3, privateKeyWrapper}) => {174 const alice = privateKey('//Alice');173 const alice = privateKeyWrapper!('//Alice');175 const matcherOwner = await createEthAccountWithBalance(api, web3);174 const matcherOwner = await createEthAccountWithBalance(api, web3);176 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {175 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {177 from: matcherOwner,176 from: matcherOwner,184 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});183 await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});185 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});184 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});186185187 const seller = privateKey(`//Seller/${Date.now()}`);186 const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);188 await transferBalanceTo(api, alice, seller.address);187 await transferBalanceTo(api, alice, seller.address);189 188 190 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);189 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);tests/src/eth/migration.test.tsdiffbeforeafterboth15// 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 {expect} from 'chai';17import {expect} from 'chai';18import privateKey from '../substrate/privateKey';19import {submitTransactionAsync} from '../substrate/substrate-api';18import {submitTransactionAsync} from '../substrate/substrate-api';20import {createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';19import {createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';212022describe('EVM Migrations', () => {21describe('EVM Migrations', () => {23 itWeb3('Deploy contract saved state', async ({web3, api}) => {22 itWeb3('Deploy contract saved state', async ({web3, api, privateKeyWrapper}) => {24 /*23 /*25 contract StatefulContract {24 contract StatefulContract {26 uint counter;25 uint counter;54 ['0xedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b567643', '0x0000000000000000000000000000000000000000000000000000000000000004'],53 ['0xedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b567643', '0x0000000000000000000000000000000000000000000000000000000000000004'],55 ];54 ];565557 const alice = privateKey('//Alice');56 const alice = privateKeyWrapper!('//Alice');58 const caller = await createEthAccountWithBalance(api, web3);57 const caller = await createEthAccountWithBalance(api, web3);595860 await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS) as any));59 await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS) as any));tests/src/eth/nonFungible.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 privateKey from '../substrate/privateKey';18import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';17import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';19import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';20import nonFungibleAbi from './nonFungibleAbi.json';19import nonFungibleAbi from './nonFungibleAbi.json';21import {expect} from 'chai';20import {expect} from 'chai';22import {submitTransactionAsync} from '../substrate/substrate-api';21import {submitTransactionAsync} from '../substrate/substrate-api';232224describe('NFT: Information getting', () => {23describe('NFT: Information getting', () => {25 itWeb3('totalSupply', async ({api, web3}) => {24 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {26 const collection = await createCollectionExpectSuccess({25 const collection = await createCollectionExpectSuccess({27 mode: {type: 'NFT'},26 mode: {type: 'NFT'},28 });27 });29 const alice = privateKey('//Alice');28 const alice = privateKeyWrapper!('//Alice');30 const caller = await createEthAccountWithBalance(api, web3);29 const caller = await createEthAccountWithBalance(api, web3);313032 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});31 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});38 expect(totalSupply).to.equal('1');37 expect(totalSupply).to.equal('1');39 });38 });403941 itWeb3('balanceOf', async ({api, web3}) => {40 itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {42 const collection = await createCollectionExpectSuccess({41 const collection = await createCollectionExpectSuccess({43 mode: {type: 'NFT'},42 mode: {type: 'NFT'},44 });43 });45 const alice = privateKey('//Alice');44 const alice = privateKeyWrapper!('//Alice');464547 const caller = await createEthAccountWithBalance(api, web3);46 const caller = await createEthAccountWithBalance(api, web3);48 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum:caller});47 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum:caller});56 expect(balance).to.equal('3');55 expect(balance).to.equal('3');57 });56 });585759 itWeb3('ownerOf', async ({api, web3}) => {58 itWeb3('ownerOf', async ({api, web3, privateKeyWrapper}) => {60 const collection = await createCollectionExpectSuccess({59 const collection = await createCollectionExpectSuccess({61 mode: {type: 'NFT'},60 mode: {type: 'NFT'},62 });61 });63 const alice = privateKey('//Alice');62 const alice = privateKeyWrapper!('//Alice');646365 const caller = await createEthAccountWithBalance(api, web3);64 const caller = await createEthAccountWithBalance(api, web3);66 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});65 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});114 });113 });115114116 //TODO: CORE-302 add eth methods115 //TODO: CORE-302 add eth methods117 itWeb3.skip('Can perform mintBulk()', async ({web3, api}) => {116 itWeb3.skip('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {118 const collection = await createCollectionExpectSuccess({117 const collection = await createCollectionExpectSuccess({119 mode: {type: 'NFT'},118 mode: {type: 'NFT'},120 });119 });121 const alice = privateKey('//Alice');120 const alice = privateKeyWrapper!('//Alice');122121123 const caller = await createEthAccountWithBalance(api, web3);122 const caller = await createEthAccountWithBalance(api, web3);124 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});123 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});177 }176 }178 });177 });179178180 itWeb3('Can perform burn()', async ({web3, api}) => {179 itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {181 const collection = await createCollectionExpectSuccess({180 const collection = await createCollectionExpectSuccess({182 mode: {type: 'NFT'},181 mode: {type: 'NFT'},183 });182 });184 const alice = privateKey('//Alice');183 const alice = privateKeyWrapper!('//Alice');185184186 const owner = await createEthAccountWithBalance(api, web3);185 const owner = await createEthAccountWithBalance(api, web3);187186208 }207 }209 });208 });210209211 itWeb3('Can perform approve()', async ({web3, api}) => {210 itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {212 const collection = await createCollectionExpectSuccess({211 const collection = await createCollectionExpectSuccess({213 mode: {type: 'NFT'},212 mode: {type: 'NFT'},214 });213 });215 const alice = privateKey('//Alice');214 const alice = privateKeyWrapper!('//Alice');216215217 const owner = createEthAccount(web3);216 const owner = createEthAccount(web3);218 await transferBalanceToEth(api, alice, owner);217 await transferBalanceToEth(api, alice, owner);242 }241 }243 });242 });244243245 itWeb3('Can perform transferFrom()', async ({web3, api}) => {244 itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {246 const collection = await createCollectionExpectSuccess({245 const collection = await createCollectionExpectSuccess({247 mode: {type: 'NFT'},246 mode: {type: 'NFT'},248 });247 });249 const alice = privateKey('//Alice');248 const alice = privateKeyWrapper!('//Alice');250249251 const owner = createEthAccount(web3);250 const owner = createEthAccount(web3);252 await transferBalanceToEth(api, alice, owner);251 await transferBalanceToEth(api, alice, owner);290 }289 }291 });290 });292291293 itWeb3('Can perform transfer()', async ({web3, api}) => {292 itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {294 const collection = await createCollectionExpectSuccess({293 const collection = await createCollectionExpectSuccess({295 mode: {type: 'NFT'},294 mode: {type: 'NFT'},296 });295 });297 const alice = privateKey('//Alice');296 const alice = privateKeyWrapper!('//Alice');298297299 const owner = createEthAccount(web3);298 const owner = createEthAccount(web3);300 await transferBalanceToEth(api, alice, owner);299 await transferBalanceToEth(api, alice, owner);336});335});337336338describe('NFT: Fees', () => {337describe('NFT: Fees', () => {339 itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api}) => {338 itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {340 const collection = await createCollectionExpectSuccess({339 const collection = await createCollectionExpectSuccess({341 mode: {type: 'NFT'},340 mode: {type: 'NFT'},342 });341 });343 const alice = privateKey('//Alice');342 const alice = privateKeyWrapper!('//Alice');344343345 const owner = await createEthAccountWithBalance(api, web3);344 const owner = await createEthAccountWithBalance(api, web3);346 const spender = createEthAccount(web3);345 const spender = createEthAccount(web3);354 expect(cost < BigInt(0.2 * Number(UNIQUE)));353 expect(cost < BigInt(0.2 * Number(UNIQUE)));355 });354 });356355357 itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api}) => {356 itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {358 const collection = await createCollectionExpectSuccess({357 const collection = await createCollectionExpectSuccess({359 mode: {type: 'NFT'},358 mode: {type: 'NFT'},360 });359 });361 const alice = privateKey('//Alice');360 const alice = privateKeyWrapper!('//Alice');362361363 const owner = await createEthAccountWithBalance(api, web3);362 const owner = await createEthAccountWithBalance(api, web3);364 const spender = await createEthAccountWithBalance(api, web3);363 const spender = await createEthAccountWithBalance(api, web3);374 expect(cost < BigInt(0.2 * Number(UNIQUE)));373 expect(cost < BigInt(0.2 * Number(UNIQUE)));375 });374 });376375377 itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api}) => {376 itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {378 const collection = await createCollectionExpectSuccess({377 const collection = await createCollectionExpectSuccess({379 mode: {type: 'NFT'},378 mode: {type: 'NFT'},380 });379 });381 const alice = privateKey('//Alice');380 const alice = privateKeyWrapper!('//Alice');382381383 const owner = await createEthAccountWithBalance(api, web3);382 const owner = await createEthAccountWithBalance(api, web3);384 const receiver = createEthAccount(web3);383 const receiver = createEthAccount(web3);394});393});395394396describe('NFT: Substrate calls', () => {395describe('NFT: Substrate calls', () => {397 itWeb3('Events emitted for mint()', async ({web3}) => {396 itWeb3('Events emitted for mint()', async ({web3, privateKeyWrapper}) => {398 const collection = await createCollectionExpectSuccess({397 const collection = await createCollectionExpectSuccess({399 mode: {type: 'NFT'},398 mode: {type: 'NFT'},400 });399 });401 const alice = privateKey('//Alice');400 const alice = privateKeyWrapper!('//Alice');402401403 const address = collectionIdToAddress(collection);402 const address = collectionIdToAddress(collection);404 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);403 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);421 ]);420 ]);422 });421 });423422424 itWeb3('Events emitted for burn()', async ({web3}) => {423 itWeb3('Events emitted for burn()', async ({web3, privateKeyWrapper}) => {425 const collection = await createCollectionExpectSuccess({424 const collection = await createCollectionExpectSuccess({426 mode: {type: 'NFT'},425 mode: {type: 'NFT'},427 });426 });428 const alice = privateKey('//Alice');427 const alice = privateKeyWrapper!('//Alice');429428430 const address = collectionIdToAddress(collection);429 const address = collectionIdToAddress(collection);431 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);430 const contract = new web3.eth.Contract(nonFungibleAbi as any, address);448 ]);447 ]);449 });448 });450449451 itWeb3('Events emitted for approve()', async ({web3}) => {450 itWeb3('Events emitted for approve()', async ({web3, privateKeyWrapper}) => {452 const collection = await createCollectionExpectSuccess({451 const collection = await createCollectionExpectSuccess({453 mode: {type: 'NFT'},452 mode: {type: 'NFT'},454 });453 });455 const alice = privateKey('//Alice');454 const alice = privateKeyWrapper!('//Alice');456455457 const receiver = createEthAccount(web3);456 const receiver = createEthAccount(web3);458457478 ]);477 ]);479 });478 });480479481 itWeb3('Events emitted for transferFrom()', async ({web3}) => {480 itWeb3('Events emitted for transferFrom()', async ({web3, privateKeyWrapper}) => {482 const collection = await createCollectionExpectSuccess({481 const collection = await createCollectionExpectSuccess({483 mode: {type: 'NFT'},482 mode: {type: 'NFT'},484 });483 });485 const alice = privateKey('//Alice');484 const alice = privateKeyWrapper!('//Alice');486 const bob = privateKey('//Bob');485 const bob = privateKeyWrapper!('//Bob');487486488 const receiver = createEthAccount(web3);487 const receiver = createEthAccount(web3);489488510 ]);509 ]);511 });510 });512511513 itWeb3('Events emitted for transfer()', async ({web3}) => {512 itWeb3('Events emitted for transfer()', async ({web3, privateKeyWrapper}) => {514 const collection = await createCollectionExpectSuccess({513 const collection = await createCollectionExpectSuccess({515 mode: {type: 'NFT'},514 mode: {type: 'NFT'},516 });515 });517 const alice = privateKey('//Alice');516 const alice = privateKeyWrapper!('//Alice');518517519 const receiver = createEthAccount(web3);518 const receiver = createEthAccount(web3);520519tests/src/eth/payable.test.tsdiffbeforeafterboth15// 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 {expect} from 'chai';17import {expect} from 'chai';18import privateKey from '../substrate/privateKey';19import {submitTransactionAsync} from '../substrate/substrate-api';18import {submitTransactionAsync} from '../substrate/substrate-api';20import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';19import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';21import {evmToAddress} from '@polkadot/util-crypto';20import {evmToAddress} from '@polkadot/util-crypto';32 expect(await contract.methods.getCollected().call()).to.be.equal('10000');31 expect(await contract.methods.getCollected().call()).to.be.equal('10000');33 });32 });343335 itWeb3('Evm contract can receive wei from substrate account', async ({api, web3}) => {34 itWeb3('Evm contract can receive wei from substrate account', async ({api, web3, privateKeyWrapper}) => {36 const deployer = await createEthAccountWithBalance(api, web3);35 const deployer = await createEthAccountWithBalance(api, web3);37 const contract = await deployCollector(web3, deployer);36 const contract = await deployCollector(web3, deployer);38 const alice = privateKey('//Alice');37 const alice = privateKeyWrapper!('//Alice');393840 // Transaction fee/value will be payed from subToEth(sender) evm balance,39 // Transaction fee/value will be payed from subToEth(sender) evm balance,41 // which is backed by evmToAddress(subToEth(sender)) substrate balance40 // which is backed by evmToAddress(subToEth(sender)) substrate balance62 });61 });636264 // We can't handle sending balance to backing storage of evm balance, because evmToAddress operation is irreversible63 // We can't handle sending balance to backing storage of evm balance, because evmToAddress operation is irreversible65 itWeb3('Wei sent directly to backing storage of evm contract balance is unaccounted', async({api, web3}) => {64 itWeb3('Wei sent directly to backing storage of evm contract balance is unaccounted', async({api, web3, privateKeyWrapper}) => {66 const deployer = await createEthAccountWithBalance(api, web3);65 const deployer = await createEthAccountWithBalance(api, web3);67 const contract = await deployCollector(web3, deployer);66 const contract = await deployCollector(web3, deployer);68 const alice = privateKey('//Alice');67 const alice = privateKeyWrapper!('//Alice');696870 await transferBalanceExpectSuccess(api, alice, evmToAddress(contract.options.address), '10000');69 await transferBalanceExpectSuccess(api, alice, evmToAddress(contract.options.address), '10000');717072 expect(await contract.methods.getUnaccounted().call()).to.be.equal('10000');71 expect(await contract.methods.getUnaccounted().call()).to.be.equal('10000');73 });72 });747375 itWeb3('Balance can be retrieved from evm contract', async({api, web3}) => {74 itWeb3('Balance can be retrieved from evm contract', async({api, web3, privateKeyWrapper}) => {76 const FEE_BALANCE = 1000n * UNIQUE;75 const FEE_BALANCE = 1000n * UNIQUE;77 const CONTRACT_BALANCE = 1n * UNIQUE;76 const CONTRACT_BALANCE = 1n * UNIQUE;787779 const deployer = await createEthAccountWithBalance(api, web3);78 const deployer = await createEthAccountWithBalance(api, web3);80 const contract = await deployCollector(web3, deployer);79 const contract = await deployCollector(web3, deployer);81 const alice = privateKey('//Alice');80 const alice = privateKeyWrapper!('//Alice');828183 await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), ...GAS_ARGS});82 await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), ...GAS_ARGS});848385 const receiver = privateKey(`//Receiver${Date.now()}`);84 const receiver = privateKeyWrapper!(`//Receiver${Date.now()}`);868587 // First receive balance on eth balance of bob86 // First receive balance on eth balance of bob88 {87 {tests/src/eth/proxy/fungibleProxy.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 privateKey from '../../substrate/privateKey';18import {createCollectionExpectSuccess, createFungibleItemExpectSuccess} from '../../util/helpers';17import {createCollectionExpectSuccess, createFungibleItemExpectSuccess} from '../../util/helpers';19import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';20import fungibleAbi from '../fungibleAbi.json';19import fungibleAbi from '../fungibleAbi.json';35}34}363537describe('Fungible (Via EVM proxy): Information getting', () => {36describe('Fungible (Via EVM proxy): Information getting', () => {38 itWeb3('totalSupply', async ({api, web3}) => {37 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {39 const collection = await createCollectionExpectSuccess({38 const collection = await createCollectionExpectSuccess({40 name: 'token name',39 name: 'token name',41 mode: {type: 'Fungible', decimalPoints: 0},40 mode: {type: 'Fungible', decimalPoints: 0},42 });41 });43 const alice = privateKey('//Alice');42 const alice = privateKeyWrapper!('//Alice');44 const caller = await createEthAccountWithBalance(api, web3);43 const caller = await createEthAccountWithBalance(api, web3);454446 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});45 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});52 expect(totalSupply).to.equal('200');51 expect(totalSupply).to.equal('200');53 });52 });545355 itWeb3('balanceOf', async ({api, web3}) => {54 itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {56 const collection = await createCollectionExpectSuccess({55 const collection = await createCollectionExpectSuccess({57 name: 'token name',56 name: 'token name',58 mode: {type: 'Fungible', decimalPoints: 0},57 mode: {type: 'Fungible', decimalPoints: 0},59 });58 });60 const alice = privateKey('//Alice');59 const alice = privateKeyWrapper!('//Alice');61 const caller = await createEthAccountWithBalance(api, web3);60 const caller = await createEthAccountWithBalance(api, web3);626163 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: caller});62 await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: caller});71});70});727173describe('Fungible (Via EVM proxy): Plain calls', () => {72describe('Fungible (Via EVM proxy): Plain calls', () => {74 itWeb3('Can perform approve()', async ({web3, api}) => {73 itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {75 const collection = await createCollectionExpectSuccess({74 const collection = await createCollectionExpectSuccess({76 name: 'token name',75 name: 'token name',77 mode: {type: 'Fungible', decimalPoints: 0},76 mode: {type: 'Fungible', decimalPoints: 0},78 });77 });79 const alice = privateKey('//Alice');78 const alice = privateKeyWrapper!('//Alice');80 const caller = await createEthAccountWithBalance(api, web3);79 const caller = await createEthAccountWithBalance(api, web3);81 const spender = createEthAccount(web3);80 const spender = createEthAccount(web3);8281107 }106 }108 });107 });109108110 itWeb3('Can perform transferFrom()', async ({web3, api}) => {109 itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {111 const collection = await createCollectionExpectSuccess({110 const collection = await createCollectionExpectSuccess({112 name: 'token name',111 name: 'token name',113 mode: {type: 'Fungible', decimalPoints: 0},112 mode: {type: 'Fungible', decimalPoints: 0},114 });113 });115 const alice = privateKey('//Alice');114 const alice = privateKeyWrapper!('//Alice');116 const caller = await createEthAccountWithBalance(api, web3);115 const caller = await createEthAccountWithBalance(api, web3);117 const owner = await createEthAccountWithBalance(api, web3);116 const owner = await createEthAccountWithBalance(api, web3);118117162 }161 }163 });162 });164163165 itWeb3('Can perform transfer()', async ({web3, api}) => {164 itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {166 const collection = await createCollectionExpectSuccess({165 const collection = await createCollectionExpectSuccess({167 name: 'token name',166 name: 'token name',168 mode: {type: 'Fungible', decimalPoints: 0},167 mode: {type: 'Fungible', decimalPoints: 0},169 });168 });170 const alice = privateKey('//Alice');169 const alice = privateKeyWrapper!('//Alice');171 const caller = await createEthAccountWithBalance(api, web3);170 const caller = await createEthAccountWithBalance(api, web3);172 const receiver = await createEthAccountWithBalance(api, web3);171 const receiver = await createEthAccountWithBalance(api, web3);173172tests/src/eth/proxy/nonFungibleProxy.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 privateKey from '../../substrate/privateKey';18import {createCollectionExpectSuccess, createItemExpectSuccess} from '../../util/helpers';17import {createCollectionExpectSuccess, createItemExpectSuccess} from '../../util/helpers';19import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';20import nonFungibleAbi from '../nonFungibleAbi.json';19import nonFungibleAbi from '../nonFungibleAbi.json';36}35}373638describe('NFT (Via EVM proxy): Information getting', () => {37describe('NFT (Via EVM proxy): Information getting', () => {39 itWeb3('totalSupply', async ({api, web3}) => {38 itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {40 const collection = await createCollectionExpectSuccess({39 const collection = await createCollectionExpectSuccess({41 mode: {type: 'NFT'},40 mode: {type: 'NFT'},42 });41 });43 const alice = privateKey('//Alice');42 const alice = privateKeyWrapper!('//Alice');44 const caller = await createEthAccountWithBalance(api, web3);43 const caller = await createEthAccountWithBalance(api, web3);454446 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});45 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});52 expect(totalSupply).to.equal('1');51 expect(totalSupply).to.equal('1');53 });52 });545355 itWeb3('balanceOf', async ({api, web3}) => {54 itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {56 const collection = await createCollectionExpectSuccess({55 const collection = await createCollectionExpectSuccess({57 mode: {type: 'NFT'},56 mode: {type: 'NFT'},58 });57 });59 const alice = privateKey('//Alice');58 const alice = privateKeyWrapper!('//Alice');605961 const caller = await createEthAccountWithBalance(api, web3);60 const caller = await createEthAccountWithBalance(api, web3);62 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});61 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});70 expect(balance).to.equal('3');69 expect(balance).to.equal('3');71 });70 });727173 itWeb3('ownerOf', async ({api, web3}) => {72 itWeb3('ownerOf', async ({api, web3, privateKeyWrapper}) => {74 const collection = await createCollectionExpectSuccess({73 const collection = await createCollectionExpectSuccess({75 mode: {type: 'NFT'},74 mode: {type: 'NFT'},76 });75 });77 const alice = privateKey('//Alice');76 const alice = privateKeyWrapper!('//Alice');787779 const caller = await createEthAccountWithBalance(api, web3);78 const caller = await createEthAccountWithBalance(api, web3);80 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});79 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});898890describe('NFT (Via EVM proxy): Plain calls', () => {89describe('NFT (Via EVM proxy): Plain calls', () => {91 //TODO: CORE-302 add eth methods90 //TODO: CORE-302 add eth methods92 itWeb3.skip('Can perform mint()', async ({web3, api}) => {91 itWeb3.skip('Can perform mint()', async ({web3, api, privateKeyWrapper}) => {93 const collection = await createCollectionExpectSuccess({92 const collection = await createCollectionExpectSuccess({94 mode: {type: 'NFT'},93 mode: {type: 'NFT'},95 });94 });96 const alice = privateKey('//Alice');95 const alice = privateKeyWrapper!('//Alice');97 const caller = await createEthAccountWithBalance(api, web3);96 const caller = await createEthAccountWithBalance(api, web3);98 const receiver = createEthAccount(web3);97 const receiver = createEthAccount(web3);9998130 });129 });131 130 132 //TODO: CORE-302 add eth methods131 //TODO: CORE-302 add eth methods133 itWeb3.skip('Can perform mintBulk()', async ({web3, api}) => {132 itWeb3.skip('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {134 const collection = await createCollectionExpectSuccess({133 const collection = await createCollectionExpectSuccess({135 mode: {type: 'NFT'},134 mode: {type: 'NFT'},136 });135 });137 const alice = privateKey('//Alice');136 const alice = privateKeyWrapper!('//Alice');138137139 const caller = await createEthAccountWithBalance(api, web3);138 const caller = await createEthAccountWithBalance(api, web3);140 const receiver = createEthAccount(web3);139 const receiver = createEthAccount(web3);193 }192 }194 });193 });195194196 itWeb3('Can perform burn()', async ({web3, api}) => {195 itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {197 const collection = await createCollectionExpectSuccess({196 const collection = await createCollectionExpectSuccess({198 mode: {type: 'NFT'},197 mode: {type: 'NFT'},199 });198 });200 const alice = privateKey('//Alice');199 const alice = privateKeyWrapper!('//Alice');201 const caller = await createEthAccountWithBalance(api, web3);200 const caller = await createEthAccountWithBalance(api, web3);202201203 const address = collectionIdToAddress(collection);202 const address = collectionIdToAddress(collection);225 }224 }226 });225 });227226228 itWeb3('Can perform approve()', async ({web3, api}) => {227 itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {229 const collection = await createCollectionExpectSuccess({228 const collection = await createCollectionExpectSuccess({230 mode: {type: 'NFT'},229 mode: {type: 'NFT'},231 });230 });232 const alice = privateKey('//Alice');231 const alice = privateKeyWrapper!('//Alice');233 const caller = await createEthAccountWithBalance(api, web3);232 const caller = await createEthAccountWithBalance(api, web3);234 const spender = createEthAccount(web3);233 const spender = createEthAccount(web3);235234255 }254 }256 });255 });257256258 itWeb3('Can perform transferFrom()', async ({web3, api}) => {257 itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {259 const collection = await createCollectionExpectSuccess({258 const collection = await createCollectionExpectSuccess({260 mode: {type: 'NFT'},259 mode: {type: 'NFT'},261 });260 });262 const alice = privateKey('//Alice');261 const alice = privateKeyWrapper!('//Alice');263 const caller = await createEthAccountWithBalance(api, web3);262 const caller = await createEthAccountWithBalance(api, web3);264 const owner = await createEthAccountWithBalance(api, web3);263 const owner = await createEthAccountWithBalance(api, web3);265264299 }298 }300 });299 });301300302 itWeb3('Can perform transfer()', async ({web3, api}) => {301 itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {303 const collection = await createCollectionExpectSuccess({302 const collection = await createCollectionExpectSuccess({304 mode: {type: 'NFT'},303 mode: {type: 'NFT'},305 });304 });306 const alice = privateKey('//Alice');305 const alice = privateKeyWrapper!('//Alice');307 const caller = await createEthAccountWithBalance(api, web3);306 const caller = await createEthAccountWithBalance(api, web3);308 const receiver = createEthAccount(web3);307 const receiver = createEthAccount(web3);309308tests/src/eth/sponsoring.test.tsdiffbeforeafterboth15// 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 {expect} from 'chai';17import {expect} from 'chai';18import privateKey from '../substrate/privateKey';19import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployCollector, deployFlipper, itWeb3, SponsoringMode, transferBalanceToEth} from './util/helpers';18import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployCollector, deployFlipper, itWeb3, SponsoringMode, transferBalanceToEth} from './util/helpers';201921describe('EVM sponsoring', () => {20describe('EVM sponsoring', () => {22 itWeb3('Fee is deducted from contract if sponsoring is enabled', async ({api, web3}) => {21 itWeb3('Fee is deducted from contract if sponsoring is enabled', async ({api, web3, privateKeyWrapper}) => {23 const alice = privateKey('//Alice');22 const alice = privateKeyWrapper!('//Alice');242325 const owner = await createEthAccountWithBalance(api, web3);24 const owner = await createEthAccountWithBalance(api, web3);26 const caller = createEthAccount(web3);25 const caller = createEthAccount(web3);50 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);49 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);51 expect(await web3.eth.getBalance(flipper.options.address)).to.be.not.equals(originalFlipperBalance);50 expect(await web3.eth.getBalance(flipper.options.address)).to.be.not.equals(originalFlipperBalance);52 });51 });53 itWeb3('...but this doesn\'t applies to payable value', async ({api, web3}) => {52 itWeb3('...but this doesn\'t applies to payable value', async ({api, web3, privateKeyWrapper}) => {54 const alice = privateKey('//Alice');53 const alice = privateKeyWrapper!('//Alice');555456 const owner = await createEthAccountWithBalance(api, web3);55 const owner = await createEthAccountWithBalance(api, web3);57 const caller = await createEthAccountWithBalance(api, web3);56 const caller = await createEthAccountWithBalance(api, web3);tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth1import privateKey from '../substrate/privateKey';2import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess} from '../util/helpers';1import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess} from '../util/helpers';3import {cartesian, collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';2import {cartesian, collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';4import nonFungibleAbi from './nonFungibleAbi.json';3import nonFungibleAbi from './nonFungibleAbi.json';5import {expect} from 'chai';4import {expect} from 'chai';6import {executeTransaction} from '../substrate/substrate-api';5import {executeTransaction} from '../substrate/substrate-api';768describe('EVM token properties', () => {7describe('EVM token properties', () => {9 itWeb3('Can be reconfigured', async({web3, api}) => {8 itWeb3('Can be reconfigured', async({web3, api, privateKeyWrapper}) => {10 const alice = privateKey('//Alice');9 const alice = privateKeyWrapper!('//Alice');11 const caller = await createEthAccountWithBalance(api, web3);10 const caller = await createEthAccountWithBalance(api, web3);12 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {11 for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {13 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});12 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});24 });23 });25 }24 }26 });25 });27 itWeb3('Can be set', async({web3, api}) => {26 itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {28 const alice = privateKey('//Alice');27 const alice = privateKeyWrapper!('//Alice');29 const caller = await createEthAccountWithBalance(api, web3);28 const caller = await createEthAccountWithBalance(api, web3);30 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});29 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});31 const token = await createItemExpectSuccess(alice, collection, 'NFT');30 const token = await createItemExpectSuccess(alice, collection, 'NFT');47 const [{value}] = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toHuman()! as any;46 const [{value}] = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toHuman()! as any;48 expect(value).to.equal('testValue');47 expect(value).to.equal('testValue');49 });48 });50 itWeb3('Can be deleted', async({web3, api}) => {49 itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {51 const alice = privateKey('//Alice');50 const alice = privateKeyWrapper!('//Alice');52 const caller = await createEthAccountWithBalance(api, web3);51 const caller = await createEthAccountWithBalance(api, web3);53 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});52 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});54 const token = await createItemExpectSuccess(alice, collection, 'NFT');53 const token = await createItemExpectSuccess(alice, collection, 'NFT');72 const result = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toJSON()! as any;71 const result = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toJSON()! as any;73 expect(result.length).to.equal(0);72 expect(result.length).to.equal(0);74 });73 });75 itWeb3('Can be read', async({web3, api}) => {74 itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {76 const alice = privateKey('//Alice');75 const alice = privateKeyWrapper!('//Alice');77 const caller = createEthAccount(web3);76 const caller = createEthAccount(web3);78 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});77 const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});79 const token = await createItemExpectSuccess(alice, collection, 'NFT');78 const token = await createItemExpectSuccess(alice, collection, 'NFT');tests/src/eth/util/helpers.tsdiffbeforeafterboth18/// <reference path="helpers.d.ts" />18/// <reference path="helpers.d.ts" />191920import {ApiPromise} from '@polkadot/api';20import {ApiPromise} from '@polkadot/api';21import {IKeyringPair} from '@polkadot/types/types';21import {addressToEvm, evmToAddress} from '@polkadot/util-crypto';22import {addressToEvm, evmToAddress} from '@polkadot/util-crypto';22import Web3 from 'web3';23import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';24import {IKeyringPair} from '@polkadot/types/types';25import {expect} from 'chai';23import {expect} from 'chai';26import {CrossAccountId, getDetailedCollectionInfo, getGenericResult, UNIQUE} from '../../util/helpers';27import * as solc from 'solc';24import * as solc from 'solc';25import Web3 from 'web3';28import config from '../../config';26import config from '../../config';27import getBalance from '../../substrate/get-balance';29import privateKey from '../../substrate/privateKey';28import privateKey from '../../substrate/privateKey';30import contractHelpersAbi from './contractHelpersAbi.json';29import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';30import waitNewBlocks from '../../substrate/wait-new-blocks';31import nonFungibleAbi from '../nonFungibleAbi.json';31import {CrossAccountId, getDetailedCollectionInfo, getGenericResult, UNIQUE} from '../../util/helpers';32import collectionHelpersAbi from '../collectionHelpersAbi.json';32import collectionHelpersAbi from '../collectionHelpersAbi.json';33import getBalance from '../../substrate/get-balance';33import nonFungibleAbi from '../nonFungibleAbi.json';34import waitNewBlocks from '../../substrate/wait-new-blocks';34import contractHelpersAbi from './contractHelpersAbi.json';353536export const GAS_ARGS = {gas: 2500000};36export const GAS_ARGS = {gas: 2500000};3737139 });139 });140 });140 });141}141}142itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, {only: true});142itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {only: true});143itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, {skip: true});143itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {skip: true});144144145export async function generateSubstrateEthPair(web3: Web3) {145export async function generateSubstrateEthPair(web3: Web3) {146 const account = web3.eth.accounts.create();146 const account = web3.eth.accounts.create();tests/src/inflation.test.tsdiffbeforeafterboth17import 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';19import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import privateKey from './substrate/privateKey';212022chai.use(chaiAsPromised);21chai.use(chaiAsPromised);23const expect = chai.expect;22const expect = chai.expect;242325describe('integration test: Inflation', () => {24describe('integration test: Inflation', () => {26 it('First year inflation is 10%', async () => {25 it('First year inflation is 10%', async () => {27 await usingApi(async (api) => {26 await usingApi(async (api, privateKeyWrapper) => {282729 // Make sure non-sudo can't start inflation28 // Make sure non-sudo can't start inflation30 const tx = api.tx.inflation.startInflation(1);29 const tx = api.tx.inflation.startInflation(1);31 const bob = privateKey('//Bob');30 const bob = privateKeyWrapper!('//Bob');32 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;31 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;333234 // Start inflation on relay block 1 (Alice is sudo)33 // Start inflation on relay block 1 (Alice is sudo)35 const alice = privateKey('//Alice');34 const alice = privateKeyWrapper!('//Alice');36 const sudoTx = api.tx.sudo.sudo(tx as any);35 const sudoTx = api.tx.sudo.sudo(tx as any);37 await submitTransactionAsync(alice, sudoTx);36 await submitTransactionAsync(alice, sudoTx);3837tests/src/limits.test.tsdiffbeforeafterboth15// 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 {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import privateKey from './substrate/privateKey';19import usingApi from './substrate/substrate-api';18import usingApi from './substrate/substrate-api';20import {19import {21 createCollectionExpectSuccess,20 createCollectionExpectSuccess,35 let alice: IKeyringPair;34 let alice: IKeyringPair;363537 before(async () => {36 before(async () => {38 await usingApi(async () => {37 await usingApi(async (api, privateKeyWrapper) => {39 alice = privateKey('//Alice');38 alice = privateKeyWrapper!('//Alice');40 });39 });41 });40 });424169 let alice: IKeyringPair;68 let alice: IKeyringPair;706971 before(async () => {70 before(async () => {72 await usingApi(async () => {71 await usingApi(async (api, privateKeyWrapper) => {73 alice = privateKey('//Alice');72 alice = privateKeyWrapper!('//Alice');74 });73 });75 });74 });7675103 let charlie: IKeyringPair;102 let charlie: IKeyringPair;104103105 before(async () => {104 before(async () => {106 await usingApi(async () => {105 await usingApi(async (api, privateKeyWrapper) => {107 alice = privateKey('//Alice');106 alice = privateKeyWrapper!('//Alice');108 bob = privateKey('//Bob');107 bob = privateKeyWrapper!('//Bob');109 charlie = privateKey('//Charlie');108 charlie = privateKeyWrapper!('//Charlie');110 });109 });111 });110 });112111166 let charlie: IKeyringPair;165 let charlie: IKeyringPair;167166168 before(async () => {167 before(async () => {169 await usingApi(async () => {168 await usingApi(async (api, privateKeyWrapper) => {170 alice = privateKey('//Alice');169 alice = privateKeyWrapper!('//Alice');171 bob = privateKey('//Bob');170 bob = privateKeyWrapper!('//Bob');172 charlie = privateKey('//Charlie');171 charlie = privateKeyWrapper!('//Charlie');173 });172 });174 });173 });175174233 let charlie: IKeyringPair;232 let charlie: IKeyringPair;234233235 before(async () => {234 before(async () => {236 await usingApi(async () => {235 await usingApi(async (api, privateKeyWrapper) => {237 alice = privateKey('//Alice');236 alice = privateKeyWrapper!('//Alice');238 bob = privateKey('//Bob');237 bob = privateKeyWrapper!('//Bob');239 charlie = privateKey('//Charlie');238 charlie = privateKeyWrapper!('//Charlie');240 });239 });241 });240 });242241296 let charlie: IKeyringPair;295 let charlie: IKeyringPair;297296298 before(async () => {297 before(async () => {299 await usingApi(async () => {298 await usingApi(async (api, privateKeyWrapper) => {300 alice = privateKey('//Alice');299 alice = privateKeyWrapper!('//Alice');301 bob = privateKey('//Bob');300 bob = privateKeyWrapper!('//Bob');302 charlie = privateKey('//Charlie');301 charlie = privateKeyWrapper!('//Charlie');303 });302 });304 });303 });305304337 let charlie: IKeyringPair;336 let charlie: IKeyringPair;338337339 before(async () => {338 before(async () => {340 await usingApi(async () => {339 await usingApi(async (api, privateKeyWrapper) => {341 alice = privateKey('//Alice');340 alice = privateKeyWrapper!('//Alice');342 bob = privateKey('//Bob');341 bob = privateKeyWrapper!('//Bob');343 charlie = privateKey('//Charlie');342 charlie = privateKeyWrapper!('//Charlie');344 });343 });345 });344 });346345369 let charlie: IKeyringPair;368 let charlie: IKeyringPair;370369371 before(async () => {370 before(async () => {372 await usingApi(async () => {371 await usingApi(async (api, privateKeyWrapper) => {373 alice = privateKey('//Alice');372 alice = privateKeyWrapper!('//Alice');374 bob = privateKey('//Bob');373 bob = privateKeyWrapper!('//Bob');375 charlie = privateKey('//Charlie');374 charlie = privateKeyWrapper!('//Charlie');376 });375 });377 });376 });378377tests/src/mintModes.test.tsdiffbeforeafterboth15// 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 {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import privateKey from './substrate/privateKey';19import usingApi from './substrate/substrate-api';18import usingApi from './substrate/substrate-api';20import {19import {21 addToAllowListExpectSuccess,20 addToAllowListExpectSuccess,33 let bob: IKeyringPair;32 let bob: IKeyringPair;343335 before(async () => {34 before(async () => {36 await usingApi(async () => {35 await usingApi(async (api, privateKeyWrapper) => {37 alice = privateKey('//Alice');36 alice = privateKeyWrapper!('//Alice');38 bob = privateKey('//Bob');37 bob = privateKeyWrapper!('//Bob');39 });38 });40 });39 });4140112 let bob: IKeyringPair;111 let bob: IKeyringPair;113112114 before(async () => {113 before(async () => {115 await usingApi(async () => {114 await usingApi(async (api, privateKeyWrapper) => {116 alice = privateKey('//Alice');115 alice = privateKeyWrapper!('//Alice');117 bob = privateKey('//Bob');116 bob = privateKeyWrapper!('//Bob');118 });117 });119 });118 });120119tests/src/nesting/graphs.test.tsdiffbeforeafterboth2import {IKeyringPair} from '@polkadot/types/types';2import {IKeyringPair} from '@polkadot/types/types';3import {expect} from 'chai';3import {expect} from 'chai';4import {tokenIdToCross} from '../eth/util/helpers';4import {tokenIdToCross} from '../eth/util/helpers';5import privateKey from '../substrate/privateKey';6import usingApi, {executeTransaction} from '../substrate/substrate-api';5import usingApi, {executeTransaction} from '../substrate/substrate-api';7import {getCreateCollectionResult, transferExpectSuccess} from '../util/helpers';6import {getCreateCollectionResult, transferExpectSuccess} from '../util/helpers';87343335describe('Graphs', () => {34describe('Graphs', () => {36 it('Ouroboros can\'t be created in a complex graph', async () => {35 it('Ouroboros can\'t be created in a complex graph', async () => {37 await usingApi(async api => {36 await usingApi(async (api, privateKeyWrapper) => {38 const alice = privateKey('//Alice');37 const alice = privateKeyWrapper!('//Alice');39 const collection = await buildComplexObjectGraph(api, alice);38 const collection = await buildComplexObjectGraph(api, alice);403941 // to self40 // to selftests/src/nesting/migration-check.test.tsdiffbeforeafterboth1import {expect} from 'chai';1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';2import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';4import {getCreateCollectionResult} from '../util/helpers';3import {getCreateCollectionResult} from '../util/helpers';5import {IKeyringPair} from '@polkadot/types/types';4import {IKeyringPair} from '@polkadot/types/types';13 let alice: IKeyringPair;12 let alice: IKeyringPair;141315 before(async() => {14 before(async() => {16 await usingApi(async () => {15 await usingApi(async (api, privateKeyWrapper) => {17 alice = privateKey('//Alice');16 alice = privateKeyWrapper!('//Alice');18 });17 });19 });18 });2019tests/src/nesting/nest.test.tsdiffbeforeafterboth1import {expect} from 'chai';1import {expect} from 'chai';2import {tokenIdToAddress} from '../eth/util/helpers';2import {tokenIdToAddress} from '../eth/util/helpers';3import privateKey from '../substrate/privateKey';4import usingApi, {executeTransaction} from '../substrate/substrate-api';3import usingApi, {executeTransaction} from '../substrate/substrate-api';5import {4import {6 addToAllowListExpectSuccess,5 addToAllowListExpectSuccess,232224describe('Integration Test: Nesting', () => {23describe('Integration Test: Nesting', () => {25 before(async () => {24 before(async () => {26 await usingApi(async () => {25 await usingApi(async (api, privateKeyWrapper) => {27 alice = privateKey('//Alice');26 alice = privateKeyWrapper!('//Alice');28 bob = privateKey('//Bob');27 bob = privateKeyWrapper!('//Bob');29 });28 });30 });29 });3130226225227describe('Negative Test: Nesting', async() => {226describe('Negative Test: Nesting', async() => {228 before(async () => {227 before(async () => {229 await usingApi(async () => {228 await usingApi(async (api, privateKeyWrapper) => {230 alice = privateKey('//Alice');229 alice = privateKeyWrapper!('//Alice');231 bob = privateKey('//Bob');230 bob = privateKeyWrapper!('//Bob');232 });231 });233 });232 });234233tests/src/nesting/properties.test.tsdiffbeforeafterboth1import {expect} from 'chai';1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import usingApi, {executeTransaction} from '../substrate/substrate-api';2import usingApi, {executeTransaction} from '../substrate/substrate-api';4import {3import {5 addCollectionAdminExpectSuccess,4 addCollectionAdminExpectSuccess,161517describe('Composite Properties Test', () => {16describe('Composite Properties Test', () => {18 before(async () => {17 before(async () => {19 await usingApi(async () => {18 await usingApi(async (api, privateKeyWrapper) => {20 alice = privateKey('//Alice');19 alice = privateKeyWrapper!('//Alice');21 bob = privateKey('//Bob');20 bob = privateKeyWrapper!('//Bob');22 });21 });23 });22 });2423636264describe('Integration Test: Collection Properties', () => {63describe('Integration Test: Collection Properties', () => {65 before(async () => {64 before(async () => {66 await usingApi(async () => {65 await usingApi(async (api, privateKeyWrapper) => {67 alice = privateKey('//Alice');66 alice = privateKeyWrapper!('//Alice');68 bob = privateKey('//Bob');67 bob = privateKeyWrapper!('//Bob');69 });68 });70 });69 });7170158157159describe('Negative Integration Test: Collection Properties', () => {158describe('Negative Integration Test: Collection Properties', () => {160 before(async () => {159 before(async () => {161 await usingApi(async () => {160 await usingApi(async (api, privateKeyWrapper) => {162 alice = privateKey('//Alice');161 alice = privateKeyWrapper!('//Alice');163 bob = privateKey('//Bob');162 bob = privateKeyWrapper!('//Bob');164 });163 });165 });164 });166 165 290289291describe('Integration Test: Access Rights to Token Properties', () => {290describe('Integration Test: Access Rights to Token Properties', () => {292 before(async () => {291 before(async () => {293 await usingApi(async () => {292 await usingApi(async (api, privateKeyWrapper) => {294 alice = privateKey('//Alice');293 alice = privateKeyWrapper!('//Alice');295 bob = privateKey('//Bob');294 bob = privateKeyWrapper!('//Bob');296 });295 });297 });296 });298 297 356355357describe('Negative Integration Test: Access Rights to Token Properties', () => {356describe('Negative Integration Test: Access Rights to Token Properties', () => {358 before(async () => {357 before(async () => {359 await usingApi(async () => {358 await usingApi(async (api, privateKeyWrapper) => {360 alice = privateKey('//Alice');359 alice = privateKeyWrapper!('//Alice');361 bob = privateKey('//Bob');360 bob = privateKeyWrapper!('//Bob');362 });361 });363 });362 });364363474 let permissions: {permission: any, signers: IKeyringPair[]}[];473 let permissions: {permission: any, signers: IKeyringPair[]}[];475474476 before(async () => {475 before(async () => {477 await usingApi(async () => {476 await usingApi(async (api, privateKeyWrapper) => {478 alice = privateKey('//Alice');477 alice = privateKeyWrapper!('//Alice');479 bob = privateKey('//Bob');478 bob = privateKeyWrapper!('//Bob');480 charlie = privateKey('//Charlie');479 charlie = privateKeyWrapper!('//Charlie');481480482 permissions = [481 permissions = [483 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob]},482 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob]},639 let constitution: {permission: any, signers: IKeyringPair[], sinner: IKeyringPair}[];638 let constitution: {permission: any, signers: IKeyringPair[], sinner: IKeyringPair}[];640639641 before(async () => {640 before(async () => {642 await usingApi(async () => {641 await usingApi(async (api, privateKeyWrapper) => {643 alice = privateKey('//Alice');642 alice = privateKeyWrapper!('//Alice');644 bob = privateKey('//Bob');643 bob = privateKeyWrapper!('//Bob');645 charlie = privateKey('//Charlie');644 charlie = privateKeyWrapper!('//Charlie');646 const dave = privateKey('//Dave');645 const dave = privateKeyWrapper!('//Dave');647646648 constitution = [647 constitution = [649 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob], sinner: charlie},648 {permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob], sinner: charlie},tests/src/nesting/rules-smoke.test.tsdiffbeforeafterboth1import {expect} from 'chai';1import {expect} from 'chai';2import {tokenIdToAddress} from '../eth/util/helpers';2import {tokenIdToAddress} from '../eth/util/helpers';3import privateKey from '../substrate/privateKey';4import usingApi, {executeTransaction} from '../substrate/substrate-api';3import usingApi, {executeTransaction} from '../substrate/substrate-api';5import {createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, CrossAccountId, getCreateCollectionResult} from '../util/helpers';4import {createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, CrossAccountId, getCreateCollectionResult} from '../util/helpers';6import {IKeyringPair} from '@polkadot/types/types';5import {IKeyringPair} from '@polkadot/types/types';9 let alice!: IKeyringPair;8 let alice!: IKeyringPair;10 let nestTarget!: CrossAccountId;9 let nestTarget!: CrossAccountId;11 before(async() => {10 before(async() => {12 await usingApi(async api => {11 await usingApi(async (api, privateKeyWrapper) => {13 alice = privateKey('//Alice');12 alice = privateKeyWrapper!('//Alice');14 const bob = privateKey('//Bob');13 const bob = privateKeyWrapper!('//Bob');15 const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({14 const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({16 mode: 'NFT',15 mode: 'NFT',17 permissions: {16 permissions: {tests/src/nesting/unnest.test.tsdiffbeforeafterboth1import {expect} from 'chai';1import {expect} from 'chai';2import {tokenIdToAddress} from '../eth/util/helpers';2import {tokenIdToAddress} from '../eth/util/helpers';3import privateKey from '../substrate/privateKey';4import usingApi, {executeTransaction} from '../substrate/substrate-api';3import usingApi, {executeTransaction} from '../substrate/substrate-api';5import {4import {6 createCollectionExpectSuccess,5 createCollectionExpectSuccess,191820describe('Integration Test: Unnesting', () => {19describe('Integration Test: Unnesting', () => {21 before(async () => {20 before(async () => {22 await usingApi(async () => {21 await usingApi(async (api, privateKeyWrapper) => {23 alice = privateKey('//Alice');22 alice = privateKeyWrapper!('//Alice');24 bob = privateKey('//Bob');23 bob = privateKeyWrapper!('//Bob');25 });24 });26 });25 });2726110109111describe('Negative Test: Unnesting', () => {110describe('Negative Test: Unnesting', () => {112 before(async () => {111 before(async () => {113 await usingApi(async () => {112 await usingApi(async (api, privateKeyWrapper) => {114 alice = privateKey('//Alice');113 alice = privateKeyWrapper!('//Alice');115 bob = privateKey('//Bob');114 bob = privateKeyWrapper!('//Bob');116 });115 });117 });116 });118117tests/src/nextSponsoring.test.tsdiffbeforeafterboth18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi} from './substrate/substrate-api';21import {default as usingApi} from './substrate/substrate-api';23import {22import {24 createCollectionExpectSuccess,23 createCollectionExpectSuccess,40 let bob: IKeyringPair;39 let bob: IKeyringPair;414042 before(async () => {41 before(async () => {43 await usingApi(async () => {42 await usingApi(async (api, privateKeyWrapper) => {44 alice = privateKey('//Alice');43 alice = privateKeyWrapper!('//Alice');45 bob = privateKey('//Bob');44 bob = privateKeyWrapper!('//Bob');46 });45 });47 });46 });4847tests/src/overflow.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import usingApi from './substrate/substrate-api';20import usingApi from './substrate/substrate-api';22import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from './util/helpers';21import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from './util/helpers';232230 let charlie: IKeyringPair;29 let charlie: IKeyringPair;313032 before(async () => {31 before(async () => {33 await usingApi(async () => {32 await usingApi(async (api, privateKeyWrapper) => {34 alice = privateKey('//Alice');33 alice = privateKeyWrapper!('//Alice');35 bob = privateKey('//Bob');34 bob = privateKeyWrapper!('//Bob');36 charlie = privateKey('//Charlie');35 charlie = privateKeyWrapper!('//Charlie');37 });36 });38 });37 });3938tests/src/removeCollectionAdmin.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 {ApiPromise} from '@polkadot/api';18import chai from 'chai';17import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';20import privateKey from './substrate/privateKey';21import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';19import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';22import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';20import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';2321262427describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {25describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {28 it('Remove collection admin.', async () => {26 it('Remove collection admin.', async () => {29 await usingApi(async (api: ApiPromise) => {27 await usingApi(async (api, privateKeyWrapper) => {30 const collectionId = await createCollectionExpectSuccess();28 const collectionId = await createCollectionExpectSuccess();31 const alice = privateKey('//Alice');29 const alice = privateKeyWrapper!('//Alice');32 const bob = privateKey('//Bob');30 const bob = privateKeyWrapper!('//Bob');33 const collection = await queryCollectionExpectSuccess(api, collectionId);31 const collection = await queryCollectionExpectSuccess(api, collectionId);34 expect(collection.owner.toString()).to.be.deep.eq(alice.address);32 expect(collection.owner.toString()).to.be.deep.eq(alice.address);35 // first - add collection admin Bob33 // first - add collection admin Bob49 });47 });504851 it('Remove collection admin by admin.', async () => {49 it('Remove collection admin by admin.', async () => {52 await usingApi(async (api: ApiPromise) => {50 await usingApi(async (api, privateKeyWrapper) => {53 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();54 const alice = privateKey('//Alice');52 const alice = privateKeyWrapper!('//Alice');55 const bob = privateKey('//Bob');53 const bob = privateKeyWrapper!('//Bob');56 const charlie = privateKey('//Charlie');54 const charlie = privateKeyWrapper!('//Charlie');57 const collection = await queryCollectionExpectSuccess(api, collectionId);55 const collection = await queryCollectionExpectSuccess(api, collectionId);58 expect(collection.owner.toString()).to.be.eq(alice.address);56 expect(collection.owner.toString()).to.be.eq(alice.address);59 // first - add collection admin Bob57 // first - add collection admin Bob76 });74 });777578 it('Remove admin from collection that has no admins', async () => {76 it('Remove admin from collection that has no admins', async () => {79 await usingApi(async (api: ApiPromise) => {77 await usingApi(async (api, privateKeyWrapper) => {80 const alice = privateKey('//Alice');78 const alice = privateKeyWrapper!('//Alice');81 const collectionId = await createCollectionExpectSuccess();79 const collectionId = await createCollectionExpectSuccess();828083 const adminListBeforeAddAdmin = await getAdminList(api, collectionId);81 const adminListBeforeAddAdmin = await getAdminList(api, collectionId);918992describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {90describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {93 it('Can\'t remove collection admin from not existing collection', async () => {91 it('Can\'t remove collection admin from not existing collection', async () => {94 await usingApi(async (api: ApiPromise) => {92 await usingApi(async (api, privateKeyWrapper) => {95 // tslint:disable-next-line: no-bitwise93 // tslint:disable-next-line: no-bitwise96 const collectionId = (1 << 32) - 1;94 const collectionId = (1 << 32) - 1;97 const alice = privateKey('//Alice');95 const alice = privateKeyWrapper!('//Alice');98 const bob = privateKey('//Bob');96 const bob = privateKeyWrapper!('//Bob');9997100 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));98 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));101 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;99 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;106 });104 });107105108 it('Can\'t remove collection admin from deleted collection', async () => {106 it('Can\'t remove collection admin from deleted collection', async () => {109 await usingApi(async (api: ApiPromise) => {107 await usingApi(async (api, privateKeyWrapper) => {110 // tslint:disable-next-line: no-bitwise108 // tslint:disable-next-line: no-bitwise111 const collectionId = await createCollectionExpectSuccess();109 const collectionId = await createCollectionExpectSuccess();112 const alice = privateKey('//Alice');110 const alice = privateKeyWrapper!('//Alice');113 const bob = privateKey('//Bob');111 const bob = privateKeyWrapper!('//Bob');114112115 await destroyCollectionExpectSuccess(collectionId);113 await destroyCollectionExpectSuccess(collectionId);116114123 });121 });124122125 it('Regular user Can\'t remove collection admin', async () => {123 it('Regular user Can\'t remove collection admin', async () => {126 await usingApi(async (api: ApiPromise) => {124 await usingApi(async (api, privateKeyWrapper) => {127 const collectionId = await createCollectionExpectSuccess();125 const collectionId = await createCollectionExpectSuccess();128 const alice = privateKey('//Alice');126 const alice = privateKeyWrapper!('//Alice');129 const bob = privateKey('//Bob');127 const bob = privateKeyWrapper!('//Bob');130 const charlie = privateKey('//Charlie');128 const charlie = privateKeyWrapper!('//Charlie');131129132 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));130 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));133 await submitTransactionAsync(alice, addAdminTx);131 await submitTransactionAsync(alice, addAdminTx);tests/src/removeFromAllowList.test.tsdiffbeforeafterboth31 addCollectionAdminExpectSuccess,31 addCollectionAdminExpectSuccess,32} from './util/helpers';32} from './util/helpers';33import {IKeyringPair} from '@polkadot/types/types';33import {IKeyringPair} from '@polkadot/types/types';34import privateKey from './substrate/privateKey';353436chai.use(chaiAsPromised);35chai.use(chaiAsPromised);37const expect = chai.expect;36const expect = chai.expect;41 let bob: IKeyringPair;40 let bob: IKeyringPair;424143 before(async () => {42 before(async () => {44 await usingApi(async () => {43 await usingApi(async (api, privateKeyWrapper) => {45 alice = privateKey('//Alice');44 alice = privateKeyWrapper!('//Alice');46 bob = privateKey('//Bob');45 bob = privateKeyWrapper!('//Bob');47 });46 });48 });47 });494875 let bob: IKeyringPair;74 let bob: IKeyringPair;767577 before(async () => {76 before(async () => {78 await usingApi(async () => {77 await usingApi(async (api, privateKeyWrapper) => {79 alice = privateKey('//Alice');78 alice = privateKeyWrapper!('//Alice');80 bob = privateKey('//Bob');79 bob = privateKeyWrapper!('//Bob');81 });80 });82 });81 });8382107 let charlie: IKeyringPair;106 let charlie: IKeyringPair;108107109 before(async () => {108 before(async () => {110 await usingApi(async () => {109 await usingApi(async (api, privateKeyWrapper) => {111 alice = privateKey('//Alice');110 alice = privateKeyWrapper!('//Alice');112 bob = privateKey('//Bob');111 bob = privateKeyWrapper!('//Bob');113 charlie = privateKey('//Charlie');112 charlie = privateKeyWrapper!('//Charlie');114 });113 });115 });114 });116115tests/src/removeFromContractAllowList.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 privateKey from './substrate/privateKey';18import usingApi from './substrate/substrate-api';17import usingApi from './substrate/substrate-api';19import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';18import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';20import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from './util/helpers';19import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from './util/helpers';25 let bob: IKeyringPair;24 let bob: IKeyringPair;262527 before(async () => {26 before(async () => {28 await usingApi(async () => {27 await usingApi(async (api, privateKeyWrapper) => {29 bob = privateKey('//Bob');28 bob = privateKeyWrapper!('//Bob');30 });29 });31 });30 });323170 let bob: IKeyringPair;69 let bob: IKeyringPair;717072 before(async () => {71 before(async () => {73 await usingApi(async () => {72 await usingApi(async (api, privateKeyWrapper) => {74 alice = privateKey('//Alice');73 alice = privateKeyWrapper!('//Alice');75 bob = privateKey('//Bob');74 bob = privateKeyWrapper!('//Bob');76 });75 });77 });76 });7877tests/src/rpc.load.tsdiffbeforeafterboth20import {ApiPromise, Keyring} from '@polkadot/api';20import {ApiPromise, Keyring} from '@polkadot/api';21import {findUnusedAddress} from './util/helpers';21import {findUnusedAddress} from './util/helpers';22import fs from 'fs';22import fs from 'fs';23import privateKey from './substrate/privateKey';242325const value = 0;24const value = 0;26const gasLimit = 500000n * 1000000n;25const gasLimit = 500000n * 1000000n;121 });120 });122121123 it('Smart Contract RPC Load Test', async () => {122 it('Smart Contract RPC Load Test', async () => {124 await usingApi(async api => {123 await usingApi(async (api, privateKeyWrapper) => {125124126 // Deploy smart contract125 // Deploy smart contract127 const [contract, deployer] = await deployLoadTester(api);126 const [contract, deployer] = await deployLoadTester(api);128127129 // Fill smart contract up with data128 // Fill smart contract up with data130 const bob = privateKey('//Bob');129 const bob = privateKeyWrapper!('//Bob');131 const tx = contract.tx.bloat(value, gasLimit, 200);130 const tx = contract.tx.bloat(value, gasLimit, 200);132 await submitTransactionAsync(bob, tx);131 await submitTransactionAsync(bob, tx);133132tests/src/scheduler.test.tsdiffbeforeafterboth161617import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import privateKey from './substrate/privateKey';20import usingApi from './substrate/substrate-api';19import usingApi from './substrate/substrate-api';21import {20import {22 createItemExpectSuccess,21 createItemExpectSuccess,302931describe.skip('Integration Test scheduler base transaction', () => {30describe.skip('Integration Test scheduler base transaction', () => {32 it('User can transfer owned token with delay (scheduler)', async () => {31 it('User can transfer owned token with delay (scheduler)', async () => {33 await usingApi(async () => {32 await usingApi(async (api, privateKeyWrapper) => {34 const alice = privateKey('//Alice');33 const alice = privateKeyWrapper!('//Alice');35 const bob = privateKey('//Bob');34 const bob = privateKeyWrapper!('//Bob');36 // nft35 // nft37 const nftCollectionId = await createCollectionExpectSuccess();36 const nftCollectionId = await createCollectionExpectSuccess();38 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');37 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');tests/src/setChainLimits.test.tsdiffbeforeafterboth15// 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 {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import privateKey from './substrate/privateKey';19import usingApi from './substrate/substrate-api';18import usingApi from './substrate/substrate-api';20import {19import {21 createCollectionExpectSuccess,20 createCollectionExpectSuccess,31 let limits: IChainLimits;30 let limits: IChainLimits;323133 before(async () => {32 before(async () => {34 await usingApi(async () => {33 await usingApi(async (api, privateKeyWrapper) => {35 alice = privateKey('//Alice');34 alice = privateKeyWrapper!('//Alice');36 bob = privateKey('//Bob');35 bob = privateKeyWrapper!('//Bob');37 dave = privateKey('//Dave');36 dave = privateKeyWrapper!('//Dave');38 limits = {37 limits = {39 collectionNumbersLimit : 1,38 collectionNumbersLimit : 1,40 accountTokenOwnershipLimit: 1,39 accountTokenOwnershipLimit: 1,tests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth15// 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 {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import privateKey from './substrate/privateKey';19import usingApi from './substrate/substrate-api';18import usingApi from './substrate/substrate-api';20import waitNewBlocks from './substrate/wait-new-blocks';19import waitNewBlocks from './substrate/wait-new-blocks';21import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';20import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';57 let alice: IKeyringPair;56 let alice: IKeyringPair;585759 before(async () => {58 before(async () => {59 await usingApi(async (api, privateKeyWrapper) => {60 alice = privateKey('//Alice');60 alice = privateKeyWrapper!('//Alice');61 });61 });62 });626363 it('fails when called for non-contract address', async () => {64 it('fails when called for non-contract address', async () => {tests/src/setMintPermission.test.tsdiffbeforeafterboth15// 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 {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import privateKey from './substrate/privateKey';19import usingApi from './substrate/substrate-api';18import usingApi from './substrate/substrate-api';20import {19import {21 addToAllowListExpectSuccess,20 addToAllowListExpectSuccess,35 let bob: IKeyringPair;34 let bob: IKeyringPair;363537 before(async () => {36 before(async () => {38 await usingApi(async () => {37 await usingApi(async (api, privateKeyWrapper) => {39 alice = privateKey('//Alice');38 alice = privateKeyWrapper!('//Alice');40 bob = privateKey('//Bob');39 bob = privateKeyWrapper!('//Bob');41 });40 });42 });41 });434275 let bob: IKeyringPair;74 let bob: IKeyringPair;767577 before(async () => {76 before(async () => {78 await usingApi(async () => {77 await usingApi(async (api, privateKeyWrapper) => {79 alice = privateKey('//Alice');78 alice = privateKeyWrapper!('//Alice');80 bob = privateKey('//Bob');79 bob = privateKeyWrapper!('//Bob');81 });80 });82 });81 });8382tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';22import privateKey from './substrate/privateKey';23import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';22import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';24import {23import {25 addToAllowListExpectSuccess,24 addToAllowListExpectSuccess,414042describe('Integration Test setPublicAccessMode(): ', () => {41describe('Integration Test setPublicAccessMode(): ', () => {43 before(async () => {42 before(async () => {44 await usingApi(async () => {43 await usingApi(async (api, privateKeyWrapper) => {45 alice = privateKey('//Alice');44 alice = privateKeyWrapper!('//Alice');46 bob = privateKey('//Bob');45 bob = privateKeyWrapper!('//Bob');47 });46 });48 });47 });4948108107109describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {108describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {110 before(async () => {109 before(async () => {111 await usingApi(async () => {110 await usingApi(async (api, privateKeyWrapper) => {112 alice = privateKey('//Alice');111 alice = privateKeyWrapper!('//Alice');113 bob = privateKey('//Bob');112 bob = privateKeyWrapper!('//Bob');114 });113 });115 });114 });116 it('setPublicAccessMode by collection admin', async () => {115 it('setPublicAccessMode by collection admin', async () => {tests/src/toggleContractAllowList.test.tsdiffbeforeafterboth17import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';19import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import privateKey from './substrate/privateKey';21import {20import {22 deployFlipper,21 deployFlipper,23 getFlipValue,22 getFlipValue,50 });49 });515052 it('Only allowlisted account can call contract', async () => {51 it('Only allowlisted account can call contract', async () => {53 await usingApi(async api => {52 await usingApi(async (api, privateKeyWrapper) => {54 const bob = privateKey('//Bob');53 const bob = privateKeyWrapper!('//Bob');555456 const [contract, deployer] = await deployFlipper(api);55 const [contract, deployer] = await deployFlipper(api);5756135describe.skip('Negative Integration Test toggleContractAllowList', () => {134describe.skip('Negative Integration Test toggleContractAllowList', () => {136135137 it('Enable allow list for a non-contract', async () => {136 it('Enable allow list for a non-contract', async () => {138 await usingApi(async api => {137 await usingApi(async (api, privateKeyWrapper) => {139 const alice = privateKey('//Alice');138 const alice = privateKeyWrapper!('//Alice');140 const bobGuineaPig = privateKey('//Bob');139 const bobGuineaPig = privateKeyWrapper!('//Bob');141140142 const enabledBefore = (await api.query.unique.contractAllowListEnabled(bobGuineaPig.address)).toJSON();141 const enabledBefore = (await api.query.unique.contractAllowListEnabled(bobGuineaPig.address)).toJSON();143 const enableAllowListTx = api.tx.unique.toggleContractAllowList(bobGuineaPig.address, true);142 const enableAllowListTx = api.tx.unique.toggleContractAllowList(bobGuineaPig.address, true);150 });149 });151150152 it('Enable allow list using a non-owner address', async () => {151 it('Enable allow list using a non-owner address', async () => {153 await usingApi(async api => {152 await usingApi(async (api, privateKeyWrapper) => {154 const bob = privateKey('//Bob');153 const bob = privateKeyWrapper!('//Bob');155 const [contract] = await deployFlipper(api);154 const [contract] = await deployFlipper(api);156155157 const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();156 const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();tests/src/transfer.nload.tsdiffbeforeafterboth161617import {ApiPromise} from '@polkadot/api';17import {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import privateKey from './substrate/privateKey';20import usingApi, {submitTransactionAsync} from './substrate/substrate-api';19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';21import waitNewBlocks from './substrate/wait-new-blocks';20import waitNewBlocks from './substrate/wait-new-blocks';22import {findUnusedAddresses} from './util/helpers';21import {findUnusedAddresses} from './util/helpers';95 });94 });96 const waiting: Promise<void>[] = [];95 const waiting: Promise<void>[] = [];97 console.log(`Starting ${os.cpus().length} workers`);96 console.log(`Starting ${os.cpus().length} workers`);98 usingApi(async (api) => {97 usingApi(async (api, privateKeyWrapper) => {99 const alice = privateKey('//Alice');98 const alice = privateKeyWrapper!('//Alice');100 for (const id in os.cpus()) {99 for (const id in os.cpus()) {101 const WORKER_NAME = `//LoadWorker${id}_${Date.now()}`;100 const WORKER_NAME = `//LoadWorker${id}_${Date.now()}`;102 const workerAccount = privateKey(WORKER_NAME);101 const workerAccount = privateKeyWrapper!(WORKER_NAME);103 const tx = api.tx.balances.transfer(workerAccount.address, 400n * 10n ** 23n);102 const tx = api.tx.balances.transfer(workerAccount.address, 400n * 10n ** 23n);104 await submitTransactionAsync(alice, tx);103 await submitTransactionAsync(alice, tx);105104119 });118 });120} else {119} else {121 increaseCounter('startedWorkers', 1);120 increaseCounter('startedWorkers', 1);122 usingApi(async (api) => {121 usingApi(async (api, privateKeyWrapper) => {123 await distributeBalance(privateKey(process.env.WORKER_NAME as string), api, 400n * 10n ** 22n, 10);122 await distributeBalance(privateKeyWrapper!(process.env.WORKER_NAME as string), api, 400n * 10n ** 22n, 10);124 });123 });125 const interval = setInterval(() => {124 const interval = setInterval(() => {126 flushCounterToMaster();125 flushCounterToMaster();tests/src/transfer.test.tsdiffbeforeafterboth19import {expect} from 'chai';19import {expect} from 'chai';20import {alicesPublicKey, bobsPublicKey} from './accounts';20import {alicesPublicKey, bobsPublicKey} from './accounts';21import getBalance from './substrate/get-balance';21import getBalance from './substrate/get-balance';22import privateKey from './substrate/privateKey';23import {default as usingApi, submitTransactionAsync} from './substrate/substrate-api';22import {default as usingApi, submitTransactionAsync} from './substrate/substrate-api';24import {23import {25 burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess,24 burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess,494850describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {49describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {51 it('Balance transfers and check balance', async () => {50 it('Balance transfers and check balance', async () => {52 await usingApi(async (api: ApiPromise) => {51 await usingApi(async (api, privateKeyWrapper) => {53 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);52 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);545355 const alicePrivateKey = privateKey('//Alice');54 const alicePrivateKey = privateKeyWrapper!('//Alice');565557 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);56 const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);58 const events = await submitTransactionAsync(alicePrivateKey, transfer);57 const events = await submitTransactionAsync(alicePrivateKey, transfer);87 });86 });888789 it('User can transfer owned token', async () => {88 it('User can transfer owned token', async () => {90 await usingApi(async () => {89 await usingApi(async (api, privateKeyWrapper) => {91 const alice = privateKey('//Alice');90 const alice = privateKeyWrapper!('//Alice');92 const bob = privateKey('//Bob');91 const bob = privateKeyWrapper!('//Bob');93 // nft92 // nft94 const nftCollectionId = await createCollectionExpectSuccess();93 const nftCollectionId = await createCollectionExpectSuccess();95 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');94 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');114 });113 });115114116 it('Collection admin can transfer owned token', async () => {115 it('Collection admin can transfer owned token', async () => {117 await usingApi(async () => {116 await usingApi(async (api, privateKeyWrapper) => {118 const alice = privateKey('//Alice');117 const alice = privateKeyWrapper!('//Alice');119 const bob = privateKey('//Bob');118 const bob = privateKeyWrapper!('//Bob');120 // nft119 // nft121 const nftCollectionId = await createCollectionExpectSuccess();120 const nftCollectionId = await createCollectionExpectSuccess();122 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);121 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);145144146describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {145describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {147 before(async () => {146 before(async () => {148 await usingApi(async () => {147 await usingApi(async (api, privateKeyWrapper) => {149 alice = privateKey('//Alice');148 alice = privateKeyWrapper!('//Alice');150 bob = privateKey('//Bob');149 bob = privateKeyWrapper!('//Bob');151 charlie = privateKey('//Charlie');150 charlie = privateKeyWrapper!('//Charlie');152 });151 });153 });152 });154 it('Transfer with not existed collection_id', async () => {153 it('Transfer with not existed collection_id', async () => {258257259describe('Zero value transfer(From)', () => {258describe('Zero value transfer(From)', () => {260 before(async () => {259 before(async () => {261 await usingApi(async () => {260 await usingApi(async (api, privateKeyWrapper) => {262 alice = privateKey('//Alice');261 alice = privateKeyWrapper!('//Alice');263 bob = privateKey('//Bob');262 bob = privateKeyWrapper!('//Bob');264 });263 });265 });264 });266265315});314});316315317describe('Transfers to self (potentially over substrate-evm boundary)', () => {316describe('Transfers to self (potentially over substrate-evm boundary)', () => {318 itWeb3('Transfers to self. In case of same frontend', async ({api}) => {317 itWeb3('Transfers to self. In case of same frontend', async ({api, privateKeyWrapper}) => {319 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});318 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});320 const alice = privateKey('//Alice');319 const alice = privateKeyWrapper!('//Alice');321 const aliceProxy = subToEth(alice.address);320 const aliceProxy = subToEth(alice.address);322 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});321 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});323 await transferExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy}, 10, 'Fungible');322 await transferExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy}, 10, 'Fungible');327 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);326 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);328 });327 });329328330 itWeb3('Transfers to self. In case of substrate-evm boundary', async ({api}) => {329 itWeb3('Transfers to self. In case of substrate-evm boundary', async ({api, privateKeyWrapper}) => {331 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});330 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});332 const alice = privateKey('//Alice');331 const alice = privateKeyWrapper!('//Alice');333 const aliceProxy = subToEth(alice.address);332 const aliceProxy = subToEth(alice.address);334 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});333 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});335 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);334 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);339 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);338 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);340 });339 });341340342 itWeb3('Transfers to self. In case of inside substrate-evm', async ({api}) => {341 itWeb3('Transfers to self. In case of inside substrate-evm', async ({api, privateKeyWrapper}) => {343 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});342 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});344 const alice = privateKey('//Alice');343 const alice = privateKeyWrapper!('//Alice');345 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});344 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});346 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);345 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);347 await transferExpectSuccess(collectionId, tokenId, alice, alice , 10, 'Fungible');346 await transferExpectSuccess(collectionId, tokenId, alice, alice , 10, 'Fungible');350 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);349 expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);351 });350 });352351353 itWeb3('Transfers to self. In case of inside substrate-evm when not enought "Fungibles"', async ({api}) => {352 itWeb3('Transfers to self. In case of inside substrate-evm when not enought "Fungibles"', async ({api, privateKeyWrapper}) => {354 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});353 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});355 const alice = privateKey('//Alice');354 const alice = privateKeyWrapper!('//Alice');356 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});355 const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});357 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);356 const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);358 await transferExpectFailure(collectionId, tokenId, alice, alice , 11);357 await transferExpectFailure(collectionId, tokenId, alice, alice , 11);tests/src/transferFrom.test.tsdiffbeforeafterboth18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi} from './substrate/substrate-api';21import {default as usingApi} from './substrate/substrate-api';23import {22import {24 approveExpectFail,23 approveExpectFail,43 let charlie: IKeyringPair;42 let charlie: IKeyringPair;444345 before(async () => {44 before(async () => {46 await usingApi(async () => {45 await usingApi(async (api, privateKeyWrapper) => {47 alice = privateKey('//Alice');46 alice = privateKeyWrapper!('//Alice');48 bob = privateKey('//Bob');47 bob = privateKeyWrapper!('//Bob');49 charlie = privateKey('//Charlie');48 charlie = privateKeyWrapper!('//Charlie');50 });49 });51 });50 });525183 });82 });848385 it('Should reduce allowance if value is big', async () => {84 it('Should reduce allowance if value is big', async () => {86 await usingApi(async (api) => {85 await usingApi(async (api, privateKeyWrapper) => {87 const alice = privateKey('//Alice');86 const alice = privateKeyWrapper!('//Alice');88 const bob = privateKey('//Bob');87 const bob = privateKeyWrapper!('//Bob');89 const charlie = privateKey('//Charlie');88 const charlie = privateKeyWrapper!('//Charlie');908991 // fungible90 // fungible92 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});91 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});112 let charlie: IKeyringPair;111 let charlie: IKeyringPair;113112114 before(async () => {113 before(async () => {115 await usingApi(async () => {114 await usingApi(async (api, privateKeyWrapper) => {116 alice = privateKey('//Alice');115 alice = privateKeyWrapper!('//Alice');117 bob = privateKey('//Bob');116 bob = privateKeyWrapper!('//Bob');118 charlie = privateKey('//Charlie');117 charlie = privateKeyWrapper!('//Charlie');119 });118 });120 });119 });121120216 });215 });217216218 it('execute transferFrom from account that is not owner of collection', async () => {217 it('execute transferFrom from account that is not owner of collection', async () => {219 await usingApi(async () => {218 await usingApi(async (api, privateKeyWrapper) => {220 const dave = privateKey('//Dave');219 const dave = privateKeyWrapper!('//Dave');221 // nft220 // nft222 const nftCollectionId = await createCollectionExpectSuccess();221 const nftCollectionId = await createCollectionExpectSuccess();223 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');222 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');tests/src/util/helpers.tsdiffbeforeafterboth24import chai from 'chai';24import chai from 'chai';25import chaiAsPromised from 'chai-as-promised';25import chaiAsPromised from 'chai-as-promised';26import {alicesPublicKey} from '../accounts';26import {alicesPublicKey} from '../accounts';27import privateKey from '../substrate/privateKey';28import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';27import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';29import {hexToStr, strToUTF16, utf16ToStr} from './util';28import {hexToStr, strToUTF16, utf16ToStr} from './util';30import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';29import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';325 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};324 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};326325327 let collectionId = 0;326 let collectionId = 0;328 await usingApi(async (api) => {327 await usingApi(async (api, privateKeyWrapper) => {329 // Get number of collections before the transaction328 // Get number of collections before the transaction330 const collectionCountBefore = await getCreatedCollectionCount(api);329 const collectionCountBefore = await getCreatedCollectionCount(api);331330332 // Run the CreateCollection transaction331 // Run the CreateCollection transaction333 const alicePrivateKey = privateKey('//Alice');332 const alicePrivateKey = privateKeyWrapper!('//Alice');334333335 let modeprm = {};334 let modeprm = {};336 if (mode.type === 'NFT') {335 if (mode.type === 'NFT') {378 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};377 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};379378380 let collectionId = 0;379 let collectionId = 0;381 await usingApi(async (api) => {380 await usingApi(async (api, privateKeyWrapper) => {382 // Get number of collections before the transaction381 // Get number of collections before the transaction383 const collectionCountBefore = await getCreatedCollectionCount(api);382 const collectionCountBefore = await getCreatedCollectionCount(api);384383385 // Run the CreateCollection transaction384 // Run the CreateCollection transaction386 const alicePrivateKey = privateKey('//Alice');385 const alicePrivateKey = privateKeyWrapper!('//Alice');387386388 let modeprm = {};387 let modeprm = {};389 if (mode.type === 'NFT') {388 if (mode.type === 'NFT') {426export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {425export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {427 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};426 const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};428427429 await usingApi(async (api) => {428 await usingApi(async (api, privateKeyWrapper) => {430 // Get number of collections before the transaction429 // Get number of collections before the transaction431 const collectionCountBefore = await getCreatedCollectionCount(api);430 const collectionCountBefore = await getCreatedCollectionCount(api);432431433 // Run the CreateCollection transaction432 // Run the CreateCollection transaction434 const alicePrivateKey = privateKey('//Alice');433 const alicePrivateKey = privateKeyWrapper!('//Alice');435434436 let modeprm = {};435 let modeprm = {};437 if (mode.type === 'NFT') {436 if (mode.type === 'NFT') {465 modeprm = {refungible: null};464 modeprm = {refungible: null};466 }465 }467466468 await usingApi(async (api) => {467 await usingApi(async (api, privateKeyWrapper) => {469 // Get number of collections before the transaction468 // Get number of collections before the transaction470 const collectionCountBefore = await getCreatedCollectionCount(api);469 const collectionCountBefore = await getCreatedCollectionCount(api);471470472 // Run the CreateCollection transaction471 // Run the CreateCollection transaction473 const alicePrivateKey = privateKey('//Alice');472 const alicePrivateKey = privateKeyWrapper!('//Alice');474 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});473 const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});475 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;474 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;476475519}518}520519521export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {520export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {522 await usingApi(async (api) => {521 await usingApi(async (api, privateKeyWrapper) => {523 // Run the DestroyCollection transaction522 // Run the DestroyCollection transaction524 const alicePrivateKey = privateKey(senderSeed);523 const alicePrivateKey = privateKeyWrapper!(senderSeed);525 const tx = api.tx.unique.destroyCollection(collectionId);524 const tx = api.tx.unique.destroyCollection(collectionId);526 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;525 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;527 });526 });528}527}529528530export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {529export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {531 await usingApi(async (api) => {530 await usingApi(async (api, privateKeyWrapper) => {532 // Run the DestroyCollection transaction531 // Run the DestroyCollection transaction533 const alicePrivateKey = privateKey(senderSeed);532 const alicePrivateKey = privateKeyWrapper!(senderSeed);534 const tx = api.tx.unique.destroyCollection(collectionId);533 const tx = api.tx.unique.destroyCollection(collectionId);535 const events = await submitTransactionAsync(alicePrivateKey, tx);534 const events = await submitTransactionAsync(alicePrivateKey, tx);536 const result = getDestroyResult(events);535 const result = getDestroyResult(events);572}571}573572574export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string, sender = '//Alice') {573export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string, sender = '//Alice') {575 await usingApi(async (api) => {574 await usingApi(async (api, privateKeyWrapper) => {576575577 // Run the transaction576 // Run the transaction578 const senderPrivateKey = privateKey(sender);577 const senderPrivateKey = privateKeyWrapper!(sender);579 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);578 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);580 const events = await submitTransactionAsync(senderPrivateKey, tx);579 const events = await submitTransactionAsync(senderPrivateKey, tx);581 const result = getGenericResult(events);580 const result = getGenericResult(events);592}591}593592594export async function removeCollectionSponsorExpectSuccess(collectionId: number, sender = '//Alice') {593export async function removeCollectionSponsorExpectSuccess(collectionId: number, sender = '//Alice') {595 await usingApi(async (api) => {594 await usingApi(async (api, privateKeyWrapper) => {596595597 // Run the transaction596 // Run the transaction598 const alicePrivateKey = privateKey(sender);597 const alicePrivateKey = privateKeyWrapper!(sender);599 const tx = api.tx.unique.removeCollectionSponsor(collectionId);598 const tx = api.tx.unique.removeCollectionSponsor(collectionId);600 const events = await submitTransactionAsync(alicePrivateKey, tx);599 const events = await submitTransactionAsync(alicePrivateKey, tx);601 const result = getGenericResult(events);600 const result = getGenericResult(events);610}609}611610612export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {611export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {613 await usingApi(async (api) => {612 await usingApi(async (api, privateKeyWrapper) => {614613615 // Run the transaction614 // Run the transaction616 const alicePrivateKey = privateKey(senderSeed);615 const alicePrivateKey = privateKeyWrapper!(senderSeed);617 const tx = api.tx.unique.removeCollectionSponsor(collectionId);616 const tx = api.tx.unique.removeCollectionSponsor(collectionId);618 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;617 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;619 });618 });620}619}621620622export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed = '//Alice') {621export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed = '//Alice') {623 await usingApi(async (api) => {622 await usingApi(async (api, privateKeyWrapper) => {624623625 // Run the transaction624 // Run the transaction626 const alicePrivateKey = privateKey(senderSeed);625 const alicePrivateKey = privateKeyWrapper!(senderSeed);627 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);626 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);628 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;627 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;629 });628 });630}629}631630632export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed = '//Alice') {631export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed = '//Alice') {633 await usingApi(async (api) => {632 await usingApi(async (api, privateKeyWrapper) => {634633635 // Run the transaction634 // Run the transaction636 const sender = privateKey(senderSeed);635 const sender = privateKeyWrapper!(senderSeed);637 const tx = api.tx.unique.confirmSponsorship(collectionId);636 const tx = api.tx.unique.confirmSponsorship(collectionId);638 const events = await submitTransactionAsync(sender, tx);637 const events = await submitTransactionAsync(sender, tx);639 const result = getGenericResult(events);638 const result = getGenericResult(events);651650652651653export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed = '//Alice') {652export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed = '//Alice') {654 await usingApi(async (api) => {653 await usingApi(async (api, privateKeyWrapper) => {655654656 // Run the transaction655 // Run the transaction657 const sender = privateKey(senderSeed);656 const sender = privateKeyWrapper!(senderSeed);658 const tx = api.tx.unique.confirmSponsorship(collectionId);657 const tx = api.tx.unique.confirmSponsorship(collectionId);659 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;658 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;660 });659 });tests/src/xcmTransfer.test.tsdiffbeforeafterboth20import {WsProvider} from '@polkadot/api';20import {WsProvider} from '@polkadot/api';21import {ApiOptions} from '@polkadot/api/types';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';22import {IKeyringPair} from '@polkadot/types/types';23import privateKey from './substrate/privateKey';24import usingApi, {submitTransactionAsync} from './substrate/substrate-api';23import usingApi, {submitTransactionAsync} from './substrate/substrate-api';25import {getGenericResult} from './util/helpers';24import {getGenericResult} from './util/helpers';26import waitNewBlocks from './substrate/wait-new-blocks';25import waitNewBlocks from './substrate/wait-new-blocks';38 let alice: IKeyringPair;37 let alice: IKeyringPair;39 38 40 before(async () => {39 before(async () => {41 await usingApi(async () => {40 await usingApi(async (api, privateKeyWrapper) => {42 alice = privateKey('//Alice');41 alice = privateKeyWrapper!('//Alice');43 });42 });444345 const karuraApiOptions: ApiOptions = {44 const karuraApiOptions: ApiOptions = {