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:
Tarik Gul
2024-07-22 13:27:58 -07:00
committed by GitHub
parent b61b7f25b8
commit 0f03a8c2bf
4 changed files with 35 additions and 2 deletions
+13 -1
View File
@@ -8,7 +8,7 @@ import store from 'store';
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 OnTypes = 'change';
@@ -35,6 +35,8 @@ export class Settings implements SettingsStruct {
#icon: string;
#ledgerApp: string;
#ledgerConn: 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.#apiType = { param: this.#apiUrl, type: 'json-rpc' as EndpointType };
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.#i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
this.#icon = settings.icon || ICON_DEFAULT;
@@ -96,6 +99,10 @@ export class Settings implements SettingsStruct {
return this.#notification;
}
public get ledgerApp (): string {
return this.#ledgerApp;
}
public get ledgerConn (): string {
return this.#ledgerConn;
}
@@ -144,6 +151,10 @@ export class Settings implements SettingsStruct {
return ICONS;
}
public get availableLedgerApp (): Option[] {
return LEDGER_APP;
}
public get availableLedgerConn (): Option[] {
return LEDGER_CONN;
}
@@ -183,6 +194,7 @@ export class Settings implements SettingsStruct {
camera: this.#camera,
i18nLang: this.#i18nLang,
icon: this.#icon,
ledgerApp: this.#ledgerApp,
ledgerConn: this.#ledgerConn,
locking: this.#locking,
metadataUp: this.#metadataUp,
+1 -1
View File
@@ -5,7 +5,7 @@ import type { Option } from '../types.js';
export { CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER } from './crypto.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 { 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'
}
];
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'
}
];
+1
View File
@@ -14,6 +14,7 @@ export interface SettingsStruct {
camera: string;
i18nLang: string;
icon: string;
ledgerApp: string;
ledgerConn: string;
locking: string;
metadataUp: string;