Skip to content

refactor(ledger): expose the Ledger signers in a typed starknet/ledge… - #1723

Merged
PhilippeR26 merged 1 commit into
starknet-io:developfrom
PhilippeR26:refactor/Ledger-isolated
Oct 8, 2026
Merged

PhilippeR26 merged 1 commit into
starknet-io:developfrom
PhilippeR26:refactor/Ledger-isolated

Conversation

@PhilippeR26

Copy link
Copy Markdown
Collaborator

Motivation and Resolution

The Ledger transport was typed as any (type _Transport = any): @ledgerhq/hw-transport was removed from the dependencies in 2024, after a packaging bug (LedgerHQ/ledger-live#7448). Importing the Ledger Transport type into the single dist/index.d.ts would break every project that does not use a Ledger and compiles with skipLibCheck: false (TS2307).

This PR adds a starknet/ledger entry point, with its own types file. There, the transport is typed with the Ledger Transport class. Nothing breaks in v11: the exports of starknet stay, deprecated. In v12, the code moves to src/ledger/ and these exports are removed.

RPC version (if applicable)

Not applicable.

Usage related changes

  • New entry point starknet/ledger: LedgerSigner111, LedgerSigner221, LedgerSigner231, getLedgerPathBuffer111, getLedgerPathBuffer221, and the aliases LedgerSigner and getLedgerPathBuffer.
    import { LedgerSigner231 } from 'starknet/ledger'; // was imported from 'starknet'
  • With this import, transporter has the type of the transport you pass (it was any for 221 and 231), and a value that is not a Ledger transport is refused at compile time.
  • Importing them from starknet still works, but is marked @deprecated (removed in v12).
  • @ledgerhq/hw-transport is an optional peer dependency (^6.0.0). The Ledger transport packages already install it. Projects without a Ledger see no change and no install warning (checked with npm, pnpm and yarn 1).
  • Docs: API pages for starknet/ledger; the signature and migration guides use the new import. Ledger Starknet APP support is stated from v2.3.1 to v2.4.3 (tested on a device with v2.4.3).

Development related changes

  • tsup builds a second entry point to dist/ledger/index.{js,mjs,d.ts}, with starknet kept external. The IIFE build keeps the main entry only and the ESM build has no shared chunk, so dist/index.js, dist/index.mjs and dist/index.global.js are unchanged except for comments (compared with a build of develop).
  • tsconfig.json (paths) and both Jest configs (moduleNameMapper) map starknet to src/index.ts. An ESLint rule forbids importing starknet in src outside src/ledger.
  • New unit test __tests__/utils/ledgerSigner.test.ts (no node needed).
  • Docusaurus: a second docusaurus-plugin-typedoc instance writes to docs/API/ledger/, so the addresses of the existing API pages do not change; new sidebar category.
  • Checked on the packed package: install with npm, pnpm and yarn 1; CJS and ESM imports; types with moduleResolution bundler, node16 and node.

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

…r entry point

The Ledger signers and their path functions can now be imported from `starknet/ledger`, with the transport typed by `@ledgerhq/hw-transport` (optional peer dependency). Importing them from `starknet` still works, but it is deprecated and will be removed in v12.

The main bundles are unchanged. The new entry point has its own API pages and a unit test; the guides use it, and state Ledger APP support from v2.3.1 to v2.4.3.
@PhilippeR26
PhilippeR26 merged commit 1fa71e7 into starknet-io:develop Oct 8, 2026
8 checks passed
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.

1 participant