@onekeyfe/hwk-adapter-core 1.2.0-alpha.11 → 1.2.0-alpha.13
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/chunk-BAGEFFFY.js +151 -0
- package/dist/chunk-BAGEFFFY.js.map +1 -0
- package/dist/chunk-FT3SZP2W.js +149 -0
- package/dist/chunk-FT3SZP2W.js.map +1 -0
- package/dist/chunk-U63HTLGJ.mjs +151 -0
- package/dist/chunk-U63HTLGJ.mjs.map +1 -0
- package/dist/chunk-XGIIA4A4.mjs +149 -0
- package/dist/chunk-XGIIA4A4.mjs.map +1 -0
- package/dist/errors.d.mts +197 -0
- package/dist/errors.d.ts +197 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +13 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.d.mts +657 -274
- package/dist/index.d.ts +657 -274
- package/dist/index.js +452 -355
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +401 -247
- package/dist/index.mjs.map +1 -1
- package/dist/ui-events-Cb7haAeE.d.mts +128 -0
- package/dist/ui-events-Cb7haAeE.d.ts +128 -0
- package/dist/ui-events.d.mts +1 -0
- package/dist/ui-events.d.ts +1 -0
- package/dist/ui-events.js +21 -0
- package/dist/ui-events.js.map +1 -0
- package/dist/ui-events.mjs +21 -0
- package/dist/ui-events.mjs.map +1 -0
- package/package.json +22 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,110 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
PinInvalid = 10400,
|
|
65
|
-
PinCancelled = 10401,
|
|
66
|
-
PassphraseRejected = 10402,
|
|
67
|
-
/** Chain app NOT INSTALLED on device. User must install via Ledger Live. */
|
|
68
|
-
AppNotInstalled = 10500,
|
|
69
|
-
WrongApp = 10501,
|
|
70
|
-
/** 0x911c Command code not supported — app predates current SDK. */
|
|
71
|
-
AppTooOld = 10502,
|
|
72
|
-
/** Not enough free storage for install/update; user must uninstall apps first. */
|
|
73
|
-
DeviceOutOfMemory = 10503,
|
|
74
|
-
/** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the
|
|
75
|
-
* user has not enabled Blind signing on the device. */
|
|
76
|
-
EvmBlindSigningRequired = 11000,
|
|
77
|
-
/** 0x6984 Plugin not installed */
|
|
78
|
-
EvmClearSignPluginMissing = 11001,
|
|
79
|
-
/** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */
|
|
80
|
-
EvmDataTooLarge = 11002,
|
|
81
|
-
/** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */
|
|
82
|
-
EvmTxTypeNotSupported = 11003,
|
|
83
|
-
/** 0x6808 Blind signing disabled for this instruction. */
|
|
84
|
-
SolanaBlindSigningRequired = 11100,
|
|
85
|
-
/** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */
|
|
86
|
-
TronCustomContractRequired = 11200,
|
|
87
|
-
/** 0x6a8b Transactions Data setting disabled. */
|
|
88
|
-
TronDataSigningRequired = 11201,
|
|
89
|
-
/** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */
|
|
90
|
-
TronSignByHashRequired = 11202,
|
|
91
|
-
/** 0xb008 Wallet policy HMAC mismatch or not registered. */
|
|
92
|
-
BtcWalletPolicyHmacMismatch = 11300,
|
|
93
|
-
/** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */
|
|
94
|
-
BtcUnexpectedState = 11301
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Device-level failures the SDK cannot self-recover from — affect the entire
|
|
98
|
-
* batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-
|
|
99
|
-
* skip in onboarding). Combined with `accounts.length === 0`, signals
|
|
100
|
-
* genuine orphan. Also reused as the batch-abort whitelist for HWK.
|
|
101
|
-
* Single source of truth.
|
|
102
|
-
*
|
|
103
|
-
* UserRejected (device-side reject) is included: pressing reject is an
|
|
104
|
-
* explicit "I don't consent" — continuing the batch to ask again on the
|
|
105
|
-
* next chain is harassment, not helpful.
|
|
106
|
-
*/
|
|
107
|
-
declare const ORPHAN_ELIGIBLE_ERROR_CODES: number[];
|
|
1
|
+
import { HardwareErrorCode } from './errors.js';
|
|
2
|
+
export { HwkError, IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage } from './errors.js';
|
|
3
|
+
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-Cb7haAeE.js';
|
|
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-Cb7haAeE.js';
|
|
108
5
|
|
|
109
6
|
interface Success<T> {
|
|
110
7
|
success: true;
|
|
@@ -163,102 +60,38 @@ interface DeviceInfo {
|
|
|
163
60
|
serialNumber?: string;
|
|
164
61
|
/** Device capabilities — varies by vendor, model, and connection type */
|
|
165
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>;
|
|
166
71
|
}
|
|
167
72
|
interface DeviceTarget {
|
|
168
73
|
connectId: string;
|
|
169
74
|
deviceId: string;
|
|
170
75
|
}
|
|
171
76
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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;
|
|
180
93
|
}
|
|
181
94
|
|
|
182
|
-
declare const UI_EVENT = "UI_EVENT";
|
|
183
|
-
declare const UI_REQUEST: {
|
|
184
|
-
readonly REQUEST_PIN: "ui-request-pin";
|
|
185
|
-
readonly REQUEST_PASSPHRASE: "ui-request-passphrase";
|
|
186
|
-
readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device";
|
|
187
|
-
readonly REQUEST_BUTTON: "ui-request-button";
|
|
188
|
-
readonly REQUEST_QR_DISPLAY: "ui-request-qr-display";
|
|
189
|
-
readonly REQUEST_QR_SCAN: "ui-request-qr-scan";
|
|
190
|
-
readonly REQUEST_DEVICE_PERMISSION: "ui-request-device-permission";
|
|
191
|
-
readonly REQUEST_SELECT_DEVICE: "ui-request-select-device";
|
|
192
|
-
readonly REQUEST_DEVICE_CONNECT: "ui-request-device-connect";
|
|
193
|
-
readonly REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm";
|
|
194
|
-
readonly REQUEST_INSTALL_APP: "ui-request-install-app";
|
|
195
|
-
readonly CLOSE_UI_WINDOW: "ui-close";
|
|
196
|
-
readonly DEVICE_PROGRESS: "ui-device_progress";
|
|
197
|
-
readonly FIRMWARE_PROGRESS: "ui-firmware-progress";
|
|
198
|
-
readonly FIRMWARE_TIP: "ui-firmware-tip";
|
|
199
|
-
};
|
|
200
|
-
declare const UI_RESPONSE: {
|
|
201
|
-
readonly RECEIVE_PIN: "receive-pin";
|
|
202
|
-
readonly RECEIVE_PASSPHRASE: "receive-passphrase";
|
|
203
|
-
readonly RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device";
|
|
204
|
-
readonly RECEIVE_QR_RESPONSE: "receive-qr-response";
|
|
205
|
-
readonly RECEIVE_SELECT_DEVICE: "receive-select-device";
|
|
206
|
-
readonly RECEIVE_DEVICE_CONNECT: "receive-device-connect";
|
|
207
|
-
readonly RECEIVE_DEVICE_PERMISSION: "receive-device-permission";
|
|
208
|
-
readonly RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm";
|
|
209
|
-
readonly RECEIVE_INSTALL_APP: "receive-install-app";
|
|
210
|
-
readonly CANCEL: "cancel";
|
|
211
|
-
};
|
|
212
|
-
type DevicePermissionDeniedReason = 'bluetoothTurnedOff' | 'permissionDenied' | (string & Record<never, never>);
|
|
213
|
-
type DevicePermissionResponse = {
|
|
214
|
-
granted: boolean;
|
|
215
|
-
reason?: DevicePermissionDeniedReason;
|
|
216
|
-
message?: string;
|
|
217
|
-
};
|
|
218
|
-
type UiResponseEvent = {
|
|
219
|
-
type: typeof UI_RESPONSE.RECEIVE_PIN;
|
|
220
|
-
payload: string;
|
|
221
|
-
} | {
|
|
222
|
-
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
|
|
223
|
-
payload: {
|
|
224
|
-
value: string;
|
|
225
|
-
passphraseOnDevice?: boolean;
|
|
226
|
-
save?: boolean;
|
|
227
|
-
};
|
|
228
|
-
} | {
|
|
229
|
-
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;
|
|
230
|
-
payload?: undefined;
|
|
231
|
-
} | {
|
|
232
|
-
type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;
|
|
233
|
-
payload: QrResponseData;
|
|
234
|
-
} | {
|
|
235
|
-
type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;
|
|
236
|
-
payload: {
|
|
237
|
-
sdkConnectId: string;
|
|
238
|
-
};
|
|
239
|
-
} | {
|
|
240
|
-
type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;
|
|
241
|
-
payload: {
|
|
242
|
-
confirmed: boolean;
|
|
243
|
-
};
|
|
244
|
-
} | {
|
|
245
|
-
type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;
|
|
246
|
-
payload: DevicePermissionResponse;
|
|
247
|
-
} | {
|
|
248
|
-
type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;
|
|
249
|
-
payload: {
|
|
250
|
-
confirmed: boolean;
|
|
251
|
-
};
|
|
252
|
-
} | {
|
|
253
|
-
type: typeof UI_RESPONSE.RECEIVE_INSTALL_APP;
|
|
254
|
-
payload: {
|
|
255
|
-
confirmed: boolean;
|
|
256
|
-
};
|
|
257
|
-
} | {
|
|
258
|
-
type: typeof UI_RESPONSE.CANCEL;
|
|
259
|
-
payload?: undefined;
|
|
260
|
-
};
|
|
261
|
-
|
|
262
95
|
/**
|
|
263
96
|
* Minimal device info returned during discovery (searchDevices).
|
|
264
97
|
* At scan time, full DeviceInfo fields like firmwareVersion are not yet available.
|
|
@@ -267,6 +100,15 @@ interface ConnectorDevice {
|
|
|
267
100
|
connectId: string;
|
|
268
101
|
deviceId: string;
|
|
269
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;
|
|
270
112
|
/** Machine model id (e.g. "nanoX"). */
|
|
271
113
|
model?: string;
|
|
272
114
|
/** Human-readable model name (e.g. "Ledger Nano X"). */
|
|
@@ -279,6 +121,13 @@ interface ConnectorDevice {
|
|
|
279
121
|
serialNumber?: string;
|
|
280
122
|
/** Device capabilities — available from scan time */
|
|
281
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>;
|
|
282
131
|
}
|
|
283
132
|
interface ConnectorSession {
|
|
284
133
|
sessionId: string;
|
|
@@ -323,7 +172,7 @@ type ConnectorCallResult = {
|
|
|
323
172
|
success: false;
|
|
324
173
|
error: ConnectorSerializedError;
|
|
325
174
|
};
|
|
326
|
-
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';
|
|
327
176
|
/**
|
|
328
177
|
* Interaction event types emitted via 'ui-event'.
|
|
329
178
|
* These map to user-facing prompts (confirm on device, open app, etc.).
|
|
@@ -387,16 +236,34 @@ interface ConnectorEventMap {
|
|
|
387
236
|
'device-disconnect': {
|
|
388
237
|
connectId: string;
|
|
389
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
|
+
};
|
|
390
249
|
'ui-request': {
|
|
391
250
|
type: string;
|
|
392
251
|
payload?: unknown;
|
|
393
252
|
};
|
|
394
253
|
'ui-event': ConnectorUiEvent;
|
|
395
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
|
+
}
|
|
396
263
|
interface IConnector {
|
|
397
264
|
/** Physical connection type this connector uses. Fixed at construction. */
|
|
398
265
|
readonly connectionType: ConnectionType;
|
|
399
|
-
searchDevices(): Promise<ConnectorDevice[]>;
|
|
266
|
+
searchDevices(options?: ConnectorSearchDevicesOptions): Promise<ConnectorDevice[]>;
|
|
400
267
|
connect(deviceId?: string): Promise<ConnectorSession>;
|
|
401
268
|
disconnect(sessionId: string): Promise<void>;
|
|
402
269
|
call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
|
|
@@ -406,10 +273,12 @@ interface IConnector {
|
|
|
406
273
|
on<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
|
|
407
274
|
off<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
|
|
408
275
|
reset(): void;
|
|
276
|
+
setKnownCredentials?(credentials: unknown[]): Promise<void> | void;
|
|
409
277
|
}
|
|
410
278
|
interface IHardwareBridge {
|
|
411
279
|
searchDevices(params: {
|
|
412
280
|
vendor: VendorType;
|
|
281
|
+
options?: ConnectorSearchDevicesOptions;
|
|
413
282
|
}): Promise<ConnectorDevice[]>;
|
|
414
283
|
connect(params: {
|
|
415
284
|
vendor: VendorType;
|
|
@@ -450,6 +319,15 @@ interface IHardwareBridge {
|
|
|
450
319
|
type: ConnectorEventType;
|
|
451
320
|
data: unknown;
|
|
452
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;
|
|
453
331
|
}
|
|
454
332
|
/**
|
|
455
333
|
* Adapt an IHardwareBridge (multi-vendor backend) into a single-vendor IConnector.
|
|
@@ -476,6 +354,7 @@ declare function serializeConnectorError(err: unknown): ConnectorSerializedError
|
|
|
476
354
|
* unchanged. The Result shape stays confined to the connector boundary.
|
|
477
355
|
*/
|
|
478
356
|
declare function rehydrateConnectorError(error: ConnectorSerializedError): Error;
|
|
357
|
+
declare function createCombinedConnector(connectors: IConnector[]): IConnector;
|
|
479
358
|
|
|
480
359
|
declare const DEVICE_EVENT = "DEVICE_EVENT";
|
|
481
360
|
/** Events originating from the hardware device. */
|
|
@@ -483,9 +362,21 @@ declare const DEVICE: {
|
|
|
483
362
|
readonly CONNECT: "device-connect";
|
|
484
363
|
readonly DISCONNECT: "device-disconnect";
|
|
485
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";
|
|
486
377
|
};
|
|
487
378
|
|
|
488
|
-
interface BtcGetAddressParams {
|
|
379
|
+
interface BtcGetAddressParams extends PassphraseStateAware {
|
|
489
380
|
path: string;
|
|
490
381
|
coin?: string;
|
|
491
382
|
showOnDevice?: boolean;
|
|
@@ -497,7 +388,7 @@ interface BtcAddress {
|
|
|
497
388
|
address: string;
|
|
498
389
|
path: string;
|
|
499
390
|
}
|
|
500
|
-
interface BtcGetPublicKeyParams {
|
|
391
|
+
interface BtcGetPublicKeyParams extends PassphraseStateAware {
|
|
501
392
|
path: string;
|
|
502
393
|
coin?: string;
|
|
503
394
|
showOnDevice?: boolean;
|
|
@@ -511,14 +402,19 @@ interface BtcPublicKey {
|
|
|
511
402
|
path: string;
|
|
512
403
|
depth: number;
|
|
513
404
|
}
|
|
514
|
-
interface BtcSignTxParams {
|
|
405
|
+
interface BtcSignTxParams extends PassphraseStateAware {
|
|
515
406
|
psbt?: string;
|
|
516
407
|
inputs?: BtcTxInput[];
|
|
517
408
|
outputs?: BtcTxOutput[];
|
|
409
|
+
paymentRequests?: BtcPaymentRequest[];
|
|
518
410
|
refTxs?: BtcRefTransaction[];
|
|
519
411
|
coin: string;
|
|
520
412
|
locktime?: number;
|
|
521
413
|
version?: number;
|
|
414
|
+
timestamp?: number;
|
|
415
|
+
expiry?: number;
|
|
416
|
+
versionGroupId?: number;
|
|
417
|
+
branchId?: number;
|
|
522
418
|
/** Account-level derivation path (e.g. "84'/0'/0'") for wallet template. */
|
|
523
419
|
path?: string;
|
|
524
420
|
}
|
|
@@ -529,12 +425,51 @@ interface BtcTxInput {
|
|
|
529
425
|
amount: string;
|
|
530
426
|
scriptType?: 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr';
|
|
531
427
|
sequence?: number;
|
|
428
|
+
origHash?: string;
|
|
429
|
+
origIndex?: number;
|
|
430
|
+
scriptSig?: string;
|
|
431
|
+
witness?: string;
|
|
432
|
+
ownershipProof?: string;
|
|
433
|
+
commitmentData?: string;
|
|
532
434
|
}
|
|
533
435
|
interface BtcTxOutput {
|
|
534
436
|
address?: string;
|
|
535
437
|
path?: string;
|
|
438
|
+
opReturnData?: string;
|
|
536
439
|
amount: string;
|
|
537
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;
|
|
538
473
|
}
|
|
539
474
|
interface BtcRefTransaction {
|
|
540
475
|
hash: string;
|
|
@@ -550,6 +485,15 @@ interface BtcRefTransaction {
|
|
|
550
485
|
scriptPubKey: string;
|
|
551
486
|
}>;
|
|
552
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;
|
|
553
497
|
}
|
|
554
498
|
interface BtcSignedTx {
|
|
555
499
|
serializedTx: string;
|
|
@@ -557,7 +501,7 @@ interface BtcSignedTx {
|
|
|
557
501
|
signatures?: string[];
|
|
558
502
|
txid?: string;
|
|
559
503
|
}
|
|
560
|
-
interface BtcSignPsbtParams {
|
|
504
|
+
interface BtcSignPsbtParams extends PassphraseStateAware {
|
|
561
505
|
psbt: string;
|
|
562
506
|
coin?: string;
|
|
563
507
|
/** Account-level derivation path (e.g. "84'/0'/0'") for wallet template. */
|
|
@@ -566,10 +510,12 @@ interface BtcSignPsbtParams {
|
|
|
566
510
|
interface BtcSignedPsbt {
|
|
567
511
|
signedPsbt: string;
|
|
568
512
|
}
|
|
569
|
-
interface BtcSignMsgParams {
|
|
513
|
+
interface BtcSignMsgParams extends PassphraseStateAware {
|
|
570
514
|
path: string;
|
|
571
515
|
message: string;
|
|
572
516
|
coin?: string;
|
|
517
|
+
hex?: boolean;
|
|
518
|
+
noScriptType?: boolean;
|
|
573
519
|
}
|
|
574
520
|
interface BtcSignature {
|
|
575
521
|
signature: string;
|
|
@@ -577,17 +523,17 @@ interface BtcSignature {
|
|
|
577
523
|
address?: string;
|
|
578
524
|
}
|
|
579
525
|
interface IBtcMethods {
|
|
580
|
-
btcGetAddress(connectId
|
|
581
|
-
btcGetPublicKey(connectId
|
|
582
|
-
btcSignTransaction(connectId
|
|
583
|
-
btcSignPsbt(connectId
|
|
584
|
-
btcSignMessage(connectId
|
|
585
|
-
btcGetMasterFingerprint(connectId
|
|
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<{
|
|
586
532
|
masterFingerprint: string;
|
|
587
533
|
}>>;
|
|
588
534
|
}
|
|
589
535
|
|
|
590
|
-
interface SolGetAddressParams {
|
|
536
|
+
interface SolGetAddressParams extends PassphraseStateAware {
|
|
591
537
|
path: string;
|
|
592
538
|
showOnDevice?: boolean;
|
|
593
539
|
}
|
|
@@ -596,11 +542,13 @@ interface SolAddress {
|
|
|
596
542
|
address: string;
|
|
597
543
|
path: string;
|
|
598
544
|
}
|
|
599
|
-
interface SolSignTxParams {
|
|
545
|
+
interface SolSignTxParams extends PassphraseStateAware {
|
|
600
546
|
path: string;
|
|
601
547
|
/** Hex-encoded serialized transaction bytes (no 0x prefix) */
|
|
602
548
|
serializedTx: string;
|
|
603
549
|
additionalInfo?: {
|
|
550
|
+
/** Trezor Solana token definition bytes as a hex string. */
|
|
551
|
+
encodedToken?: string;
|
|
604
552
|
tokenAccountsInfos?: Array<{
|
|
605
553
|
baseAddress: string;
|
|
606
554
|
tokenProgram: string;
|
|
@@ -613,7 +561,7 @@ interface SolSignedTx {
|
|
|
613
561
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
614
562
|
signature: string;
|
|
615
563
|
}
|
|
616
|
-
interface SolSignMsgParams {
|
|
564
|
+
interface SolSignMsgParams extends PassphraseStateAware {
|
|
617
565
|
path: string;
|
|
618
566
|
/** Message bytes as hex string (no 0x prefix) */
|
|
619
567
|
message: string;
|
|
@@ -623,12 +571,12 @@ interface SolSignature {
|
|
|
623
571
|
signature: string;
|
|
624
572
|
}
|
|
625
573
|
interface ISolMethods {
|
|
626
|
-
solGetAddress(connectId
|
|
627
|
-
solSignTransaction(connectId
|
|
628
|
-
solSignMessage(connectId
|
|
574
|
+
solGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<SolGetAddressParams>>): Promise<Response<SolAddress>>;
|
|
575
|
+
solSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<SolSignTxParams>>): Promise<Response<SolSignedTx>>;
|
|
576
|
+
solSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<SolSignMsgParams>>): Promise<Response<SolSignature>>;
|
|
629
577
|
}
|
|
630
578
|
|
|
631
|
-
interface TronGetAddressParams {
|
|
579
|
+
interface TronGetAddressParams extends PassphraseStateAware {
|
|
632
580
|
path: string;
|
|
633
581
|
showOnDevice?: boolean;
|
|
634
582
|
}
|
|
@@ -637,16 +585,110 @@ interface TronAddress {
|
|
|
637
585
|
address: string;
|
|
638
586
|
path: string;
|
|
639
587
|
}
|
|
640
|
-
|
|
588
|
+
/** TRON network resource, used by freeze/unfreeze contracts. */
|
|
589
|
+
type TronResource = 'BANDWIDTH' | 'ENERGY';
|
|
590
|
+
interface TronTransferContract {
|
|
591
|
+
/**
|
|
592
|
+
* Recipient address as hex, 0x41-prefixed (`41` + 20-byte hash, 42 hex chars).
|
|
593
|
+
* A leading `0x` is tolerated. Base58 (`T...`) is NOT accepted — convert first.
|
|
594
|
+
*/
|
|
595
|
+
toAddress: string;
|
|
596
|
+
/** Amount in sun (1 TRX = 1e6 sun). */
|
|
597
|
+
amount: string | number;
|
|
598
|
+
}
|
|
599
|
+
interface TronTriggerSmartContract {
|
|
600
|
+
/** Smart-contract address, hex 0x41-prefixed. */
|
|
601
|
+
contractAddress: string;
|
|
602
|
+
/** ABI-encoded call data, hex (with or without `0x`). */
|
|
603
|
+
data: string;
|
|
604
|
+
}
|
|
605
|
+
interface TronFreezeBalanceV2Contract {
|
|
606
|
+
/** Amount to freeze, in sun. */
|
|
607
|
+
balance: number;
|
|
608
|
+
resource?: TronResource;
|
|
609
|
+
}
|
|
610
|
+
interface TronUnfreezeBalanceV2Contract {
|
|
611
|
+
/** Amount to unfreeze, in sun. */
|
|
612
|
+
balance: number;
|
|
613
|
+
resource?: TronResource;
|
|
614
|
+
}
|
|
615
|
+
interface TronVote {
|
|
616
|
+
/** Witness (SR) address, hex 0x41-prefixed. */
|
|
617
|
+
voteAddress: string;
|
|
618
|
+
voteCount: number;
|
|
619
|
+
}
|
|
620
|
+
interface TronVoteWitnessContract {
|
|
621
|
+
votes: TronVote[];
|
|
622
|
+
}
|
|
623
|
+
/** Withdraw-expired-unfreeze carries no fields beyond the implicit owner. */
|
|
624
|
+
type TronWithdrawExpireUnfreezeContract = Record<string, never>;
|
|
625
|
+
/**
|
|
626
|
+
* Exactly one field must be set — mirrors OneKey's `TronTransactionContract`.
|
|
627
|
+
* Only the six contract types Trezor firmware/protobuf supports are exposed.
|
|
628
|
+
*/
|
|
629
|
+
interface TronContract {
|
|
630
|
+
transferContract?: TronTransferContract;
|
|
631
|
+
triggerSmartContract?: TronTriggerSmartContract;
|
|
632
|
+
freezeBalanceV2Contract?: TronFreezeBalanceV2Contract;
|
|
633
|
+
unfreezeBalanceV2Contract?: TronUnfreezeBalanceV2Contract;
|
|
634
|
+
voteWitnessContract?: TronVoteWitnessContract;
|
|
635
|
+
withdrawExpireUnfreezeContract?: TronWithdrawExpireUnfreezeContract;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Cross-vendor TRON sign params. Adapters consume different shapes:
|
|
639
|
+
*
|
|
640
|
+
* - **Ledger** signs the serialized transaction directly → needs `rawTxHex`.
|
|
641
|
+
* - **Trezor** runs a two-step contract flow → needs the structured fields
|
|
642
|
+
* (`ownerAddress` + `refBlock*` + `contract` …), mirroring OneKey hd-core.
|
|
643
|
+
*
|
|
644
|
+
* Both groups are optional at the type level; provide whichever your target
|
|
645
|
+
* vendor needs (or both for a vendor-agnostic call). Each adapter validates the
|
|
646
|
+
* fields it requires at runtime and ignores the rest — neither re-decodes the
|
|
647
|
+
* other's representation.
|
|
648
|
+
*/
|
|
649
|
+
interface TronSignTxParams extends PassphraseStateAware {
|
|
641
650
|
path: string;
|
|
642
|
-
/**
|
|
643
|
-
|
|
651
|
+
/**
|
|
652
|
+
* Protobuf-encoded raw TRON transaction, hex (with or without `0x`).
|
|
653
|
+
* Consumed by Ledger; ignored by Trezor.
|
|
654
|
+
*/
|
|
655
|
+
rawTxHex?: string;
|
|
656
|
+
/**
|
|
657
|
+
* The signer's own TRON address, hex 0x41-prefixed. Required by Trezor
|
|
658
|
+
* (its contract messages carry an explicit `owner_address`); Ledger derives
|
|
659
|
+
* it from `rawTxHex`.
|
|
660
|
+
*/
|
|
661
|
+
ownerAddress?: string;
|
|
662
|
+
/** Last 2 bytes of the reference block height, hex (4 chars). Trezor. */
|
|
663
|
+
refBlockBytes?: string;
|
|
664
|
+
/** Middle 8 bytes of the reference block hash, hex (16 chars). Trezor. */
|
|
665
|
+
refBlockHash?: string;
|
|
666
|
+
/** Expiration timestamp, milliseconds. Trezor. */
|
|
667
|
+
expiration?: number;
|
|
668
|
+
/** Transaction timestamp, milliseconds. Trezor. */
|
|
669
|
+
timestamp?: number;
|
|
670
|
+
/** Energy fee cap in sun (TriggerSmartContract only). Trezor. */
|
|
671
|
+
feeLimit?: number;
|
|
672
|
+
/** Optional memo/data, hex (with or without `0x`). Trezor. */
|
|
673
|
+
data?: string;
|
|
674
|
+
/** Exactly one contract — required by Trezor. */
|
|
675
|
+
contract?: TronContract;
|
|
644
676
|
}
|
|
645
677
|
interface TronSignedTx {
|
|
646
678
|
/** 65-byte hex-encoded signature (no 0x prefix) */
|
|
647
679
|
signature: string;
|
|
680
|
+
/**
|
|
681
|
+
* The transaction's `raw_data`, re-encoded host-side from the structured
|
|
682
|
+
* fields the device signed (hex, no prefix). The signature covers exactly
|
|
683
|
+
* this serialization, so callers should broadcast THIS rather than a
|
|
684
|
+
* pre-existing raw_data blob. Present only for contract types the host can
|
|
685
|
+
* re-encode (transfer / triggerSmart); `undefined` otherwise. Despite the
|
|
686
|
+
* historic `serializedTx` name, this is the TRON `raw_data_hex` payload, not
|
|
687
|
+
* trezor-suite's full broadcast transaction envelope.
|
|
688
|
+
*/
|
|
689
|
+
serializedTx?: string;
|
|
648
690
|
}
|
|
649
|
-
interface TronSignMsgParams {
|
|
691
|
+
interface TronSignMsgParams extends PassphraseStateAware {
|
|
650
692
|
path: string;
|
|
651
693
|
/** Message hex (no 0x prefix) */
|
|
652
694
|
messageHex: string;
|
|
@@ -656,9 +698,9 @@ interface TronSignature {
|
|
|
656
698
|
signature: string;
|
|
657
699
|
}
|
|
658
700
|
interface ITronMethods {
|
|
659
|
-
tronGetAddress(connectId
|
|
660
|
-
tronSignTransaction(connectId
|
|
661
|
-
tronSignMessage(connectId
|
|
701
|
+
tronGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronGetAddressParams>>): Promise<Response<TronAddress>>;
|
|
702
|
+
tronSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignTxParams>>): Promise<Response<TronSignedTx>>;
|
|
703
|
+
tronSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignMsgParams>>): Promise<Response<TronSignature>>;
|
|
662
704
|
}
|
|
663
705
|
|
|
664
706
|
/**
|
|
@@ -687,6 +729,85 @@ declare const SDK: {
|
|
|
687
729
|
readonly DEVICE_INTERACTION: "device-interaction";
|
|
688
730
|
};
|
|
689
731
|
|
|
732
|
+
type HardwareMethodMetadata = {
|
|
733
|
+
chain: ChainForFingerprint;
|
|
734
|
+
allNetwork: boolean;
|
|
735
|
+
};
|
|
736
|
+
declare const HARDWARE_METHOD_CATALOG: {
|
|
737
|
+
readonly evmGetAddress: {
|
|
738
|
+
readonly chain: "evm";
|
|
739
|
+
readonly allNetwork: true;
|
|
740
|
+
};
|
|
741
|
+
readonly evmSignTransaction: {
|
|
742
|
+
readonly chain: "evm";
|
|
743
|
+
readonly allNetwork: false;
|
|
744
|
+
};
|
|
745
|
+
readonly evmSignMessage: {
|
|
746
|
+
readonly chain: "evm";
|
|
747
|
+
readonly allNetwork: false;
|
|
748
|
+
};
|
|
749
|
+
readonly evmSignTypedData: {
|
|
750
|
+
readonly chain: "evm";
|
|
751
|
+
readonly allNetwork: false;
|
|
752
|
+
};
|
|
753
|
+
readonly btcGetAddress: {
|
|
754
|
+
readonly chain: "btc";
|
|
755
|
+
readonly allNetwork: true;
|
|
756
|
+
};
|
|
757
|
+
readonly btcGetPublicKey: {
|
|
758
|
+
readonly chain: "btc";
|
|
759
|
+
readonly allNetwork: true;
|
|
760
|
+
};
|
|
761
|
+
readonly btcSignTransaction: {
|
|
762
|
+
readonly chain: "btc";
|
|
763
|
+
readonly allNetwork: false;
|
|
764
|
+
};
|
|
765
|
+
readonly btcSignPsbt: {
|
|
766
|
+
readonly chain: "btc";
|
|
767
|
+
readonly allNetwork: false;
|
|
768
|
+
};
|
|
769
|
+
readonly btcSignMessage: {
|
|
770
|
+
readonly chain: "btc";
|
|
771
|
+
readonly allNetwork: false;
|
|
772
|
+
};
|
|
773
|
+
readonly btcGetMasterFingerprint: {
|
|
774
|
+
readonly chain: "btc";
|
|
775
|
+
readonly allNetwork: false;
|
|
776
|
+
};
|
|
777
|
+
readonly solGetAddress: {
|
|
778
|
+
readonly chain: "sol";
|
|
779
|
+
readonly allNetwork: true;
|
|
780
|
+
};
|
|
781
|
+
readonly solSignTransaction: {
|
|
782
|
+
readonly chain: "sol";
|
|
783
|
+
readonly allNetwork: false;
|
|
784
|
+
};
|
|
785
|
+
readonly solSignMessage: {
|
|
786
|
+
readonly chain: "sol";
|
|
787
|
+
readonly allNetwork: false;
|
|
788
|
+
};
|
|
789
|
+
readonly tronGetAddress: {
|
|
790
|
+
readonly chain: "tron";
|
|
791
|
+
readonly allNetwork: true;
|
|
792
|
+
};
|
|
793
|
+
readonly tronSignTransaction: {
|
|
794
|
+
readonly chain: "tron";
|
|
795
|
+
readonly allNetwork: false;
|
|
796
|
+
};
|
|
797
|
+
readonly tronSignMessage: {
|
|
798
|
+
readonly chain: "tron";
|
|
799
|
+
readonly allNetwork: false;
|
|
800
|
+
};
|
|
801
|
+
};
|
|
802
|
+
type HardwareMethodName = keyof typeof HARDWARE_METHOD_CATALOG;
|
|
803
|
+
type AllNetworkMethodName = {
|
|
804
|
+
[K in HardwareMethodName]: (typeof HARDWARE_METHOD_CATALOG)[K]['allNetwork'] extends true ? K : never;
|
|
805
|
+
}[HardwareMethodName];
|
|
806
|
+
declare const ALL_NETWORK_METHOD_NAMES: AllNetworkMethodName[];
|
|
807
|
+
declare function getHardwareMethodMetadata(method: string): HardwareMethodMetadata | undefined;
|
|
808
|
+
declare function isAllNetworkMethodName(method: string): method is AllNetworkMethodName;
|
|
809
|
+
declare function getAllNetworkMethodChain(method: AllNetworkMethodName): ChainForFingerprint;
|
|
810
|
+
|
|
690
811
|
/**
|
|
691
812
|
* Wallet-level `ui-event` variants. Same shape as `ConnectorUiEvent` except
|
|
692
813
|
* the AppInstallProgress variant's payload is re-keyed by the adapter from
|
|
@@ -703,6 +824,28 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
|
|
|
703
824
|
};
|
|
704
825
|
};
|
|
705
826
|
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
|
|
827
|
+
type TrezorDisplayRotation = 'North' | 'East' | 'South' | 'West';
|
|
828
|
+
type TrezorSafetyCheckLevel = 'Strict' | 'PromptAlways' | 'PromptTemporarily';
|
|
829
|
+
type TrezorDeviceSettingsParams = {
|
|
830
|
+
language?: string;
|
|
831
|
+
label?: string;
|
|
832
|
+
use_passphrase?: boolean;
|
|
833
|
+
homescreen?: string;
|
|
834
|
+
auto_lock_delay_ms?: number;
|
|
835
|
+
display_rotation?: TrezorDisplayRotation;
|
|
836
|
+
passphrase_always_on_device?: boolean;
|
|
837
|
+
safety_checks?: TrezorSafetyCheckLevel;
|
|
838
|
+
experimental_features?: boolean;
|
|
839
|
+
hide_passphrase_from_host?: boolean;
|
|
840
|
+
haptic_feedback?: boolean;
|
|
841
|
+
auto_lock_delay_battery_ms?: number;
|
|
842
|
+
};
|
|
843
|
+
type TrezorBrightnessParams = {
|
|
844
|
+
value?: number;
|
|
845
|
+
};
|
|
846
|
+
type TrezorChangePinParams = {
|
|
847
|
+
remove?: boolean;
|
|
848
|
+
};
|
|
706
849
|
/**
|
|
707
850
|
* Cross-chain / cross-vendor options passed alongside any chain method's
|
|
708
851
|
* own params (the optional last argument). Holds operation-level switches
|
|
@@ -717,6 +860,48 @@ interface ICommonCallParams {
|
|
|
717
860
|
*/
|
|
718
861
|
autoInstallApp?: boolean;
|
|
719
862
|
}
|
|
863
|
+
type NullableCallArg<T> = T | null | undefined;
|
|
864
|
+
interface IPassphraseCallParams {
|
|
865
|
+
passphraseState?: string;
|
|
866
|
+
useEmptyPassphrase?: boolean;
|
|
867
|
+
}
|
|
868
|
+
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
869
|
+
type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
|
|
870
|
+
interface AllNetworkAddressParams {
|
|
871
|
+
network: string;
|
|
872
|
+
path: string;
|
|
873
|
+
showOnDevice?: boolean;
|
|
874
|
+
methodName: AllNetworkMethodName;
|
|
875
|
+
[key: string]: unknown;
|
|
876
|
+
}
|
|
877
|
+
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
878
|
+
bundle: AllNetworkAddressParams[];
|
|
879
|
+
}
|
|
880
|
+
type AllNetworkDeviceIdentity = {
|
|
881
|
+
vendor: 'ledger';
|
|
882
|
+
type: 'chainFingerprint';
|
|
883
|
+
chain: ChainForFingerprint;
|
|
884
|
+
value: string;
|
|
885
|
+
} | {
|
|
886
|
+
vendor: 'trezor';
|
|
887
|
+
type: 'deviceId';
|
|
888
|
+
value: string;
|
|
889
|
+
};
|
|
890
|
+
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
891
|
+
error?: string;
|
|
892
|
+
code?: HardwareErrorCode | number;
|
|
893
|
+
errorCode?: string | number;
|
|
894
|
+
connectId?: string;
|
|
895
|
+
deviceId?: string;
|
|
896
|
+
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
897
|
+
chainFingerprint?: string;
|
|
898
|
+
chainFingerprintChain?: ChainForFingerprint;
|
|
899
|
+
params?: Record<string, unknown>;
|
|
900
|
+
};
|
|
901
|
+
type AllNetworkAddressResponse = AllNetworkAddressParams & {
|
|
902
|
+
success: boolean;
|
|
903
|
+
payload?: AllNetworkAddressResponsePayload;
|
|
904
|
+
};
|
|
720
905
|
interface PassphraseResponse {
|
|
721
906
|
passphrase: string;
|
|
722
907
|
/** If true, passphrase will be entered on the device. `passphrase` field is ignored. */
|
|
@@ -733,11 +918,30 @@ type DeviceEvent = {
|
|
|
733
918
|
} | {
|
|
734
919
|
type: typeof DEVICE.CHANGED;
|
|
735
920
|
payload: DeviceInfo;
|
|
921
|
+
} | {
|
|
922
|
+
type: typeof DEVICE.FEATURES;
|
|
923
|
+
device: DeviceInfo & {
|
|
924
|
+
features: Record<string, unknown>;
|
|
925
|
+
};
|
|
926
|
+
payload: {
|
|
927
|
+
device: DeviceInfo & {
|
|
928
|
+
features: Record<string, unknown>;
|
|
929
|
+
};
|
|
930
|
+
};
|
|
931
|
+
} | {
|
|
932
|
+
type: typeof DEVICE.TREZOR_THP_CREDENTIALS_CHANGED;
|
|
933
|
+
payload: {
|
|
934
|
+
connectId: string;
|
|
935
|
+
deviceId?: string;
|
|
936
|
+
credentials: Record<string, unknown>[];
|
|
937
|
+
};
|
|
736
938
|
};
|
|
737
939
|
type UiRequestEvent = {
|
|
738
940
|
type: typeof UI_REQUEST.REQUEST_PIN;
|
|
739
941
|
payload: {
|
|
740
|
-
device
|
|
942
|
+
device?: DeviceInfo;
|
|
943
|
+
connectId?: string;
|
|
944
|
+
type?: string;
|
|
741
945
|
};
|
|
742
946
|
} | {
|
|
743
947
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
@@ -804,6 +1008,14 @@ type UiRequestEvent = {
|
|
|
804
1008
|
vendor: string;
|
|
805
1009
|
appName: string;
|
|
806
1010
|
};
|
|
1011
|
+
} | {
|
|
1012
|
+
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1013
|
+
payload: {
|
|
1014
|
+
connectId: string;
|
|
1015
|
+
availableMethods: number[];
|
|
1016
|
+
selectedMethod: number;
|
|
1017
|
+
nfcData?: string;
|
|
1018
|
+
};
|
|
807
1019
|
} | {
|
|
808
1020
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
809
1021
|
payload: Record<string, never>;
|
|
@@ -854,16 +1066,40 @@ interface HardwareEventMap {
|
|
|
854
1066
|
type: typeof DEVICE.CHANGED;
|
|
855
1067
|
payload: DeviceInfo;
|
|
856
1068
|
};
|
|
1069
|
+
[DEVICE.FEATURES]: {
|
|
1070
|
+
type: typeof DEVICE.FEATURES;
|
|
1071
|
+
device: DeviceInfo & {
|
|
1072
|
+
features: Record<string, unknown>;
|
|
1073
|
+
};
|
|
1074
|
+
payload: {
|
|
1075
|
+
device: DeviceInfo & {
|
|
1076
|
+
features: Record<string, unknown>;
|
|
1077
|
+
};
|
|
1078
|
+
};
|
|
1079
|
+
};
|
|
1080
|
+
[DEVICE.TREZOR_THP_CREDENTIALS_CHANGED]: {
|
|
1081
|
+
type: typeof DEVICE.TREZOR_THP_CREDENTIALS_CHANGED;
|
|
1082
|
+
payload: {
|
|
1083
|
+
connectId: string;
|
|
1084
|
+
deviceId?: string;
|
|
1085
|
+
credentials: Record<string, unknown>[];
|
|
1086
|
+
};
|
|
1087
|
+
};
|
|
857
1088
|
[UI_REQUEST.REQUEST_PIN]: {
|
|
858
1089
|
type: typeof UI_REQUEST.REQUEST_PIN;
|
|
859
1090
|
payload: {
|
|
860
|
-
device
|
|
1091
|
+
device?: DeviceInfo;
|
|
1092
|
+
connectId?: string;
|
|
1093
|
+
type?: string;
|
|
861
1094
|
};
|
|
862
1095
|
};
|
|
863
1096
|
[UI_REQUEST.REQUEST_PASSPHRASE]: {
|
|
864
1097
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
865
1098
|
payload: {
|
|
866
|
-
device
|
|
1099
|
+
device?: DeviceInfo;
|
|
1100
|
+
connectId?: string;
|
|
1101
|
+
passphraseState?: string;
|
|
1102
|
+
useEmptyPassphrase?: boolean;
|
|
867
1103
|
};
|
|
868
1104
|
};
|
|
869
1105
|
[UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
|
|
@@ -929,6 +1165,15 @@ interface HardwareEventMap {
|
|
|
929
1165
|
appName: string;
|
|
930
1166
|
};
|
|
931
1167
|
};
|
|
1168
|
+
[UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
|
|
1169
|
+
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1170
|
+
payload: {
|
|
1171
|
+
connectId: string;
|
|
1172
|
+
availableMethods: number[];
|
|
1173
|
+
selectedMethod: number;
|
|
1174
|
+
nfcData?: string;
|
|
1175
|
+
};
|
|
1176
|
+
};
|
|
932
1177
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
933
1178
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
934
1179
|
payload: Record<string, never>;
|
|
@@ -959,7 +1204,41 @@ interface HardwareEventMap {
|
|
|
959
1204
|
};
|
|
960
1205
|
};
|
|
961
1206
|
}
|
|
962
|
-
interface
|
|
1207
|
+
interface IDeviceManagerMethods {
|
|
1208
|
+
getFeatures?(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
1209
|
+
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams): Promise<Response<Record<string, unknown>>>;
|
|
1210
|
+
setBrightness?(connectId: string, params?: TrezorBrightnessParams): Promise<Response<Record<string, unknown>>>;
|
|
1211
|
+
changePin?(connectId: string, params?: TrezorChangePinParams): Promise<Response<Record<string, unknown>>>;
|
|
1212
|
+
wipeDevice?(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
1213
|
+
}
|
|
1214
|
+
interface IWalletStateMethods {
|
|
1215
|
+
/**
|
|
1216
|
+
* Resolve the device's active passphrase wallet identity (`passphraseState`).
|
|
1217
|
+
* Today this is the compressed public key derived at `m/44'/0'/0'`, not the
|
|
1218
|
+
* 4-byte master fingerprint. Two modes:
|
|
1219
|
+
*
|
|
1220
|
+
* - **Discover** (no `passphraseState`): for a **standard wallet** (passphrase
|
|
1221
|
+
* protection off) returns `null` — there's one wallet and nothing to pin.
|
|
1222
|
+
* The SDK may still create a THP app session and derive once so it can
|
|
1223
|
+
* unlock and re-read fresh Features, but it does not ask for a passphrase.
|
|
1224
|
+
* For a **passphrase wallet** it creates a fresh session (prompts the user),
|
|
1225
|
+
* derives its state, and returns it so the host can persist the wallet.
|
|
1226
|
+
* Mirrors OneKey's null-for-standard convention.
|
|
1227
|
+
* - **Verify** (`passphraseState` given): align the device to that wallet and
|
|
1228
|
+
* confirm the derived state matches. Fails with `PassphraseStateMismatch`
|
|
1229
|
+
* when the entered passphrase yields a different wallet.
|
|
1230
|
+
*
|
|
1231
|
+
* SECURITY: every wallet-bound op that carries a `passphraseState` (getAddress,
|
|
1232
|
+
* sign, …) creates a fresh session, re-derives, and confirms the state before
|
|
1233
|
+
* the chain method runs. Standard wallets should pass `useEmptyPassphrase` so
|
|
1234
|
+
* the host can explicitly create the empty-passphrase session.
|
|
1235
|
+
*
|
|
1236
|
+
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1237
|
+
* it. Implemented by `TrezorAdapter`.
|
|
1238
|
+
*/
|
|
1239
|
+
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1240
|
+
}
|
|
1241
|
+
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
963
1242
|
readonly vendor: string;
|
|
964
1243
|
readonly activeTransport: TransportType | null;
|
|
965
1244
|
init(config: TConfig): Promise<void>;
|
|
@@ -973,6 +1252,7 @@ interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, I
|
|
|
973
1252
|
getSupportedChains(): ChainCapability[];
|
|
974
1253
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
975
1254
|
cancel(connectId?: string): void;
|
|
1255
|
+
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
976
1256
|
/** Respond to any pending `ui-request-*`. */
|
|
977
1257
|
uiResponse(response: UiResponseEvent): void;
|
|
978
1258
|
/**
|
|
@@ -999,12 +1279,19 @@ interface SearchDevicesOptions {
|
|
|
999
1279
|
* should leave this false so an active session can still be reused.
|
|
1000
1280
|
*/
|
|
1001
1281
|
resetSession?: boolean;
|
|
1282
|
+
/**
|
|
1283
|
+
* Wait for every physical transport behind a fused connector. Use this for
|
|
1284
|
+
* transport binding/pairing UIs that must show BLE candidates even when USB
|
|
1285
|
+
* was discovered first.
|
|
1286
|
+
*/
|
|
1287
|
+
waitForAllTransports?: boolean;
|
|
1002
1288
|
}
|
|
1003
1289
|
|
|
1004
|
-
interface EvmGetAddressParams {
|
|
1290
|
+
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
1005
1291
|
path: string;
|
|
1006
1292
|
showOnDevice?: boolean;
|
|
1007
1293
|
chainId?: number;
|
|
1294
|
+
ethereumDefinitions?: EvmEthereumDefinitions;
|
|
1008
1295
|
}
|
|
1009
1296
|
interface EvmAddress {
|
|
1010
1297
|
address: string;
|
|
@@ -1012,21 +1299,36 @@ interface EvmAddress {
|
|
|
1012
1299
|
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
1013
1300
|
publicKey?: string;
|
|
1014
1301
|
}
|
|
1015
|
-
interface
|
|
1302
|
+
interface EvmSignTxBaseParams extends PassphraseStateAware {
|
|
1016
1303
|
path: string;
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1304
|
+
chainId?: number;
|
|
1305
|
+
}
|
|
1306
|
+
/** Ledger shape: the whole RLP-serialized tx (0x-prefixed or plain hex); structured fields forbidden. */
|
|
1307
|
+
interface EvmSignTxLedgerParams extends EvmSignTxBaseParams {
|
|
1308
|
+
serializedTx: string;
|
|
1309
|
+
to?: never;
|
|
1310
|
+
value?: never;
|
|
1311
|
+
nonce?: never;
|
|
1312
|
+
gasLimit?: never;
|
|
1313
|
+
gasPrice?: never;
|
|
1314
|
+
txType?: never;
|
|
1315
|
+
maxFeePerGas?: never;
|
|
1316
|
+
maxPriorityFeePerGas?: never;
|
|
1317
|
+
accessList?: never;
|
|
1318
|
+
data?: never;
|
|
1319
|
+
paymentRequest?: never;
|
|
1320
|
+
ethereumDefinitions?: never;
|
|
1321
|
+
}
|
|
1322
|
+
/** Trezor shape: structured EthereumSignTx protobuf fields; serializedTx forbidden. */
|
|
1323
|
+
interface EvmSignTxTrezorParams extends EvmSignTxBaseParams {
|
|
1324
|
+
serializedTx?: never;
|
|
1023
1325
|
/** Contract address or recipient. Optional for contract deployment transactions. */
|
|
1024
1326
|
to?: string;
|
|
1025
1327
|
value?: string;
|
|
1026
|
-
chainId?: number;
|
|
1027
1328
|
nonce?: string;
|
|
1028
1329
|
gasLimit?: string;
|
|
1029
1330
|
gasPrice?: string;
|
|
1331
|
+
txType?: number;
|
|
1030
1332
|
maxFeePerGas?: string;
|
|
1031
1333
|
maxPriorityFeePerGas?: string;
|
|
1032
1334
|
accessList?: Array<{
|
|
@@ -1034,6 +1336,45 @@ interface EvmSignTxParams {
|
|
|
1034
1336
|
storageKeys: string[];
|
|
1035
1337
|
}>;
|
|
1036
1338
|
data?: string;
|
|
1339
|
+
paymentRequest?: EvmPaymentRequest;
|
|
1340
|
+
ethereumDefinitions?: EvmEthereumDefinitions;
|
|
1341
|
+
}
|
|
1342
|
+
/** Mutually exclusive vendor shapes; each adapter narrows to its own. */
|
|
1343
|
+
type EvmSignTxParams = EvmSignTxLedgerParams | EvmSignTxTrezorParams;
|
|
1344
|
+
interface EvmEthereumDefinitions {
|
|
1345
|
+
/** Trezor Ethereum network definition bytes as a hex string. */
|
|
1346
|
+
encodedNetwork?: string;
|
|
1347
|
+
/** Trezor Ethereum token definition bytes as a hex string. */
|
|
1348
|
+
encodedToken?: string;
|
|
1349
|
+
}
|
|
1350
|
+
interface EvmPaymentRequestMemo {
|
|
1351
|
+
textMemo?: {
|
|
1352
|
+
text: string;
|
|
1353
|
+
};
|
|
1354
|
+
textDetailsMemo?: {
|
|
1355
|
+
title: string;
|
|
1356
|
+
text: string;
|
|
1357
|
+
};
|
|
1358
|
+
refundMemo?: {
|
|
1359
|
+
address: string;
|
|
1360
|
+
addressN?: number[];
|
|
1361
|
+
mac: string;
|
|
1362
|
+
};
|
|
1363
|
+
coinPurchaseMemo?: {
|
|
1364
|
+
coinType: number;
|
|
1365
|
+
amount: string;
|
|
1366
|
+
address: string;
|
|
1367
|
+
addressN?: number[];
|
|
1368
|
+
mac: string;
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
interface EvmPaymentRequest {
|
|
1372
|
+
nonce?: string;
|
|
1373
|
+
recipientName: string;
|
|
1374
|
+
memos?: EvmPaymentRequestMemo[];
|
|
1375
|
+
/** Decimal string in subunits; SDK encodes it as SLIP-24 uint256 LE hex. */
|
|
1376
|
+
amount?: string;
|
|
1377
|
+
signature: string;
|
|
1037
1378
|
}
|
|
1038
1379
|
interface EvmSignedTx {
|
|
1039
1380
|
/** Recovery id as `0x`-prefixed hex string. */
|
|
@@ -1044,16 +1385,20 @@ interface EvmSignedTx {
|
|
|
1044
1385
|
s: string;
|
|
1045
1386
|
serializedTx?: string;
|
|
1046
1387
|
}
|
|
1047
|
-
interface EvmSignMsgParams {
|
|
1388
|
+
interface EvmSignMsgParams extends PassphraseStateAware {
|
|
1048
1389
|
path: string;
|
|
1049
1390
|
message: string;
|
|
1391
|
+
chainId?: number;
|
|
1050
1392
|
hex?: boolean;
|
|
1393
|
+
ethereumDefinitions?: EvmEthereumDefinitions;
|
|
1051
1394
|
}
|
|
1052
1395
|
type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
|
|
1053
|
-
interface EvmSignTypedDataFull {
|
|
1396
|
+
interface EvmSignTypedDataFull extends PassphraseStateAware {
|
|
1054
1397
|
path: string;
|
|
1398
|
+
chainId?: number;
|
|
1055
1399
|
/** Defaults to `'full'` when omitted. */
|
|
1056
1400
|
mode?: 'full';
|
|
1401
|
+
ethereumDefinitions?: EvmEthereumDefinitions;
|
|
1057
1402
|
data: {
|
|
1058
1403
|
domain: EIP712Domain;
|
|
1059
1404
|
types: Record<string, Array<{
|
|
@@ -1064,12 +1409,22 @@ interface EvmSignTypedDataFull {
|
|
|
1064
1409
|
message: Record<string, unknown>;
|
|
1065
1410
|
};
|
|
1066
1411
|
metamaskV4Compat?: boolean;
|
|
1412
|
+
showMessageHash?: boolean;
|
|
1413
|
+
/**
|
|
1414
|
+
* Optional host-computed hashes. Core Trezor models still use full typed-data
|
|
1415
|
+
* signing for display, while Trezor One can fall back to typed-hash signing
|
|
1416
|
+
* when firmware cannot compute the hashes itself.
|
|
1417
|
+
*/
|
|
1418
|
+
domainSeparatorHash?: string;
|
|
1419
|
+
messageHash?: string;
|
|
1067
1420
|
}
|
|
1068
|
-
interface EvmSignTypedDataHash {
|
|
1421
|
+
interface EvmSignTypedDataHash extends PassphraseStateAware {
|
|
1069
1422
|
path: string;
|
|
1423
|
+
chainId?: number;
|
|
1070
1424
|
mode: 'hash';
|
|
1071
1425
|
domainSeparatorHash: string;
|
|
1072
1426
|
messageHash: string;
|
|
1427
|
+
ethereumDefinitions?: EvmEthereumDefinitions;
|
|
1073
1428
|
}
|
|
1074
1429
|
interface EIP712Domain {
|
|
1075
1430
|
name?: string;
|
|
@@ -1085,10 +1440,10 @@ interface EvmSignature {
|
|
|
1085
1440
|
address?: string;
|
|
1086
1441
|
}
|
|
1087
1442
|
interface IEvmMethods {
|
|
1088
|
-
evmGetAddress(connectId
|
|
1089
|
-
evmSignTransaction(connectId
|
|
1090
|
-
evmSignMessage(connectId
|
|
1091
|
-
evmSignTypedData(connectId
|
|
1443
|
+
evmGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmGetAddressParams>>): Promise<Response<EvmAddress>>;
|
|
1444
|
+
evmSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTxParams>>): Promise<Response<EvmSignedTx>>;
|
|
1445
|
+
evmSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignMsgParams>>): Promise<Response<EvmSignature>>;
|
|
1446
|
+
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1092
1447
|
}
|
|
1093
1448
|
|
|
1094
1449
|
/**
|
|
@@ -1204,32 +1559,8 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
1204
1559
|
emit<K extends keyof TMap & string>(event: K, data: TMap[K]): void;
|
|
1205
1560
|
emit(event: string, data: unknown): void;
|
|
1206
1561
|
removeAllListeners(): void;
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
/** 10 min — every UI request is human-in-the-loop; bias toward "wait long". */
|
|
1210
|
-
declare const UI_REQUEST_DEFAULT_TIMEOUT_MS = 600000;
|
|
1211
|
-
declare const UI_REQUEST_PREEMPTED_TAG = "UiRequestPreempted";
|
|
1212
|
-
declare const UI_REQUEST_CANCELLED_TAG = "UiRequestCancelled";
|
|
1213
|
-
declare const UI_REQUEST_TIMEOUT_TAG = "UiRequestTimeout";
|
|
1214
|
-
/**
|
|
1215
|
-
* Per-type single-slot registry for adapter-level UI requests. A new `wait`
|
|
1216
|
-
* of the same type supersedes (rejects) the prior pending entry. With the
|
|
1217
|
-
* job queue running globally serially, cross-type collisions don't occur in
|
|
1218
|
-
* normal flow — same-type preemption is a defensive measure for callers
|
|
1219
|
-
* that fire the same request twice without waiting on the first.
|
|
1220
|
-
*
|
|
1221
|
-
* Unknown response types are dropped silently so the public `uiResponse`
|
|
1222
|
-
* entry never throws.
|
|
1223
|
-
*/
|
|
1224
|
-
declare class UiRequestRegistry {
|
|
1225
|
-
private pending;
|
|
1226
|
-
wait<T = unknown>(requestType: string, options?: {
|
|
1227
|
-
timeoutMs?: number;
|
|
1228
|
-
}): Promise<T>;
|
|
1229
|
-
resolve(responseType: string, payload: unknown): void;
|
|
1230
|
-
cancel(requestType?: string): void;
|
|
1231
|
-
reset(): void;
|
|
1232
|
-
hasPending(requestType?: string): boolean;
|
|
1562
|
+
/** Number of listeners registered for `event`. 0 if none. */
|
|
1563
|
+
listenerCount(event: string): number;
|
|
1233
1564
|
}
|
|
1234
1565
|
|
|
1235
1566
|
/**
|
|
@@ -1252,11 +1583,32 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
1252
1583
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
1253
1584
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
1254
1585
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1586
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger';
|
|
1587
|
+
type HardwareDeviceIdentityInput = {
|
|
1588
|
+
name?: string | null;
|
|
1589
|
+
localName?: string | null;
|
|
1590
|
+
bleName?: string | null;
|
|
1591
|
+
model?: string | null;
|
|
1592
|
+
modelName?: string | null;
|
|
1593
|
+
type?: string | null;
|
|
1594
|
+
productName?: string | null;
|
|
1595
|
+
manufacturerName?: string | null;
|
|
1596
|
+
vendor?: number | string | null;
|
|
1597
|
+
vendorId?: number | null;
|
|
1598
|
+
product?: number | string | null;
|
|
1599
|
+
productId?: number | null;
|
|
1600
|
+
label?: string | null;
|
|
1601
|
+
fw_vendor?: string | null;
|
|
1602
|
+
internal_model?: string | null;
|
|
1603
|
+
onekey_version?: string | null;
|
|
1604
|
+
onekey_device_type?: string | null;
|
|
1605
|
+
onekey_serial?: string | null;
|
|
1606
|
+
serviceUUIDs?: string[] | null;
|
|
1607
|
+
advertisedServiceUuids?: string[] | null;
|
|
1608
|
+
serviceUuids?: string[] | null;
|
|
1609
|
+
};
|
|
1610
|
+
declare function detectHardwareVendorFromDescriptor(input: HardwareDeviceIdentityInput): DetectableHardwareVendor | undefined;
|
|
1611
|
+
declare function isKnownNonTargetHardwareVendor(input: HardwareDeviceIdentityInput, targetVendor: DetectableHardwareVendor): boolean;
|
|
1260
1612
|
|
|
1261
1613
|
/**
|
|
1262
1614
|
* Generic batch call with progress reporting.
|
|
@@ -1267,4 +1619,35 @@ declare function batchCall<TParam, TResult>(params: TParam[], callFn: (p: TParam
|
|
|
1267
1619
|
total: number;
|
|
1268
1620
|
}) => void): Promise<Response<TResult[]>>;
|
|
1269
1621
|
|
|
1270
|
-
|
|
1622
|
+
type AllNetworkCallItemContext = {
|
|
1623
|
+
connectId: string;
|
|
1624
|
+
deviceId: string;
|
|
1625
|
+
method: AllNetworkMethodName;
|
|
1626
|
+
chain: ChainForFingerprint;
|
|
1627
|
+
item: AllNetworkAddressParams;
|
|
1628
|
+
index: number;
|
|
1629
|
+
};
|
|
1630
|
+
type AllNetworkAttachIdentityContext = AllNetworkCallItemContext & {
|
|
1631
|
+
payload: Record<string, unknown>;
|
|
1632
|
+
};
|
|
1633
|
+
type AllNetworkResponseContext = AllNetworkCallItemContext & {
|
|
1634
|
+
response: AllNetworkAddressResponse;
|
|
1635
|
+
};
|
|
1636
|
+
type RunAllNetworkGetAddressOptions = {
|
|
1637
|
+
connectId: string;
|
|
1638
|
+
deviceId: string;
|
|
1639
|
+
params: AllNetworkGetAddressParams;
|
|
1640
|
+
getMethodChain?: (method: AllNetworkMethodName, item: AllNetworkAddressParams) => ChainForFingerprint;
|
|
1641
|
+
normalizeItem?: (method: AllNetworkMethodName, item: AllNetworkAddressParams) => AllNetworkAddressParams;
|
|
1642
|
+
buildUnsupportedNetworkResponse?: (item: AllNetworkAddressParams, method: AllNetworkMethodName) => AllNetworkAddressResponse | undefined;
|
|
1643
|
+
callItem: (context: AllNetworkCallItemContext) => Promise<Response<unknown>>;
|
|
1644
|
+
attachIdentity: (context: AllNetworkAttachIdentityContext) => Promise<AllNetworkAddressResponse>;
|
|
1645
|
+
shouldAbortBundle?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => boolean;
|
|
1646
|
+
buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
|
|
1647
|
+
};
|
|
1648
|
+
declare function runAllNetworkGetAddress({ connectId, deviceId, params, getMethodChain, normalizeItem, buildUnsupportedNetworkResponse, callItem, attachIdentity, shouldAbortBundle, buildTopLevelFailure, }: RunAllNetworkGetAddressOptions): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
1649
|
+
declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
|
|
1650
|
+
|
|
1651
|
+
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1652
|
+
|
|
1653
|
+
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 EvmSignTxLedgerParams, type EvmSignTxParams, type EvmSignTxTrezorParams, 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 };
|