1234567891011121314151617import {ApiPromise} from '@polkadot/api';18import {AccountInfo} from '@polkadot/types/interfaces/system';19import promisifySubstrate from './promisify-substrate';20import {IKeyringPair} from '@polkadot/types/types';21import {submitTransactionAsync} from './substrate-api';22import {getGenericResult} from '../deprecated-helpers/helpers';23import {expect} from 'chai';2425export default async function getBalance(api: ApiPromise, accounts: string[]): Promise<Array<bigint>> {26 const balance = promisifySubstrate(api, (acc: string[]) => api.query.system.account.multi(acc));27 const responce = await balance(accounts) as unknown as AccountInfo[];28 return responce.map((r) => r.data.free.toBigInt().valueOf());29}3031export async function getBalanceSingle(api: ApiPromise, account: string): Promise<bigint> {32 return (await getBalance(api, [account]))[0];33}3435export async function transferBalanceExpectSuccess(api: ApiPromise, from: IKeyringPair, to: string, amount: bigint | string) {36 const tx = api.tx.balances.transfer(to, amount);37 const events = await submitTransactionAsync(from, tx);38 const result = getGenericResult(events);39 expect(result.success).to.be.true;40}