difftreelog
Merge pull request #682 from UniqueNetwork/tests/require-await
in: master
Add requireAwait rule to avoid flakiness in tests
25 files changed
tests/.eslintrc.jsondiffbeforeafterboth--- a/tests/.eslintrc.json
+++ b/tests/.eslintrc.json
@@ -42,6 +42,7 @@
"avoidEscape": true
}
],
+ "require-await": 2,
"semi": [
"error",
"always"
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -56,10 +56,8 @@
const collection = await helper.collection.getData(collectionId);
expect(collection?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(alice.address));
- const changeAdminTxBob = async () => helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address});
- const changeAdminTxCharlie = async () => helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address});
- await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);
- await expect(changeAdminTxBob()).to.be.rejectedWith(/common\.NoPermission/);
+ await expect(helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address})).to.be.rejectedWith(/common\.NoPermission/);
+ await expect(helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address})).to.be.rejectedWith(/common\.NoPermission/);
const adminListAfterAddAdmin = await helper.collection.getAdmins(collectionId);
expect(adminListAfterAddAdmin).to.be.not.deep.contains({Substrate: charlie.address});
@@ -75,8 +73,7 @@
const adminListAfterAddAdmin = await collection.getAdmins();
expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});
- const changeAdminTxCharlie = async () => collection.addAdmin(bob, {Substrate: charlie.address});
- await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);
+ await expect(collection.addAdmin(bob, {Substrate: charlie.address})).to.be.rejectedWith(/common\.NoPermission/);
const adminListAfterAddNewAdmin = await collection.getAdmins();
expect(adminListAfterAddNewAdmin).to.be.deep.contains({Substrate: bob.address});
@@ -87,8 +84,7 @@
const [alice, bob] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
const collectionId = (1 << 32) - 1;
- const addAdminTx = async () => helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});
- await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
+ await expect(helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address})).to.be.rejectedWith(/common\.CollectionNotFound/);
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
@@ -99,8 +95,7 @@
const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
await collection.burn(alice);
- const addAdminTx = async () => collection.addAdmin(alice, {Substrate: bob.address});
- await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
+ await expect(collection.addAdmin(alice, {Substrate: bob.address})).to.be.rejectedWith(/common\.CollectionNotFound/);
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
@@ -119,7 +114,6 @@
expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: accounts[i].address});
}
- const addExtraAdminTx = async () => collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address});
- await expect(addExtraAdminTx()).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);
+ await expect(collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address})).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);
});
});
tests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth--- a/tests/src/adminTransferAndBurn.test.ts
+++ b/tests/src/adminTransferAndBurn.test.ts
@@ -36,8 +36,7 @@
expect(limits.ownerCanTransfer).to.be.true;
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});
- await expect(transferResult()).to.be.rejected;
+ await expect(helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address})).to.be.rejected;
await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});
const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);
@@ -52,9 +51,8 @@
expect(limits.ownerCanTransfer).to.be.true;
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const burnTxFailed = async () => helper.nft.burnToken(alice, collectionId, tokenId);
- await expect(burnTxFailed()).to.be.rejected;
+ await expect(helper.nft.burnToken(alice, collectionId, tokenId)).to.be.rejected;
await helper.nft.burnToken(bob, collectionId, tokenId);
const token = await helper.nft.getToken(collectionId, tokenId);
tests/src/allowLists.test.tsdiffbeforeafterboth--- a/tests/src/allowLists.test.ts
+++ b/tests/src/allowLists.test.ts
@@ -30,7 +30,7 @@
});
});
- describe('Positive', async () => {
+ describe('Positive', () => {
itSub('Owner can add address to allow list', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
// allow list does not need to be enabled to add someone in advance
@@ -58,7 +58,7 @@
});
});
- describe('Negative', async () => {
+ describe('Negative', () => {
itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {
const collectionId = (1<<32) - 1;
await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))
@@ -92,7 +92,7 @@
});
});
- describe('Positive', async () => {
+ describe('Positive', () => {
itSub('Owner can remove address from allow list', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});
@@ -128,7 +128,7 @@
});
});
- describe('Negative', async () => {
+ describe('Negative', () => {
itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});
@@ -168,7 +168,7 @@
});
});
- describe('Positive', async () => {
+ describe('Positive', () => {
itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
@@ -219,7 +219,7 @@
});
});
- describe('Negative', async () => {
+ describe('Negative', () => {
itSub('If Public Access mode is set to AllowList, tokens can\'t be transferred from a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
@@ -303,7 +303,7 @@
{access: 'AllowList', mintMode: true},
];
- const testPermissionSuite = async (permissions: ICollectionPermissions) => {
+ const testPermissionSuite = (permissions: ICollectionPermissions) => {
const allowlistedMintingShouldFail = !permissions.mintMode!;
const appropriateRejectionMessage = permissions.mintMode! ? /common\.AddressNotInAllowlist/ : /common\.PublicMintingNotAllowed/;
@@ -323,8 +323,8 @@
);
- describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, async () => {
- describe('Positive', async () => {
+ describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, () => {
+ describe('Positive', () => {
itSub('With the condtions above, tokens can be created by owner', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {});
await collection.setPermissions(alice, permissions);
@@ -341,7 +341,7 @@
if (!allowlistedMintingShouldFail) allowlistedMintingTest();
});
- describe('Negative', async () => {
+ describe('Negative', () => {
itSub('With the condtions above, tokens can\'t be created by non-priviliged non-allow-listed address', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await collection.setPermissions(alice, permissions);
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -92,7 +92,7 @@
itSub('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const approveTokenTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
+ const approveTokenTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
await expect(approveTokenTx()).to.be.rejected;
});
});
@@ -196,7 +196,7 @@
await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
const owner = await helper.nft.getTokenOwner(collectionId, tokenId);
expect(owner.Substrate).to.be.equal(alice.address);
- const transferTokenFromTx = async () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
+ const transferTokenFromTx = () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
await expect(transferTokenFromTx()).to.be.rejected;
});
@@ -210,7 +210,7 @@
const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});
expect(after - before).to.be.equal(BigInt(1));
- const transferTokenFromTx = async () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
+ const transferTokenFromTx = () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);
await expect(transferTokenFromTx()).to.be.rejected;
});
@@ -222,7 +222,7 @@
await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});
expect(after - before).to.be.equal(BigInt(100));
- const transferTokenFromTx = async () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
+ const transferTokenFromTx = () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);
await expect(transferTokenFromTx()).to.be.rejected;
});
});
@@ -277,7 +277,7 @@
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
- const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
+ const transferTokenFromTx = () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
await expect(transferTokenFromTx()).to.be.rejected;
});
@@ -293,7 +293,7 @@
const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
expect(amountAfter).to.be.equal(BigInt(0));
- const transferTokenFromTx = async () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);
+ const transferTokenFromTx = () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);
await expect(transferTokenFromTx()).to.be.rejected;
});
@@ -308,7 +308,7 @@
const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});
expect(amountAfter).to.be.equal(BigInt(0));
- const transferTokenFromTx = async () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);
+ const transferTokenFromTx = () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);
await expect(transferTokenFromTx()).to.be.rejected;
});
});
@@ -328,7 +328,7 @@
itSub('1 for NFT', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const approveTx = async () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
+ const approveTx = () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
await expect(approveTx()).to.be.rejected;
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;
});
@@ -337,14 +337,14 @@
const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
const tokenId = await helper.ft.getLastTokenId(collectionId);
- const approveTx = async () => helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 11n);
+ const approveTx = () => helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 11n);
await expect(approveTx()).to.be.rejected;
});
itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {
const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- const approveTx = async () => helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 101n);
+ const approveTx = () => helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 101n);
await expect(approveTx()).to.be.rejected;
});
});
@@ -483,7 +483,7 @@
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});
- const approveTx = async () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
+ const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});
await expect(approveTx()).to.be.rejected;
});
});
@@ -502,59 +502,59 @@
itSub('[nft] Approve for a collection that does not exist', async ({helper}) => {
const collectionId = 1 << 32 - 1;
- const approveTx = async () => helper.nft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
+ const approveTx = () => helper.nft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
await expect(approveTx()).to.be.rejected;
});
itSub('[fungible] Approve for a collection that does not exist', async ({helper}) => {
const collectionId = 1 << 32 - 1;
- const approveTx = async () => helper.ft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
+ const approveTx = () => helper.ft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
await expect(approveTx()).to.be.rejected;
});
itSub.ifWithPallets('[refungible] Approve for a collection that does not exist', [Pallets.ReFungible], async ({helper}) => {
const collectionId = 1 << 32 - 1;
- const approveTx = async () => helper.rft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
+ const approveTx = () => helper.rft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});
await expect(approveTx()).to.be.rejected;
});
itSub('[nft] Approve for a collection that was destroyed', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await helper.nft.burn(alice, collectionId);
- const approveTx = async () => helper.nft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
+ const approveTx = () => helper.nft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
await expect(approveTx()).to.be.rejected;
});
itSub('[fungible] Approve for a collection that was destroyed', async ({helper}) => {
const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await helper.ft.burn(alice, collectionId);
- const approveTx = async () => helper.ft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
+ const approveTx = () => helper.ft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
await expect(approveTx()).to.be.rejected;
});
itSub.ifWithPallets('[refungible] Approve for a collection that was destroyed', [Pallets.ReFungible], async ({helper}) => {
const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await helper.rft.burn(alice, collectionId);
- const approveTx = async () => helper.rft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
+ const approveTx = () => helper.rft.approveToken(alice, collectionId, 1, {Substrate: bob.address});
await expect(approveTx()).to.be.rejected;
});
itSub('[nft] Approve transfer of a token that does not exist', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const approveTx = async () => helper.nft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
+ const approveTx = () => helper.nft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
await expect(approveTx()).to.be.rejected;
});
itSub.ifWithPallets('[refungible] Approve transfer of a token that does not exist', [Pallets.ReFungible], async ({helper}) => {
const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const approveTx = async () => helper.rft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
+ const approveTx = () => helper.rft.approveToken(alice, collectionId, 2, {Substrate: bob.address});
await expect(approveTx()).to.be.rejected;
});
itSub('[nft] Approve using the address that does not own the approved token', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
- const approveTx = async () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
+ const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
await expect(approveTx()).to.be.rejected;
});
@@ -562,14 +562,14 @@
const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);
const tokenId = await helper.ft.getLastTokenId(collectionId);
- const approveTx = async () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
+ const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
await expect(approveTx()).to.be.rejected;
});
itSub.ifWithPallets('[refungible] Approve using the address that does not own the approved token', [Pallets.ReFungible], async ({helper}) => {
const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});
- const approveTx = async () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
+ const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});
await expect(approveTx()).to.be.rejected;
});
@@ -579,7 +579,7 @@
await helper.rft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 100n);
await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 100n);
- const approveTx = async () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 101n);
+ const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 101n);
await expect(approveTx()).to.be.rejected;
});
@@ -590,7 +590,7 @@
await helper.ft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 10n);
await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 10n);
- const approveTx = async () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 11n);
+ const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 11n);
await expect(approveTx()).to.be.rejected;
});
@@ -599,7 +599,7 @@
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: false});
- const approveTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
+ const approveTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});
await expect(approveTx()).to.be.rejected;
});
});
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -56,7 +56,7 @@
await collection.changeOwner(alice, bob.address);
- const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);
+ const changeOwnerTx = () => collection.changeOwner(alice, alice.address);
await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
const afterChanging = await helper.collection.getData(collection.collectionId);
@@ -115,20 +115,20 @@
itSub('Not owner can\'t change owner.', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);
+ const changeOwnerTx = () => collection.changeOwner(bob, bob.address);
await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
});
itSub('Collection admin can\'t change owner.', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await collection.addAdmin(alice, {Substrate: bob.address});
- const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);
+ const changeOwnerTx = () => collection.changeOwner(bob, bob.address);
await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
});
itSub('Can\'t change owner of a non-existing collection.', async ({helper}) => {
const collectionId = (1 << 32) - 1;
- const changeOwnerTx = async () => helper.collection.changeOwner(bob, collectionId, bob.address);
+ const changeOwnerTx = () => helper.collection.changeOwner(bob, collectionId, bob.address);
await expect(changeOwnerTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
});
@@ -136,15 +136,15 @@
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await collection.changeOwner(alice, bob.address);
- const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);
+ const changeOwnerTx = () => collection.changeOwner(alice, alice.address);
await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);
const afterChanging = await helper.collection.getData(collection.collectionId);
expect(afterChanging?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(bob.address));
- const setSponsorTx = async () => collection.setSponsor(alice, charlie.address);
- const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);
- const removeSponsorTx = async () => collection.removeSponsor(alice);
+ const setSponsorTx = () => collection.setSponsor(alice, charlie.address);
+ const confirmSponsorshipTx = () => collection.confirmSponsorship(alice);
+ const removeSponsorTx = () => collection.removeSponsor(alice);
await expect(setSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
await expect(removeSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);
@@ -157,13 +157,13 @@
ownerCanTransfer: true,
};
- const setLimitsTx = async () => collection.setLimits(alice, limits);
+ const setLimitsTx = () => collection.setLimits(alice, limits);
await expect(setLimitsTx()).to.be.rejectedWith(/common\.NoPermission/);
- const setPermissionTx = async () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});
+ const setPermissionTx = () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});
await expect(setPermissionTx()).to.be.rejectedWith(/common\.NoPermission/);
- const burnTx = async () => collection.burn(alice);
+ const burnTx = () => collection.burn(alice);
await expect(burnTx()).to.be.rejectedWith(/common\.NoPermission/);
});
});
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -119,7 +119,7 @@
await token.transfer(alice, {Substrate: zeroBalance.address});
const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
- const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});
+ const transferTx = () => token.transfer(zeroBalance, {Substrate: alice.address});
await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');
const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
@@ -137,7 +137,7 @@
await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);
const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
- const transferTx = async () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});
+ const transferTx = () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});
await expect(transferTx()).to.be.rejected;
const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
@@ -155,7 +155,7 @@
await token.transfer(zeroBalance, {Substrate: alice.address});
const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
- const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});
+ const transferTx = () => token.transfer(zeroBalance, {Substrate: alice.address});
await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');
const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
@@ -175,7 +175,7 @@
await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});
const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);
- const mintTx = async () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});
+ const mintTx = () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});
await expect(mintTx()).to.be.rejectedWith('Inability to pay some fees');
const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);
@@ -199,21 +199,21 @@
itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {
const collectionId = (1 << 32) - 1;
- const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);
+ const confirmSponsorshipTx = () => helper.collection.confirmSponsorship(bob, collectionId);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
});
itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await collection.setSponsor(alice, bob.address);
- const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+ const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
});
itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await collection.setSponsor(alice, bob.address);
- const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);
+ const confirmSponsorshipTx = () => collection.confirmSponsorship(alice);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
});
@@ -221,20 +221,20 @@
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await collection.setSponsor(alice, bob.address);
await collection.addAdmin(alice, {Substrate: charlie.address});
- const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+ const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
});
itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+ const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);
});
itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
await collection.burn(alice);
- const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);
+ const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);
await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
});
@@ -244,7 +244,7 @@
await collection.confirmSponsorship(bob);
const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});
const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);
- const transferTx = async () => token.transfer(senderZeroBalance, {Substrate: alice.address});
+ const transferTx = () => token.transfer(senderZeroBalance, {Substrate: alice.address});
await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');
const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);
expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);
tests/src/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -116,20 +116,20 @@
});
itSub('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async ({helper}) => {
- const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});
+ const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});
await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
});
itSub('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async ({helper}) => {
- const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});
+ const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});
await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
});
itSub('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async ({helper}) => {
- const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});
+ const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});
await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
});
itSub('(!negative test!) fails when bad limits are set', async ({helper}) => {
- const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});
+ const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});
await expect(mintCollectionTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);
});
@@ -139,7 +139,7 @@
for (let i = 0; i < 65; i++) {
props.push({key: `key${i}`, value: `value${i}`});
}
- const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
+ const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
});
@@ -150,7 +150,7 @@
props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});
}
- const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
+ const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});
await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');
});
});
tests/src/createItem.test.tsdiffbeforeafterboth--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -186,17 +186,17 @@
itSub('Regular user cannot create new item in NFT collection', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});
+ const mintTx = () => collection.mintToken(bob, {Substrate: bob.address});
await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
});
itSub('Regular user cannot create new item in Fungible collection', async ({helper}) => {
const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
- const mintTx = async () => collection.mint(bob, 10n, {Substrate: bob.address});
+ const mintTx = () => collection.mint(bob, 10n, {Substrate: bob.address});
await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
});
itSub.ifWithPallets('Regular user cannot create new item in ReFungible collection', [Pallets.ReFungible], async ({helper}) => {
const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const mintTx = async () => collection.mintToken(bob, 100n, {Substrate: bob.address});
+ const mintTx = () => collection.mintToken(bob, 100n, {Substrate: bob.address});
await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
});
@@ -204,7 +204,7 @@
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],
});
- const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+ const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
});
@@ -212,13 +212,13 @@
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',
tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],
});
- const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+ const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
});
itSub('Adding property without access rights', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+ const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
});
@@ -231,7 +231,7 @@
const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
- const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, props);
+ const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, props);
await expect(mintTx()).to.be.rejectedWith('Verification Error');
});
@@ -242,7 +242,7 @@
{key: 'k2', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},
],
});
- const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [
+ const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [
{key: 'k1', value: 'vvvvvv'.repeat(5000)},
{key: 'k2', value: 'vvv'.repeat(5000)},
]);
tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -183,7 +183,7 @@
{},
{},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
});
@@ -198,7 +198,7 @@
{value: 2n},
{value: 3n},
];
- const mintTx = async () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, args, {Substrate: alice.address});
+ const mintTx = () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, args, {Substrate: alice.address});
await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
});
@@ -213,7 +213,7 @@
{pieces: 1n},
{pieces: 1n},
];
- const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
});
@@ -223,7 +223,7 @@
{},
{},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith(/common\.CollectionNotFound/);
});
@@ -241,7 +241,7 @@
{properties: [{key: 'data', value: 'B'.repeat(32769)}]},
{properties: [{key: 'data', value: 'C'.repeat(32769)}]},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith('Verification Error');
});
@@ -259,7 +259,7 @@
{pieces: 10n, properties: [{key: 'data', value: 'B'.repeat(32769)}]},
{pieces: 10n, properties: [{key: 'data', value: 'C'.repeat(32769)}]},
];
- const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith('Verification Error');
});
@@ -291,7 +291,7 @@
{properties: [{key: 'data', value: 'A'}]},
{properties: [{key: 'data', value: 'B'.repeat(32769)}]},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith('Verification Error');
});
@@ -311,7 +311,7 @@
{},
{},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);
});
@@ -327,7 +327,7 @@
const args = [
{properties: [{key: 'data', value: 'A'}]},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
});
@@ -346,7 +346,7 @@
const args = [
{properties: [{key: 'data', value: 'A'}]},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);
});
@@ -368,7 +368,7 @@
{properties: prps},
];
- const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
+ const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);
await expect(mintTx()).to.be.rejectedWith('Verification Error');
});
});
tests/src/eth/base.test.tsdiffbeforeafterboth--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -69,7 +69,7 @@
});
});
-describe('ERC165 tests', async () => {
+describe('ERC165 tests', () => {
// https://eips.ethereum.org/EIPS/eip-165
let erc721MetadataCompatibleNftCollectionId: number;
tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -81,7 +81,7 @@
});
});
- describe('Negative Test: EVM Nesting', async() => {
+ describe('Negative Test: EVM Nesting', () => {
itEth('NFT: disallows to nest token if nesting is disabled', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
tests/src/eth/util/index.tsdiffbeforeafterboth--- a/tests/src/eth/util/index.ts
+++ b/tests/src/eth/util/index.ts
@@ -58,7 +58,7 @@
}
};
-export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
(opts.only ? it.only :
opts.skip ? it.skip : it)(name, async function() {
await usingEthPlaygrounds(async (helper, privateKey) => {
@@ -71,7 +71,7 @@
});
}
-export async function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
return itEth(name, cb, {requiredPallets: required, ...opts});
}
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034/* eslint-disable function-call-argument-newline */5// eslint-disable-next-line @typescript-eslint/triple-slash-reference6/// <reference path="unique.dev.d.ts" />78import {readFile} from 'fs/promises';910import Web3 from 'web3';11import {WebsocketProvider} from 'web3-core';12import {Contract} from 'web3-eth-contract';1314import * as solc from 'solc';1516import {evmToAddress} from '@polkadot/util-crypto';17import {IKeyringPair} from '@polkadot/types/types';1819import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';2021import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent, EthProperty} from './types';2223// Native contracts ABI24import collectionHelpersAbi from '../../collectionHelpersAbi.json';25import fungibleAbi from '../../fungibleAbi.json';26import nonFungibleAbi from '../../nonFungibleAbi.json';27import refungibleAbi from '../../reFungibleAbi.json';28import refungibleTokenAbi from '../../reFungibleTokenAbi.json';29import contractHelpersAbi from './../contractHelpersAbi.json';30import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';31import {TCollectionMode} from '../../../util/playgrounds/types';3233class EthGroupBase {34 helper: EthUniqueHelper;3536 constructor(helper: EthUniqueHelper) {37 this.helper = helper;38 }39}404142class ContractGroup extends EthGroupBase {43 async findImports(imports?: ContractImports[]){44 if(!imports) return function(path: string) {45 return {error: `File not found: ${path}`};46 };4748 const knownImports = {} as {[key: string]: string};49 for(const imp of imports) {50 knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString();51 }5253 return function(path: string) {54 if(path in knownImports) return {contents: knownImports[path]};55 return {error: `File not found: ${path}`};56 };57 }5859 async compile(name: string, src: string, imports?: ContractImports[]): Promise<CompiledContract> {60 const out = JSON.parse(solc.compile(JSON.stringify({61 language: 'Solidity',62 sources: {63 [`${name}.sol`]: {64 content: src,65 },66 },67 settings: {68 outputSelection: {69 '*': {70 '*': ['*'],71 },72 },73 },74 }), {import: await this.findImports(imports)})).contracts[`${name}.sol`][name];7576 return {77 abi: out.abi,78 object: '0x' + out.evm.bytecode.object,79 };80 }8182 async deployByCode(signer: string, name: string, src: string, imports?: ContractImports[]): Promise<Contract> {83 const compiledContract = await this.compile(name, src, imports);84 return this.deployByAbi(signer, compiledContract.abi, compiledContract.object);85 }8687 async deployByAbi(signer: string, abi: any, object: string): Promise<Contract> {88 const web3 = this.helper.getWeb3();89 const contract = new web3.eth.Contract(abi, undefined, {90 data: object,91 from: signer,92 gas: this.helper.eth.DEFAULT_GAS,93 });94 return await contract.deploy({data: object}).send({from: signer});95 }9697}9899class NativeContractGroup extends EthGroupBase {100101 contractHelpers(caller: string): Contract {102 const web3 = this.helper.getWeb3();103 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, gas: this.helper.eth.DEFAULT_GAS});104 }105106 collectionHelpers(caller: string) {107 const web3 = this.helper.getWeb3();108 return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});109 }110111 collection(address: string, mode: TCollectionMode, caller?: string): Contract {112 const abi = {113 'nft': nonFungibleAbi,114 'rft': refungibleAbi,115 'ft': fungibleAbi,116 }[mode];117 const web3 = this.helper.getWeb3();118 return new web3.eth.Contract(abi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});119 }120121 collectionById(collectionId: number, mode: 'nft' | 'rft' | 'ft', caller?: string): Contract {122 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller);123 }124125 rftToken(address: string, caller?: string): Contract {126 const web3 = this.helper.getWeb3();127 return new web3.eth.Contract(refungibleTokenAbi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});128 }129130 rftTokenById(collectionId: number, tokenId: number, caller?: string): Contract {131 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);132 }133}134135136class EthGroup extends EthGroupBase {137 DEFAULT_GAS = 2_500_000;138139 createAccount() {140 const web3 = this.helper.getWeb3();141 const account = web3.eth.accounts.create();142 web3.eth.accounts.wallet.add(account.privateKey);143 return account.address;144 }145146 async createAccountWithBalance(donor: IKeyringPair, amount=100n) {147 const account = this.createAccount();148 await this.transferBalanceFromSubstrate(donor, account, amount);149150 return account;151 }152153 async transferBalanceFromSubstrate(donor: IKeyringPair, recepient: string, amount=100n, inTokens=true) {154 return await this.helper.balance.transferToSubstrate(donor, evmToAddress(recepient), amount * (inTokens ? this.helper.balance.getOneTokenNominal() : 1n));155 }156157 async getCollectionCreationFee(signer: string) {158 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);159 return await collectionHelper.methods.collectionCreationFee().call();160 }161162 async sendEVM(signer: IKeyringPair, contractAddress: string, abi: string, value: string, gasLimit?: number) {163 if(!gasLimit) gasLimit = this.DEFAULT_GAS;164 const web3 = this.helper.getWeb3();165 const gasPrice = await web3.eth.getGasPrice();166 // TODO: check execution status167 await this.helper.executeExtrinsic(168 signer,169 'api.tx.evm.call', [this.helper.address.substrateToEth(signer.address), contractAddress, abi, value, gasLimit, gasPrice, null, null, []],170 true,171 );172 }173174 async callEVM(signer: TEthereumAccount, contractAddress: string, abi: string) {175 return await this.helper.callRpc('api.rpc.eth.call', [{from: signer, to: contractAddress, data: abi}]);176 }177178 async createCollecion(functionName: string, signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {179 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();180 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);181182 const result = await collectionHelper.methods[functionName](name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});183184 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);185 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);186 const events = this.helper.eth.normalizeEvents(result.events);187188 return {collectionId, collectionAddress, events};189 }190191 async createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {192 return this.createCollecion('createNFTCollection', signer, name, description, tokenPrefix);193 }194195 async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {196 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);197198 const {collectionId, collectionAddress, events} = await this.createCollecion('createNFTCollection', signer, name, description, tokenPrefix);199200 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();201202 return {collectionId, collectionAddress, events};203 }204205 async createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {206 return this.createCollecion('createRFTCollection', signer, name, description, tokenPrefix);207 }208209 async createFungibleCollection(signer: string, name: string, decimals: number, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {210 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();211 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);212213 const result = await collectionHelper.methods.createFTCollection(name, decimals, description, tokenPrefix).send({value: Number(collectionCreationPrice)});214 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);215 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);216217 const events = this.helper.eth.normalizeEvents(result.events);218219 return {collectionId, collectionAddress, events};220 }221222 async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {223 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);224225 const {collectionId, collectionAddress, events} = await this.createCollecion('createRFTCollection', signer, name, description, tokenPrefix);226227 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();228229 return {collectionId, collectionAddress, events};230 }231232 async deployCollectorContract(signer: string): Promise<Contract> {233 return await this.helper.ethContract.deployByCode(signer, 'Collector', `234 // SPDX-License-Identifier: UNLICENSED235 pragma solidity ^0.8.6;236237 contract Collector {238 uint256 collected;239 fallback() external payable {240 giveMoney();241 }242 function giveMoney() public payable {243 collected += msg.value;244 }245 function getCollected() public view returns (uint256) {246 return collected;247 }248 function getUnaccounted() public view returns (uint256) {249 return address(this).balance - collected;250 }251252 function withdraw(address payable target) public {253 target.transfer(collected);254 collected = 0;255 }256 }257 `);258 }259260 async deployFlipper(signer: string): Promise<Contract> {261 return await this.helper.ethContract.deployByCode(signer, 'Flipper', `262 // SPDX-License-Identifier: UNLICENSED263 pragma solidity ^0.8.6;264265 contract Flipper {266 bool value = false;267 function flip() public {268 value = !value;269 }270 function getValue() public view returns (bool) {271 return value;272 }273 }274 `);275 }276277 async recordCallFee(user: string, call: () => Promise<any>): Promise<bigint> {278 const before = await this.helper.balance.getEthereum(user);279 await call();280 // In dev mode, the transaction might not finish processing in time281 await this.helper.wait.newBlocks(1);282 const after = await this.helper.balance.getEthereum(user);283284 return before - after;285 }286287 normalizeEvents(events: any): NormalizedEvent[] {288 const output = [];289 for (const key of Object.keys(events)) {290 if (key.match(/^[0-9]+$/)) {291 output.push(events[key]);292 } else if (Array.isArray(events[key])) {293 output.push(...events[key]);294 } else {295 output.push(events[key]);296 }297 }298 output.sort((a, b) => a.logIndex - b.logIndex);299 return output.map(({address, event, returnValues}) => {300 const args: { [key: string]: string } = {};301 for (const key of Object.keys(returnValues)) {302 if (!key.match(/^[0-9]+$/)) {303 args[key] = returnValues[key];304 }305 }306 return {307 address,308 event,309 args,310 };311 });312 }313314 async calculateFee(address: ICrossAccountId, code: () => Promise<any>): Promise<bigint> {315 const wrappedCode = async () => {316 await code();317 // In dev mode, the transaction might not finish processing in time318 await this.helper.wait.newBlocks(1);319 };320 return await this.helper.arrange.calculcateFee(address, wrappedCode);321 }322}323324class EthAddressGroup extends EthGroupBase {325 extractCollectionId(address: string): number {326 if (!(address.length === 42 || address.length === 40)) throw new Error('address wrong format');327 return parseInt(address.substr(address.length - 8), 16);328 }329330 fromCollectionId(collectionId: number): string {331 if (collectionId >= 0xffffffff || collectionId < 0) throw new Error('collectionId overflow');332 return Web3.utils.toChecksumAddress(`0x17c4e6453cc49aaaaeaca894e6d9683e${collectionId.toString(16).padStart(8,'0')}`);333 }334335 extractTokenId(address: string): {collectionId: number, tokenId: number} {336 if (!address.startsWith('0x'))337 throw 'address not starts with "0x"';338 if (address.length > 42)339 throw 'address length is more than 20 bytes';340 return {341 collectionId: Number('0x' + address.substring(address.length - 16, address.length - 8)),342 tokenId: Number('0x' + address.substring(address.length - 8)),343 };344 }345346 fromTokenId(collectionId: number, tokenId: number): string {347 return this.helper.util.getTokenAddress({collectionId, tokenId});348 }349350 normalizeAddress(address: string): string {351 return '0x' + address.substring(address.length - 40);352 }353}354export class EthPropertyGroup extends EthGroupBase {355 property(key: string, value: string): EthProperty {356 return [357 key,358 '0x'+Buffer.from(value).toString('hex'),359 ];360 }361}362export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;363364export class EthCrossAccountGroup extends EthGroupBase {365 fromAddress(address: TEthereumAccount): TEthCrossAccount {366 return {367 0: address,368 1: '0',369 field_0: address,370 field_1: '0',371 };372 }373374 fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {375 return {376 0: '0x0000000000000000000000000000000000000000',377 1: keyring.addressRaw,378 field_0: '0x0000000000000000000000000000000000000000',379 field_1: keyring.addressRaw,380 };381 }382}383384export class EthUniqueHelper extends DevUniqueHelper {385 web3: Web3 | null = null;386 web3Provider: WebsocketProvider | null = null;387388 eth: EthGroup;389 ethAddress: EthAddressGroup;390 ethNativeContract: NativeContractGroup;391 ethContract: ContractGroup;392 ethCrossAccount: EthCrossAccountGroup;393 ethProperty: EthPropertyGroup;394395 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {396 options.helperBase = options.helperBase ?? EthUniqueHelper;397398 super(logger, options);399 this.eth = new EthGroup(this);400 this.ethAddress = new EthAddressGroup(this);401 this.ethCrossAccount = new EthCrossAccountGroup(this);402 this.ethNativeContract = new NativeContractGroup(this);403 this.ethContract = new ContractGroup(this);404 this.ethProperty = new EthPropertyGroup(this);405 }406407 getWeb3(): Web3 {408 if(this.web3 === null) throw Error('Web3 not connected');409 return this.web3;410 }411412 async connectWeb3(wsEndpoint: string) {413 if(this.web3 !== null) return;414 this.web3Provider = new Web3.providers.WebsocketProvider(wsEndpoint);415 this.web3 = new Web3(this.web3Provider);416 }417418 async disconnect() {419 if(this.web3 === null) return;420 this.web3Provider?.connection.close();421422 await super.disconnect();423 }424425 clearApi() {426 super.clearApi();427 this.web3 = null;428 }429430 clone(helperCls: EthUniqueHelperConstructor, options?: { [key: string]: any; }): EthUniqueHelper {431 const newHelper = super.clone(helperCls, options) as EthUniqueHelper;432 newHelper.web3 = this.web3;433 newHelper.web3Provider = this.web3Provider;434435 return newHelper;436 }437}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034/* eslint-disable function-call-argument-newline */5// eslint-disable-next-line @typescript-eslint/triple-slash-reference6/// <reference path="unique.dev.d.ts" />78import {readFile} from 'fs/promises';910import Web3 from 'web3';11import {WebsocketProvider} from 'web3-core';12import {Contract} from 'web3-eth-contract';1314import * as solc from 'solc';1516import {evmToAddress} from '@polkadot/util-crypto';17import {IKeyringPair} from '@polkadot/types/types';1819import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';2021import {ContractImports, CompiledContract, TEthCrossAccount, NormalizedEvent, EthProperty} from './types';2223// Native contracts ABI24import collectionHelpersAbi from '../../collectionHelpersAbi.json';25import fungibleAbi from '../../fungibleAbi.json';26import nonFungibleAbi from '../../nonFungibleAbi.json';27import refungibleAbi from '../../reFungibleAbi.json';28import refungibleTokenAbi from '../../reFungibleTokenAbi.json';29import contractHelpersAbi from './../contractHelpersAbi.json';30import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';31import {TCollectionMode} from '../../../util/playgrounds/types';3233class EthGroupBase {34 helper: EthUniqueHelper;3536 constructor(helper: EthUniqueHelper) {37 this.helper = helper;38 }39}404142class ContractGroup extends EthGroupBase {43 async findImports(imports?: ContractImports[]){44 if(!imports) return function(path: string) {45 return {error: `File not found: ${path}`};46 };4748 const knownImports = {} as {[key: string]: string};49 for(const imp of imports) {50 knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString();51 }5253 return function(path: string) {54 if(path in knownImports) return {contents: knownImports[path]};55 return {error: `File not found: ${path}`};56 };57 }5859 async compile(name: string, src: string, imports?: ContractImports[]): Promise<CompiledContract> {60 const out = JSON.parse(solc.compile(JSON.stringify({61 language: 'Solidity',62 sources: {63 [`${name}.sol`]: {64 content: src,65 },66 },67 settings: {68 outputSelection: {69 '*': {70 '*': ['*'],71 },72 },73 },74 }), {import: await this.findImports(imports)})).contracts[`${name}.sol`][name];7576 return {77 abi: out.abi,78 object: '0x' + out.evm.bytecode.object,79 };80 }8182 async deployByCode(signer: string, name: string, src: string, imports?: ContractImports[]): Promise<Contract> {83 const compiledContract = await this.compile(name, src, imports);84 return this.deployByAbi(signer, compiledContract.abi, compiledContract.object);85 }8687 async deployByAbi(signer: string, abi: any, object: string): Promise<Contract> {88 const web3 = this.helper.getWeb3();89 const contract = new web3.eth.Contract(abi, undefined, {90 data: object,91 from: signer,92 gas: this.helper.eth.DEFAULT_GAS,93 });94 return await contract.deploy({data: object}).send({from: signer});95 }9697}9899class NativeContractGroup extends EthGroupBase {100101 contractHelpers(caller: string): Contract {102 const web3 = this.helper.getWeb3();103 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, gas: this.helper.eth.DEFAULT_GAS});104 }105106 collectionHelpers(caller: string) {107 const web3 = this.helper.getWeb3();108 return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});109 }110111 collection(address: string, mode: TCollectionMode, caller?: string): Contract {112 const abi = {113 'nft': nonFungibleAbi,114 'rft': refungibleAbi,115 'ft': fungibleAbi,116 }[mode];117 const web3 = this.helper.getWeb3();118 return new web3.eth.Contract(abi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});119 }120121 collectionById(collectionId: number, mode: 'nft' | 'rft' | 'ft', caller?: string): Contract {122 return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller);123 }124125 rftToken(address: string, caller?: string): Contract {126 const web3 = this.helper.getWeb3();127 return new web3.eth.Contract(refungibleTokenAbi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});128 }129130 rftTokenById(collectionId: number, tokenId: number, caller?: string): Contract {131 return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);132 }133}134135136class EthGroup extends EthGroupBase {137 DEFAULT_GAS = 2_500_000;138139 createAccount() {140 const web3 = this.helper.getWeb3();141 const account = web3.eth.accounts.create();142 web3.eth.accounts.wallet.add(account.privateKey);143 return account.address;144 }145146 async createAccountWithBalance(donor: IKeyringPair, amount=100n) {147 const account = this.createAccount();148 await this.transferBalanceFromSubstrate(donor, account, amount);149150 return account;151 }152153 async transferBalanceFromSubstrate(donor: IKeyringPair, recepient: string, amount=100n, inTokens=true) {154 return await this.helper.balance.transferToSubstrate(donor, evmToAddress(recepient), amount * (inTokens ? this.helper.balance.getOneTokenNominal() : 1n));155 }156157 async getCollectionCreationFee(signer: string) {158 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);159 return await collectionHelper.methods.collectionCreationFee().call();160 }161162 async sendEVM(signer: IKeyringPair, contractAddress: string, abi: string, value: string, gasLimit?: number) {163 if(!gasLimit) gasLimit = this.DEFAULT_GAS;164 const web3 = this.helper.getWeb3();165 const gasPrice = await web3.eth.getGasPrice();166 // TODO: check execution status167 await this.helper.executeExtrinsic(168 signer,169 'api.tx.evm.call', [this.helper.address.substrateToEth(signer.address), contractAddress, abi, value, gasLimit, gasPrice, null, null, []],170 true,171 );172 }173174 async callEVM(signer: TEthereumAccount, contractAddress: string, abi: string) {175 return await this.helper.callRpc('api.rpc.eth.call', [{from: signer, to: contractAddress, data: abi}]);176 }177178 async createCollecion(functionName: string, signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {179 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();180 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);181182 const result = await collectionHelper.methods[functionName](name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});183184 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);185 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);186 const events = this.helper.eth.normalizeEvents(result.events);187188 return {collectionId, collectionAddress, events};189 }190191 createNFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {192 return this.createCollecion('createNFTCollection', signer, name, description, tokenPrefix);193 }194195 async createERC721MetadataCompatibleNFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {196 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);197198 const {collectionId, collectionAddress, events} = await this.createCollecion('createNFTCollection', signer, name, description, tokenPrefix);199200 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();201202 return {collectionId, collectionAddress, events};203 }204205 createRFTCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {206 return this.createCollecion('createRFTCollection', signer, name, description, tokenPrefix);207 }208209 async createFungibleCollection(signer: string, name: string, decimals: number, description: string, tokenPrefix: string): Promise<{ collectionId: number, collectionAddress: string, events: NormalizedEvent[]}> {210 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();211 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);212213 const result = await collectionHelper.methods.createFTCollection(name, decimals, description, tokenPrefix).send({value: Number(collectionCreationPrice)});214 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);215 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);216217 const events = this.helper.eth.normalizeEvents(result.events);218219 return {collectionId, collectionAddress, events};220 }221222 async createERC721MetadataCompatibleRFTCollection(signer: string, name: string, description: string, tokenPrefix: string, baseUri: string): Promise<{collectionId: number, collectionAddress: string, events: NormalizedEvent[] }> {223 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);224225 const {collectionId, collectionAddress, events} = await this.createCollecion('createRFTCollection', signer, name, description, tokenPrefix);226227 await collectionHelper.methods.makeCollectionERC721MetadataCompatible(collectionAddress, baseUri).send();228229 return {collectionId, collectionAddress, events};230 }231232 async deployCollectorContract(signer: string): Promise<Contract> {233 return await this.helper.ethContract.deployByCode(signer, 'Collector', `234 // SPDX-License-Identifier: UNLICENSED235 pragma solidity ^0.8.6;236237 contract Collector {238 uint256 collected;239 fallback() external payable {240 giveMoney();241 }242 function giveMoney() public payable {243 collected += msg.value;244 }245 function getCollected() public view returns (uint256) {246 return collected;247 }248 function getUnaccounted() public view returns (uint256) {249 return address(this).balance - collected;250 }251252 function withdraw(address payable target) public {253 target.transfer(collected);254 collected = 0;255 }256 }257 `);258 }259260 async deployFlipper(signer: string): Promise<Contract> {261 return await this.helper.ethContract.deployByCode(signer, 'Flipper', `262 // SPDX-License-Identifier: UNLICENSED263 pragma solidity ^0.8.6;264265 contract Flipper {266 bool value = false;267 function flip() public {268 value = !value;269 }270 function getValue() public view returns (bool) {271 return value;272 }273 }274 `);275 }276277 async recordCallFee(user: string, call: () => Promise<any>): Promise<bigint> {278 const before = await this.helper.balance.getEthereum(user);279 await call();280 // In dev mode, the transaction might not finish processing in time281 await this.helper.wait.newBlocks(1);282 const after = await this.helper.balance.getEthereum(user);283284 return before - after;285 }286287 normalizeEvents(events: any): NormalizedEvent[] {288 const output = [];289 for (const key of Object.keys(events)) {290 if (key.match(/^[0-9]+$/)) {291 output.push(events[key]);292 } else if (Array.isArray(events[key])) {293 output.push(...events[key]);294 } else {295 output.push(events[key]);296 }297 }298 output.sort((a, b) => a.logIndex - b.logIndex);299 return output.map(({address, event, returnValues}) => {300 const args: { [key: string]: string } = {};301 for (const key of Object.keys(returnValues)) {302 if (!key.match(/^[0-9]+$/)) {303 args[key] = returnValues[key];304 }305 }306 return {307 address,308 event,309 args,310 };311 });312 }313314 async calculateFee(address: ICrossAccountId, code: () => Promise<any>): Promise<bigint> {315 const wrappedCode = async () => {316 await code();317 // In dev mode, the transaction might not finish processing in time318 await this.helper.wait.newBlocks(1);319 };320 return await this.helper.arrange.calculcateFee(address, wrappedCode);321 }322}323324class EthAddressGroup extends EthGroupBase {325 extractCollectionId(address: string): number {326 if (!(address.length === 42 || address.length === 40)) throw new Error('address wrong format');327 return parseInt(address.substr(address.length - 8), 16);328 }329330 fromCollectionId(collectionId: number): string {331 if (collectionId >= 0xffffffff || collectionId < 0) throw new Error('collectionId overflow');332 return Web3.utils.toChecksumAddress(`0x17c4e6453cc49aaaaeaca894e6d9683e${collectionId.toString(16).padStart(8,'0')}`);333 }334335 extractTokenId(address: string): {collectionId: number, tokenId: number} {336 if (!address.startsWith('0x'))337 throw 'address not starts with "0x"';338 if (address.length > 42)339 throw 'address length is more than 20 bytes';340 return {341 collectionId: Number('0x' + address.substring(address.length - 16, address.length - 8)),342 tokenId: Number('0x' + address.substring(address.length - 8)),343 };344 }345346 fromTokenId(collectionId: number, tokenId: number): string {347 return this.helper.util.getTokenAddress({collectionId, tokenId});348 }349350 normalizeAddress(address: string): string {351 return '0x' + address.substring(address.length - 40);352 }353}354export class EthPropertyGroup extends EthGroupBase {355 property(key: string, value: string): EthProperty {356 return [357 key,358 '0x'+Buffer.from(value).toString('hex'),359 ];360 }361}362export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;363364export class EthCrossAccountGroup extends EthGroupBase {365 fromAddress(address: TEthereumAccount): TEthCrossAccount {366 return {367 0: address,368 1: '0',369 field_0: address,370 field_1: '0',371 };372 }373374 fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {375 return {376 0: '0x0000000000000000000000000000000000000000',377 1: keyring.addressRaw,378 field_0: '0x0000000000000000000000000000000000000000',379 field_1: keyring.addressRaw,380 };381 }382}383384export class EthUniqueHelper extends DevUniqueHelper {385 web3: Web3 | null = null;386 web3Provider: WebsocketProvider | null = null;387388 eth: EthGroup;389 ethAddress: EthAddressGroup;390 ethNativeContract: NativeContractGroup;391 ethContract: ContractGroup;392 ethCrossAccount: EthCrossAccountGroup;393 ethProperty: EthPropertyGroup;394395 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {396 options.helperBase = options.helperBase ?? EthUniqueHelper;397398 super(logger, options);399 this.eth = new EthGroup(this);400 this.ethAddress = new EthAddressGroup(this);401 this.ethCrossAccount = new EthCrossAccountGroup(this);402 this.ethNativeContract = new NativeContractGroup(this);403 this.ethContract = new ContractGroup(this);404 this.ethProperty = new EthPropertyGroup(this);405 }406407 getWeb3(): Web3 {408 if(this.web3 === null) throw Error('Web3 not connected');409 return this.web3;410 }411412 connectWeb3(wsEndpoint: string) {413 if(this.web3 !== null) return;414 this.web3Provider = new Web3.providers.WebsocketProvider(wsEndpoint);415 this.web3 = new Web3(this.web3Provider);416 }417418 async disconnect() {419 if(this.web3 === null) return;420 this.web3Provider?.connection.close();421422 await super.disconnect();423 }424425 clearApi() {426 super.clearApi();427 this.web3 = null;428 }429430 clone(helperCls: EthUniqueHelperConstructor, options?: { [key: string]: any; }): EthUniqueHelper {431 const newHelper = super.clone(helperCls, options) as EthUniqueHelper;432 newHelper.web3 = this.web3;433 newHelper.web3Provider = this.web3Provider;434435 return newHelper;436 }437}tests/src/pallet-presence.test.tsdiffbeforeafterboth--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -86,15 +86,15 @@
});
});
- itSub('Required pallets are present', async ({helper}) => {
+ itSub('Required pallets are present', ({helper}) => {
expect(helper.fetchAllPalletNames()).to.contain.members([...requiredPallets]);
});
- itSub('Governance and consensus pallets are present', async ({helper}) => {
+ itSub('Governance and consensus pallets are present', ({helper}) => {
expect(helper.fetchAllPalletNames()).to.contain.members([...consensusPallets]);
});
- itSub('No extra pallets are included', async ({helper}) => {
+ itSub('No extra pallets are included', ({helper}) => {
expect(helper.fetchAllPalletNames().sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());
});
});
tests/src/refungible.test.tsdiffbeforeafterboth--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -19,7 +19,7 @@
const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;
-describe('integration test: Refungible functionality:', async () => {
+describe('integration test: Refungible functionality:', () => {
let donor: IKeyringPair;
let alice: IKeyringPair;
let bob: IKeyringPair;
tests/src/rmrk/addResource.seqtest.tsdiffbeforeafterboth--- a/tests/src/rmrk/addResource.seqtest.ts
+++ b/tests/src/rmrk/addResource.seqtest.ts
@@ -112,7 +112,7 @@
const resourcesInfo = [];
const resourceNum = 4;
- const checkResource = async (resource: ResourceInfo, resType: string, expectedId: number, expected: {
+ const checkResource = (resource: ResourceInfo, resType: string, expectedId: number, expected: {
src: string,
metadata: string,
license: string,
tests/src/rmrk/equipNft.seqtest.tsdiffbeforeafterboth--- a/tests/src/rmrk/equipNft.seqtest.ts
+++ b/tests/src/rmrk/equipNft.seqtest.ts
@@ -30,7 +30,7 @@
const slotId = 1;
-async function createTestCollection(api: ApiPromise): Promise<number> {
+function createTestCollection(api: ApiPromise): Promise<number> {
return createCollection(
api,
alice,
@@ -60,7 +60,7 @@
return nftChildId;
}
-async function createTestBase(api: ApiPromise): Promise<number> {
+function createTestBase(api: ApiPromise): Promise<number> {
return createBase(api, alice, 'test-base', 'DTBase', [
{
SlotPart: {
tests/src/rmrk/rmrkIsolation.seqtest.tsdiffbeforeafterboth--- a/tests/src/rmrk/rmrkIsolation.seqtest.ts
+++ b/tests/src/rmrk/rmrkIsolation.seqtest.ts
@@ -58,7 +58,7 @@
return rmrkNftId;
}
-describe('RMRK External Integration Test', async () => {
+describe('RMRK External Integration Test', () => {
before(async function() {
await usingPlaygrounds(async (_helper, privateKey) => {
alice = await privateKey('//Alice');
@@ -78,7 +78,7 @@
});
});
-describe('Negative Integration Test: External Collections, Internal Ops', async () => {
+describe('Negative Integration Test: External Collections, Internal Ops', () => {
let uniqueCollectionId: number;
let rmrkCollectionId: number;
let rmrkNftId: number;
@@ -196,7 +196,7 @@
});
});
-describe('Negative Integration Test: Internal Collections, External Ops', async () => {
+describe('Negative Integration Test: Internal Collections, External Ops', () => {
let collectionId: number;
let nftId: number;
tests/src/rmrk/util/fetch.tsdiffbeforeafterboth--- a/tests/src/rmrk/util/fetch.ts
+++ b/tests/src/rmrk/util/fetch.ts
@@ -20,7 +20,7 @@
return (await api.rpc.rmrk.lastCollectionIdx()).toNumber();
}
-export async function getCollection(api: ApiPromise, id: number): Promise<Option<Collection>> {
+export function getCollection(api: ApiPromise, id: number): Promise<Option<Collection>> {
return api.rpc.rmrk.collectionById(id);
}
@@ -36,7 +36,7 @@
.map((value) => value.toNumber());
}
-export async function getNft(api: ApiPromise, collectionId: number, nftId: number): Promise<Option<Nft>> {
+export function getNft(api: ApiPromise, collectionId: number, nftId: number): Promise<Option<Nft>> {
return api.rpc.rmrk.nftById(collectionId, nftId);
}
@@ -56,7 +56,7 @@
return (await api.rpc.rmrk.nftChildren(collectionId, nftId)).toArray();
}
-export async function getBase(api: ApiPromise, baseId: number): Promise<Option<Base>> {
+export function getBase(api: ApiPromise, baseId: number): Promise<Option<Base>> {
return api.rpc.rmrk.base(baseId);
}
@@ -112,7 +112,7 @@
.map((name) => name.toUtf8());
}
-export async function getTheme(
+export function getTheme(
api: ApiPromise,
baseId: number,
themeName: string,
tests/src/tx-version-presence.test.tsdiffbeforeafterboth--- a/tests/src/tx-version-presence.test.ts
+++ b/tests/src/tx-version-presence.test.ts
@@ -26,7 +26,7 @@
});
});
- itSub('Signed extension CheckTxVersion is present', async () => {
+ itSub('Signed extension CheckTxVersion is present', () => {
expect(metadata.asLatest.extrinsic.signedExtensions.map(se => se.identifier.toString())).to.include('CheckTxVersion');
});
});
tests/src/util/globalSetup.tsdiffbeforeafterboth--- a/tests/src/util/globalSetup.ts
+++ b/tests/src/util/globalSetup.ts
@@ -90,7 +90,7 @@
});
};
-const fundFilenamesWithRetries = async (retriesLeft: number): Promise<boolean> => {
+const fundFilenamesWithRetries = (retriesLeft: number): Promise<boolean> => {
if (retriesLeft <= 0) return Promise.resolve(false);
return fundFilenames()
.then(() => Promise.resolve(true))
tests/src/util/index.tsdiffbeforeafterboth--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -59,27 +59,27 @@
return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
};
-export const usingWestmintPlaygrounds = async (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
};
-export const usingRelayPlaygrounds = async (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
};
-export const usingAcalaPlaygrounds = async (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
};
-export const usingKaruraPlaygrounds = async (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
};
-export const usingMoonbeamPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
};
-export const usingMoonriverPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
+export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
};
@@ -108,7 +108,7 @@
}
}
-export async function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
(opts.only ? it.only :
opts.skip ? it.skip : it)(name, async function () {
await usingPlaygrounds(async (helper, privateKey) => {
@@ -120,7 +120,7 @@
});
});
}
-export async function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
+export function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {
return itSub(name, cb, {requiredPallets: required, ...opts});
}
itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});
@@ -130,7 +130,7 @@
itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});
itSub.ifWithPallets = itSubIfWithPallet;
-export async function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {
+export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {
(process.env.RUN_XCM_TESTS && !opts.skip
? describe
: describe.skip)(title, fn);
tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -273,7 +273,7 @@
}
const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber])]);
const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber - 1])]);
- const findCreationDate = async (block: any) => {
+ const findCreationDate = (block: any) => {
const humanBlock = block.toHuman();
let date;
humanBlock.block.extrinsics.forEach((ext: any) => {
@@ -388,7 +388,7 @@
* @param blocksCount number of blocks to wait
* @returns
*/
- async newBlocks(blocksCount = 1): Promise<void> {
+ newBlocks(blocksCount = 1): Promise<void> {
// eslint-disable-next-line no-async-promise-executor
const promise = new Promise<void>(async (resolve) => {
const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {
@@ -403,10 +403,10 @@
return promise;
}
- async forParachainBlockNumber(blockNumber: bigint) {
+ forParachainBlockNumber(blockNumber: bigint) {
// eslint-disable-next-line no-async-promise-executor
return new Promise<void>(async (resolve) => {
- const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {
+ const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads((data: any) => {
if (data.number.toNumber() >= blockNumber) {
unsubscribe();
resolve();
@@ -415,10 +415,10 @@
});
}
- async forRelayBlockNumber(blockNumber: bigint) {
+ forRelayBlockNumber(blockNumber: bigint) {
// eslint-disable-next-line no-async-promise-executor
return new Promise<void>(async (resolve) => {
- const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {
+ const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData((data: any) => {
if (data.value.relayParentNumber.toNumber() >= blockNumber) {
// @ts-ignore
unsubscribe();
@@ -428,7 +428,7 @@
});
}
- async noScheduledTasks() {
+ noScheduledTasks() {
const api = this.helper.getApi();
// eslint-disable-next-line no-async-promise-executor
@@ -446,7 +446,7 @@
return promise;
}
- async event(maxBlocksToWait: number, eventSection: string, eventMethod: string) {
+ event(maxBlocksToWait: number, eventSection: string, eventMethod: string) {
// eslint-disable-next-line no-async-promise-executor
const promise = new Promise<EventRecord | null>(async (resolve) => {
const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async header => {
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1677,7 +1677,7 @@
* @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."})
* @returns ```true``` if extrinsic success, otherwise ```false```
*/
- async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId) {
+ approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId) {
return super.approveToken(signer, collectionId, tokenId, toAddressObj, 1n);
}
}
@@ -1870,7 +1870,7 @@
* @example approveToken(aliceKeyring, 10, 5, {Substrate: "5GHoZe9c73RYbVzq..."}, "", 10000n);
* @returns true if the token success, otherwise false
*/
- async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {
+ approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, amount=1n) {
return super.approveToken(signer, collectionId, tokenId, toAddressObj, amount);
}
@@ -2082,7 +2082,7 @@
* @example approveTokens(aliceKeyring, 10, {Substrate: "5GHoZe9c73RYbVzq..."}, 1000n)
* @returns ```true``` if extrinsic success, otherwise ```false```
*/
- async approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=1n) {
+ approveTokens(signer: IKeyringPair, collectionId: number, toAddressObj: ICrossAccountId, amount=1n) {
return super.approveToken(signer, collectionId, 0, toAddressObj, amount);
}
@@ -2093,7 +2093,7 @@
* @param toAddressObj the address approved for the transfer of tokens on behalf of the owner
* @returns number of tokens approved for the transfer
*/
- async getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {
+ getApprovedTokens(collectionId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId) {
return super.getTokenApprovedPieces(collectionId, 0, toAddressObj, fromAddressObj);
}
}
@@ -2270,7 +2270,7 @@
* @example getSubstrate("5GrwvaEF5zXb26Fz...")
* @returns amount of tokens on address
*/
- async getSubstrate(address: TSubstrateAccount): Promise<bigint> {
+ getSubstrate(address: TSubstrateAccount): Promise<bigint> {
return this.subBalanceGroup.getSubstrate(address);
}
@@ -2279,7 +2279,7 @@
* @param address substrate address
* @returns
*/
- async getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {
+ getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {
return this.subBalanceGroup.getSubstrateFull(address);
}
@@ -2289,7 +2289,7 @@
* @example getEthereum("0x9F0583DbB855d...")
* @returns amount of tokens on address
*/
- async getEthereum(address: TEthereumAccount): Promise<bigint> {
+ getEthereum(address: TEthereumAccount): Promise<bigint> {
return this.ethBalanceGroup.getEthereum(address);
}
@@ -2301,7 +2301,7 @@
* @example transferToSubstrate(aliceKeyring, "5GrwvaEF5zXb26Fz...", 100_000_000_000n);
* @returns ```true``` if extrinsic success, otherwise ```false```
*/
- async transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {
+ transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {
return this.subBalanceGroup.transferToSubstrate(signer, address, amount);
}
@@ -2471,7 +2471,7 @@
super(helper);
}
- async cancelScheduled(signer: TSigner, scheduledId: string) {
+ cancelScheduled(signer: TSigner, scheduledId: string) {
return this.helper.executeExtrinsic(
signer,
'api.tx.scheduler.cancelNamed',
@@ -2480,7 +2480,7 @@
);
}
- async changePriority(signer: TSigner, scheduledId: string, priority: number) {
+ changePriority(signer: TSigner, scheduledId: string, priority: number) {
return this.helper.executeExtrinsic(
signer,
'api.tx.scheduler.changeNamedPriority',