mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 09:51:04 +00:00
Convert all to named imports (#414)
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "^2.10.1",
|
||||
"@polkadot/types": "^2.10.2-4",
|
||||
"@types/mkdirp": "^1.0.1",
|
||||
"@types/store": "^2.0.2"
|
||||
},
|
||||
|
||||
@@ -9,13 +9,13 @@ import type { KeyringOptions, KeyringStore } from './types';
|
||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||
import { isBoolean, isString } from '@polkadot/util';
|
||||
|
||||
import accounts from './observable/accounts';
|
||||
import addresses from './observable/addresses';
|
||||
import contracts from './observable/contracts';
|
||||
import env from './observable/development';
|
||||
import BrowserStore from './stores/Browser'; // direct import (skip index with all)
|
||||
import { accounts } from './observable/accounts';
|
||||
import { addresses } from './observable/addresses';
|
||||
import { contracts } from './observable/contracts';
|
||||
import { env } from './observable/env';
|
||||
import { BrowserStore } from './stores/Browser'; // direct import (skip index with all)
|
||||
|
||||
export default class Base {
|
||||
export class Base {
|
||||
#accounts: AddressSubject;
|
||||
|
||||
#addresses: AddressSubject;
|
||||
|
||||
@@ -9,12 +9,12 @@ import type { CreateResult, KeyringAddress, KeyringAddressType, KeyringItemType,
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { createPair } from '@polkadot/keyring/pair';
|
||||
import chains from '@polkadot/ui-settings/defaults/chains';
|
||||
import { chains } from '@polkadot/ui-settings/defaults/chains';
|
||||
import { bnToBn, hexToU8a, isHex, isString, u8aSorted } from '@polkadot/util';
|
||||
import { base64Decode, createKeyMulti } from '@polkadot/util-crypto';
|
||||
|
||||
import env from './observable/development';
|
||||
import Base from './Base';
|
||||
import { env } from './observable/env';
|
||||
import { Base } from './Base';
|
||||
import { accountKey, accountRegex, addressKey, addressRegex, contractKey, contractRegex } from './defaults';
|
||||
import { KeyringOption } from './options';
|
||||
|
||||
@@ -122,7 +122,7 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
return Object
|
||||
.keys(available)
|
||||
.map((address): KeyringAddress => this.getAddress(address, 'account') as KeyringAddress)
|
||||
.filter((account): boolean => env.isDevelopment() || account.meta.isTesting !== true);
|
||||
.filter((account) => env.isDevelopment() || account.meta.isTesting !== true);
|
||||
}
|
||||
|
||||
public getAddress (_address: string | Uint8Array, type: KeyringItemType | null = null): KeyringAddress | undefined {
|
||||
|
||||
@@ -5,10 +5,10 @@ import './detectPackage';
|
||||
|
||||
import { Keyring } from './Keyring';
|
||||
|
||||
export { default as Ledger } from '@polkadot/ledger';
|
||||
export { Ledger } from '@polkadot/ledger';
|
||||
|
||||
const keyring = new Keyring();
|
||||
|
||||
export default keyring;
|
||||
export { Keyring, keyring };
|
||||
|
||||
export { Keyring };
|
||||
export default keyring;
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { accountKey } from '../defaults';
|
||||
import genericSubject from './genericSubject';
|
||||
import { genericSubject } from './genericSubject';
|
||||
|
||||
export default genericSubject(accountKey, true);
|
||||
export const accounts = genericSubject(accountKey, true);
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { addressKey } from '../defaults';
|
||||
import genericSubject from './genericSubject';
|
||||
import { genericSubject } from './genericSubject';
|
||||
|
||||
export default genericSubject(addressKey);
|
||||
export const addresses = genericSubject(addressKey);
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { contractKey } from '../defaults';
|
||||
import genericSubject from './genericSubject';
|
||||
import { genericSubject } from './genericSubject';
|
||||
|
||||
export default genericSubject(contractKey);
|
||||
export const contracts = genericSubject(contractKey);
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
const subject = new BehaviorSubject(false);
|
||||
|
||||
export default {
|
||||
export const env = {
|
||||
isDevelopment: (): boolean =>
|
||||
subject.getValue(),
|
||||
set: (isDevelopment: boolean): void => {
|
||||
@@ -7,11 +7,11 @@ import type { AddressSubject, SingleAddress, SubjectInfo } from './types';
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import createOptionItem from '../options/item';
|
||||
import development from './development';
|
||||
import { createOptionItem } from '../options/item';
|
||||
import { env } from './env';
|
||||
|
||||
function callNext (current: SubjectInfo, subject: BehaviorSubject<SubjectInfo>, withTest: boolean): void {
|
||||
const isDevMode = development.isDevelopment();
|
||||
const isDevMode = env.isDevelopment();
|
||||
const filtered: SubjectInfo = {};
|
||||
|
||||
Object.keys(current).forEach((key): void => {
|
||||
@@ -25,12 +25,12 @@ function callNext (current: SubjectInfo, subject: BehaviorSubject<SubjectInfo>,
|
||||
subject.next(filtered);
|
||||
}
|
||||
|
||||
export default function genericSubject (keyCreator: (address: string) => string, withTest = false): AddressSubject {
|
||||
export function genericSubject (keyCreator: (address: string) => string, withTest = false): AddressSubject {
|
||||
let current: SubjectInfo = {};
|
||||
const subject = new BehaviorSubject({});
|
||||
const next = (): void => callNext(current, subject, withTest);
|
||||
|
||||
development.subject.subscribe(next);
|
||||
env.subject.subscribe(next);
|
||||
|
||||
return {
|
||||
add: (store: KeyringStore, address: string, json: KeyringJson, type?: KeypairType): SingleAddress => {
|
||||
@@ -43,7 +43,7 @@ export default function genericSubject (keyCreator: (address: string) => string,
|
||||
};
|
||||
|
||||
// we do not store dev accounts, injected or hardware (the latter two are external/transient)
|
||||
if (!json.meta.isInjected && !json.meta.isHardware && (!json.meta.isTesting || development.isDevelopment())) {
|
||||
if (!json.meta.isInjected && !json.meta.isHardware && (!json.meta.isTesting || env.isDevelopment())) {
|
||||
store.set(keyCreator(address), json);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import type { SubjectInfo } from './types';
|
||||
import { combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import accounts from './accounts';
|
||||
import addresses from './addresses';
|
||||
import contracts from './contracts';
|
||||
import { accounts } from './accounts';
|
||||
import { addresses } from './addresses';
|
||||
import { contracts } from './contracts';
|
||||
|
||||
interface Result {
|
||||
accounts: SubjectInfo;
|
||||
@@ -16,7 +16,7 @@ interface Result {
|
||||
contracts: SubjectInfo;
|
||||
}
|
||||
|
||||
export default combineLatest(
|
||||
export const obervableAll = combineLatest(
|
||||
accounts.subject,
|
||||
addresses.subject,
|
||||
contracts.subject
|
||||
|
||||
@@ -9,7 +9,7 @@ import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import observableAll from '../observable';
|
||||
import { obervableAll } from '../observable';
|
||||
|
||||
let hasCalledInitOptions = false;
|
||||
|
||||
@@ -49,7 +49,7 @@ export class KeyringOption implements KeyringOptionInstance {
|
||||
public init (keyring: KeyringStruct): void {
|
||||
assert(!hasCalledInitOptions, 'Unable to initialise options more than once');
|
||||
|
||||
observableAll.subscribe((): void => {
|
||||
obervableAll.subscribe((): void => {
|
||||
const opts = this.emptyOptions();
|
||||
|
||||
this.addAccounts(keyring, opts);
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { KeyringSectionOption } from './types';
|
||||
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
export default function createItem (address: string, _name?: string): KeyringSectionOption {
|
||||
export function createOptionItem (address: string, _name?: string): KeyringSectionOption {
|
||||
const name = isUndefined(_name)
|
||||
? (
|
||||
(address.length > 15)
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { KeyringJson, KeyringStore } from '../types';
|
||||
|
||||
import store from 'store';
|
||||
|
||||
export default class BrowserStore implements KeyringStore {
|
||||
export class BrowserStore implements KeyringStore {
|
||||
public all (cb: (key: string, value: KeyringJson) => void): void {
|
||||
store.each((value: KeyringJson, key: string): void => {
|
||||
cb(key, value);
|
||||
|
||||
@@ -10,7 +10,7 @@ import path from 'path';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
// NOTE untested and unused by any known apps, probably broken in various mysterious ways
|
||||
export default class FileStore implements KeyringStore {
|
||||
export class FileStore implements KeyringStore {
|
||||
#path: string;
|
||||
|
||||
constructor (path: string) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as BrowserStore } from './Browser';
|
||||
export { default as FileStore } from './File';
|
||||
export { BrowserStore } from './Browser';
|
||||
export { FileStore } from './File';
|
||||
|
||||
Reference in New Issue
Block a user