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.tsdiffbeforeafterboth1import {addToAllowListExpectSuccess, bigIntToSub, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess} from '../util/helpers';1import {addToAllowListExpectSuccess, bigIntToSub, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess} from '../util/helpers';2import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub, subToEth} from './util/helpers';2import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub} from './util/helpers';3import nonFungibleAbi from './nonFungibleAbi.json';3import nonFungibleAbi from './nonFungibleAbi.json';4import {expect} from 'chai';4import {expect} from 'chai';5import {evmToAddress} from '@polkadot/util-crypto';5import {evmToAddress} from '@polkadot/util-crypto';tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth181 });181 });182 182 183 itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => {183 itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => {184 const owner = await createEthAccount(web3);184 const owner = createEthAccount(web3);185 const helper = evmCollectionHelpers(web3, owner);185 const helper = evmCollectionHelpers(web3, owner);186 const collectionName = 'A';186 const collectionName = 'A';187 const description = 'A';187 const description = 'A';194194195 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {195 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {196 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);196 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);197 const notOwner = await createEthAccount(web3);197 const notOwner = createEthAccount(web3);198 const collectionHelpers = evmCollectionHelpers(web3, owner);198 const collectionHelpers = evmCollectionHelpers(web3, owner);199 const result = await collectionHelpers.methods.createNonfungibleCollection('A', 'A', 'A').send();199 const result = await collectionHelpers.methods.createNonfungibleCollection('A', 'A', 'A').send();200 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);200 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth189 });189 });190 190 191 itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => {191 itWeb3('(!negative test!) Create collection (no funds)', async ({web3}) => {192 const owner = await createEthAccount(web3);192 const owner = createEthAccount(web3);193 const helper = evmCollectionHelpers(web3, owner);193 const helper = evmCollectionHelpers(web3, owner);194 const collectionName = 'A';194 const collectionName = 'A';195 const description = 'A';195 const description = 'A';202202203 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {203 itWeb3('(!negative test!) Check owner', async ({api, web3, privateKeyWrapper}) => {204 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);204 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);205 const notOwner = await createEthAccount(web3);205 const notOwner = createEthAccount(web3);206 const collectionHelpers = evmCollectionHelpers(web3, owner);206 const collectionHelpers = evmCollectionHelpers(web3, owner);207 const result = await collectionHelpers.methods.createRefungibleCollection('A', 'A', 'A').send();207 const result = await collectionHelpers.methods.createRefungibleCollection('A', 'A', 'A').send();208 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);208 const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth1import {IKeyringPair} from '@polkadot/types/types';1import {IKeyringPair} from '@polkadot/types/types';2import {Contract} from 'web3-eth-contract';2import {Contract} from 'web3-eth-contract';334import {itEth, EthUniqueHelper, usingEthPlaygrounds, expect} from '../util/playgrounds'4import {itEth, EthUniqueHelper, usingEthPlaygrounds, expect} from '../util/playgrounds';556const createNestingCollection = async (6const createNestingCollection = async (7 helper: EthUniqueHelper,7 helper: EthUniqueHelper,tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers';17import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers';18import {collectionIdFromAddress, collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createNonfungibleCollection, createRefungibleCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from './util/helpers';18import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createRefungibleCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueRefungible, uniqueRefungibleToken} from './util/helpers';191920import chai from 'chai';20import chai from 'chai';21import chaiAsPromised from 'chai-as-promised';21import chaiAsPromised from 'chai-as-promised';tests/src/eth/util/playgrounds/index.tsdiffbeforeafterboth33 await helper.disconnectWeb3();33 await helper.disconnectWeb3();34 silentConsole.disable();34 silentConsole.disable();35 }35 }36}36};37 37 38export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {38export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {39 let i: any = it;39 let i: any = it;tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth38class ContractGroup extends EthGroupBase {38class ContractGroup extends EthGroupBase {39 async findImports(imports?: ContractImports[]){39 async findImports(imports?: ContractImports[]){40 if(!imports) return function(path: string) {40 if(!imports) return function(path: string) {41 return {error: 'File not found'};41 return {error: `File not found: ${path}`};42 };42 };43 43 44 const knownImports = {} as any;44 const knownImports = {} as any;45 for(let imp of imports) {45 for(const imp of imports) {46 knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString();46 knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString();47 }47 }48 48 49 return function(path: string) {49 return function(path: string) {50 if(knownImports.hasOwnProperty(path)) return {contents: knownImports[path]};50 if(knownImports.hasOwnPropertyDescriptor(path)) return {contents: knownImports[path]};51 return {error: 'File not found'};51 return {error: `File not found: ${path}`};52 }52 };53 }53 }545455 async compile(name: string, src: string, imports?: ContractImports[]): Promise<CompiledContract> {55 async compile(name: string, src: string, imports?: ContractImports[]): Promise<CompiledContract> {154 await this.helper.executeExtrinsic(154 await this.helper.executeExtrinsic(155 signer,155 signer,156 'api.tx.evm.call', [this.helper.address.substrateToEth(signer.address), contractAddress, abi, value, gasLimit, gasPrice, null, null, []],156 'api.tx.evm.call', [this.helper.address.substrateToEth(signer.address), contractAddress, abi, value, gasLimit, gasPrice, null, null, []],157 true, `Unable to perform evm.call`157 true, 'Unable to perform evm.call',158 );158 );159 }159 }160160