Repository navigation
feat: use the Coinbase Wallet extension's provider in getProvider() - #1947
Open
fan-zhang-sv wants to merge 1 commit into
Open
fan-zhang-sv wants to merge 1 commit into
fan-zhang-sv wants to merge 1 commit into
Conversation
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.
Collaborator
🟡 Heimdall Review Status
|
This branch has not been deployed
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
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 thewindow.coinbaseWalletExtensioncheck that v4 had ingetCoinbaseInjectedProvider; the remaining check only accepts a provider withisCoinbaseBrowser, which is the in-app browser's marker and isfalseon the extension's provider.This ports the v4 lines back as
getExtensionProvider:sdk.evm.getProvider()returnswindow.coinbaseWalletExtensionwhen it exists, ahead of the in-app browser provider and the popup provider.setAppInfo, as in v4. v4 also passedappChainIdsandpreference; v5 has no chain list, so only the name and logo are sent.provider.selectedtelemetry reports the extension asinjected.Not carried over: v4 skipped the extension for
preference.options: 'smartWalletOnly'. v5 has nooptionspreference, so the extension is always used when present.Out of scope:
sdk.connect()and Solana. The extension is deliberately not added togetInjectedProvider(), which also feedsisCoinbaseWalletHost(). A host's provider is sentwallet_connectbysdk.connect(), and the extension rejects that method, so making the extension a host would breaksdk.connect(). It would also skip registering the SDK's Solana wallet. Both keep using the popup, which means a dapp that callssdk.connect()and then usessdk.evm.getProvider()talks to two different wallets when the extension is installed. The README says the extension is a host forsdk.connect(); that line is left as is and needs a follow-up once the extension answerswallet_connect.How did you test your changes?
yarn lint,yarn format:check,yarn typecheckandyarn testpass (527 SDK tests, 47 playground tests). New unit tests covergetExtensionProviderand the provider choice increateCoinbaseWalletSDK.examples/testapp) in Chrome for Testing 153 with two local builds of the Coinbase Wallet extension loaded:CoinbaseWalletProvider, notwindow.coinbaseWalletExtension.window.coinbaseWalletExtensionfor both builds,eth_chainIdreturns0x1andeth_accountsreturns[]on a fresh page, and the SDK's Solana wallet is still registered.eth_requestAccountsor a signing request through the extension, and the script-tag bundle.