git.delta.rocks / unique-network / refs/commits / f462fd90fa85

difftreelog

Tests: code-style fixes

Andrey2022-10-06parent: #21df7e4.patch.diff
in: master

14 files changed

modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -110,7 +110,7 @@
     const [alice, ...accounts] = await helper.arrange.createAccounts([10n, 0n, 0n, 0n, 0n, 0n, 0n, 0n], donor);
     const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
 
-    const chainAdminLimit = (helper.api!.consts.common.collectionAdminsLimit as any).toNumber();
+    const chainAdminLimit = (helper.getApi().consts.common.collectionAdminsLimit as any).toNumber();
     expect(chainAdminLimit).to.be.equal(5);
 
     for (let i = 0; i < chainAdminLimit; i++) {
modifiedtests/src/approve.test.tsdiffbeforeafterboth
--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -60,7 +60,7 @@
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
     await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
-    await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));
+    await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
   });
 
@@ -275,7 +275,7 @@
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
     await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
-    await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));
+    await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
     const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
     await expect(transferTokenFromTx()).to.be.rejected;
@@ -328,7 +328,7 @@
   itSub('1 for NFT', async ({helper}) => {
     const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
-    const approveTx = async () => helper.signTransaction(bob, helper.api?.tx.unique.approve({Substrate: charlie.address}, collectionId, tokenId, 2));
+    const approveTx = async () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
     await expect(approveTx()).to.be.rejected;
     expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;
   });
modifiedtests/src/block-production.test.tsdiffbeforeafterboth
--- a/tests/src/block-production.test.ts
+++ b/tests/src/block-production.test.ts
@@ -37,7 +37,7 @@
 
 describe('Block Production smoke test', () => {
   itSub('Node produces new blocks', async ({helper}) => {
-    const blocks: number[] | undefined = await getBlocks(helper.api!);
+    const blocks: number[] | undefined = await getBlocks(helper.getApi());
     expect(blocks[0]).to.be.lessThan(blocks[1]);
   });
 });
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
--- a/tests/src/createMultipleItemsEx.test.ts
+++ b/tests/src/createMultipleItemsEx.test.ts
@@ -178,13 +178,12 @@
       tokenPrefix: 'COL',
     }, 0);
 
-    const api = helper.api;
-    await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {
+    await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx',[collection.collectionId, {
       Fungible: new Map([
         [JSON.stringify({Substrate: alice.address}), 50],
         [JSON.stringify({Substrate: bob.address}), 100],
       ]),
-    }));
+    }], true);
 
     expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(50n);
     expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(100n);
@@ -200,8 +199,7 @@
       ],
     });
 
-    const api = helper.api;
-    await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {
+    await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx', [collection.collectionId, {
       RefungibleMultipleOwners: {
         users: new Map([
           [JSON.stringify({Substrate: alice.address}), 1],
@@ -211,7 +209,7 @@
           {key: 'k', value: 'v'},
         ],
       },
-    }));
+    }], true);
     const tokenId = await collection.getLastTokenId();
     expect(tokenId).to.be.equal(1);
     expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);
@@ -228,9 +226,7 @@
       ],
     });
 
-    const api = helper.api;
-
-    await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {
+    await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx', [collection.collectionId, {
       RefungibleMultipleItems: [
         {
           user: {Substrate: alice.address}, pieces: 1,
@@ -245,7 +241,7 @@
           ],
         },
       ],
-    }));
+    }], true);
 
     expect(await collection.getLastTokenId()).to.be.equal(2);
     expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -70,7 +70,7 @@
   });
 
   itSub('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async ({helper}) => {
-    await skipInflationBlock(helper.api!);
+    await skipInflationBlock(helper.getApi());
     await helper.wait.newBlocks(1);
 
     const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
@@ -89,7 +89,7 @@
   });
 
   itSub('Treasury balance increased by failed tx fee', async ({helper}) => {
-    const api = helper.api!;
+    const api = helper.getApi();
     await helper.wait.newBlocks(1);
 
     const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
@@ -107,7 +107,7 @@
   });
 
   itSub('NFT Transactions also send fees to Treasury', async ({helper}) => {
-    await skipInflationBlock(helper.api!);
+    await skipInflationBlock(helper.getApi());
     await helper.wait.newBlocks(1);
 
     const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
@@ -125,7 +125,7 @@
 
   itSub('Fees are sane', async ({helper}) => {
     const unique = helper.balance.getOneTokenNominal();
-    await skipInflationBlock(helper.api!);
+    await skipInflationBlock(helper.getApi());
     await helper.wait.newBlocks(1);
 
     const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);
@@ -140,7 +140,7 @@
   });
 
   itSub('NFT Transfer fee is close to 0.1 Unique', async ({helper}) => {
-    await skipInflationBlock(helper.api!);
+    await skipInflationBlock(helper.getApi());
     await helper.wait.newBlocks(1);
 
     const collection = await helper.nft.mintCollection(alice, {
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -152,7 +152,7 @@
   before(async function() {
     await usingEthPlaygrounds(async (helper, privateKey) => {
       donor = privateKey('//Alice');
-      nominal = helper.balance.getOneTokenNominal()
+      nominal = helper.balance.getOneTokenNominal();
     });
   });
 
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -138,23 +138,16 @@
   });
 
   //TODO: CORE-302 add eth methods
-  itEth.skip('Can perform mintBulk()', async ({helper, privateKey}) => {
-    const api = helper.getApi();
-    const web3 = helper.getWeb3();
-    const privateKeyWrapper = privateKey;
-    /*
-    const collection = await createCollectionExpectSuccess({
-      mode: {type: 'NFT'},
-    });
-    const alice = privateKeyWrapper('//Alice');
+  itEth.skip('Can perform mintBulk()', async ({helper}) => {
+    const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});
 
-    const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
-    const receiver = createEthAccount(web3);
+    const caller = await helper.eth.createAccountWithBalance(donor, 30n);
+    const receiver = helper.eth.createAccount();
 
-    const address = collectionIdToAddress(collection);
-    const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}), privateKeyWrapper);
-    const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});
-    await submitTransactionAsync(alice, changeAdminTx);
+    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+    const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);
+    const contract = await proxyWrap(helper, evmCollection, donor);
+    await collection.addAdmin(donor, {Ethereum: contract.options.address});
 
     {
       const nextTokenId = await contract.methods.nextTokenId().call();
@@ -167,7 +160,7 @@
           [+nextTokenId + 2, 'Test URI 2'],
         ],
       ).send({from: caller});
-      const events = normalizeEvents(result.events);
+      const events = helper.eth.normalizeEvents(result.events);
 
       expect(events).to.be.deep.equal([
         {
@@ -203,7 +196,6 @@
       expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');
       expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');
     }
-    */
   });
 
   itEth('Can perform burn()', async ({helper}) => {
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
before · tests/src/eth/util/playgrounds/unique.dev.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034/* eslint-disable function-call-argument-newline */5// eslint-disable-next-line @typescript-eslint/triple-slash-reference6/// <reference path="unique.dev.d.ts" />78import {readFile} from 'fs/promises';910import Web3 from 'web3';11import {WebsocketProvider} from 'web3-core';12import {Contract} from 'web3-eth-contract';1314import * as solc from 'solc';1516import {evmToAddress} from '@polkadot/util-crypto';17import {IKeyringPair} from '@polkadot/types/types';1819import {DevUniqueHelper} from '../../../util/playgrounds/unique.dev';2021import {ContractImports, CompiledContract, NormalizedEvent} from './types';2223// Native contracts ABI24import collectionHelpersAbi from '../../collectionHelpersAbi.json';25import fungibleAbi from '../../fungibleAbi.json';26import nonFungibleAbi from '../../nonFungibleAbi.json';27import refungibleAbi from '../../reFungibleAbi.json';28import refungibleTokenAbi from '../../reFungibleTokenAbi.json';29import contractHelpersAbi from './../contractHelpersAbi.json';30import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';3132class EthGroupBase {33  helper: EthUniqueHelper;3435  constructor(helper: EthUniqueHelper) {36    this.helper = helper;37  }38}394041class ContractGroup extends EthGroupBase {42  async findImports(imports?: ContractImports[]){43    if(!imports) return function(path: string) {44      return {error: `File not found: ${path}`};45    };46  47    const knownImports = {} as {[key: string]: string};48    for(const imp of imports) {49      knownImports[imp.solPath] = (await readFile(imp.fsPath)).toString();50    }51  52    return function(path: string) {53      if(path in knownImports) return {contents: knownImports[path]};54      return {error: `File not found: ${path}`};55    };56  }5758  async compile(name: string, src: string, imports?: ContractImports[]): Promise<CompiledContract> {59    const out = JSON.parse(solc.compile(JSON.stringify({60      language: 'Solidity',61      sources: {62        [`${name}.sol`]: {63          content: src,64        },65      },66      settings: {67        outputSelection: {68          '*': {69            '*': ['*'],70          },71        },72      },73    }), {import: await this.findImports(imports)})).contracts[`${name}.sol`][name];74  75    return {76      abi: out.abi,77      object: '0x' + out.evm.bytecode.object,78    };79  }8081  async deployByCode(signer: string, name: string, src: string, imports?: ContractImports[]): Promise<Contract> {82    const compiledContract = await this.compile(name, src, imports);83    return this.deployByAbi(signer, compiledContract.abi, compiledContract.object);84  }8586  async deployByAbi(signer: string, abi: any, object: string): Promise<Contract> {87    const web3 = this.helper.getWeb3();88    const contract = new web3.eth.Contract(abi, undefined, {89      data: object,90      from: signer,91      gas: this.helper.eth.DEFAULT_GAS,92    });93    return await contract.deploy({data: object}).send({from: signer});94  }9596}97  98class NativeContractGroup extends EthGroupBase {99100  contractHelpers(caller: string): Contract {101    const web3 = this.helper.getWeb3();102    return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, gas: this.helper.eth.DEFAULT_GAS});103  }104105  collectionHelpers(caller: string) {106    const web3 = this.helper.getWeb3();107    return new web3.eth.Contract(collectionHelpersAbi as any, '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f', {from: caller, gas: this.helper.eth.DEFAULT_GAS});108  }109110  collection(address: string, mode: 'nft' | 'rft' | 'ft', caller?: string): Contract {111    const abi = {112      'nft': nonFungibleAbi,113      'rft': refungibleAbi,114      'ft': fungibleAbi,115    }[mode];116    const web3 = this.helper.getWeb3();117    return new web3.eth.Contract(abi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});118  }119120  collectionById(collectionId: number, mode: 'nft' | 'rft' | 'ft', caller?: string): Contract {121    return this.collection(this.helper.ethAddress.fromCollectionId(collectionId), mode, caller);122  }123124  rftToken(address: string, caller?: string): Contract {125    const web3 = this.helper.getWeb3();126    return new web3.eth.Contract(refungibleTokenAbi as any, address, {gas: this.helper.eth.DEFAULT_GAS, ...(caller ? {from: caller} : {})});127  }128129  rftTokenById(collectionId: number, tokenId: number, caller?: string): Contract {130    return this.rftToken(this.helper.ethAddress.fromTokenId(collectionId, tokenId), caller);131  }132}133134135class EthGroup extends EthGroupBase {136  DEFAULT_GAS = 2_500_000;137138  createAccount() {139    const web3 = this.helper.getWeb3();140    const account = web3.eth.accounts.create();141    web3.eth.accounts.wallet.add(account.privateKey);142    return account.address;143  }144145  async createAccountWithBalance(donor: IKeyringPair, amount=1000n) {146    const account = this.createAccount();147    await this.transferBalanceFromSubstrate(donor, account, amount);148  149    return account;150  }151152  async transferBalanceFromSubstrate(donor: IKeyringPair, recepient: string, amount=1000n, inTokens=true) {153    return await this.helper.balance.transferToSubstrate(donor, evmToAddress(recepient), amount * (inTokens ? this.helper.balance.getOneTokenNominal() : 1n));154  }155  156  async getCollectionCreationFee(signer: string) {157    const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);158    return await collectionHelper.methods.collectionCreationFee().call();159  }160161  async sendEVM(signer: IKeyringPair, contractAddress: string, abi: string, value: string, gasLimit?: number) {162    if(!gasLimit) gasLimit = this.DEFAULT_GAS;163    const web3 = this.helper.getWeb3();164    const gasPrice = await web3.eth.getGasPrice();165    // TODO: check execution status166    await this.helper.executeExtrinsic(167      signer,168      'api.tx.evm.call', [this.helper.address.substrateToEth(signer.address), contractAddress, abi, value, gasLimit, gasPrice, null, null, []],169      true,170    );171  }172173  async callEVM(signer: TEthereumAccount, contractAddress: string, abi: string) {174    return await this.helper.callRpc('api.rpc.eth.call', [{from: signer, to: contractAddress, data: abi}]);175  }176177  async createNonfungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {178    const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();179    const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);180        181    const result = await collectionHelper.methods.createNonfungibleCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});182183    const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);184    const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);185186    return {collectionId, collectionAddress};187  }188189  async createRefungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {190    const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();191    const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);192        193    const result = await collectionHelper.methods.createRFTCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});194195    const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);196    const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);197198    return {collectionId, collectionAddress};199  }200201  async deployCollectorContract(signer: string): Promise<Contract> {202    return await this.helper.ethContract.deployByCode(signer, 'Collector', `203    // SPDX-License-Identifier: UNLICENSED204    pragma solidity ^0.8.6;205206    contract Collector {207      uint256 collected;208      fallback() external payable {209        giveMoney();210      }211      function giveMoney() public payable {212        collected += msg.value;213      }214      function getCollected() public view returns (uint256) {215        return collected;216      }217      function getUnaccounted() public view returns (uint256) {218        return address(this).balance - collected;219      }220221      function withdraw(address payable target) public {222        target.transfer(collected);223        collected = 0;224      }225    }226  `);227  }228229  async deployFlipper(signer: string): Promise<Contract> {230    return await this.helper.ethContract.deployByCode(signer, 'Flipper', `231    // SPDX-License-Identifier: UNLICENSED232    pragma solidity ^0.8.6;233234    contract Flipper {235      bool value = false;236      function flip() public {237        value = !value;238      }239      function getValue() public view returns (bool) {240        return value;241      }242    }243  `);244  }245246  async recordCallFee(user: string, call: () => Promise<any>): Promise<bigint> {247    const before = await this.helper.balance.getEthereum(user);248    await call();249    // In dev mode, the transaction might not finish processing in time250    await this.helper.wait.newBlocks(1);251    const after = await this.helper.balance.getEthereum(user);252253    return before - after;254  }255256  normalizeEvents(events: any): NormalizedEvent[] {257    const output = [];258    for (const key of Object.keys(events)) {259      if (key.match(/^[0-9]+$/)) {260        output.push(events[key]);261      } else if (Array.isArray(events[key])) {262        output.push(...events[key]);263      } else {264        output.push(events[key]);265      }266    }267    output.sort((a, b) => a.logIndex - b.logIndex);268    return output.map(({address, event, returnValues}) => {269      const args: { [key: string]: string } = {};270      for (const key of Object.keys(returnValues)) {271        if (!key.match(/^[0-9]+$/)) {272          args[key] = returnValues[key];273        }274      }275      return {276        address,277        event,278        args,279      };280    });281  }282283  async calculateFee(address: ICrossAccountId, code: () => Promise<any>): Promise<bigint> {284    const wrappedCode = async () => {285      await code();286      // In dev mode, the transaction might not finish processing in time287      await this.helper.wait.newBlocks(1);288    }289    return await this.helper.arrange.calculcateFee(address, code);290  }291}  292293class EthAddressGroup extends EthGroupBase {294  extractCollectionId(address: string): number {295    if (!(address.length === 42 || address.length === 40)) throw new Error('address wrong format');296    return parseInt(address.substr(address.length - 8), 16);297  }298299  fromCollectionId(collectionId: number): string {300    if (collectionId >= 0xffffffff || collectionId < 0) throw new Error('collectionId overflow');301    return Web3.utils.toChecksumAddress(`0x17c4e6453cc49aaaaeaca894e6d9683e${collectionId.toString(16).padStart(8, '0')}`);302  }303304  extractTokenId(address: string): {collectionId: number, tokenId: number} {305    if (!address.startsWith('0x'))306      throw 'address not starts with "0x"';307    if (address.length > 42)308      throw 'address length is more than 20 bytes';309    return {310      collectionId: Number('0x' + address.substring(address.length - 16, address.length - 8)),311      tokenId: Number('0x' + address.substring(address.length - 8)),312    };313  }314315  fromTokenId(collectionId: number, tokenId: number): string  {316    return this.helper.util.getTokenAddress({collectionId, tokenId});317  }318319  normalizeAddress(address: string): string {320    return '0x' + address.substring(address.length - 40);321  }322}  323 324325export class EthUniqueHelper extends DevUniqueHelper {326  web3: Web3 | null = null;327  web3Provider: WebsocketProvider | null = null;328329  eth: EthGroup;330  ethAddress: EthAddressGroup;331  ethNativeContract: NativeContractGroup;332  ethContract: ContractGroup;333334  constructor(logger: { log: (msg: any, level: any) => void, level: any }) {335    super(logger);336    this.eth = new EthGroup(this);337    this.ethAddress = new EthAddressGroup(this);338    this.ethNativeContract = new NativeContractGroup(this);339    this.ethContract = new ContractGroup(this);340  }341342  getWeb3(): Web3 {343    if(this.web3 === null) throw Error('Web3 not connected');344    return this.web3;345  }346347  async connectWeb3(wsEndpoint: string) {348    if(this.web3 !== null) return;349    this.web3Provider = new Web3.providers.WebsocketProvider(wsEndpoint);350    this.web3 = new Web3(this.web3Provider);351  }352353  async disconnectWeb3() {354    if(this.web3 === null) return;355    this.web3Provider?.connection.close();356    this.web3 = null;357  }358}359  
modifiedtests/src/inflation.test.tsdiffbeforeafterboth
--- a/tests/src/inflation.test.ts
+++ b/tests/src/inflation.test.ts
@@ -40,9 +40,9 @@
     const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);
     await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;
 
-    const blockInterval = (helper.api!.consts.inflation.inflationBlockInterval as any).toBigInt();
-    const totalIssuanceStart = ((await helper.api!.query.inflation.startingYearTotalIssuance()) as any).toBigInt();
-    const blockInflation = (await helper.api!.query.inflation.blockInflation() as any).toBigInt();
+    const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();
+    const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();
+    const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();
 
     const YEAR = 5259600n;  // 6-second block. Blocks in one year
     // const YEAR = 2629800n; // 12-second block. Blocks in one year
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -276,7 +276,7 @@
   
   itSub('Reads access rights to properties of a collection', async ({helper}) =>  {
     const collection = await helper.nft.mintCollection(alice);
-    const propertyRights = (await helper.api!.query.common.collectionPropertyPermissions(collection.collectionId)).toJSON();
+    const propertyRights = (await helper.callRpc('api.query.common.collectionPropertyPermissions', [collection.collectionId])).toJSON();
     expect(propertyRights).to.be.empty;
   });
   
@@ -817,7 +817,7 @@
       ).to.be.fulfilled;
     }
 
-    const originalSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
+    const originalSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
     return originalSpace;
   }
 
@@ -840,7 +840,7 @@
       ).to.be.rejectedWith(/common\.NoPermission/);
     }
 
-    const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
+    const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
     expect(consumedSpace).to.be.equal(originalSpace);
   }
 
@@ -875,7 +875,7 @@
       ).to.be.rejectedWith(/common\.NoPermission/);
     }
   
-    const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
+    const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
     expect(consumedSpace).to.be.equal(originalSpace);
   }
 
@@ -911,7 +911,7 @@
 
     expect(await token.getProperties(['non-existent', 'now-existent'])).to.be.empty;
       
-    const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
+    const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
     expect(consumedSpace).to.be.equal(originalSpace);
   }
 
@@ -951,7 +951,7 @@
     ])).to.be.rejectedWith(/common\.NoSpaceForProperty/);
   
     expect(await token.getProperties(['a_holy_book', 'young_years'])).to.be.empty;
-    const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
+    const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 
     expect(consumedSpace).to.be.equal(originalSpace);
   }
 
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -59,7 +59,7 @@
 describe('Pallet presence', () => {
   before(async () => {
     await usingPlaygrounds(async helper => {
-      const chain = await helper.api!.rpc.system.chain();
+      const chain = await helper.callRpc('api.rpc.system.chain', []);
 
       const refungible = 'refungible';
       const scheduler = 'scheduler';
modifiedtests/src/tx-version-presence.test.tsdiffbeforeafterboth
--- a/tests/src/tx-version-presence.test.ts
+++ b/tests/src/tx-version-presence.test.ts
@@ -22,7 +22,7 @@
 describe('TxVersion is present', () => {
   before(async () => {
     await usingPlaygrounds(async helper => {
-      metadata = await helper.api!.rpc.state.getMetadata();
+      metadata = await helper.callRpc('api.rpc.state.getMetadata', []);
     });
   });
 
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -215,8 +215,8 @@
   };
 
   isDevNode = async () => {
-    const block1 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(1));
-    const block2 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(2));
+    const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [1])]);
+    const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [2])]);
     const findCreationDate = async (block: any) => {
       const humanBlock = block.toHuman();
       let date;
@@ -259,7 +259,7 @@
   async newBlocks(blocksCount = 1): Promise<void> {
     // eslint-disable-next-line no-async-promise-executor
     const promise = new Promise<void>(async (resolve) => {
-      const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(() => {
+      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {
         if (blocksCount > 0) {
           blocksCount--;
         } else {
@@ -274,7 +274,7 @@
   async forParachainBlockNumber(blockNumber: bigint) {
     // eslint-disable-next-line no-async-promise-executor
     return new Promise<void>(async (resolve) => {
-      const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(async (data: any) => {
+      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {
         if (data.number.toNumber() >= blockNumber) {
           unsubscribe();
           resolve();
@@ -286,7 +286,7 @@
   async forRelayBlockNumber(blockNumber: bigint) {
     // eslint-disable-next-line no-async-promise-executor
     return new Promise<void>(async (resolve) => {
-      const unsubscribe = await this.helper.api!.query.parachainSystem.validationData(async (data: any) => {
+      const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {
         if (data.value.relayParentNumber.toNumber() >= blockNumber) {
           // @ts-ignore
           unsubscribe();
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1991,7 +1991,7 @@
    * @returns ss58Format, token decimals, and token symbol
    */
   getChainProperties(): IChainProperties {
-    const properties = (this.helper.api as any).registry.getChainProperties().toJSON();
+    const properties = (this.helper.getApi() as any).registry.getChainProperties().toJSON();
     return {
       ss58Format: properties.ss58Format.toJSON(),
       tokenDecimals: properties.tokenDecimals.toJSON(),
@@ -2034,7 +2034,7 @@
    * @returns number, account's nonce
    */
   async getNonce(address: TSubstrateAccount): Promise<number> {
-    return (await (this.helper.api as any).query.system.account(address)).nonce.toNumber();
+    return (await this.helper.callRpc('api.query.system.account', [address])).nonce.toNumber();
   }
 }