Skip to content

Commit e96892c

Browse files
committed
[Issue-4365] fix: Update ledger-substrate-js library
1 parent d35920d commit e96892c

File tree

22 files changed

+165
-103
lines changed

22 files changed

+165
-103
lines changed

packages/extension-base/src/background/KoniTypes.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ export interface CreateHardwareAccountItem {
842842
isEthereum: boolean;
843843
isGeneric: boolean;
844844
isLedgerRecovery?: boolean;
845+
isSubstrateECDSA?: boolean;
845846
}
846847

847848
export interface RequestAccountCreateHardwareV2 extends CreateHardwareAccountItem {
@@ -1424,22 +1425,17 @@ export interface LedgerNetwork {
14241425
isRecovery?: boolean;
14251426
/** Slip44 in the derivation path */
14261427
slip44: number;
1428+
/** Signature substrate scheme */
1429+
scheme?: LEDGER_SCHEME;
14271430
}
14281431

14291432
export const enum LEDGER_SCHEME {
14301433
ED25519 = 0,
1431-
/**
1432-
* @deprecated This is deprecated and will be removed in future versions.
1433-
*/
1434-
SR25519 = 1,
14351434
ECDSA = 2
14361435
}
14371436

14381437
export interface MigrationLedgerNetwork extends Omit<LedgerNetwork, 'isGeneric' | 'isEthereum' | 'isDevMode' | 'icon' > {
14391438
ss58_addr_type: number;
1440-
1441-
/** Signature scheme */
1442-
scheme: LEDGER_SCHEME;
14431439
}
14441440

14451441
/// Qr Sign

packages/extension-base/src/core/logic-validation/recipientAddress.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { ActionType, ValidateRecipientParams, ValidationCondition } from '@subwallet/extension-base/core/types';
5-
import { _isAddress, _isNotDuplicateAddress, _isNotNull, _isSupportLedgerAccount, _isValidAddressForEcosystem, _isValidCardanoAddressFormat, _isValidSubstrateAddressFormat, _isValidTonAddressFormat } from '@subwallet/extension-base/core/utils';
5+
import { _isAddress, _isNotDuplicateAddress, _isNotNull, _isSupportLedgerAccount, _isValidAddressForEcosystem, _isValidCardanoAddressFormat, _isValidEvmAddressFormat, _isValidSubstrateAddressFormat, _isValidTonAddressFormat } from '@subwallet/extension-base/core/utils';
66
import { AccountSignMode } from '@subwallet/extension-base/types';
77
import { detectTranslate } from '@subwallet/extension-base/utils';
88
import { isCardanoAddress, isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
@@ -39,6 +39,10 @@ function getConditions (validateRecipientParams: ValidateRecipientParams): Valid
3939
if (account.signMode === AccountSignMode.LEGACY_LEDGER) {
4040
conditions.push(ValidationCondition.IS_VALID_SUBSTRATE_ADDRESS_FORMAT);
4141
}
42+
43+
if (account.signMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
44+
conditions.push(ValidationCondition.IS_VALID_EVM_ADDRESS_FORMAT);
45+
}
4246
}
4347

4448
return conditions;
@@ -85,6 +89,12 @@ function getValidationFunctions (conditions: ValidationCondition[]): Array<(vali
8589
break;
8690
}
8791

92+
case ValidationCondition.IS_VALID_EVM_ADDRESS_FORMAT: {
93+
validationFunctions.push(_isValidEvmAddressFormat);
94+
95+
break;
96+
}
97+
8898
case ValidationCondition.IS_NOT_DUPLICATE_ADDRESS: {
8999
validationFunctions.push(_isNotDuplicateAddress);
90100

packages/extension-base/src/core/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export enum ValidationCondition {
1111
IS_ADDRESS = 'IS_ADDRESS',
1212
IS_VALID_ADDRESS_FOR_ECOSYSTEM = 'IS_VALID_ADDRESS_FOR_ECOSYSTEM',
1313
IS_VALID_SUBSTRATE_ADDRESS_FORMAT = 'IS_VALID_SUBSTRATE_ADDRESS_FORMAT',
14+
IS_VALID_EVM_ADDRESS_FORMAT = 'IS_VALID_EVM_ADDRESS_FORMAT',
1415
IS_VALID_TON_ADDRESS_FORMAT = 'IS_VALID_TON_ADDRESS_FORMAT',
1516
IS_VALID_CARDANO_ADDRESS_FORMAT = 'IS_VALID_CARDANO_ADDRESS_FORMAT',
1617
IS_NOT_DUPLICATE_ADDRESS = 'IS_NOT_DUPLICATE_ADDRESS',

packages/extension-base/src/core/utils.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ export function _isValidCardanoAddressFormat (validateRecipientParams: ValidateR
112112
return '';
113113
}
114114

115+
export function _isValidEvmAddressFormat (validateRecipientParams: ValidateRecipientParams): string {
116+
const { destChainInfo, toAddress } = validateRecipientParams;
117+
118+
if (_isChainEvmCompatible(destChainInfo) && !isEthereumAddress(toAddress)) {
119+
return 'Recipient address must be a valid EVM address';
120+
}
121+
122+
return '';
123+
}
124+
115125
export function _isNotDuplicateAddress (validateRecipientParams: ValidateRecipientParams): string {
116126
const { fromAddress, toAddress } = validateRecipientParams;
117127

@@ -127,12 +137,18 @@ export function _isSupportLedgerAccount (validateRecipientParams: ValidateRecipi
127137

128138
if (account?.isHardware) {
129139
if (!account.isGeneric) {
130-
// For ledger legacy
131-
const availableGen: string[] = account.availableGenesisHashes || [];
132-
const destChainName = destChainInfo?.name || 'Unknown';
140+
if (account.isSubstrateECDSA) {
141+
if (!destChainInfo.substrateInfo || !destChainInfo.evmInfo) {
142+
return 'Your Ledger account is not supported by {{network}} network.'.replace('{{network}}', destChainInfo?.name || 'Unknown');
143+
}
144+
} else {
145+
// For ledger legacy
146+
const availableGen: string[] = account.availableGenesisHashes || [];
147+
const destChainName = destChainInfo?.name || 'Unknown';
133148

134-
if (!availableGen.includes(destChainInfo?.substrateInfo?.genesisHash || '')) {
135-
return 'Your Ledger account is not supported by {{network}} network.'.replace('{{network}}', destChainName);
149+
if (!availableGen.includes(destChainInfo?.substrateInfo?.genesisHash || '')) {
150+
return 'Your Ledger account is not supported by {{network}} network.'.replace('{{network}}', destChainName);
151+
}
136152
}
137153
} else {
138154
// For ledger generic

packages/extension-base/src/services/keyring-service/context/handlers/Ledger.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { RequestAccountCreateHardwareMultiple, RequestAccountCreateHardwareV2 } from '@subwallet/extension-base/background/KoniTypes';
55
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
6-
import { KeyringPair, KeyringPair$Meta } from '@subwallet/keyring/types';
6+
import { KeypairType, KeyringPair, KeyringPair$Meta } from '@subwallet/keyring/types';
77
import { keyring } from '@subwallet/ui-keyring';
88
import { t } from 'i18next';
99

@@ -86,7 +86,7 @@ export class AccountLedgerHandler extends AccountBaseHandler {
8686
const pairs: KeyringPair[] = [];
8787

8888
for (const account of accounts) {
89-
const { accountIndex, address, addressOffset, genesisHash, hardwareType, isEthereum, isGeneric, isLedgerRecovery, name, originGenesisHash } = account;
89+
const { accountIndex, address, addressOffset, genesisHash, hardwareType, isEthereum, isGeneric, isLedgerRecovery, isSubstrateECDSA, name, originGenesisHash } = account;
9090

9191
const baseMeta: KeyringPair$Meta = {
9292
name,
@@ -96,10 +96,16 @@ export class AccountLedgerHandler extends AccountBaseHandler {
9696
genesisHash,
9797
originGenesisHash,
9898
isGeneric,
99-
isLedgerRecovery
99+
isLedgerRecovery,
100+
isSubstrateECDSA
100101
};
101102

102-
const type = isEthereum ? 'ethereum' : 'sr25519';
103+
let type: KeypairType = 'sr25519';
104+
105+
if (isEthereum || isSubstrateECDSA) {
106+
type = 'ethereum';
107+
}
108+
103109
const pair = keyring.keyring.createFromAddress(
104110
address,
105111
{

packages/extension-base/src/types/account/info/keyring.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export interface AccountLedgerData {
6161
availableGenesisHashes?: string[];
6262
/** Is Ledger recovery chain */
6363
isLedgerRecovery?: boolean;
64+
/** Is Ledger substrate ECDSA scheme signature */
65+
isSubstrateECDSA?: boolean;
6466
}
6567

6668
/**
@@ -113,6 +115,7 @@ export enum AccountSignMode {
113115
QR = 'qr',
114116
LEGACY_LEDGER = 'legacy-ledger',
115117
GENERIC_LEDGER = 'generic-ledger',
118+
ECDSA_SUBSTRATE_LEDGER = 'ecdsa-substrate-ledger',
116119
READ_ONLY = 'readonly',
117120
ALL_ACCOUNT = 'all',
118121
INJECTED = 'injected',

packages/extension-base/src/utils/account/transform.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export const getAccountSignMode = (address: string, _meta?: KeyringPair$Meta): A
8989
if (meta.isHardware) {
9090
if (meta.isGeneric) {
9191
return AccountSignMode.GENERIC_LEDGER;
92+
} else if (meta.isSubstrateECDSA) {
93+
return AccountSignMode.ECDSA_SUBSTRATE_LEDGER;
9294
} else {
9395
return AccountSignMode.LEGACY_LEDGER;
9496
}
@@ -379,6 +381,12 @@ export const getAccountTransactionActions = (signMode: AccountSignMode, networkT
379381
result.push(...CLAIM_AVAIL_BRIDGE);
380382
}
381383

384+
return result;
385+
} else if (signMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER) { // Only for account substrate with ECDSA scheme format
386+
const result: ExtrinsicType[] = [];
387+
388+
result.push(...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ExtrinsicType.SWAP, ExtrinsicType.CROWDLOAN);
389+
382390
return result;
383391
}
384392

@@ -506,6 +514,7 @@ export const convertAccountProxyType = (accountSignMode: AccountSignMode): Accou
506514
switch (accountSignMode) {
507515
case AccountSignMode.GENERIC_LEDGER:
508516
case AccountSignMode.LEGACY_LEDGER:
517+
case AccountSignMode.ECDSA_SUBSTRATE_LEDGER:
509518
return AccountProxyType.LEDGER;
510519
case AccountSignMode.QR:
511520
return AccountProxyType.QR;
@@ -623,6 +632,7 @@ export const _combineAccounts = (accounts: AccountJson[], modifyPairs: ModifyPai
623632
switch (account.signMode) {
624633
case AccountSignMode.GENERIC_LEDGER:
625634
case AccountSignMode.LEGACY_LEDGER:
635+
case AccountSignMode.ECDSA_SUBSTRATE_LEDGER:
626636
specialChain = account.specialChain;
627637
break;
628638
}

packages/extension-koni-ui/src/Popup/Account/ConnectLedger.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2019-2022 @subwallet/extension-koni-ui authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { LedgerNetwork, MigrationLedgerNetwork } from '@subwallet/extension-base/background/KoniTypes';
4+
import { LEDGER_SCHEME, LedgerNetwork, MigrationLedgerNetwork } from '@subwallet/extension-base/background/KoniTypes';
55
import { reformatAddress } from '@subwallet/extension-base/utils';
66
import { AccountItemWithName, AccountWithNameSkeleton, BasicOnChangeFunction, ChainSelector, DualLogo, InfoIcon, Layout, PageWrapper } from '@subwallet/extension-koni-ui/components';
77
import { LedgerChainSelector, LedgerItemType } from '@subwallet/extension-koni-ui/components/Field/LedgerChainSelector';
@@ -254,7 +254,8 @@ const Component: React.FC<Props> = (props: Props) => {
254254
name: item.name,
255255
isEthereum: selectedChain.isEthereum,
256256
isGeneric: selectedChain.isGeneric,
257-
isLedgerRecovery: selectedChain?.isRecovery
257+
isLedgerRecovery: selectedChain?.isRecovery,
258+
isSubstrateECDSA: selectedChain.scheme === LEDGER_SCHEME.ECDSA
258259
}))
259260
})
260261
.then(() => {

packages/extension-koni-ui/src/Popup/Confirmations/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33

44
import { ConfirmationDefinitions, ConfirmationDefinitionsCardano, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
55
import { AuthorizeRequest, MetadataRequest, SigningRequest } from '@subwallet/extension-base/background/types';
6+
import { _isChainEvmCompatible, _isChainSubstrateCompatible } from '@subwallet/extension-base/services/chain-service/utils';
67
import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
78
import { AccountJson, ProcessType } from '@subwallet/extension-base/types';
89
import { _isRuntimeUpdated, detectTranslate } from '@subwallet/extension-base/utils';
910
import { AlertModal } from '@subwallet/extension-koni-ui/components';
1011
import { isProductionMode, NEED_SIGN_CONFIRMATION } from '@subwallet/extension-koni-ui/constants';
1112
import { useAlert, useConfirmationsInfo, useSelector } from '@subwallet/extension-koni-ui/hooks';
1213
import { SubmitApiConfirmation } from '@subwallet/extension-koni-ui/Popup/Confirmations/variants/Action';
14+
import { RootState } from '@subwallet/extension-koni-ui/stores';
1315
import { ConfirmationType } from '@subwallet/extension-koni-ui/stores/base/RequestState';
1416
import { AccountSignMode, ThemeProps } from '@subwallet/extension-koni-ui/types';
15-
import { findAccountByAddress, getSignMode, isRawPayload } from '@subwallet/extension-koni-ui/utils';
17+
import { findAccountByAddress, findChainInfoByGenesisHash, getSignMode, isRawPayload } from '@subwallet/extension-koni-ui/utils';
1618
import React, { useCallback, useEffect, useMemo, useState } from 'react';
1719
import { useTranslation } from 'react-i18next';
1820
import styled from 'styled-components';
@@ -51,6 +53,7 @@ const Component = function ({ className }: Props) {
5153
const { t } = useTranslation();
5254
const { alertProps, closeAlert, openAlert } = useAlert(alertModalId);
5355
const { transactionRequest } = useSelector((state) => state.requestState);
56+
const chainInfoMap = useSelector((state: RootState) => state.chainStore.chainInfoMap);
5457

5558
const nextConfirmation = useCallback(() => {
5659
setIndex((val) => Math.min(val + 1, numberOfConfirmations - 1));
@@ -87,8 +90,14 @@ const Component = function ({ className }: Props) {
8790
} else {
8891
const payload = request.request.payload as SignerPayloadJSON;
8992

90-
// Valid even with evm ledger account (evm - availableGenesisHashes is empty)
91-
canSign = !!account?.availableGenesisHashes?.includes(payload.genesisHash) || _isRuntimeUpdated(payload?.signedExtensions);
93+
if (account.isSubstrateECDSA) {
94+
const chainInfo = findChainInfoByGenesisHash(chainInfoMap, payload.genesisHash);
95+
96+
canSign = !!chainInfo && (_isChainEvmCompatible(chainInfo) && _isChainSubstrateCompatible(chainInfo));
97+
} else {
98+
// Valid even with evm ledger account (evm - availableGenesisHashes is empty)
99+
canSign = !!account?.availableGenesisHashes?.includes(payload.genesisHash) || _isRuntimeUpdated(payload?.signedExtensions);
100+
}
92101
}
93102
}
94103
} else {
@@ -227,7 +236,7 @@ const Component = function ({ className }: Props) {
227236
}
228237

229238
return null;
230-
}, [accounts, closeAlert, confirmation, openAlert]);
239+
}, [accounts, chainInfoMap, closeAlert, confirmation, openAlert]);
231240

232241
const headerTitle = useMemo((): string => {
233242
if (!confirmation) {

packages/extension-koni-ui/src/Popup/Confirmations/parts/Sign/Substrate.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ExtrinsicType, NotificationType } from '@subwallet/extension-base/backg
55
import { RequestSign } from '@subwallet/extension-base/background/types';
66
import { _isRuntimeUpdated, detectTranslate } from '@subwallet/extension-base/utils';
77
import { AlertBox, AlertModal } from '@subwallet/extension-koni-ui/components';
8-
import { CONFIRMATION_QR_MODAL, NotNeedMigrationGens, SUBSTRATE_GENERIC_KEY, SUBSTRATE_MIGRATION_KEY } from '@subwallet/extension-koni-ui/constants';
8+
import { CONFIRMATION_QR_MODAL, NotNeedMigrationGens, SUBSTRATE_GENERIC_KEY, SUBSTRATE_MIGRATION_KEY, SubstrateLedgerSignModeSupport } from '@subwallet/extension-koni-ui/constants';
99
import { InjectContext } from '@subwallet/extension-koni-ui/contexts/InjectContext';
1010
import { useAlert, useGetAccountByAddress, useGetChainInfoByGenesisHash, useLedger, useMetadata, useNotification, useParseSubstrateRequestPayload, useSelector, useUnlockChecker } from '@subwallet/extension-koni-ui/hooks';
1111
import { approveSignPasswordV2, approveSignSignature, cancelSignRequest, shortenMetadata } from '@subwallet/extension-koni-ui/messaging';
@@ -36,19 +36,19 @@ interface AlertData {
3636
title: string;
3737
type: 'info' | 'warning' | 'error';
3838
}
39+
3940
const alertModalId = 'dapp-alert-modal';
41+
const metadataFAQUrl = 'https://docs.subwallet.app/main/extension-user-guide/faqs#how-do-i-update-network-metadata';
42+
const genericFAQUrl = 'https://docs.subwallet.app/main/extension-user-guide/faqs#how-do-i-re-attach-a-new-polkadot-account-on-ledger';
43+
const migrationFAQUrl = 'https://docs.subwallet.app/main/extension-user-guide/faqs#how-do-i-move-assets-from-a-substrate-network-to-the-new-polkadot-account-on-ledger';
4044

4145
const handleConfirm = async (id: string) => await approveSignPasswordV2({ id });
42-
4346
const handleCancel = async (id: string) => await cancelSignRequest(id);
44-
4547
const handleSignature = async (id: string, { signature, signedTransaction }: SubstrateSigData) => await approveSignSignature(id, signature, signedTransaction);
48+
const getChainSlug = (signMode: AccountSignMode, originGenesisHash?: string | null, accountChainInfoSlug?: string) => (signMode === AccountSignMode.GENERIC_LEDGER ? originGenesisHash ? SUBSTRATE_MIGRATION_KEY : SUBSTRATE_GENERIC_KEY : (accountChainInfoSlug || ''));
49+
const isRequireMetadata = (signMode: AccountSignMode, isRuntimeUpdated: boolean) => signMode === AccountSignMode.GENERIC_LEDGER || signMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER || (signMode === AccountSignMode.LEGACY_LEDGER && isRuntimeUpdated);
4650

47-
const metadataFAQUrl = 'https://docs.subwallet.app/main/extension-user-guide/faqs#how-do-i-update-network-metadata';
48-
const genericFAQUrl = 'https://docs.subwallet.app/main/extension-user-guide/faqs#how-do-i-re-attach-a-new-polkadot-account-on-ledger';
49-
const migrationFAQUrl = 'https://docs.subwallet.app/main/extension-user-guide/faqs#how-do-i-move-assets-from-a-substrate-network-to-the-new-polkadot-account-on-ledger';
50-
51-
const modeCanSignMessage: AccountSignMode[] = [AccountSignMode.QR, AccountSignMode.PASSWORD, AccountSignMode.INJECTED, AccountSignMode.LEGACY_LEDGER, AccountSignMode.GENERIC_LEDGER];
51+
const modeCanSignMessage: AccountSignMode[] = [AccountSignMode.QR, AccountSignMode.PASSWORD, AccountSignMode.INJECTED, AccountSignMode.LEGACY_LEDGER, AccountSignMode.GENERIC_LEDGER, AccountSignMode.ECDSA_SUBSTRATE_LEDGER];
5252

5353
const Component: React.FC<Props> = (props: Props) => {
5454
const { className, extrinsicType, id, isInternal, request, txExpirationTime } = props;
@@ -73,7 +73,7 @@ const Component: React.FC<Props> = (props: Props) => {
7373
: _payload.genesisHash;
7474
}, [account?.genesisHash, chainInfoMap.polkadot.substrateInfo?.genesisHash, request.payload]);
7575
const signMode = useMemo(() => getSignMode(account), [account]);
76-
const isLedger = useMemo(() => signMode === AccountSignMode.LEGACY_LEDGER || signMode === AccountSignMode.GENERIC_LEDGER, [signMode]);
76+
const isLedger = useMemo(() => SubstrateLedgerSignModeSupport.includes(signMode), [signMode]);
7777
const isRuntimeUpdated = useMemo(() => {
7878
const _payload = request.payload;
7979

@@ -83,7 +83,7 @@ const Component: React.FC<Props> = (props: Props) => {
8383
return _isRuntimeUpdated(_payload.signedExtensions);
8484
}
8585
}, [request.payload]);
86-
const requireMetadata = useMemo(() => signMode === AccountSignMode.GENERIC_LEDGER || (signMode === AccountSignMode.LEGACY_LEDGER && isRuntimeUpdated), [isRuntimeUpdated, signMode]);
86+
const requireMetadata = useMemo(() => isRequireMetadata(signMode, isRuntimeUpdated), [isRuntimeUpdated, signMode]);
8787
const requireSpecVersion = useMemo((): number | undefined => {
8888
const _payload = request.payload;
8989

@@ -107,14 +107,15 @@ const Component: React.FC<Props> = (props: Props) => {
107107
return QrCode;
108108
case AccountSignMode.LEGACY_LEDGER:
109109
case AccountSignMode.GENERIC_LEDGER:
110+
case AccountSignMode.ECDSA_SUBSTRATE_LEDGER:
110111
return Swatches;
111112
case AccountSignMode.INJECTED:
112113
return Wallet;
113114
default:
114115
return CheckCircle;
115116
}
116117
}, [signMode]);
117-
const chainSlug = useMemo(() => signMode === AccountSignMode.GENERIC_LEDGER ? account?.originGenesisHash ? SUBSTRATE_MIGRATION_KEY : SUBSTRATE_GENERIC_KEY : (accountChainInfo?.slug || ''), [account?.originGenesisHash, accountChainInfo?.slug, signMode]);
118+
const chainSlug = useMemo(() => getChainSlug(signMode, account?.originGenesisHash, accountChainInfo?.slug), [account?.originGenesisHash, accountChainInfo?.slug, signMode]);
118119
const networkName = useMemo(() => chainInfo?.name || chain?.name || toShort(genesisHash), [chainInfo, genesisHash, chain]);
119120

120121
const isMetadataOutdated = useMemo(() => {
@@ -162,7 +163,7 @@ const Component: React.FC<Props> = (props: Props) => {
162163
}, [closeAlert, isOpenAlert, networkName, openAlert, t]);
163164

164165
const alertData = useMemo((): AlertData | undefined => {
165-
const requireMetadata = signMode === AccountSignMode.GENERIC_LEDGER || (signMode === AccountSignMode.LEGACY_LEDGER && isRuntimeUpdated);
166+
const requireMetadata = isRequireMetadata(signMode, isRuntimeUpdated);
166167

167168
if (!isMessage && !loadingChain) {
168169
if (!chain || !chain.hasMetadata || isMetadataOutdated) {
@@ -242,7 +243,7 @@ const Component: React.FC<Props> = (props: Props) => {
242243
}
243244
}
244245
} else {
245-
if (signMode === AccountSignMode.GENERIC_LEDGER) {
246+
if (signMode === AccountSignMode.GENERIC_LEDGER || signMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
246247
return {
247248
type: 'error',
248249
title: t('Error!'),
@@ -446,6 +447,7 @@ const Component: React.FC<Props> = (props: Props) => {
446447
break;
447448
case AccountSignMode.LEGACY_LEDGER:
448449
case AccountSignMode.GENERIC_LEDGER:
450+
case AccountSignMode.ECDSA_SUBSTRATE_LEDGER:
449451
onConfirmLedger();
450452
break;
451453
case AccountSignMode.INJECTED:

0 commit comments

Comments
 (0)