Commit 3bb38cb
authored
Feat/ton sign data (#778)
* feat(ton): add tonSignData method for TON Connect v2 signData
- New `tonSignData` method dispatching firmware TonSignData/TonSignedData
for text/binary/cell payload signing, mirroring the TonSignProof shape.
- Re-export TonSignDataType as a runtime value from @onekeyfe/hd-core so
consumers can use the enum (previously only re-exported as a type, so
`TonSignDataType.TEXT` threw at runtime).
- Map firmware Failure_PinMismatch to new HardwareErrorCode.PinMismatch
(828); surfaced only in set/change-PIN flows, so not added to the
session-release list.
- Regenerate hd-transport messages.ts and core messages.json from the
updated firmware proto.
* refactor(hwk-ledger-adapter): unify UI events and legacy SDK lifecycle
App-side now subscribes hardware UI events from a single hw.on(...) bus
instead of mixing connector.on('ui-event') with hw.on(UI_REQUEST.X).
LedgerAdapter forwards the connector 'ui-event' channel onto its own
emitter so the four EConnectorInteraction values (ConfirmOnDevice /
ConfirmOpenApp / UnlockDevice / InteractionComplete) reach consumers
through the same surface as REQUEST_DEVICE_PERMISSION etc. The dead
'ui-request_confirmation' → REQUEST_BUTTON path and its 'ui-request'
listener are removed.
Legacy-SDK chains (TRON today, future XRP/ADA/DOT) now go through a
single withLegacyChainCall wrapper that owns the full lifecycle:
pre-flight ensureAppOpen, ConfirmOnDevice/InteractionComplete pairing,
wrong-app retry, and symmetric UI cleanup on failure paths. TRON
handlers shrink ~40% and stop reimplementing the open-app boilerplate.
AppManager.ensureAppOpen invokes the onConfirmOnDevice callback BEFORE
issuing the blocking OpenAppCommand APDU; previously the prompt event
fired after the user had already confirmed on-device, so UI consumers
showed and immediately closed the "open app" toast. The fallback path
also closes any lingering ConfirmOpenApp prompt when ensureAppOpen
itself throws (e.g. 0x6807 app-not-installed).
mapLedgerError accepts an optional defaultAppName so DMK signer errors
(which lack appName) get a chain-bound fallback. LedgerConnectorBase
.dispatcher injects this once per call via _ctxForMethod, keeping
chain handlers' wrapError calls a single line. Downstream the App
layer's ThirdPartyAppNotInstalled toast can interpolate {appName}
across all chains, not just TRON.
Adds focused debug logs at points where, when bugs occur, no upstream
log can localize the failure: AppManager (currentApp / closeApp /
openApp statusCode / waitForApp exhausted), legacyChainCall decision
points (pre-flight failure / non-wrong-app / wrong-app retry /
retry failure / retry success), and BTC wallet template selection.
* fix(hwk-ledger-adapter): stop duplicating the same device with mismatched labels
Two independent bugs combined to make a single physical Ledger appear as
two devices in the discovered list — one labelled with its real name and
one labelled "Ledger".
1. LedgerAdapter.searchDevices() accumulated entries instead of replacing
them. DMK assigns ephemeral UUIDs as USB device paths (which we use as
connectId), so each replug produced a fresh connectId while the prior
connectId still sat in the cache pointing at a device DMK no longer
recognized. Fix: clear the cache before writing this round's raw result
so it always reflects current discovery state.
2. LedgerConnectorBase.connect() emitted 'device-connect' with a hardcoded
`name: 'Ledger'` placeholder. The adapter's deviceConnectHandler then
wrote that placeholder over the real label that searchDevices() had
just stored. Fix: capture the searchDevices() return value at connect
entry and emit the real name found by connectId; fall back to 'Ledger'
only if the device isn't in this round's discovery.
Both fixes are required: clearing the cache without fixing the emit still
leaves the active device's label clobbered by the placeholder; fixing the
emit without clearing the cache still leaves stale connectId entries from
prior plug events.
* chore: release 1.1.26-alpha.9
* refactor(hwk-ledger-adapter): replace setDebugEnabled with setLogger sink
Hosts now inject a typed logger callback instead of toggling a boolean
to switch console output on/off. Makes SDK debug output flow into the
host's existing logging pipeline (e.g. defaultLogger.hardware.sdkLog).
setLogger((level, ...args) => { ... }) // host-supplied
debugLog('[X]', value) // routed through the injected sink
Removes setDebugEnabled / isDebugEnabled. SDK no longer holds a
console-output flag; not injecting a logger means the SDK is silent.
Cross-runtime note: this module's `logger` is a per-process singleton.
Hosts that span multiple runtimes (e.g. MV3 extensions where the SW
holds the adapter and an offscreen document holds the connector) must
call setLogger from each runtime — they don't share state.
* refactor(hwk-ledger-adapter): unify SDK events behind onSdkEvent bus
Replaces the single-sink setLogger callback with a typed event bus,
matching the pattern OneKey's own hd-core uses (addHardwareGlobalEventListener).
onSdkEvent((event) => {
if (event.type === 'log') /* ... */
})
`SdkEvent` is a discriminated union — currently `{ type: 'log', level,
message }`. Future variants (firmware progress, battery state, ...)
extend the union and host adapters dispatch via the same subscription.
Why this matters for cross-runtime integration: hosts that span SW ↔
offscreen (MV3 extensions) or main ↔ renderer (Electron) wire one IPC
channel that forwards the whole `SdkEvent` payload. Adding a new event
variant doesn't require a new IPC route, a new subscriber, or a new
host-side handler — the dispatch is data-driven on `event.type`.
debugLog/debugError now `emitSdkEvent({type: 'log', ...})` internally;
hosts that want logs subscribe and route to their logger pipeline.
With no subscribers the bus skips stringification, so the SDK has zero
overhead when nobody's listening.
Removes setLogger / Logger / LogLevel exports.
* chore(hwk-ledger-adapter): log DMK signer interactions; trim sdkEventBus comments
Adds a single debugLog at each chain's signer.onInteraction site so the
raw DMK interaction string (verify-address / sign-transaction /
confirm-open-app / interaction-complete / unlock-device / ...) is
visible in the host's SDK log scope. Without it, the entire device-side
state machine between IO start and IO end is a black box — useful for
diagnosing UI-event timing questions like "did verify-address actually
fire on the device" or "where did app-switch insert itself".
Trims redundant prose from sdkEventBus.ts and debugLog.ts that the file
header / function name already conveys.
* chore: release 1.1.26-alpha.10
* fix: address PR review feedback
- TonSignData: restore getVersionRange(). With strictCheckDeviceSupport=true
the core consults this method's version matrix; an empty range causes
every device to be classified as unsupported and the TonSignData typedCall
is rejected before run() ever fires. Aligned with TonSignMessage's
getFixInitStateErrorVersionRange — bump when the firmware ships TonSignData.
- LedgerConnectorBase.call: stop logging full call params via
JSON.stringify(params). Now that debugLog flows through onSdkEvent into
the host's defaultLogger pipeline, sensitive payloads (serializedTx,
psbt, rawTxHex, messageHex, typed data) would propagate to telemetry /
persistent stores. Replaced with summarizeCallParams() which surfaces
only path, length-of-payload, and harmless flags.
* revert: roll back PR review fixes per maintainer call
- TonSignData: drop strictCheckDeviceSupport (set to false) and remove
getVersionRange(). Firmware version that ships TonSignData isn't decided
yet; gating now would lock out every connected device. Re-enable both
once the touch/classic1s min versions are known.
- LedgerConnectorBase.call: restore JSON.stringify(params) in debugLog.
Log bus only feeds the host's local defaultLogger pipeline (no third-party
telemetry forwarding), so full params are acceptable for now and useful
for in-the-wild debugging.1 parent 7b8e0ff commit 3bb38cb
65 files changed
Lines changed: 1092 additions & 533 deletions
File tree
- packages
- connect-examples
- electron-example
- expo-example
- src/data
- expo-playground
- core
- src
- api
- alephium
- ton
- constants
- data/messages
- device
- types/api
- hd-ble-sdk
- hd-cli
- hd-common-connect-sdk
- hd-transport-electron
- hd-transport-emulator
- hd-transport-http
- hd-transport-lowlevel
- hd-transport-react-native
- hd-transport-usb
- hd-transport-web-device
- hd-transport
- src/types
- hd-web-sdk
- hwk-adapter-core
- src
- types
- utils
- hwk-ledger-adapter
- src
- __tests__
- adapter
- app
- connector
- chains
- device
- signer
- utils
- hwk-ledger-connector-ble
- hwk-ledger-connector-webhid
- submodules
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
167 | 223 | | |
168 | 224 | | |
169 | 225 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 1 | | |
7 | 2 | | |
8 | 3 | | |
9 | 4 | | |
10 | 5 | | |
11 | 6 | | |
12 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11569 | 11569 | | |
11570 | 11570 | | |
11571 | 11571 | | |
| 11572 | + | |
| 11573 | + | |
| 11574 | + | |
| 11575 | + | |
| 11576 | + | |
| 11577 | + | |
| 11578 | + | |
| 11579 | + | |
| 11580 | + | |
| 11581 | + | |
| 11582 | + | |
| 11583 | + | |
| 11584 | + | |
| 11585 | + | |
| 11586 | + | |
| 11587 | + | |
| 11588 | + | |
| 11589 | + | |
| 11590 | + | |
| 11591 | + | |
| 11592 | + | |
| 11593 | + | |
| 11594 | + | |
| 11595 | + | |
| 11596 | + | |
| 11597 | + | |
| 11598 | + | |
| 11599 | + | |
| 11600 | + | |
| 11601 | + | |
| 11602 | + | |
| 11603 | + | |
| 11604 | + | |
| 11605 | + | |
| 11606 | + | |
| 11607 | + | |
| 11608 | + | |
| 11609 | + | |
| 11610 | + | |
| 11611 | + | |
| 11612 | + | |
| 11613 | + | |
| 11614 | + | |
| 11615 | + | |
| 11616 | + | |
| 11617 | + | |
| 11618 | + | |
| 11619 | + | |
| 11620 | + | |
| 11621 | + | |
| 11622 | + | |
| 11623 | + | |
| 11624 | + | |
| 11625 | + | |
| 11626 | + | |
| 11627 | + | |
| 11628 | + | |
| 11629 | + | |
| 11630 | + | |
| 11631 | + | |
| 11632 | + | |
| 11633 | + | |
| 11634 | + | |
| 11635 | + | |
| 11636 | + | |
| 11637 | + | |
| 11638 | + | |
| 11639 | + | |
| 11640 | + | |
| 11641 | + | |
| 11642 | + | |
| 11643 | + | |
| 11644 | + | |
| 11645 | + | |
| 11646 | + | |
| 11647 | + | |
| 11648 | + | |
| 11649 | + | |
| 11650 | + | |
| 11651 | + | |
| 11652 | + | |
| 11653 | + | |
| 11654 | + | |
| 11655 | + | |
| 11656 | + | |
| 11657 | + | |
| 11658 | + | |
| 11659 | + | |
| 11660 | + | |
| 11661 | + | |
| 11662 | + | |
| 11663 | + | |
| 11664 | + | |
| 11665 | + | |
| 11666 | + | |
| 11667 | + | |
11572 | 11668 | | |
11573 | 11669 | | |
11574 | 11670 | | |
| |||
12501 | 12597 | | |
12502 | 12598 | | |
12503 | 12599 | | |
| 12600 | + | |
| 12601 | + | |
12504 | 12602 | | |
12505 | 12603 | | |
12506 | 12604 | | |
| |||
0 commit comments