Skip to content
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

feat: @coinbase/wallet-sdk upgrade #3784

Closed
wants to merge 18 commits into from

Conversation

nateReiners
Copy link
Contributor

@nateReiners nateReiners commented Apr 3, 2024

Description

What changes are made in this PR? Is it a feature or a bug fix?

  • This is just a draft to show what changes are needed in order to upgrade and get the ball rolling
  • Upgrade @coinbase/wallet-sdk from v3 to v4
  • v4 is almost ready and includes Coinbase smart wallets!

Additional Information

Bundle size has been cut in half!

https://bundlephobia.com/package/@coinbase/wallet-sdk@4.0.0

Before submitting this issue, please make sure you do the following.

  • Read the contributing guide
  • Added documentation related to the changes made.
  • Added or updated tests (and snapshots) related to the changes made.

Copy link

changeset-bot bot commented Apr 3, 2024

⚠️ No Changeset found

Latest commit: c50c593

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wagmi ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 4:25am

@@ -45,7 +45,7 @@
}
},
"dependencies": {
"@coinbase/wallet-sdk": "3.9.1",
"@coinbase/wallet-sdk": "4.0.0-beta.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: upgrade to v4 latest when published

@jxom
Copy link
Member

jxom commented Apr 3, 2024

What are the breaking changes in v4?

const reloadOnDisconnect = false

type Provider = CoinbaseWalletProvider
export function coinbaseWallet(parameters: CoinbaseWalletSDKOptions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep CoinbaseWalletParameters around, even if it just proxies CoinbaseWalletSDKOptions. Gives us more control over the connector's public API.

@nateReiners
Copy link
Contributor Author

What are the breaking changes in v4?

Hey @jxom , For most apps there won't be any necessary code changes other than a version bump. However we did remove a bunch of optional SDK options so apps that were passing in any of those will need to remove them. Details here

@nateReiners nateReiners changed the title cb wallet sdk upgrade feat: cb wallet sdk upgrade Apr 9, 2024
@arein
Copy link

arein commented Apr 10, 2024

We need a disableSmartWallet option please - also can you please provide a bundle size comparison @nateReiners ? we have thousands of apps using web3modal and we serve your SDK

@glitch-txs
Copy link
Collaborator

hi @nateReiners we are also using enableMobileWalletLink in Web3Modal, do you know if this would cause some sort of error or conflict in the SDK? It would be a bit tricky for us since Wagmi is just a peer dependency and we cannot control which version devs are using.

@nateReiners
Copy link
Contributor Author

hi @nateReiners we are also using enableMobileWalletLink in Web3Modal, do you know if this would cause some sort of error or conflict in the SDK? It would be a bit tricky for us since Wagmi is just a peer dependency and we cannot control which version devs are using.

Hey @glitch-txs enableMobileWalletLink is gone, but the ability to connect via mobile is enabled by default in v4. When the SDK receives an eth_requestAccounts request, it will open a popup that allows the user to choose between connecting via smart wallet or Coinbase Wallet mobile. You can test out the UX for smart wallet or mobile wallet link here: https://www.smart-wallet.xyz/ Feedback welcome

To remove the option to connect via mobile, dapps can pass in smartWalletOnly: true as an optional SDK option

@wilsoncusack
Copy link

We need a disableSmartWallet option please - also can you please provide a bundle size comparison @nateReiners ? we have thousands of apps using web3modal and we serve your SDK

Hey Derek can you say more why the disable option is needed?

@glitch-txs
Copy link
Collaborator

@nateReiners thanks for the quick response! My question is if the SDK will throw an error if I pass it down the enableMobileWalletLink option in v4. In which case it would break Web3Modal if the dev is using an "old" version.

@nateReiners
Copy link
Contributor Author

also can you please provide a bundle size comparison

@arein Yep, just added it to the PR description. gzipped size was reduced by ~20 KB 🎉

@jxom
Copy link
Member

jxom commented Apr 10, 2024

We need a disableSmartWallet option please - also can you please provide a bundle size comparison @nateReiners ? we have thousands of apps using web3modal and we serve your SDK

Curious why you'd want to disable smart wallets? Shouldn't Web3Modal be agnostic in this sense? I see iOS Coinbase Wallet via Web3Modal the same as what Coinbase Smart Wallet via Web3Modal would be.

@nateReiners
Copy link
Contributor Author

@nateReiners thanks for the quick response! My question is if the SDK will throw an error if I pass it down the enableMobileWalletLink option in v4. In which case it would break Web3Modal if the dev is using an "old" version.

No the SDK wont throw an error. All deprecated options including enableMobileWalletLink are just ignored in v4. It would just be a Typescript issue.

@arein
Copy link

arein commented Apr 12, 2024

@jxom @wilsoncusack I can imagine some dapps not wanting this so I think it makes sense to allow them to configure. What rationale went into the option to exclusively use the smart wallet.

@nateReiners
Copy link
Contributor Author

Hey just wanted to drop an update here since I know this has been sitting for some time. We have been making some SDK interface tweaks and I wanted to wait until all of those decisions are solidified before cleaning up this PR.

We are adding the ability to disable smart wallet as part of these tweaks via an 'eoaOnly' option cc: @arein

Copy link

socket-security bot commented May 14, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@coinbase/wallet-sdk@4.0.0 None 0 0 B

View full report↗︎

packages/connectors/src/coinbaseWallet.ts Outdated Show resolved Hide resolved
packages/connectors/src/coinbaseWallet.ts Show resolved Hide resolved
packages/connectors/src/coinbaseWallet.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@bangtoven bangtoven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: to minimize diff

* @default false
*/
reloadOnDisconnect?: boolean | undefined
Mutable<Omit<ConstructorParameters<typeof CoinbaseWalletSDK>[0], "appChainIds">> & {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Mutable<Omit<ConstructorParameters<typeof CoinbaseWalletSDK>[0], "appChainIds">> & {
Mutable<
Omit<
ConstructorParameters<typeof CoinbaseWalletSDK>[0],
'appChainIds' // remove property and use `config.chains`
>
> & {

@nateReiners nateReiners marked this pull request as ready for review May 14, 2024 01:49
@nateReiners nateReiners changed the title feat: cb wallet sdk upgrade feat: @coinbase/wallet-sdk upgrade May 14, 2024
Copy link
Member

@tmm tmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
'appChainIds' // set via wagmi config
> & {
preference?: Preference
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's inline Preference

Suggested change
preference?: Preference
preference?: Parameters<CoinbaseWalletSDK['makeWeb3Provider']>[0] | undefined

Comment on lines 17 to 18
type Preference = Parameters<CoinbaseWalletSDK['makeWeb3Provider']>[0]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type Preference = Parameters<CoinbaseWalletSDK['makeWeb3Provider']>[0]

@nateReiners
Copy link
Contributor Author

Closing in favor of #3928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants