You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add sign-with-wallet-adapter React example (#29)
* feat: add sign-with-wallet-adapter React example
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>
* fix: add confirmTransaction to useWrap, expand README
- 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>
* test: add e2e integration test for wallet-adapter hooks
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>
* test: add localnet mode to e2e integration test
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>
* Apply suggestions from code review
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix: resolve Devin review — fetch mint decimals, consistent Math.round
- 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>
* fix: apply same decimals + Math.round fixes to Privy example
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>
* fix: pass correct programId to getMint for Token 2022 mints
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>
* fix: refactor Node.js balance snippet to store raw bigints
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>
* docs: add wallet-adapter and sponsor-rent-top-ups to READMEs
List all 5 toolkits in both root and toolkits README. Add missing
pinocchio-swap to program examples table.
Entire-Checkpoint: 4afa49be1970
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: tilo-14 <tilo@luminouslabs.org>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: tilo-14 <tilo@luminouslabs.com>
Wallet Adapter handles wallet connection and transaction signing. You build transactions with light-token instructions and the connected wallet signs them client-side:
4
+
5
+
1. Connect wallet via Wallet Adapter
6
+
2. Build unsigned transaction
7
+
3. Sign transaction using connected wallet (Phantom, Backpack, Solflare, etc.)
8
+
4. Send signed transaction to RPC
9
+
10
+
Light Token gives you rent-free token accounts on Solana. Light-token accounts hold balances from any light, SPL, or Token-2022 mint.
-**[useTransactionHistory.ts](src/hooks/useTransactionHistory.ts)** — Fetch transaction history for light-token operations.
32
+
33
+
#### Components
34
+
35
+
-**[TransferForm.tsx](src/components/sections/TransferForm.tsx)** — Single "Send" button. Routes by token type: light-token -> light-token, or SPL/Token 2022 are wrapped then transfered in one transaction.
36
+
-**[TransactionHistory.tsx](src/components/sections/TransactionHistory.tsx)** — Recent light-token interface transactions with explorer links.
cd ../scripts && npm run register:spl-interface <mint-address>
62
+
```
63
+
64
+
Or in code via `createSplInterface(rpc, payer, mint)`. Works with both SPL Token and Token-2022 mints.
65
+
66
+
**Example: wrapping devnet USDC.** If you have devnet USDC (`4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU`), register its interface PDA first, then wrap it into a light-token associated token account. Set `TEST_MINT` in `.env` to the USDC mint address.
Setup scripts live in [`scripts/`](../scripts/). They use the Solana CLI keypair at `~/.config/solana/id.json`.
85
+
86
+
```bash
87
+
cd ../scripts
88
+
cp .env.example .env # set HELIUS_RPC_URL
89
+
```
90
+
91
+
| Command | What it does |
92
+
| ------- | ----------- |
93
+
|`npm run mint:spl-and-wrap <recipient> [amount] [decimals]`| Create an SPL or T22 mint with interface PDA, mint tokens, wrap, and transfer to recipient. |
94
+
|`npm run mint:spl <mint> <recipient> [amount] [decimals]`| Mint additional SPL or T22 tokens to an existing mint. |
95
+
|`npm run register:spl-interface <mint>`| Register an interface PDA on an existing SPL or T22 mint. Required for wrap/unwrap. |
96
+
97
+
## Quick start
98
+
99
+
```bash
100
+
# 1. Create a test mint with interface PDA + fund your wallet
101
+
cd ../scripts && npm run mint:spl-and-wrap <your-wallet-address>
102
+
103
+
# 2. Start the dev server
104
+
cd ../react && npm run dev
105
+
```
106
+
107
+
Then in the browser:
108
+
1. Connect your wallet via the Wallet Adapter modal
109
+
2. Select a light-token balance from the dropdown
110
+
3. Enter a recipient address and amount
111
+
4. Click "Send" — the app transfers directly
112
+
5. Select an SPL balance — the app wraps to light-token then transfers (two signing prompts)
0 commit comments