feat: add sign-with-wallet-adapter React example#29
Merged
tilo-14 merged 11 commits intoLightprotocol:mainfrom Mar 2, 2026
Merged
feat: add sign-with-wallet-adapter React example#29tilo-14 merged 11 commits intoLightprotocol:mainfrom
tilo-14 merged 11 commits intoLightprotocol:mainfrom
Conversation
Adds a Wallet Adapter equivalent of the existing Privy example. Swaps the signing layer from Privy SDK to @solana/wallet-adapter-react while keeping identical Light Token SDK usage (transfer, wrap, unwrap). Changes from Privy example: - ConnectionProvider + WalletProvider + WalletModalProvider (replaces PrivyProvider) - useWallet().signTransaction (replaces useSignTransaction from Privy) - signAndSendBatches takes signTransaction(Transaction) -> Transaction - WalletMultiButton for connect/disconnect (replaces Privy login/logout) - Removed wallet selector (single connected wallet) - Fixed hot/cold balance fetch order (cold before hot) so compressed-only mints also get hot balance lookup 26 unit tests passing, build clean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- useWrap now awaits confirmTransaction after sendRawTransaction, matching the behavior of signAndSendBatches (used by transfer/unwrap) - Added confirmTransaction assertion to wrap test - README expanded to match Privy example quality: hook docs, component docs, setup helpers table, quick start guide Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests useUnifiedBalance, useTransfer, and useTransactionHistory against devnet using filesystem keypair signing. Creates a fresh mint with SPL interface, mints tokens, wraps to light-token, then exercises the full transfer + balance + history flow. Run: VITE_HELIUS_RPC_URL=<url> pnpm test:integration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Support both devnet and localnet testing: - VITE_HELIUS_RPC_URL=<url> for devnet (Helius bundles compression API) - VITE_LOCALNET=true for localnet (createRpc() uses default ports 8899/8784/3001) - Localnet mode airdrops SOL before running tests Note: localnet currently blocked by CLI/SDK version mismatch (CLI v0.27.0 programs don't match SDK v0.23.0-beta.9 instructions). Devnet tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- useUnifiedBalance: fetch actual mint decimals via getMint() instead of hardcoding 9 (fixes wrong display/amounts for USDC and other non-9 decimal tokens) - useWrap, useUnwrap: align on Math.round to match useTransfer (all 3 hooks now consistent) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mirror of the wallet-adapter fixes: - useUnifiedBalance: fetch actual mint decimals via getMint() - useUnifiedBalance: fix hot/cold fetch order (cold before hot) so mints discovered only via compressed accounts also get hot balance lookup - useTransfer, useWrap, useUnwrap: Math.floor → Math.round Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a744666 to
08dbfbc
Compare
getMint() defaults to TOKEN_PROGRAM_ID, silently failing for T22 mints and falling back to hardcoded decimals: 9. Track tokenProgram per mint in mintMap and pass it through to getMint(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Same four bugs as React versions: - toUiAmount(amount, 9) called early, hardcoding 9 decimals - Hot balance fetched before cold (ordering bug) - decimals: 9 never updated from on-chain - No tokenProgram tracking for T22 getMint Refactored to store raw bigint values in accumulator and convert to UI amounts at assembly time using actual mint decimals. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
List all 5 toolkits in both root and toolkits README. Add missing pinocchio-swap to program examples table. Entire-Checkpoint: 4afa49be1970
Keep both wallet-adapter and sponsor-rent-top-ups rows. Entire-Checkpoint: 4afa49be1970
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
toolkits/sign-with-wallet-adapter/react/— a Wallet Adapter equivalent of the existing Privy example@solana/wallet-adapter-reactwhile keeping identical Light Token SDK usage (transfer, wrap, unwrap)useUnifiedBalanceso mints discovered only via compressed accounts also get hot balance lookupWhat changed from Privy
PrivyProviderConnectionProvider+WalletProvider+WalletModalProvideruseSignTransaction→ serialize unsigned → sign buffer → deserializeuseWallet().signTransaction→ sign Transaction object → serializeWalletMultiButton(auto-detects wallet-standard wallets)@privy-io/react-auth,@solana-program/memo,@solana/kit@solana/wallet-adapter-react,@solana/wallet-adapter-react-uiFiles identical to Privy
useLightBalance,useUnifiedBalance,useTransactionHistory,CopyButton,Section,TransactionStatus,TransactionHistory,WalletInfo, config files (vite, tsconfig, vitest)Test plan
pnpm test)pnpm build)VITE_HELIUS_RPC_URL)🤖 Generated with Claude Code