MetaMask / metamask-sdk

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.
https://metamask.io/sdk/
Other
188 stars 115 forks source link

fix: connectWith potnetially returning incorrect response #1053

Closed abretonc7s closed 1 month ago

abretonc7s commented 1 month ago

Explanation

Since Async Key exchange, the mobile directly returns the account and chainId before the "with" method is processed which can potentially trigger an eth_getBalance on sdk_react. The sdk historically was waiting for the first rpc response to treat as response to connectWith which is why it could treat response to getBalance instead of the "with" method. This PR fixes this issue.

References

Fixes: https://consensyssoftware.atlassian.net/jira/software/projects/SDK/boards/711?selectedIssue=SDK-61&sprintStarted=true

Checklist

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Project coverage is 78.55%. Comparing base (e7c9409) to head (056a950). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...kages/sdk/src/provider/initializeMobileProvider.ts 0.00% 30 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1053 +/- ## ========================================== - Coverage 78.98% 78.55% -0.44% ========================================== Files 179 179 Lines 4117 4140 +23 Branches 1014 1021 +7 ========================================== Hits 3252 3252 - Misses 865 888 +23 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud