@onekeyfe/hwk-adapter-core 1.1.27 → 1.1.29-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,133 +1,7 @@
1
- /**
2
- * HWK HardwareErrorCode independent namespace from the legacy
3
- * `@onekeyfe/shared` HardwareErrorCode (which occupies 0-902).
4
- *
5
- * All HWK codes are 5-digit (>= 10000) so the two tables never collide
6
- * even if either side grows. Each sub-category gets a 100-slot block.
7
- *
8
- * 10000-10099 Generic / cross-cutting primitives
9
- * 10100-10199 Device state
10
- * 10200-10299 Firmware
11
- * 10300-10399 Transport + OS-level permission
12
- * 10400-10499 PIN / Passphrase
13
- * 10500-10599 App lifecycle (wrong app, not open, too old)
14
- * 10600-10999 RESERVED — future adapter-level categories
15
- *
16
- * 11000-11099 EVM APDU (reactive mapping)
17
- * 11100-11199 Solana APDU
18
- * 11200-11299 Tron APDU
19
- * 11300-11399 BTC APDU
20
- * 11400-11999 RESERVED — future chain APDU blocks (100 per chain)
21
- *
22
- * 12000-99999 RESERVED — future major categories
23
- */
24
- declare enum HardwareErrorCode {
25
- UnknownError = 10000,
26
- UserRejected = 10001,
27
- InvalidParams = 10002,
28
- OperationTimeout = 10003,
29
- MethodNotSupported = 10004,
30
- /** User dismissed in-app cancel UI. Distinct from UserRejected (on-device). */
31
- UserAborted = 10005,
32
- DeviceNotFound = 10100,
33
- DeviceDisconnected = 10101,
34
- DeviceBusy = 10102,
35
- DeviceLocked = 10103,
36
- DeviceNotInitialized = 10104,
37
- DeviceInBootloader = 10105,
38
- DeviceMismatch = 10106,
39
- /** Chain app wedged (e.g. Ledger BTC 0x6901). User must exit app on device. */
40
- DeviceAppStuck = 10107,
41
- /** Vendor (Ledger / Trezor) doesn't support the chain at all. */
42
- ChainNotSupported = 10108,
43
- /** Current operation supports only one connected device. */
44
- DeviceOneDeviceOnly = 10109,
45
- FirmwareTooOld = 10200,
46
- FirmwareUpdateRequired = 10201,
47
- TransportError = 10300,
48
- BridgeNotFound = 10301,
49
- TransportNotAvailable = 10302,
50
- /**
51
- * OS-level permission (Bluetooth / USB / etc.) — denied, blocked,
52
- * unavailable, or dismissed. Consumers surface a single "please grant
53
- * permission" toast and let the user retry manually.
54
- */
55
- DevicePermissionDenied = 10303,
56
- /**
57
- * BLE SMP pairing did not complete within the GATT bonding window.
58
- * GATT connected but the device didn't acknowledge SMP — typically
59
- * because the user didn't confirm the passkey on the device, or the
60
- * device went out of range mid-pairing. Distinct from OperationTimeout
61
- * (generic) and from DeviceLocked (Secure Element actually locked).
62
- */
63
- BlePairingTimeout = 10304,
64
- /** Remote network failure reaching a vendor's servers (HTTP/WS). Distinct from TransportError (local USB/BLE link). */
65
- NetworkError = 10305,
66
- PinInvalid = 10400,
67
- PinCancelled = 10401,
68
- PassphraseRejected = 10402,
69
- /** Chain app NOT INSTALLED on device. User must install via Ledger Live. */
70
- AppNotInstalled = 10500,
71
- WrongApp = 10501,
72
- /** 0x911c Command code not supported — app predates current SDK. */
73
- AppTooOld = 10502,
74
- /** Not enough free storage for install/update; user must uninstall apps first. */
75
- DeviceOutOfMemory = 10503,
76
- /** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the
77
- * user has not enabled Blind signing on the device. */
78
- EvmBlindSigningRequired = 11000,
79
- /** 0x6984 Plugin not installed */
80
- EvmClearSignPluginMissing = 11001,
81
- /** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */
82
- EvmDataTooLarge = 11002,
83
- /** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */
84
- EvmTxTypeNotSupported = 11003,
85
- /** 0x6808 Blind signing disabled for this instruction. */
86
- SolanaBlindSigningRequired = 11100,
87
- /** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */
88
- TronCustomContractRequired = 11200,
89
- /** 0x6a8b Transactions Data setting disabled. */
90
- TronDataSigningRequired = 11201,
91
- /** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */
92
- TronSignByHashRequired = 11202,
93
- /** 0xb008 Wallet policy HMAC mismatch or not registered. */
94
- BtcWalletPolicyHmacMismatch = 11300,
95
- /** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */
96
- BtcUnexpectedState = 11301
97
- }
98
- /**
99
- * Device-level failures the SDK cannot self-recover from — affect the entire
100
- * batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-
101
- * skip in onboarding). Combined with `accounts.length === 0`, signals
102
- * genuine orphan. Also reused as the batch-abort whitelist for HWK.
103
- * Single source of truth.
104
- *
105
- * UserRejected (device-side reject) is included: pressing reject is an
106
- * explicit "I don't consent" — continuing the batch to ask again on the
107
- * next chain is harassment, not helpful.
108
- */
109
- declare const ORPHAN_ELIGIBLE_ERROR_CODES: number[];
110
- interface IHwkErrorPayload {
111
- code: HardwareErrorCode;
112
- message: string;
113
- appName?: string;
114
- _tag?: string;
115
- params?: Record<string, unknown>;
116
- }
117
- type HwkError = Error & {
118
- code: HardwareErrorCode;
119
- appName?: string;
120
- _tag?: string;
121
- params?: Record<string, unknown>;
122
- };
123
- /**
124
- * Canonical throwable for HWK adapters. Plain Error + canonical extra fields,
125
- * shape-compatible with `rehydrateConnectorError` so locally-thrown and
126
- * cross-boundary errors are indistinguishable to downstream classifiers
127
- * (`err.code` / `err._tag` / `err.appName`). Do NOT mutate caught errors
128
- * with `Object.assign` — construct a fresh one via this factory.
129
- */
130
- declare function createHwkError(payload: IHwkErrorPayload): HwkError;
1
+ import { HardwareErrorCode } from './errors.mjs';
2
+ export { HwkError, IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage } from './errors.mjs';
3
+ import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-BzkI1wZk.mjs';
4
+ export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, c as QrResponseData, d as UI_EVENT, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry } from './ui-events-BzkI1wZk.mjs';
131
5
 
132
6
  interface Success<T> {
133
7
  success: true;
@@ -186,102 +60,38 @@ interface DeviceInfo {
186
60
  serialNumber?: string;
187
61
  /** Device capabilities — varies by vendor, model, and connection type */
188
62
  capabilities?: DeviceCapabilities;
63
+ /**
64
+ * Vendor-specific raw payload from the post-handshake `Features` (Trezor)
65
+ * or device-info call. Populated by the connector with `{ transport,
66
+ * descriptor, features }` so the app layer can read fields we haven't
67
+ * promoted to the typed surface yet. Treat as informational — promote
68
+ * any consumed field above.
69
+ */
70
+ raw?: Record<string, unknown>;
189
71
  }
190
72
  interface DeviceTarget {
191
73
  connectId: string;
192
74
  deviceId: string;
193
75
  }
194
76
 
195
- interface QrDisplayData {
196
- urType: string;
197
- urData: string;
198
- animated: boolean;
199
- }
200
- interface QrResponseData {
201
- urType: string;
202
- urData: string;
77
+ /**
78
+ * Mixin for chain-operation params that can be pinned to a specific passphrase
79
+ * wallet.
80
+ *
81
+ * Trezor-only. `passphraseState` is the wallet identity returned by
82
+ * `getPassphraseState`: today this is the compressed public key derived at
83
+ * `m/44'/0'/0'`, not the 4-byte master fingerprint. When present, the adapter
84
+ * creates a fresh wallet session (THP application session, or v1 device
85
+ * session) and verifies the derived state before issuing the call, so the
86
+ * address/signature comes from the intended passphrase wallet.
87
+ *
88
+ * Ledger has no equivalent and ignores the field — it never reaches the
89
+ * protobuf layer (the adapter strips it before forwarding to the connector).
90
+ */
91
+ interface PassphraseStateAware {
92
+ passphraseState?: string;
203
93
  }
204
94
 
205
- declare const UI_EVENT = "UI_EVENT";
206
- declare const UI_REQUEST: {
207
- readonly REQUEST_PIN: "ui-request-pin";
208
- readonly REQUEST_PASSPHRASE: "ui-request-passphrase";
209
- readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device";
210
- readonly REQUEST_BUTTON: "ui-request-button";
211
- readonly REQUEST_QR_DISPLAY: "ui-request-qr-display";
212
- readonly REQUEST_QR_SCAN: "ui-request-qr-scan";
213
- readonly REQUEST_DEVICE_PERMISSION: "ui-request-device-permission";
214
- readonly REQUEST_SELECT_DEVICE: "ui-request-select-device";
215
- readonly REQUEST_DEVICE_CONNECT: "ui-request-device-connect";
216
- readonly REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm";
217
- readonly REQUEST_INSTALL_APP: "ui-request-install-app";
218
- readonly CLOSE_UI_WINDOW: "ui-close";
219
- readonly DEVICE_PROGRESS: "ui-device_progress";
220
- readonly FIRMWARE_PROGRESS: "ui-firmware-progress";
221
- readonly FIRMWARE_TIP: "ui-firmware-tip";
222
- };
223
- declare const UI_RESPONSE: {
224
- readonly RECEIVE_PIN: "receive-pin";
225
- readonly RECEIVE_PASSPHRASE: "receive-passphrase";
226
- readonly RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device";
227
- readonly RECEIVE_QR_RESPONSE: "receive-qr-response";
228
- readonly RECEIVE_SELECT_DEVICE: "receive-select-device";
229
- readonly RECEIVE_DEVICE_CONNECT: "receive-device-connect";
230
- readonly RECEIVE_DEVICE_PERMISSION: "receive-device-permission";
231
- readonly RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm";
232
- readonly RECEIVE_INSTALL_APP: "receive-install-app";
233
- readonly CANCEL: "cancel";
234
- };
235
- type DevicePermissionDeniedReason = 'bluetoothTurnedOff' | 'permissionDenied' | (string & Record<never, never>);
236
- type DevicePermissionResponse = {
237
- granted: boolean;
238
- reason?: DevicePermissionDeniedReason;
239
- message?: string;
240
- };
241
- type UiResponseEvent = {
242
- type: typeof UI_RESPONSE.RECEIVE_PIN;
243
- payload: string;
244
- } | {
245
- type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
246
- payload: {
247
- value: string;
248
- passphraseOnDevice?: boolean;
249
- save?: boolean;
250
- };
251
- } | {
252
- type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;
253
- payload?: undefined;
254
- } | {
255
- type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;
256
- payload: QrResponseData;
257
- } | {
258
- type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;
259
- payload: {
260
- sdkConnectId: string;
261
- };
262
- } | {
263
- type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;
264
- payload: {
265
- confirmed: boolean;
266
- };
267
- } | {
268
- type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;
269
- payload: DevicePermissionResponse;
270
- } | {
271
- type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;
272
- payload: {
273
- confirmed: boolean;
274
- };
275
- } | {
276
- type: typeof UI_RESPONSE.RECEIVE_INSTALL_APP;
277
- payload: {
278
- confirmed: boolean;
279
- };
280
- } | {
281
- type: typeof UI_RESPONSE.CANCEL;
282
- payload?: undefined;
283
- };
284
-
285
95
  /**
286
96
  * Minimal device info returned during discovery (searchDevices).
287
97
  * At scan time, full DeviceInfo fields like firmwareVersion are not yet available.
@@ -290,6 +100,15 @@ interface ConnectorDevice {
290
100
  connectId: string;
291
101
  deviceId: string;
292
102
  name: string;
103
+ /**
104
+ * Physical transport this device was discovered on. Mirrors Trezor
105
+ * Connect's `descriptor.apiType` — when several transports are fused behind
106
+ * one connector (see `createCombinedConnector`), the merged device list
107
+ * carries this so the host can tell a USB entry from a BLE one and route
108
+ * `connect()` back to the owning transport. Single-transport connectors may
109
+ * leave it undefined.
110
+ */
111
+ connectionType?: ConnectionType;
293
112
  /** Machine model id (e.g. "nanoX"). */
294
113
  model?: string;
295
114
  /** Human-readable model name (e.g. "Ledger Nano X"). */
@@ -302,6 +121,13 @@ interface ConnectorDevice {
302
121
  serialNumber?: string;
303
122
  /** Device capabilities — available from scan time */
304
123
  capabilities?: DeviceCapabilities;
124
+ /**
125
+ * Vendor-specific raw blob from the transport descriptor (USB / BLE).
126
+ * Populated by `descriptorToConnectorDevice` in each connector. Treat as
127
+ * informational; promote any field consumed by the app layer onto the
128
+ * typed surface above.
129
+ */
130
+ raw?: Record<string, unknown>;
305
131
  }
306
132
  interface ConnectorSession {
307
133
  sessionId: string;
@@ -346,7 +172,7 @@ type ConnectorCallResult = {
346
172
  success: false;
347
173
  error: ConnectorSerializedError;
348
174
  };
349
- type ConnectorEventType = 'device-connect' | 'device-disconnect' | 'ui-request' | 'ui-event';
175
+ type ConnectorEventType = 'device-connect' | 'device-disconnect' | 'features' | 'device-trezor-thp-credentials-changed' | 'ui-request' | 'ui-event';
350
176
  /**
351
177
  * Interaction event types emitted via 'ui-event'.
352
178
  * These map to user-facing prompts (confirm on device, open app, etc.).
@@ -410,16 +236,34 @@ interface ConnectorEventMap {
410
236
  'device-disconnect': {
411
237
  connectId: string;
412
238
  };
239
+ features: {
240
+ device: ConnectorDevice & {
241
+ features: Record<string, unknown>;
242
+ };
243
+ };
244
+ 'device-trezor-thp-credentials-changed': {
245
+ connectId: string;
246
+ deviceId?: string;
247
+ credentials: Record<string, unknown>[];
248
+ };
413
249
  'ui-request': {
414
250
  type: string;
415
251
  payload?: unknown;
416
252
  };
417
253
  'ui-event': ConnectorUiEvent;
418
254
  }
255
+ interface ConnectorSearchDevicesOptions {
256
+ /**
257
+ * Wait for every child transport in a fused connector. Default discovery can
258
+ * return shortly after USB appears so BLE does not slow down USB flows;
259
+ * binding pickers can opt in when they need BLE candidates too.
260
+ */
261
+ waitForAll?: boolean;
262
+ }
419
263
  interface IConnector {
420
264
  /** Physical connection type this connector uses. Fixed at construction. */
421
265
  readonly connectionType: ConnectionType;
422
- searchDevices(): Promise<ConnectorDevice[]>;
266
+ searchDevices(options?: ConnectorSearchDevicesOptions): Promise<ConnectorDevice[]>;
423
267
  connect(deviceId?: string): Promise<ConnectorSession>;
424
268
  disconnect(sessionId: string): Promise<void>;
425
269
  call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
@@ -429,10 +273,12 @@ interface IConnector {
429
273
  on<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
430
274
  off<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
431
275
  reset(): void;
276
+ setKnownCredentials?(credentials: unknown[]): Promise<void> | void;
432
277
  }
433
278
  interface IHardwareBridge {
434
279
  searchDevices(params: {
435
280
  vendor: VendorType;
281
+ options?: ConnectorSearchDevicesOptions;
436
282
  }): Promise<ConnectorDevice[]>;
437
283
  connect(params: {
438
284
  vendor: VendorType;
@@ -473,6 +319,15 @@ interface IHardwareBridge {
473
319
  type: ConnectorEventType;
474
320
  data: unknown;
475
321
  }) => void): void;
322
+ /**
323
+ * Warm-load vendor-specific persisted credentials. Currently only Trezor
324
+ * uses this (THP `knownCredentials`); the bridge implementation can
325
+ * dispatch on `vendor` and route to the right connector instance.
326
+ */
327
+ setKnownCredentials?(params: {
328
+ vendor: VendorType;
329
+ credentials: unknown[];
330
+ }): Promise<void> | void;
476
331
  }
477
332
  /**
478
333
  * Adapt an IHardwareBridge (multi-vendor backend) into a single-vendor IConnector.
@@ -499,6 +354,7 @@ declare function serializeConnectorError(err: unknown): ConnectorSerializedError
499
354
  * unchanged. The Result shape stays confined to the connector boundary.
500
355
  */
501
356
  declare function rehydrateConnectorError(error: ConnectorSerializedError): Error;
357
+ declare function createCombinedConnector(connectors: IConnector[]): IConnector;
502
358
 
503
359
  declare const DEVICE_EVENT = "DEVICE_EVENT";
504
360
  /** Events originating from the hardware device. */
@@ -506,9 +362,21 @@ declare const DEVICE: {
506
362
  readonly CONNECT: "device-connect";
507
363
  readonly DISCONNECT: "device-disconnect";
508
364
  readonly CHANGED: "device-changed";
365
+ readonly FEATURES: "features";
366
+ /**
367
+ * Trezor-only. Emitted after a successful THP handshake that minted or
368
+ * refreshed pairing credentials. The host should persist `credentials`
369
+ * keyed by `deviceId` and feed them back into the connector on the next
370
+ * connect to skip the CodeEntry/QrCode/NFC pairing UX.
371
+ *
372
+ * The `TREZOR_` prefix mirrors `UI_REQUEST.REQUEST_TREZOR_THP_PAIRING` —
373
+ * vendor-specific events live in the shared event taxonomy but are named
374
+ * so hosts can ignore them when they don't drive Trezor hardware.
375
+ */
376
+ readonly TREZOR_THP_CREDENTIALS_CHANGED: "device-trezor-thp-credentials-changed";
509
377
  };
510
378
 
511
- interface BtcGetAddressParams {
379
+ interface BtcGetAddressParams extends PassphraseStateAware {
512
380
  path: string;
513
381
  coin?: string;
514
382
  showOnDevice?: boolean;
@@ -520,7 +388,7 @@ interface BtcAddress {
520
388
  address: string;
521
389
  path: string;
522
390
  }
523
- interface BtcGetPublicKeyParams {
391
+ interface BtcGetPublicKeyParams extends PassphraseStateAware {
524
392
  path: string;
525
393
  coin?: string;
526
394
  showOnDevice?: boolean;
@@ -534,14 +402,19 @@ interface BtcPublicKey {
534
402
  path: string;
535
403
  depth: number;
536
404
  }
537
- interface BtcSignTxParams {
405
+ interface BtcSignTxParams extends PassphraseStateAware {
538
406
  psbt?: string;
539
407
  inputs?: BtcTxInput[];
540
408
  outputs?: BtcTxOutput[];
409
+ paymentRequests?: BtcPaymentRequest[];
541
410
  refTxs?: BtcRefTransaction[];
542
411
  coin: string;
543
412
  locktime?: number;
544
413
  version?: number;
414
+ timestamp?: number;
415
+ expiry?: number;
416
+ versionGroupId?: number;
417
+ branchId?: number;
545
418
  /** Account-level derivation path (e.g. "84'/0'/0'") for wallet template. */
546
419
  path?: string;
547
420
  }
@@ -552,12 +425,51 @@ interface BtcTxInput {
552
425
  amount: string;
553
426
  scriptType?: 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr';
554
427
  sequence?: number;
428
+ origHash?: string;
429
+ origIndex?: number;
430
+ scriptSig?: string;
431
+ witness?: string;
432
+ ownershipProof?: string;
433
+ commitmentData?: string;
555
434
  }
556
435
  interface BtcTxOutput {
557
436
  address?: string;
558
437
  path?: string;
438
+ opReturnData?: string;
559
439
  amount: string;
560
440
  scriptType?: 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr';
441
+ paymentReqIndex?: number;
442
+ origHash?: string;
443
+ origIndex?: number;
444
+ }
445
+ interface BtcPaymentRequestMemo {
446
+ textMemo?: {
447
+ text: string;
448
+ };
449
+ textDetailsMemo?: {
450
+ title: string;
451
+ text: string;
452
+ };
453
+ refundMemo?: {
454
+ address: string;
455
+ addressN?: number[];
456
+ mac: string;
457
+ };
458
+ coinPurchaseMemo?: {
459
+ coinType: number;
460
+ amount: string;
461
+ address: string;
462
+ addressN?: number[];
463
+ mac: string;
464
+ };
465
+ }
466
+ interface BtcPaymentRequest {
467
+ nonce?: string;
468
+ recipientName: string;
469
+ memos?: BtcPaymentRequestMemo[];
470
+ /** Decimal string in satoshis/subunits; SDK encodes it as SLIP-24 uint64 LE hex. */
471
+ amount?: string;
472
+ signature: string;
561
473
  }
562
474
  interface BtcRefTransaction {
563
475
  hash: string;
@@ -573,6 +485,15 @@ interface BtcRefTransaction {
573
485
  scriptPubKey: string;
574
486
  }>;
575
487
  locktime: number;
488
+ /** Original transaction inputs used by Trezor RBF verification (TXORIGINPUT). */
489
+ origInputs?: BtcTxInput[];
490
+ /** Original transaction outputs used by Trezor RBF verification (TXORIGOUTPUT). */
491
+ origOutputs?: BtcTxOutput[];
492
+ extraData?: string;
493
+ timestamp?: number;
494
+ expiry?: number;
495
+ versionGroupId?: number;
496
+ branchId?: number;
576
497
  }
577
498
  interface BtcSignedTx {
578
499
  serializedTx: string;
@@ -580,7 +501,7 @@ interface BtcSignedTx {
580
501
  signatures?: string[];
581
502
  txid?: string;
582
503
  }
583
- interface BtcSignPsbtParams {
504
+ interface BtcSignPsbtParams extends PassphraseStateAware {
584
505
  psbt: string;
585
506
  coin?: string;
586
507
  /** Account-level derivation path (e.g. "84'/0'/0'") for wallet template. */
@@ -589,10 +510,12 @@ interface BtcSignPsbtParams {
589
510
  interface BtcSignedPsbt {
590
511
  signedPsbt: string;
591
512
  }
592
- interface BtcSignMsgParams {
513
+ interface BtcSignMsgParams extends PassphraseStateAware {
593
514
  path: string;
594
515
  message: string;
595
516
  coin?: string;
517
+ hex?: boolean;
518
+ noScriptType?: boolean;
596
519
  }
597
520
  interface BtcSignature {
598
521
  signature: string;
@@ -600,17 +523,17 @@ interface BtcSignature {
600
523
  address?: string;
601
524
  }
602
525
  interface IBtcMethods {
603
- btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
604
- btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
605
- btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
606
- btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
607
- btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
608
- btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
526
+ btcGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<BtcGetAddressParams>>): Promise<Response<BtcAddress>>;
527
+ btcGetPublicKey(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<BtcGetPublicKeyParams>>): Promise<Response<BtcPublicKey>>;
528
+ btcSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<BtcSignTxParams>>): Promise<Response<BtcSignedTx>>;
529
+ btcSignPsbt(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<BtcSignPsbtParams>>): Promise<Response<BtcSignedPsbt>>;
530
+ btcSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<BtcSignMsgParams>>): Promise<Response<BtcSignature>>;
531
+ btcGetMasterFingerprint(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCommonCallParams>): Promise<Response<{
609
532
  masterFingerprint: string;
610
533
  }>>;
611
534
  }
612
535
 
613
- interface SolGetAddressParams {
536
+ interface SolGetAddressParams extends PassphraseStateAware {
614
537
  path: string;
615
538
  showOnDevice?: boolean;
616
539
  }
@@ -619,11 +542,12 @@ interface SolAddress {
619
542
  address: string;
620
543
  path: string;
621
544
  }
622
- interface SolSignTxParams {
545
+ interface SolSignTxParams extends PassphraseStateAware {
623
546
  path: string;
624
547
  /** Hex-encoded serialized transaction bytes (no 0x prefix) */
625
548
  serializedTx: string;
626
549
  additionalInfo?: {
550
+ encodedToken?: ArrayBuffer;
627
551
  tokenAccountsInfos?: Array<{
628
552
  baseAddress: string;
629
553
  tokenProgram: string;
@@ -636,7 +560,7 @@ interface SolSignedTx {
636
560
  /** Hex-encoded Ed25519 signature (no 0x prefix) */
637
561
  signature: string;
638
562
  }
639
- interface SolSignMsgParams {
563
+ interface SolSignMsgParams extends PassphraseStateAware {
640
564
  path: string;
641
565
  /** Message bytes as hex string (no 0x prefix) */
642
566
  message: string;
@@ -646,12 +570,12 @@ interface SolSignature {
646
570
  signature: string;
647
571
  }
648
572
  interface ISolMethods {
649
- solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
650
- solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
651
- solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
573
+ solGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<SolGetAddressParams>>): Promise<Response<SolAddress>>;
574
+ solSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<SolSignTxParams>>): Promise<Response<SolSignedTx>>;
575
+ solSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<SolSignMsgParams>>): Promise<Response<SolSignature>>;
652
576
  }
653
577
 
654
- interface TronGetAddressParams {
578
+ interface TronGetAddressParams extends PassphraseStateAware {
655
579
  path: string;
656
580
  showOnDevice?: boolean;
657
581
  }
@@ -660,16 +584,110 @@ interface TronAddress {
660
584
  address: string;
661
585
  path: string;
662
586
  }
663
- interface TronSignTxParams {
587
+ /** TRON network resource, used by freeze/unfreeze contracts. */
588
+ type TronResource = 'BANDWIDTH' | 'ENERGY';
589
+ interface TronTransferContract {
590
+ /**
591
+ * Recipient address as hex, 0x41-prefixed (`41` + 20-byte hash, 42 hex chars).
592
+ * A leading `0x` is tolerated. Base58 (`T...`) is NOT accepted — convert first.
593
+ */
594
+ toAddress: string;
595
+ /** Amount in sun (1 TRX = 1e6 sun). */
596
+ amount: string | number;
597
+ }
598
+ interface TronTriggerSmartContract {
599
+ /** Smart-contract address, hex 0x41-prefixed. */
600
+ contractAddress: string;
601
+ /** ABI-encoded call data, hex (with or without `0x`). */
602
+ data: string;
603
+ }
604
+ interface TronFreezeBalanceV2Contract {
605
+ /** Amount to freeze, in sun. */
606
+ balance: number;
607
+ resource?: TronResource;
608
+ }
609
+ interface TronUnfreezeBalanceV2Contract {
610
+ /** Amount to unfreeze, in sun. */
611
+ balance: number;
612
+ resource?: TronResource;
613
+ }
614
+ interface TronVote {
615
+ /** Witness (SR) address, hex 0x41-prefixed. */
616
+ voteAddress: string;
617
+ voteCount: number;
618
+ }
619
+ interface TronVoteWitnessContract {
620
+ votes: TronVote[];
621
+ }
622
+ /** Withdraw-expired-unfreeze carries no fields beyond the implicit owner. */
623
+ type TronWithdrawExpireUnfreezeContract = Record<string, never>;
624
+ /**
625
+ * Exactly one field must be set — mirrors OneKey's `TronTransactionContract`.
626
+ * Only the six contract types Trezor firmware/protobuf supports are exposed.
627
+ */
628
+ interface TronContract {
629
+ transferContract?: TronTransferContract;
630
+ triggerSmartContract?: TronTriggerSmartContract;
631
+ freezeBalanceV2Contract?: TronFreezeBalanceV2Contract;
632
+ unfreezeBalanceV2Contract?: TronUnfreezeBalanceV2Contract;
633
+ voteWitnessContract?: TronVoteWitnessContract;
634
+ withdrawExpireUnfreezeContract?: TronWithdrawExpireUnfreezeContract;
635
+ }
636
+ /**
637
+ * Cross-vendor TRON sign params. Adapters consume different shapes:
638
+ *
639
+ * - **Ledger** signs the serialized transaction directly → needs `rawTxHex`.
640
+ * - **Trezor** runs a two-step contract flow → needs the structured fields
641
+ * (`ownerAddress` + `refBlock*` + `contract` …), mirroring OneKey hd-core.
642
+ *
643
+ * Both groups are optional at the type level; provide whichever your target
644
+ * vendor needs (or both for a vendor-agnostic call). Each adapter validates the
645
+ * fields it requires at runtime and ignores the rest — neither re-decodes the
646
+ * other's representation.
647
+ */
648
+ interface TronSignTxParams extends PassphraseStateAware {
664
649
  path: string;
665
- /** Protobuf-encoded raw transaction hex (no 0x prefix) */
666
- rawTxHex: string;
650
+ /**
651
+ * Protobuf-encoded raw TRON transaction, hex (with or without `0x`).
652
+ * Consumed by Ledger; ignored by Trezor.
653
+ */
654
+ rawTxHex?: string;
655
+ /**
656
+ * The signer's own TRON address, hex 0x41-prefixed. Required by Trezor
657
+ * (its contract messages carry an explicit `owner_address`); Ledger derives
658
+ * it from `rawTxHex`.
659
+ */
660
+ ownerAddress?: string;
661
+ /** Last 2 bytes of the reference block height, hex (4 chars). Trezor. */
662
+ refBlockBytes?: string;
663
+ /** Middle 8 bytes of the reference block hash, hex (16 chars). Trezor. */
664
+ refBlockHash?: string;
665
+ /** Expiration timestamp, milliseconds. Trezor. */
666
+ expiration?: number;
667
+ /** Transaction timestamp, milliseconds. Trezor. */
668
+ timestamp?: number;
669
+ /** Energy fee cap in sun (TriggerSmartContract only). Trezor. */
670
+ feeLimit?: number;
671
+ /** Optional memo/data, hex (with or without `0x`). Trezor. */
672
+ data?: string;
673
+ /** Exactly one contract — required by Trezor. */
674
+ contract?: TronContract;
667
675
  }
668
676
  interface TronSignedTx {
669
677
  /** 65-byte hex-encoded signature (no 0x prefix) */
670
678
  signature: string;
679
+ /**
680
+ * The transaction's `raw_data`, re-encoded host-side from the structured
681
+ * fields the device signed (hex, no prefix). The signature covers exactly
682
+ * this serialization, so callers should broadcast THIS rather than a
683
+ * pre-existing raw_data blob. Present only for contract types the host can
684
+ * re-encode (transfer / triggerSmart); `undefined` otherwise. Despite the
685
+ * historic `serializedTx` name, this is the TRON `raw_data_hex` payload, not
686
+ * trezor-suite's full broadcast transaction envelope.
687
+ */
688
+ serializedTx?: string;
671
689
  }
672
- interface TronSignMsgParams {
690
+ interface TronSignMsgParams extends PassphraseStateAware {
673
691
  path: string;
674
692
  /** Message hex (no 0x prefix) */
675
693
  messageHex: string;
@@ -679,9 +697,9 @@ interface TronSignature {
679
697
  signature: string;
680
698
  }
681
699
  interface ITronMethods {
682
- tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
683
- tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
684
- tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
700
+ tronGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronGetAddressParams>>): Promise<Response<TronAddress>>;
701
+ tronSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignTxParams>>): Promise<Response<TronSignedTx>>;
702
+ tronSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignMsgParams>>): Promise<Response<TronSignature>>;
685
703
  }
686
704
 
687
705
  /**
@@ -710,6 +728,85 @@ declare const SDK: {
710
728
  readonly DEVICE_INTERACTION: "device-interaction";
711
729
  };
712
730
 
731
+ type HardwareMethodMetadata = {
732
+ chain: ChainForFingerprint;
733
+ allNetwork: boolean;
734
+ };
735
+ declare const HARDWARE_METHOD_CATALOG: {
736
+ readonly evmGetAddress: {
737
+ readonly chain: "evm";
738
+ readonly allNetwork: true;
739
+ };
740
+ readonly evmSignTransaction: {
741
+ readonly chain: "evm";
742
+ readonly allNetwork: false;
743
+ };
744
+ readonly evmSignMessage: {
745
+ readonly chain: "evm";
746
+ readonly allNetwork: false;
747
+ };
748
+ readonly evmSignTypedData: {
749
+ readonly chain: "evm";
750
+ readonly allNetwork: false;
751
+ };
752
+ readonly btcGetAddress: {
753
+ readonly chain: "btc";
754
+ readonly allNetwork: true;
755
+ };
756
+ readonly btcGetPublicKey: {
757
+ readonly chain: "btc";
758
+ readonly allNetwork: true;
759
+ };
760
+ readonly btcSignTransaction: {
761
+ readonly chain: "btc";
762
+ readonly allNetwork: false;
763
+ };
764
+ readonly btcSignPsbt: {
765
+ readonly chain: "btc";
766
+ readonly allNetwork: false;
767
+ };
768
+ readonly btcSignMessage: {
769
+ readonly chain: "btc";
770
+ readonly allNetwork: false;
771
+ };
772
+ readonly btcGetMasterFingerprint: {
773
+ readonly chain: "btc";
774
+ readonly allNetwork: false;
775
+ };
776
+ readonly solGetAddress: {
777
+ readonly chain: "sol";
778
+ readonly allNetwork: true;
779
+ };
780
+ readonly solSignTransaction: {
781
+ readonly chain: "sol";
782
+ readonly allNetwork: false;
783
+ };
784
+ readonly solSignMessage: {
785
+ readonly chain: "sol";
786
+ readonly allNetwork: false;
787
+ };
788
+ readonly tronGetAddress: {
789
+ readonly chain: "tron";
790
+ readonly allNetwork: true;
791
+ };
792
+ readonly tronSignTransaction: {
793
+ readonly chain: "tron";
794
+ readonly allNetwork: false;
795
+ };
796
+ readonly tronSignMessage: {
797
+ readonly chain: "tron";
798
+ readonly allNetwork: false;
799
+ };
800
+ };
801
+ type HardwareMethodName = keyof typeof HARDWARE_METHOD_CATALOG;
802
+ type AllNetworkMethodName = {
803
+ [K in HardwareMethodName]: (typeof HARDWARE_METHOD_CATALOG)[K]['allNetwork'] extends true ? K : never;
804
+ }[HardwareMethodName];
805
+ declare const ALL_NETWORK_METHOD_NAMES: AllNetworkMethodName[];
806
+ declare function getHardwareMethodMetadata(method: string): HardwareMethodMetadata | undefined;
807
+ declare function isAllNetworkMethodName(method: string): method is AllNetworkMethodName;
808
+ declare function getAllNetworkMethodChain(method: AllNetworkMethodName): ChainForFingerprint;
809
+
713
810
  /**
714
811
  * Wallet-level `ui-event` variants. Same shape as `ConnectorUiEvent` except
715
812
  * the AppInstallProgress variant's payload is re-keyed by the adapter from
@@ -726,6 +823,28 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
726
823
  };
727
824
  };
728
825
  type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
826
+ type TrezorDisplayRotation = 'North' | 'East' | 'South' | 'West';
827
+ type TrezorSafetyCheckLevel = 'Strict' | 'PromptAlways' | 'PromptTemporarily';
828
+ type TrezorDeviceSettingsParams = {
829
+ language?: string;
830
+ label?: string;
831
+ use_passphrase?: boolean;
832
+ homescreen?: string;
833
+ auto_lock_delay_ms?: number;
834
+ display_rotation?: TrezorDisplayRotation;
835
+ passphrase_always_on_device?: boolean;
836
+ safety_checks?: TrezorSafetyCheckLevel;
837
+ experimental_features?: boolean;
838
+ hide_passphrase_from_host?: boolean;
839
+ haptic_feedback?: boolean;
840
+ auto_lock_delay_battery_ms?: number;
841
+ };
842
+ type TrezorBrightnessParams = {
843
+ value?: number;
844
+ };
845
+ type TrezorChangePinParams = {
846
+ remove?: boolean;
847
+ };
729
848
  /**
730
849
  * Cross-chain / cross-vendor options passed alongside any chain method's
731
850
  * own params (the optional last argument). Holds operation-level switches
@@ -740,22 +859,40 @@ interface ICommonCallParams {
740
859
  */
741
860
  autoInstallApp?: boolean;
742
861
  }
862
+ type NullableCallArg<T> = T | null | undefined;
863
+ interface IPassphraseCallParams {
864
+ passphraseState?: string;
865
+ useEmptyPassphrase?: boolean;
866
+ }
867
+ type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
868
+ type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
743
869
  interface AllNetworkAddressParams {
744
870
  network: string;
745
871
  path: string;
746
872
  showOnDevice?: boolean;
747
- methodName: 'evmGetAddress' | 'btcGetAddress' | 'btcGetPublicKey' | 'solGetAddress' | 'tronGetAddress';
873
+ methodName: AllNetworkMethodName;
748
874
  [key: string]: unknown;
749
875
  }
750
- interface AllNetworkGetAddressParams extends ICommonCallParams {
876
+ interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
751
877
  bundle: AllNetworkAddressParams[];
752
878
  }
879
+ type AllNetworkDeviceIdentity = {
880
+ vendor: 'ledger';
881
+ type: 'chainFingerprint';
882
+ chain: ChainForFingerprint;
883
+ value: string;
884
+ } | {
885
+ vendor: 'trezor';
886
+ type: 'deviceId';
887
+ value: string;
888
+ };
753
889
  type AllNetworkAddressResponsePayload = Record<string, unknown> & {
754
890
  error?: string;
755
891
  code?: HardwareErrorCode | number;
756
892
  errorCode?: string | number;
757
893
  connectId?: string;
758
894
  deviceId?: string;
895
+ deviceIdentity?: AllNetworkDeviceIdentity;
759
896
  chainFingerprint?: string;
760
897
  chainFingerprintChain?: ChainForFingerprint;
761
898
  params?: Record<string, unknown>;
@@ -780,11 +917,30 @@ type DeviceEvent = {
780
917
  } | {
781
918
  type: typeof DEVICE.CHANGED;
782
919
  payload: DeviceInfo;
920
+ } | {
921
+ type: typeof DEVICE.FEATURES;
922
+ device: DeviceInfo & {
923
+ features: Record<string, unknown>;
924
+ };
925
+ payload: {
926
+ device: DeviceInfo & {
927
+ features: Record<string, unknown>;
928
+ };
929
+ };
930
+ } | {
931
+ type: typeof DEVICE.TREZOR_THP_CREDENTIALS_CHANGED;
932
+ payload: {
933
+ connectId: string;
934
+ deviceId?: string;
935
+ credentials: Record<string, unknown>[];
936
+ };
783
937
  };
784
938
  type UiRequestEvent = {
785
939
  type: typeof UI_REQUEST.REQUEST_PIN;
786
940
  payload: {
787
- device: DeviceInfo;
941
+ device?: DeviceInfo;
942
+ connectId?: string;
943
+ type?: string;
788
944
  };
789
945
  } | {
790
946
  type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
@@ -851,6 +1007,14 @@ type UiRequestEvent = {
851
1007
  vendor: string;
852
1008
  appName: string;
853
1009
  };
1010
+ } | {
1011
+ type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
1012
+ payload: {
1013
+ connectId: string;
1014
+ availableMethods: number[];
1015
+ selectedMethod: number;
1016
+ nfcData?: string;
1017
+ };
854
1018
  } | {
855
1019
  type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
856
1020
  payload: Record<string, never>;
@@ -901,16 +1065,40 @@ interface HardwareEventMap {
901
1065
  type: typeof DEVICE.CHANGED;
902
1066
  payload: DeviceInfo;
903
1067
  };
1068
+ [DEVICE.FEATURES]: {
1069
+ type: typeof DEVICE.FEATURES;
1070
+ device: DeviceInfo & {
1071
+ features: Record<string, unknown>;
1072
+ };
1073
+ payload: {
1074
+ device: DeviceInfo & {
1075
+ features: Record<string, unknown>;
1076
+ };
1077
+ };
1078
+ };
1079
+ [DEVICE.TREZOR_THP_CREDENTIALS_CHANGED]: {
1080
+ type: typeof DEVICE.TREZOR_THP_CREDENTIALS_CHANGED;
1081
+ payload: {
1082
+ connectId: string;
1083
+ deviceId?: string;
1084
+ credentials: Record<string, unknown>[];
1085
+ };
1086
+ };
904
1087
  [UI_REQUEST.REQUEST_PIN]: {
905
1088
  type: typeof UI_REQUEST.REQUEST_PIN;
906
1089
  payload: {
907
- device: DeviceInfo;
1090
+ device?: DeviceInfo;
1091
+ connectId?: string;
1092
+ type?: string;
908
1093
  };
909
1094
  };
910
1095
  [UI_REQUEST.REQUEST_PASSPHRASE]: {
911
1096
  type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
912
1097
  payload: {
913
- device: DeviceInfo;
1098
+ device?: DeviceInfo;
1099
+ connectId?: string;
1100
+ passphraseState?: string;
1101
+ useEmptyPassphrase?: boolean;
914
1102
  };
915
1103
  };
916
1104
  [UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
@@ -976,6 +1164,15 @@ interface HardwareEventMap {
976
1164
  appName: string;
977
1165
  };
978
1166
  };
1167
+ [UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
1168
+ type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
1169
+ payload: {
1170
+ connectId: string;
1171
+ availableMethods: number[];
1172
+ selectedMethod: number;
1173
+ nfcData?: string;
1174
+ };
1175
+ };
979
1176
  [UI_REQUEST.CLOSE_UI_WINDOW]: {
980
1177
  type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
981
1178
  payload: Record<string, never>;
@@ -1006,7 +1203,41 @@ interface HardwareEventMap {
1006
1203
  };
1007
1204
  };
1008
1205
  }
1009
- interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods {
1206
+ interface IDeviceManagerMethods {
1207
+ getFeatures?(connectId: string): Promise<Response<Record<string, unknown>>>;
1208
+ deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams): Promise<Response<Record<string, unknown>>>;
1209
+ setBrightness?(connectId: string, params?: TrezorBrightnessParams): Promise<Response<Record<string, unknown>>>;
1210
+ changePin?(connectId: string, params?: TrezorChangePinParams): Promise<Response<Record<string, unknown>>>;
1211
+ wipeDevice?(connectId: string): Promise<Response<Record<string, unknown>>>;
1212
+ }
1213
+ interface IWalletStateMethods {
1214
+ /**
1215
+ * Resolve the device's active passphrase wallet identity (`passphraseState`).
1216
+ * Today this is the compressed public key derived at `m/44'/0'/0'`, not the
1217
+ * 4-byte master fingerprint. Two modes:
1218
+ *
1219
+ * - **Discover** (no `passphraseState`): for a **standard wallet** (passphrase
1220
+ * protection off) returns `null` — there's one wallet and nothing to pin.
1221
+ * The SDK may still create a THP app session and derive once so it can
1222
+ * unlock and re-read fresh Features, but it does not ask for a passphrase.
1223
+ * For a **passphrase wallet** it creates a fresh session (prompts the user),
1224
+ * derives its state, and returns it so the host can persist the wallet.
1225
+ * Mirrors OneKey's null-for-standard convention.
1226
+ * - **Verify** (`passphraseState` given): align the device to that wallet and
1227
+ * confirm the derived state matches. Fails with `PassphraseStateMismatch`
1228
+ * when the entered passphrase yields a different wallet.
1229
+ *
1230
+ * SECURITY: every wallet-bound op that carries a `passphraseState` (getAddress,
1231
+ * sign, …) creates a fresh session, re-derives, and confirms the state before
1232
+ * the chain method runs. Standard wallets should pass `useEmptyPassphrase` so
1233
+ * the host can explicitly create the empty-passphrase session.
1234
+ *
1235
+ * Optional: vendors without host-managed passphrase sessions (Ledger) omit
1236
+ * it. Implemented by `TrezorAdapter`.
1237
+ */
1238
+ getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
1239
+ }
1240
+ interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
1010
1241
  readonly vendor: string;
1011
1242
  readonly activeTransport: TransportType | null;
1012
1243
  init(config: TConfig): Promise<void>;
@@ -1047,12 +1278,19 @@ interface SearchDevicesOptions {
1047
1278
  * should leave this false so an active session can still be reused.
1048
1279
  */
1049
1280
  resetSession?: boolean;
1281
+ /**
1282
+ * Wait for every physical transport behind a fused connector. Use this for
1283
+ * transport binding/pairing UIs that must show BLE candidates even when USB
1284
+ * was discovered first.
1285
+ */
1286
+ waitForAllTransports?: boolean;
1050
1287
  }
1051
1288
 
1052
- interface EvmGetAddressParams {
1289
+ interface EvmGetAddressParams extends PassphraseStateAware {
1053
1290
  path: string;
1054
1291
  showOnDevice?: boolean;
1055
1292
  chainId?: number;
1293
+ ethereumDefinitions?: EvmEthereumDefinitions;
1056
1294
  }
1057
1295
  interface EvmAddress {
1058
1296
  address: string;
@@ -1060,7 +1298,7 @@ interface EvmAddress {
1060
1298
  /** Device-reported secp256k1 public key; populated when the transport exposes it. */
1061
1299
  publicKey?: string;
1062
1300
  }
1063
- interface EvmSignTxParams {
1301
+ interface EvmSignTxParams extends PassphraseStateAware {
1064
1302
  path: string;
1065
1303
  /**
1066
1304
  * RLP-serialized transaction hex (0x-prefixed or plain).
@@ -1075,6 +1313,7 @@ interface EvmSignTxParams {
1075
1313
  nonce?: string;
1076
1314
  gasLimit?: string;
1077
1315
  gasPrice?: string;
1316
+ txType?: number;
1078
1317
  maxFeePerGas?: string;
1079
1318
  maxPriorityFeePerGas?: string;
1080
1319
  accessList?: Array<{
@@ -1082,6 +1321,43 @@ interface EvmSignTxParams {
1082
1321
  storageKeys: string[];
1083
1322
  }>;
1084
1323
  data?: string;
1324
+ paymentRequest?: EvmPaymentRequest;
1325
+ ethereumDefinitions?: EvmEthereumDefinitions;
1326
+ }
1327
+ interface EvmEthereumDefinitions {
1328
+ /** Trezor Ethereum network definition, as raw bytes or hex. */
1329
+ encodedNetwork?: ArrayBuffer | string;
1330
+ /** Trezor Ethereum token definition, as raw bytes or hex. */
1331
+ encodedToken?: ArrayBuffer | string;
1332
+ }
1333
+ interface EvmPaymentRequestMemo {
1334
+ textMemo?: {
1335
+ text: string;
1336
+ };
1337
+ textDetailsMemo?: {
1338
+ title: string;
1339
+ text: string;
1340
+ };
1341
+ refundMemo?: {
1342
+ address: string;
1343
+ addressN?: number[];
1344
+ mac: string;
1345
+ };
1346
+ coinPurchaseMemo?: {
1347
+ coinType: number;
1348
+ amount: string;
1349
+ address: string;
1350
+ addressN?: number[];
1351
+ mac: string;
1352
+ };
1353
+ }
1354
+ interface EvmPaymentRequest {
1355
+ nonce?: string;
1356
+ recipientName: string;
1357
+ memos?: EvmPaymentRequestMemo[];
1358
+ /** Decimal string in subunits; SDK encodes it as SLIP-24 uint256 LE hex. */
1359
+ amount?: string;
1360
+ signature: string;
1085
1361
  }
1086
1362
  interface EvmSignedTx {
1087
1363
  /** Recovery id as `0x`-prefixed hex string. */
@@ -1092,16 +1368,20 @@ interface EvmSignedTx {
1092
1368
  s: string;
1093
1369
  serializedTx?: string;
1094
1370
  }
1095
- interface EvmSignMsgParams {
1371
+ interface EvmSignMsgParams extends PassphraseStateAware {
1096
1372
  path: string;
1097
1373
  message: string;
1374
+ chainId?: number;
1098
1375
  hex?: boolean;
1376
+ ethereumDefinitions?: EvmEthereumDefinitions;
1099
1377
  }
1100
1378
  type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
1101
- interface EvmSignTypedDataFull {
1379
+ interface EvmSignTypedDataFull extends PassphraseStateAware {
1102
1380
  path: string;
1381
+ chainId?: number;
1103
1382
  /** Defaults to `'full'` when omitted. */
1104
1383
  mode?: 'full';
1384
+ ethereumDefinitions?: EvmEthereumDefinitions;
1105
1385
  data: {
1106
1386
  domain: EIP712Domain;
1107
1387
  types: Record<string, Array<{
@@ -1112,12 +1392,22 @@ interface EvmSignTypedDataFull {
1112
1392
  message: Record<string, unknown>;
1113
1393
  };
1114
1394
  metamaskV4Compat?: boolean;
1395
+ showMessageHash?: boolean;
1396
+ /**
1397
+ * Optional host-computed hashes. Core Trezor models still use full typed-data
1398
+ * signing for display, while Trezor One can fall back to typed-hash signing
1399
+ * when firmware cannot compute the hashes itself.
1400
+ */
1401
+ domainSeparatorHash?: string;
1402
+ messageHash?: string;
1115
1403
  }
1116
- interface EvmSignTypedDataHash {
1404
+ interface EvmSignTypedDataHash extends PassphraseStateAware {
1117
1405
  path: string;
1406
+ chainId?: number;
1118
1407
  mode: 'hash';
1119
1408
  domainSeparatorHash: string;
1120
1409
  messageHash: string;
1410
+ ethereumDefinitions?: EvmEthereumDefinitions;
1121
1411
  }
1122
1412
  interface EIP712Domain {
1123
1413
  name?: string;
@@ -1133,10 +1423,10 @@ interface EvmSignature {
1133
1423
  address?: string;
1134
1424
  }
1135
1425
  interface IEvmMethods {
1136
- evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
1137
- evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
1138
- evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
1139
- evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
1426
+ evmGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmGetAddressParams>>): Promise<Response<EvmAddress>>;
1427
+ evmSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTxParams>>): Promise<Response<EvmSignedTx>>;
1428
+ evmSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignMsgParams>>): Promise<Response<EvmSignature>>;
1429
+ evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
1140
1430
  }
1141
1431
 
1142
1432
  /**
@@ -1252,32 +1542,8 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
1252
1542
  emit<K extends keyof TMap & string>(event: K, data: TMap[K]): void;
1253
1543
  emit(event: string, data: unknown): void;
1254
1544
  removeAllListeners(): void;
1255
- }
1256
-
1257
- /** 10 min — every UI request is human-in-the-loop; bias toward "wait long". */
1258
- declare const UI_REQUEST_DEFAULT_TIMEOUT_MS = 600000;
1259
- declare const UI_REQUEST_PREEMPTED_TAG = "UiRequestPreempted";
1260
- declare const UI_REQUEST_CANCELLED_TAG = "UiRequestCancelled";
1261
- declare const UI_REQUEST_TIMEOUT_TAG = "UiRequestTimeout";
1262
- /**
1263
- * Per-type single-slot registry for adapter-level UI requests. A new `wait`
1264
- * of the same type supersedes (rejects) the prior pending entry. With the
1265
- * job queue running globally serially, cross-type collisions don't occur in
1266
- * normal flow — same-type preemption is a defensive measure for callers
1267
- * that fire the same request twice without waiting on the first.
1268
- *
1269
- * Unknown response types are dropped silently so the public `uiResponse`
1270
- * entry never throws.
1271
- */
1272
- declare class UiRequestRegistry {
1273
- private pending;
1274
- wait<T = unknown>(requestType: string, options?: {
1275
- timeoutMs?: number;
1276
- }): Promise<T>;
1277
- resolve(responseType: string, payload: unknown): void;
1278
- cancel(requestType?: string): void;
1279
- reset(): void;
1280
- hasPending(requestType?: string): boolean;
1545
+ /** Number of listeners registered for `event`. 0 if none. */
1546
+ listenerCount(event: string): number;
1281
1547
  }
1282
1548
 
1283
1549
  /**
@@ -1300,11 +1566,32 @@ declare function hexToBytes(hex: string): Uint8Array;
1300
1566
  /** Convert a Uint8Array to a hex string (no 0x prefix). */
1301
1567
  declare function bytesToHex(bytes: Uint8Array): string;
1302
1568
 
1303
- /**
1304
- * Enrich a hardware error message with actionable recovery hints.
1305
- * Shared across adapters (Ledger, Trezor, etc.).
1306
- */
1307
- declare function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string;
1569
+ type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger';
1570
+ type HardwareDeviceIdentityInput = {
1571
+ name?: string | null;
1572
+ localName?: string | null;
1573
+ bleName?: string | null;
1574
+ model?: string | null;
1575
+ modelName?: string | null;
1576
+ type?: string | null;
1577
+ productName?: string | null;
1578
+ manufacturerName?: string | null;
1579
+ vendor?: number | string | null;
1580
+ vendorId?: number | null;
1581
+ product?: number | string | null;
1582
+ productId?: number | null;
1583
+ label?: string | null;
1584
+ fw_vendor?: string | null;
1585
+ internal_model?: string | null;
1586
+ onekey_version?: string | null;
1587
+ onekey_device_type?: string | null;
1588
+ onekey_serial?: string | null;
1589
+ serviceUUIDs?: string[] | null;
1590
+ advertisedServiceUuids?: string[] | null;
1591
+ serviceUuids?: string[] | null;
1592
+ };
1593
+ declare function detectHardwareVendorFromDescriptor(input: HardwareDeviceIdentityInput): DetectableHardwareVendor | undefined;
1594
+ declare function isKnownNonTargetHardwareVendor(input: HardwareDeviceIdentityInput, targetVendor: DetectableHardwareVendor): boolean;
1308
1595
 
1309
1596
  /**
1310
1597
  * Generic batch call with progress reporting.
@@ -1315,4 +1602,35 @@ declare function batchCall<TParam, TResult>(params: TParam[], callFn: (p: TParam
1315
1602
  total: number;
1316
1603
  }) => void): Promise<Response<TResult[]>>;
1317
1604
 
1318
- export { type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkGetAddressParams, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_EVENT, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DevicePermissionDeniedReason, type DevicePermissionResponse, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmGetAddressParams, type EvmSignMsgParams, type EvmSignTxParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareUiEvent, type HwkError, type IBtcMethods, type ICommonCallParams, type IConnector, type IEvmMethods, type IHardwareBridge, type IHardwareWallet, type IHwkErrorPayload, type ISolMethods, type ITronMethods, type JobOptions, ORPHAN_ELIGIBLE_ERROR_CODES, type PassphraseResponse, type QrDisplayData, type QrResponseData, type Response, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TronAddress, type TronGetAddressParams, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, TypedEventEmitter, UI_EVENT, UI_REQUEST, UI_REQUEST_CANCELLED_TAG, UI_REQUEST_DEFAULT_TIMEOUT_MS, UI_REQUEST_PREEMPTED_TAG, UI_REQUEST_TIMEOUT_TAG, UI_RESPONSE, type UiRequestEvent, UiRequestRegistry, type UiResponseEvent, type VendorType, batchCall, bytesToHex, compareSemver, createBridgedConnector, createHwkError, deriveDeviceFingerprint, enrichErrorMessage, ensure0x, failure, hexToBytes, padHex64, rehydrateConnectorError, serializeConnectorError, stripHex, success };
1605
+ type AllNetworkCallItemContext = {
1606
+ connectId: string;
1607
+ deviceId: string;
1608
+ method: AllNetworkMethodName;
1609
+ chain: ChainForFingerprint;
1610
+ item: AllNetworkAddressParams;
1611
+ index: number;
1612
+ };
1613
+ type AllNetworkAttachIdentityContext = AllNetworkCallItemContext & {
1614
+ payload: Record<string, unknown>;
1615
+ };
1616
+ type AllNetworkResponseContext = AllNetworkCallItemContext & {
1617
+ response: AllNetworkAddressResponse;
1618
+ };
1619
+ type RunAllNetworkGetAddressOptions = {
1620
+ connectId: string;
1621
+ deviceId: string;
1622
+ params: AllNetworkGetAddressParams;
1623
+ getMethodChain?: (method: AllNetworkMethodName, item: AllNetworkAddressParams) => ChainForFingerprint;
1624
+ normalizeItem?: (method: AllNetworkMethodName, item: AllNetworkAddressParams) => AllNetworkAddressParams;
1625
+ buildUnsupportedNetworkResponse?: (item: AllNetworkAddressParams, method: AllNetworkMethodName) => AllNetworkAddressResponse | undefined;
1626
+ callItem: (context: AllNetworkCallItemContext) => Promise<Response<unknown>>;
1627
+ attachIdentity: (context: AllNetworkAttachIdentityContext) => Promise<AllNetworkAddressResponse>;
1628
+ shouldAbortBundle?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => boolean;
1629
+ buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
1630
+ };
1631
+ declare function runAllNetworkGetAddress({ connectId, deviceId, params, getMethodChain, normalizeItem, buildUnsupportedNetworkResponse, callItem, attachIdentity, shouldAbortBundle, buildTopLevelFailure, }: RunAllNetworkGetAddressOptions): Promise<Response<AllNetworkAddressResponse[]>>;
1632
+ declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
1633
+
1634
+ declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
1635
+
1636
+ export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareUiEvent, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type NullableCallArg, type PassphraseResponse, type PassphraseStateAware, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiResponseEvent, type VendorType, batchCall, buildUnsupportedMethodResponse, bytesToHex, compareSemver, createBridgedConnector, createCombinedConnector, deriveDeviceFingerprint, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hexToBytes, isAllNetworkMethodName, isKnownNonTargetHardwareVendor, padHex64, rehydrateConnectorError, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };