git.delta.rocks / unique-network / refs/commits / 3be2070a21b6

difftreelog

fix(test) add generateKeyringPair

Daniel Shiposha2022-08-24parent: #0b95edb.patch.diff
in: master

1 file changed

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
1616
17import '../interfaces/augment-api-rpc';17import '../interfaces/augment-api-rpc';
18import '../interfaces/augment-api-query';18import '../interfaces/augment-api-query';
19import {ApiPromise} from '@polkadot/api';19import {ApiPromise, Keyring} from '@polkadot/api';
20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';
21import type {GenericEventData} from '@polkadot/types';21import type {GenericEventData} from '@polkadot/types';
22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';
1786itApi.only = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {only: true});1786itApi.only = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {only: true});
1787itApi.skip = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {skip: true});1787itApi.skip = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {skip: true});
1788
1789let accountSeed = 10000;
1790
1791const keyringEth = new Keyring({type: 'ethereum'});
1792const keyringEd25519 = new Keyring({type: 'ed25519'});
1793const keyringSr25519 = new Keyring({type: 'sr25519'});
1794
1795export function generateKeyringPair(type: 'ethereum' | 'sr25519' | 'ed25519' = 'sr25519') {
1796 const privateKey = `0xDEADBEEF${(accountSeed++).toString(16).padStart(56, '0')}`;
1797 if (type == 'sr25519') {
1798 return keyringSr25519.addFromUri(privateKey);
1799 } else if (type == 'ed25519') {
1800 return keyringEd25519.addFromUri(privateKey);
1801 }
1802 return keyringEth.addFromUri(privateKey);
1803}
17881804