-
Notifications
You must be signed in to change notification settings - Fork 619
[SDK] Simplify wallet connection code and add Abstract wallet support #8061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK] Simplify wallet connection code and add Abstract wallet support #8061
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
4 Skipped Deployments
|
|
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8061 +/- ##
=======================================
Coverage 56.51% 56.51%
=======================================
Files 904 904
Lines 58865 58865
Branches 4170 4170
=======================================
Hits 33269 33269
Misses 25491 25491
Partials 105 105
🚀 New features to boost your workflow:
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsx (1)
23-27: Fix Next.js params typing and return concrete objects from generateStaticParams.
paramsshould not be a Promise, andgenerateStaticParamsmust return an array of objects (not Promises). The current types risk build-time failures.-type PageProps = { - params: Promise<{ - walletId: WalletId; - }>; -}; +type PageProps = { + params: { + walletId: WalletId; + }; +}; -export async function generateStaticParams(): Promise<PageProps["params"][]> { +export async function generateStaticParams(): Promise<PageProps["params"][]> { const walletList = await getAllWalletsList(); - return walletList.map((w) => { - return Promise.resolve({ - walletId: w.id, - }); - }); + return walletList.map((w) => ({ + walletId: w.id, + })); }Also applies to: 173-181
🧹 Nitpick comments (9)
apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsx (2)
183-193: Clean unusedinjectedProviderimports in generated snippets and align comments with the unified connect flow.These snippets import
injectedProviderbut never use it after the simplification. Also tweak comments to reflect the unconditional connect (extension → injected, otherwise WalletConnect).function injectedSupportedTS(id: string) { return `\ import { createThirdwebClient } from "thirdweb"; -import { createWallet, injectedProvider } from "thirdweb/wallets"; +import { createWallet } from "thirdweb/wallets"; ... `; } function injectedAndWCSupportedCodeTS(id: string) { return `\ import { createThirdwebClient } from "thirdweb"; -import { createWallet, injectedProvider } from "thirdweb/wallets"; +import { createWallet } from "thirdweb/wallets"; ... -// if user has wallet installed, connects to it, otherwise opens a WalletConnect modal +// Connect. If the extension isn't installed, a WalletConnect flow opens. await wallet.connect({ client }); `; } function injectedAndWCSupportedCodeReact(id: string) { return `\ import { createThirdwebClient } from "thirdweb"; import { useConnect } from "thirdweb/react"; -import { createWallet, injectedProvider } from "thirdweb/wallets"; +import { createWallet } from "thirdweb/wallets"; ...function injectedSupportedCodeReact(id: string) { return `\ import { createThirdwebClient } from "thirdweb"; import { useConnect } from "thirdweb/react"; -import { createWallet, injectedProvider } from "thirdweb/wallets"; +import { createWallet } from "thirdweb/wallets"; ... - // if the wallet extension is installed, connect to it, otherwise opens a WalletConnect modal + // Connect. If the extension isn't installed, a WalletConnect flow opens. connect(async () => { const wallet = createWallet("${id}"); await wallet.connect({ client }); return wallet; });Also applies to: 207-218, 220-246, 276-302
137-149: Use TSX highlighting for React examples.The “React (Custom UI)” tab shows React code; switch to
tsxfor accurate highlighting.- lang="ts" + lang="tsx"apps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx (7)
1-1: Drop unnecessary ESLint disable.You’re using
next/image; theno-img-elementrule is not applicable here.-/* eslint-disable @next/next/no-img-element */
18-29: Add explicit return types for exported functions.Matches repo TS guidelines and improves DX.
+import type { Metadata } from "next"; ... -export async function generateMetadata() { +export async function generateMetadata(): Promise<Metadata> { const walletMetadata = await getWalletInfo(walletId); return createMetadata({ description: `Connect ${walletMetadata.name} with thirdweb TypeScript SDK`, image: { icon: "wallets", title: walletMetadata.name }, title: walletMetadata.name, }); } -export default async function Page() { +export default async function Page(): Promise<JSX.Element> { const [walletMetadata, walletImage] = await Promise.all([ getWalletInfo(walletId), getWalletInfo(walletId, true), ]);Also applies to: 31-36
79-86: Fix duplicate/incorrect heading anchor.“Installation” uses
anchorId="connect-wallet", colliding with the actual Connect section.- <Heading anchorId="connect-wallet" level={2}> + <Heading anchorId="installation" level={2}> Installation </Heading>Also applies to: 88-90
101-103: Use TSX highlighting for React example.- <CodeBlock code={injectedSupportedCodeReact()} lang="ts" /> + <CodeBlock code={injectedSupportedCodeReact()} lang="tsx" />
148-175: Update outdated comment; connect flow is unconditional now.Comment mentions “if the wallet extension is installed,” but the code calls
connectunconditionally.- // if the wallet extension is installed, connect to it + // Connect. The appropriate provider/modal will be used automatically.
177-200: Import ConnectEmbed in the component snippet.The snippet uses
ConnectEmbedwithout importing it.-import { ConnectButton } from "thirdweb/react"; +import { ConnectButton, ConnectEmbed } from "thirdweb/react";
134-146: Avoid helper name shadowing and make intent clearer.Local
createWallet()helper returnsabstractWallet()string and can be confused withcreateWalletfrom the SDK (also imported inside snippets). Rename and update references.-const wallet = ${createWallet()}; +const wallet = ${absWalletSnippet()}; ... -const wallet = ${createWallet()}; +const wallet = ${absWalletSnippet()}; ... - ${createWallet()}, + ${absWalletSnippet()}, ... -function createWallet() { +function absWalletSnippet() { return `abstractWallet()`; }Also applies to: 148-175, 177-200, 202-205
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/portal/src/app/typescript/v5/connecting-wallets/page.mdx(1 hunks)apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsx(6 hunks)apps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsxapps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsxapps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx
🧠 Learnings (2)
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).
Applied to files:
apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsxapps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : Support for in-app wallets (social/email login)
Applied to files:
apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsx
🧬 Code graph analysis (1)
apps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx (1)
apps/portal/src/app/wallets/external-wallets/[walletId]/page.tsx (2)
generateMetadata(29-41)Page(43-171)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Size
- GitHub Check: Lint Packages
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/portal/src/app/typescript/v5/connecting-wallets/page.mdx (1)
44-46: Remove unused import and clarify WalletConnect fallbackDrop
injectedProviderfrom the import — it's unused..connect({ client })prefers an injected provider if present; if none is available and you provide a WalletConnect client/options it will open a WalletConnect session/modal. Connect UI enables WalletConnect-by-default; AutoConnect does not auto-reconnect WalletConnect sessions.-import { createWallet, injectedProvider } from "thirdweb/wallets"; +import { createWallet } from "thirdweb/wallets";apps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx (1)
123-130: Verify referenced docs route exists or update the link.No static page found at /references/typescript/v5/AbsWalletCreationOptions; repo uses dynamic handler apps/portal/src/app/references/typescript/[version]/[[...slug]]/page.tsx — confirm "AbsWalletCreationOptions" is present in the reference data/link map (or update the DocLink).
Location: apps/portal/src/app/wallets/external-wallets/xyz.abs/page.tsx:127

PR-Codex overview
This PR simplifies the wallet connection logic by removing conditional checks for wallet installations and directly attempting to connect. It also introduces a new page for the
xyz.abswallet with detailed metadata and connection instructions.Detailed summary
page.mdxandpage.tsx.xyz.abswallet with metadata generation and connection instructions.Summary by CodeRabbit
New Features
Documentation