Skip to content

feat: add solana to ledger wallet - #1520

Open
RyukTheCoder wants to merge 8 commits into
nextfrom
feat/add-solana-to-ledger-wallet
Open

RyukTheCoder wants to merge 8 commits into
nextfrom
feat/add-solana-to-ledger-wallet

Conversation

@RyukTheCoder

Copy link
Copy Markdown
Contributor

Summary

Adds Solana support to the Ledger Wallet provider (@rango-dev/provider-ledger-wallet) by upgrading to Ledger Wallet Provider v2.

What changed

Dependencies

  • @ledgerhq/ledger-wallet-provider ^1.4.2 → ^2.0.0.
  • New: @ledgerhq/ledger-wallet-provider-evm and @ledgerhq/ledger-wallet-provider-solana. In v2 each blockchain family is a separate package that is passed to initializeLedgerProvider through blockchainProviderFactories.
  • New: @ledgerhq/device-management-kit (pinned to 1.10.0). We don't import it, but it is a peer dependency of the two family packages. Without declaring it, yarn nests it under ledger-wallet-provider-core and the family packages can't resolve it.
  • New: @hub3js/solana, @rango-dev/signer-solana, @wallet-standard/app, bs58, plus three type-only dev dependencies for the Wallet Standard types.

Solana namespace (src/namespaces/solana.ts)

  • Ledger registers its Solana wallet through the Wallet Standard, so it is looked up with getWallets() instead of being announced like the EVM provider.
  • connect and disconnect actions, with an account-change subscription. When the user selects a non-Solana account in the Ledger Button, Ledger clears the Solana accounts and we disconnect the namespace.
  • No canEagerConnect: see "Known limitations".

Solana signer (src/signers/solana.ts)

  • Ledger only signs (solana:signTransaction). Simulation, broadcast and confirmation go through generalSolanaTransactionExecutor, the same as the MetaMask Solana signer.
  • Ledger refreshes the blockhash after the user approves on the device ("2-step signing"), so the signed transaction must be broadcast as returned. The shared executor already does that and confirms by signature status.

Loading and build

  • The Ledger runtime, both family packages and the stylesheet are loaded with dynamic imports inside the provider's init, so they are not pulled in at widget startup.
  • The package now builds with --splitting, so the EVM and Solana signers are emitted as separate chunks and @rango-dev/signer-evm / @rango-dev/signer-solana are only loaded when signers are requested.

Docs

  • wallets/readme.md: Ledger Wallet now lists Solana, and Auto Connect is marked partial.
  • wallets/provider-ledger-wallet/readme.md: notes on Solana auto connect and on how signing errors surface.

Patches

Ledger's v2 packages need several patch-package patches to work in this repo. They only affect this repo's node_modules; they are not shipped to integrators.

Patch What it does Why it is needed
ledger-wallet-provider+2.0.0, ledger-wallet-provider-core+2.0.0 Reorders exports so default is last Renamed from the existing 1.4.2 patches, same content. The Next example (webpack 5.74) fails with "Default condition should be last one" otherwise. Reported upstream: LedgerHQ/ledger-button-public#3
ledger-wallet-provider-evm+1.0.0, ledger-wallet-provider-solana+1.0.0 Same exports reorder, and adds a missing BlockchainFamily import to two .d.ts files in each package Without the import, ts-check fails with TS2304: Cannot find name 'BlockchainFamily'. Reported upstream: LedgerHQ/ledger-button-public#4
ledger-wallet-provider-core++@inversifyjs+core+9.2.0 Changes symbol to unique symbol in inversify's typings Unchanged, already in the repo. Without it ts-check fails with TS1166
ledger-wallet-provider-core++zod+4.5.4 Sets "sideEffects": true in zod's v4/classic/package.json Parcel bundles import { z } from "zod" as an empty object, so Ledger crashes with z.string is not a function
device-signer-kit-ethereum++ethers+6.14.1 Sets "sideEffects": true in ethers' lib.esm/package.json Parcel drops ethers.Transaction from the ethers namespace import, so every EVM signature fails with "Invalid transaction"
ledger-wallet-provider-evm++ethers+6.17.0 Same change, in the EVM package's own ethers copy Parcel drops ethers.Signature, which Ledger uses to assemble the signed transaction

The last three are specific to Parcel (used by widget/app and widget/playground). The same imports bundle correctly with webpack 5.100, Vite 4.5, Vite 8 and esbuild.

Known limitations

How did you test this change?

Automated checks on @rango-dev/provider-ledger-wallet:

  • yarn ts-check
  • yarn lint
  • yarn build (output is split into mod.js, a shared chunk and one chunk per signer)
  • yarn install --frozen-lockfile and patch-package apply all patches cleanly

Manual, in widget/app with a Ledger device (requires a ledgerWallet config with apiKey and dAppIdentifier, and Solana enabled for that dApp identifier on Ledger's side):

  • Connect on Solana through the Ledger Button
  • Execute a Solana swap (blind signing enabled in the Solana app)
  • Connect on EVM and execute an EVM swap, including an approval
  • Switch account in the Ledger Button while connected
  • Disconnect and reconnect

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Implemented a user interface (UI) change, referencing our Figma design to ensure pixel-perfect precision.

@arlert-armin arlert-armin 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.

LGTM

disconnect() dropped each namespace.disconnect() promise inside a forEach,
so callers (e.g. single-namespace wallets switching namespace) started a
new connect while the previous disconnect was still in flight.
hub3 doesn't await before hooks, so the Ledger session reset ran after
disconnect resolved and raced the next namespace connect, causing a
'No session ID' error. Move the wallet disconnect into the action.
Upgrade ledger-wallet-provider and ledger-wallet-provider-core to 2.0.3,
and ledger-wallet-provider-evm and ledger-wallet-provider-solana to
1.0.3.

Pin the ledger-wallet-provider packages and the exact peers that evm and
solana require (device-management-kit, rxjs, xstate, purify-ts), and
dedupe rxjs to a single 7.8.2 copy. A second device-management-kit copy
next to the one ledger-wallet-provider-core bundles made instanceof
checks fail across copies, and EVM signing showed Ledger's generic sign
error. device-management-kit stays at 1.11.0, not the latest 1.11.1,
because the evm and solana peers and provider-core all require exactly
1.11.0. Document the pins in the readme.

Parcel's production build leaves the namespace re-export in ethers'
index (`export { ethers }`) undefined, so Ledger's calls to
`ethers.Transaction.from` threw "re_export$ethers is not defined" and
EVM signing failed on deployed builds only. Patch
ledger-wallet-provider-evm and device-signer-kit-ethereum to import
Transaction and Signature by name.

Rename the ledger patches to the new versions. None of their fixes are
upstream yet.
patch-package only runs on install, so a node_modules cache hit kept
packages patched with whatever patches the cache was built with. Add
patches/ to the cache key.

Also drop the restore-keys fallback: yarn v1 doesn't prune stale nested
packages when installing over an older node_modules, which shipped a
second device-management-kit copy to the PR preview. A dependency or
patch change now installs into an empty tree.

This branch was successfully deployed

3 active deployments
playground-preview — 0a8a5906 Deployed Nov 11, 2026 by RyukTheCoder via playground-preview #5576
app-preview — 0a8a5906 Deployed Nov 11, 2026 by RyukTheCoder via app-preview #5576
preview — 0a8a5906 Deployed Nov 11, 2026 by RyukTheCoder via deploy #5576
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.

2 participants