diff --git a/packages/apps-config/src/settings/ethereumNetworks.ts b/packages/apps-config/src/settings/ethereumChains.ts similarity index 63% rename from packages/apps-config/src/settings/ethereumNetworks.ts rename to packages/apps-config/src/settings/ethereumChains.ts index 34b0de742e..c9fccdf4c8 100644 --- a/packages/apps-config/src/settings/ethereumNetworks.ts +++ b/packages/apps-config/src/settings/ethereumChains.ts @@ -3,4 +3,4 @@ // The list of Ethereum networks, for these the UI will default to Ethereum-only accounts -export const ethereumNetworks = ['node-moonbeam', 'moonbase-alphanet', 'moonbeam-alphanet', 'moonbeam-standalone']; +export const ethereumChains = ['node-moonbeam', 'moonbase-alphanet', 'moonbeam-alphanet', 'moonbeam-standalone']; diff --git a/packages/apps-config/src/settings/index.ts b/packages/apps-config/src/settings/index.ts index 14cbdb4a73..2d84e84b8e 100644 --- a/packages/apps-config/src/settings/index.ts +++ b/packages/apps-config/src/settings/index.ts @@ -1,6 +1,7 @@ // Copyright 2017-2020 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -export * from './ethereumNetworks'; +export * from './ethereumChains'; export * from './languages'; +export * from './ledgerChains'; export * from './ss58'; diff --git a/packages/apps-config/src/settings/ledgerChains.ts b/packages/apps-config/src/settings/ledgerChains.ts new file mode 100644 index 0000000000..afe3d433ed --- /dev/null +++ b/packages/apps-config/src/settings/ledgerChains.ts @@ -0,0 +1,10 @@ +// Copyright 2017-2020 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import { KUSAMA_GENESIS, POLKADOT_GENESIS } from '../api/constants'; + +// mapping of the genesisHash with the actual app name for Ledger +export const ledgerChains = [ + [KUSAMA_GENESIS, 'kusama'], + [POLKADOT_GENESIS, 'polkadot'] +]; diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index b6d0407292..e3912c7418 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -11,7 +11,7 @@ import store from 'store'; import { ApiPromise } from '@polkadot/api/promise'; import { deriveMapCache, setDeriveCache } from '@polkadot/api-derive/util'; -import { ethereumNetworks, POLKADOT_DENOM_BLOCK, POLKADOT_GENESIS, typesBundle, typesChain, typesSpec } from '@polkadot/apps-config'; +import { ethereumChains, POLKADOT_DENOM_BLOCK, POLKADOT_GENESIS, typesBundle, typesChain, typesSpec } from '@polkadot/apps-config'; import { web3Accounts, web3Enable } from '@polkadot/extension-dapp'; import { TokenUnit } from '@polkadot/react-components/InputNumber'; import { StatusContext } from '@polkadot/react-components/Status'; @@ -127,7 +127,7 @@ async function loadOnReady (api: ApiPromise, injectedPromise: Promise g).includes(api.genesisHash.toHex()); + return !!(window as unknown as { USB?: unknown }).USB && !!api && ledgerChains.map(([g]) => g).includes(api.genesisHash.toHex()); } catch (error) { return false; } @@ -33,7 +28,7 @@ export function clearLedger (): void { export function getLedger (): Ledger { if (!ledger) { - const def = api && ALLOWED_CHAINS.find(([g]) => g === api.genesisHash.toHex()); + const def = api && ledgerChains.find(([g]) => g === api.genesisHash.toHex()); assert(def, `Unable to find supported chain for ${api.genesisHash.toHex()}`);