@onekeyfe/hwk-adapter-core 1.1.29-alpha.2 → 1.1.29

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,7 +1,133 @@
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';
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;
5
131
 
6
132
  interface Success<T> {
7
133
  success: true;
@@ -60,38 +186,102 @@ interface DeviceInfo {
60
186
  serialNumber?: string;
61
187
  /** Device capabilities — varies by vendor, model, and connection type */
62
188
  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>;
71
189
  }
72
190
  interface DeviceTarget {
73
191
  connectId: string;
74
192
  deviceId: string;
75
193
  }
76
194
 
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;
195
+ interface QrDisplayData {
196
+ urType: string;
197
+ urData: string;
198
+ animated: boolean;
199
+ }
200
+ interface QrResponseData {
201
+ urType: string;
202
+ urData: string;
93
203
  }
94
204
 
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
+
95
285
  /**
96
286
  * Minimal device info returned during discovery (searchDevices).
97
287
  * At scan time, full DeviceInfo fields like firmwareVersion are not yet available.
@@ -100,15 +290,6 @@ interface ConnectorDevice {
100
290
  connectId: string;
101
291
  deviceId: string;
102
292
  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;
112
293
  /** Machine model id (e.g. "nanoX"). */
113
294
  model?: string;
114
295
  /** Human-readable model name (e.g. "Ledger Nano X"). */
@@ -121,13 +302,6 @@ interface ConnectorDevice {
121
302
  serialNumber?: string;
122
303
  /** Device capabilities — available from scan time */
123
304
  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>;
131
305
  }
132
306
  interface ConnectorSession {
133
307
  sessionId: string;
@@ -172,7 +346,7 @@ type ConnectorCallResult = {
172
346
  success: false;
173
347
  error: ConnectorSerializedError;
174
348
  };
175
- type ConnectorEventType = 'device-connect' | 'device-disconnect' | 'features' | 'device-trezor-thp-credentials-changed' | 'ui-request' | 'ui-event';
349
+ type ConnectorEventType = 'device-connect' | 'device-disconnect' | 'ui-request' | 'ui-event';
176
350
  /**
177
351
  * Interaction event types emitted via 'ui-event'.
178
352
  * These map to user-facing prompts (confirm on device, open app, etc.).
@@ -236,34 +410,16 @@ interface ConnectorEventMap {
236
410
  'device-disconnect': {
237
411
  connectId: string;
238
412
  };
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
- };
249
413
  'ui-request': {
250
414
  type: string;
251
415
  payload?: unknown;
252
416
  };
253
417
  'ui-event': ConnectorUiEvent;
254
418
  }
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
- }
263
419
  interface IConnector {
264
420
  /** Physical connection type this connector uses. Fixed at construction. */
265
421
  readonly connectionType: ConnectionType;
266
- searchDevices(options?: ConnectorSearchDevicesOptions): Promise<ConnectorDevice[]>;
422
+ searchDevices(): Promise<ConnectorDevice[]>;
267
423
  connect(deviceId?: string): Promise<ConnectorSession>;
268
424
  disconnect(sessionId: string): Promise<void>;
269
425
  call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
@@ -273,12 +429,10 @@ interface IConnector {
273
429
  on<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
274
430
  off<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
275
431
  reset(): void;
276
- setKnownCredentials?(credentials: unknown[]): Promise<void> | void;
277
432
  }
278
433
  interface IHardwareBridge {
279
434
  searchDevices(params: {
280
435
  vendor: VendorType;
281
- options?: ConnectorSearchDevicesOptions;
282
436
  }): Promise<ConnectorDevice[]>;
283
437
  connect(params: {
284
438
  vendor: VendorType;
@@ -319,15 +473,6 @@ interface IHardwareBridge {
319
473
  type: ConnectorEventType;
320
474
  data: unknown;
321
475
  }) => 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;
331
476
  }
332
477
  /**
333
478
  * Adapt an IHardwareBridge (multi-vendor backend) into a single-vendor IConnector.
@@ -354,7 +499,6 @@ declare function serializeConnectorError(err: unknown): ConnectorSerializedError
354
499
  * unchanged. The Result shape stays confined to the connector boundary.
355
500
  */
356
501
  declare function rehydrateConnectorError(error: ConnectorSerializedError): Error;
357
- declare function createCombinedConnector(connectors: IConnector[]): IConnector;
358
502
 
359
503
  declare const DEVICE_EVENT = "DEVICE_EVENT";
360
504
  /** Events originating from the hardware device. */
@@ -362,21 +506,9 @@ declare const DEVICE: {
362
506
  readonly CONNECT: "device-connect";
363
507
  readonly DISCONNECT: "device-disconnect";
364
508
  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";
377
509
  };
378
510
 
379
- interface BtcGetAddressParams extends PassphraseStateAware {
511
+ interface BtcGetAddressParams {
380
512
  path: string;
381
513
  coin?: string;
382
514
  showOnDevice?: boolean;
@@ -388,7 +520,7 @@ interface BtcAddress {
388
520
  address: string;
389
521
  path: string;
390
522
  }
391
- interface BtcGetPublicKeyParams extends PassphraseStateAware {
523
+ interface BtcGetPublicKeyParams {
392
524
  path: string;
393
525
  coin?: string;
394
526
  showOnDevice?: boolean;
@@ -402,19 +534,14 @@ interface BtcPublicKey {
402
534
  path: string;
403
535
  depth: number;
404
536
  }
405
- interface BtcSignTxParams extends PassphraseStateAware {
537
+ interface BtcSignTxParams {
406
538
  psbt?: string;
407
539
  inputs?: BtcTxInput[];
408
540
  outputs?: BtcTxOutput[];
409
- paymentRequests?: BtcPaymentRequest[];
410
541
  refTxs?: BtcRefTransaction[];
411
542
  coin: string;
412
543
  locktime?: number;
413
544
  version?: number;
414
- timestamp?: number;
415
- expiry?: number;
416
- versionGroupId?: number;
417
- branchId?: number;
418
545
  /** Account-level derivation path (e.g. "84'/0'/0'") for wallet template. */
419
546
  path?: string;
420
547
  }
@@ -425,51 +552,12 @@ interface BtcTxInput {
425
552
  amount: string;
426
553
  scriptType?: 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr';
427
554
  sequence?: number;
428
- origHash?: string;
429
- origIndex?: number;
430
- scriptSig?: string;
431
- witness?: string;
432
- ownershipProof?: string;
433
- commitmentData?: string;
434
555
  }
435
556
  interface BtcTxOutput {
436
557
  address?: string;
437
558
  path?: string;
438
- opReturnData?: string;
439
559
  amount: string;
440
560
  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;
473
561
  }
474
562
  interface BtcRefTransaction {
475
563
  hash: string;
@@ -485,15 +573,6 @@ interface BtcRefTransaction {
485
573
  scriptPubKey: string;
486
574
  }>;
487
575
  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;
497
576
  }
498
577
  interface BtcSignedTx {
499
578
  serializedTx: string;
@@ -501,7 +580,7 @@ interface BtcSignedTx {
501
580
  signatures?: string[];
502
581
  txid?: string;
503
582
  }
504
- interface BtcSignPsbtParams extends PassphraseStateAware {
583
+ interface BtcSignPsbtParams {
505
584
  psbt: string;
506
585
  coin?: string;
507
586
  /** Account-level derivation path (e.g. "84'/0'/0'") for wallet template. */
@@ -510,12 +589,10 @@ interface BtcSignPsbtParams extends PassphraseStateAware {
510
589
  interface BtcSignedPsbt {
511
590
  signedPsbt: string;
512
591
  }
513
- interface BtcSignMsgParams extends PassphraseStateAware {
592
+ interface BtcSignMsgParams {
514
593
  path: string;
515
594
  message: string;
516
595
  coin?: string;
517
- hex?: boolean;
518
- noScriptType?: boolean;
519
596
  }
520
597
  interface BtcSignature {
521
598
  signature: string;
@@ -523,17 +600,17 @@ interface BtcSignature {
523
600
  address?: string;
524
601
  }
525
602
  interface IBtcMethods {
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<{
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<{
532
609
  masterFingerprint: string;
533
610
  }>>;
534
611
  }
535
612
 
536
- interface SolGetAddressParams extends PassphraseStateAware {
613
+ interface SolGetAddressParams {
537
614
  path: string;
538
615
  showOnDevice?: boolean;
539
616
  }
@@ -542,12 +619,11 @@ interface SolAddress {
542
619
  address: string;
543
620
  path: string;
544
621
  }
545
- interface SolSignTxParams extends PassphraseStateAware {
622
+ interface SolSignTxParams {
546
623
  path: string;
547
624
  /** Hex-encoded serialized transaction bytes (no 0x prefix) */
548
625
  serializedTx: string;
549
626
  additionalInfo?: {
550
- encodedToken?: ArrayBuffer;
551
627
  tokenAccountsInfos?: Array<{
552
628
  baseAddress: string;
553
629
  tokenProgram: string;
@@ -560,7 +636,7 @@ interface SolSignedTx {
560
636
  /** Hex-encoded Ed25519 signature (no 0x prefix) */
561
637
  signature: string;
562
638
  }
563
- interface SolSignMsgParams extends PassphraseStateAware {
639
+ interface SolSignMsgParams {
564
640
  path: string;
565
641
  /** Message bytes as hex string (no 0x prefix) */
566
642
  message: string;
@@ -570,12 +646,12 @@ interface SolSignature {
570
646
  signature: string;
571
647
  }
572
648
  interface ISolMethods {
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>>;
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>>;
576
652
  }
577
653
 
578
- interface TronGetAddressParams extends PassphraseStateAware {
654
+ interface TronGetAddressParams {
579
655
  path: string;
580
656
  showOnDevice?: boolean;
581
657
  }
@@ -584,110 +660,16 @@ interface TronAddress {
584
660
  address: string;
585
661
  path: string;
586
662
  }
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 {
663
+ interface TronSignTxParams {
649
664
  path: 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;
665
+ /** Protobuf-encoded raw transaction hex (no 0x prefix) */
666
+ rawTxHex: string;
675
667
  }
676
668
  interface TronSignedTx {
677
669
  /** 65-byte hex-encoded signature (no 0x prefix) */
678
670
  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;
689
671
  }
690
- interface TronSignMsgParams extends PassphraseStateAware {
672
+ interface TronSignMsgParams {
691
673
  path: string;
692
674
  /** Message hex (no 0x prefix) */
693
675
  messageHex: string;
@@ -697,9 +679,9 @@ interface TronSignature {
697
679
  signature: string;
698
680
  }
699
681
  interface ITronMethods {
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>>;
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>>;
703
685
  }
704
686
 
705
687
  /**
@@ -728,85 +710,6 @@ declare const SDK: {
728
710
  readonly DEVICE_INTERACTION: "device-interaction";
729
711
  };
730
712
 
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
-
810
713
  /**
811
714
  * Wallet-level `ui-event` variants. Same shape as `ConnectorUiEvent` except
812
715
  * the AppInstallProgress variant's payload is re-keyed by the adapter from
@@ -823,28 +726,6 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
823
726
  };
824
727
  };
825
728
  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
- };
848
729
  /**
849
730
  * Cross-chain / cross-vendor options passed alongside any chain method's
850
731
  * own params (the optional last argument). Holds operation-level switches
@@ -859,40 +740,22 @@ interface ICommonCallParams {
859
740
  */
860
741
  autoInstallApp?: boolean;
861
742
  }
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;
869
743
  interface AllNetworkAddressParams {
870
744
  network: string;
871
745
  path: string;
872
746
  showOnDevice?: boolean;
873
- methodName: AllNetworkMethodName;
747
+ methodName: 'evmGetAddress' | 'btcGetAddress' | 'btcGetPublicKey' | 'solGetAddress' | 'tronGetAddress';
874
748
  [key: string]: unknown;
875
749
  }
876
- interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
750
+ interface AllNetworkGetAddressParams extends ICommonCallParams {
877
751
  bundle: AllNetworkAddressParams[];
878
752
  }
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
- };
889
753
  type AllNetworkAddressResponsePayload = Record<string, unknown> & {
890
754
  error?: string;
891
755
  code?: HardwareErrorCode | number;
892
756
  errorCode?: string | number;
893
757
  connectId?: string;
894
758
  deviceId?: string;
895
- deviceIdentity?: AllNetworkDeviceIdentity;
896
759
  chainFingerprint?: string;
897
760
  chainFingerprintChain?: ChainForFingerprint;
898
761
  params?: Record<string, unknown>;
@@ -917,30 +780,11 @@ type DeviceEvent = {
917
780
  } | {
918
781
  type: typeof DEVICE.CHANGED;
919
782
  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
- };
937
783
  };
938
784
  type UiRequestEvent = {
939
785
  type: typeof UI_REQUEST.REQUEST_PIN;
940
786
  payload: {
941
- device?: DeviceInfo;
942
- connectId?: string;
943
- type?: string;
787
+ device: DeviceInfo;
944
788
  };
945
789
  } | {
946
790
  type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
@@ -1007,14 +851,6 @@ type UiRequestEvent = {
1007
851
  vendor: string;
1008
852
  appName: string;
1009
853
  };
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
- };
1018
854
  } | {
1019
855
  type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
1020
856
  payload: Record<string, never>;
@@ -1065,40 +901,16 @@ interface HardwareEventMap {
1065
901
  type: typeof DEVICE.CHANGED;
1066
902
  payload: DeviceInfo;
1067
903
  };
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
- };
1087
904
  [UI_REQUEST.REQUEST_PIN]: {
1088
905
  type: typeof UI_REQUEST.REQUEST_PIN;
1089
906
  payload: {
1090
- device?: DeviceInfo;
1091
- connectId?: string;
1092
- type?: string;
907
+ device: DeviceInfo;
1093
908
  };
1094
909
  };
1095
910
  [UI_REQUEST.REQUEST_PASSPHRASE]: {
1096
911
  type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
1097
912
  payload: {
1098
- device?: DeviceInfo;
1099
- connectId?: string;
1100
- passphraseState?: string;
1101
- useEmptyPassphrase?: boolean;
913
+ device: DeviceInfo;
1102
914
  };
1103
915
  };
1104
916
  [UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
@@ -1164,15 +976,6 @@ interface HardwareEventMap {
1164
976
  appName: string;
1165
977
  };
1166
978
  };
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
- };
1176
979
  [UI_REQUEST.CLOSE_UI_WINDOW]: {
1177
980
  type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
1178
981
  payload: Record<string, never>;
@@ -1203,41 +1006,7 @@ interface HardwareEventMap {
1203
1006
  };
1204
1007
  };
1205
1008
  }
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 {
1009
+ interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods {
1241
1010
  readonly vendor: string;
1242
1011
  readonly activeTransport: TransportType | null;
1243
1012
  init(config: TConfig): Promise<void>;
@@ -1278,19 +1047,12 @@ interface SearchDevicesOptions {
1278
1047
  * should leave this false so an active session can still be reused.
1279
1048
  */
1280
1049
  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;
1287
1050
  }
1288
1051
 
1289
- interface EvmGetAddressParams extends PassphraseStateAware {
1052
+ interface EvmGetAddressParams {
1290
1053
  path: string;
1291
1054
  showOnDevice?: boolean;
1292
1055
  chainId?: number;
1293
- ethereumDefinitions?: EvmEthereumDefinitions;
1294
1056
  }
1295
1057
  interface EvmAddress {
1296
1058
  address: string;
@@ -1298,7 +1060,7 @@ interface EvmAddress {
1298
1060
  /** Device-reported secp256k1 public key; populated when the transport exposes it. */
1299
1061
  publicKey?: string;
1300
1062
  }
1301
- interface EvmSignTxParams extends PassphraseStateAware {
1063
+ interface EvmSignTxParams {
1302
1064
  path: string;
1303
1065
  /**
1304
1066
  * RLP-serialized transaction hex (0x-prefixed or plain).
@@ -1313,7 +1075,6 @@ interface EvmSignTxParams extends PassphraseStateAware {
1313
1075
  nonce?: string;
1314
1076
  gasLimit?: string;
1315
1077
  gasPrice?: string;
1316
- txType?: number;
1317
1078
  maxFeePerGas?: string;
1318
1079
  maxPriorityFeePerGas?: string;
1319
1080
  accessList?: Array<{
@@ -1321,43 +1082,6 @@ interface EvmSignTxParams extends PassphraseStateAware {
1321
1082
  storageKeys: string[];
1322
1083
  }>;
1323
1084
  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;
1361
1085
  }
1362
1086
  interface EvmSignedTx {
1363
1087
  /** Recovery id as `0x`-prefixed hex string. */
@@ -1368,20 +1092,16 @@ interface EvmSignedTx {
1368
1092
  s: string;
1369
1093
  serializedTx?: string;
1370
1094
  }
1371
- interface EvmSignMsgParams extends PassphraseStateAware {
1095
+ interface EvmSignMsgParams {
1372
1096
  path: string;
1373
1097
  message: string;
1374
- chainId?: number;
1375
1098
  hex?: boolean;
1376
- ethereumDefinitions?: EvmEthereumDefinitions;
1377
1099
  }
1378
1100
  type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
1379
- interface EvmSignTypedDataFull extends PassphraseStateAware {
1101
+ interface EvmSignTypedDataFull {
1380
1102
  path: string;
1381
- chainId?: number;
1382
1103
  /** Defaults to `'full'` when omitted. */
1383
1104
  mode?: 'full';
1384
- ethereumDefinitions?: EvmEthereumDefinitions;
1385
1105
  data: {
1386
1106
  domain: EIP712Domain;
1387
1107
  types: Record<string, Array<{
@@ -1392,22 +1112,12 @@ interface EvmSignTypedDataFull extends PassphraseStateAware {
1392
1112
  message: Record<string, unknown>;
1393
1113
  };
1394
1114
  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;
1403
1115
  }
1404
- interface EvmSignTypedDataHash extends PassphraseStateAware {
1116
+ interface EvmSignTypedDataHash {
1405
1117
  path: string;
1406
- chainId?: number;
1407
1118
  mode: 'hash';
1408
1119
  domainSeparatorHash: string;
1409
1120
  messageHash: string;
1410
- ethereumDefinitions?: EvmEthereumDefinitions;
1411
1121
  }
1412
1122
  interface EIP712Domain {
1413
1123
  name?: string;
@@ -1423,10 +1133,10 @@ interface EvmSignature {
1423
1133
  address?: string;
1424
1134
  }
1425
1135
  interface IEvmMethods {
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>>;
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>>;
1430
1140
  }
1431
1141
 
1432
1142
  /**
@@ -1542,8 +1252,32 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
1542
1252
  emit<K extends keyof TMap & string>(event: K, data: TMap[K]): void;
1543
1253
  emit(event: string, data: unknown): void;
1544
1254
  removeAllListeners(): void;
1545
- /** Number of listeners registered for `event`. 0 if none. */
1546
- listenerCount(event: string): number;
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;
1547
1281
  }
1548
1282
 
1549
1283
  /**
@@ -1566,32 +1300,11 @@ declare function hexToBytes(hex: string): Uint8Array;
1566
1300
  /** Convert a Uint8Array to a hex string (no 0x prefix). */
1567
1301
  declare function bytesToHex(bytes: Uint8Array): string;
1568
1302
 
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;
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;
1595
1308
 
1596
1309
  /**
1597
1310
  * Generic batch call with progress reporting.
@@ -1602,35 +1315,4 @@ declare function batchCall<TParam, TResult>(params: TParam[], callFn: (p: TParam
1602
1315
  total: number;
1603
1316
  }) => void): Promise<Response<TResult[]>>;
1604
1317
 
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 };
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 };