✨ (signer-polkadot) [LIVE-30994]: Scaffold signer kit for Polkadot (Substrate chains)#1501
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
This PR scaffolds a new @ledgerhq/device-signer-kit-polkadot package (following the existing non‑EVM signer patterns) and wires it into the monorepo tooling, sample app, and documentation so it can be iterated on for upcoming APDU/protocol work.
Changes:
- Added the new Polkadot signer package skeleton (DI container, app binder, commands/tasks, API surface, build/lint/test configs).
- Integrated the signer into the sample app (provider, view, route, and signer list entry).
- Added Polkadot signer documentation and release/repo plumbing (docs nav, release aliases, changeset, lockfile/workspace entries).
Reviewed changes
Copilot reviewed 49 out of 50 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds workspace entry/deps for the new signer package. |
| package.json | Adds a root script alias for signer-polkadot. |
| packages/signer/signer-polkadot/vitest.setup.mjs | Vitest setup (reflect-metadata). |
| packages/signer/signer-polkadot/vitest.config.mjs | Vitest configuration + coverage/aliases. |
| packages/signer/signer-polkadot/tsconfig.prod.json | Production TS config wrapper. |
| packages/signer/signer-polkadot/tsconfig.json | Package TS config (paths/types/output). |
| packages/signer/signer-polkadot/src/internal/use-cases/transaction/SignTransactionUseCase.ts | Use-case wrapper for sign-transaction device action. |
| packages/signer/signer-polkadot/src/internal/use-cases/transaction/di/transactionTypes.ts | DI symbols for transaction use-cases. |
| packages/signer/signer-polkadot/src/internal/use-cases/transaction/di/transactionModule.ts | DI bindings for transaction use-cases. |
| packages/signer/signer-polkadot/src/internal/use-cases/address/GetAddressUseCase.ts | Use-case wrapper for get-address device action. |
| packages/signer/signer-polkadot/src/internal/use-cases/address/di/addressTypes.ts | DI symbols for address use-cases. |
| packages/signer/signer-polkadot/src/internal/use-cases/address/di/addressModule.ts | DI bindings for address use-cases. |
| packages/signer/signer-polkadot/src/internal/externalTypes.ts | DI symbols for externally-provided instances (DMK/session). |
| packages/signer/signer-polkadot/src/internal/di.ts | Builds and loads the inversify container. |
| packages/signer/signer-polkadot/src/internal/DefaultSignerPolkadot.ts | Concrete SignerPolkadot implementation delegating to use-cases. |
| packages/signer/signer-polkadot/src/internal/app-binder/task/SignTransactionTask.ts | Task wrapper around the sign-transaction command. |
| packages/signer/signer-polkadot/src/internal/app-binder/PolkadotAppBinder.ts | DMK device-action wiring for getAddress/signTransaction. |
| packages/signer/signer-polkadot/src/internal/app-binder/di/appBinderTypes.ts | DI symbols for the app binder. |
| packages/signer/signer-polkadot/src/internal/app-binder/di/appBinderModule.ts | DI bindings for the app binder. |
| packages/signer/signer-polkadot/src/internal/app-binder/constants.ts | Polkadot app constants (name/CLA/INS). |
| packages/signer/signer-polkadot/src/internal/app-binder/command/utils/polkadotApplicationErrors.ts | Placeholder error-code enum for Polkadot app. |
| packages/signer/signer-polkadot/src/internal/app-binder/command/SignTransactionCommand.ts | Sign-transaction command scaffold (APDU + parse TBD). |
| packages/signer/signer-polkadot/src/internal/app-binder/command/GetAddressCommand.ts | Get-address command scaffold (APDU + parse TBD). |
| packages/signer/signer-polkadot/src/index.ts | Package entrypoint exporting API. |
| packages/signer/signer-polkadot/src/api/SignerPolkadotBuilder.ts | Public builder to construct the signer. |
| packages/signer/signer-polkadot/src/api/SignerPolkadotBuilder.test.ts | Minimal builder/constants tests. |
| packages/signer/signer-polkadot/src/api/SignerPolkadot.ts | Public signer interface (getAddress/signTransaction). |
| packages/signer/signer-polkadot/src/api/model/TransactionOptions.ts | Transaction options type. |
| packages/signer/signer-polkadot/src/api/model/Signature.ts | Signature type definition. |
| packages/signer/signer-polkadot/src/api/model/AddressOptions.ts | Address options type. |
| packages/signer/signer-polkadot/src/api/index.ts | API barrel exports. |
| packages/signer/signer-polkadot/src/api/app-binder/SignTransactionDeviceActionTypes.ts | Public DA types for signing. |
| packages/signer/signer-polkadot/src/api/app-binder/GetAddressDeviceActionTypes.ts | Public DA types for getAddress. |
| packages/signer/signer-polkadot/README.md | Package README (usage/install/dev). |
| packages/signer/signer-polkadot/package.json | New package manifest (exports/scripts/deps). |
| packages/signer/signer-polkadot/eslint.config.mjs | Package eslint configuration. |
| packages/signer/signer-polkadot/CHANGELOG.md | Initial changelog entry. |
| packages/signer/signer-polkadot/.prettierrc.js | Prettier config wiring. |
| packages/signer/signer-polkadot/.prettierignore | Prettier ignore list. |
| apps/sample/src/providers/SignerPolkadotProvider/index.tsx | Adds signer provider to sample app. |
| apps/sample/src/components/SignerView/index.tsx | Adds Polkadot entry to supported signers list. |
| apps/sample/src/components/SignerPolkadotView/index.tsx | Adds Polkadot device-action tester view. |
| apps/sample/src/app/signers/polkadot/page.tsx | Adds Polkadot signer page route. |
| apps/sample/src/app/client-layout.tsx | Registers the Polkadot signer provider in layout. |
| apps/sample/package.json | Adds dependency on the new signer package. |
| apps/docs/pages/docs/references/signers/polkadot.mdx | Adds Polkadot signer documentation page. |
| apps/docs/pages/docs/references/signers/_meta.js | Adds Polkadot entry to docs sidebar meta. |
| .cursor/skills/release/SKILL.md | Adds release alias mapping for signer-polkadot. |
| .cursor/scripts/release/config.cjs | Adds release alias + display name for the new package. |
| .changeset/yummy-news-bow.md | Adds changeset for initial Polkadot signer release. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (4)
packages/signer/signer-polkadot/README.md:25
SignerPolkadot.signTransactionrequires bothblobandmetadata(plus optionaloptions), but the README example only passestransactionBytes. Update the example to include the metadata parameter (or explicitly pass an empty metadata blob if that’s the intended placeholder).
// Sign transaction
const signature = await signer.signTransaction(
"m/44'/0'/0'/0/0",
transactionBytes,
);
apps/docs/pages/docs/references/signers/polkadot.mdx:142
- The docs describe
signTransaction(derivationPath, transaction, options)and show a{r,s,v}signature shape, but the exported API issignTransaction(derivationPath, blob: Uint8Array, metadata: Uint8Array, options?)andSignatureis aUint8Array. Please align the docs (parameters + return type example) with the actual types.
```typescript
const { observable, cancel } = signerPolkadot.signTransaction(
derivationPath,
transaction,
options,
);
Parameters
-
derivationPath- Required
- Type:
string(e.g.,"m/44'/0'/0'/0/0") - The derivation path used for the polkadot transaction. See here for more information.
-
transaction- Required
- Type:
Uint8Array - The serialized transaction to be signed.
-
options-
Optional
-
Type:
TransactionOptionstype TransactionOptions = { skipOpenApp?: boolean; };
-
skipOpenApp: An optional boolean indicating whether to skip opening the polkadot app automatically (true) or not (false).
-
Returns
observableEmits DeviceActionState updates, including the following details:
type Signature = {
r: string;
s: string;
v?: number;
};**apps/sample/src/components/SignerPolkadotView/index.tsx:77**
* The transaction hex parsing here will silently produce incorrect bytes for invalid input (e.g. non-hex chars -> `NaN` -> coerces to `0`, odd-length strings, etc.). The sample app already uses `hexaStringToBuffer` in other signer views (e.g. Zcash); consider using it here and throwing on invalid hex to avoid testing against malformed payloads.
// Convert hex string to Uint8Array
const txBytes = transaction.startsWith("0x")
? new Uint8Array(
transaction
.slice(2)
.match(/.{1,2}/g)
?.map((byte) => parseInt(byte, 16)) ?? []
)
: new Uint8Array(
transaction
.match(/.{1,2}/g)
?.map((byte) => parseInt(byte, 16)) ?? []
);
**apps/sample/src/components/SignerPolkadotView/index.tsx:80**
* This call does not match the `SignerPolkadot.signTransaction` signature. The API is `(derivationPath, blob: Uint8Array, metadata: Uint8Array, options?)`, but the sample passes `(derivationPath, ss58Prefix, txBytes, options)`. Update the UI/handler to provide `metadata` and pass parameters in the correct order/types.
return signer.signTransaction(derivationPath, Number(ss58Prefix), txBytes, {
skipOpenApp,
});
</details>
---
💡 <a href="/LedgerHQ/device-sdk-ts/new/develop?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
a425ad3 to
d778459
Compare
d778459 to
714d9b6
Compare
714d9b6 to
22cd048
Compare
|


📝 Description
Scaffolds the
@ledgerhq/device-signer-kit-polkadotpackage inpackages/signer/signer-polkadot/.This signer serves all Substrate chains (Polkadot, Bittensor, etc.) via configurable SS58 prefix and derivation path — following the pattern of
signer-cosmosfor non-EVM chains. ImplementsGetAddressCommand(SS58 prefix param) andSignTransactionCommand(SCALE payload + metadata blob).❓ Context
✅ Checklist
signer-polkadot. No changes to existing signers or packages.