mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-23 17:41:04 +00:00
Add isHardware flags (#210)
* Add isHardware flags * Ledger connection options
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^1.4.1",
|
"@polkadot/keyring": "^1.4.1",
|
||||||
"@polkadot/types": "^0.93.0-beta.2",
|
"@polkadot/types": "^0.93.0-beta.3",
|
||||||
"@polkadot/util": "^1.4.1"
|
"@polkadot/util": "^1.4.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ export default function genericSubject (keyCreator: (address: string) => string,
|
|||||||
option: createOptionItem(address, json.meta.name)
|
option: createOptionItem(address, json.meta.name)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!json.meta.isInjected && (!json.meta.isTesting || development.isDevelopment())) {
|
// 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())) {
|
||||||
store.set(keyCreator(address), json);
|
store.set(keyCreator(address), json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ export interface KeyringOptions extends KeyringOptionsBase {
|
|||||||
export interface KeyringJson$Meta {
|
export interface KeyringJson$Meta {
|
||||||
contract?: ContractMeta;
|
contract?: ContractMeta;
|
||||||
genesisHash?: string | null;
|
genesisHash?: string | null;
|
||||||
|
hardwareType?: 'ledger';
|
||||||
|
isHardware?: boolean;
|
||||||
isInjected?: boolean;
|
isInjected?: boolean;
|
||||||
isRecent?: boolean;
|
isRecent?: boolean;
|
||||||
isTesting?: boolean;
|
isTesting?: boolean;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import store from 'store';
|
import store from 'store';
|
||||||
import { isUndefined } from '@polkadot/util';
|
import { isUndefined } from '@polkadot/util';
|
||||||
|
|
||||||
import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LANGUAGES, LOCKING_DEFAULT, LOCKING, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
|
import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LANGUAGES, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING_DEFAULT, LOCKING, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
|
||||||
import { Option, SettingsStruct } from './types';
|
import { Option, SettingsStruct } from './types';
|
||||||
|
|
||||||
export class Settings implements SettingsStruct {
|
export class Settings implements SettingsStruct {
|
||||||
@@ -15,6 +15,8 @@ export class Settings implements SettingsStruct {
|
|||||||
|
|
||||||
private _icon: string;
|
private _icon: string;
|
||||||
|
|
||||||
|
private _ledgerConn: string;
|
||||||
|
|
||||||
private _locking: string;
|
private _locking: string;
|
||||||
|
|
||||||
private _prefix: number;
|
private _prefix: number;
|
||||||
@@ -27,6 +29,7 @@ export class Settings implements SettingsStruct {
|
|||||||
const settings = store.get('settings') || {};
|
const settings = store.get('settings') || {};
|
||||||
|
|
||||||
this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT;
|
this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT;
|
||||||
|
this._ledgerConn = settings.ledgerConn || LEDGER_CONN_DEFAULT;
|
||||||
this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
|
this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
|
||||||
this._icon = settings.icon || ICON_DEFAULT;
|
this._icon = settings.icon || ICON_DEFAULT;
|
||||||
this._locking = settings.locking || LOCKING_DEFAULT;
|
this._locking = settings.locking || LOCKING_DEFAULT;
|
||||||
@@ -47,6 +50,10 @@ export class Settings implements SettingsStruct {
|
|||||||
return this._icon;
|
return this._icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get ledgerConn (): string {
|
||||||
|
return this._ledgerConn;
|
||||||
|
}
|
||||||
|
|
||||||
public get locking (): string {
|
public get locking (): string {
|
||||||
return this._locking;
|
return this._locking;
|
||||||
}
|
}
|
||||||
@@ -75,6 +82,10 @@ export class Settings implements SettingsStruct {
|
|||||||
return LANGUAGES;
|
return LANGUAGES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get availableLedgerConn (): Option[] {
|
||||||
|
return LEDGER_CONN;
|
||||||
|
}
|
||||||
|
|
||||||
public get availableLocking (): Option[] {
|
public get availableLocking (): Option[] {
|
||||||
return LOCKING;
|
return LOCKING;
|
||||||
}
|
}
|
||||||
@@ -100,6 +111,7 @@ export class Settings implements SettingsStruct {
|
|||||||
apiUrl: this._apiUrl,
|
apiUrl: this._apiUrl,
|
||||||
i18nLang: this._i18nLang,
|
i18nLang: this._i18nLang,
|
||||||
icon: this._icon,
|
icon: this._icon,
|
||||||
|
ledgerConn: this._ledgerConn,
|
||||||
locking: this._locking,
|
locking: this._locking,
|
||||||
prefix: this._prefix,
|
prefix: this._prefix,
|
||||||
uiMode: this._uiMode,
|
uiMode: this._uiMode,
|
||||||
@@ -109,6 +121,7 @@ export class Settings implements SettingsStruct {
|
|||||||
|
|
||||||
public set (settings: Partial<SettingsStruct>): void {
|
public set (settings: Partial<SettingsStruct>): void {
|
||||||
this._apiUrl = settings.apiUrl || this._apiUrl;
|
this._apiUrl = settings.apiUrl || this._apiUrl;
|
||||||
|
this._ledgerConn = settings.ledgerConn || this._ledgerConn;
|
||||||
this._i18nLang = settings.i18nLang || this._i18nLang;
|
this._i18nLang = settings.i18nLang || this._i18nLang;
|
||||||
this._icon = settings.icon || this._icon;
|
this._icon = settings.icon || this._icon;
|
||||||
this._locking = settings.locking || this._locking;
|
this._locking = settings.locking || this._locking;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Option } from '../types';
|
|||||||
|
|
||||||
import { CRYPTOS } from './crypto';
|
import { CRYPTOS } from './crypto';
|
||||||
import { ENDPOINTS, ENDPOINT_DEFAULT } from './endpoints';
|
import { ENDPOINTS, ENDPOINT_DEFAULT } from './endpoints';
|
||||||
|
import { LEDGER_CONN, LEDGER_CONN_DEFAULT } from './ledger';
|
||||||
import { PREFIXES, PREFIX_DEFAULT } from './ss58';
|
import { PREFIXES, PREFIX_DEFAULT } from './ss58';
|
||||||
import { ICON_DEFAULT, ICON_DEFAULT_HOST, ICONS, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './ui';
|
import { ICON_DEFAULT, ICON_DEFAULT_HOST, ICONS, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './ui';
|
||||||
|
|
||||||
@@ -43,6 +44,8 @@ export {
|
|||||||
ICONS,
|
ICONS,
|
||||||
LANGUAGE_DEFAULT,
|
LANGUAGE_DEFAULT,
|
||||||
LANGUAGES,
|
LANGUAGES,
|
||||||
|
LEDGER_CONN_DEFAULT,
|
||||||
|
LEDGER_CONN,
|
||||||
LOCKING_DEFAULT,
|
LOCKING_DEFAULT,
|
||||||
LOCKING,
|
LOCKING,
|
||||||
PREFIX_DEFAULT,
|
PREFIX_DEFAULT,
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2017-2019 @polkadot/ui-settings authors & contributors
|
||||||
|
// This software may be modified and distributed under the terms
|
||||||
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||||
|
|
||||||
|
import { Option } from '../types';
|
||||||
|
|
||||||
|
export const LEDGER_CONN_DEFAULT = 'none';
|
||||||
|
|
||||||
|
export const LEDGER_CONN: Option[] = [
|
||||||
|
{
|
||||||
|
info: 'none',
|
||||||
|
text: 'Do not attach Ledger devices',
|
||||||
|
value: 'none'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
info: 'u2f',
|
||||||
|
text: 'Attach Ledger via U2F',
|
||||||
|
value: 'u2f'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
info: 'webusb',
|
||||||
|
text: 'Attach Ledger via WebUSB',
|
||||||
|
value: 'webusb'
|
||||||
|
}
|
||||||
|
];
|
||||||
@@ -13,6 +13,7 @@ export interface SettingsStruct {
|
|||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
i18nLang: string;
|
i18nLang: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
|
ledgerConn: string;
|
||||||
locking: string;
|
locking: string;
|
||||||
prefix: number;
|
prefix: number;
|
||||||
uiMode: string;
|
uiMode: string;
|
||||||
|
|||||||
@@ -2099,10 +2099,10 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/chrome" "^0.0.88"
|
"@types/chrome" "^0.0.88"
|
||||||
|
|
||||||
"@polkadot/types@^0.93.0-beta.2":
|
"@polkadot/types@^0.93.0-beta.3":
|
||||||
version "0.93.0-beta.2"
|
version "0.93.0-beta.3"
|
||||||
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.93.0-beta.2.tgz#107c803fe349854f6af6de48961d8461d3230204"
|
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.93.0-beta.3.tgz#2a5843c35b3fb3369390e66236ff20968099b9fe"
|
||||||
integrity sha512-05dWMROnjlFI3BG6PBc0YAOZQyTURQGtgAgGZYjOMrT/9CiuG64migc1GEUBkt/vWPUZ9Rgx6rt92HtANL4pwQ==
|
integrity sha512-RlwhdtnQXq9yHgNwQJ2Rnl0RtklGucPFJE2in6gCNrvAE9V+KbJqXrwGtCqbt/CmGySTZclaL9yJ9Qzg1JgS1w==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.6.0"
|
"@babel/runtime" "^7.6.0"
|
||||||
"@polkadot/util" "^1.4.1"
|
"@polkadot/util" "^1.4.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user