Skip to content

Commit d62bbb9

Browse files
committed
linting fixing of transport type with resolution
1 parent 731ce90 commit d62bbb9

File tree

10 files changed

+211
-269
lines changed

10 files changed

+211
-269
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"@scure/bip32/@noble/hashes": "1.8.0",
5151
"@scure/bip39/@noble/hashes": "1.8.0",
5252
"@scure/btc-signer/@noble/hashes": "1.8.0",
53-
"[email protected]": "4.17.21"
53+
"[email protected]": "4.17.21",
54+
"@ledgerhq/hw-transport": "6.31.0"
5455
},
5556
"engines": {
5657
"node": ">=20.18.0",

packages/core-mobile/app/new/features/ledger/components/DerivationPathSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useCallback } from 'react'
22
import { View } from 'react-native'
33
import { Text, Button, useTheme, GroupList, Icons } from '@avalabs/k2-alpine'
44
import { ScrollScreen } from 'common/components/ScrollScreen'
5-
import { LedgerDerivationPathType } from 'services/wallet/LedgerWallet'
5+
import { LedgerDerivationPathType } from 'services/ledger/types'
66

77
interface DerivationPathOption {
88
type: LedgerDerivationPathType

packages/core-mobile/app/new/features/ledger/components/EnhancedLedgerSetup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { View, Alert } from 'react-native'
33
import { Text, Button, useTheme, GroupList, Icons } from '@avalabs/k2-alpine'
44
import { ScrollScreen } from 'common/components/ScrollScreen'
55
import { LoadingState } from 'common/components/LoadingState'
6-
import { LedgerDerivationPathType } from 'services/wallet/LedgerWallet'
76
import {
8-
useLedgerWallet,
7+
LedgerDerivationPathType,
98
WalletCreationOptions
10-
} from '../hooks/useLedgerWallet'
9+
} from 'services/ledger/types'
10+
import { useLedgerWallet } from '../hooks/useLedgerWallet'
1111
import { DerivationPathSelector } from './DerivationPathSelector'
1212
import { LedgerSetupProgress } from './LedgerSetupProgress'
1313
import { LedgerAppConnection } from './LedgerAppConnection'

packages/core-mobile/app/new/features/ledger/components/LedgerSetupProgress.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react'
22
import { View, ActivityIndicator, TouchableOpacity } from 'react-native'
33
import { Text, useTheme } from '@avalabs/k2-alpine'
4-
import { LedgerDerivationPathType } from 'services/wallet/LedgerWallet'
5-
import { SetupProgress } from '../hooks/useLedgerWallet'
4+
import { LedgerDerivationPathType } from 'services/ledger/types'
5+
import { SetupProgress } from 'services/ledger/types'
66

77
interface LedgerSetupProgressProps {
88
progress: SetupProgress

packages/core-mobile/app/new/features/ledger/hooks/useLedgerWallet.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { useState, useCallback, useEffect } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import { Alert, Platform, PermissionsAndroid } from 'react-native'
44
import TransportBLE from '@ledgerhq/react-native-hw-transport-ble'
5+
import Transport from '@ledgerhq/hw-transport'
56
import AppSolana from '@ledgerhq/hw-app-solana'
67
import bs58 from 'bs58'
7-
import LedgerService, { LedgerAppType } from 'services/ledger/LedgerService'
8-
import { LedgerDerivationPathType } from 'services/wallet/LedgerWallet'
8+
import LedgerService from 'services/ledger/LedgerService'
9+
import { LedgerAppType, LedgerDerivationPathType } from 'services/ledger/types'
910
import { ChainName } from 'services/network/consts'
1011
import { WalletType } from 'services/wallet/types'
1112
import { AppThunkDispatch } from 'store/types'
@@ -24,7 +25,7 @@ import {
2425
LedgerDevice,
2526
LedgerTransportState,
2627
LedgerKeys
27-
} from '../types'
28+
} from 'services/ledger/types'
2829

2930
export interface UseLedgerWalletReturn {
3031
// Connection state
@@ -267,7 +268,7 @@ export function useLedgerWallet(): UseLedgerWalletReturn {
267268

268269
// Get address directly from Solana app
269270
const transport = await LedgerService.getTransport()
270-
const solanaApp = new AppSolana(transport as any)
271+
const solanaApp = new AppSolana(transport as Transport)
271272
const derivationPath = SOLANA_DERIVATION_PATH
272273
const result = await solanaApp.getAddress(derivationPath, false)
273274

packages/core-mobile/app/new/features/ledger/types/index.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/core-mobile/app/services/ledger/LedgerService.ts

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import TransportBLE from '@ledgerhq/react-native-hw-transport-ble'
2+
import Transport from '@ledgerhq/hw-transport'
23
import AppAvalanche from '@avalabs/hw-app-avalanche'
34
import AppSolana from '@ledgerhq/hw-app-solana'
45
import { NetworkVMType } from '@avalabs/core-chains-sdk'
@@ -17,49 +18,14 @@ import {
1718
getSolanaDerivationPath
1819
} from 'new/features/ledger/consts'
1920
import { assertNotNull } from 'utils/assertions'
20-
21-
export interface AddressInfo {
22-
id: string
23-
address: string
24-
derivationPath: string
25-
network: string
26-
}
27-
28-
export interface ExtendedPublicKey {
29-
path: string
30-
key: string
31-
chainCode: string
32-
}
33-
34-
export interface PublicKeyInfo {
35-
key: string
36-
derivationPath: string
37-
curve: 'secp256k1' | 'ed25519'
38-
}
39-
40-
export enum LedgerAppType {
41-
AVALANCHE = 'Avalanche',
42-
SOLANA = 'Solana',
43-
ETHEREUM = 'Ethereum',
44-
UNKNOWN = 'Unknown'
45-
}
46-
47-
export const LedgerReturnCode = {
48-
SUCCESS: 0x9000,
49-
USER_REJECTED: 0x6985,
50-
APP_NOT_OPEN: 0x6a80,
51-
DEVICE_LOCKED: 0x5515,
52-
INVALID_PARAMETER: 0x6b00,
53-
COMMAND_NOT_ALLOWED: 0x6986
54-
} as const
55-
56-
export type LedgerReturnCodeType =
57-
typeof LedgerReturnCode[keyof typeof LedgerReturnCode]
58-
59-
export interface AppInfo {
60-
applicationName: string
61-
version: string
62-
}
21+
import {
22+
AddressInfo,
23+
ExtendedPublicKey,
24+
PublicKeyInfo,
25+
LedgerAppType,
26+
LedgerReturnCode,
27+
AppInfo
28+
} from './types'
6329

6430
export class LedgerService {
6531
#transport: TransportBLE | null = null
@@ -145,7 +111,7 @@ export class LedgerService {
145111

146112
// Get current app info from device
147113
private async getCurrentAppInfo(): Promise<AppInfo> {
148-
return await getLedgerAppInfo(this.transport as any)
114+
return await getLedgerAppInfo(this.transport as Transport)
149115
}
150116

151117
// Map app name to our enum
@@ -241,7 +207,7 @@ export class LedgerService {
241207
Logger.info('Avalanche app detected, creating app instance...')
242208

243209
// Create Avalanche app instance
244-
const avalancheApp = new AppAvalanche(this.transport as any)
210+
const avalancheApp = new AppAvalanche(this.transport as Transport)
245211
Logger.info('Avalanche app instance created')
246212

247213
try {
@@ -361,7 +327,7 @@ export class LedgerService {
361327
try {
362328
// Create fresh Solana app instance
363329
const transport = await this.getTransport()
364-
const solanaApp = new AppSolana(transport as any)
330+
const solanaApp = new AppSolana(transport as Transport)
365331
// Try to get a simple address to check if app is open
366332
// Use a standard Solana derivation path
367333
const testPath = "m/44'/501'/0'"
@@ -377,7 +343,7 @@ export class LedgerService {
377343
async getSolanaAddress(derivationPath: string): Promise<{ address: Buffer }> {
378344
await this.waitForApp(LedgerAppType.SOLANA)
379345
const transport = await this.getTransport()
380-
const solanaApp = new AppSolana(transport as any)
346+
const solanaApp = new AppSolana(transport as Transport)
381347
return await solanaApp.getAddress(derivationPath, false)
382348
}
383349

@@ -388,7 +354,7 @@ export class LedgerService {
388354
): Promise<PublicKeyInfo[]> {
389355
// Create a fresh AppSolana instance for each call (like the SDK does)
390356
const transport = await this.getTransport()
391-
const freshSolanaApp = new AppSolana(transport as any)
357+
const freshSolanaApp = new AppSolana(transport as Transport)
392358
const publicKeys: PublicKeyInfo[] = []
393359

394360
try {
@@ -430,7 +396,7 @@ export class LedgerService {
430396
// Use the SDK function directly (like the extension does)
431397
const publicKey = await getSolanaPublicKeyFromLedger(
432398
startIndex,
433-
this.transport as any
399+
this.transport as Transport
434400
)
435401

436402
const publicKeys: PublicKeyInfo[] = [
@@ -493,7 +459,7 @@ export class LedgerService {
493459
await this.waitForApp(LedgerAppType.AVALANCHE)
494460

495461
// Create Avalanche app instance
496-
const avalancheApp = new AppAvalanche(this.transport as any)
462+
const avalancheApp = new AppAvalanche(this.transport as Transport)
497463

498464
const publicKeys: PublicKeyInfo[] = []
499465

@@ -563,7 +529,7 @@ export class LedgerService {
563529
await this.waitForApp(LedgerAppType.AVALANCHE)
564530

565531
// Create Avalanche app instance
566-
const avalancheApp = new AppAvalanche(this.transport as any)
532+
const avalancheApp = new AppAvalanche(this.transport as Transport)
567533

568534
const addresses: AddressInfo[] = []
569535

0 commit comments

Comments
 (0)