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

difftreelog

feat enrich playgrounds with xcm capability

Daniel Shiposha2022-10-10parent: #8d90cab.patch.diff
in: master

4 files changed

modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/index.ts
+++ b/tests/src/util/playgrounds/index.ts
@@ -7,16 +7,18 @@
 import {Context} from 'mocha';
 import config from '../../config';
 import '../../interfaces/augment-api-events';
-import {DevUniqueHelper, SilentLogger, SilentConsole} from './unique.dev';
+import {ChainHelperBase} from './unique';
+import {ILogger} from './types';
+import {DevUniqueHelper, SilentLogger, SilentConsole, DevMoonbeamHelper, DevMoonriverHelper, DevAcalaHelper, DevKaruraHelper, DevRelayHelper} from './unique.dev';
 
 chai.use(chaiAsPromised);
 export const expect = chai.expect;
 
-export async function usingPlaygrounds(code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>, url: string = config.substrateUrl) {
+async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string) => IKeyringPair) => Promise<void>) {
   const silentConsole = new SilentConsole();
   silentConsole.enable();
 
-  const helper = new DevUniqueHelper(new SilentLogger());
+  const helper = new helperType(new SilentLogger());
 
   try {
     await helper.connect(url);
@@ -30,8 +32,33 @@
   }
 }
 
-usingPlaygrounds.atUrl = (url: string, code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
-  return usingPlaygrounds(code, url);
+export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>, url: string = config.substrateUrl) => {
+  return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
+};
+
+// TODO specific type
+export const usingStatemintPlaygrounds = async (url: string, code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);
+};
+
+export const usingRelayPlaygrounds = async (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);
+};
+
+export const usingAcalaPlaygrounds = async (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);
+};
+
+export const usingKaruraPlaygrounds = async (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);
+};
+
+export const usingMoonbeamPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);
+};
+
+export const usingMoonriverPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+  return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);
 };
 
 export enum Pallets {
modifiedtests/src/util/playgrounds/types.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/types.ts
+++ b/tests/src/util/playgrounds/types.ts
@@ -179,8 +179,41 @@
   minimalBalance?: bigint,
 }
 
+export interface MoonbeamAssetInfo {
+  location: any,
+  metadata: {
+    name: string,
+    symbol: string,
+    decimals: number,
+    isFrozen: boolean,
+    minimalBalance: bigint,
+  },
+  existentialDeposit: bigint,
+  isSufficient: boolean,
+  unitsPerSecond: bigint,
+  numAssetsWeightHint: number,
+}
+
+export interface AcalaAssetMetadata {
+  name: string,
+  symbol: string,
+  decimals: number,
+  minimalBalance: bigint,
+}
+
+export interface DemocracyStandardAccountVote {
+  balance: bigint,
+  vote: {
+    aye: boolean,
+    conviction: number,
+  },
+}
+
 export type TSubstrateAccount = string;
 export type TEthereumAccount = string;
 export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';
 export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';
+export type TSiblingNetworkds = 'moonbeam' | 'moonriver' | 'acala' | 'karura' | 'westmint';
+export type TRelayNetworks = 'rococo' | 'westend';
+export type TNetworks = TUniqueNetworks | TSiblingNetworkds | TRelayNetworks;
 export type TSigner = IKeyringPair; // | 'string'
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
before · tests/src/util/playgrounds/unique.dev.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {mnemonicGenerate} from '@polkadot/util-crypto';5import {UniqueHelper} from './unique';6import {ApiPromise, WsProvider} from '@polkadot/api';7import * as defs from '../../interfaces/definitions';8import {IKeyringPair} from '@polkadot/types/types';9import {ICrossAccountId} from './types';1011export class SilentLogger {12  log(_msg: any, _level: any): void { }13  level = {14    ERROR: 'ERROR' as const,15    WARNING: 'WARNING' as const,16    INFO: 'INFO' as const,17  };18}1920export class SilentConsole {21  // TODO: Remove, this is temporary: Filter unneeded API output22  // (Jaco promised it will be removed in the next version)23  consoleErr: any;24  consoleLog: any;25  consoleWarn: any;2627  constructor() {28    this.consoleErr = console.error;29    this.consoleLog = console.log;30    this.consoleWarn = console.warn;31  }3233  enable() {  34    const outFn = (printer: any) => (...args: any[]) => {35      for (const arg of args) {36        if (typeof arg !== 'string')37          continue;38        if (arg.includes('1000:: Normal connection closure') || arg.includes('Not decorating unknown runtime apis:') || arg.includes('RPC methods not decorated:') || arg === 'Normal connection closure')39          return;40      }41      printer(...args);42    };43  44    console.error = outFn(this.consoleErr.bind(console));45    console.log = outFn(this.consoleLog.bind(console));46    console.warn = outFn(this.consoleWarn.bind(console));47  }4849  disable() {50    console.error = this.consoleErr;51    console.log = this.consoleLog;52    console.warn = this.consoleWarn;53  }54}555657export class DevUniqueHelper extends UniqueHelper {58  /**59   * Arrange methods for tests60   */61  arrange: ArrangeGroup;62  wait: WaitGroup;63  admin: AdminGroup;6465  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {66    options.helperBase = options.helperBase ?? DevUniqueHelper;6768    super(logger, options);69    this.arrange = new ArrangeGroup(this);70    this.wait = new WaitGroup(this);71    this.admin = new AdminGroup(this);72  }7374  async connect(wsEndpoint: string, _listeners?: any): Promise<void> {75    const wsProvider = new WsProvider(wsEndpoint);76    this.api = new ApiPromise({77      provider: wsProvider,78      signedExtensions: {79        ContractHelpers: {80          extrinsic: {},81          payload: {},82        },83        FakeTransactionFinalizer: {84          extrinsic: {},85          payload: {},86        },87      },88      rpc: {89        unique: defs.unique.rpc,90        appPromotion: defs.appPromotion.rpc,91        rmrk: defs.rmrk.rpc,92        eth: {93          feeHistory: {94            description: 'Dummy',95            params: [],96            type: 'u8',97          },98          maxPriorityFeePerGas: {99            description: 'Dummy',100            params: [],101            type: 'u8',102          },103        },104      },105    });106    await this.api.isReadyOrError;107    this.network = await UniqueHelper.detectNetwork(this.api);108  }109}110111class ArrangeGroup {112  helper: DevUniqueHelper;113114  constructor(helper: DevUniqueHelper) {115    this.helper = helper;116  }117118  /**119   * Generates accounts with the specified UNQ token balance 120   * @param balances balances for generated accounts. Each balance will be multiplied by the token nominal.121   * @param donor donor account for balances122   * @returns array of newly created accounts123   * @example const [acc1, acc2, acc3] = await createAccounts([0n, 10n, 20n], donor); 124   */125  createAccounts = async (balances: bigint[], donor: IKeyringPair): Promise<IKeyringPair[]> => {126    let nonce = await this.helper.chain.getNonce(donor.address);127    const wait = new WaitGroup(this.helper);128    const ss58Format = this.helper.chain.getChainProperties().ss58Format;129    const tokenNominal = this.helper.balance.getOneTokenNominal();130    const transactions = [];131    const accounts: IKeyringPair[] = [];132    for (const balance of balances) {133      const recipient = this.helper.util.fromSeed(mnemonicGenerate(), ss58Format);134      accounts.push(recipient);135      if (balance !== 0n) {136        const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recipient.address}, balance * tokenNominal]);137        transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));138        nonce++;139      }140    }141142    await Promise.all(transactions).catch(_e => {});143    144    //#region TODO remove this region, when nonce problem will be solved145    const checkBalances = async () => {146      let isSuccess = true;147      for (let i = 0; i < balances.length; i++) {148        const balance = await this.helper.balance.getSubstrate(accounts[i].address);149        if (balance !== balances[i] * tokenNominal) {150          isSuccess = false;151          break;152        }153      }154      return isSuccess;155    };156157    let accountsCreated = false;158    // checkBalances retry up to 5 blocks159    for (let index = 0; index < 5; index++) {160      accountsCreated = await checkBalances();161      if(accountsCreated) break;162      await wait.newBlocks(1);163    }164165    if (!accountsCreated) throw Error('Accounts generation failed');166    //#endregion167168    return accounts;169  };170171  // TODO combine this method and createAccounts into one172  createCrowd = async (accountsToCreate: number, withBalance: bigint, donor: IKeyringPair): Promise<IKeyringPair[]> => {  173    const createAsManyAsCan = async () => {174      let transactions: any = [];175      const accounts: IKeyringPair[] = [];176      let nonce = await this.helper.chain.getNonce(donor.address);177      const tokenNominal = this.helper.balance.getOneTokenNominal();178      for (let i = 0; i < accountsToCreate; i++) {179        if (i === 500) { // if there are too many accounts to create180          await Promise.allSettled(transactions); // wait while first 500 (should be 100 for devnode) tx will be settled 181          transactions = []; //182          nonce = await this.helper.chain.getNonce(donor.address); // update nonce 183        }184        const recepient = this.helper.util.fromSeed(mnemonicGenerate());185        accounts.push(recepient);186        if (withBalance !== 0n) {187          const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recepient.address}, withBalance * tokenNominal]);188          transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));189          nonce++;190        }191      }192      193      const fullfilledAccounts = [];194      await Promise.allSettled(transactions);195      for (const account of accounts) {196        const accountBalance = await this.helper.balance.getSubstrate(account.address);197        if (accountBalance === withBalance * tokenNominal) {198          fullfilledAccounts.push(account);199        }200      }201      return fullfilledAccounts;202    };203204    205    const crowd: IKeyringPair[] = [];206    // do up to 5 retries207    for (let index = 0; index < 5 && accountsToCreate !== 0; index++) {208      const asManyAsCan = await createAsManyAsCan();209      crowd.push(...asManyAsCan);210      accountsToCreate -= asManyAsCan.length;211    }212213    if (accountsToCreate !== 0) throw Error(`Crowd generation failed: ${accountsToCreate} accounts left`);214215    return crowd;216  };217218  isDevNode = async () => {219    const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [1])]);220    const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [2])]);221    const findCreationDate = async (block: any) => {222      const humanBlock = block.toHuman();223      let date;224      humanBlock.block.extrinsics.forEach((ext: any) => {225        if(ext.method.section === 'timestamp') {226          date = Number(ext.method.args.now.replaceAll(',', ''));227        }228      });229      return date;230    };231    const block1date = await findCreationDate(block1);232    const block2date = await findCreationDate(block2);233    if(block2date! - block1date! < 9000) return true;234  };235  236  async calculcateFee(payer: ICrossAccountId, promise: () => Promise<any>): Promise<bigint> {237    const address = payer.Substrate ? payer.Substrate : await this.helper.address.ethToSubstrate(payer.Ethereum!);238    let balance = await this.helper.balance.getSubstrate(address); 239    240    await promise();241    242    balance -= await this.helper.balance.getSubstrate(address);243    244    return balance;245  }246}247248class WaitGroup {249  helper: DevUniqueHelper;250251  constructor(helper: DevUniqueHelper) {252    this.helper = helper;253  }254255  /**256   * Wait for specified number of blocks257   * @param blocksCount number of blocks to wait258   * @returns 259   */260  async newBlocks(blocksCount = 1): Promise<void> {261    // eslint-disable-next-line no-async-promise-executor262    const promise = new Promise<void>(async (resolve) => {263      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {264        if (blocksCount > 0) {265          blocksCount--;266        } else {267          unsubscribe();268          resolve();269        }270      });271    });272    return promise;273  }274275  async forParachainBlockNumber(blockNumber: bigint) {276    // eslint-disable-next-line no-async-promise-executor277    return new Promise<void>(async (resolve) => {278      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {279        if (data.number.toNumber() >= blockNumber) {280          unsubscribe();281          resolve();282        }283      });284    });285  }286  287  async forRelayBlockNumber(blockNumber: bigint) {288    // eslint-disable-next-line no-async-promise-executor289    return new Promise<void>(async (resolve) => {290      const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {291        if (data.value.relayParentNumber.toNumber() >= blockNumber) {292          // @ts-ignore293          unsubscribe();294          resolve();295        }296      });297    });298  }299}300301class AdminGroup {302  helper: UniqueHelper;303304  constructor(helper: UniqueHelper) {305    this.helper = helper;306  }307308  async payoutStakers(signer: IKeyringPair, stakersToPayout: number) {309    const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);310    return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => {311      return {312        staker: e.event.data[0].toString(),313        stake: e.event.data[1].toBigInt(),314        payout: e.event.data[2].toBigInt(),315      };316    });317  }318}
after · tests/src/util/playgrounds/unique.dev.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {mnemonicGenerate} from '@polkadot/util-crypto';5import {UniqueHelper, MoonbeamHelper, ChainHelperBase, AcalaHelper, RelayHelper} from './unique';6import {ApiPromise, Keyring, WsProvider} from '@polkadot/api';7import * as defs from '../../interfaces/definitions';8import {IKeyringPair} from '@polkadot/types/types';9import {EventRecord} from '@polkadot/types/interfaces';10import {ICrossAccountId} from './types';1112export class SilentLogger {13  log(_msg: any, _level: any): void { }14  level = {15    ERROR: 'ERROR' as const,16    WARNING: 'WARNING' as const,17    INFO: 'INFO' as const,18  };19}2021export class SilentConsole {22  // TODO: Remove, this is temporary: Filter unneeded API output23  // (Jaco promised it will be removed in the next version)24  consoleErr: any;25  consoleLog: any;26  consoleWarn: any;2728  constructor() {29    this.consoleErr = console.error;30    this.consoleLog = console.log;31    this.consoleWarn = console.warn;32  }3334  enable() {  35    const outFn = (printer: any) => (...args: any[]) => {36      for (const arg of args) {37        if (typeof arg !== 'string')38          continue;39        if (arg.includes('1000:: Normal connection closure') || arg.includes('Not decorating unknown runtime apis:') || arg.includes('RPC methods not decorated:') || arg === 'Normal connection closure')40          return;41      }42      printer(...args);43    };44  45    console.error = outFn(this.consoleErr.bind(console));46    console.log = outFn(this.consoleLog.bind(console));47    console.warn = outFn(this.consoleWarn.bind(console));48  }4950  disable() {51    console.error = this.consoleErr;52    console.log = this.consoleLog;53    console.warn = this.consoleWarn;54  }55}5657export class DevUniqueHelper extends UniqueHelper {58  /**59   * Arrange methods for tests60   */61  arrange: ArrangeGroup;62  wait: WaitGroup;63  admin: AdminGroup;6465  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {66    options.helperBase = options.helperBase ?? DevUniqueHelper;6768    super(logger, options);69    this.arrange = new ArrangeGroup(this);70    this.wait = new WaitGroup(this);71    this.admin = new AdminGroup(this);72  }7374  async connect(wsEndpoint: string, _listeners?: any): Promise<void> {75    const wsProvider = new WsProvider(wsEndpoint);76    this.api = new ApiPromise({77      provider: wsProvider,78      signedExtensions: {79        ContractHelpers: {80          extrinsic: {},81          payload: {},82        },83        FakeTransactionFinalizer: {84          extrinsic: {},85          payload: {},86        },87      },88      rpc: {89        unique: defs.unique.rpc,90        appPromotion: defs.appPromotion.rpc,91        rmrk: defs.rmrk.rpc,92        eth: {93          feeHistory: {94            description: 'Dummy',95            params: [],96            type: 'u8',97          },98          maxPriorityFeePerGas: {99            description: 'Dummy',100            params: [],101            type: 'u8',102          },103        },104      },105    });106    await this.api.isReadyOrError;107    this.network = await UniqueHelper.detectNetwork(this.api);108  }109}110111export class DevRelayHelper extends RelayHelper {}112113export class DevMoonbeamHelper extends MoonbeamHelper {114  account: MoonbeamAccountGroup;115  wait: WaitGroup;116117  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {118    options.helperBase = options.helperBase ?? DevMoonbeamHelper;119120    super(logger, options);121    this.account = new MoonbeamAccountGroup(this);122    this.wait = new WaitGroup(this);123  }124}125126export class DevMoonriverHelper extends DevMoonbeamHelper {}127128export class DevAcalaHelper extends AcalaHelper {129  wait: WaitGroup;130131  constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {132    options.helperBase = options.helperBase ?? DevAcalaHelper;133134    super(logger, options);135    this.wait = new WaitGroup(this);136  }137}138139export class DevKaruraHelper extends DevAcalaHelper {}140141class ArrangeGroup {142  helper: DevUniqueHelper;143144  constructor(helper: DevUniqueHelper) {145    this.helper = helper;146  }147148  /**149   * Generates accounts with the specified UNQ token balance 150   * @param balances balances for generated accounts. Each balance will be multiplied by the token nominal.151   * @param donor donor account for balances152   * @returns array of newly created accounts153   * @example const [acc1, acc2, acc3] = await createAccounts([0n, 10n, 20n], donor); 154   */155  createAccounts = async (balances: bigint[], donor: IKeyringPair): Promise<IKeyringPair[]> => {156    let nonce = await this.helper.chain.getNonce(donor.address);157    const wait = new WaitGroup(this.helper);158    const ss58Format = this.helper.chain.getChainProperties().ss58Format;159    const tokenNominal = this.helper.balance.getOneTokenNominal();160    const transactions = [];161    const accounts: IKeyringPair[] = [];162    for (const balance of balances) {163      const recipient = this.helper.util.fromSeed(mnemonicGenerate(), ss58Format);164      accounts.push(recipient);165      if (balance !== 0n) {166        const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recipient.address}, balance * tokenNominal]);167        transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));168        nonce++;169      }170    }171172    await Promise.all(transactions).catch(_e => {});173    174    //#region TODO remove this region, when nonce problem will be solved175    const checkBalances = async () => {176      let isSuccess = true;177      for (let i = 0; i < balances.length; i++) {178        const balance = await this.helper.balance.getSubstrate(accounts[i].address);179        if (balance !== balances[i] * tokenNominal) {180          isSuccess = false;181          break;182        }183      }184      return isSuccess;185    };186187    let accountsCreated = false;188    // checkBalances retry up to 5 blocks189    for (let index = 0; index < 5; index++) {190      accountsCreated = await checkBalances();191      if(accountsCreated) break;192      await wait.newBlocks(1);193    }194195    if (!accountsCreated) throw Error('Accounts generation failed');196    //#endregion197198    return accounts;199  };200201  // TODO combine this method and createAccounts into one202  createCrowd = async (accountsToCreate: number, withBalance: bigint, donor: IKeyringPair): Promise<IKeyringPair[]> => {  203    const createAsManyAsCan = async () => {204      let transactions: any = [];205      const accounts: IKeyringPair[] = [];206      let nonce = await this.helper.chain.getNonce(donor.address);207      const tokenNominal = this.helper.balance.getOneTokenNominal();208      for (let i = 0; i < accountsToCreate; i++) {209        if (i === 500) { // if there are too many accounts to create210          await Promise.allSettled(transactions); // wait while first 500 (should be 100 for devnode) tx will be settled 211          transactions = []; //212          nonce = await this.helper.chain.getNonce(donor.address); // update nonce 213        }214        const recepient = this.helper.util.fromSeed(mnemonicGenerate());215        accounts.push(recepient);216        if (withBalance !== 0n) {217          const tx = this.helper.constructApiCall('api.tx.balances.transfer', [{Id: recepient.address}, withBalance * tokenNominal]);218          transactions.push(this.helper.signTransaction(donor, tx, {nonce}, 'account generation'));219          nonce++;220        }221      }222      223      const fullfilledAccounts = [];224      await Promise.allSettled(transactions);225      for (const account of accounts) {226        const accountBalance = await this.helper.balance.getSubstrate(account.address);227        if (accountBalance === withBalance * tokenNominal) {228          fullfilledAccounts.push(account);229        }230      }231      return fullfilledAccounts;232    };233234    235    const crowd: IKeyringPair[] = [];236    // do up to 5 retries237    for (let index = 0; index < 5 && accountsToCreate !== 0; index++) {238      const asManyAsCan = await createAsManyAsCan();239      crowd.push(...asManyAsCan);240      accountsToCreate -= asManyAsCan.length;241    }242243    if (accountsToCreate !== 0) throw Error(`Crowd generation failed: ${accountsToCreate} accounts left`);244245    return crowd;246  };247248  isDevNode = async () => {249    const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [1])]);250    const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [2])]);251    const findCreationDate = async (block: any) => {252      const humanBlock = block.toHuman();253      let date;254      humanBlock.block.extrinsics.forEach((ext: any) => {255        if(ext.method.section === 'timestamp') {256          date = Number(ext.method.args.now.replaceAll(',', ''));257        }258      });259      return date;260    };261    const block1date = await findCreationDate(block1);262    const block2date = await findCreationDate(block2);263    if(block2date! - block1date! < 9000) return true;264  };265  266  async calculcateFee(payer: ICrossAccountId, promise: () => Promise<any>): Promise<bigint> {267    const address = payer.Substrate ? payer.Substrate : await this.helper.address.ethToSubstrate(payer.Ethereum!);268    let balance = await this.helper.balance.getSubstrate(address); 269    270    await promise();271    272    balance -= await this.helper.balance.getSubstrate(address);273    274    return balance;275  }276}277278class MoonbeamAccountGroup {279  helper: MoonbeamHelper;280281  _alithAccount: IKeyringPair;282  _baltatharAccount: IKeyringPair;283  _dorothyAccount: IKeyringPair;284285  constructor(helper: MoonbeamHelper) {286    this.helper = helper;287288    const keyring = new Keyring({type: 'ethereum'});289    const alithPrivateKey = '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133';290    const baltatharPrivateKey = '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b';291    const dorothyPrivateKey = '0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68';292293    this._alithAccount = keyring.addFromUri(alithPrivateKey, undefined, 'ethereum');294    this._baltatharAccount = keyring.addFromUri(baltatharPrivateKey, undefined, 'ethereum');295    this._dorothyAccount = keyring.addFromUri(dorothyPrivateKey, undefined, 'ethereum');296  }297298  alithAccount() {299    return this._alithAccount;300  }301302  baltatharAccount() {303    return this._baltatharAccount;304  }305306  dorothyAccount() {307    return this._dorothyAccount;308  }309}310311class WaitGroup {312  helper: ChainHelperBase;313314  constructor(helper: ChainHelperBase) {315    this.helper = helper;316  }317318  /**319   * Wait for specified number of blocks320   * @param blocksCount number of blocks to wait321   * @returns 322   */323  async newBlocks(blocksCount = 1): Promise<void> {324    // eslint-disable-next-line no-async-promise-executor325    const promise = new Promise<void>(async (resolve) => {326      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {327        if (blocksCount > 0) {328          blocksCount--;329        } else {330          unsubscribe();331          resolve();332        }333      });334    });335    return promise;336  }337338  async forParachainBlockNumber(blockNumber: bigint) {339    // eslint-disable-next-line no-async-promise-executor340    return new Promise<void>(async (resolve) => {341      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {342        if (data.number.toNumber() >= blockNumber) {343          unsubscribe();344          resolve();345        }346      });347    });348  }349  350  async forRelayBlockNumber(blockNumber: bigint) {351    // eslint-disable-next-line no-async-promise-executor352    return new Promise<void>(async (resolve) => {353      const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {354        if (data.value.relayParentNumber.toNumber() >= blockNumber) {355          // @ts-ignore356          unsubscribe();357          resolve();358        }359      });360    });361  }362363  async event(maxBlocksToWait: number, eventSection: string, eventMethod: string) {364    // eslint-disable-next-line no-async-promise-executor365    const promise = new Promise<EventRecord | null>(async (resolve) => {366      const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async header => {367        const blockNumber = header.number.toHuman();368        const blockHash = header.hash;369        const eventIdStr = `${eventSection}.${eventMethod}`;370        const waitLimitStr = `wait blocks remaining: ${maxBlocksToWait}`;371  372        console.log(`[Block #${blockNumber}] Waiting for event \`${eventIdStr}\` (${waitLimitStr})`);373  374        const apiAt = await this.helper.getApi().at(blockHash);375        const eventRecords = await apiAt.query.system.events();376  377        const neededEvent = eventRecords.find(r => {378          return r.event.section == eventSection && r.event.method == eventMethod;379        });380  381        if (neededEvent) {382          unsubscribe();383          resolve(neededEvent);384        } else if (maxBlocksToWait > 0) {385          maxBlocksToWait--;386        } else {387          console.log(`Event \`${eventIdStr}\` is NOT found`);388  389          unsubscribe();390          resolve(null);391        }392      });393    });394    return promise;395  }396}397398class AdminGroup {399  helper: UniqueHelper;400401  constructor(helper: UniqueHelper) {402    this.helper = helper;403  }404405  async payoutStakers(signer: IKeyringPair, stakersToPayout: number) {406    const payoutResult = await this.helper.executeExtrinsic(signer, 'api.tx.appPromotion.payoutStakers', [stakersToPayout], true);407    return payoutResult.result.events.filter(e => e.event.method === 'StakingRecalculation').map(e => {408      return {409        staker: e.event.data[0].toString(),410        stake: e.event.data[1].toBigInt(),411        payout: e.event.data[2].toBigInt(),412      };413    });414  }415}
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -9,7 +9,7 @@
 import {ApiInterfaceEvents, SignerOptions} from '@polkadot/api/types';
 import {encodeAddress, decodeAddress, keccakAsHex, evmToAddress, addressToEvm} from '@polkadot/util-crypto';
 import {IKeyringPair} from '@polkadot/types/types';
-import {IApiListeners, IBlock, IEvent, IChainProperties, ICollectionCreationOptions, ICollectionLimits, ICollectionPermissions, ICrossAccountId, ICrossAccountIdLower, ILogger, INestingPermissions, IProperty, IStakingInfo, ISchedulerOptions, ISubstrateBalance, IToken, ITokenPropertyPermission, ITransactionResult, IUniqueHelperLog, TApiAllowedListeners, TEthereumAccount, TSigner, TSubstrateAccount, TUniqueNetworks, IForeignAssetMetadata} from './types';
+import {IApiListeners, IBlock, IEvent, IChainProperties, ICollectionCreationOptions, ICollectionLimits, ICollectionPermissions, ICrossAccountId, ICrossAccountIdLower, ILogger, INestingPermissions, IProperty, IStakingInfo, ISchedulerOptions, ISubstrateBalance, IToken, ITokenPropertyPermission, ITransactionResult, IUniqueHelperLog, TApiAllowedListeners, TEthereumAccount, TSigner, TSubstrateAccount, IForeignAssetMetadata, TNetworks, MoonbeamAssetInfo, DemocracyStandardAccountVote, AcalaAssetMetadata} from './types';
 
 export class CrossAccountId implements ICrossAccountId {
   Substrate?: TSubstrateAccount;
@@ -308,19 +308,25 @@
   }
 }
 
-class ChainHelperBase {
+export class ChainHelperBase {
+  helperBase: any;
+
   transactionStatus = UniqueUtil.transactionStatus;
   chainLogType = UniqueUtil.chainLogType;
   util: typeof UniqueUtil;
   eventHelper: typeof UniqueEventHelper;
   logger: ILogger;
   api: ApiPromise | null;
-  forcedNetwork: TUniqueNetworks | null;
-  network: TUniqueNetworks | null;
+  forcedNetwork: TNetworks | null;
+  network: TNetworks | null;
   chainLog: IUniqueHelperLog[];
   children: ChainHelperBase[];
+  address: AddressGroup;
+  chain: ChainGroup;
+
+  constructor(logger?: ILogger, helperBase?: any) {
+    this.helperBase = helperBase;
 
-  constructor(logger?: ILogger) {
     this.util = UniqueUtil;
     this.eventHelper = UniqueEventHelper;
     if (typeof logger == 'undefined') logger = this.util.getDefaultLogger();
@@ -330,6 +336,21 @@
     this.network = null;
     this.chainLog = [];
     this.children = [];
+    this.address = new AddressGroup(this);
+    this.chain = new ChainGroup(this);
+  }
+
+  clone(helperCls: ChainHelperBaseConstructor, options: {[key: string]: any} = {}) {
+    Object.setPrototypeOf(helperCls.prototype, this);
+    const newHelper = new helperCls(this.logger, options);
+
+    newHelper.api = this.api;
+    newHelper.network = this.network;
+    newHelper.forceNetwork = this.forceNetwork;
+
+    this.children.push(newHelper);
+
+    return newHelper;
   }
 
   getApi(): ApiPromise {
@@ -341,7 +362,7 @@
     this.chainLog = [];
   }
 
-  forceNetwork(value: TUniqueNetworks): void {
+  forceNetwork(value: TNetworks): void {
     this.forcedNetwork = value;
   }
 
@@ -367,13 +388,17 @@
     this.network = null;
   }
 
-  static async detectNetwork(api: ApiPromise): Promise<TUniqueNetworks> {
+  static async detectNetwork(api: ApiPromise): Promise<TNetworks> {
     const spec = (await api.query.system.lastRuntimeUpgrade()).toJSON() as any;
+    const xcmChains = ['rococo', 'westend', 'westmint', 'acala', 'karura', 'moonbeam', 'moonriver'];
+
+    if(xcmChains.indexOf(spec.specName) > -1) return spec.specName;
+
     if(['quartz', 'unique'].indexOf(spec.specName) > -1) return spec.specName;
     return 'opal';
   }
 
-  static async detectNetworkByWsEndpoint(wsEndpoint: string): Promise<TUniqueNetworks> {
+  static async detectNetworkByWsEndpoint(wsEndpoint: string): Promise<TNetworks> {
     const api = new ApiPromise({provider: new WsProvider(wsEndpoint)});
     await api.isReady;
 
@@ -384,10 +409,11 @@
     return network;
   }
 
-  static async createConnection(wsEndpoint: string, listeners?: IApiListeners, network?: TUniqueNetworks | null): Promise<{
+  static async createConnection(wsEndpoint: string, listeners?: IApiListeners, network?: TNetworks | null): Promise<{
     api: ApiPromise;
-    network: TUniqueNetworks;
+    network: TNetworks;
   }> {
+    console.log('createConnection network = ', network);
     if(typeof network === 'undefined' || network === null) network = 'opal';
     const supportedRPC = {
       opal: {
@@ -399,6 +425,13 @@
       unique: {
         unique: require('@unique-nft/unique-mainnet-types/definitions').unique.rpc,
       },
+      rococo: {},
+      westend: {},
+      moonbeam: {},
+      moonriver: {},
+      acala: {},
+      karura: {},
+      westmint: {},
     };
     if(!supportedRPC.hasOwnProperty(network)) network = await this.detectNetworkByWsEndpoint(wsEndpoint);
     const rpc = supportedRPC[network];
@@ -590,16 +623,16 @@
 }
 
 
-class HelperGroup {
-  helper: UniqueHelper;
+class HelperGroup<T extends ChainHelperBase> {
+  helper: T;
 
-  constructor(uniqueHelper: UniqueHelper) {
+  constructor(uniqueHelper: T) {
     this.helper = uniqueHelper;
   }
 }
 
 
-class CollectionGroup extends HelperGroup {
+class CollectionGroup extends HelperGroup<UniqueHelper> {
   /**
  * Get number of blocks when sponsored transaction is available.
  *
@@ -2000,7 +2033,7 @@
 }
 
 
-class ChainGroup extends HelperGroup {
+class ChainGroup extends HelperGroup<ChainHelperBase> {
   /**
    * Get system properties of a chain
    * @example getChainProperties();
@@ -2054,10 +2087,106 @@
   }
 }
 
+class SubstrateBalanceGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+  /**
+ * Get substrate address balance
+ * @param address substrate address
+ * @example getSubstrate("5GrwvaEF5zXb26Fz...")
+ * @returns amount of tokens on address
+ */
+  async getSubstrate(address: TSubstrateAccount): Promise<bigint> {
+    return (await this.helper.callRpc('api.query.system.account', [address])).data.free.toBigInt();
+  }
+
+  /**
+   * Transfer tokens to substrate address
+   * @param signer keyring of signer
+   * @param address substrate address of a recipient
+   * @param amount amount of tokens to be transfered
+   * @example transferToSubstrate(aliceKeyring, "5GrwvaEF5zXb26Fz...", 100_000_000_000n);
+   * @returns ```true``` if extrinsic success, otherwise ```false```
+   */
+  async transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {
+    const result = await this.helper.executeExtrinsic(signer, 'api.tx.balances.transfer', [address, amount], true/*, `Unable to transfer balance from ${this.helper.getSignerAddress(signer)} to ${address}`*/);
+
+    let transfer = {from: null, to: null, amount: 0n} as any;
+    result.result.events.forEach(({event: {data, method, section}}) => {
+      if ((section === 'balances') && (method === 'Transfer')) {
+        transfer = {
+          from: this.helper.address.normalizeSubstrate(data[0]),
+          to: this.helper.address.normalizeSubstrate(data[1]),
+          amount: BigInt(data[2]),
+        };
+      }
+    });
+    const isSuccess = this.helper.address.normalizeSubstrate(typeof signer === 'string' ? signer : signer.address) === transfer.from 
+      && this.helper.address.normalizeSubstrate(address) === transfer.to 
+      && BigInt(amount) === transfer.amount;
+    return isSuccess;
+  }
+
+  /**
+   * Get full substrate balance including free, miscFrozen, feeFrozen, and reserved
+   * @param address substrate address
+   * @returns
+   */
+  async getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {
+    const accountInfo = (await this.helper.callRpc('api.query.system.account', [address])).data;
+    return {free: accountInfo.free.toBigInt(), miscFrozen: accountInfo.miscFrozen.toBigInt(), feeFrozen: accountInfo.feeFrozen.toBigInt(), reserved: accountInfo.reserved.toBigInt()};
+  }
+}
+
+class EthereumBalanceGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+  /**
+   * Get ethereum address balance
+   * @param address ethereum address
+   * @example getEthereum("0x9F0583DbB855d...")
+   * @returns amount of tokens on address
+   */
+  async getEthereum(address: TEthereumAccount): Promise<bigint> {
+    return (await this.helper.callRpc('api.rpc.eth.getBalance', [address])).toBigInt();
+  }
+
+  /**
+   * Transfer tokens to address
+   * @param signer keyring of signer
+   * @param address Ethereum address of a recipient
+   * @param amount amount of tokens to be transfered
+   * @example transferToEthereum(alithKeyring, "0x9F0583DbB855d...", 100_000_000_000n);
+   * @returns ```true``` if extrinsic success, otherwise ```false```
+   */
+  async transferToEthereum(signer: TSigner, address: TEthereumAccount, amount: bigint | string): Promise<boolean> {
+    const result = await this.helper.executeExtrinsic(signer, 'api.tx.balances.transfer', [address, amount], true);
+
+    let transfer = {from: null, to: null, amount: 0n} as any;
+    result.result.events.forEach(({event: {data, method, section}}) => {
+      if ((section === 'balances') && (method === 'Transfer')) {
+        transfer = {
+          from: data[0].toString(),
+          to: data[1].toString(),
+          amount: BigInt(data[2]),
+        };
+      }
+    });
+    const isSuccess = (typeof signer === 'string' ? signer : signer.address) === transfer.from 
+      && address === transfer.to 
+      && BigInt(amount) === transfer.amount;
+    return isSuccess;
+  }
+}
+
+class BalanceGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+  subBalanceGroup: SubstrateBalanceGroup<T>;
+  ethBalanceGroup: EthereumBalanceGroup<T>;
+
+  constructor(helper: T) {
+    super(helper);
+    this.subBalanceGroup = new SubstrateBalanceGroup(helper);
+    this.ethBalanceGroup = new EthereumBalanceGroup(helper);
+  }
 
-class BalanceGroup extends HelperGroup {
   getCollectionCreationPrice(): bigint {
-    return 2n * this.helper.balance.getOneTokenNominal();
+    return 2n * this.getOneTokenNominal();
   }
   /**
    * Representation of the native token in the smallest unit - one OPAL (OPL), QUARTZ (QTZ), or UNIQUE (UNQ).
@@ -2076,7 +2205,7 @@
    * @returns amount of tokens on address
    */
   async getSubstrate(address: TSubstrateAccount): Promise<bigint> {
-    return (await this.helper.callRpc('api.query.system.account', [address])).data.free.toBigInt();
+    return this.subBalanceGroup.getSubstrate(address);
   }
 
   /**
@@ -2085,8 +2214,7 @@
    * @returns
    */
   async getSubstrateFull(address: TSubstrateAccount): Promise<ISubstrateBalance> {
-    const accountInfo = (await this.helper.callRpc('api.query.system.account', [address])).data;
-    return {free: accountInfo.free.toBigInt(), miscFrozen: accountInfo.miscFrozen.toBigInt(), feeFrozen: accountInfo.feeFrozen.toBigInt(), reserved: accountInfo.reserved.toBigInt()};
+    return this.subBalanceGroup.getSubstrateFull(address);
   }
 
   /**
@@ -2096,7 +2224,7 @@
    * @returns amount of tokens on address
    */
   async getEthereum(address: TEthereumAccount): Promise<bigint> {
-    return (await this.helper.callRpc('api.rpc.eth.getBalance', [address])).toBigInt();
+    return this.ethBalanceGroup.getEthereum(address);
   }
 
   /**
@@ -2108,27 +2236,11 @@
    * @returns ```true``` if extrinsic success, otherwise ```false```
    */
   async transferToSubstrate(signer: TSigner, address: TSubstrateAccount, amount: bigint | string): Promise<boolean> {
-    const result = await this.helper.executeExtrinsic(signer, 'api.tx.balances.transfer', [address, amount], true/*, `Unable to transfer balance from ${this.helper.getSignerAddress(signer)} to ${address}`*/);
-
-    let transfer = {from: null, to: null, amount: 0n} as any;
-    result.result.events.forEach(({event: {data, method, section}}) => {
-      if ((section === 'balances') && (method === 'Transfer')) {
-        transfer = {
-          from: this.helper.address.normalizeSubstrate(data[0]),
-          to: this.helper.address.normalizeSubstrate(data[1]),
-          amount: BigInt(data[2]),
-        };
-      }
-    });
-    const isSuccess = this.helper.address.normalizeSubstrate(typeof signer === 'string' ? signer : signer.address) === transfer.from 
-      && this.helper.address.normalizeSubstrate(address) === transfer.to 
-      && BigInt(amount) === transfer.amount;
-    return isSuccess;
+    return this.subBalanceGroup.transferToSubstrate(signer, address, amount);
   }
 }
-
 
-class AddressGroup extends HelperGroup {
+class AddressGroup extends HelperGroup<ChainHelperBase> {
   /**
    * Normalizes the address to the specified ss58 format, by default ```42```.
    * @param address substrate address
@@ -2172,7 +2284,7 @@
   }
 }
 
-class StakingGroup extends HelperGroup {
+class StakingGroup extends HelperGroup<UniqueHelper> {
   /**
    * Stake tokens for App Promotion
    * @param signer keyring of signer
@@ -2258,7 +2370,7 @@
   }
 }
 
-class SchedulerGroup extends HelperGroup {
+class SchedulerGroup extends HelperGroup<UniqueHelper> {
   constructor(helper: UniqueHelper) {
     super(helper);
   }
@@ -2314,11 +2426,7 @@
   }
 }
 
-class ForeignAssetsGroup extends HelperGroup {
-  constructor(helper: UniqueHelper) {
-    super(helper);
-  }
-
+class ForeignAssetsGroup extends HelperGroup<UniqueHelper> {
   async register(signer: TSigner, ownerAddress: TSubstrateAccount, location: any, metadata: IForeignAssetMetadata) {
     await this.helper.executeExtrinsic(
       signer,
@@ -2338,14 +2446,130 @@
   }
 }
 
+class XcmGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+  palletName: string;
+
+  constructor(helper: T, palletName: string) {
+    super(helper);
+
+    this.palletName = palletName;
+  }
+
+  async limitedReserveTransferAssets(signer: TSigner, destination: any, beneficiary: any, assets: any, feeAssetItem: number, weightLimit: number) {
+    await this.helper.executeExtrinsic(signer, `api.tx.${this.palletName}.limitedReserveTransferAssets`, [destination, beneficiary, assets, feeAssetItem, {Limited: weightLimit}], true);
+  }
+}
+
+class XTokensGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+  async transfer(signer: TSigner, currencyId: any, amount: bigint, destination: any, destWeight: number) {
+    await this.helper.executeExtrinsic(signer, 'api.tx.xTokens.transfer', [currencyId, amount, destination, destWeight], true);
+  }
+
+  async transferMultiasset(signer: TSigner, asset: any, destination: any, destWeight: number) {
+    await this.helper.executeExtrinsic(signer, 'api.tx.xTokens.transferMultiasset', [asset, destination, destWeight], true);
+  }
+}
+
+class TokensGroup<T extends ChainHelperBase> extends HelperGroup<T> {
+  async accounts(address: string, currencyId: any) {
+    const {free} = (await this.helper.callRpc('api.query.tokens.accounts', [address, currencyId])).toJSON() as any;
+    return BigInt(free);
+  }
+}
+
+class AcalaAssetRegistryGroup extends HelperGroup<AcalaHelper> {
+  async registerForeignAsset(signer: TSigner, destination: any, metadata: AcalaAssetMetadata) {
+    await this.helper.executeExtrinsic(signer, 'api.tx.assetRegistry.registerForeignAsset', [destination, metadata], true);
+  }
+}
+
+class MoonbeamAssetManagerGroup extends HelperGroup<MoonbeamHelper> {
+  makeRegisterForeignAssetProposal(assetInfo: MoonbeamAssetInfo) {
+    const apiPrefix = 'api.tx.assetManager.';
+
+    const registerTx = this.helper.constructApiCall(
+      apiPrefix + 'registerForeignAsset',
+      [assetInfo.location, assetInfo.metadata, assetInfo.existentialDeposit, assetInfo.isSufficient],
+    );
+
+    const setUnitsTx = this.helper.constructApiCall(
+      apiPrefix + 'setAssetUnitsPerSecond',
+      [assetInfo.location, assetInfo.unitsPerSecond, assetInfo.numAssetsWeightHint],
+    );
+
+    const batchCall = this.helper.getApi().tx.utility.batchAll([registerTx, setUnitsTx]);
+    const encodedProposal = batchCall?.method.toHex() || '';
+    return encodedProposal;
+  }
+
+  async assetTypeId(location: any) {
+    return await this.helper.callRpc('api.query.assetManager.assetTypeId', [location]);
+  }
+}
+
+class MoonbeamAssetsGroup extends HelperGroup<MoonbeamHelper> {
+  async account(assetId: string, address: string) {
+    const accountAsset = (
+      await this.helper.callRpc('api.query.assets.account', [assetId, address])
+    ).toJSON()! as any;
+
+    if (accountAsset !== null) {
+      return BigInt(accountAsset['balance']);
+    } else {
+      return null;
+    }
+  }
+}
+
+class MoonbeamDemocracyGroup extends HelperGroup<MoonbeamHelper> {
+  async notePreimage(signer: TSigner, encodedProposal: string) {
+    await this.helper.executeExtrinsic(signer, 'api.tx.democracy.notePreimage', [encodedProposal], true);
+  }
+
+  externalProposeMajority(proposalHash: string) {
+    return this.helper.constructApiCall('api.tx.democracy.externalProposeMajority', [proposalHash]);
+  }
+
+  fastTrack(proposalHash: string, votingPeriod: number, delayPeriod: number) {
+    return this.helper.constructApiCall('api.tx.democracy.fastTrack', [proposalHash, votingPeriod, delayPeriod]);
+  }
+
+  async referendumVote(signer: TSigner, referendumIndex: number, accountVote: DemocracyStandardAccountVote) {
+    await this.helper.executeExtrinsic(signer, 'api.tx.democracy.vote', [referendumIndex, {Standard: accountVote}], true);
+  }
+}
+
+class MoonbeamCollectiveGroup extends HelperGroup<MoonbeamHelper> {
+  collective: string;
+
+  constructor(helper: MoonbeamHelper, collective: string) {
+    super(helper);
+
+    this.collective = collective;
+  }
+
+  async propose(signer: TSigner, threshold: number, proposalHash: string, lengthBound: number) {
+    await this.helper.executeExtrinsic(signer, `api.tx.${this.collective}.propose`, [threshold, proposalHash, lengthBound], true);
+  }
+
+  async vote(signer: TSigner, proposalHash: string, proposalIndex: number, approve: boolean) {
+    await this.helper.executeExtrinsic(signer, `api.tx.${this.collective}.vote`, [proposalHash, proposalIndex, approve], true);
+  }
+
+  async close(signer: TSigner, proposalHash: string, proposalIndex: number, weightBound: number, lengthBound: number) {
+    await this.helper.executeExtrinsic(signer, `api.tx.${this.collective}.close`, [proposalHash, proposalIndex, weightBound, lengthBound], true);
+  }
+
+  async proposalCount() {
+    return Number(await this.helper.callRpc(`api.query.${this.collective}.proposalCount`, []));
+  }
+}
+
+export type ChainHelperBaseConstructor = new(...args: any[]) => ChainHelperBase;
 export type UniqueHelperConstructor = new(...args: any[]) => UniqueHelper;
 
 export class UniqueHelper extends ChainHelperBase {
-  helperBase: any;
-
-  chain: ChainGroup;
-  balance: BalanceGroup;
-  address: AddressGroup;
+  balance: BalanceGroup<UniqueHelper>;
   collection: CollectionGroup;
   nft: NFTGroup;
   rft: RFTGroup;
@@ -2353,13 +2577,13 @@
   staking: StakingGroup;
   scheduler: SchedulerGroup;
   foreignAssets: ForeignAssetsGroup;
+  xcm: XcmGroup<UniqueHelper>;
+  xTokens: XTokensGroup<UniqueHelper>;
+  tokens: TokensGroup<UniqueHelper>;
 
   constructor(logger?: ILogger, options: {[key: string]: any} = {}) {
-    super(logger);
-
-    this.helperBase = options.helperBase ?? UniqueHelper;
+    super(logger, options.helperBase ?? UniqueHelper);
 
-    this.chain = new ChainGroup(this);
     this.balance = new BalanceGroup(this);
     this.address = new AddressGroup(this);
     this.collection = new CollectionGroup(this);
@@ -2369,24 +2593,83 @@
     this.staking = new StakingGroup(this);
     this.scheduler = new SchedulerGroup(this);
     this.foreignAssets = new ForeignAssetsGroup(this);
+    this.xcm = new XcmGroup(this, 'polkadotXcm');
+    this.xTokens = new XTokensGroup(this);
+    this.tokens = new TokensGroup(this);
   }
 
-  clone(helperCls: UniqueHelperConstructor, options: {[key: string]: any} = {}) {
-    Object.setPrototypeOf(helperCls.prototype, this);
-    const newHelper = new helperCls(this.logger, options);
+  getSudo<T extends UniqueHelper>() {
+    // eslint-disable-next-line @typescript-eslint/naming-convention
+    const SudoHelperType = SudoHelper(this.helperBase);
+    return this.clone(SudoHelperType) as T;
+  }
+}
 
-    newHelper.api = this.api;
-    newHelper.network = this.network;
-    newHelper.forceNetwork = this.forceNetwork;
+export class XcmChainHelper extends ChainHelperBase {
+  async connect(wsEndpoint: string, _listeners?: any): Promise<void> {
+    const wsProvider = new WsProvider(wsEndpoint);
+    this.api = new ApiPromise({
+      provider: wsProvider,
+    });
+    await this.api.isReadyOrError;
+    this.network = await UniqueHelper.detectNetwork(this.api);
+  }
+}
 
-    this.children.push(newHelper);
+export class RelayHelper extends XcmChainHelper {
+  xcm: XcmGroup<RelayHelper>;
 
-    return newHelper;
+  constructor(logger?: ILogger, options: {[key: string]: any} = {}) {
+    super(logger, options.helperBase ?? RelayHelper);
+
+    this.xcm = new XcmGroup(this, 'xcmPallet');
   }
+}
+
+export class MoonbeamHelper extends XcmChainHelper {
+  balance: EthereumBalanceGroup<MoonbeamHelper>;
+  assetManager: MoonbeamAssetManagerGroup;
+  assets: MoonbeamAssetsGroup;
+  xTokens: XTokensGroup<MoonbeamHelper>;
+  democracy: MoonbeamDemocracyGroup;
+  collective: {
+    council: MoonbeamCollectiveGroup,
+    techCommittee: MoonbeamCollectiveGroup,
+  };
 
-  getSudo<T extends UniqueHelper>() {
+  constructor(logger?: ILogger, options: {[key: string]: any} = {}) {
+    super(logger, options.helperBase ?? MoonbeamHelper);
+
+    this.balance = new EthereumBalanceGroup(this);
+    this.assetManager = new MoonbeamAssetManagerGroup(this);
+    this.assets = new MoonbeamAssetsGroup(this);
+    this.xTokens = new XTokensGroup(this);
+    this.democracy = new MoonbeamDemocracyGroup(this);
+    this.collective = {
+      council: new MoonbeamCollectiveGroup(this, 'councilCollective'),
+      techCommittee: new MoonbeamCollectiveGroup(this, 'techCommitteeCollective'),
+    };
+  }
+}
+
+export class AcalaHelper extends XcmChainHelper {
+  balance: SubstrateBalanceGroup<AcalaHelper>;
+  assetRegistry: AcalaAssetRegistryGroup;
+  xTokens: XTokensGroup<AcalaHelper>;
+  tokens: TokensGroup<AcalaHelper>;
+
+  constructor(logger?: ILogger, options: {[key: string]: any} = {}) {
+    super(logger, options.helperBase ?? AcalaHelper);
+
+    this.balance = new SubstrateBalanceGroup(this);
+    this.assetRegistry = new AcalaAssetRegistryGroup(this);
+    this.xTokens = new XTokensGroup(this);
+    this.tokens = new TokensGroup(this);
+  }
+
+  getSudo<T extends AcalaHelper>() {
     // eslint-disable-next-line @typescript-eslint/naming-convention
-    const SudoHelperType = SudoUniqueHelper(this.helperBase);
+    const SudoHelperType = SudoHelper(this.helperBase);
     return this.clone(SudoHelperType) as T;
   }
 }
@@ -2437,7 +2720,7 @@
 }
 
 // eslint-disable-next-line @typescript-eslint/naming-convention
-function SudoUniqueHelper<T extends UniqueHelperConstructor>(Base: T) {
+function SudoHelper<T extends ChainHelperBaseConstructor>(Base: T) {
   return class extends Base {
     constructor(...args: any[]) {
       super(...args);