feat: extract use-auth and use-wallet-accounts hooks across JS SDK examples#59
Open
avneesh0612 wants to merge 8 commits into
Open
feat: extract use-auth and use-wallet-accounts hooks across JS SDK examples#59avneesh0612 wants to merge 8 commits into
avneesh0612 wants to merge 8 commits into
Conversation
…amples Add reusable `use-auth` and `use-wallet-accounts` hooks to all Next.js examples that use the Dynamic JS SDK, removing duplicated inline logic from providers and components. Affected examples: - nextjs-bridge-mayan - nextjs-defi-lending-morpho - nextjs-moneygram-ramp - nextjs-stablecoin-yield-aave - nextjs-stablecoin-yield-kamino - nextjs-stablecoin-yield-pods Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed with the following error: |
3 tasks
Replace custom useSyncExternalStore-based hooks with the official @dynamic-labs-sdk/react-hooks package across all JS SDK examples. - useAuth: delegate to useUser() from react-hooks (null = signed out) - useEvmWalletAccount / useSolanaWalletAccount / useWalletAccounts: delegate to useWalletAccounts() from react-hooks with chain filters - Providers: wrap with DynamicProvider from react-hooks - Remove manual onEvent subscriptions and getWalletAccounts polling Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace @dynamic-labs-sdk/* with the current @dynamic-labs/* packages across all JS SDK examples. Key changes: - createDynamicClient → createClient + .extend() pattern - useUser/useWalletAccounts → useReactiveClient(dynamicClient) - DynamicProvider removed (not needed in new API) - State accessed via client.auth.authenticatedUser and client.wallets.userWallets - Wallet chain filtering via w.chain === "EVM" | "SOL" Packages updated: - @dynamic-labs/client@4.83.1 - @dynamic-labs/react-hooks@4.83.1 - @dynamic-labs/waas-evm@4.83.1 (EVM examples) - @dynamic-labs/waas-svm@4.83.1 (Solana examples) - @dynamic-labs/viem-extension@4.83.1 (morpho, aave) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Delete hooks/use-auth.ts and hooks/use-wallet-accounts.ts from all JS SDK examples — the indirection is unnecessary. All callers now use useReactiveClient(dynamicClient) directly from @dynamic-labs/react-hooks and access state via client.auth.authenticatedUser and client.wallets.userWallets. Also completes the @dynamic-labs-sdk → @dynamic-labs migration: - All old SDK imports removed from providers, components, and hooks - Wallet filtering: w.chain === "EVM" | "SOL" (no type guards) - Wallet creation: dynamicClient.wallets.embedded.createWallet() - Auth: dynamicClient.auth.logout(), dynamicClient.ui.auth.show() Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* feat(iron-ramp): add Solana wallet support Adds end-to-end Solana support to the nextjs-iron-ramp example alongside the existing EVM flow. Every place that previously assumed a single EVM wallet now handles both ecosystems. ## What changed **Wallet connectors** - Add `@dynamic-labs/solana@4.52.2` and register `SolanaWalletConnectors` alongside `EthereumWalletConnectors` in the provider. **Constants & chain selector** - Add `Solana` to the `CHAINS` list. - In the Quick Ramp chain dropdown, show all EVM chains when any EVM wallet is registered; show Solana only when a Solana wallet is registered (falls back to all chains if nothing is registered yet). **Address handling** - Solana addresses (base58, no `0x` prefix) are never lowercased; all comparisons use exact-match. EVM addresses keep case-insensitive comparison everywhere. - Blockchain is detected from the address itself rather than chain IDs, so it works for both ecosystems without extra config. **Wallet registration — onboarding step** - The "Register Wallet" card is replaced with a multi-wallet card: fetches already-linked wallets from Iron Finance on mount and marks them as "Linked ✓". - Renders every wallet from `useUserWallets()` with a SOL / EVM badge, network label, and per-wallet Link button. - Calls `useSwitchWallet` to make the target wallet the Dynamic primary before requesting a signature, so the signing prompt appears on the correct wallet. - The Continue button appears once ≥1 wallet is linked and advances to the bank step separately. **Wallet registration — status card (main page)** - Onboarding Status card now lists all registered wallets (SOL / EVM badges + copy buttons) instead of just the first one. - "+ Link another wallet" button appears for any connected but unregistered wallet; clicking it runs the same sign + register flow inline without leaving the page. **Wallet selection — Quick Ramp** - When the user picks a registered wallet from the dropdown, calls `useSwitchWallet` so the Dynamic primary wallet stays in sync. **Iron Finance API — `recipient_account_id`** - For GET `/api/autoramps/quote` (onramp and offramp), passes `recipient_account_id` (registered UUID) instead of the raw address/IBAN when available — required by Iron Finance for some destination currencies (e.g. USDC on Solana). - POST `/api/autoramps` (create) continues to use the `recipient_account` object, which is what that endpoint accepts. **Resilience fixes** - `handleAddBankAccount`: on 409 "already exists", looks up the registered bank by IBAN and advances to complete instead of getting stuck on the bank step. - `syncToDynamic` in `useKYCMetadata`: retries up to 3 times with increasing delays; logs at `warn` instead of `error` to avoid the Next.js dev error overlay on transient network failures. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * chore(iron-ramp): remove unused @dynamic-labs/ethereum-aa dependency Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * chore: update packages --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…examples - kamino: fix deposit minimum pre-flight (minDepositAmount is in raw token units; divide by 10^decimals for human-readable comparison) - pods: add "use client" + ssr:false to header to fix DynamicButton hydration - pods: add mounted guard for auth-gated Positions section - pods: fix position balance parsing — balance lives in spotPosition.currentPosition.humanized, not p.balance; update RawWalletPosition types to match actual API shape - pods: set filterSpamTokens:true on getBalances call - iron-ramp: mark resolved pnpm-lock.yaml conflict Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace local use-auth.ts and use-wallet-accounts.ts wrapper files across the 6 examples with direct imports from @dynamic-labs-sdk/react-hooks. Each providers.tsx now uses useUser() and useWalletAccounts() directly; moneygram components (header, ramp-app) import useUser/useWalletAccounts from the package instead of local wrappers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Only the 6 target examples should be modified on this branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
use-authanduse-wallet-accountshooks from inline provider/component logic into dedicated hook files across all Next.js examples using the Dynamic JS SDKproviders.tsxand componentsExamples Updated
nextjs-bridge-mayanhooks/use-auth.ts,hooks/use-wallet-accounts.tslib/providers.tsxnextjs-defi-lending-morphohooks/use-auth.ts,hooks/use-wallet-accounts.tslib/providers.tsxnextjs-moneygram-ramphooks/use-auth.ts,hooks/use-wallet-accounts.tscomponents/header.tsx,components/ramp-app.tsxnextjs-stablecoin-yield-aavehooks/use-auth.ts,hooks/use-wallet-accounts.tslib/providers.tsxnextjs-stablecoin-yield-kaminohooks/use-auth.ts,hooks/use-wallet-accounts.tslib/providers.tsxnextjs-stablecoin-yield-podshooks/use-auth.ts,hooks/use-wallet-accounts.tslib/providers.tsxHook Pattern
Both hooks use
useSyncExternalStoreover Dynamic client events for reactive, subscription-based state:Test plan
pnpm devin each updated example and verify auth state reflects correctly on sign-in / sign-out🤖 Generated with Claude Code