Skip to content

Conversation

@FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Dec 19, 2024

Since we only expose the request function from the provider and don't allow listening to events or using provider.chainId etc we can initialize the provider without making the metamask_getProviderState request. This saves us a potential network request that may add overhead to booting the Snap. Specifically the clients call net_version since this property is required in the MetaMaskInpageProvider.

Closes #2968

});

await provider.initialize();
provider.initializeSync();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the main change of this PR alongside the introduction of the SnapProvider wrapper class

@FrederikBolding FrederikBolding marked this pull request as ready for review December 19, 2024 11:00
@FrederikBolding FrederikBolding requested a review from a team as a code owner December 19, 2024 11:00
@codecov
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.59%. Comparing base (336b83f) to head (95882f1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2967   +/-   ##
=======================================
  Coverage   94.59%   94.59%           
=======================================
  Files         493      494    +1     
  Lines       10654    10656    +2     
  Branches     1635     1635           
=======================================
+ Hits        10078    10080    +2     
  Misses        576      576           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@FrederikBolding FrederikBolding merged commit 0a4f8db into main Dec 19, 2024
166 checks passed
@FrederikBolding FrederikBolding deleted the fb/skip-provider-init branch December 19, 2024 11:09
PatrykLucka pushed a commit that referenced this pull request Jan 13, 2025
Since we only expose the `request` function from the provider and don't
allow listening to events or using `provider.chainId` etc we can
initialize the provider without making the `metamask_getProviderState`
request. This saves us a potential network request that may add overhead
to booting the Snap. Specifically the clients call `net_version` since
this property is required in the `MetaMaskInpageProvider`.

Closes #2968
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.

Booting the Snap is slow when requests to the currently selected network are slow

3 participants