Skip to content

feat(wallets): per-wallet directSigningSupport for V3 swap flow#17

Merged
towanTG merged 1 commit intodevelopfrom
feat/wallet-supports-direct-signing
Apr 16, 2026
Merged

feat(wallets): per-wallet directSigningSupport for V3 swap flow#17
towanTG merged 1 commit intodevelopfrom
feat/wallet-supports-direct-signing

Conversation

@towanTG
Copy link
Copy Markdown
Contributor

@towanTG towanTG commented Apr 16, 2026

Summary

Moves V3 capability from a centralized `V3SwapFlowSupport` map (in `@swapkit/helpers`) to inline per-wallet declaration. Each wallet now owns the truth about which chains it can sign raw transactions for, and the SDK can gate V3 routing via `wallet.supportsDirectSigning` instead of a central lookup.

Changes

  • Drop the duplicated `core.ts` files in `wallets`, `wallet-extensions`, and `wallet-hardware`. Import `createWallet` / `getWalletSupportedChains` from `@swapkit/wallet-core@^4.2.0` directly. Adds a single source of truth for the wallet contract.
  • Stamp `directSigningSupport: Partial<Record<Chain, boolean>>` on every `createWallet({...})` call based on what's actually wired today. Comments inline mark which entries are blocked on provider/library/toolbox work (see `docs/v3-plans/` on the planning branch for the full per-wallet analysis).
  • Wire two real signers as part of the rollout:
    • Xaman / Ripple — `submitXamanPayload` now exposes the signed `hex` blob and accepts `{ submit: false }`; new `ChainSigner` wraps `xumm.payload.createAndSubscribe` and is passed to `getRippleToolbox({ signer })`. Existing `transfer` / `setTrustLine` retained for back-compat.
    • Ledger / Cosmos Hub — pass the existing `CosmosLedger` (already implements `signAmino` + `getAccounts` matching `OfflineAminoSigner`) to `getCosmosToolbox(Chain.Cosmos, { signer })`. Bespoke `transfer` retained.
  • BitGet Cosmos: switch `getOfflineSignerOnlyAmino` → `getOfflineSignerAuto` so V3 proto SignDocs sign natively (Ledger via BitGet still falls back to amino).
  • WalletConnect EVM latent bug fixes (flagged by V3 audit, not V3 blockers but real bugs):
    • Add `Aurora` and `Berachain` to the EVM `getToolbox` switch (were in `supportedChains` but unhandled — threw `wallet_chain_not_supported` at runtime).
    • Register `XLAYER_MAINNET_ID = "eip155:196"` so XLayer's namespace negotiation works (was returning empty string from `chainToChainId`).

What's still pending

Each wallet's `directSigningSupport` map omits / leaves `false` for chains where the signer wrapper still needs work. Comments in the code point to the per-chain plans. Highlights:

  • Hardware wallets (Ledger BTC/LTC, Trezor UTXO, KeepKey UTXO/Cosmos): need PSBT/converter signers — separate PRs, device QA in the loop.
  • Vultisig non-EVM: blocked on Vultisig provider (no raw-sign RPC).
  • CTRL non-BTC UTXO + THORChain/Maya: blocked on CTRL provider (no sats-connect for those chains).
  • WalletConnect Cosmos / Near / Tron: needs proper signer wiring (Cosmos chains have no `case` in switch today).
  • Aptos (BitGet, Petra): blocked on toolbox — `getAptosToolbox` needs to accept `AptosExtensionProvider`.

Follow-up

  • SDK PR: switch the V3 plugin gate from `V3SwapFlowSupport[chain].includes(walletType)` to `wallet.supportsDirectSigning` and delete the central map.

Test plan

  • `bun run type-check` ✓ (passes locally across all packages)
  • Connect Xaman, run a V3 XRP swap end-to-end; confirm the toolbox's `signAndBroadcastTransaction` resolves with a hash and there's no double-submit (set `submit: false` on XUMM payload)
  • Connect Ledger Cosmos, run a V3 ATOM swap; confirm `signAndBroadcastTransaction` works via the new toolbox path
  • Connect BitGet Cosmos, run a V3 ATOM swap; confirm `signDirect` is preferred over amino on hot wallet
  • Regression: legacy `wallet.transfer({...})` for Xaman, Ledger Cosmos, BitGet Cosmos still works
  • Regression: WalletConnect EVM connect across all listed chains (especially Aurora, Berachain, XLayer)

🤖 Generated with Claude Code

* Drop the duplicated local `core.ts` files and import `createWallet` /
  `getWalletSupportedChains` from `@swapkit/wallet-core` (^4.2.0) so all
  wallets share one canonical contract.
* Stamp `directSigningSupport: Partial<Record<Chain, boolean>>` on every
  wallet so the SDK can decide V3 routing per (wallet, chain) without a
  central map.
* Wire two real signers as part of the rollout:
    - Xaman/Ripple — `submitXamanPayload` exposes the signed `hex` blob
      and accepts `{ submit: false }`; new ChainSigner wraps
      xumm.payload.createAndSubscribe and is passed to
      `getRippleToolbox({ signer })`.
    - Ledger/Cosmos Hub — pass the existing `CosmosLedger`
      (already an OfflineAminoSigner) to `getCosmosToolbox(_, { signer })`.
* BitGet Cosmos: use `getOfflineSignerAuto` so V3 proto SignDocs sign
  natively (Ledger via BitGet still falls back to amino).
* WalletConnect EVM: add Aurora + Berachain to the EVM `getToolbox`
  switch and register `XLAYER_MAINNET_ID` so XLayer's namespace
  negotiation works.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@towanTG towanTG merged commit 2e76644 into develop Apr 16, 2026
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