difftreelog
test(ss58Format) transfer all tests to the new privateKeyWrapper method
in: master
62 files changed
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -17,7 +17,6 @@
import {ApiPromise} from '@polkadot/api';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';
@@ -26,10 +25,10 @@
describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
it('Add collection admin.', async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.equal(alice.address);
@@ -43,11 +42,11 @@
});
it('Add admin using added collection admin.', async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//CHARLIE');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//CHARLIE');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.equal(alice.address);
@@ -69,10 +68,10 @@
describe('Negative Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
it("Not owner can't add collection admin.", async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const nonOwner = privateKey('//Bob_stash');
+ const alice = privateKeyWrapper!('//Alice');
+ const nonOwner = privateKeyWrapper!('//Bob_stash');
const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));
await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;
@@ -85,11 +84,11 @@
});
});
it("Can't add collection admin of not existing collection.", async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// tslint:disable-next-line: no-bitwise
const collectionId = (1 << 32) - 1;
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
@@ -100,10 +99,10 @@
});
it("Can't add an admin to a destroyed collection.", async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
await destroyCollectionExpectSuccess(collectionId);
const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
@@ -114,16 +113,16 @@
});
it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
- await usingApi(async (api: ApiPromise) => {
- const alice = privateKey('//Alice');
+ await usingApi(async (api: ApiPromise, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
const accounts = [
- privateKey('//AdminTest/1').address,
- privateKey('//AdminTest/2').address,
- privateKey('//AdminTest/3').address,
- privateKey('//AdminTest/4').address,
- privateKey('//AdminTest/5').address,
- privateKey('//AdminTest/6').address,
- privateKey('//AdminTest/7').address,
+ privateKeyWrapper!('//AdminTest/1').address,
+ privateKeyWrapper!('//AdminTest/2').address,
+ privateKeyWrapper!('//AdminTest/3').address,
+ privateKeyWrapper!('//AdminTest/4').address,
+ privateKeyWrapper!('//AdminTest/5').address,
+ privateKeyWrapper!('//AdminTest/6').address,
+ privateKeyWrapper!('//AdminTest/7').address,
];
const collectionId = await createCollectionExpectSuccess();
tests/src/addToAllowList.test.tsdiffbeforeafterboth--- a/tests/src/addToAllowList.test.ts
+++ b/tests/src/addToAllowList.test.ts
@@ -17,7 +17,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
addToAllowListExpectSuccess,
@@ -42,9 +41,9 @@
describe('Integration Test ext. addToAllowList()', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -65,10 +64,10 @@
describe('Negative Integration Test ext. addToAllowList()', () => {
it('Allow list an address in the collection that does not exist', async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// tslint:disable-next-line: no-bitwise
const collectionId = await getCreatedCollectionCount(api) + 1;
- const bob = privateKey('//Bob');
+ const bob = privateKeyWrapper!('//Bob');
const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));
await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
@@ -76,9 +75,9 @@
});
it('Allow list an address in the collection that was destroyed', async () => {
- await usingApi(async (api) => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// tslint:disable-next-line: no-bitwise
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId);
@@ -88,9 +87,9 @@
});
it('Allow list an address in the collection that does not have allow list access enabled', async () => {
- await usingApi(async (api) => {
- const alice = privateKey('//Alice');
- const ferdie = privateKey('//Ferdie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const ferdie = privateKeyWrapper!('//Ferdie');
const collectionId = await createCollectionExpectSuccess();
await enableAllowListExpectSuccess(alice, collectionId);
await enablePublicMintingExpectSuccess(alice, collectionId);
@@ -104,10 +103,10 @@
describe('Integration Test ext. addToAllowList() with collection admin permissions:', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
tests/src/addToContractAllowList.test.tsdiffbeforeafterboth--- a/tests/src/addToContractAllowList.test.ts
+++ b/tests/src/addToContractAllowList.test.ts
@@ -17,7 +17,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import privateKey from './substrate/privateKey';
import {
deployFlipper,
} from './util/contracthelpers';
@@ -31,8 +30,8 @@
describe.skip('Integration Test addToContractAllowList', () => {
it('Add an address to a contract allow list', async () => {
- await usingApi(async api => {
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const bob = privateKeyWrapper!('//Bob');
const [contract, deployer] = await deployFlipper(api);
const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();
@@ -47,8 +46,8 @@
});
it('Adding same address to allow list repeatedly should not produce errors', async () => {
- await usingApi(async api => {
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const bob = privateKeyWrapper!('//Bob');
const [contract, deployer] = await deployFlipper(api);
const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();
@@ -70,10 +69,10 @@
describe.skip('Negative Integration Test addToContractAllowList', () => {
it('Add an address to a allow list of a non-contract', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Bob');
- const bob = privateKey('//Bob');
- const charlieGuineaPig = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Bob');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlieGuineaPig = privateKeyWrapper!('//Charlie');
const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();
const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);
@@ -86,8 +85,8 @@
});
it('Add to a contract allow list using a non-owner address', async () => {
- await usingApi(async api => {
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const bob = privateKeyWrapper!('//Bob');
const [contract] = await deployFlipper(api);
const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();
tests/src/allowLists.test.tsdiffbeforeafterboth--- a/tests/src/allowLists.test.ts
+++ b/tests/src/allowLists.test.ts
@@ -17,7 +17,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
addToAllowListExpectSuccess,
@@ -50,10 +49,10 @@
describe('Integration Test ext. Allow list tests', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -18,7 +18,6 @@
import {ApiPromise} from '@polkadot/api';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import {default as usingApi} from './substrate/substrate-api';
import {
approveExpectFail,
@@ -43,10 +42,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -99,10 +98,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -131,10 +130,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -166,10 +165,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -205,11 +204,11 @@
let dave: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
- dave = privateKey('//Dave');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
+ dave = privateKeyWrapper!('//Dave');
});
});
@@ -228,10 +227,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -267,10 +266,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -300,11 +299,11 @@
let dave: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
- dave = privateKey('//Dave');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
+ dave = privateKeyWrapper!('//Dave');
});
});
@@ -340,11 +339,11 @@
let dave: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
- dave = privateKey('//Dave');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
+ dave = privateKeyWrapper!('//Dave');
});
});
@@ -391,10 +390,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -413,10 +412,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -16,7 +16,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {createCollectionExpectSuccess,
addCollectionAdminExpectSuccess,
@@ -41,10 +40,10 @@
describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
it('Changing owner changes owner address', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const collection =await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.deep.eq(alice.address);
@@ -60,10 +59,10 @@
describe('Integration Test changeCollectionOwner(collection_id, new_owner) special checks for exOwner:', () => {
it('Changing the owner of the collection is not allowed for the former owner', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.deep.eq(alice.address);
@@ -80,11 +79,11 @@
});
it('New collectionOwner has access to sponsorship management operations in the collection', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.deep.eq(alice.address);
@@ -124,11 +123,11 @@
});
it('New collectionOwner has access to changeCollectionOwner', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.deep.eq(alice.address);
@@ -151,10 +150,10 @@
describe('Negative Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
it('Not owner can\'t change owner.', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;
@@ -168,10 +167,10 @@
});
it('Collection admin can\'t change owner.', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
@@ -187,10 +186,10 @@
});
it('Can\'t change owner of a non-existing collection.', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = (1<<32) - 1;
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
@@ -201,11 +200,11 @@
});
it('Former collectionOwner not allowed to sponsorship management operations in the collection', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.deep.eq(alice.address);
tests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/burnItemEvent.test.ts
+++ b/tests/src/check-event/burnItemEvent.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage} from '../util/helpers';
@@ -32,8 +31,8 @@
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
it('Check event from burnItem(): ', async () => {
tests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createCollectionEvent.test.ts
+++ b/tests/src/check-event/createCollectionEvent.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {uniqueEventMessage} from '../util/helpers';
@@ -32,8 +31,8 @@
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
it('Check event from createCollection(): ', async () => {
tests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createItemEvent.test.ts
+++ b/tests/src/check-event/createItemEvent.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
@@ -32,8 +31,8 @@
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
it('Check event from createItem(): ', async () => {
tests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createMultipleItemsEvent.test.ts
+++ b/tests/src/check-event/createMultipleItemsEvent.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
@@ -32,8 +31,8 @@
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
it('Check event from createMultipleItems(): ', async () => {
tests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/destroyCollectionEvent.test.ts
+++ b/tests/src/check-event/destroyCollectionEvent.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {createCollectionExpectSuccess, uniqueEventMessage} from '../util/helpers';
@@ -31,8 +30,8 @@
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
it('Check event from destroyCollection(): ', async () => {
tests/src/check-event/transferEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/transferEvent.test.ts
+++ b/tests/src/check-event/transferEvent.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
@@ -33,9 +32,9 @@
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
it('Check event from transfer(): ', async () => {
tests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/transferFromEvent.test.ts
+++ b/tests/src/check-event/transferFromEvent.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
@@ -33,9 +32,9 @@
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
it('Check event from transferFrom(): ', async () => {
tests/src/contracts.test.tsdiffbeforeafterboth--- a/tests/src/contracts.test.ts
+++ b/tests/src/contracts.test.ts
@@ -50,11 +50,11 @@
describe.skip('Contracts', () => {
it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
const [contract, deployer] = await deployFlipper(api);
const initialGetResponse = await getFlipValue(contract, deployer);
- const bob = privateKey('//Bob');
+ const bob = privateKeyWrapper!('//Bob');
const flip = contract.tx.flip(value, gasLimit);
await submitTransactionAsync(bob, flip);
@@ -76,9 +76,9 @@
describe.skip('Chain extensions', () => {
it('Transfer CE', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// Prep work
const collectionId = await createCollectionExpectSuccess();
@@ -100,9 +100,9 @@
});
it('Mint CE', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const collectionId = await createCollectionExpectSuccess();
const [contract] = await deployTransferContract(api);
@@ -127,9 +127,9 @@
});
it('Bulk mint CE', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const collectionId = await createCollectionExpectSuccess();
const [contract] = await deployTransferContract(api);
@@ -168,10 +168,10 @@
});
it('Approve CE', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const collectionId = await createCollectionExpectSuccess();
const [contract] = await deployTransferContract(api);
@@ -187,10 +187,10 @@
});
it('TransferFrom CE', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const collectionId = await createCollectionExpectSuccess();
const [contract] = await deployTransferContract(api);
@@ -208,9 +208,9 @@
});
it('ToggleAllowList CE', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const collectionId = await createCollectionExpectSuccess();
const [contract] = await deployTransferContract(api);
tests/src/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {expect} from 'chai';
-import privateKey from './substrate/privateKey';
import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';
import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';
@@ -58,9 +57,9 @@
});
it('Create new collection with extra fields', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const tx = api.tx.unique.createCollectionEx({
mode: {Fungible: 8},
permissions: {
@@ -101,8 +100,8 @@
await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});
});
it('fails when bad limits are set', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});
await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);
});
tests/src/createMultipleItems.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';23import {24 createCollectionExpectSuccess,25 destroyCollectionExpectSuccess,26 getGenericResult,27 normalizeAccountId,28 setCollectionLimitsExpectSuccess,29 addCollectionAdminExpectSuccess,30 getBalance,31 getTokenOwner,32 getLastTokenId,33 getCreatedCollectionCount,34 createCollectionWithPropsExpectSuccess,35 createMultipleItemsWithPropsExpectSuccess,36 getTokenProperties,37} from './util/helpers';3839chai.use(chaiAsPromised);40const expect = chai.expect;4142describe('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 () => {44 await usingApi(async (api: ApiPromise) => {45 const collectionId = await createCollectionExpectSuccess();46 const itemsListIndexBefore = await getLastTokenId(api, collectionId);47 expect(itemsListIndexBefore).to.be.equal(0);4849 const alice = privateKey('//Alice');50 await submitTransactionAsync(51 alice, 52 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),53 );54 55 const args = [56 {NFT: {properties: [{key: 'data', value: '1'}]}},57 {NFT: {properties: [{key: 'data', value: '2'}]}},58 {NFT: {properties: [{key: 'data', value: '3'}]}},59 ];60 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);61 await submitTransactionAsync(alice, createMultipleItemsTx);62 const itemsListIndexAfter = await getLastTokenId(api, collectionId);63 expect(itemsListIndexAfter).to.be.equal(3);6465 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));66 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));67 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));6869 expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('1');70 expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('2');71 expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('3');72 });73 });7475 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {76 await usingApi(async (api: ApiPromise) => {77 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});78 const itemsListIndexBefore = await getLastTokenId(api, collectionId);79 expect(itemsListIndexBefore).to.be.equal(0);80 const alice = privateKey('//Alice');81 const args = [82 {Fungible: {value: 1}},83 {Fungible: {value: 2}},84 {Fungible: {value: 3}},85 ];86 const createMultipleItemsTx = api.tx.unique87 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);88 await submitTransactionAsync(alice, createMultipleItemsTx);89 const token1Data = await getBalance(api, collectionId, alice.address, 0);9091 expect(token1Data).to.be.equal(6n); // 1 + 2 + 392 });93 });9495 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {96 await usingApi(async (api: ApiPromise) => {97 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});98 const itemsListIndexBefore = await getLastTokenId(api, collectionId);99 expect(itemsListIndexBefore).to.be.equal(0);100 const alice = privateKey('//Alice');101 const args = [102 {ReFungible: {pieces: 1}},103 {ReFungible: {pieces: 2}},104 {ReFungible: {pieces: 3}},105 ];106 const createMultipleItemsTx = api.tx.unique107 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);108 await submitTransactionAsync(alice, createMultipleItemsTx);109 const itemsListIndexAfter = await getLastTokenId(api, collectionId);110 expect(itemsListIndexAfter).to.be.equal(3);111112 expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);113 expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(2n);114 expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(3n);115 });116 });117118 it('Can mint amount of items equals to collection limits', async () => {119 await usingApi(async (api) => {120 const alice = privateKey('//Alice');121122 const collectionId = await createCollectionExpectSuccess();123 await setCollectionLimitsExpectSuccess(alice, collectionId, {124 tokenLimit: 2,125 });126 const args = [127 {NFT: {}},128 {NFT: {}},129 ];130 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);131 const events = await submitTransactionAsync(alice, createMultipleItemsTx);132 const result = getGenericResult(events);133 expect(result.success).to.be.true;134 });135 });136137 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {138 await usingApi(async (api: ApiPromise) => {139 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});140 const itemsListIndexBefore = await getLastTokenId(api, collectionId);141 expect(itemsListIndexBefore).to.be.equal(0);142 const alice = privateKey('//Alice');143 const args = [144 {NFT: {properties: [{key: 'k', value: 'v1'}]}},145 {NFT: {properties: [{key: 'k', value: 'v2'}]}},146 {NFT: {properties: [{key: 'k', value: 'v3'}]}},147 ];148149 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);150 const itemsListIndexAfter = await getLastTokenId(api, collectionId);151 expect(itemsListIndexAfter).to.be.equal(3);152153 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));154 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));155 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));156157 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');158 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');159 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');160 });161 });162163 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {164 await usingApi(async (api: ApiPromise) => {165 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});166 const itemsListIndexBefore = await getLastTokenId(api, collectionId);167 expect(itemsListIndexBefore).to.be.equal(0);168 const alice = privateKey('//Alice');169 const bob = privateKey('//Bob');170 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);171 const args = [172 {NFT: {properties: [{key: 'k', value: 'v1'}]}},173 {NFT: {properties: [{key: 'k', value: 'v2'}]}},174 {NFT: {properties: [{key: 'k', value: 'v3'}]}},175 ];176177 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);178 const itemsListIndexAfter = await getLastTokenId(api, collectionId);179 expect(itemsListIndexAfter).to.be.equal(3);180181 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));182 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));183 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));184185 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');186 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');187 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');188 });189 });190191 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {192 await usingApi(async (api: ApiPromise) => {193 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});194 const itemsListIndexBefore = await getLastTokenId(api, collectionId);195 expect(itemsListIndexBefore).to.be.equal(0);196 const alice = privateKey('//Alice');197 const args = [198 {NFT: {properties: [{key: 'k', value: 'v1'}]}},199 {NFT: {properties: [{key: 'k', value: 'v2'}]}},200 {NFT: {properties: [{key: 'k', value: 'v3'}]}},201 ];202203 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);204 const itemsListIndexAfter = await getLastTokenId(api, collectionId);205 expect(itemsListIndexAfter).to.be.equal(3);206207 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));208 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));209 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));210211 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');212 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');213 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');214 });215 });216});217218describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {219 let alice: IKeyringPair;220 let bob: IKeyringPair;221222 before(async () => {223 await usingApi(async () => {224 alice = privateKey('//Alice');225 bob = privateKey('//Bob');226 });227 });228229 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {230 await usingApi(async (api: ApiPromise) => {231 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});232 const itemsListIndexBefore = await getLastTokenId(api, collectionId);233 expect(itemsListIndexBefore).to.be.equal(0);234 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);235 const args = [236 {NFT: {properties: [{key: 'data', value: 'v1'}]}},237 {NFT: {properties: [{key: 'data', value: 'v2'}]}},238 {NFT: {properties: [{key: 'data', value: 'v3'}]}},239 ];240 const createMultipleItemsTx = api.tx.unique241 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);242 await submitTransactionAsync(bob, createMultipleItemsTx);243 const itemsListIndexAfter = await getLastTokenId(api, collectionId);244 expect(itemsListIndexAfter).to.be.equal(3);245246 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));247 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));248 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));249250 expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('v1');251 expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('v2');252 expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('v3');253 });254 });255256 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {257 await usingApi(async (api: ApiPromise) => {258 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});259 const itemsListIndexBefore = await getLastTokenId(api, collectionId);260 expect(itemsListIndexBefore).to.be.equal(0);261 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);262 const args = [263 {Fungible: {value: 1}},264 {Fungible: {value: 2}},265 {Fungible: {value: 3}},266 ];267 const createMultipleItemsTx = api.tx.unique268 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);269 await submitTransactionAsync(bob, createMultipleItemsTx);270 const token1Data = await getBalance(api, collectionId, bob.address, 0);271272 expect(token1Data).to.be.equal(6n); // 1 + 2 + 3273 });274 });275276 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {277 await usingApi(async (api: ApiPromise) => {278 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});279 const itemsListIndexBefore = await getLastTokenId(api, collectionId);280 expect(itemsListIndexBefore).to.be.equal(0);281 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);282 const args = [283 {ReFungible: {pieces: 1}},284 {ReFungible: {pieces: 2}},285 {ReFungible: {pieces: 3}},286 ];287 const createMultipleItemsTx = api.tx.unique288 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);289 await submitTransactionAsync(bob, createMultipleItemsTx);290 const itemsListIndexAfter = await getLastTokenId(api, collectionId);291 expect(itemsListIndexAfter).to.be.equal(3);292293 expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);294 expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(2n);295 expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(3n);296 });297 });298});299300describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {301 let alice: IKeyringPair;302 let bob: IKeyringPair;303304 before(async () => {305 await usingApi(async () => {306 alice = privateKey('//Alice');307 bob = privateKey('//Bob');308 });309 });310311 it('Regular user cannot create items in active NFT collection', async () => {312 await usingApi(async (api: ApiPromise) => {313 const collectionId = await createCollectionExpectSuccess();314 const itemsListIndexBefore = await getLastTokenId(api, collectionId);315 expect(itemsListIndexBefore).to.be.equal(0);316 const args = [{NFT: {}},317 {NFT: {}},318 {NFT: {}}];319 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);320 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);321 });322 });323324 it('Regular user cannot create items in active Fungible collection', async () => {325 await usingApi(async (api: ApiPromise) => {326 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});327 const itemsListIndexBefore = await getLastTokenId(api, collectionId);328 expect(itemsListIndexBefore).to.be.equal(0);329 const args = [330 {Fungible: {value: 1}},331 {Fungible: {value: 2}},332 {Fungible: {value: 3}},333 ];334 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);335 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);336 });337 });338339 it('Regular user cannot create items in active ReFungible collection', async () => {340 await usingApi(async (api: ApiPromise) => {341 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});342 const itemsListIndexBefore = await getLastTokenId(api, collectionId);343 expect(itemsListIndexBefore).to.be.equal(0);344 const args = [345 {ReFungible: {pieces: 1}},346 {ReFungible: {pieces: 1}},347 {ReFungible: {pieces: 1}},348 ];349 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);350 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);351 });352 });353354 it('Create token in not existing collection', async () => {355 await usingApi(async (api: ApiPromise) => {356 const collectionId = await getCreatedCollectionCount(api) + 1;357 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);358 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionNotFound/);359 });360 });361362 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {363 await usingApi(async (api: ApiPromise) => {364 // NFT365 const collectionId = await createCollectionWithPropsExpectSuccess({366 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],367 });368 const alice = privateKey('//Alice');369 const args = [370 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},371 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},372 {NFT: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},373 ];374 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);375 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;376377 // ReFungible378 const collectionIdReFungible =379 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});380 const argsReFungible = [381 {ReFungible: ['1'.repeat(2049), 10]},382 {ReFungible: ['2'.repeat(2049), 10]},383 {ReFungible: ['3'.repeat(2049), 10]},384 ];385 const createMultipleItemsTxFungible = api.tx.unique386 .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);387 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;388 });389 });390391 it('Create tokens with different types', async () => {392 await usingApi(async (api: ApiPromise) => {393 const collectionId = await createCollectionExpectSuccess();394 const createMultipleItemsTx = api.tx.unique395 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);396 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/);397 // garbage collection :-D // lol398 await destroyCollectionExpectSuccess(collectionId);399 });400 });401402 it('Create tokens with different data limits <> maximum data limit', async () => {403 await usingApi(async (api: ApiPromise) => {404 const collectionId = await createCollectionWithPropsExpectSuccess({405 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],406 });407 const args = [408 {NFT: {properties: [{key: 'key', value: 'A'}]}},409 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},410 ];411 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);412 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;413 });414 });415416 it('Fails when minting tokens exceeds collectionLimits amount', async () => {417 await usingApi(async (api) => {418 const collectionId = await createCollectionExpectSuccess();419 await setCollectionLimitsExpectSuccess(alice, collectionId, {420 tokenLimit: 1,421 });422 const args = [423 {NFT: {}},424 {NFT: {}},425 ];426 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);427 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);428 });429 });430431 it('User doesnt have editing rights', async () => {432 await usingApi(async (api: ApiPromise) => {433 const collectionId = await createCollectionWithPropsExpectSuccess({434 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],435 });436 const itemsListIndexBefore = await getLastTokenId(api, collectionId);437 expect(itemsListIndexBefore).to.be.equal(0);438 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);439 const args = [440 {NFT: {properties: [{key: 'key1', value: 'v2'}]}},441 {NFT: {}},442 {NFT: {}},443 ];444445 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);446 await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);447 });448 });449450 it('Adding property without access rights', async () => {451 await usingApi(async (api: ApiPromise) => {452 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'k', value: 'v1'}]});453 const itemsListIndexBefore = await getLastTokenId(api, collectionId);454 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);455 expect(itemsListIndexBefore).to.be.equal(0);456 const args = [{NFT: {properties: [{key: 'k', value: 'v'}]}},457 {NFT: {}},458 {NFT: {}}];459460 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);461 await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);462 });463 });464465 it('Adding more than 64 prps', async () => {466 await usingApi(async (api: ApiPromise) => {467 const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];468 for (let i = 0; i < 65; i++) {469 propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});470 }471472 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});473474 const tx1 = api.tx.unique.setPropertyPermissions(collectionId, propPerms);475 await expect(executeTransaction(api, alice, tx1)).to.be.rejectedWith(/common\.PropertyLimitReached/);476477 const itemsListIndexBefore = await getLastTokenId(api, collectionId);478 expect(itemsListIndexBefore).to.be.equal(0);479 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);480481 const prps = [];482483 for (let i = 0; i < 65; i++) {484 prps.push({key: `key${i}`, value: `value${i}`});485 }486487 const args = [488 {NFT: {properties: prps}},489 {NFT: {properties: prps}},490 {NFT: {properties: prps}},491 ];492493 // there are no permissions, but will fail anyway because of too much weight for a block494 const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);495 await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;496 });497 });498499 it('Trying to add bigger property than allowed', async () => {500 await usingApi(async (api: ApiPromise) => {501 const collectionId = await createCollectionWithPropsExpectSuccess({502 propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],503 });504 const itemsListIndexBefore = await getLastTokenId(api, collectionId);505 expect(itemsListIndexBefore).to.be.equal(0);506 const args = [{NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},507 {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},508 {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];509510 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);511 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);512 });513 });514});1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';22import {23 createCollectionExpectSuccess,24 destroyCollectionExpectSuccess,25 getGenericResult,26 normalizeAccountId,27 setCollectionLimitsExpectSuccess,28 addCollectionAdminExpectSuccess,29 getBalance,30 getTokenOwner,31 getLastTokenId,32 getCreatedCollectionCount,33 createCollectionWithPropsExpectSuccess,34 createMultipleItemsWithPropsExpectSuccess,35 getTokenProperties,36} from './util/helpers';3738chai.use(chaiAsPromised);39const expect = chai.expect;4041describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {42 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {43 await usingApi(async (api, privateKeyWrapper) => {44 const collectionId = await createCollectionExpectSuccess();45 const itemsListIndexBefore = await getLastTokenId(api, collectionId);46 expect(itemsListIndexBefore).to.be.equal(0);4748 const alice = privateKeyWrapper!('//Alice');49 await submitTransactionAsync(50 alice, 51 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),52 );53 54 const args = [55 {NFT: {properties: [{key: 'data', value: '1'}]}},56 {NFT: {properties: [{key: 'data', value: '2'}]}},57 {NFT: {properties: [{key: 'data', value: '3'}]}},58 ];59 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);60 await submitTransactionAsync(alice, createMultipleItemsTx);61 const itemsListIndexAfter = await getLastTokenId(api, collectionId);62 expect(itemsListIndexAfter).to.be.equal(3);6364 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));65 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));66 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));6768 expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('1');69 expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('2');70 expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('3');71 });72 });7374 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {75 await usingApi(async (api, privateKeyWrapper) => {76 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});77 const itemsListIndexBefore = await getLastTokenId(api, collectionId);78 expect(itemsListIndexBefore).to.be.equal(0);79 const alice = privateKeyWrapper!('//Alice');80 const args = [81 {Fungible: {value: 1}},82 {Fungible: {value: 2}},83 {Fungible: {value: 3}},84 ];85 const createMultipleItemsTx = api.tx.unique86 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);87 await submitTransactionAsync(alice, createMultipleItemsTx);88 const token1Data = await getBalance(api, collectionId, alice.address, 0);8990 expect(token1Data).to.be.equal(6n); // 1 + 2 + 391 });92 });9394 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {95 await usingApi(async (api, privateKeyWrapper) => {96 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});97 const itemsListIndexBefore = await getLastTokenId(api, collectionId);98 expect(itemsListIndexBefore).to.be.equal(0);99 const alice = privateKeyWrapper!('//Alice');100 const args = [101 {ReFungible: {pieces: 1}},102 {ReFungible: {pieces: 2}},103 {ReFungible: {pieces: 3}},104 ];105 const createMultipleItemsTx = api.tx.unique106 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);107 await submitTransactionAsync(alice, createMultipleItemsTx);108 const itemsListIndexAfter = await getLastTokenId(api, collectionId);109 expect(itemsListIndexAfter).to.be.equal(3);110111 expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);112 expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(2n);113 expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(3n);114 });115 });116117 it('Can mint amount of items equals to collection limits', async () => {118 await usingApi(async (api, privateKeyWrapper) => {119 const alice = privateKeyWrapper!('//Alice');120121 const collectionId = await createCollectionExpectSuccess();122 await setCollectionLimitsExpectSuccess(alice, collectionId, {123 tokenLimit: 2,124 });125 const args = [126 {NFT: {}},127 {NFT: {}},128 ];129 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);130 const events = await submitTransactionAsync(alice, createMultipleItemsTx);131 const result = getGenericResult(events);132 expect(result.success).to.be.true;133 });134 });135136 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {137 await usingApi(async (api, privateKeyWrapper) => {138 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});139 const itemsListIndexBefore = await getLastTokenId(api, collectionId);140 expect(itemsListIndexBefore).to.be.equal(0);141 const alice = privateKeyWrapper!('//Alice');142 const args = [143 {NFT: {properties: [{key: 'k', value: 'v1'}]}},144 {NFT: {properties: [{key: 'k', value: 'v2'}]}},145 {NFT: {properties: [{key: 'k', value: 'v3'}]}},146 ];147148 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);149 const itemsListIndexAfter = await getLastTokenId(api, collectionId);150 expect(itemsListIndexAfter).to.be.equal(3);151152 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));153 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));154 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));155156 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');157 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');158 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');159 });160 });161162 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {163 await usingApi(async (api, privateKeyWrapper) => {164 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});165 const itemsListIndexBefore = await getLastTokenId(api, collectionId);166 expect(itemsListIndexBefore).to.be.equal(0);167 const alice = privateKeyWrapper!('//Alice');168 const bob = privateKeyWrapper!('//Bob');169 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);170 const args = [171 {NFT: {properties: [{key: 'k', value: 'v1'}]}},172 {NFT: {properties: [{key: 'k', value: 'v2'}]}},173 {NFT: {properties: [{key: 'k', value: 'v3'}]}},174 ];175176 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);177 const itemsListIndexAfter = await getLastTokenId(api, collectionId);178 expect(itemsListIndexAfter).to.be.equal(3);179180 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));181 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));182 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));183184 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');185 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');186 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');187 });188 });189190 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {191 await usingApi(async (api, privateKeyWrapper) => {192 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});193 const itemsListIndexBefore = await getLastTokenId(api, collectionId);194 expect(itemsListIndexBefore).to.be.equal(0);195 const alice = privateKeyWrapper!('//Alice');196 const args = [197 {NFT: {properties: [{key: 'k', value: 'v1'}]}},198 {NFT: {properties: [{key: 'k', value: 'v2'}]}},199 {NFT: {properties: [{key: 'k', value: 'v3'}]}},200 ];201202 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);203 const itemsListIndexAfter = await getLastTokenId(api, collectionId);204 expect(itemsListIndexAfter).to.be.equal(3);205206 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));207 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));208 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));209210 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');211 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');212 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');213 });214 });215});216217describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {218 let alice: IKeyringPair;219 let bob: IKeyringPair;220221 before(async () => {222 await usingApi(async (api, privateKeyWrapper) => {223 alice = privateKeyWrapper!('//Alice');224 bob = privateKeyWrapper!('//Bob');225 });226 });227228 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {229 await usingApi(async (api: ApiPromise) => {230 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});231 const itemsListIndexBefore = await getLastTokenId(api, collectionId);232 expect(itemsListIndexBefore).to.be.equal(0);233 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);234 const args = [235 {NFT: {properties: [{key: 'data', value: 'v1'}]}},236 {NFT: {properties: [{key: 'data', value: 'v2'}]}},237 {NFT: {properties: [{key: 'data', value: 'v3'}]}},238 ];239 const createMultipleItemsTx = api.tx.unique240 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);241 await submitTransactionAsync(bob, createMultipleItemsTx);242 const itemsListIndexAfter = await getLastTokenId(api, collectionId);243 expect(itemsListIndexAfter).to.be.equal(3);244245 expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));246 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));247 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));248249 expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('v1');250 expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('v2');251 expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('v3');252 });253 });254255 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {256 await usingApi(async (api: ApiPromise) => {257 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});258 const itemsListIndexBefore = await getLastTokenId(api, collectionId);259 expect(itemsListIndexBefore).to.be.equal(0);260 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);261 const args = [262 {Fungible: {value: 1}},263 {Fungible: {value: 2}},264 {Fungible: {value: 3}},265 ];266 const createMultipleItemsTx = api.tx.unique267 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);268 await submitTransactionAsync(bob, createMultipleItemsTx);269 const token1Data = await getBalance(api, collectionId, bob.address, 0);270271 expect(token1Data).to.be.equal(6n); // 1 + 2 + 3272 });273 });274275 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {276 await usingApi(async (api: ApiPromise) => {277 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});278 const itemsListIndexBefore = await getLastTokenId(api, collectionId);279 expect(itemsListIndexBefore).to.be.equal(0);280 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);281 const args = [282 {ReFungible: {pieces: 1}},283 {ReFungible: {pieces: 2}},284 {ReFungible: {pieces: 3}},285 ];286 const createMultipleItemsTx = api.tx.unique287 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);288 await submitTransactionAsync(bob, createMultipleItemsTx);289 const itemsListIndexAfter = await getLastTokenId(api, collectionId);290 expect(itemsListIndexAfter).to.be.equal(3);291292 expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);293 expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(2n);294 expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(3n);295 });296 });297});298299describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {300 let alice: IKeyringPair;301 let bob: IKeyringPair;302303 before(async () => {304 await usingApi(async (api, privateKeyWrapper) => {305 alice = privateKeyWrapper!('//Alice');306 bob = privateKeyWrapper!('//Bob');307 });308 });309310 it('Regular user cannot create items in active NFT collection', async () => {311 await usingApi(async (api: ApiPromise) => {312 const collectionId = await createCollectionExpectSuccess();313 const itemsListIndexBefore = await getLastTokenId(api, collectionId);314 expect(itemsListIndexBefore).to.be.equal(0);315 const args = [{NFT: {}},316 {NFT: {}},317 {NFT: {}}];318 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);319 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);320 });321 });322323 it('Regular user cannot create items in active Fungible collection', async () => {324 await usingApi(async (api: ApiPromise) => {325 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});326 const itemsListIndexBefore = await getLastTokenId(api, collectionId);327 expect(itemsListIndexBefore).to.be.equal(0);328 const args = [329 {Fungible: {value: 1}},330 {Fungible: {value: 2}},331 {Fungible: {value: 3}},332 ];333 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);334 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);335 });336 });337338 it('Regular user cannot create items in active ReFungible collection', async () => {339 await usingApi(async (api: ApiPromise) => {340 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});341 const itemsListIndexBefore = await getLastTokenId(api, collectionId);342 expect(itemsListIndexBefore).to.be.equal(0);343 const args = [344 {ReFungible: {pieces: 1}},345 {ReFungible: {pieces: 1}},346 {ReFungible: {pieces: 1}},347 ];348 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);349 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);350 });351 });352353 it('Create token in not existing collection', async () => {354 await usingApi(async (api: ApiPromise) => {355 const collectionId = await getCreatedCollectionCount(api) + 1;356 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);357 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionNotFound/);358 });359 });360361 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {362 await usingApi(async (api, privateKeyWrapper) => {363 // NFT364 const collectionId = await createCollectionWithPropsExpectSuccess({365 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],366 });367 const alice = privateKeyWrapper!('//Alice');368 const args = [369 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},370 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},371 {NFT: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},372 ];373 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);374 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;375376 // ReFungible377 const collectionIdReFungible =378 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});379 const argsReFungible = [380 {ReFungible: ['1'.repeat(2049), 10]},381 {ReFungible: ['2'.repeat(2049), 10]},382 {ReFungible: ['3'.repeat(2049), 10]},383 ];384 const createMultipleItemsTxFungible = api.tx.unique385 .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);386 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;387 });388 });389390 it('Create tokens with different types', async () => {391 await usingApi(async (api: ApiPromise) => {392 const collectionId = await createCollectionExpectSuccess();393 const createMultipleItemsTx = api.tx.unique394 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);395 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/);396 // garbage collection :-D // lol397 await destroyCollectionExpectSuccess(collectionId);398 });399 });400401 it('Create tokens with different data limits <> maximum data limit', async () => {402 await usingApi(async (api: ApiPromise) => {403 const collectionId = await createCollectionWithPropsExpectSuccess({404 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],405 });406 const args = [407 {NFT: {properties: [{key: 'key', value: 'A'}]}},408 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},409 ];410 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);411 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;412 });413 });414415 it('Fails when minting tokens exceeds collectionLimits amount', async () => {416 await usingApi(async (api) => {417 const collectionId = await createCollectionExpectSuccess();418 await setCollectionLimitsExpectSuccess(alice, collectionId, {419 tokenLimit: 1,420 });421 const args = [422 {NFT: {}},423 {NFT: {}},424 ];425 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);426 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);427 });428 });429430 it('User doesnt have editing rights', async () => {431 await usingApi(async (api: ApiPromise) => {432 const collectionId = await createCollectionWithPropsExpectSuccess({433 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],434 });435 const itemsListIndexBefore = await getLastTokenId(api, collectionId);436 expect(itemsListIndexBefore).to.be.equal(0);437 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);438 const args = [439 {NFT: {properties: [{key: 'key1', value: 'v2'}]}},440 {NFT: {}},441 {NFT: {}},442 ];443444 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);445 await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);446 });447 });448449 it('Adding property without access rights', async () => {450 await usingApi(async (api: ApiPromise) => {451 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'k', value: 'v1'}]});452 const itemsListIndexBefore = await getLastTokenId(api, collectionId);453 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);454 expect(itemsListIndexBefore).to.be.equal(0);455 const args = [{NFT: {properties: [{key: 'k', value: 'v'}]}},456 {NFT: {}},457 {NFT: {}}];458459 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);460 await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);461 });462 });463464 it('Adding more than 64 prps', async () => {465 await usingApi(async (api: ApiPromise) => {466 const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];467 for (let i = 0; i < 65; i++) {468 propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});469 }470471 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});472473 const tx1 = api.tx.unique.setPropertyPermissions(collectionId, propPerms);474 await expect(executeTransaction(api, alice, tx1)).to.be.rejectedWith(/common\.PropertyLimitReached/);475476 const itemsListIndexBefore = await getLastTokenId(api, collectionId);477 expect(itemsListIndexBefore).to.be.equal(0);478 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);479480 const prps = [];481482 for (let i = 0; i < 65; i++) {483 prps.push({key: `key${i}`, value: `value${i}`});484 }485486 const args = [487 {NFT: {properties: prps}},488 {NFT: {properties: prps}},489 {NFT: {properties: prps}},490 ];491492 // there are no permissions, but will fail anyway because of too much weight for a block493 const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);494 await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;495 });496 });497498 it('Trying to add bigger property than allowed', async () => {499 await usingApi(async (api: ApiPromise) => {500 const collectionId = await createCollectionWithPropsExpectSuccess({501 propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],502 });503 const itemsListIndexBefore = await getLastTokenId(api, collectionId);504 expect(itemsListIndexBefore).to.be.equal(0);505 const args = [{NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},506 {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},507 {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];508509 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);510 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);511 });512 });513});tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItemsEx.test.ts
+++ b/tests/src/createMultipleItemsEx.test.ts
@@ -15,17 +15,16 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {expect} from 'chai';
-import privateKey from './substrate/privateKey';
import usingApi, {executeTransaction} from './substrate/substrate-api';
-import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess} from './util/helpers';
+import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess} from './util/helpers';
describe('createMultipleItemsEx', () => {
it('can initialize multiple NFT with different owners', async () => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const data = [
{
owner: {substrate: alice.address},
@@ -47,10 +46,10 @@
it('createMultipleItemsEx with property Admin', async () => {
const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const data = [
{
owner: {substrate: alice.address},
@@ -75,10 +74,10 @@
it('createMultipleItemsEx with property AdminConst', async () => {
const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const data = [
{
owner: {substrate: alice.address},
@@ -103,10 +102,10 @@
it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {
const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const data = [
{
owner: {substrate: alice.address},
@@ -132,11 +131,11 @@
it('No editing rights', async () => {
const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await addCollectionAdminExpectSuccess(alice, collection, bob.address);
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
const data = [
{
owner: {substrate: alice.address},
@@ -161,10 +160,10 @@
it('User doesnt have editing rights', async () => {
const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- await addCollectionAdminExpectSuccess(alice, collection, bob.address);
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
const data = [
{
owner: {substrate: alice.address},
@@ -188,11 +187,11 @@
it('Adding property without access rights', async () => {
const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await addCollectionAdminExpectSuccess(alice, collection, bob.address);
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
const data = [
{
owner: {substrate: alice.address},
@@ -220,20 +219,20 @@
propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});
}
- const alice = privateKey('//Alice');
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
await expect(executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))).to.be.rejectedWith(/common\.PropertyLimitReached/);
});
});
it('Trying to add bigger property than allowed', async () => {
const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await addCollectionAdminExpectSuccess(alice, collection, bob.address);
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
+ await addCollectionAdminExpectSuccess(alice, collection, bob.address);
const data = [
{
owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],
@@ -253,10 +252,10 @@
it('can initialize multiple NFT with different owners', async () => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const data = [
{
owner: {substrate: alice.address},
@@ -278,10 +277,10 @@
it('can initialize multiple NFT with different owners', async () => {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const data = [
{
owner: {substrate: alice.address},
@@ -303,10 +302,10 @@
it('fails when trying to set multiple owners when creating multiple refungibles', async () => {
const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
-
- await usingApi(async (api) => {
+
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// Polkadot requires map, and yet requires keys to be JSON encoded
const users = new Map();
users.set(JSON.stringify({substrate: alice.address}), 1);
tests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -19,7 +19,6 @@
import chaiAsPromised from 'chai-as-promised';
import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {alicesPublicKey, bobsPublicKey} from './accounts';
-import privateKey from './substrate/privateKey';
import {IKeyringPair} from '@polkadot/types/types';
import {
createCollectionExpectSuccess,
@@ -65,20 +64,20 @@
describe('integration test: Fees must be credited to Treasury:', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
it('Total issuance does not change', async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
await skipInflationBlock(api);
await waitNewBlocks(api, 1);
const totalBefore = (await api.query.balances.totalIssuance()).toBigInt();
- const alicePrivateKey = privateKey('//Alice');
+ const alicePrivateKey = privateKeyWrapper!('//Alice');
const amount = 1n;
const transfer = api.tx.balances.transfer(bobsPublicKey, amount);
@@ -92,11 +91,11 @@
});
it('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
await skipInflationBlock(api);
await waitNewBlocks(api, 1);
- const alicePrivateKey = privateKey('//Alice');
+ const alicePrivateKey = privateKeyWrapper!('//Alice');
const treasuryBalanceBefore: bigint = (await api.query.system.account(TREASURY)).data.free.toBigInt();
const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
@@ -115,11 +114,11 @@
});
it('Treasury balance increased by failed tx fee', async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
//await skipInflationBlock(api);
await waitNewBlocks(api, 1);
- const bobPrivateKey = privateKey('//Bob');
+ const bobPrivateKey = privateKeyWrapper!('//Bob');
const treasuryBalanceBefore = (await api.query.system.account(TREASURY)).data.free.toBigInt();
const bobBalanceBefore = (await api.query.system.account(bobsPublicKey)).data.free.toBigInt();
tests/src/destroyCollection.test.tsdiffbeforeafterboth--- a/tests/src/destroyCollection.test.ts
+++ b/tests/src/destroyCollection.test.ts
@@ -17,7 +17,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import {default as usingApi} from './substrate/substrate-api';
import {createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
@@ -50,9 +49,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
tests/src/enableContractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/enableContractSponsoring.test.ts
+++ b/tests/src/enableContractSponsoring.test.ts
@@ -17,7 +17,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {deployFlipper, getFlipValue, toggleFlipValueExpectSuccess} from './util/contracthelpers';
import {
@@ -79,7 +78,9 @@
let alice: IKeyringPair;
before(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ });
});
it('fails when called for non-contract address', async () => {
tests/src/enableDisableTransfer.test.tsdiffbeforeafterboth--- a/tests/src/enableDisableTransfer.test.ts
+++ b/tests/src/enableDisableTransfer.test.ts
@@ -16,7 +16,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
createItemExpectSuccess,
@@ -31,9 +30,9 @@
describe('Enable/Disable Transfers', () => {
it('User can transfer token with enabled transfer flag', async () => {
- await usingApi(async () => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
@@ -46,9 +45,9 @@
});
it('User can\'n transfer token with disabled transfer flag', async () => {
- await usingApi(async () => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
@@ -63,8 +62,8 @@
describe('Negative Enable/Disable Transfers', () => {
it('Non-owner cannot change transfer flag', async () => {
- await usingApi(async () => {
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const bob = privateKeyWrapper!('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
tests/src/eth/base.test.tsdiffbeforeafterboth--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -28,7 +28,6 @@
import {expect} from 'chai';
import {createCollectionExpectSuccess, createItemExpectSuccess, UNIQUE} from '../util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
-import privateKey from '../substrate/privateKey';
import {Contract} from 'web3-eth-contract';
import Web3 from 'web3';
@@ -50,11 +49,11 @@
expect(cost - balanceB < BigInt(0.2 * Number(UNIQUE))).to.be.true;
});
- itWeb3('NFT transfer is close to 0.15 UNQ', async ({web3, api}) => {
+ itWeb3('NFT transfer is close to 0.15 UNQ', async ({web3, api, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionProperties.test.ts
+++ b/tests/src/eth/collectionProperties.test.ts
@@ -1,4 +1,3 @@
-import privateKey from '../substrate/privateKey';
import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess} from '../util/helpers';
import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
@@ -6,8 +5,8 @@
import {executeTransaction} from '../substrate/substrate-api';
describe('EVM collection properties', () => {
- itWeb3('Can be set', async({web3, api}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
@@ -21,8 +20,8 @@
const [{value}] = (await api.rpc.unique.collectionProperties(collection, ['testKey'])).toHuman()! as any;
expect(value).to.equal('testValue');
});
- itWeb3('Can be deleted', async({web3, api}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
@@ -38,8 +37,8 @@
const result = (await api.rpc.unique.collectionProperties(collection, ['testKey'])).toJSON()! as any;
expect(result.length).to.equal(0);
});
- itWeb3('Can be read', async({web3, api}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const caller = createEthAccount(web3);
const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});
tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -1,12 +1,11 @@
-import privateKey from '../substrate/privateKey';
import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, setCollectionSponsorExpectSuccess} from '../util/helpers';
import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents} from './util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
import {expect} from 'chai';
describe('evm collection sponsoring', () => {
- itWeb3('sponsors mint transactions', async ({web3}) => {
- const alice = privateKey('//Alice');
+ itWeb3('sponsors mint transactions', async ({web3, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const collection = await createCollectionExpectSuccess();
await setCollectionSponsorExpectSuccess(collection, alice.address);
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import privateKey from '../substrate/privateKey';
import {expect} from 'chai';
import {
contractHelpers,
@@ -63,8 +62,8 @@
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
});
- itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const caller = await createEthAccountWithBalance(api, web3);
@@ -91,8 +90,8 @@
expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);
});
- 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}) => {
- const alice = privateKey('//Alice');
+ 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}) => {
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const caller = createEthAccount(web3);
@@ -121,8 +120,8 @@
expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);
});
- 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}) => {
- const alice = privateKey('//Alice');
+ 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}) => {
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const caller = createEthAccount(web3);
@@ -149,8 +148,8 @@
expect(+balanceAfter).to.be.equals(+originalFlipperBalance);
});
- itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ 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}) => {
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const caller = await createEthAccountWithBalance(api, web3);
@@ -178,8 +177,8 @@
expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);
});
- itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ 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}) => {
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const caller = await createEthAccountWithBalance(api, web3);
@@ -301,9 +300,9 @@
});
//TODO: CORE-302 add eth methods
- itWeb3.skip('Check that transaction via EVM spend money from substrate address', async ({api, web3}) => {
- const owner = privateKey('//Alice');
- const user = privateKey(`//User/${Date.now()}`);
+ itWeb3.skip('Check that transaction via EVM spend money from substrate address', async ({api, web3, privateKeyWrapper}) => {
+ const owner = privateKeyWrapper!('//Alice');
+ const user = privateKeyWrapper!(`//User/${Date.now()}`);
const userEth = subToEth(user.address);
const collectionId = await createCollectionExpectSuccess();
await addCollectionAdminExpectSuccess(owner, collectionId, {Ethereum: userEth});
tests/src/eth/crossTransfer.test.tsdiffbeforeafterboth--- a/tests/src/eth/crossTransfer.test.ts
+++ b/tests/src/eth/crossTransfer.test.ts
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import privateKey from '../substrate/privateKey';
import {createCollectionExpectSuccess,
createFungibleItemExpectSuccess,
transferExpectSuccess,
@@ -28,27 +27,27 @@
import nonFungibleAbi from './nonFungibleAbi.json';
describe('Token transfer between substrate address and EVM address. Fungible', () => {
- 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 () => {
+ 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}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
await transferExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)} , 200, 'Fungible');
await transferFromExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');
await transferExpectSuccess(collection, 0, charlie, bob, 50, 'Fungible');
});
- 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}) => {
+ 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}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const bobProxy = await createEthAccountWithBalance(api, web3);
const aliceProxy = await createEthAccountWithBalance(api, web3);
@@ -64,28 +63,28 @@
});
describe('Token transfer between substrate address and EVM address. NFT', () => {
- 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 () => {
+ 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}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
await transferExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, 1, 'NFT');
await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');
await transferExpectSuccess(collection, tokenId, charlie, bob, 1, 'NFT');
});
- 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}) => {
+ 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}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const bobProxy = await createEthAccountWithBalance(api, web3);
const aliceProxy = await createEthAccountWithBalance(api, web3);
const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
tests/src/eth/fungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -14,19 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import privateKey from '../substrate/privateKey';
import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';
import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';
import fungibleAbi from './fungibleAbi.json';
import {expect} from 'chai';
describe('Fungible: Information getting', () => {
- itWeb3('totalSupply', async ({api, web3}) => {
+ itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
@@ -39,12 +38,12 @@
expect(totalSupply).to.equal('200');
});
- itWeb3('balanceOf', async ({api, web3}) => {
+ itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
@@ -59,12 +58,12 @@
});
describe('Fungible: Plain calls', () => {
- itWeb3('Can perform approve()', async ({web3, api}) => {
+ itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
@@ -98,12 +97,12 @@
}
});
- itWeb3('Can perform transferFrom()', async ({web3, api}) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner);
@@ -156,12 +155,12 @@
}
});
- itWeb3('Can perform transfer()', async ({web3, api}) => {
+ itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner);
@@ -203,11 +202,11 @@
});
describe('Fungible: Fees', () => {
- itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api}) => {
+ itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const spender = createEthAccount(web3);
@@ -221,11 +220,11 @@
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api}) => {
+ itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const spender = await createEthAccountWithBalance(api, web3);
@@ -241,11 +240,11 @@
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api}) => {
+ itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
@@ -261,11 +260,11 @@
});
describe('Fungible: Substrate calls', () => {
- itWeb3('Events emitted for approve()', async ({web3}) => {
+ itWeb3('Events emitted for approve()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const receiver = createEthAccount(web3);
@@ -291,12 +290,12 @@
]);
});
- itWeb3('Events emitted for transferFrom()', async ({web3}) => {
+ itWeb3('Events emitted for transferFrom()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const receiver = createEthAccount(web3);
@@ -332,11 +331,11 @@
]);
});
- itWeb3('Events emitted for transfer()', async ({web3}) => {
+ itWeb3('Events emitted for transfer()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const receiver = createEthAccount(web3);
tests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth--- a/tests/src/eth/marketplace/marketplace.test.ts
+++ b/tests/src/eth/marketplace/marketplace.test.ts
@@ -16,7 +16,6 @@
import {readFile} from 'fs/promises';
import {getBalanceSingle} from '../../substrate/get-balance';
-import privateKey from '../../substrate/privateKey';
import {
addToAllowListExpectSuccess,
confirmSponsorshipExpectSuccess,
@@ -38,8 +37,8 @@
const PRICE = 2000n;
describe('Matcher contract usage', () => {
- itWeb3('With UNQ', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ itWeb3('With UNQ', async ({api, web3, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const matcherOwner = await createEthAccountWithBalance(api, web3);
const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
from: matcherOwner,
@@ -61,7 +60,7 @@
await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});
await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));
- const seller = privateKey(`//Seller/${Date.now()}`);
+ const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);
await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
@@ -99,8 +98,8 @@
});
- itWeb3('With escrow', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ itWeb3('With escrow', async ({api, web3, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const matcherOwner = await createEthAccountWithBalance(api, web3);
const escrow = await createEthAccountWithBalance(api, web3);
const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
@@ -124,7 +123,7 @@
await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});
await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));
- const seller = privateKey(`//Seller/${Date.now()}`);
+ const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);
await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
@@ -170,8 +169,8 @@
});
- itWeb3('Sell tokens from substrate user via EVM contract', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Sell tokens from substrate user via EVM contract', async ({api, web3, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const matcherOwner = await createEthAccountWithBalance(api, web3);
const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
from: matcherOwner,
@@ -184,7 +183,7 @@
await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});
const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
- const seller = privateKey(`//Seller/${Date.now()}`);
+ const seller = privateKeyWrapper!(`//Seller/${Date.now()}`);
await transferBalanceTo(api, alice, seller.address);
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
tests/src/eth/migration.test.tsdiffbeforeafterboth--- a/tests/src/eth/migration.test.ts
+++ b/tests/src/eth/migration.test.ts
@@ -15,12 +15,11 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {expect} from 'chai';
-import privateKey from '../substrate/privateKey';
import {submitTransactionAsync} from '../substrate/substrate-api';
import {createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';
describe('EVM Migrations', () => {
- itWeb3('Deploy contract saved state', async ({web3, api}) => {
+ itWeb3('Deploy contract saved state', async ({web3, api, privateKeyWrapper}) => {
/*
contract StatefulContract {
uint counter;
@@ -54,7 +53,7 @@
['0xedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b567643', '0x0000000000000000000000000000000000000000000000000000000000000004'],
];
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS) as any));
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import privateKey from '../substrate/privateKey';
import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';
import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
@@ -22,11 +21,11 @@
import {submitTransactionAsync} from '../substrate/substrate-api';
describe('NFT: Information getting', () => {
- itWeb3('totalSupply', async ({api, web3}) => {
+ itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
@@ -38,11 +37,11 @@
expect(totalSupply).to.equal('1');
});
- itWeb3('balanceOf', async ({api, web3}) => {
+ itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum:caller});
@@ -56,11 +55,11 @@
expect(balance).to.equal('3');
});
- itWeb3('ownerOf', async ({api, web3}) => {
+ itWeb3('ownerOf', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
@@ -114,11 +113,11 @@
});
//TODO: CORE-302 add eth methods
- itWeb3.skip('Can perform mintBulk()', async ({web3, api}) => {
+ itWeb3.skip('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});
@@ -177,11 +176,11 @@
}
});
- itWeb3('Can perform burn()', async ({web3, api}) => {
+ itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
@@ -208,11 +207,11 @@
}
});
- itWeb3('Can perform approve()', async ({web3, api}) => {
+ itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner);
@@ -242,11 +241,11 @@
}
});
- itWeb3('Can perform transferFrom()', async ({web3, api}) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner);
@@ -290,11 +289,11 @@
}
});
- itWeb3('Can perform transfer()', async ({web3, api}) => {
+ itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner);
@@ -336,11 +335,11 @@
});
describe('NFT: Fees', () => {
- itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api}) => {
+ itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const spender = createEthAccount(web3);
@@ -354,11 +353,11 @@
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api}) => {
+ itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const spender = await createEthAccountWithBalance(api, web3);
@@ -374,11 +373,11 @@
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api}) => {
+ itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
@@ -394,11 +393,11 @@
});
describe('NFT: Substrate calls', () => {
- itWeb3('Events emitted for mint()', async ({web3}) => {
+ itWeb3('Events emitted for mint()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
@@ -421,11 +420,11 @@
]);
});
- itWeb3('Events emitted for burn()', async ({web3}) => {
+ itWeb3('Events emitted for burn()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
@@ -448,11 +447,11 @@
]);
});
- itWeb3('Events emitted for approve()', async ({web3}) => {
+ itWeb3('Events emitted for approve()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const receiver = createEthAccount(web3);
@@ -478,12 +477,12 @@
]);
});
- itWeb3('Events emitted for transferFrom()', async ({web3}) => {
+ itWeb3('Events emitted for transferFrom()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const receiver = createEthAccount(web3);
@@ -510,11 +509,11 @@
]);
});
- itWeb3('Events emitted for transfer()', async ({web3}) => {
+ itWeb3('Events emitted for transfer()', async ({web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const receiver = createEthAccount(web3);
tests/src/eth/payable.test.tsdiffbeforeafterboth--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {expect} from 'chai';
-import privateKey from '../substrate/privateKey';
import {submitTransactionAsync} from '../substrate/substrate-api';
import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';
import {evmToAddress} from '@polkadot/util-crypto';
@@ -32,10 +31,10 @@
expect(await contract.methods.getCollected().call()).to.be.equal('10000');
});
- itWeb3('Evm contract can receive wei from substrate account', async ({api, web3}) => {
+ itWeb3('Evm contract can receive wei from substrate account', async ({api, web3, privateKeyWrapper}) => {
const deployer = await createEthAccountWithBalance(api, web3);
const contract = await deployCollector(web3, deployer);
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
// Transaction fee/value will be payed from subToEth(sender) evm balance,
// which is backed by evmToAddress(subToEth(sender)) substrate balance
@@ -62,27 +61,27 @@
});
// We can't handle sending balance to backing storage of evm balance, because evmToAddress operation is irreversible
- itWeb3('Wei sent directly to backing storage of evm contract balance is unaccounted', async({api, web3}) => {
+ itWeb3('Wei sent directly to backing storage of evm contract balance is unaccounted', async({api, web3, privateKeyWrapper}) => {
const deployer = await createEthAccountWithBalance(api, web3);
const contract = await deployCollector(web3, deployer);
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
await transferBalanceExpectSuccess(api, alice, evmToAddress(contract.options.address), '10000');
expect(await contract.methods.getUnaccounted().call()).to.be.equal('10000');
});
- itWeb3('Balance can be retrieved from evm contract', async({api, web3}) => {
+ itWeb3('Balance can be retrieved from evm contract', async({api, web3, privateKeyWrapper}) => {
const FEE_BALANCE = 1000n * UNIQUE;
const CONTRACT_BALANCE = 1n * UNIQUE;
const deployer = await createEthAccountWithBalance(api, web3);
const contract = await deployCollector(web3, deployer);
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), ...GAS_ARGS});
- const receiver = privateKey(`//Receiver${Date.now()}`);
+ const receiver = privateKeyWrapper!(`//Receiver${Date.now()}`);
// First receive balance on eth balance of bob
{
tests/src/eth/proxy/fungibleProxy.test.tsdiffbeforeafterboth--- a/tests/src/eth/proxy/fungibleProxy.test.ts
+++ b/tests/src/eth/proxy/fungibleProxy.test.ts
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import privateKey from '../../substrate/privateKey';
import {createCollectionExpectSuccess, createFungibleItemExpectSuccess} from '../../util/helpers';
import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';
import fungibleAbi from '../fungibleAbi.json';
@@ -35,12 +34,12 @@
}
describe('Fungible (Via EVM proxy): Information getting', () => {
- itWeb3('totalSupply', async ({api, web3}) => {
+ itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
@@ -52,12 +51,12 @@
expect(totalSupply).to.equal('200');
});
- itWeb3('balanceOf', async ({api, web3}) => {
+ itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: caller});
@@ -71,12 +70,12 @@
});
describe('Fungible (Via EVM proxy): Plain calls', () => {
- itWeb3('Can perform approve()', async ({web3, api}) => {
+ itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const spender = createEthAccount(web3);
@@ -107,12 +106,12 @@
}
});
- itWeb3('Can perform transferFrom()', async ({web3, api}) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const owner = await createEthAccountWithBalance(api, web3);
@@ -162,12 +161,12 @@
}
});
- itWeb3('Can perform transfer()', async ({web3, api}) => {
+ itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
mode: {type: 'Fungible', decimalPoints: 0},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const receiver = await createEthAccountWithBalance(api, web3);
tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import privateKey from '../../substrate/privateKey';
import {createCollectionExpectSuccess, createItemExpectSuccess} from '../../util/helpers';
import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';
import nonFungibleAbi from '../nonFungibleAbi.json';
@@ -36,11 +35,11 @@
}
describe('NFT (Via EVM proxy): Information getting', () => {
- itWeb3('totalSupply', async ({api, web3}) => {
+ itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
@@ -52,11 +51,11 @@
expect(totalSupply).to.equal('1');
});
- itWeb3('balanceOf', async ({api, web3}) => {
+ itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
@@ -70,11 +69,11 @@
expect(balance).to.equal('3');
});
- itWeb3('ownerOf', async ({api, web3}) => {
+ itWeb3('ownerOf', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
@@ -89,11 +88,11 @@
describe('NFT (Via EVM proxy): Plain calls', () => {
//TODO: CORE-302 add eth methods
- itWeb3.skip('Can perform mint()', async ({web3, api}) => {
+ itWeb3.skip('Can perform mint()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
@@ -130,11 +129,11 @@
});
//TODO: CORE-302 add eth methods
- itWeb3.skip('Can perform mintBulk()', async ({web3, api}) => {
+ itWeb3.skip('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
@@ -193,11 +192,11 @@
}
});
- itWeb3('Can perform burn()', async ({web3, api}) => {
+ itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const address = collectionIdToAddress(collection);
@@ -225,11 +224,11 @@
}
});
- itWeb3('Can perform approve()', async ({web3, api}) => {
+ itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const spender = createEthAccount(web3);
@@ -255,11 +254,11 @@
}
});
- itWeb3('Can perform transferFrom()', async ({web3, api}) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const owner = await createEthAccountWithBalance(api, web3);
@@ -299,11 +298,11 @@
}
});
- itWeb3('Can perform transfer()', async ({web3, api}) => {
+ itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
tests/src/eth/sponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/sponsoring.test.ts
+++ b/tests/src/eth/sponsoring.test.ts
@@ -15,12 +15,11 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {expect} from 'chai';
-import privateKey from '../substrate/privateKey';
import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployCollector, deployFlipper, itWeb3, SponsoringMode, transferBalanceToEth} from './util/helpers';
describe('EVM sponsoring', () => {
- itWeb3('Fee is deducted from contract if sponsoring is enabled', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Fee is deducted from contract if sponsoring is enabled', async ({api, web3, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const caller = createEthAccount(web3);
@@ -50,8 +49,8 @@
expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);
expect(await web3.eth.getBalance(flipper.options.address)).to.be.not.equals(originalFlipperBalance);
});
- itWeb3('...but this doesn\'t applies to payable value', async ({api, web3}) => {
- const alice = privateKey('//Alice');
+ itWeb3('...but this doesn\'t applies to payable value', async ({api, web3, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const caller = await createEthAccountWithBalance(api, web3);
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -1,4 +1,3 @@
-import privateKey from '../substrate/privateKey';
import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess} from '../util/helpers';
import {cartesian, collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
@@ -6,8 +5,8 @@
import {executeTransaction} from '../substrate/substrate-api';
describe('EVM token properties', () => {
- itWeb3('Can be reconfigured', async({web3, api}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Can be reconfigured', async({web3, api, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
@@ -24,8 +23,8 @@
});
}
});
- itWeb3('Can be set', async({web3, api}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Can be set', async({web3, api, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
const token = await createItemExpectSuccess(alice, collection, 'NFT');
@@ -47,8 +46,8 @@
const [{value}] = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toHuman()! as any;
expect(value).to.equal('testValue');
});
- itWeb3('Can be deleted', async({web3, api}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Can be deleted', async({web3, api, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
const token = await createItemExpectSuccess(alice, collection, 'NFT');
@@ -72,8 +71,8 @@
const result = (await api.rpc.unique.tokenProperties(collection, token, ['testKey'])).toJSON()! as any;
expect(result.length).to.equal(0);
});
- itWeb3('Can be read', async({web3, api}) => {
- const alice = privateKey('//Alice');
+ itWeb3('Can be read', async({web3, api, privateKeyWrapper}) => {
+ const alice = privateKeyWrapper!('//Alice');
const caller = createEthAccount(web3);
const collection = await createCollectionExpectSuccess({mode: {type:'NFT'}});
const token = await createItemExpectSuccess(alice, collection, 'NFT');
tests/src/eth/util/helpers.tsdiffbeforeafterboth--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -18,20 +18,20 @@
/// <reference path="helpers.d.ts" />
import {ApiPromise} from '@polkadot/api';
-import {addressToEvm, evmToAddress} from '@polkadot/util-crypto';
-import Web3 from 'web3';
-import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';
import {IKeyringPair} from '@polkadot/types/types';
+import {addressToEvm, evmToAddress} from '@polkadot/util-crypto';
import {expect} from 'chai';
-import {CrossAccountId, getDetailedCollectionInfo, getGenericResult, UNIQUE} from '../../util/helpers';
import * as solc from 'solc';
+import Web3 from 'web3';
import config from '../../config';
+import getBalance from '../../substrate/get-balance';
import privateKey from '../../substrate/privateKey';
-import contractHelpersAbi from './contractHelpersAbi.json';
-import nonFungibleAbi from '../nonFungibleAbi.json';
+import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';
+import waitNewBlocks from '../../substrate/wait-new-blocks';
+import {CrossAccountId, getDetailedCollectionInfo, getGenericResult, UNIQUE} from '../../util/helpers';
import collectionHelpersAbi from '../collectionHelpersAbi.json';
-import getBalance from '../../substrate/get-balance';
-import waitNewBlocks from '../../substrate/wait-new-blocks';
+import nonFungibleAbi from '../nonFungibleAbi.json';
+import contractHelpersAbi from './contractHelpersAbi.json';
export const GAS_ARGS = {gas: 2500000};
@@ -139,8 +139,8 @@
});
});
}
-itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, {only: true});
-itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, {skip: true});
+itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {only: true});
+itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise, privateKeyWrapper?: (account: string) => IKeyringPair }) => any) => itWeb3(name, cb, {skip: true});
export async function generateSubstrateEthPair(web3: Web3) {
const account = web3.eth.accounts.create();
tests/src/inflation.test.tsdiffbeforeafterboth--- a/tests/src/inflation.test.ts
+++ b/tests/src/inflation.test.ts
@@ -17,22 +17,21 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import privateKey from './substrate/privateKey';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('integration test: Inflation', () => {
it('First year inflation is 10%', async () => {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Make sure non-sudo can't start inflation
const tx = api.tx.inflation.startInflation(1);
- const bob = privateKey('//Bob');
+ const bob = privateKeyWrapper!('//Bob');
await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
// Start inflation on relay block 1 (Alice is sudo)
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const sudoTx = api.tx.sudo.sudo(tx as any);
await submitTransactionAsync(alice, sudoTx);
tests/src/limits.test.tsdiffbeforeafterboth--- a/tests/src/limits.test.ts
+++ b/tests/src/limits.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
createCollectionExpectSuccess,
@@ -35,8 +34,8 @@
let alice: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
@@ -69,8 +68,8 @@
let alice: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
@@ -103,10 +102,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -166,10 +165,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -233,10 +232,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -296,10 +295,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -337,10 +336,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -369,10 +368,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
tests/src/mintModes.test.tsdiffbeforeafterboth--- a/tests/src/mintModes.test.ts
+++ b/tests/src/mintModes.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
addToAllowListExpectSuccess,
@@ -33,9 +32,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -112,9 +111,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
tests/src/nesting/graphs.test.tsdiffbeforeafterboth--- a/tests/src/nesting/graphs.test.ts
+++ b/tests/src/nesting/graphs.test.ts
@@ -2,7 +2,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import {expect} from 'chai';
import {tokenIdToCross} from '../eth/util/helpers';
-import privateKey from '../substrate/privateKey';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {getCreateCollectionResult, transferExpectSuccess} from '../util/helpers';
@@ -34,8 +33,8 @@
describe('Graphs', () => {
it('Ouroboros can\'t be created in a complex graph', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
const collection = await buildComplexObjectGraph(api, alice);
// to self
tests/src/nesting/migration-check.test.tsdiffbeforeafterboth--- a/tests/src/nesting/migration-check.test.ts
+++ b/tests/src/nesting/migration-check.test.ts
@@ -1,5 +1,4 @@
import {expect} from 'chai';
-import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {getCreateCollectionResult} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
@@ -13,8 +12,8 @@
let alice: IKeyringPair;
before(async() => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
});
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -1,6 +1,5 @@
import {expect} from 'chai';
import {tokenIdToAddress} from '../eth/util/helpers';
-import privateKey from '../substrate/privateKey';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {
addToAllowListExpectSuccess,
@@ -23,9 +22,9 @@
describe('Integration Test: Nesting', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -226,9 +225,9 @@
describe('Negative Test: Nesting', async() => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
tests/src/nesting/properties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -1,5 +1,4 @@
import {expect} from 'chai';
-import privateKey from '../substrate/privateKey';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {
addCollectionAdminExpectSuccess,
@@ -16,9 +15,9 @@
describe('Composite Properties Test', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -63,9 +62,9 @@
describe('Integration Test: Collection Properties', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -158,9 +157,9 @@
describe('Negative Integration Test: Collection Properties', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -290,9 +289,9 @@
describe('Integration Test: Access Rights to Token Properties', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -356,9 +355,9 @@
describe('Negative Integration Test: Access Rights to Token Properties', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -474,10 +473,10 @@
let permissions: {permission: any, signers: IKeyringPair[]}[];
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
permissions = [
{permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob]},
@@ -639,11 +638,11 @@
let constitution: {permission: any, signers: IKeyringPair[], sinner: IKeyringPair}[];
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
- const dave = privateKey('//Dave');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
+ const dave = privateKeyWrapper!('//Dave');
constitution = [
{permission: {mutable: true, collectionAdmin: true}, signers: [alice, bob], sinner: charlie},
tests/src/nesting/rules-smoke.test.tsdiffbeforeafterboth--- a/tests/src/nesting/rules-smoke.test.ts
+++ b/tests/src/nesting/rules-smoke.test.ts
@@ -1,6 +1,5 @@
import {expect} from 'chai';
import {tokenIdToAddress} from '../eth/util/helpers';
-import privateKey from '../substrate/privateKey';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, CrossAccountId, getCreateCollectionResult} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
@@ -9,9 +8,9 @@
let alice!: IKeyringPair;
let nestTarget!: CrossAccountId;
before(async() => {
- await usingApi(async api => {
- alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({
mode: 'NFT',
permissions: {
tests/src/nesting/unnest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/unnest.test.ts
+++ b/tests/src/nesting/unnest.test.ts
@@ -1,6 +1,5 @@
import {expect} from 'chai';
import {tokenIdToAddress} from '../eth/util/helpers';
-import privateKey from '../substrate/privateKey';
import usingApi, {executeTransaction} from '../substrate/substrate-api';
import {
createCollectionExpectSuccess,
@@ -19,9 +18,9 @@
describe('Integration Test: Unnesting', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -110,9 +109,9 @@
describe('Negative Test: Unnesting', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
tests/src/nextSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/nextSponsoring.test.ts
+++ b/tests/src/nextSponsoring.test.ts
@@ -18,7 +18,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import {default as usingApi} from './substrate/substrate-api';
import {
createCollectionExpectSuccess,
@@ -40,9 +39,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
tests/src/overflow.test.tsdiffbeforeafterboth--- a/tests/src/overflow.test.ts
+++ b/tests/src/overflow.test.ts
@@ -17,7 +17,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from './util/helpers';
@@ -30,10 +29,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -14,10 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import {ApiPromise} from '@polkadot/api';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';
@@ -26,10 +24,10 @@
describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
it('Remove collection admin.', async () => {
- await usingApi(async (api: ApiPromise) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.deep.eq(alice.address);
// first - add collection admin Bob
@@ -49,11 +47,11 @@
});
it('Remove collection admin by admin.', async () => {
- await usingApi(async (api: ApiPromise) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const collection = await queryCollectionExpectSuccess(api, collectionId);
expect(collection.owner.toString()).to.be.eq(alice.address);
// first - add collection admin Bob
@@ -76,8 +74,8 @@
});
it('Remove admin from collection that has no admins', async () => {
- await usingApi(async (api: ApiPromise) => {
- const alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
const collectionId = await createCollectionExpectSuccess();
const adminListBeforeAddAdmin = await getAdminList(api, collectionId);
@@ -91,11 +89,11 @@
describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
it('Can\'t remove collection admin from not existing collection', async () => {
- await usingApi(async (api: ApiPromise) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// tslint:disable-next-line: no-bitwise
const collectionId = (1 << 32) - 1;
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));
await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
@@ -106,11 +104,11 @@
});
it('Can\'t remove collection admin from deleted collection', async () => {
- await usingApi(async (api: ApiPromise) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// tslint:disable-next-line: no-bitwise
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
await destroyCollectionExpectSuccess(collectionId);
@@ -123,11 +121,11 @@
});
it('Regular user Can\'t remove collection admin', async () => {
- await usingApi(async (api: ApiPromise) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const collectionId = await createCollectionExpectSuccess();
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
await submitTransactionAsync(alice, addAdminTx);
tests/src/removeFromAllowList.test.tsdiffbeforeafterboth--- a/tests/src/removeFromAllowList.test.ts
+++ b/tests/src/removeFromAllowList.test.ts
@@ -31,7 +31,6 @@
addCollectionAdminExpectSuccess,
} from './util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -41,9 +40,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -75,9 +74,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -107,10 +106,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
tests/src/removeFromContractAllowList.test.tsdiffbeforeafterboth--- a/tests/src/removeFromContractAllowList.test.ts
+++ b/tests/src/removeFromContractAllowList.test.ts
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';
import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from './util/helpers';
@@ -25,8 +24,8 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -70,9 +69,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
tests/src/rpc.load.tsdiffbeforeafterboth--- a/tests/src/rpc.load.ts
+++ b/tests/src/rpc.load.ts
@@ -20,7 +20,6 @@
import {ApiPromise, Keyring} from '@polkadot/api';
import {findUnusedAddress} from './util/helpers';
import fs from 'fs';
-import privateKey from './substrate/privateKey';
const value = 0;
const gasLimit = 500000n * 1000000n;
@@ -121,13 +120,13 @@
});
it('Smart Contract RPC Load Test', async () => {
- await usingApi(async api => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Deploy smart contract
const [contract, deployer] = await deployLoadTester(api);
// Fill smart contract up with data
- const bob = privateKey('//Bob');
+ const bob = privateKeyWrapper!('//Bob');
const tx = contract.tx.bloat(value, gasLimit, 200);
await submitTransactionAsync(bob, tx);
tests/src/scheduler.test.tsdiffbeforeafterboth--- a/tests/src/scheduler.test.ts
+++ b/tests/src/scheduler.test.ts
@@ -16,7 +16,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
createItemExpectSuccess,
@@ -30,9 +29,9 @@
describe.skip('Integration Test scheduler base transaction', () => {
it('User can transfer owned token with delay (scheduler)', async () => {
- await usingApi(async () => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
tests/src/setChainLimits.test.tsdiffbeforeafterboth--- a/tests/src/setChainLimits.test.ts
+++ b/tests/src/setChainLimits.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
createCollectionExpectSuccess,
@@ -31,10 +30,10 @@
let limits: IChainLimits;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- dave = privateKey('//Dave');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ dave = privateKeyWrapper!('//Dave');
limits = {
collectionNumbersLimit : 1,
accountTokenOwnershipLimit: 1,
tests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth--- a/tests/src/setContractSponsoringRateLimit.test.ts
+++ b/tests/src/setContractSponsoringRateLimit.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import waitNewBlocks from './substrate/wait-new-blocks';
import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';
@@ -57,7 +56,9 @@
let alice: IKeyringPair;
before(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ });
});
it('fails when called for non-contract address', async () => {
tests/src/setMintPermission.test.tsdiffbeforeafterboth--- a/tests/src/setMintPermission.test.ts
+++ b/tests/src/setMintPermission.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
addToAllowListExpectSuccess,
@@ -35,9 +34,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -75,9 +74,9 @@
let bob: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth--- a/tests/src/setPublicAccessMode.test.ts
+++ b/tests/src/setPublicAccessMode.test.ts
@@ -19,7 +19,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
addToAllowListExpectSuccess,
@@ -41,9 +40,9 @@
describe('Integration Test setPublicAccessMode(): ', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -108,9 +107,9 @@
describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
it('setPublicAccessMode by collection admin', async () => {
tests/src/toggleContractAllowList.test.tsdiffbeforeafterboth--- a/tests/src/toggleContractAllowList.test.ts
+++ b/tests/src/toggleContractAllowList.test.ts
@@ -17,7 +17,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import privateKey from './substrate/privateKey';
import {
deployFlipper,
getFlipValue,
@@ -50,8 +49,8 @@
});
it('Only allowlisted account can call contract', async () => {
- await usingApi(async api => {
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const bob = privateKeyWrapper!('//Bob');
const [contract, deployer] = await deployFlipper(api);
@@ -135,9 +134,9 @@
describe.skip('Negative Integration Test toggleContractAllowList', () => {
it('Enable allow list for a non-contract', async () => {
- await usingApi(async api => {
- const alice = privateKey('//Alice');
- const bobGuineaPig = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bobGuineaPig = privateKeyWrapper!('//Bob');
const enabledBefore = (await api.query.unique.contractAllowListEnabled(bobGuineaPig.address)).toJSON();
const enableAllowListTx = api.tx.unique.toggleContractAllowList(bobGuineaPig.address, true);
@@ -150,8 +149,8 @@
});
it('Enable allow list using a non-owner address', async () => {
- await usingApi(async api => {
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const bob = privateKeyWrapper!('//Bob');
const [contract] = await deployFlipper(api);
const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();
tests/src/transfer.nload.tsdiffbeforeafterboth--- a/tests/src/transfer.nload.ts
+++ b/tests/src/transfer.nload.ts
@@ -16,7 +16,6 @@
import {ApiPromise} from '@polkadot/api';
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
import usingApi, {submitTransactionAsync} from './substrate/substrate-api';
import waitNewBlocks from './substrate/wait-new-blocks';
import {findUnusedAddresses} from './util/helpers';
@@ -95,11 +94,11 @@
});
const waiting: Promise<void>[] = [];
console.log(`Starting ${os.cpus().length} workers`);
- usingApi(async (api) => {
- const alice = privateKey('//Alice');
+ usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
for (const id in os.cpus()) {
const WORKER_NAME = `//LoadWorker${id}_${Date.now()}`;
- const workerAccount = privateKey(WORKER_NAME);
+ const workerAccount = privateKeyWrapper!(WORKER_NAME);
const tx = api.tx.balances.transfer(workerAccount.address, 400n * 10n ** 23n);
await submitTransactionAsync(alice, tx);
@@ -119,8 +118,8 @@
});
} else {
increaseCounter('startedWorkers', 1);
- usingApi(async (api) => {
- await distributeBalance(privateKey(process.env.WORKER_NAME as string), api, 400n * 10n ** 22n, 10);
+ usingApi(async (api, privateKeyWrapper) => {
+ await distributeBalance(privateKeyWrapper!(process.env.WORKER_NAME as string), api, 400n * 10n ** 22n, 10);
});
const interval = setInterval(() => {
flushCounterToMaster();
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -19,7 +19,6 @@
import {expect} from 'chai';
import {alicesPublicKey, bobsPublicKey} from './accounts';
import getBalance from './substrate/get-balance';
-import privateKey from './substrate/privateKey';
import {default as usingApi, submitTransactionAsync} from './substrate/substrate-api';
import {
burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess,
@@ -49,10 +48,10 @@
describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
it('Balance transfers and check balance', async () => {
- await usingApi(async (api: ApiPromise) => {
+ await usingApi(async (api, privateKeyWrapper) => {
const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);
- const alicePrivateKey = privateKey('//Alice');
+ const alicePrivateKey = privateKeyWrapper!('//Alice');
const transfer = api.tx.balances.transfer(bobsPublicKey, 1n);
const events = await submitTransactionAsync(alicePrivateKey, transfer);
@@ -87,9 +86,9 @@
});
it('User can transfer owned token', async () => {
- await usingApi(async () => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
@@ -114,9 +113,9 @@
});
it('Collection admin can transfer owned token', async () => {
- await usingApi(async () => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
@@ -145,10 +144,10 @@
describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
it('Transfer with not existed collection_id', async () => {
@@ -258,9 +257,9 @@
describe('Zero value transfer(From)', () => {
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
});
});
@@ -315,9 +314,9 @@
});
describe('Transfers to self (potentially over substrate-evm boundary)', () => {
- itWeb3('Transfers to self. In case of same frontend', async ({api}) => {
+ itWeb3('Transfers to self. In case of same frontend', async ({api, privateKeyWrapper}) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const aliceProxy = subToEth(alice.address);
const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
await transferExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy}, 10, 'Fungible');
@@ -327,9 +326,9 @@
expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);
});
- itWeb3('Transfers to self. In case of substrate-evm boundary', async ({api}) => {
+ itWeb3('Transfers to self. In case of substrate-evm boundary', async ({api, privateKeyWrapper}) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const aliceProxy = subToEth(alice.address);
const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);
@@ -339,9 +338,9 @@
expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);
});
- itWeb3('Transfers to self. In case of inside substrate-evm', async ({api}) => {
+ itWeb3('Transfers to self. In case of inside substrate-evm', async ({api, privateKeyWrapper}) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);
await transferExpectSuccess(collectionId, tokenId, alice, alice , 10, 'Fungible');
@@ -350,9 +349,9 @@
expect(balanceAliceBefore).to.be.eq(balanceAliceAfter);
});
- itWeb3('Transfers to self. In case of inside substrate-evm when not enought "Fungibles"', async ({api}) => {
+ itWeb3('Transfers to self. In case of inside substrate-evm when not enought "Fungibles"', async ({api, privateKeyWrapper}) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const alice = privateKey('//Alice');
+ const alice = privateKeyWrapper!('//Alice');
const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address});
const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId);
await transferExpectFailure(collectionId, tokenId, alice, alice , 11);
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -18,7 +18,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
import {default as usingApi} from './substrate/substrate-api';
import {
approveExpectFail,
@@ -43,10 +42,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -83,10 +82,10 @@
});
it('Should reduce allowance if value is big', async () => {
- await usingApi(async (api) => {
- const alice = privateKey('//Alice');
- const bob = privateKey('//Bob');
- const charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const alice = privateKeyWrapper!('//Alice');
+ const bob = privateKeyWrapper!('//Bob');
+ const charlie = privateKeyWrapper!('//Charlie');
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
@@ -112,10 +111,10 @@
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
- bob = privateKey('//Bob');
- charlie = privateKey('//Charlie');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
+ bob = privateKeyWrapper!('//Bob');
+ charlie = privateKeyWrapper!('//Charlie');
});
});
@@ -216,8 +215,8 @@
});
it('execute transferFrom from account that is not owner of collection', async () => {
- await usingApi(async () => {
- const dave = privateKey('//Dave');
+ await usingApi(async (api, privateKeyWrapper) => {
+ const dave = privateKeyWrapper!('//Dave');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -24,7 +24,6 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import {alicesPublicKey} from '../accounts';
-import privateKey from '../substrate/privateKey';
import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';
import {hexToStr, strToUTF16, utf16ToStr} from './util';
import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';
@@ -325,12 +324,12 @@
const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
let collectionId = 0;
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Get number of collections before the transaction
const collectionCountBefore = await getCreatedCollectionCount(api);
// Run the CreateCollection transaction
- const alicePrivateKey = privateKey('//Alice');
+ const alicePrivateKey = privateKeyWrapper!('//Alice');
let modeprm = {};
if (mode.type === 'NFT') {
@@ -378,12 +377,12 @@
const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
let collectionId = 0;
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Get number of collections before the transaction
const collectionCountBefore = await getCreatedCollectionCount(api);
// Run the CreateCollection transaction
- const alicePrivateKey = privateKey('//Alice');
+ const alicePrivateKey = privateKeyWrapper!('//Alice');
let modeprm = {};
if (mode.type === 'NFT') {
@@ -426,12 +425,12 @@
export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {
const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Get number of collections before the transaction
const collectionCountBefore = await getCreatedCollectionCount(api);
// Run the CreateCollection transaction
- const alicePrivateKey = privateKey('//Alice');
+ const alicePrivateKey = privateKeyWrapper!('//Alice');
let modeprm = {};
if (mode.type === 'NFT') {
@@ -465,12 +464,12 @@
modeprm = {refungible: null};
}
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Get number of collections before the transaction
const collectionCountBefore = await getCreatedCollectionCount(api);
// Run the CreateCollection transaction
- const alicePrivateKey = privateKey('//Alice');
+ const alicePrivateKey = privateKeyWrapper!('//Alice');
const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});
await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
@@ -519,18 +518,18 @@
}
export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the DestroyCollection transaction
- const alicePrivateKey = privateKey(senderSeed);
+ const alicePrivateKey = privateKeyWrapper!(senderSeed);
const tx = api.tx.unique.destroyCollection(collectionId);
await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
});
}
export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the DestroyCollection transaction
- const alicePrivateKey = privateKey(senderSeed);
+ const alicePrivateKey = privateKeyWrapper!(senderSeed);
const tx = api.tx.unique.destroyCollection(collectionId);
const events = await submitTransactionAsync(alicePrivateKey, tx);
const result = getDestroyResult(events);
@@ -572,10 +571,10 @@
}
export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string, sender = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the transaction
- const senderPrivateKey = privateKey(sender);
+ const senderPrivateKey = privateKeyWrapper!(sender);
const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);
const events = await submitTransactionAsync(senderPrivateKey, tx);
const result = getGenericResult(events);
@@ -592,10 +591,10 @@
}
export async function removeCollectionSponsorExpectSuccess(collectionId: number, sender = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the transaction
- const alicePrivateKey = privateKey(sender);
+ const alicePrivateKey = privateKeyWrapper!(sender);
const tx = api.tx.unique.removeCollectionSponsor(collectionId);
const events = await submitTransactionAsync(alicePrivateKey, tx);
const result = getGenericResult(events);
@@ -610,30 +609,30 @@
}
export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the transaction
- const alicePrivateKey = privateKey(senderSeed);
+ const alicePrivateKey = privateKeyWrapper!(senderSeed);
const tx = api.tx.unique.removeCollectionSponsor(collectionId);
await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
});
}
export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the transaction
- const alicePrivateKey = privateKey(senderSeed);
+ const alicePrivateKey = privateKeyWrapper!(senderSeed);
const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);
await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
});
}
export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the transaction
- const sender = privateKey(senderSeed);
+ const sender = privateKeyWrapper!(senderSeed);
const tx = api.tx.unique.confirmSponsorship(collectionId);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
@@ -651,10 +650,10 @@
export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed = '//Alice') {
- await usingApi(async (api) => {
+ await usingApi(async (api, privateKeyWrapper) => {
// Run the transaction
- const sender = privateKey(senderSeed);
+ const sender = privateKeyWrapper!(senderSeed);
const tx = api.tx.unique.confirmSponsorship(collectionId);
await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
});
tests/src/xcmTransfer.test.tsdiffbeforeafterboth--- a/tests/src/xcmTransfer.test.ts
+++ b/tests/src/xcmTransfer.test.ts
@@ -20,7 +20,6 @@
import {WsProvider} from '@polkadot/api';
import {ApiOptions} from '@polkadot/api/types';
import {IKeyringPair} from '@polkadot/types/types';
-import privateKey from './substrate/privateKey';
import usingApi, {submitTransactionAsync} from './substrate/substrate-api';
import {getGenericResult} from './util/helpers';
import waitNewBlocks from './substrate/wait-new-blocks';
@@ -38,8 +37,8 @@
let alice: IKeyringPair;
before(async () => {
- await usingApi(async () => {
- alice = privateKey('//Alice');
+ await usingApi(async (api, privateKeyWrapper) => {
+ alice = privateKeyWrapper!('//Alice');
});
const karuraApiOptions: ApiOptions = {