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

fix: use hostname to fetch approvedhosts #7489

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

elefantel
Copy link
Contributor

Description

This PR fixes an Android SDK bug whereby:

  • The wallet was always returning the first permitted account instead of the selected account when connecting the SDK to MetaMask
  • Changing the selected account on MetaMask did not fire a metamask_accountsChanged event so the SDK did not get selected account updated.

This change implements the getApprovedHosts to fix this issue.

Manual testing steps

_1. Have more than one address in your metamask account and select any address as active address
_2. Connect from Android Metamask SDK and ensure the active account is the selected address on the SDK
_3. Switch to another account on the wallet, and ensure that the SDK updates to the new address

Related issues

Fixes #???

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained:
    • What problem this PR is solving.
    • How this problem was solved.
    • How reviewers can test my changes.
  • I’ve indicated what issue this PR is linked to: Fixes #???
  • I’ve included tests if applicable.
  • I’ve documented any added code.
  • I’ve applied the right labels on the PR (see labeling guidelines).
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@elefantel elefantel added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Oct 12, 2023
@elefantel elefantel requested a review from a team as a code owner October 12, 2023 13:58
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@elefantel elefantel added the team-sdk SDK team label Oct 12, 2023
@elefantel elefantel changed the title bug-fix: use hostname to fetch approvedhosts fix: use hostname to fetch approvedhosts Oct 12, 2023
Copy link

@deeeed deeeed left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@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

Copy link
Member

@andreahaku andreahaku left a comment

Choose a reason for hiding this comment

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

LGTM

@andreahaku andreahaku added needs-qa Any New Features that needs a full manual QA prior to being added to a release. and removed needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) labels Oct 12, 2023
@codecov-commenter
Copy link

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (974809d) 34.60% compared to head (87ab71c) 34.60%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7489   +/-   ##
=======================================
  Coverage   34.60%   34.60%           
=======================================
  Files        1019     1019           
  Lines       27192    27193    +1     
  Branches     2212     2213    +1     
=======================================
+ Hits         9409     9410    +1     
  Misses      17295    17295           
  Partials      488      488           
Files Coverage Δ
app/core/RPCMethods/RPCMethodMiddleware.ts 44.15% <100.00%> (+0.21%) ⬆️
app/core/BackgroundBridge/BackgroundBridge.js 5.35% <0.00%> (-0.05%) ⬇️
app/core/SDKConnect/AndroidSDK/AndroidService.ts 0.00% <0.00%> (ø)

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

@sonarcloud
Copy link

sonarcloud bot commented Oct 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

46.2% 46.2% Coverage
0.0% 0.0% Duplication

@christopherferreira9 christopherferreira9 self-assigned this Oct 16, 2023
@christopherferreira9 christopherferreira9 added QA in Progress QA has started on the feature. QA Passed A successful QA run through has been done and removed needs-qa Any New Features that needs a full manual QA prior to being added to a release. QA in Progress QA has started on the feature. labels Oct 17, 2023
@christopherferreira9
Copy link
Contributor

All good and working ✅

Screen.Recording.2023-10-17.at.18.28.06.mov

@christopherferreira9 christopherferreira9 merged commit 13130e3 into main Oct 17, 2023
28 of 30 checks passed
@christopherferreira9 christopherferreira9 deleted the change-selected-account branch October 17, 2023 17:33
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2023
@christopherferreira9
Copy link
Contributor

Fixes: MetaMask/metamask-android-sdk#32

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
QA Passed A successful QA run through has been done release-7.10.0 team-sdk SDK team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants