Loading...
Loading...
Compare original and translation side by side
dmk-intent-vocabularydmk-intent-vocabularydmk-intent-vocabularydmk-business-logicdmk-sdk-reference.mddmk-code-patterns.mddmk-platform-patterns.mdhttps://github.com/LedgerHQ/device-sdk-tshttps://github.com/LedgerHQ/device-sdk-ts/tree/develop/apps/samplestartDiscovering()connect()dmk-intent-vocabularydmk-business-logicdmk-sdk-reference.mddmk-code-patterns.mddmk-platform-patterns.mdhttps://github.com/LedgerHQ/device-sdk-tshttps://github.com/LedgerHQ/device-sdk-ts/tree/develop/apps/samplestartDiscovering()connect()→ PROCEED→ WAIT(Ns)→ ABORT→ ESCALATE→ PROCEED→ WAIT(Ns)→ ABORT→ ESCALATEdmk-sdk-reference.mddmk-code-patterns.mddmk-platform-patterns.mddmk-sdk-reference.mddmk-code-patterns.mddmk-platform-patterns.mddmk-code-patterns.md@ledgerhq/device-management-kitsessionIddmk.getDeviceSessionState({ sessionId })DisconnectedDisconnectedsessionIdsessionIddmk.startDiscovering({ transport: webHidIdentifier })dmk.connect({ device, sessionRefresherOptions: { isRefresherDisabled: false } })sessionIddmk-code-patterns.md@ledgerhq/device-management-kitsessionIddmk.getDeviceSessionState({ sessionId })DisconnectedDisconnectedsessionIdsessionIddmk.startDiscovering({ transport: webHidIdentifier })dmk.connect({ device, sessionRefresherOptions: { isRefresherDisabled: false } })sessionIdDeviceSessionState@ledgerhq/device-management-kitdmk.getDeviceSessionState({ sessionId })| State | Action |
|---|---|
| → PROCEED to Step 4 |
| → WAIT(10s), recheck once. Still busy → ABORT: "Device busy" |
| → ESCALATE: "Device is locked — user must enter PIN" |
| → ABORT: "Device disconnected" |
@ledgerhq/device-management-kitDeviceSessionStatedmk.getDeviceSessionState({ sessionId })| 状态 | 操作 |
|---|---|
| → PROCEED 进入步骤4 |
| → WAIT(10s),重新检查一次。仍处于忙碌状态 → ABORT:「设备忙碌」 |
| → ESCALATE:「设备已锁定——用户需输入PIN码」 |
| → ABORT:「设备已断开连接」 |
OpenAppDeviceActionGetAppAndVersionCommand@ledgerhq/device-management-kitdmk-sdk-reference.mdstate.currentApp.name| Current state | Action |
|---|---|
| Correct app open | → PROCEED to Step 5 |
| Wrong app open | |
| No app (dashboard) | → open correct app |
OpenAppDeviceAction| State | User interaction | Action |
|---|---|---|
| | Wait |
| | Wait up to 30s for user to confirm on device |
| | → ESCALATE: "Device locked during app open" |
| — | → PROCEED to Step 5 |
| — | → ABORT: "App open was cancelled" |
| — | → classify (see Rules → Error Classification) |
CompletedErrorcancel()@ledgerhq/device-management-kitOpenAppDeviceActionGetAppAndVersionCommanddmk-sdk-reference.mdstate.currentApp.name| 当前状态 | 操作 |
|---|---|
| 正确应用已打开 | → PROCEED 进入步骤5 |
| 打开的应用错误 | 执行 |
| 无应用(仪表盘界面) | → 打开正确的应用 |
OpenAppDeviceAction| 状态 | 用户交互 | 操作 |
|---|---|---|
| | 等待 |
| | 等待最多30秒,供用户在设备上确认 |
| | → ESCALATE:「打开应用过程中设备锁定」 |
| — | → PROCEED 进入步骤5 |
| — | → ABORT:「打开应用已取消」 |
| — | → 分类处理(参见 规则 → 错误分类) |
CompletedErrorcancel()dmk-sdk-reference.mddmk-code-patterns.mdnew [Chain]SignerBuilder({ dmk, sessionId }).build()| State | User interaction | Action |
|---|---|---|
| — | Wait |
| | Wait |
| | → ESCALATE: "Device locked during signing" |
| | Wait up to 60s for user to approve |
| — | Extract |
| — | → ABORT: "Operation stopped" |
| — | → classify (see Rules → Error Classification) |
cancel()originTokenSignerEthBuilderdomaintypesmessagesignPsbt()signTransaction()registerWallet()Uint8Arraydmk-sdk-reference.mddmk-code-patterns.mdnew [Chain]SignerBuilder({ dmk, sessionId }).build()| 状态 | 用户交互 | 操作 |
|---|---|---|
| — | 等待 |
| | 等待 |
| | → ESCALATE:「签名过程中设备锁定」 |
| | 等待最多60秒,供用户批准 |
| — | 提取 |
| — | → ABORT:「操作已停止」 |
| — | → 分类处理(参见 规则 → 错误分类) |
cancel()SignerEthBuilderoriginTokendomaintypesmessagesignPsbt()signTransaction()registerWallet()Uint8Arraydmk.executeDeviceAction()| State | User interaction | Action |
|---|---|---|
| — | Wait |
| | Wait (install/uninstall: check |
| | Wait up to 30s for user to approve on device |
| | → ESCALATE: "Device locked during device management" |
| — | Extract |
| — | → ABORT: "Operation stopped" |
| — | → classify (see Rules → Error Classification) |
AllowSecureConnectioncancel()AllowSecureConnectiondmk-sdk-reference.mddmk.executeDeviceAction()| 状态 | 用户交互 | 操作 |
|---|---|---|
| — | 等待 |
| | 等待(安装/卸载:查看 |
| | 等待最多30秒,供用户在设备上批准 |
| | → ESCALATE:「设备管理过程中设备锁定」 |
| — | 提取 |
| — | → ABORT:「操作已停止」 |
| — | → 分类处理(参见 规则 → 错误分类) |
AllowSecureConnectioncancel()AllowSecureConnectiondmk-sdk-reference.mddmk.disconnect({ sessionId })Disconnecteddmk.disconnect({ sessionId })DisconnectedsetStub(true)setStub(true)DeviceActionStatus.ErrorRefusedByUserDAError55016985DeviceActionStatus.Error| Outcome | User-facing message | UI state | Action |
|---|---|---|---|
User rejected ( | "Action cancelled on device." | Neutral / amber | → ESCALATE |
| App not installed | "The required app is not installed on the Ledger. Install it via Ledger Wallet and try again." | Error | → ESCALATE |
| Device locked | "The Ledger is locked. Enter your PIN on the device to continue." | Error | → ESCALATE |
Status word | "The device returned an unexpected error. Disconnect and reconnect the Ledger, then try again." | Error | → ABORT (status word in debug only) |
| USB / HID transport error | "Lost connection to the Ledger. Reconnect the device and try again." | Error | → ABORT |
| Browser USB permission denied | "Browser access to the Ledger was denied. Click 'Connect Ledger' to grant permission." | Error | → ESCALATE |
| Unknown / unclassified | "An unexpected error occurred. Disconnect and reconnect the Ledger, then start a new operation." | Error | → ABORT (raw error in debug only) |
DeviceActionStatus.ErrorRefusedByUserDAError55016985DeviceActionStatus.Error| 结果类型 | 用户可见消息 | UI状态 | 操作 |
|---|---|---|---|
用户拒绝( | 「操作已在设备上取消。」 | 中性 / 琥珀色 | → ESCALATE |
| 应用未安装 | 「Ledger上未安装所需应用。请通过Ledger Wallet安装后重试。」 | 错误 | → ESCALATE |
| 设备锁定 | 「Ledger已锁定。请在设备上输入PIN码以继续。」 | 错误 | → ESCALATE |
状态字 | 「设备返回了意外错误。请断开并重新连接Ledger后重试。」 | 错误 | → ABORT(状态字仅在调试信息中显示) |
| USB / HID传输错误 | 「与Ledger的连接已断开。请重新连接设备后重试。」 | 错误 | → ABORT |
| 浏览器USB权限被拒绝 | 「浏览器访问Ledger的权限被拒绝。请点击「连接Ledger」授予权限。」 | 错误 | → ESCALATE |
| 未知 / 未分类 | 「发生意外错误。请断开并重新连接Ledger,然后发起新的操作。」 | 错误 | → ABORT(原始错误仅在调试信息中显示) |
| Step | Default | Acceptable range |
|---|---|---|
| Device discovery | 15s | 5s – 300s |
| App open — user confirmation | 30s | 5s – 300s |
| Signing — user confirmation | 60s | 5s – 300s |
| Busy device recheck | 10s (one retry) | — |
| 步骤 | 默认值 | 可接受范围 |
|---|---|---|
| 设备发现 | 15秒 | 5秒 – 300秒 |
| 打开应用 — 用户确认 | 30秒 | 5秒 – 300秒 |
| 签名 — 用户确认 | 60秒 | 5秒 – 300秒 |
| 设备忙碌重查 | 10秒(一次重试) | — |
AllowSecureConnectionAllowSecureConnection