Skip to content

feat(client): wire Privy signer through SentinelClient#24

Merged
Sentinel-Bluebuilder merged 1 commit intomasterfrom
feat/privy-full-integration
Apr 27, 2026
Merged

feat(client): wire Privy signer through SentinelClient#24
Sentinel-Bluebuilder merged 1 commit intomasterfrom
feat/privy-full-integration

Conversation

@Sentinel-Bluebuilder
Copy link
Copy Markdown
Owner

Summary

  • SentinelClient({ signer }) — accept a pre-built cosmjs OfflineDirectSigner (e.g. PrivyCosmosSigner.fromRawSign(...)) directly. getWallet(), getClient(), and getBalance() work without a mnemonic.
  • Backwards-compatible: existing SentinelClient({ mnemonic }) callers unchanged.
  • VPN tunnel paths (connect, autoConnect, connectPlan) throw a helpful error in signer-only mode and point to the docs — the WireGuard/V2Ray handshake still requires a raw cosmos privkey, which Privy's raw-sign endpoint cannot expose.

Context

PR #23 shipped the PrivyCosmosSigner adapter (Mode A mnemonic + Mode B raw-sign). This PR is the follow-up "integrate it fully" pass: instead of asking consumers to hand-build a SigningStargateClient, SentinelClient now accepts the signer directly and routes it everywhere getWallet() is consumed.

The handshake constraint is the one piece we can't unify yet — v3protocol.js#initHandshakeV3 calls Secp256k1.createSignature(msgHash, cosmosPrivKey) with the raw 32-byte privkey, which Mode B doesn't have. Lifting this requires either (a) refactoring the handshake to call out to signRawSecp256k1, or (b) the consumer providing both a mnemonic-derived signer for tunnel ops and a Privy signer for chain ops. Documented as future work; not in this PR.

Changes

  • client.jsgetWallet() resolves: per-call mnemonic → constructor signer → constructor mnemonic. New _requireMnemonicForTunnel() guards connect/autoConnect/connectPlan.
  • test/privy-client-integration.test.mjs (new) — 12 assertions: signer-mode shape, address parity, helpful error for missing auth, rejection of all three connect paths in signer-only mode.
  • docs/PRIVY-INTEGRATION.md — adds operation-by-mode table, "Tunnel connect/disconnect — Mode A only" section, SentinelClient usage example, test list.

Test plan

  • node test/privy-client-integration.test.mjs — 12/12 pass
  • node test/privy-cosmos-signer.test.mjs — 20/20 still pass (no regression on feat(auth): Privy embedded wallet → Cosmos signer adapter #23)
  • npm test (smoke) — 670/671 pass; the 1 failure (SDK_VERSION is 1.0.0) pre-exists on master, unrelated to this diff
  • npm run test:exports — 401 exports load cleanly

…adcast)

The PrivyCosmosSigner adapter shipped in #23 produced a cosmjs OfflineDirectSigner
but consumers had to hand-build a SigningStargateClient to use it. This wires it
into SentinelClient directly:

  new SentinelClient({ signer: privySigner, rpcUrl })
  await client.getBalance()                // works — uses signer's address
  await client.getClient()                  // works — passes signer to SigningStargateClient

getWallet() now resolves in this order:
  1. per-call mnemonic (override)
  2. constructor-supplied signer (Privy raw-sign, Keplr, etc.)
  3. constructor-supplied mnemonic (the original path)

Tunnel handshake constraint: connect() / autoConnect() / connectPlan() throw a
helpful "VPN connect/disconnect requires a mnemonic" error when only a signer is
supplied, because the WireGuard/V2Ray handshake signs locally with the raw
secp256k1 privkey before any chain TX. Privy's raw-sign endpoint cannot reach
into that primitive without a handshake refactor (deferred — out of scope here).
The error message points to docs/PRIVY-INTEGRATION.md for the full table.

Tests: test/privy-client-integration.test.mjs — 12 assertions covering
signer-mode getWallet shape, address parity with mnemonic mode, helpful error
for missing auth, and rejection of all three connect entry points in
signer-only mode. Existing privy-cosmos-signer.test.mjs (20) still passes; smoke
test 670/671 passing (the one pre-existing SDK_VERSION mismatch is unrelated).

Docs: docs/PRIVY-INTEGRATION.md gains a "Tunnel connect/disconnect — Mode A only"
section with the operation-by-mode table, plus a SentinelClient usage example.
@Sentinel-Bluebuilder Sentinel-Bluebuilder merged commit 57230b3 into master Apr 27, 2026
2 checks passed
@Sentinel-Bluebuilder Sentinel-Bluebuilder deleted the feat/privy-full-integration branch April 27, 2026 10:08
@Sentinel-Bluebuilder Sentinel-Bluebuilder mentioned this pull request Apr 27, 2026
4 tasks
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