Skip to content

✨ (signer-polkadot) [LIVE-30994]: Scaffold signer kit for Polkadot (Substrate chains)#1501

Merged
mbertin-ledger merged 1 commit into
developfrom
feat/LIVE-30994-scaffold-polkadot-signer
Jun 1, 2026
Merged

✨ (signer-polkadot) [LIVE-30994]: Scaffold signer kit for Polkadot (Substrate chains)#1501
mbertin-ledger merged 1 commit into
developfrom
feat/LIVE-30994-scaffold-polkadot-signer

Conversation

@cted-ledger

@cted-ledger cted-ledger commented May 20, 2026

Copy link
Copy Markdown
Contributor

📝 Description

Scaffolds the @ledgerhq/device-signer-kit-polkadot package in packages/signer/signer-polkadot/.

This signer serves all Substrate chains (Polkadot, Bittensor, etc.) via configurable SS58 prefix and derivation path — following the pattern of signer-cosmos for non-EVM chains. Implements GetAddressCommand (SS58 prefix param) and SignTransactionCommand (SCALE payload + metadata blob).

❓ Context

✅ Checklist

  • Covered by automatic tests
  • Changeset is provided
  • Documentation is up-to-date
  • Impact of the changes:
    • New package signer-polkadot. No changes to existing signers or packages.
    • Unblocks LIVE-30995 (APDU implementation) and LIVE-30996 (live-signer wrapper in ledger-live).

@cted-ledger cted-ledger requested a review from a team as a code owner May 20, 2026 20:27
Copilot AI review requested due to automatic review settings May 20, 2026 20:27
@vercel

vercel Bot commented May 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
device-sdk-ts-sample Ready Ready Preview, Comment May 20, 2026 11:27pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
doc-device-management-kit Ignored Ignored May 20, 2026 11:27pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.signTransaction requires both blob and metadata (plus optional options), but the README example only passes transactionBytes. 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 is signTransaction(derivationPath, blob: Uint8Array, metadata: Uint8Array, options?) and Signature is a Uint8Array. 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: TransactionOptions

      type TransactionOptions = {
        skipOpenApp?: boolean;
      };
    • skipOpenApp: An optional boolean indicating whether to skip opening the polkadot app automatically (true) or not (false).

Returns

  • observable Emits 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>.

Comment thread packages/signer/signer-polkadot/README.md Outdated
Comment thread apps/docs/pages/docs/references/signers/polkadot.mdx
Comment thread apps/sample/src/components/SignerPolkadotView/index.tsx Outdated
@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Danger Check Results

Messages

Danger: All checks passed successfully! 🎉

Generated by 🚫 dangerJS against 22cd048

@cted-ledger cted-ledger force-pushed the feat/LIVE-30994-scaffold-polkadot-signer branch from 714d9b6 to 22cd048 Compare May 20, 2026 23:25
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@mbertin-ledger mbertin-ledger added this pull request to the merge queue Jun 1, 2026
Merged via the queue into develop with commit 6019986 Jun 1, 2026
24 of 25 checks passed
@mbertin-ledger mbertin-ledger deleted the feat/LIVE-30994-scaffold-polkadot-signer branch June 1, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants