difftreelog
fix empty space
in: master
2 files changed
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -18,7 +18,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Pallets, requirePalletsOrSkip} from '../util';
import {expect, itEth, usingEthPlaygrounds} from './util';
-import { CollectionLimits } from './util/playgrounds/types';
+import {CollectionLimits} from './util/playgrounds/types';
describe('Create RFT collection from EVM', () => {
tests/src/eth/util/index.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import * as path from 'path';5import {IKeyringPair} from '@polkadot/types/types';67import config from '../../config';89import {EthUniqueHelper} from './playgrounds/unique.dev';10import {SilentLogger, SilentConsole} from '../../util/playgrounds/unique.dev';11import {SchedKind} from '../../util';1213export {EthUniqueHelper} from './playgrounds/unique.dev';1415import chai from 'chai';16import chaiAsPromised from 'chai-as-promised';17import chaiLike from 'chai-like';18import {getTestSeed, MINIMUM_DONOR_FUND, requirePalletsOrSkip} from '../../util';1920chai.use(chaiAsPromised);21chai.use(chaiLike);22export const expect = chai.expect;2324export enum SponsoringMode {25 Disabled = 0,26 Allowlisted = 1,27 Generous = 2,28}293031export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair>) => Promise<void>) => {32 const silentConsole = new SilentConsole();33 silentConsole.enable();3435 const helper = new EthUniqueHelper(new SilentLogger());3637 try {38 await helper.connect(config.substrateUrl);39 await helper.connectWeb3(config.substrateUrl);40 const ss58Format = helper.chain.getChainProperties().ss58Format;41 const privateKey = async (seed: string | {filename: string}) => {42 if (typeof seed === 'string') {43 return helper.util.fromSeed(seed, ss58Format);44 }45 else {46 const actualSeed = getTestSeed(seed.filename);47 let account = helper.util.fromSeed(actualSeed, ss58Format);48 if (await helper.balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND) {49 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);50 account = helper.util.fromSeed('//Alice', ss58Format);51 }52 return account;53 }54 };55 await code(helper, privateKey);56 }57 finally {58 await helper.disconnect();59 silentConsole.disable();60 }61};62 63export function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {64 (opts.only ? it.only : 65 opts.skip ? it.skip : it)(name, async function() {66 await usingEthPlaygrounds(async (helper, privateKey) => {67 if (opts.requiredPallets) {68 requirePalletsOrSkip(this, helper, opts.requiredPallets);69 }7071 await cb({helper, privateKey});72 });73 });74}7576export function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {77 return itEth(name, cb, {requiredPallets: required, ...opts});78}7980itEth.only = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEth(name, cb, {only: true});81itEth.skip = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEth(name, cb, {skip: true});8283itEthIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {only: true});84itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});85itEth.ifWithPallets = itEthIfWithPallet;8687export function itSchedEth(88 name: string,89 cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any,90 opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},91) {92 itEth(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);93 itEth(name + ' (named scheduling)', (apis) => cb('named', apis), opts);94}95itSchedEth.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {only: true});96itSchedEth.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {skip: true});97itSchedEth.ifWithPallets = itSchedIfWithPallets;9899function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {100 return itSchedEth(name, cb, {requiredPallets: required, ...opts});101}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import * as path from 'path';5import {IKeyringPair} from '@polkadot/types/types';67import config from '../../config';89import {EthUniqueHelper} from './playgrounds/unique.dev';10import {SilentLogger, SilentConsole} from '../../util/playgrounds/unique.dev';11import {SchedKind} from '../../util';1213export {EthUniqueHelper} from './playgrounds/unique.dev';1415import chai from 'chai';16import chaiAsPromised from 'chai-as-promised';17import chaiLike from 'chai-like';18import {getTestSeed, MINIMUM_DONOR_FUND, requirePalletsOrSkip} from '../../util';1920chai.use(chaiAsPromised);21chai.use(chaiLike);22export const expect = chai.expect;2324export enum SponsoringMode {25 Disabled = 0,26 Allowlisted = 1,27 Generous = 2,28}2930export const usingEthPlaygrounds = async (code: (helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair>) => Promise<void>) => {31 const silentConsole = new SilentConsole();32 silentConsole.enable();3334 const helper = new EthUniqueHelper(new SilentLogger());3536 try {37 await helper.connect(config.substrateUrl);38 await helper.connectWeb3(config.substrateUrl);39 const ss58Format = helper.chain.getChainProperties().ss58Format;40 const privateKey = async (seed: string | {filename: string}) => {41 if (typeof seed === 'string') {42 return helper.util.fromSeed(seed, ss58Format);43 }44 else {45 const actualSeed = getTestSeed(seed.filename);46 let account = helper.util.fromSeed(actualSeed, ss58Format);47 if (await helper.balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND) {48 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);49 account = helper.util.fromSeed('//Alice', ss58Format);50 }51 return account;52 }53 };54 await code(helper, privateKey);55 }56 finally {57 await helper.disconnect();58 silentConsole.disable();59 }60};61 62export function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {63 (opts.only ? it.only : 64 opts.skip ? it.skip : it)(name, async function() {65 await usingEthPlaygrounds(async (helper, privateKey) => {66 if (opts.requiredPallets) {67 requirePalletsOrSkip(this, helper, opts.requiredPallets);68 }6970 await cb({helper, privateKey});71 });72 });73}7475export function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {76 return itEth(name, cb, {requiredPallets: required, ...opts});77}7879itEth.only = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEth(name, cb, {only: true});80itEth.skip = (name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEth(name, cb, {skip: true});8182itEthIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {only: true});83itEthIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itEthIfWithPallet(name, required, cb, {skip: true});84itEth.ifWithPallets = itEthIfWithPallet;8586export function itSchedEth(87 name: string,88 cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any,89 opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},90) {91 itEth(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);92 itEth(name + ' (named scheduling)', (apis) => cb('named', apis), opts);93}94itSchedEth.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {only: true});95itSchedEth.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any) => itSchedEth(name, cb, {skip: true});96itSchedEth.ifWithPallets = itSchedIfWithPallets;9798function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {99 return itSchedEth(name, cb, {requiredPallets: required, ...opts});100}