✨ (signer-polkadot) [LIVE-30995]: Implement APDU commands for the Polkadot signer#1530
✨ (signer-polkadot) [LIVE-30995]: Implement APDU commands for the Polkadot signer#1530cted-ledger wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
There was a problem hiding this comment.
Pull request overview
Implements the Polkadot/Bittensor signer-kit APDU command layer in @ledgerhq/device-signer-kit-polkadot, including address derivation (SS58 prefix) and multi-APDU transaction signing orchestration.
Changes:
- Added concrete APDU implementations for
GetAddressCommandandSignTransactionCommand(INIT/ADD/LAST) plusSignTransactionTaskchunking logic. - Introduced Polkadot app error mapping + derivation-path binary encoding utility.
- Wired logger factory into the package DI and app-binder, and added comprehensive Vitest coverage + changeset.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/signer/signer-polkadot/src/internal/externalTypes.ts | Adds DI token for DMK logger factory. |
| packages/signer/signer-polkadot/src/internal/di.ts | Binds DmkLoggerFactory to DMK logger factory implementation. |
| packages/signer/signer-polkadot/src/internal/app-binder/task/SignTransactionTask.ts | Implements multi-chunk signing task using APDU_MAX_PAYLOAD and INIT/ADD/LAST phases. |
| packages/signer/signer-polkadot/src/internal/app-binder/task/SignTransactionTask.test.ts | Tests for chunking behavior and error handling in signing task. |
| packages/signer/signer-polkadot/src/internal/app-binder/PolkadotAppBinder.ts | Injects logger factory and forwards loggers to device actions and signing task. |
| packages/signer/signer-polkadot/src/internal/app-binder/constants.ts | Adds P2 constants (curve selection) for APDU headers. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/utils/polkadotApplicationErrors.ts | Introduces Polkadot app status-word mapping and typed command error class. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/utils/PolkadotApplicationErrors.test.ts | Tests Polkadot app error mapping and error class construction. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/utils/EncodeDerivationPath.ts | Adds derivation path encoder (5×u32 LE) for Polkadot app format. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/utils/EncodeDerivationPath.test.ts | Tests derivation path encoding output and validation. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/SignTransactionCommand.ts | Implements APDU building + response parsing for signing protocol. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/SignTransactionCommand.test.ts | Tests APDU construction and status-word error handling for signing command. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/GetAddressCommand.ts | Implements APDU building + response parsing for publicKey+address derivation. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/GetAddressCommand.test.ts | Tests APDU construction and parsing for address command. |
| .changeset/bittensor-apdu-commands.md | Publishes a minor changeset for the new APDU layer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
96dd06d to
7c180a0
Compare
7c180a0 to
1e8eca9
Compare
|
mbertin-ledger
left a comment
There was a problem hiding this comment.
Please Handle also comment from sonarcloud analysis
| SIGN_RAW: 0x03, | ||
| } as const; | ||
|
|
||
| export const P2 = { |
There was a problem hiding this comment.
[SHOULD] P2 is parameter for a given command, this should be directly in command SignTransactionCommand as it's used there.
Same for INS above.
There was a problem hiding this comment.
Done in 251691e — moved the command-specific INS and P2 into GetAddressCommand and SignTransactionCommand; constants.ts now keeps only the app-wide LEDGER_CLA (also dropped the unused SIGN_RAW/ECDSA).
1e8eca9 to
b533fe9
Compare
Complete the how-to-create-signer §13.1 test set (DefaultSignerPolkadot, GetAddressUseCase). Also fix a stale derivation-path example in the EncodeDerivationPath comment (354, generic Polkadot-family).
…ation) - Move command-specific INS/P2 into GetAddressCommand and SignTransactionCommand; keep only the app-wide CLA in constants (removes the unused SIGN_RAW/ECDSA). (mbertin) - Validate ss58Prefix and blobLength fit in a uint16 before the little-endian encoding, instead of silently truncating. (copilot) - Use the reused Polkadot path (354) in test fixtures and rename BITTENSOR_PATH -> POLKADOT_PATH (the signer is generic, not Bittensor-specific).
Rename and reword the changeset so the released changelog describes the Polkadot-family signer rather than a Bittensor-specific feature (the signer is generic; chains differ only by SS58 prefix).
0a6325c to
df12d8d
Compare
|





📝 Description
Implement the full APDU command layer for the
signer-polkadotDMK signer kit. The signer is generic across the Polkadot family (Polkadot, Westend, AssetHub, Bittensor, …) — chains differ only by the SS58 prefix parameter and the derivation path. Bittensor is the driving integration.Commands implemented:
Supporting utilities:
EncodeDerivationPath— encodes a hardened BIP44 path into the little-endian binary layout expected by the device apppolkadotApplicationErrors— maps device status words to typed error codes❓ Context
Depends on #1501 (scaffold, merged).
✅ Checklist
@ledgerhq/device-signer-kit-polkadotsigner-polkadot