1234import {IKeyringPair} from '@polkadot/types/types';56import config from '../../../config';78import {EthUniqueHelper} from './unique.dev';9import {SilentLogger, SilentConsole} from '../../../util/playgrounds/unique.dev';1011export {EthUniqueHelper} from './unique.dev';1213import chai from 'chai';14import chaiAsPromised from 'chai-as-promised';15chai.use(chaiAsPromised);16export const expect = chai.expect;1718export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {19 const silentConsole = new SilentConsole();20 silentConsole.enable();2122 const helper = new EthUniqueHelper(new SilentLogger());2324 try {25 await helper.connect(config.substrateUrl);26 await helper.connectWeb3(config.substrateUrl);27 const ss58Format = helper.chain.getChainProperties().ss58Format;28 const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);29 await code(helper, privateKey);30 }31 finally {32 await helper.disconnect();33 await helper.disconnectWeb3();34 silentConsole.disable();35 }36};37 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;40 if (opts.only) i = i.only;41 else if (opts.skip) i = i.skip;42 i(name, async () => {43 await usingEthPlaygrounds(async (helper, privateKey) => {44 await cb({helper, privateKey});45 });46 });47}48itEth.only = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {only: true});49itEth.skip = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string) => IKeyringPair }) => any) => itEth(name, cb, {skip: true});