@onekeyfe/hwk-adapter-core 1.2.8-alpha.119 → 1.2.8-alpha.120

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.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HardwareErrorCode, a as HwkErrorOrigin, b as HwkRecoveryHint } from './errors-DednD9bG.js';
2
- export { c as HwkError, d as HwkRecoveryScope, I as IHwkErrorPayload, e as IOperationMayHaveCompletedParams, O as ORPHAN_ELIGIBLE_ERROR_CODES, f as createHwkError, g as defaultOriginForCode, h as defaultRecoveryForCode, i as enrichErrorMessage, j as isHwkRecoveryHint, o as operationMayHaveCompletedParams } from './errors-DednD9bG.js';
3
- import { U as UiResponseEvent, E as ExportedAccountKey, a as UiRequestOperationAttribution, b as UI_REQUEST, Q as QrDisplayData, c as UiRequestRegistry, S as SaveDeviceBindingDeclineReason } from './ui-events-BCbB6sfo.js';
4
- export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, e as QrResponseData, f as UI_EVENT, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE } from './ui-events-BCbB6sfo.js';
1
+ import { H as HardwareErrorCode, a as HwkErrorOrigin, b as HwkRecoveryHint } from './errors-BgJ4kzRx.js';
2
+ export { c as HwkError, d as HwkRecoveryScope, I as IHwkErrorPayload, e as IOperationMayHaveCompletedParams, O as ORPHAN_ELIGIBLE_ERROR_CODES, f as createHwkError, g as defaultOriginForCode, h as defaultRecoveryForCode, i as enrichErrorMessage, j as isHwkRecoveryHint, o as operationMayHaveCompletedParams } from './errors-BgJ4kzRx.js';
3
+ import { U as UiResponseEvent, E as ExportedAccountKey, a as UiRequestOperationAttribution, b as UI_REQUEST, Q as QrDisplayData, c as UiRequestRegistry, S as SaveDeviceBindingDeclineReason } from './ui-events-C61GTilK.js';
4
+ export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, e as QrResponseData, f as UI_EVENT, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE } from './ui-events-C61GTilK.js';
5
5
 
6
6
  interface Success<T> {
7
7
  success: true;
@@ -53,6 +53,116 @@ declare function parseWalletMasterFingerprint(value: unknown): string | undefine
53
53
  */
54
54
  declare function deriveDeviceFingerprint(value: string): string;
55
55
 
56
+ type VendorType = 'trezor' | 'ledger' | 'keystone';
57
+ /** 'qr' is a virtual channel: UR payloads travel via app-rendered/scanned QR codes. */
58
+ type ConnectionType = 'usb' | 'ble' | 'qr';
59
+ type TransportType = 'usb' | 'ble' | 'hid' | 'bridge' | 'qr';
60
+ /**
61
+ * Device capabilities — describes what a specific device/connection
62
+ * combination can or cannot do. Varies by vendor, model, and connection type.
63
+ *
64
+ * This enables business logic to check capabilities instead of hard-coding
65
+ * vendor-specific conditions (e.g., `if (vendor === 'ledger')`).
66
+ */
67
+ interface DeviceCapabilities {
68
+ /**
69
+ * Whether the discovery handle can be reused to reconnect; `false` requires rediscovery. Says
70
+ * nothing about identity (Trezor BLE is false yet its device_id is stable); verify it separately.
71
+ */
72
+ persistentDeviceIdentity: boolean;
73
+ }
74
+ interface DeviceInfo {
75
+ vendor: VendorType;
76
+ /** Machine model id (e.g. "nanoX"). */
77
+ model: string;
78
+ /** Human-readable model name (e.g. "Ledger Nano X"). */
79
+ modelName?: string;
80
+ firmwareVersion: string;
81
+ deviceId: string;
82
+ connectId: string;
83
+ label?: string;
84
+ connectionType: ConnectionType;
85
+ battery?: number;
86
+ /** BLE signal strength (BLE only). */
87
+ rssi?: number | null;
88
+ /** BLE connectable flag (BLE only). */
89
+ isConnectable?: boolean | null;
90
+ /** USB serial number (USB only). */
91
+ serialNumber?: string;
92
+ /** Device capabilities — varies by vendor, model, and connection type */
93
+ capabilities?: DeviceCapabilities;
94
+ /**
95
+ * Vendor-specific raw payload from the post-handshake `Features` (Trezor)
96
+ * or device-info call. Populated by the connector with `{ transport,
97
+ * descriptor, features }` so the app layer can read fields we haven't
98
+ * promoted to the typed surface yet. Treat as informational — promote
99
+ * any consumed field above.
100
+ */
101
+ raw?: Record<string, unknown>;
102
+ }
103
+ interface DeviceTarget {
104
+ connectId: string;
105
+ deviceId: string;
106
+ }
107
+ /**
108
+ * How long a discovery handle remains safe to use for a new connection.
109
+ * This is deliberately separate from post-connect device identity.
110
+ */
111
+ type SearchTargetReusePolicy = 'current-discovery' | 'reconnectable' | 'rediscover';
112
+ declare function resolveSearchTargetReusePolicy(device: Pick<DeviceInfo, 'connectionType' | 'capabilities'>): SearchTargetReusePolicy;
113
+ /** Search target for a physical device whose connectId is the discovery handle. */
114
+ declare function toPhysicalDeviceSearchTarget(vendor: VendorType, device: DeviceInfo): DeviceSearchTarget;
115
+ /**
116
+ * A selectable result from hardware discovery. It may represent a physical
117
+ * transport endpoint or an interactive entry such as Keystone QR; it is not a
118
+ * physical-device or wallet identity.
119
+ */
120
+ interface DeviceSearchTarget {
121
+ /** Opaque handle scoped to the adapter's current discovery state. */
122
+ searchTargetId: string;
123
+ /** Whether the handle itself may be retried; never inferred from a stored connectId. */
124
+ searchTargetReusePolicy?: SearchTargetReusePolicy;
125
+ vendor: VendorType;
126
+ connectionType: ConnectionType;
127
+ kind: 'physical' | 'interactive';
128
+ label?: string;
129
+ model?: string;
130
+ modelName?: string;
131
+ serialNumber?: string;
132
+ }
133
+ type WalletIdentity = {
134
+ vendor: 'ledger';
135
+ type: 'chainFingerprint';
136
+ chain: ChainForFingerprint;
137
+ value: string;
138
+ } | {
139
+ vendor: 'trezor';
140
+ type: 'deviceId';
141
+ value: string;
142
+ } | {
143
+ vendor: 'keystone';
144
+ type: 'walletId';
145
+ value: string;
146
+ };
147
+
148
+ /**
149
+ * Mixin for chain-operation params that can be pinned to a specific passphrase
150
+ * wallet.
151
+ *
152
+ * Trezor-only. `passphraseState` is the wallet identity returned by
153
+ * `getPassphraseState`: today this is the compressed public key derived at
154
+ * `m/44'/0'/0'`, not the 4-byte master fingerprint. When present, the adapter
155
+ * creates a fresh wallet session (THP application session, or v1 device
156
+ * session) and verifies the derived state before issuing the call, so the
157
+ * address/signature comes from the intended passphrase wallet.
158
+ *
159
+ * Ledger has no equivalent and ignores the field — it never reaches the
160
+ * protobuf layer (the adapter strips it before forwarding to the connector).
161
+ */
162
+ interface PassphraseStateAware {
163
+ passphraseState?: string;
164
+ }
165
+
56
166
  /**
57
167
  * Minimal device info returned during discovery (searchDevices).
58
168
  * At scan time, full DeviceInfo fields like firmwareVersion are not yet available.
@@ -167,8 +277,6 @@ declare enum EConnectorInteraction {
167
277
  AppInstallProgress = "app-install-progress"
168
278
  }
169
279
  type ConnectorUiEvent = {
170
- operationId?: string;
171
- } & ({
172
280
  type: EConnectorInteraction.Searching;
173
281
  payload: {
174
282
  sessionId: string;
@@ -177,7 +285,6 @@ type ConnectorUiEvent = {
177
285
  type: EConnectorInteraction.ConfirmOpenApp;
178
286
  payload: {
179
287
  sessionId: string;
180
- appName?: string;
181
288
  };
182
289
  } | {
183
290
  type: EConnectorInteraction.UnlockDevice;
@@ -201,7 +308,7 @@ type ConnectorUiEvent = {
201
308
  appName: string;
202
309
  progress: number;
203
310
  };
204
- });
311
+ };
205
312
  interface ConnectorEventMap {
206
313
  'device-connect': {
207
314
  device: ConnectorDevice;
@@ -376,199 +483,15 @@ declare const DEVICE: {
376
483
  /**
377
484
  * Trezor-only. Emitted after a successful THP handshake that minted or
378
485
  * refreshed pairing credentials. The host should persist `credentials`
379
- * keyed by `deviceId` and feed them back into the connector on the next
380
- * connect to skip the CodeEntry/QrCode/NFC pairing UX.
381
- *
382
- * The `TREZOR_` prefix mirrors `UI_REQUEST.REQUEST_TREZOR_THP_PAIRING` —
383
- * vendor-specific events live in the shared event taxonomy but are named
384
- * so hosts can ignore them when they don't drive Trezor hardware.
385
- */
386
- readonly TREZOR_THP_CREDENTIALS_CHANGED: "device-trezor-thp-credentials-changed";
387
- };
388
-
389
- /**
390
- * Mixin for chain-operation params that can be pinned to a specific passphrase
391
- * wallet.
392
- *
393
- * Trezor-only. `passphraseState` is the wallet identity returned by
394
- * `getPassphraseState`: today this is the compressed public key derived at
395
- * `m/44'/0'/0'`, not the 4-byte master fingerprint. When present, the adapter
396
- * creates a fresh wallet session (THP application session, or v1 device
397
- * session) and verifies the derived state before issuing the call, so the
398
- * address/signature comes from the intended passphrase wallet.
399
- *
400
- * Ledger has no equivalent and ignores the field — it never reaches the
401
- * protobuf layer (the adapter strips it before forwarding to the connector).
402
- */
403
- interface PassphraseStateAware {
404
- passphraseState?: string;
405
- }
406
-
407
- interface EvmGetAddressParams extends PassphraseStateAware {
408
- path: string;
409
- showOnDevice?: boolean;
410
- chainId?: number;
411
- ethereumDefinitions?: EvmEthereumDefinitions;
412
- }
413
- interface EvmAddress {
414
- address: string;
415
- path: string;
416
- /** Device-reported secp256k1 public key; populated when the transport exposes it. */
417
- publicKey?: string;
418
- /** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
419
- accountKey?: ExportedAccountKey;
420
- }
421
- interface EvmSignTxBaseParams extends PassphraseStateAware {
422
- path: string;
423
- chainId?: number;
424
- }
425
- /** Ledger shape: the whole RLP-serialized tx (0x-prefixed or plain hex); structured fields forbidden. */
426
- interface EvmSignTxLedgerParams extends EvmSignTxBaseParams {
427
- serializedTx: string;
428
- to?: never;
429
- value?: never;
430
- nonce?: never;
431
- gasLimit?: never;
432
- gasPrice?: never;
433
- txType?: never;
434
- maxFeePerGas?: never;
435
- maxPriorityFeePerGas?: never;
436
- accessList?: never;
437
- data?: never;
438
- paymentRequest?: never;
439
- ethereumDefinitions?: never;
440
- }
441
- /** Trezor shape: structured EthereumSignTx protobuf fields; serializedTx forbidden. */
442
- interface EvmSignTxTrezorParams extends EvmSignTxBaseParams {
443
- serializedTx?: never;
444
- /** Contract address or recipient. Optional for contract deployment transactions. */
445
- to?: string;
446
- value?: string;
447
- nonce?: string;
448
- gasLimit?: string;
449
- gasPrice?: string;
450
- txType?: number;
451
- maxFeePerGas?: string;
452
- maxPriorityFeePerGas?: string;
453
- accessList?: Array<{
454
- address: string;
455
- storageKeys: string[];
456
- }>;
457
- data?: string;
458
- paymentRequest?: EvmPaymentRequest;
459
- ethereumDefinitions?: EvmEthereumDefinitions;
460
- }
461
- /** Mutually exclusive vendor shapes; each adapter narrows to its own. */
462
- type EvmSignTxParams = EvmSignTxLedgerParams | EvmSignTxTrezorParams;
463
- interface EvmEthereumDefinitions {
464
- /** Trezor Ethereum network definition bytes as a hex string. */
465
- encodedNetwork?: string;
466
- /** Trezor Ethereum token definition bytes as a hex string. */
467
- encodedToken?: string;
468
- }
469
- interface EvmPaymentRequestMemo {
470
- textMemo?: {
471
- text: string;
472
- };
473
- textDetailsMemo?: {
474
- title: string;
475
- text: string;
476
- };
477
- refundMemo?: {
478
- address: string;
479
- addressN?: number[];
480
- mac: string;
481
- };
482
- coinPurchaseMemo?: {
483
- coinType: number;
484
- amount: string;
485
- address: string;
486
- addressN?: number[];
487
- mac: string;
488
- };
489
- }
490
- interface EvmPaymentRequest {
491
- nonce?: string;
492
- recipientName: string;
493
- memos?: EvmPaymentRequestMemo[];
494
- /** Decimal string in subunits; SDK encodes it as SLIP-24 uint256 LE hex. */
495
- amount?: string;
496
- signature: string;
497
- }
498
- interface EvmSignedTx {
499
- /** Recovery id as `0x`-prefixed hex string. */
500
- v: string;
501
- /** ECDSA `r` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
502
- r: string;
503
- /** ECDSA `s` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
504
- s: string;
505
- serializedTx?: string;
506
- }
507
- interface EvmSignMsgParams extends PassphraseStateAware {
508
- path: string;
509
- message: string;
510
- chainId?: number;
511
- hex?: boolean;
512
- ethereumDefinitions?: EvmEthereumDefinitions;
513
- }
514
- type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
515
- interface EvmSignTypedDataFull extends PassphraseStateAware {
516
- path: string;
517
- chainId?: number;
518
- /** Defaults to `'full'` when omitted. */
519
- mode?: 'full';
520
- ethereumDefinitions?: EvmEthereumDefinitions;
521
- data: {
522
- domain: EIP712Domain;
523
- types: Record<string, Array<{
524
- name: string;
525
- type: string;
526
- }>>;
527
- primaryType: string;
528
- message: Record<string, unknown>;
529
- };
530
- /**
531
- * The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
532
- * re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
533
- */
534
- dataJson?: string;
535
- metamaskV4Compat?: boolean;
536
- showMessageHash?: boolean;
537
- /**
538
- * Optional host-computed hashes. Core Trezor models still use full typed-data
539
- * signing for display, while Trezor One can fall back to typed-hash signing
540
- * when firmware cannot compute the hashes itself.
541
- */
542
- domainSeparatorHash?: string;
543
- messageHash?: string;
544
- }
545
- interface EvmSignTypedDataHash extends PassphraseStateAware {
546
- path: string;
547
- chainId?: number;
548
- mode: 'hash';
549
- domainSeparatorHash: string;
550
- messageHash: string;
551
- ethereumDefinitions?: EvmEthereumDefinitions;
552
- }
553
- interface EIP712Domain {
554
- name?: string;
555
- version?: string;
556
- chainId?: number;
557
- verifyingContract?: string;
558
- salt?: string;
559
- [key: string]: unknown;
560
- }
561
- interface EvmSignature {
562
- /** `0x`-prefixed hex string (r + s + v). */
563
- signature: string;
564
- address?: string;
565
- }
566
- interface IEvmMethods {
567
- evmGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmGetAddressParams>>): Promise<Response<EvmAddress>>;
568
- evmSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTxParams>>): Promise<Response<EvmSignedTx>>;
569
- evmSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignMsgParams>>): Promise<Response<EvmSignature>>;
570
- evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
571
- }
486
+ * keyed by `deviceId` and feed them back into the connector on the next
487
+ * connect to skip the CodeEntry/QrCode/NFC pairing UX.
488
+ *
489
+ * The `TREZOR_` prefix mirrors `UI_REQUEST.REQUEST_TREZOR_THP_PAIRING` —
490
+ * vendor-specific events live in the shared event taxonomy but are named
491
+ * so hosts can ignore them when they don't drive Trezor hardware.
492
+ */
493
+ readonly TREZOR_THP_CREDENTIALS_CHANGED: "device-trezor-thp-credentials-changed";
494
+ };
572
495
 
573
496
  interface BtcGetAddressParams extends PassphraseStateAware {
574
497
  path: string;
@@ -975,7 +898,7 @@ declare class OperationRegistry {
975
898
  /** Return active or tombstoned binding data without refreshing its TTL. */
976
899
  find(operationId: string): HardwareOperation | undefined;
977
900
  findActiveByConnectionKey(connectionKey: string): HardwareOperation | undefined;
978
- /** Only an explicitly supplied operation job key owns the call's UI requests. */
901
+ /** Map a job queue key (an operation id or a connection key) to its live operation id. */
979
902
  findOperationIdByJobKey(jobKey: string | undefined): string | undefined;
980
903
  /**
981
904
  * End an operation on the caller's explicit release. Throws for an unknown id; returns undefined
@@ -1111,7 +1034,6 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
1111
1034
  type: EConnectorInteraction.AppInstallProgress;
1112
1035
  }> | {
1113
1036
  type: EConnectorInteraction.AppInstallProgress;
1114
- operationId?: string;
1115
1037
  payload: {
1116
1038
  connectId: string;
1117
1039
  appName: string;
@@ -1294,8 +1216,6 @@ interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
1294
1216
  }
1295
1217
  type AllNetworkDeviceIdentity = WalletIdentity;
1296
1218
  type AllNetworkAddressResponsePayload = Record<string, unknown> & {
1297
- /** This account came from the user's explicit device-export scan. */
1298
- accountExport?: boolean;
1299
1219
  error?: string;
1300
1220
  code?: HardwareErrorCode | number;
1301
1221
  errorCode?: string | number;
@@ -1593,12 +1513,6 @@ interface HardwareEventMap {
1593
1513
  appName: string;
1594
1514
  } & UiRequestOperationAttribution;
1595
1515
  };
1596
- [UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM]: {
1597
- type: typeof UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM;
1598
- payload: {
1599
- vendor: string;
1600
- } & UiRequestOperationAttribution;
1601
- };
1602
1516
  [UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
1603
1517
  type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
1604
1518
  payload: {
@@ -1752,99 +1666,171 @@ interface SearchDevicesOptions {
1752
1666
  transportType?: ConnectionType;
1753
1667
  }
1754
1668
 
1755
- type VendorType = 'trezor' | 'ledger' | 'keystone';
1756
- /** 'qr' is a virtual channel: UR payloads travel via app-rendered/scanned QR codes. */
1757
- type ConnectionType = 'usb' | 'ble' | 'qr';
1758
- type TransportType = 'usb' | 'ble' | 'hid' | 'bridge' | 'qr';
1759
- /**
1760
- * Device capabilities — describes what a specific device/connection
1761
- * combination can or cannot do. Varies by vendor, model, and connection type.
1762
- *
1763
- * This enables business logic to check capabilities instead of hard-coding
1764
- * vendor-specific conditions (e.g., `if (vendor === 'ledger')`).
1765
- */
1766
- interface DeviceCapabilities {
1767
- /** Chains usable through this adapter on the connected firmware; absent means not advertised. */
1768
- supportedChains?: ChainCapability[];
1669
+ interface EvmGetAddressParams extends PassphraseStateAware {
1670
+ path: string;
1671
+ showOnDevice?: boolean;
1672
+ chainId?: number;
1673
+ ethereumDefinitions?: EvmEthereumDefinitions;
1674
+ }
1675
+ interface EvmAddress {
1676
+ address: string;
1677
+ path: string;
1678
+ /** Device-reported secp256k1 public key; populated when the transport exposes it. */
1679
+ publicKey?: string;
1680
+ /** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
1681
+ accountKey?: ExportedAccountKey;
1682
+ }
1683
+ interface EvmSignTxBaseParams extends PassphraseStateAware {
1684
+ path: string;
1685
+ chainId?: number;
1686
+ }
1687
+ /** Ledger shape: the whole RLP-serialized tx (0x-prefixed or plain hex); structured fields forbidden. */
1688
+ interface EvmSignTxLedgerParams extends EvmSignTxBaseParams {
1689
+ serializedTx: string;
1690
+ to?: never;
1691
+ value?: never;
1692
+ nonce?: never;
1693
+ gasLimit?: never;
1694
+ gasPrice?: never;
1695
+ txType?: never;
1696
+ maxFeePerGas?: never;
1697
+ maxPriorityFeePerGas?: never;
1698
+ accessList?: never;
1699
+ data?: never;
1700
+ paymentRequest?: never;
1701
+ ethereumDefinitions?: never;
1702
+ }
1703
+ /** Trezor shape: structured EthereumSignTx protobuf fields; serializedTx forbidden. */
1704
+ interface EvmSignTxTrezorParams extends EvmSignTxBaseParams {
1705
+ serializedTx?: never;
1706
+ /** Contract address or recipient. Optional for contract deployment transactions. */
1707
+ to?: string;
1708
+ value?: string;
1709
+ nonce?: string;
1710
+ gasLimit?: string;
1711
+ gasPrice?: string;
1712
+ txType?: number;
1713
+ maxFeePerGas?: string;
1714
+ maxPriorityFeePerGas?: string;
1715
+ accessList?: Array<{
1716
+ address: string;
1717
+ storageKeys: string[];
1718
+ }>;
1719
+ data?: string;
1720
+ paymentRequest?: EvmPaymentRequest;
1721
+ ethereumDefinitions?: EvmEthereumDefinitions;
1722
+ }
1723
+ /** Mutually exclusive vendor shapes; each adapter narrows to its own. */
1724
+ type EvmSignTxParams = EvmSignTxLedgerParams | EvmSignTxTrezorParams;
1725
+ interface EvmEthereumDefinitions {
1726
+ /** Trezor Ethereum network definition bytes as a hex string. */
1727
+ encodedNetwork?: string;
1728
+ /** Trezor Ethereum token definition bytes as a hex string. */
1729
+ encodedToken?: string;
1730
+ }
1731
+ interface EvmPaymentRequestMemo {
1732
+ textMemo?: {
1733
+ text: string;
1734
+ };
1735
+ textDetailsMemo?: {
1736
+ title: string;
1737
+ text: string;
1738
+ };
1739
+ refundMemo?: {
1740
+ address: string;
1741
+ addressN?: number[];
1742
+ mac: string;
1743
+ };
1744
+ coinPurchaseMemo?: {
1745
+ coinType: number;
1746
+ amount: string;
1747
+ address: string;
1748
+ addressN?: number[];
1749
+ mac: string;
1750
+ };
1751
+ }
1752
+ interface EvmPaymentRequest {
1753
+ nonce?: string;
1754
+ recipientName: string;
1755
+ memos?: EvmPaymentRequestMemo[];
1756
+ /** Decimal string in subunits; SDK encodes it as SLIP-24 uint256 LE hex. */
1757
+ amount?: string;
1758
+ signature: string;
1759
+ }
1760
+ interface EvmSignedTx {
1761
+ /** Recovery id as `0x`-prefixed hex string. */
1762
+ v: string;
1763
+ /** ECDSA `r` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
1764
+ r: string;
1765
+ /** ECDSA `s` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
1766
+ s: string;
1767
+ serializedTx?: string;
1768
+ }
1769
+ interface EvmSignMsgParams extends PassphraseStateAware {
1770
+ path: string;
1771
+ message: string;
1772
+ chainId?: number;
1773
+ hex?: boolean;
1774
+ ethereumDefinitions?: EvmEthereumDefinitions;
1775
+ }
1776
+ type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
1777
+ interface EvmSignTypedDataFull extends PassphraseStateAware {
1778
+ path: string;
1779
+ chainId?: number;
1780
+ /** Defaults to `'full'` when omitted. */
1781
+ mode?: 'full';
1782
+ ethereumDefinitions?: EvmEthereumDefinitions;
1783
+ data: {
1784
+ domain: EIP712Domain;
1785
+ types: Record<string, Array<{
1786
+ name: string;
1787
+ type: string;
1788
+ }>>;
1789
+ primaryType: string;
1790
+ message: Record<string, unknown>;
1791
+ };
1769
1792
  /**
1770
- * Whether the discovery handle can be reused to reconnect; `false` requires rediscovery. Says
1771
- * nothing about identity (Trezor BLE is false yet its device_id is stable); verify it separately.
1793
+ * The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
1794
+ * re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
1772
1795
  */
1773
- persistentDeviceIdentity: boolean;
1774
- }
1775
- interface DeviceInfo {
1776
- vendor: VendorType;
1777
- /** Machine model id (e.g. "nanoX"). */
1778
- model: string;
1779
- /** Human-readable model name (e.g. "Ledger Nano X"). */
1780
- modelName?: string;
1781
- firmwareVersion: string;
1782
- deviceId: string;
1783
- connectId: string;
1784
- label?: string;
1785
- connectionType: ConnectionType;
1786
- battery?: number;
1787
- /** BLE signal strength (BLE only). */
1788
- rssi?: number | null;
1789
- /** BLE connectable flag (BLE only). */
1790
- isConnectable?: boolean | null;
1791
- /** USB serial number (USB only). */
1792
- serialNumber?: string;
1793
- /** Device capabilities — varies by vendor, model, and connection type */
1794
- capabilities?: DeviceCapabilities;
1796
+ dataJson?: string;
1797
+ metamaskV4Compat?: boolean;
1798
+ showMessageHash?: boolean;
1795
1799
  /**
1796
- * Vendor-specific raw payload from the post-handshake `Features` (Trezor)
1797
- * or device-info call. Populated by the connector with `{ transport,
1798
- * descriptor, features }` so the app layer can read fields we haven't
1799
- * promoted to the typed surface yet. Treat as informational — promote
1800
- * any consumed field above.
1800
+ * Optional host-computed hashes. Core Trezor models still use full typed-data
1801
+ * signing for display, while Trezor One can fall back to typed-hash signing
1802
+ * when firmware cannot compute the hashes itself.
1801
1803
  */
1802
- raw?: Record<string, unknown>;
1804
+ domainSeparatorHash?: string;
1805
+ messageHash?: string;
1803
1806
  }
1804
- interface DeviceTarget {
1805
- connectId: string;
1806
- deviceId: string;
1807
+ interface EvmSignTypedDataHash extends PassphraseStateAware {
1808
+ path: string;
1809
+ chainId?: number;
1810
+ mode: 'hash';
1811
+ domainSeparatorHash: string;
1812
+ messageHash: string;
1813
+ ethereumDefinitions?: EvmEthereumDefinitions;
1807
1814
  }
1808
- /**
1809
- * How long a discovery handle remains safe to use for a new connection.
1810
- * This is deliberately separate from post-connect device identity.
1811
- */
1812
- type SearchTargetReusePolicy = 'current-discovery' | 'reconnectable' | 'rediscover';
1813
- declare function resolveSearchTargetReusePolicy(device: Pick<DeviceInfo, 'connectionType' | 'capabilities'>): SearchTargetReusePolicy;
1814
- /** Search target for a physical device whose connectId is the discovery handle. */
1815
- declare function toPhysicalDeviceSearchTarget(vendor: VendorType, device: DeviceInfo): DeviceSearchTarget;
1816
- /**
1817
- * A selectable result from hardware discovery. It may represent a physical
1818
- * transport endpoint or an interactive entry such as Keystone QR; it is not a
1819
- * physical-device or wallet identity.
1820
- */
1821
- interface DeviceSearchTarget {
1822
- /** Opaque handle scoped to the adapter's current discovery state. */
1823
- searchTargetId: string;
1824
- /** Whether the handle itself may be retried; never inferred from a stored connectId. */
1825
- searchTargetReusePolicy?: SearchTargetReusePolicy;
1826
- vendor: VendorType;
1827
- connectionType: ConnectionType;
1828
- kind: 'physical' | 'interactive';
1829
- label?: string;
1830
- model?: string;
1831
- modelName?: string;
1832
- serialNumber?: string;
1815
+ interface EIP712Domain {
1816
+ name?: string;
1817
+ version?: string;
1818
+ chainId?: number;
1819
+ verifyingContract?: string;
1820
+ salt?: string;
1821
+ [key: string]: unknown;
1822
+ }
1823
+ interface EvmSignature {
1824
+ /** `0x`-prefixed hex string (r + s + v). */
1825
+ signature: string;
1826
+ address?: string;
1827
+ }
1828
+ interface IEvmMethods {
1829
+ evmGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmGetAddressParams>>): Promise<Response<EvmAddress>>;
1830
+ evmSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTxParams>>): Promise<Response<EvmSignedTx>>;
1831
+ evmSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignMsgParams>>): Promise<Response<EvmSignature>>;
1832
+ evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
1833
1833
  }
1834
- type WalletIdentity = {
1835
- vendor: 'ledger';
1836
- type: 'chainFingerprint';
1837
- chain: ChainForFingerprint;
1838
- value: string;
1839
- } | {
1840
- vendor: 'trezor';
1841
- type: 'deviceId';
1842
- value: string;
1843
- } | {
1844
- vendor: 'keystone';
1845
- type: 'walletId';
1846
- value: string;
1847
- };
1848
1834
 
1849
1835
  /** Which `GET_VK` encoding the Ledger Zcash app should return. */
1850
1836
  type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';