difftreelog
add Apache-2.0 license identifier
in: master
2 files changed
tests/src/util/playgrounds/index.tsdiffbeforeafterboth1import {IKeyringPair} from '@polkadot/types/types';2import {UniqueHelper} from './unique';3import config from '../../config';4import '../../interfaces/augment-api-events';5import * as defs from '../../interfaces/definitions';6import {ApiPromise, WsProvider} from '@polkadot/api';789class 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}171819class DevUniqueHelper extends UniqueHelper {20 async connect(wsEndpoint: string, listeners?: any): Promise<void> {21 const wsProvider = new WsProvider(wsEndpoint);22 this.api = new ApiPromise({23 provider: wsProvider, 24 signedExtensions: {25 ContractHelpers: {26 extrinsic: {},27 payload: {},28 },29 FakeTransactionFinalizer: {30 extrinsic: {},31 payload: {},32 },33 },34 rpc: {35 unique: defs.unique.rpc,36 rmrk: defs.rmrk.rpc,37 eth: {38 feeHistory: {39 description: 'Dummy',40 params: [],41 type: 'u8',42 },43 maxPriorityFeePerGas: {44 description: 'Dummy',45 params: [],46 type: 'u8',47 },48 },49 },50 });51 await this.api.isReadyOrError;52 this.network = await UniqueHelper.detectNetwork(this.api);53 }54}5556export const usingPlaygrounds = async (code: (helper: UniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {57 // TODO: Remove, this is temporary: Filter unneeded API output58 // (Jaco promised it will be removed in the next version)59 const consoleErr = console.error;60 const consoleLog = console.log;61 const consoleWarn = console.warn;6263 const outFn = (printer: any) => (...args: any[]) => {64 for (const arg of args) {65 if (typeof arg !== 'string')66 continue;67 if (arg.includes('1000:: Normal connection closure' || arg === 'Normal connection closure'))68 return;69 }70 printer(...args);71 };7273 console.error = outFn(consoleErr.bind(console));74 console.log = outFn(consoleLog.bind(console));75 console.warn = outFn(consoleWarn.bind(console));76 const helper = new DevUniqueHelper(new SilentLogger());7778 try {79 await helper.connect(config.substrateUrl);80 const ss58Format = helper.chain.getChainProperties().ss58Format;81 const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);82 await code(helper, privateKey);83 } 84 finally {85 await helper.disconnect();86 console.error = consoleErr;87 console.log = consoleLog;88 console.warn = consoleWarn;89 }90};tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1,3 +1,6 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// SPDX-License-Identifier: Apache-2.0
+
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable function-call-argument-newline */
/* eslint-disable no-prototype-builtins */