1234import {IKeyringPair} from '@polkadot/types/types';5import config from '../../config';6import '../../interfaces/augment-api-events';7import {DevUniqueHelper} from './unique.dev';89class SilentLogger {10 log(msg: any, level: any): void { }11 level = {12 ERROR: 'ERROR' as const,13 WARNING: 'WARNING' as const,14 INFO: 'INFO' as const,15 };16}1718export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {19 20 21 const consoleErr = console.error;22 const consoleLog = console.log;23 const consoleWarn = console.warn;2425 const outFn = (printer: any) => (...args: any[]) => {26 for (const arg of args) {27 if (typeof arg !== 'string')28 continue;29 if (arg.includes('1000:: Normal connection closure' || arg === 'Normal connection closure'))30 return;31 }32 printer(...args);33 };3435 console.error = outFn(consoleErr.bind(console));36 console.log = outFn(consoleLog.bind(console));37 console.warn = outFn(consoleWarn.bind(console));38 const helper = new DevUniqueHelper(new SilentLogger());3940 try {41 await helper.connect(config.substrateUrl);42 const ss58Format = helper.chain.getChainProperties().ss58Format;43 const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);44 await code(helper, privateKey);45 }46 finally {47 await helper.disconnect();48 console.error = consoleErr;49 console.log = consoleLog;50 console.warn = consoleWarn;51 }52};