File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ export const SOLANA_DERIVATION_PATH = "44'/501'/0'/0'/0"
3131// Solana derivation path prefix for generating indexed paths
3232export const SOLANA_DERIVATION_PATH_PREFIX = "44'/501'/0'/0'"
3333
34+ // Deprecated Avalanche public key path prefix
35+ export const DEPRECATED_AVALANCHE_DERIVATION_PATH_PREFIX = "m/44'/9000'/0'"
36+
3437/**
3538 * Generate a Solana derivation path for a specific account index
3639 * @param accountIndex - The account index to generate the path for
Original file line number Diff line number Diff line change 11import * as cs from '@cubist-labs/cubesigner-sdk'
22import { strip0x } from '@avalabs/core-utils-sdk'
33import { AddressPublicKey , Curve } from 'utils/publicKeys'
4+ import { DEPRECATED_AVALANCHE_DERIVATION_PATH_PREFIX } from 'features/ledger/consts'
45
56export const transformKeyInfosToPubKeys = (
67 keyInfos : cs . KeyInfo [ ]
@@ -9,7 +10,23 @@ export const transformKeyInfosToPubKeys = (
910 const requiredKeyTypes : cs . KeyTypeApi [ ] = [ cs . Secp256k1 . Evm , cs . Secp256k1 . Ava ]
1011 const optionalKeyTypes : cs . KeyTypeApi [ ] = [ cs . Ed25519 . Solana ]
1112 const allowedKeyTypes = [ ...requiredKeyTypes , ...optionalKeyTypes ]
12- const keys = keyInfos
13+
14+ // we are migrating to the new account model with new derivation path spec for Ava and AvaTest: m/44'/${coinIndex}'/${accountIndex}'/0/0
15+ // in the backend, we are returning the keys with new spec and existing spec for backward compatibility,
16+ // to prepare for this change, we need to filter out the keys with new spec to avoid getting the wrong derivation path
17+ const filteredKeyInfos = keyInfos ?. filter ( k => {
18+ if (
19+ k . key_type === cs . Secp256k1 . Ava ||
20+ k . key_type === cs . Secp256k1 . AvaTest
21+ ) {
22+ return k . derivation_info ?. derivation_path ?. startsWith (
23+ DEPRECATED_AVALANCHE_DERIVATION_PATH_PREFIX
24+ )
25+ }
26+ return true
27+ } )
28+
29+ const keys = filteredKeyInfos
1330 ?. filter (
1431 k =>
1532 k . enabled &&
You can’t perform that action at this time.
0 commit comments