Skip to content

feat: use the Coinbase Wallet extension's provider in getProvider() - #1947

Open
fan-zhang-sv wants to merge 1 commit into
masterfrom
felixzhang/extension-injected-provider
Open

fan-zhang-sv wants to merge 1 commit into
masterfrom
felixzhang/extension-injected-provider

Conversation

@fan-zhang-sv

Copy link
Copy Markdown
Contributor

Summary

With the Coinbase Wallet browser extension installed, sdk.evm.getProvider() returned the SDK's popup provider and never reached the extension. The v5 rewrite (#1917) dropped the window.coinbaseWalletExtension check that v4 had in getCoinbaseInjectedProvider; the remaining check only accepts a provider with isCoinbaseBrowser, which is the in-app browser's marker and is false on the extension's provider.

This ports the v4 lines back as getExtensionProvider:

  • sdk.evm.getProvider() returns window.coinbaseWalletExtension when it exists, ahead of the in-app browser provider and the popup provider.
  • The extension is told the app name and logo through setAppInfo, as in v4. v4 also passed appChainIds and preference; v5 has no chain list, so only the name and logo are sent.
  • provider.selected telemetry reports the extension as injected.

Not carried over: v4 skipped the extension for preference.options: 'smartWalletOnly'. v5 has no options preference, so the extension is always used when present.

Out of scope: sdk.connect() and Solana. The extension is deliberately not added to getInjectedProvider(), which also feeds isCoinbaseWalletHost(). A host's provider is sent wallet_connect by sdk.connect(), and the extension rejects that method, so making the extension a host would break sdk.connect(). It would also skip registering the SDK's Solana wallet. Both keep using the popup, which means a dapp that calls sdk.connect() and then uses sdk.evm.getProvider() talks to two different wallets when the extension is installed. The README says the extension is a host for sdk.connect(); that line is left as is and needs a follow-up once the extension answers wallet_connect.

How did you test your changes?

  • yarn lint, yarn format:check, yarn typecheck and yarn test pass (527 SDK tests, 47 playground tests). New unit tests cover getExtensionProvider and the provider choice in createCoinbaseWalletSDK.
  • Ran the playground (examples/testapp) in Chrome for Testing 153 with two local builds of the Coinbase Wallet extension loaded:
    • Before: the playground's provider was the SDK's CoinbaseWalletProvider, not window.coinbaseWalletExtension.
    • After: the playground's provider is window.coinbaseWalletExtension for both builds, eth_chainId returns 0x1 and eth_accounts returns [] on a fresh page, and the SDK's Solana wallet is still registered.
  • Not tested: an approved eth_requestAccounts or a signing request through the extension, and the script-tag bundle.

The v5 rewrite (#1917) dropped the `window.coinbaseWalletExtension`
check that v4 had in `getCoinbaseInjectedProvider`, so with the
extension installed `sdk.evm.getProvider()` returned the SDK's popup
provider and never reached the extension.

Port the v4 lines back as `getExtensionProvider`: return the extension's
provider and pass it the app name and logo through `setAppInfo`.

The extension stays out of `isCoinbaseWalletHost`. A host's provider is
sent `wallet_connect` by `sdk.connect()`, which the extension does not
answer, so `sdk.connect()` and Solana keep using the popup.
@fan-zhang-sv
fan-zhang-sv requested a review from a team as a code owner December 2, 2026 17:56
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants