-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: implement lazy-loading for Coinbase Wallet SDK #5152
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
base: main
Are you sure you want to change the base?
Conversation
Defers Coinbase SDK initialization until user explicitly connects, reducing bundle size and improving initial load performance across all EVM adapters. Changes: - ethers & ethers5: Extract getCoinbaseProvider as lazy class method, store options reference, instantiate SDK only on connect - wagmi: Skip getProvider() call during connector setup for Coinbase, resolve lazily in connect flow - Add security scanning utility script 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🦋 Changeset detectedLatest commit: 3c080bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
10 Skipped Deployments
|
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.
Pull Request Overview
This pull request implements lazy-loading for the Coinbase Wallet SDK to reduce initial bundle size and improve load performance. The change defers SDK initialization until the user explicitly connects to Coinbase wallet.
- Extracted Coinbase provider initialization into lazy class methods across ethers and ethers5 adapters
- Modified wagmi adapter to skip getProvider() calls during setup for Coinbase connectors
- Updated connection flow to resolve Coinbase provider only when needed
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/adapters/wagmi/src/client.ts | Skip getProvider() during Coinbase connector setup, resolve lazily in connect flow |
| packages/adapters/ethers5/src/client.ts | Extract getCoinbaseProviderLazy method and defer SDK initialization until connect |
| packages/adapters/ethers/src/client.ts | Extract getCoinbaseProviderLazy method and defer SDK initialization until connect |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Register Coinbase connector without instantiating SDK yet (lazy-load on connect) | ||
| providers.coinbase = undefined |
Copilot
AI
Oct 4, 2025
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.
Setting providers.coinbase to undefined may cause issues downstream. Consider using a placeholder object or lazy provider wrapper instead of undefined to maintain consistent provider interface expectations.
| // Register Coinbase connector without instantiating SDK yet (lazy-load on connect) | |
| providers.coinbase = undefined | |
| // Register Coinbase connector with a lazy provider wrapper (lazy-load on connect) | |
| providers.coinbase = { | |
| getProvider: () => this.getCoinbaseProviderLazy() | |
| } |
| // Register Coinbase connector without instantiating SDK yet (lazy-load on connect) | ||
| providers.coinbase = undefined |
Copilot
AI
Oct 4, 2025
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.
Setting providers.coinbase to undefined may cause issues downstream. Consider using a placeholder object or lazy provider wrapper instead of undefined to maintain consistent provider interface expectations.
| // Register Coinbase connector without instantiating SDK yet (lazy-load on connect) | |
| providers.coinbase = undefined | |
| // Register Coinbase connector with a lazy provider getter function | |
| providers.coinbase = this.getCoinbaseProviderLazy.bind(this) |
| // Persist on the connector so listeners work normally | ||
| // eslint-disable-next-line no-param-reassign | ||
| connector.provider = selectedProvider |
Copilot
AI
Oct 4, 2025
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.
Directly mutating the connector parameter violates immutability principles. Consider using a more functional approach or documenting why this mutation is necessary for the architecture.
| // Persist on the connector so listeners work normally | |
| // eslint-disable-next-line no-param-reassign | |
| connector.provider = selectedProvider | |
| // Create a new connector object with the updated provider to preserve immutability | |
| connector = { ...connector, provider: selectedProvider } |
| // eslint-disable-next-line no-param-reassign | ||
| connector.provider = selectedProvider |
Copilot
AI
Oct 4, 2025
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.
Directly mutating the connector parameter violates immutability principles. Consider using a more functional approach or documenting why this mutation is necessary for the architecture.
| // eslint-disable-next-line no-param-reassign | |
| connector.provider = selectedProvider | |
| // Use a new connector object to preserve immutability | |
| const updatedConnector = { ...connector, provider: selectedProvider } | |
| connector = updatedConnector |
|
@claude review |
Defers Coinbase SDK initialization until user explicitly connects, reducing bundle size and improving initial load performance across all adapters. Improves UX/privacy as it removes ~3 HTTP calls to Coinbase.
Changes:
Description
Please include a brief summary of the change.
Type of change
Associated Issues
For Linear issues: Closes APKT-xxx
For GH issues: closes #...
Showcase (Optional)
If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.
Checklist