Skip to content

feat: update the metamask sdk package to version "0.18.3" #3602

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

Conversation

omridan159
Copy link
Contributor

@omridan159 omridan159 commented Feb 15, 2024

Description

This PR updates the MetaMask SDK package to version 0.18.3, introducing significant improvements aimed at reducing the bundle size and enhancing the MetaMask connector's logic. This version marks a pivotal update where we've focused on optimizing the overall package size to ensure faster loading times and a more efficient integration process for developers. Alongside the SDK bundle size reduction, this PR addresses various bugs and enhances the SDK's functionality to operate seamlessly without the necessity for the extensionOnly=true option.

It is also crucial to highlight that dappMetadata has become mandatory for integration with this version. This change underscores our commitment to improving security and user experience by ensuring that dApps provide the necessary information for a safer and more transparent interaction.

Furthermore, to expand the SDK's compatibility and usability on mobile devices, we have introduced support for custom RPC URLs. This enhancement allows for the direct incorporation of custom RPC URLs from the Wagmi Config, offering developers the flexibility to specify their network configurations, thereby facilitating a smoother integration with different blockchain networks.

These updates collectively contribute to a more robust, efficient, and versatile MetaMask SDK, setting a new standard for blockchain application development.

Additional Information

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 Feb 15, 2024

🦋 Changeset detected

Latest commit: 4733017

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@wagmi/connectors Minor
create-wagmi Minor
wagmi Patch

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

Copy link

vercel bot commented Feb 15, 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 Apr 11, 2024 3:09pm

Copy link

socket-security bot commented Feb 15, 2024

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

Package New capabilities Transitives Size Publisher
npm/@metamask/[email protected] Transitive: environment, eval, filesystem, network, shell +91 55.8 MB metamaskbot

View full report↗︎

Copy link
Collaborator

@abretonc7s abretonc7s left a comment

Choose a reason for hiding this comment

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

small change for dapp metadata

Copy link
Collaborator

@abretonc7s abretonc7s left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 37 to 38
let sdk: MetaMaskSDK
let sdkImport: Promise<typeof import('@metamask/sdk')> | undefined
Copy link
Member

@jxom jxom Feb 24, 2024

Choose a reason for hiding this comment

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

I am curious why this was moved here? It should only be initialized once in the Connector instance (where it was before).

Copy link

Choose a reason for hiding this comment

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

yes we can move it back, was initially testing different variation but eventually the scope shouldn't have impact.

dappMetadata: {
name: 'Create Wagmi',
},
infuraAPIKey: import.meta.env.VITE_INFURA_API_KEY,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should expose this at all as not all consumers use Infura, and tend to bring their own RPC providers. Instead, can we have the ability to pass an arbitrary RPC URL to the MetaMask SDK? This is what we are doing for the other connectors, like WalletConnect: https://github.com/wevm/wagmi/blob/main/packages/connectors/src/walletConnect.ts#L212-L217

This means we can infer the RPC URL from the provided transports from the Wagmi Config.

Copy link

Choose a reason for hiding this comment

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

Thanks, we have a similar way to configure rpcMap, will update accordingly.

@jxom
Copy link
Member

jxom commented Feb 26, 2024

Will review this in-depth later in the week and happy to merge after that.

I was also wondering – has there been any efforts so far to mitigate bundle size? Saw that in the SDK changelog, but I am seeing no difference between 0.14.3 and 0.15.0 (looks like it increased very slightly?):

0.15.0

  import { MetaMaskSDK } from '@metamask/sdk'
  //       ^?

  Size:         324.98 kB with all dependencies, minified and brotlied
  Loading time: 6.4 s     on slow 3G
  Running time: 7.1 s     on Snapdragon 410
  Total time:   13.5 s

0.14.3

  import { MetaMaskSDK } from '@metamask/sdk'
  //       ^?
  
  Size:         324.61 kB with all dependencies, minified and brotlied
  Loading time: 6.4 s     on slow 3G
  Running time: 1.8 s     on Snapdragon 410
  Total time:   8.2 s

Reproduced with size-limit

@deeeed
Copy link

deeeed commented Feb 26, 2024

Will review this in-depth later in the week and happy to merge after that.

I was also wondering – has there been any efforts so far to mitigate bundle size? Saw that in the SDK changelog, but I am seeing no difference between 0.14.3 and 0.15.0 (looks like it increased very slightly?):

0.15.0

  import { MetaMaskSDK } from '@metamask/sdk'
  //       ^?

  Size:         324.98 kB with all dependencies, minified and brotlied
  Loading time: 6.4 s     on slow 3G
  Running time: 7.1 s     on Snapdragon 410
  Total time:   13.5 s

0.14.3

  import { MetaMaskSDK } from '@metamask/sdk'
  //       ^?
  
  Size:         324.61 kB with all dependencies, minified and brotlied
  Loading time: 6.4 s     on slow 3G
  Running time: 1.8 s     on Snapdragon 410
  Total time:   8.2 s

Reproduced with size-limit

Not on the source itself, we are tackling that next. Currently we removed the sourcemaps that were creating high package size on npm and was potentially scaring people away (even though it is unrelated). We will have another update on the PR today to address your comments.

@omridan159 omridan159 changed the title feat: update the metamask sdk package to version "0.15.0" feat: update the metamask sdk package to version "0.16.0" Mar 6, 2024
@omridan159 omridan159 changed the title feat: update the metamask sdk package to version "0.16.0" feat: update the metamask sdk package to version "0.17.1" Mar 13, 2024
@glitch-txs
Copy link
Collaborator

Currently we removed the sourcemaps that were creating high package size on npm

Source maps don't necessarily affect the bundle size, devs can choose if they'd like to ship them or not. IMO the focus should be on the source code itself.

For example I noticed the SDK installs react and react-native regardless of the environment used. Although this might be tree shaken I'm not sure why it would be needed.

When installing Wagmi the console also shows some peer dependency issues that are from the SDK too. It would be nice to address that to have a clean install as well.

@omridan159 omridan159 changed the title feat: update the metamask sdk package to version "0.17.1" feat: update the metamask sdk package to version "0.17.2" Mar 18, 2024
…kage-to-version-0.15.0' into feat_update-the-metamask-sdk-package-to-version-0.15.0
@omridan159 omridan159 changed the title feat: update the metamask sdk package to version "0.17.2" feat: update the metamask sdk package to version "0.18.3" Apr 11, 2024
@omridan159 omridan159 closed this Apr 11, 2024
@omridan159 omridan159 deleted the feat_update-the-metamask-sdk-package-to-version-0.15.0 branch April 11, 2024 15:06
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.

5 participants