mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-24 20:31:04 +00:00
Add new ledger app settings (#796)
* Add ledger app settings * Add ledgerApp * Add to setting struct * add available ledger apps * fix info
This commit is contained in:
@@ -8,7 +8,7 @@ import store from 'store';
|
|||||||
|
|
||||||
import { hasProcess, isUndefined } from '@polkadot/util';
|
import { hasProcess, isUndefined } from '@polkadot/util';
|
||||||
|
|
||||||
import { CAMERA, CAMERA_DEFAULT, CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING, LOCKING_DEFAULT, METADATA_UP, METADATA_UP_DEFAULT, NOTIFICATION_DEFAULT, PREFIX_DEFAULT, PREFIXES, STORAGE, STORAGE_DEFAULT, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults/index.js';
|
import { CAMERA, CAMERA_DEFAULT, CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LEDGER_APP, LEDGER_APP_DEFAULT, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING, LOCKING_DEFAULT, METADATA_UP, METADATA_UP_DEFAULT, NOTIFICATION_DEFAULT, PREFIX_DEFAULT, PREFIXES, STORAGE, STORAGE_DEFAULT, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults/index.js';
|
||||||
|
|
||||||
type ChangeCallback = (settings: SettingsStruct) => void;
|
type ChangeCallback = (settings: SettingsStruct) => void;
|
||||||
type OnTypes = 'change';
|
type OnTypes = 'change';
|
||||||
@@ -35,6 +35,8 @@ export class Settings implements SettingsStruct {
|
|||||||
|
|
||||||
#icon: string;
|
#icon: string;
|
||||||
|
|
||||||
|
#ledgerApp: string;
|
||||||
|
|
||||||
#ledgerConn: string;
|
#ledgerConn: string;
|
||||||
|
|
||||||
#locking: string;
|
#locking: string;
|
||||||
@@ -60,6 +62,7 @@ export class Settings implements SettingsStruct {
|
|||||||
this.#apiUrl = (typeof settings.apiUrl === 'string' && settings.apiUrl) || (hasProcess && process.env?.['WS_URL']) || (ENDPOINT_DEFAULT.value as string);
|
this.#apiUrl = (typeof settings.apiUrl === 'string' && settings.apiUrl) || (hasProcess && process.env?.['WS_URL']) || (ENDPOINT_DEFAULT.value as string);
|
||||||
this.#apiType = { param: this.#apiUrl, type: 'json-rpc' as EndpointType };
|
this.#apiType = { param: this.#apiUrl, type: 'json-rpc' as EndpointType };
|
||||||
this.#camera = withDefault(CAMERA, settings.camera, CAMERA_DEFAULT);
|
this.#camera = withDefault(CAMERA, settings.camera, CAMERA_DEFAULT);
|
||||||
|
this.#ledgerApp = withDefault(LEDGER_APP, settings.ledgerApp, LEDGER_APP_DEFAULT);
|
||||||
this.#ledgerConn = withDefault(LEDGER_CONN, settings.ledgerConn, LEDGER_CONN_DEFAULT);
|
this.#ledgerConn = withDefault(LEDGER_CONN, 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;
|
||||||
@@ -96,6 +99,10 @@ export class Settings implements SettingsStruct {
|
|||||||
return this.#notification;
|
return this.#notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get ledgerApp (): string {
|
||||||
|
return this.#ledgerApp;
|
||||||
|
}
|
||||||
|
|
||||||
public get ledgerConn (): string {
|
public get ledgerConn (): string {
|
||||||
return this.#ledgerConn;
|
return this.#ledgerConn;
|
||||||
}
|
}
|
||||||
@@ -144,6 +151,10 @@ export class Settings implements SettingsStruct {
|
|||||||
return ICONS;
|
return ICONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get availableLedgerApp (): Option[] {
|
||||||
|
return LEDGER_APP;
|
||||||
|
}
|
||||||
|
|
||||||
public get availableLedgerConn (): Option[] {
|
public get availableLedgerConn (): Option[] {
|
||||||
return LEDGER_CONN;
|
return LEDGER_CONN;
|
||||||
}
|
}
|
||||||
@@ -183,6 +194,7 @@ export class Settings implements SettingsStruct {
|
|||||||
camera: this.#camera,
|
camera: this.#camera,
|
||||||
i18nLang: this.#i18nLang,
|
i18nLang: this.#i18nLang,
|
||||||
icon: this.#icon,
|
icon: this.#icon,
|
||||||
|
ledgerApp: this.#ledgerApp,
|
||||||
ledgerConn: this.#ledgerConn,
|
ledgerConn: this.#ledgerConn,
|
||||||
locking: this.#locking,
|
locking: this.#locking,
|
||||||
metadataUp: this.#metadataUp,
|
metadataUp: this.#metadataUp,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { Option } from '../types.js';
|
|||||||
|
|
||||||
export { CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER } from './crypto.js';
|
export { CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER } from './crypto.js';
|
||||||
export { ENDPOINT_DEFAULT, ENDPOINTS } from './endpoints.js';
|
export { ENDPOINT_DEFAULT, ENDPOINTS } from './endpoints.js';
|
||||||
export { LEDGER_CONN, LEDGER_CONN_DEFAULT } from './ledger.js';
|
export { LEDGER_APP, LEDGER_APP_DEFAULT, LEDGER_CONN, LEDGER_CONN_DEFAULT } from './ledger.js';
|
||||||
export { PREFIX_DEFAULT, PREFIXES } from './ss58.js';
|
export { PREFIX_DEFAULT, PREFIXES } from './ss58.js';
|
||||||
export { ICON_DEFAULT, ICON_DEFAULT_HOST, ICONS, NOTIFICATION_DEFAULT, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './ui.js';
|
export { ICON_DEFAULT, ICON_DEFAULT_HOST, ICONS, NOTIFICATION_DEFAULT, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './ui.js';
|
||||||
|
|
||||||
|
|||||||
@@ -28,3 +28,23 @@ export const LEDGER_CONN: Option[] = [
|
|||||||
value: 'hid'
|
value: 'hid'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const LEDGER_APP_DEFAULT = 'generic';
|
||||||
|
|
||||||
|
export const LEDGER_APP: Option[] = [
|
||||||
|
{
|
||||||
|
info: 'generic',
|
||||||
|
text: 'Use the Ledger Polkadot Generic App',
|
||||||
|
value: 'generic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
info: 'migration',
|
||||||
|
text: 'Use the Ledger Migration App',
|
||||||
|
value: 'migration'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
info: 'legacy',
|
||||||
|
text: 'Use the Ledger Legacy App',
|
||||||
|
value: 'legacy'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export interface SettingsStruct {
|
|||||||
camera: string;
|
camera: string;
|
||||||
i18nLang: string;
|
i18nLang: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
|
ledgerApp: string;
|
||||||
ledgerConn: string;
|
ledgerConn: string;
|
||||||
locking: string;
|
locking: string;
|
||||||
metadataUp: string;
|
metadataUp: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user