--- a/tests/src/eth/collectionAdmin.test.ts +++ b/tests/src/eth/collectionAdmin.test.ts @@ -15,7 +15,7 @@ import {expect} from 'chai'; import privateKey from '../substrate/privateKey'; -import { UNIQUE } from '../util/helpers'; +import {UNIQUE} from '../util/helpers'; import { createEthAccount, createEthAccountWithBalance, @@ -24,7 +24,6 @@ getCollectionAddressFromResult, itWeb3, recordEthFee, - subToEth, } from './util/helpers'; describe('Add collection admins', () => { @@ -37,7 +36,7 @@ .send(); const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result); - const newAdmin = await createEthAccount(web3); + const newAdmin = createEthAccount(web3); const collectionEvm = evmCollection(web3, owner, collectionIdAddress); await collectionEvm.methods.addCollectionAdmin(newAdmin).send(); const adminList = await api.rpc.unique.adminlist(collectionId); @@ -92,7 +91,7 @@ const collectionEvm = evmCollection(web3, owner, collectionIdAddress); await collectionEvm.methods.addCollectionAdmin(admin).send(); - const user = await createEthAccount(web3); + const user = createEthAccount(web3); await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin})) .to.be.rejectedWith('NoPermission'); @@ -114,7 +113,7 @@ const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper); const collectionEvm = evmCollection(web3, owner, collectionIdAddress); - const user = await createEthAccount(web3); + const user = createEthAccount(web3); await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin})) .to.be.rejectedWith('NoPermission'); @@ -175,7 +174,7 @@ .send(); const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result); - const newAdmin = await createEthAccount(web3); + const newAdmin = createEthAccount(web3); const collectionEvm = evmCollection(web3, owner, collectionIdAddress); await collectionEvm.methods.addCollectionAdmin(newAdmin).send(); { @@ -226,7 +225,7 @@ const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper); await collectionEvm.methods.addCollectionAdmin(admin0).send(); - const admin1 = await createEthAccount(web3); + const admin1 = createEthAccount(web3); await collectionEvm.methods.addCollectionAdmin(admin1).send(); await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0})) @@ -253,7 +252,7 @@ const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper); await collectionEvm.methods.addCollectionAdmin(admin).send(); - const notAdmin = await createEthAccount(web3); + const notAdmin = createEthAccount(web3); await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin})) .to.be.rejectedWith('NoPermission'); --- a/tests/src/eth/collectionSponsoring.test.ts +++ b/tests/src/eth/collectionSponsoring.test.ts @@ -1,5 +1,5 @@ import {addToAllowListExpectSuccess, bigIntToSub, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess} from '../util/helpers'; -import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub, subToEth} from './util/helpers'; +import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub} from './util/helpers'; import nonFungibleAbi from './nonFungibleAbi.json'; import {expect} from 'chai'; import {evmToAddress} from '@polkadot/util-crypto'; --- a/tests/src/eth/createNFTCollection.test.ts +++ b/tests/src/eth/createNFTCollection.test.ts @@ -181,7 +181,7 @@ }); itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => { - const owner = await createEthAccount(web3); + const owner = createEthAccount(web3); const helper = evmCollectionHelpers(web3, owner); const collectionName = 'A'; const description = 'A'; @@ -194,7 +194,7 @@ itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => { const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper); - const notOwner = await createEthAccount(web3); + const notOwner = createEthAccount(web3); const collectionHelpers = evmCollectionHelpers(web3, owner); const result = await collectionHelpers.methods.createNonfungibleCollection('A', 'A', 'A').send(); const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); --- a/tests/src/eth/createRFTCollection.test.ts +++ b/tests/src/eth/createRFTCollection.test.ts @@ -189,7 +189,7 @@ }); itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => { - const owner = await createEthAccount(web3); + const owner = createEthAccount(web3); const helper = evmCollectionHelpers(web3, owner); const collectionName = 'A'; const description = 'A'; @@ -202,7 +202,7 @@ itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => { const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper); - const notOwner = await createEthAccount(web3); + const notOwner = createEthAccount(web3); const collectionHelpers = evmCollectionHelpers(web3, owner); const result = await collectionHelpers.methods.createRefungibleCollection('A', 'A', 'A').send(); const {collectionIdAddress} = await getCollectionAddressFromResult(api, result); --- a/tests/src/eth/nesting/nest.test.ts +++ b/tests/src/eth/nesting/nest.test.ts @@ -1,7 +1,7 @@ import {IKeyringPair} from '@polkadot/types/types'; import {Contract} from 'web3-eth-contract'; -import {itEth, EthUniqueHelper, usingEthPlaygrounds, expect} from '../util/playgrounds' +import {itEth, EthUniqueHelper, usingEthPlaygrounds, expect} from '../util/playgrounds'; const createNestingCollection = async ( helper: EthUniqueHelper, --- a/tests/src/eth/reFungibleToken.test.ts +++ b/tests/src/eth/reFungibleToken.test.ts @@ -15,7 +15,7 @@ // along with Unique Network. If not, see . import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers'; -import {collectionIdFromAddress, collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createNonfungibleCollection, createRefungibleCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from './util/helpers'; +import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createRefungibleCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueRefungible, uniqueRefungibleToken} from './util/helpers'; import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; --- a/tests/src/eth/util/playgrounds/index.ts +++ b/tests/src/eth/util/playgrounds/index.ts @@ -33,7 +33,7 @@ await helper.disconnectWeb3(); silentConsole.disable(); } -} +}; export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) { let i: any = it; --- a/tests/src/eth/util/playgrounds/unique.dev.ts +++ b/tests/src/eth/util/playgrounds/unique.dev.ts @@ -38,18 +38,18 @@ class ContractGroup extends EthGroupBase { async findImports(imports?: ContractImports[]){ if(!imports) return function(path: string) { - return {error: 'File not found'}; + return {error: `File not found: ${path}`}; }; const knownImports = {} as any; - for(let imp of imports) { + for(const imp of imports) { knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString(); } return function(path: string) { - if(knownImports.hasOwnProperty(path)) return {contents: knownImports[path]}; - return {error: 'File not found'}; - } + if(knownImports.hasOwnPropertyDescriptor(path)) return {contents: knownImports[path]}; + return {error: `File not found: ${path}`}; + }; } async compile(name: string, src: string, imports?: ContractImports[]): Promise { @@ -85,7 +85,7 @@ const contract = new web3.eth.Contract(abi, undefined, { data: object, from: signer, - gas: this.helper.eth.DEFAULT_GAS + gas: this.helper.eth.DEFAULT_GAS, }); return await contract.deploy({data: object}).send({from: signer}); } @@ -108,7 +108,7 @@ const abi = { 'nft': nonFungibleAbi, 'rft': refungibleAbi, - 'ft': fungibleAbi + 'ft': fungibleAbi, }[mode]; const web3 = this.helper.getWeb3(); return new web3.eth.Contract(abi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})}); @@ -154,7 +154,7 @@ await this.helper.executeExtrinsic( signer, 'api.tx.evm.call', [this.helper.address.substrateToEth(signer.address), contractAddress, abi, value, gasLimit, gasPrice, null, null, []], - true, `Unable to perform evm.call` + true, 'Unable to perform evm.call', ); }