difftreelog
test run eslint --fix
in: master
20 files changed
tests/src/benchmarks/mintFee/index.tsdiffbeforeafterboth--- a/tests/src/benchmarks/mintFee/index.ts
+++ b/tests/src/benchmarks/mintFee/index.ts
@@ -222,9 +222,7 @@
await collection.mintToken(
donor,
{Substrate: susbstrateReceiver.address},
- PROPERTIES.slice(0, setup.propertiesNumber).map((p) => {
- return {key: p.key, value: Buffer.from(p.value).toString()};
- }),
+ PROPERTIES.slice(0, setup.propertiesNumber).map((p) => ({key: p.key, value: Buffer.from(p.value).toString()})),
);
},
);
tests/src/benchmarks/opsFee/index.tsdiffbeforeafterboth--- a/tests/src/benchmarks/opsFee/index.ts
+++ b/tests/src/benchmarks/opsFee/index.ts
@@ -379,7 +379,7 @@
res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
{Substrate: donor.address},
() => collection.setProperties(donor, PROPERTIES.slice(0, 1)
- .map(p => { return {key: p.key, value: p.value.toString()}; })),
+ .map(p => ({key: p.key, value: p.value.toString()}))),
)));
res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
@@ -755,7 +755,7 @@
res['setCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
{Substrate: donor.address},
() => collection.setProperties(donor, PROPERTIES.slice(0, 1)
- .map(p => { return {key: p.key, value: p.value.toString()}; })),
+ .map(p => ({key: p.key, value: p.value.toString()}))),
)));
res['deleteCollectionProperties'].substrate = convertToTokens((await helper.arrange.calculcateFee(
tests/src/benchmarks/utils/common.tsdiffbeforeafterboth--- a/tests/src/benchmarks/utils/common.ts
+++ b/tests/src/benchmarks/utils/common.ts
@@ -5,32 +5,26 @@
export const PROPERTIES = Array(40)
.fill(0)
- .map((_, i) => {
- return {
- key: `key_${i}`,
- value: Uint8Array.from(Buffer.from(`value_${i}`)),
- };
- });
+ .map((_, i) => ({
+ key: `key_${i}`,
+ value: Uint8Array.from(Buffer.from(`value_${i}`)),
+ }));
export const SUBS_PROPERTIES = Array(40)
.fill(0)
- .map((_, i) => {
- return {
- key: `key_${i}`,
- value: `value_${i}`,
- };
- });
+ .map((_, i) => ({
+ key: `key_${i}`,
+ value: `value_${i}`,
+ }));
-export const PERMISSIONS: ITokenPropertyPermission[] = PROPERTIES.map((p) => {
- return {
- key: p.key,
- permission: {
- tokenOwner: true,
- collectionAdmin: true,
- mutable: true,
- },
- };
-});
+export const PERMISSIONS: ITokenPropertyPermission[] = PROPERTIES.map((p) => ({
+ key: p.key,
+ permission: {
+ tokenOwner: true,
+ collectionAdmin: true,
+ mutable: true,
+ },
+}));
export function convertToTokens(value: bigint, nominal = 1000_000_000_000_000_000n): number {
return Number((value * 1000n) / nominal) / 1000;
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -76,9 +76,7 @@
// 2. Expect methods.collectionAdmins == api.rpc.unique.adminlist
let adminListEth = await collectionEvm.methods.collectionAdmins().call();
- adminListEth = adminListEth.map((element: IEthCrossAccountId) => {
- return helper.address.convertCrossAccountFromEthCrossAccount(element);
- });
+ adminListEth = adminListEth.map((element: IEthCrossAccountId) => helper.address.convertCrossAccountFromEthCrossAccount(element));
expect(adminListRpc).to.be.like(adminListEth);
// 3. check isOwnerOrAdminCross returns true:
tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {itEth, usingEthPlaygrounds, expect} from './util';18import {Pallets} from '../util';19import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';20import {IKeyringPair} from '@polkadot/types/types';2122describe('EVM collection properties', () => {23 let donor: IKeyringPair;24 let alice: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = await privateKey({url: import.meta.url});29 [alice] = await _helper.arrange.createAccounts([50n], donor);30 });31 });3233 // Soft-deprecated: setCollectionProperty34 [35 {method: 'setCollectionProperties', mode: 'nft' as const, methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]], expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}]},36 {method: 'setCollectionProperties', mode: 'rft' as const, methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]], expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}]},37 {method: 'setCollectionProperties', mode: 'ft' as const, methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]], expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}]},38 {method: 'setCollectionProperty', mode: 'nft' as const, methodParams: ['testKey', Buffer.from('testValue')], expectedProps: [{key: 'testKey', value: 'testValue'}]},39 ].map(testCase =>40 itEth.ifWithPallets(`Collection properties can be set: ${testCase.method}() for ${testCase.mode}`, testCase.mode === 'rft' ? [Pallets.ReFungible] : [], async({helper}) => {41 const caller = await helper.eth.createAccountWithBalance(donor);42 const collection = await helper[testCase.mode].mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});43 await collection.addAdmin(alice, {Ethereum: caller});4445 const address = helper.ethAddress.fromCollectionId(collection.collectionId);46 const collectionEvm = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'setCollectionProperty');4748 // collectionProperties returns an empty array if no properties:49 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like([]);50 expect(await collectionEvm.methods.collectionProperties(['NonExistingKey']).call()).to.be.like([]);5152 await collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller});5354 const raw = (await collection.getData())?.raw;55 expect(raw.properties).to.deep.equal(testCase.expectedProps);5657 // collectionProperties returns properties:58 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like(testCase.expectedProps.map(prop => helper.ethProperty.property(prop.key, prop.value)));59 }));6061 itEth('Cannot set invalid properties', async({helper}) => {62 const caller = await helper.eth.createAccountWithBalance(donor);63 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});64 await collection.addAdmin(alice, {Ethereum: caller});6566 const address = helper.ethAddress.fromCollectionId(collection.collectionId);67 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);6869 await expect(contract.methods.setCollectionProperties([{key: '', value: Buffer.from('val1')}]).send({from: caller})).to.be.rejected;70 await expect(contract.methods.setCollectionProperties([{key: 'déjà vu', value: Buffer.from('hmm...')}]).send({from: caller})).to.be.rejected;71 await expect(contract.methods.setCollectionProperties([{key: 'a'.repeat(257), value: Buffer.from('val3')}]).send({from: caller})).to.be.rejected;72 // TODO add more expects73 const raw = (await collection.getData())?.raw;74 expect(raw.properties).to.deep.equal([]);75 });767778 // Soft-deprecated: deleteCollectionProperty79 [80 {method: 'deleteCollectionProperties', mode: 'nft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},81 {method: 'deleteCollectionProperties', mode: 'rft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},82 {method: 'deleteCollectionProperties', mode: 'ft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},83 {method: 'deleteCollectionProperty', mode: 'nft' as const, methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]},84 ].map(testCase =>85 itEth.ifWithPallets(`Collection properties can be deleted: ${testCase.method}() for ${testCase.mode}`, testCase.mode === 'rft' ? [Pallets.ReFungible] : [], async({helper}) => {86 const properties = [87 {key: 'testKey1', value: 'testValue1'},88 {key: 'testKey2', value: 'testValue2'},89 {key: 'testKey3', value: 'testValue3'}];90 const caller = await helper.eth.createAccountWithBalance(donor);91 const collection = await helper[testCase.mode].mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});9293 await collection.addAdmin(alice, {Ethereum: caller});9495 const address = helper.ethAddress.fromCollectionId(collection.collectionId);96 const contract = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');9798 await contract.methods[testCase.method](...testCase.methodParams).send({from: caller});99100 const raw = (await collection.getData())?.raw;101102 expect(raw.properties.length).to.equal(testCase.expectedProps.length);103 expect(raw.properties).to.deep.equal(testCase.expectedProps);104 }));105106 [107 {method: 'deleteCollectionProperties', methodParams: [['testKey2']]},108 {method: 'deleteCollectionProperty', methodParams: ['testKey2']},109 ].map(testCase =>110 itEth(`cannot ${testCase.method}() of non-owned collections`, async ({helper}) => {111 const properties = [112 {key: 'testKey1', value: 'testValue1'},113 {key: 'testKey2', value: 'testValue2'},114 ];115 const caller = await helper.eth.createAccountWithBalance(donor);116 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});117118 const address = helper.ethAddress.fromCollectionId(collection.collectionId);119 const collectionEvm = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');120121 await expect(collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller})).to.be.rejected;122 expect(await collection.getProperties()).to.deep.eq(properties);123 }));124125 itEth('Can be read', async({helper}) => {126 const caller = helper.eth.createAccount();127 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});128129 const address = helper.ethAddress.fromCollectionId(collection.collectionId);130 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);131132 const value = await contract.methods.collectionProperty('testKey').call();133 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));134 });135});136137describe('Supports ERC721Metadata', () => {138 let donor: IKeyringPair;139140 before(async function() {141 await usingEthPlaygrounds(async (_helper, privateKey) => {142 donor = await privateKey({url: import.meta.url});143 });144 });145146 [147 {case: 'nft' as const},148 {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},149 ].map(testCase =>150 itEth.ifWithPallets(`ERC721Metadata property can be set for ${testCase.case} collection`, testCase.requiredPallets || [], async ({helper}) => {151 const caller = await helper.eth.createAccountWithBalance(donor);152 const bruh = await helper.eth.createAccountWithBalance(donor);153154 const BASE_URI = 'base/';155 const SUFFIX = 'suffix1';156 const URI = 'uri1';157158 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(caller);159 const creatorMethod = testCase.case === 'rft' ? 'createRFTCollection' : 'createNFTCollection';160161 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');162 const bruhCross = helper.ethCrossAccount.fromAddress(bruh);163164 const contract = await helper.ethNativeContract.collectionById(collectionId, testCase.case, caller);165 await contract.methods.addCollectionAdminCross(bruhCross).send(); // to check that admin will work too166167 const collection1 = helper.nft.getCollectionObject(collectionId);168 const data1 = await collection1.getData();169 expect(data1?.raw.flags.erc721metadata).to.be.false;170 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;171172 await collectionHelpers.methods.makeCollectionERC721MetadataCompatible(collectionAddress, BASE_URI)173 .send({from: bruh});174175 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;176177 const collection2 = helper.nft.getCollectionObject(collectionId);178 const data2 = await collection2.getData();179 expect(data2?.raw.flags.erc721metadata).to.be.true;180181 const propertyPermissions = data2?.raw.tokenPropertyPermissions;182 expect(propertyPermissions?.length).to.equal(2);183184 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {185 return tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;186 })).to.be.not.null;187188 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => {189 return tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner;190 })).to.be.not.null;191192 expect(data2?.raw.properties?.find((property: IProperty) => {193 return property.key === 'baseURI' && property.value === BASE_URI;194 })).to.be.not.null;195196 const token1Result = await contract.methods.mint(bruh).send();197 const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;198199 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);200201 await contract.methods.setProperties(tokenId1, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();202 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);203204 await contract.methods.setProperties(tokenId1, [{key: 'URI', value: Buffer.from(URI)}]).send();205 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);206207 await contract.methods.deleteProperties(tokenId1, ['URI']).send();208 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);209210 const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();211 const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;212213 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);214215 await contract.methods.deleteProperties(tokenId2, ['URI']).send();216 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);217218 await contract.methods.setProperties(tokenId2, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();219 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);220 }));221});1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {itEth, usingEthPlaygrounds, expect} from './util';18import {Pallets} from '../util';19import {IProperty, ITokenPropertyPermission} from '../util/playgrounds/types';20import {IKeyringPair} from '@polkadot/types/types';2122describe('EVM collection properties', () => {23 let donor: IKeyringPair;24 let alice: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (_helper, privateKey) => {28 donor = await privateKey({url: import.meta.url});29 [alice] = await _helper.arrange.createAccounts([50n], donor);30 });31 });3233 // Soft-deprecated: setCollectionProperty34 [35 {method: 'setCollectionProperties', mode: 'nft' as const, methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]], expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}]},36 {method: 'setCollectionProperties', mode: 'rft' as const, methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]], expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}]},37 {method: 'setCollectionProperties', mode: 'ft' as const, methodParams: [[{key: 'testKey1', value: Buffer.from('testValue1')}, {key: 'testKey2', value: Buffer.from('testValue2')}]], expectedProps: [{key: 'testKey1', value: 'testValue1'}, {key: 'testKey2', value: 'testValue2'}]},38 {method: 'setCollectionProperty', mode: 'nft' as const, methodParams: ['testKey', Buffer.from('testValue')], expectedProps: [{key: 'testKey', value: 'testValue'}]},39 ].map(testCase =>40 itEth.ifWithPallets(`Collection properties can be set: ${testCase.method}() for ${testCase.mode}`, testCase.mode === 'rft' ? [Pallets.ReFungible] : [], async({helper}) => {41 const caller = await helper.eth.createAccountWithBalance(donor);42 const collection = await helper[testCase.mode].mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});43 await collection.addAdmin(alice, {Ethereum: caller});4445 const address = helper.ethAddress.fromCollectionId(collection.collectionId);46 const collectionEvm = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'setCollectionProperty');4748 // collectionProperties returns an empty array if no properties:49 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like([]);50 expect(await collectionEvm.methods.collectionProperties(['NonExistingKey']).call()).to.be.like([]);5152 await collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller});5354 const raw = (await collection.getData())?.raw;55 expect(raw.properties).to.deep.equal(testCase.expectedProps);5657 // collectionProperties returns properties:58 expect(await collectionEvm.methods.collectionProperties([]).call()).to.be.like(testCase.expectedProps.map(prop => helper.ethProperty.property(prop.key, prop.value)));59 }));6061 itEth('Cannot set invalid properties', async({helper}) => {62 const caller = await helper.eth.createAccountWithBalance(donor);63 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: []});64 await collection.addAdmin(alice, {Ethereum: caller});6566 const address = helper.ethAddress.fromCollectionId(collection.collectionId);67 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);6869 await expect(contract.methods.setCollectionProperties([{key: '', value: Buffer.from('val1')}]).send({from: caller})).to.be.rejected;70 await expect(contract.methods.setCollectionProperties([{key: 'déjà vu', value: Buffer.from('hmm...')}]).send({from: caller})).to.be.rejected;71 await expect(contract.methods.setCollectionProperties([{key: 'a'.repeat(257), value: Buffer.from('val3')}]).send({from: caller})).to.be.rejected;72 // TODO add more expects73 const raw = (await collection.getData())?.raw;74 expect(raw.properties).to.deep.equal([]);75 });767778 // Soft-deprecated: deleteCollectionProperty79 [80 {method: 'deleteCollectionProperties', mode: 'nft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},81 {method: 'deleteCollectionProperties', mode: 'rft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},82 {method: 'deleteCollectionProperties', mode: 'ft' as const, methodParams: [['testKey1', 'testKey2']], expectedProps: [{key: 'testKey3', value: 'testValue3'}]},83 {method: 'deleteCollectionProperty', mode: 'nft' as const, methodParams: ['testKey1'], expectedProps: [{key: 'testKey2', value: 'testValue2'}, {key: 'testKey3', value: 'testValue3'}]},84 ].map(testCase =>85 itEth.ifWithPallets(`Collection properties can be deleted: ${testCase.method}() for ${testCase.mode}`, testCase.mode === 'rft' ? [Pallets.ReFungible] : [], async({helper}) => {86 const properties = [87 {key: 'testKey1', value: 'testValue1'},88 {key: 'testKey2', value: 'testValue2'},89 {key: 'testKey3', value: 'testValue3'}];90 const caller = await helper.eth.createAccountWithBalance(donor);91 const collection = await helper[testCase.mode].mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});9293 await collection.addAdmin(alice, {Ethereum: caller});9495 const address = helper.ethAddress.fromCollectionId(collection.collectionId);96 const contract = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');9798 await contract.methods[testCase.method](...testCase.methodParams).send({from: caller});99100 const raw = (await collection.getData())?.raw;101102 expect(raw.properties.length).to.equal(testCase.expectedProps.length);103 expect(raw.properties).to.deep.equal(testCase.expectedProps);104 }));105106 [107 {method: 'deleteCollectionProperties', methodParams: [['testKey2']]},108 {method: 'deleteCollectionProperty', methodParams: ['testKey2']},109 ].map(testCase =>110 itEth(`cannot ${testCase.method}() of non-owned collections`, async ({helper}) => {111 const properties = [112 {key: 'testKey1', value: 'testValue1'},113 {key: 'testKey2', value: 'testValue2'},114 ];115 const caller = await helper.eth.createAccountWithBalance(donor);116 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties});117118 const address = helper.ethAddress.fromCollectionId(collection.collectionId);119 const collectionEvm = await helper.ethNativeContract.collection(address, 'nft', caller, testCase.method === 'deleteCollectionProperty');120121 await expect(collectionEvm.methods[testCase.method](...testCase.methodParams).send({from: caller})).to.be.rejected;122 expect(await collection.getProperties()).to.deep.eq(properties);123 }));124125 itEth('Can be read', async({helper}) => {126 const caller = helper.eth.createAccount();127 const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'test', tokenPrefix: 'test', properties: [{key: 'testKey', value: 'testValue'}]});128129 const address = helper.ethAddress.fromCollectionId(collection.collectionId);130 const contract = await helper.ethNativeContract.collection(address, 'nft', caller);131132 const value = await contract.methods.collectionProperty('testKey').call();133 expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));134 });135});136137describe('Supports ERC721Metadata', () => {138 let donor: IKeyringPair;139140 before(async function() {141 await usingEthPlaygrounds(async (_helper, privateKey) => {142 donor = await privateKey({url: import.meta.url});143 });144 });145146 [147 {case: 'nft' as const},148 {case: 'rft' as const, requiredPallets: [Pallets.ReFungible]},149 ].map(testCase =>150 itEth.ifWithPallets(`ERC721Metadata property can be set for ${testCase.case} collection`, testCase.requiredPallets || [], async ({helper}) => {151 const caller = await helper.eth.createAccountWithBalance(donor);152 const bruh = await helper.eth.createAccountWithBalance(donor);153154 const BASE_URI = 'base/';155 const SUFFIX = 'suffix1';156 const URI = 'uri1';157158 const collectionHelpers = await helper.ethNativeContract.collectionHelpers(caller);159 const creatorMethod = testCase.case === 'rft' ? 'createRFTCollection' : 'createNFTCollection';160161 const {collectionId, collectionAddress} = await helper.eth[creatorMethod](caller, 'n', 'd', 'p');162 const bruhCross = helper.ethCrossAccount.fromAddress(bruh);163164 const contract = await helper.ethNativeContract.collectionById(collectionId, testCase.case, caller);165 await contract.methods.addCollectionAdminCross(bruhCross).send(); // to check that admin will work too166167 const collection1 = helper.nft.getCollectionObject(collectionId);168 const data1 = await collection1.getData();169 expect(data1?.raw.flags.erc721metadata).to.be.false;170 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;171172 await collectionHelpers.methods.makeCollectionERC721MetadataCompatible(collectionAddress, BASE_URI)173 .send({from: bruh});174175 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.true;176177 const collection2 = helper.nft.getCollectionObject(collectionId);178 const data2 = await collection2.getData();179 expect(data2?.raw.flags.erc721metadata).to.be.true;180181 const propertyPermissions = data2?.raw.tokenPropertyPermissions;182 expect(propertyPermissions?.length).to.equal(2);183184 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => tpp.key === 'URI' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner)).to.be.not.null;185186 expect(propertyPermissions.find((tpp: ITokenPropertyPermission) => tpp.key === 'URISuffix' && tpp.permission.mutable && tpp.permission.collectionAdmin && !tpp.permission.tokenOwner)).to.be.not.null;187188 expect(data2?.raw.properties?.find((property: IProperty) => property.key === 'baseURI' && property.value === BASE_URI)).to.be.not.null;189190 const token1Result = await contract.methods.mint(bruh).send();191 const tokenId1 = token1Result.events.Transfer.returnValues.tokenId;192193 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI);194195 await contract.methods.setProperties(tokenId1, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();196 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);197198 await contract.methods.setProperties(tokenId1, [{key: 'URI', value: Buffer.from(URI)}]).send();199 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(URI);200201 await contract.methods.deleteProperties(tokenId1, ['URI']).send();202 expect(await contract.methods.tokenURI(tokenId1).call()).to.equal(BASE_URI + SUFFIX);203204 const token2Result = await contract.methods.mintWithTokenURI(bruh, URI).send();205 const tokenId2 = token2Result.events.Transfer.returnValues.tokenId;206207 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(URI);208209 await contract.methods.deleteProperties(tokenId2, ['URI']).send();210 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI);211212 await contract.methods.setProperties(tokenId2, [{key: 'URISuffix', value: Buffer.from(SUFFIX)}]).send();213 expect(await contract.methods.tokenURI(tokenId2).call()).to.equal(BASE_URI + SUFFIX);214 }));215});tests/src/eth/evmCoder.test.tsdiffbeforeafterboth--- a/tests/src/eth/evmCoder.test.ts
+++ b/tests/src/eth/evmCoder.test.ts
@@ -17,8 +17,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {itEth, expect, usingEthPlaygrounds} from './util';
-const getContractSource = (collectionAddress: string, contractAddress: string): string => {
- return `
+const getContractSource = (collectionAddress: string, contractAddress: string): string => `
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ITest {
@@ -51,7 +50,6 @@
}
}
`;
-};
describe('Evm Coder tests', () => {
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -102,17 +102,15 @@
const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);
// const receiverCross = helper.ethCrossAccount.fromKeyringPair(bob);
- const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
+ const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
const permissions: ITokenPropertyPermission[] = properties
- .map(p => {
- return {
- key: p.key, permission: {
- tokenOwner: false,
- collectionAdmin: true,
- mutable: false,
- },
- };
- });
+ .map(p => ({
+ key: p.key, permission: {
+ tokenOwner: false,
+ collectionAdmin: true,
+ mutable: false,
+ },
+ }));
const collection = await helper.nft.mintCollection(minter, {
tokenPrefix: 'ethp',
@@ -146,7 +144,7 @@
expect(tokenId).to.be.equal(expectedTokenId);
expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties
- .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
+ .map(p => helper.ethProperty.property(p.key, p.value.toString())));
expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))
.to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -46,12 +46,11 @@
const receiverSub = bob;
const receiverCrossSub = helper.ethCrossAccount.fromKeyringPair(receiverSub);
- const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
- const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {
+ const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
+ const permissions: ITokenPropertyPermission[] = properties.map(p => ({key: p.key, permission: {
tokenOwner: false,
collectionAdmin: true,
- mutable: false}};
- });
+ mutable: false}}));
const collection = await helper.rft.mintCollection(minter, {
@@ -86,7 +85,7 @@
expect(tokenId).to.be.equal(expectedTokenId);
expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties
- .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
+ .map(p => helper.ethProperty.property(p.key, p.value.toString())));
expect(await helper.nft.getTokenOwner(collection.collectionId, tokenId))
.to.deep.eq(testCase === 'ethereum' ? {Ethereum: receiverEth.toLowerCase()} : {Substrate: receiverSub.address});
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -241,10 +241,10 @@
itEth.ifWithPallets(`Can be multiple set/read for ${testCase.mode}`, testCase.requiredPallets, async({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
- const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
- const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,
+ const properties = Array(5).fill(0).map((_, i) => ({key: `key_${i}`, value: Buffer.from(`value_${i}`)}));
+ const permissions: ITokenPropertyPermission[] = properties.map(p => ({key: p.key, permission: {tokenOwner: true,
collectionAdmin: true,
- mutable: true}}; });
+ mutable: true}}));
const collection = await helper[testCase.mode].mintCollection(alice, {
tokenPrefix: 'ethp',
@@ -267,10 +267,10 @@
await contract.methods.setProperties(token.tokenId, properties).send({from: caller});
const values = await token.getProperties(properties.map(p => p.key));
- expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));
+ expect(values).to.be.deep.equal(properties.map(p => ({key: p.key, value: p.value.toString()})));
expect(await contract.methods.properties(token.tokenId, []).call()).to.be.like(properties
- .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
+ .map(p => helper.ethProperty.property(p.key, p.value.toString())));
expect(await contract.methods.properties(token.tokenId, [properties[0].key]).call())
.to.be.like([helper.ethProperty.property(properties[0].key, properties[0].value.toString())]);
tests/src/fungible.test.tsdiffbeforeafterboth--- a/tests/src/fungible.test.ts
+++ b/tests/src/fungible.test.ts
@@ -46,7 +46,7 @@
itSub('RPC method tokenOnewrs for fungible collection and token', async ({helper}) => {
const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
- const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
+ const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => ({Substrate: keyring.address}));
const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
tests/src/getPropertiesRpc.test.tsdiffbeforeafterboth--- a/tests/src/getPropertiesRpc.test.ts
+++ b/tests/src/getPropertiesRpc.test.ts
@@ -48,17 +48,13 @@
describe('query properties RPC', () => {
let alice: IKeyringPair;
- const mintCollection = async (helper: UniqueHelper) => {
- return await helper.nft.mintCollection(alice, {
- tokenPrefix: 'prps',
- properties: collectionProps,
- tokenPropertyPermissions: tokenPropPermissions,
- });
- };
+ const mintCollection = async (helper: UniqueHelper) => await helper.nft.mintCollection(alice, {
+ tokenPrefix: 'prps',
+ properties: collectionProps,
+ tokenPropertyPermissions: tokenPropPermissions,
+ });
- const mintToken = async (collection: UniqueNFTCollection) => {
- return await collection.mintToken(alice, {Substrate: alice.address}, tokenProps);
- };
+ const mintToken = async (collection: UniqueNFTCollection) => await collection.mintToken(alice, {Substrate: alice.address}, tokenProps);
before(async () => {
tests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/tokenProperties.test.ts
+++ b/tests/src/nesting/tokenProperties.test.ts
@@ -44,7 +44,7 @@
async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {
const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {
tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
- signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+ signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
});
return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];
}
@@ -201,7 +201,7 @@
const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
const collectionB = await helper.nft.mintCollection(alice, {
tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
- signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+ signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
});
const targetToken = await collectionA.mintToken(alice);
const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
@@ -239,7 +239,7 @@
const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
const collectionB = await helper.nft.mintCollection(alice, {
tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
- signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+ signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
});
const targetToken = await collectionA.mintToken(alice);
const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
@@ -284,7 +284,7 @@
const collectionA = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
const collectionB = await helper.nft.mintCollection(alice, {
tokenPropertyPermissions: permissions.flatMap(({permission, signers}, i) =>
- signers.map(signer => {return {key: `${i+1}_${signer.address}`, permission};})),
+ signers.map(signer => ({key: `${i+1}_${signer.address}`, permission}))),
});
const targetToken = await collectionA.mintToken(alice);
const nestedToken = await collectionB.mintToken(alice, targetToken.nestingAccount());
@@ -477,7 +477,7 @@
async function mintCollectionWithAllPermissionsAndToken(helper: UniqueHelper, mode: 'NFT' | 'RFT'): Promise<[UniqueNFToken | UniqueRFToken, bigint]> {
const collection = await (mode == 'NFT' ? helper.nft : helper.rft).mintCollection(alice, {
- tokenPropertyPermissions: constitution.map(({permission}, i) => {return {key: `${i+1}`, permission};}),
+ tokenPropertyPermissions: constitution.map(({permission}, i) => ({key: `${i+1}`, permission})),
});
return mode == 'NFT' ? [await collection.mintToken(alice), 1n] : [await collection.mintToken(alice, 100n as any), 100n];
}
tests/src/refungible.test.tsdiffbeforeafterboth--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -64,7 +64,7 @@
itSub('RPC method tokenOwners for refungible collection and token', async ({helper}) => {
const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
- const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => {return {Substrate: keyring.address};});
+ const facelessCrowd = (await helper.arrange.createAccounts(Array(7).fill(0n), donor)).map(keyring => ({Substrate: keyring.address}));
const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
tests/src/rpc.test.tsdiffbeforeafterboth--- a/tests/src/rpc.test.ts
+++ b/tests/src/rpc.test.ts
@@ -40,7 +40,7 @@
// Set-up a few token owners of all stripes
const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};
const facelessCrowd = (await helper.arrange.createAccounts([0n, 0n, 0n, 0n, 0n, 0n, 0n], donor))
- .map(i => {return {Substrate: i.address};});
+ .map(i => ({Substrate: i.address}));
const collection = await helper.ft.mintCollection(alice, {name: 'RPC-2', tokenPrefix: 'RPC'});
// mint some maximum (u128) amounts of tokens possible
tests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth--- a/tests/src/sub/appPromotion/appPromotion.test.ts
+++ b/tests/src/sub/appPromotion/appPromotion.test.ts
@@ -357,11 +357,9 @@
const stakers = await getAccounts(3);
await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
- await Promise.all(stakers.map(staker => {
- return testCase.method === 'unstakeAll'
- ? helper.staking.unstakeAll(staker)
- : helper.staking.unstakePartial(staker, 100n * nominal);
- }));
+ await Promise.all(stakers.map(staker => testCase.method === 'unstakeAll'
+ ? helper.staking.unstakeAll(staker)
+ : helper.staking.unstakePartial(staker, 100n * nominal)));
await Promise.all(stakers.map(async (staker) => {
expect(await helper.staking.getPendingUnstake({Substrate: staker.address})).to.be.equal(100n * nominal);
@@ -375,11 +373,9 @@
const stakers = await getAccounts(10);
await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
- const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => {
- return i % 2 === 0
- ? helper.staking.unstakeAll(staker)
- : helper.staking.unstakePartial(staker, 100n * nominal);
- }));
+ const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => i % 2 === 0
+ ? helper.staking.unstakeAll(staker)
+ : helper.staking.unstakePartial(staker, 100n * nominal)));
const successfulUnstakes = unstakingResults.filter(result => result.status === 'fulfilled');
expect(successfulUnstakes).to.have.length(3);
tests/src/util/index.tsdiffbeforeafterboth--- a/tests/src/util/index.ts
+++ b/tests/src/util/index.ts
@@ -19,13 +19,9 @@
chai.use(chaiSubset);
export const expect = chai.expect;
-const getTestHash = (filename: string) => {
- return crypto.createHash('md5').update(filename).digest('hex');
-};
+const getTestHash = (filename: string) => crypto.createHash('md5').update(filename).digest('hex');
-export const getTestSeed = (filename: string) => {
- return `//Alice+${getTestHash(filename)}`;
-};
+export const getTestSeed = (filename: string) => `//Alice+${getTestHash(filename)}`;
async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {
const silentConsole = new SilentConsole();
@@ -65,49 +61,27 @@
}
}
-export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {
- return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
-};
+export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename?: string, url?: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
-export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
-};
+export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);
-export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);
-};
+export const usingStateminePlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevStatemineHelper>(DevWestmintHelper, url, code);
-export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);
-};
+export const usingStatemintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevStatemintHelper>(DevWestmintHelper, url, code);
-export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
-};
+export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
-export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
-};
+export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
-export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
-};
+export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
-export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
-};
+export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
-export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
-};
+export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
-export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);
-};
+export const usingAstarPlaygrounds = (url: string, code: (helper: DevAstarHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevAstarHelper>(DevAstarHelper, url, code);
-export const usingShidenPlaygrounds = (url: string, code: (helper: DevShidenHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {
- return usingPlaygroundsGeneral<DevShidenHelper>(DevShidenHelper, url, code);
-};
+export const usingShidenPlaygrounds = (url: string, code: (helper: DevShidenHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => usingPlaygroundsGeneral<DevShidenHelper>(DevShidenHelper, url, code);
export const MINIMUM_DONOR_FUND = 100_000n;
export const DONOR_FUNDING = 2_000_000n;
tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -771,9 +771,7 @@
// <<< Referendum voting <<<
// Wait the proposal to pass
- await this.helper.wait.expectEvent(3, Event.Democracy.Passed, event => {
- return event.referendumIndex() == referendumIndex;
- });
+ await this.helper.wait.expectEvent(3, Event.Democracy.Passed, event => event.referendumIndex() == referendumIndex);
await this.helper.wait.newBlocks(1);
@@ -924,7 +922,7 @@
event<T extends IEventHelper>(
maxBlocksToWait: number,
eventHelperType: new () => T,
- filter: (_: T) => boolean = () => { return true; },
+ filter: (_: T) => boolean = () => true,
) {
// eslint-disable-next-line no-async-promise-executor
const promise = new Promise<T | null>(async (resolve) => {
@@ -970,7 +968,7 @@
async expectEvent<T extends IEventHelper>(
maxBlocksToWait: number,
eventHelperType: new () => T,
- filter: (e: T) => boolean = () => { return true; },
+ filter: (e: T) => boolean = () => true,
) {
const e = await this.event(maxBlocksToWait, eventHelperType, filter);
if (e == null) {
@@ -1077,9 +1075,7 @@
async startCapture() {
this.stopCapture();
this.unsubscribe = (await this.helper.getApi().query.system.events((eventRecords: FrameSystemEventRecord[]) => {
- const newEvents = eventRecords.filter(r => {
- return r.event.section == this.eventSection && r.event.method == this.eventMethod;
- });
+ const newEvents = eventRecords.filter(r => r.event.section == this.eventSection && r.event.method == this.eventMethod);
this.events.push(...newEvents);
})) as any;
@@ -1105,12 +1101,10 @@
async payoutStakers(signer: IKeyringPair, stakersToPayout: number): Promise<{staker: string, stake: bigint, payout: bigint}[]> {
const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);
- return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => {
- return {
- staker: e.event.data[0].toString(),
- stake: e.event.data[1].toBigInt(),
- payout: e.event.data[2].toBigInt(),
- };
- });
+ return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => ({
+ staker: e.event.data[0].toString(),
+ stake: e.event.data[1].toBigInt(),
+ payout: e.event.data[2].toBigInt(),
+ }));
}
}
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2395,7 +2395,7 @@
return total.toBigInt();
}
- async getLocked(address: TSubstrateAccount): Promise<[{ id: string, amount: bigint, reason: string }]> {
+ async getLocked(address: TSubstrateAccount): Promise<{ id: string, amount: bigint, reason: string }[]> {
const locks = (await this.helper.callRpc('api.query.balances.locks', [address])).toHuman();
return locks.map((lock: any) => ({id: lock.id, amount: BigInt(lock.amount.replace(/,/g, '')), reasons: lock.reasons}));
}
@@ -2581,14 +2581,12 @@
*/
async getVestingSchedules(address: TSubstrateAccount): Promise<{ start: bigint, period: bigint, periodCount: bigint, perPeriod: bigint }[]> {
const schedule = (await this.helper.callRpc('api.query.vesting.vestingSchedules', [address])).toJSON();
- return schedule.map((schedule: any) => {
- return {
- start: BigInt(schedule.start),
- period: BigInt(schedule.period),
- periodCount: BigInt(schedule.periodCount),
- perPeriod: BigInt(schedule.perPeriod),
- };
- });
+ return schedule.map((schedule: any) => ({
+ start: BigInt(schedule.start),
+ period: BigInt(schedule.period),
+ periodCount: BigInt(schedule.periodCount),
+ perPeriod: BigInt(schedule.perPeriod),
+ }));
}
/**
@@ -2804,12 +2802,10 @@
*/
async getTotalStakedPerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {
const rawTotalStakerdPerBlock = await this.helper.callRpc('api.rpc.appPromotion.totalStakedPerBlock', [address]);
- return rawTotalStakerdPerBlock.map(([block, amount]: any[]) => {
- return {
- block: block.toBigInt(),
- amount: amount.toBigInt(),
- };
- });
+ return rawTotalStakerdPerBlock.map(([block, amount]: any[]) => ({
+ block: block.toBigInt(),
+ amount: amount.toBigInt(),
+ }));
}
/**
@@ -2828,12 +2824,10 @@
*/
async getPendingUnstakePerBlock(address: ICrossAccountId): Promise<IStakingInfo[]> {
const rawUnstakedPerBlock = await this.helper.callRpc('api.rpc.appPromotion.pendingUnstakePerBlock', [address]);
- const result = rawUnstakedPerBlock.map(([block, amount]: any[]) => {
- return {
- block: block.toBigInt(),
- amount: amount.toBigInt(),
- };
- });
+ const result = rawUnstakedPerBlock.map(([block, amount]: any[]) => ({
+ block: block.toBigInt(),
+ amount: amount.toBigInt(),
+ }));
return result;
}
}
tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmQuartz.test.ts
+++ b/tests/src/xcm/xcmQuartz.test.ts
@@ -682,10 +682,8 @@
maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(targetAccountBalance).to.be.equal(0n);
@@ -765,10 +763,8 @@
maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -780,10 +776,8 @@
maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -858,10 +852,8 @@
});
const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == messageSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == messageSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
};
itSub('Quartz rejects KAR tokens from Karura', async ({helper}) => {
@@ -1172,10 +1164,8 @@
maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(targetAccountBalance).to.be.equal(0n);
@@ -1263,10 +1253,8 @@
maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -1282,10 +1270,8 @@
maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -1544,10 +1530,8 @@
maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(targetAccountBalance).to.be.equal(0n);
@@ -1627,10 +1611,8 @@
maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -1642,10 +1624,8 @@
maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth--- a/tests/src/xcm/xcmUnique.test.ts
+++ b/tests/src/xcm/xcmUnique.test.ts
@@ -684,10 +684,8 @@
maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(targetAccountBalance).to.be.equal(0n);
@@ -767,10 +765,8 @@
maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -782,10 +778,8 @@
maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -860,10 +854,8 @@
});
const expectFailedToTransact = async (helper: DevUniqueHelper, messageSent: any) => {
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == messageSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == messageSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
};
itSub('Unique rejects ACA tokens from Acala', async ({helper}) => {
@@ -1175,10 +1167,8 @@
maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(targetAccountBalance).to.be.equal(0n);
@@ -1266,10 +1256,8 @@
maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -1285,10 +1273,8 @@
maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -1546,10 +1532,8 @@
maliciousXcmProgramSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramSent.messageHash()
- && event.outcome().isFailedToTransactAsset;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramSent.messageHash()
+ && event.outcome().isFailedToTransactAsset);
targetAccountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(targetAccountBalance).to.be.equal(0n);
@@ -1629,10 +1613,8 @@
maliciousXcmProgramFullIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramFullIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
let accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);
@@ -1644,10 +1626,8 @@
maliciousXcmProgramHereIdSent = await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.XcmpMessageSent);
});
- await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => {
- return event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
- && event.outcome().isUntrustedReserveLocation;
- });
+ await helper.wait.expectEvent(maxWaitBlocks, Event.XcmpQueue.Fail, event => event.messageHash() == maliciousXcmProgramHereIdSent.messageHash()
+ && event.outcome().isUntrustedReserveLocation);
accountBalance = await helper.balance.getSubstrate(targetAccount.address);
expect(accountBalance).to.be.equal(0n);