difftreelog
test(eth) fix linting errors and warnings
in: master
8 files changed
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth24 getCollectionAddressFromResult, 24 getCollectionAddressFromResult, 25 itWeb3,25 itWeb3,26 recordEthFee,26 recordEthFee,27 subToEth,28} from './util/helpers';27} from './util/helpers';292830describe('Add collection admins', () => {29describe('Add collection admins', () => {37 .send();36 .send();38 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);37 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);393840 const newAdmin = await createEthAccount(web3);39 const newAdmin = createEthAccount(web3);41 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);40 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);42 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();41 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();43 const adminList = await api.rpc.unique.adminlist(collectionId);42 const adminList = await api.rpc.unique.adminlist(collectionId);92 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);91 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);93 await collectionEvm.methods.addCollectionAdmin(admin).send();92 await collectionEvm.methods.addCollectionAdmin(admin).send();94 93 95 const user = await createEthAccount(web3);94 const user = createEthAccount(web3);96 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))95 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: admin}))97 .to.be.rejectedWith('NoPermission');96 .to.be.rejectedWith('NoPermission');9897114 const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);113 const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);115 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);114 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);116 115 117 const user = await createEthAccount(web3);116 const user = createEthAccount(web3);118 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))117 await expect(collectionEvm.methods.addCollectionAdmin(user).call({from: notAdmin}))119 .to.be.rejectedWith('NoPermission');118 .to.be.rejectedWith('NoPermission');120119175 .send();174 .send();176 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);175 const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);177176178 const newAdmin = await createEthAccount(web3);177 const newAdmin = createEthAccount(web3);179 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);178 const collectionEvm = evmCollection(web3, owner, collectionIdAddress);180 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();179 await collectionEvm.methods.addCollectionAdmin(newAdmin).send();181 {180 {226225227 const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);226 const admin0 = await createEthAccountWithBalance(api, web3, privateKeyWrapper);228 await collectionEvm.methods.addCollectionAdmin(admin0).send();227 await collectionEvm.methods.addCollectionAdmin(admin0).send();229 const admin1 = await createEthAccount(web3);228 const admin1 = createEthAccount(web3);230 await collectionEvm.methods.addCollectionAdmin(admin1).send();229 await collectionEvm.methods.addCollectionAdmin(admin1).send();231230232 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))231 await expect(collectionEvm.methods.removeCollectionAdmin(admin1).call({from: admin0}))253252254 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);253 const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);255 await collectionEvm.methods.addCollectionAdmin(admin).send();254 await collectionEvm.methods.addCollectionAdmin(admin).send();256 const notAdmin = await createEthAccount(web3);255 const notAdmin = createEthAccount(web3);257256258 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))257 await expect(collectionEvm.methods.removeCollectionAdmin(admin).call({from: notAdmin}))259 .to.be.rejectedWith('NoPermission');258 .to.be.rejectedWith('NoPermission');tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- 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';
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth--- 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);
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- 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);
tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth--- 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,
tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth--- 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 <http://www.gnu.org/licenses/>.
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';
tests/src/eth/util/playgrounds/index.tsdiffbeforeafterboth--- 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;
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- 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<CompiledContract> {
@@ -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',
);
}