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

build: Pull @metamask/mobile-provider back into metamask-mobile #7494

Merged
merged 27 commits into from
Oct 18, 2023

Conversation

jiexi
Copy link
Contributor

@jiexi jiexi commented Oct 13, 2023

Description

Currently the inpage injected scripts used in the in-app browser (for making the wallet provider object available to the dapp) are currently built in a separate @metamask/mobile-provider package. This PR brings the build process into the mobile repo itself. This is needed in order to support passing build time variables to the provider initialization (for EIP6963 support).

Manual testing steps

  1. Pull in branch
  2. yarn setup
  3. yarn watch
  4. yarn start:ios
  5. Go to in-app browser
  6. Visit test dapp
  7. Verify that buttons are still functional
  8. Optionally: Open safari debug console on the test dapp webview
  9. check that window.ethereum is defined and window.ethereum.chainId logs a deprecation warning

Screenshots/Recordings

Note the deprecation warnings which indicates that provider v13.0.0 is now being used
image

Related issues

See: https://github.com/MetaMask/MetaMask-planning/issues/869

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.

@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.

@jiexi jiexi changed the title Jl/pull in mobile provider Pull @metamask/mobile-provider back into metamask-mobile Oct 13, 2023
.eslintignore Outdated Show resolved Hide resolved
@socket-security
Copy link

socket-security bot commented Oct 13, 2023

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

Packages Version New capabilities Transitives Size Publisher
@metamask/object-multiplex 1.2.0 None +1 102 kB gudahtt
webpack-cli 5.1.4 environment +10 481 kB evilebottnawi
@metamask/providers 13.1.0 None +6 635 kB metamaskbot
stream-browserify 1.0.0...3.0.0 None +2/-1 150 kB goto-bus-stop
readable-stream 1.0.33...2.3.7 None +0/-0 87.7 kB matteo.collina

🚮 Removed packages: obj-multiplex@1.0.0

@socket-security
Copy link

socket-security bot commented Oct 13, 2023

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: @metamask/object-multiplex@1.2.0, extension-port-stream@2.1.1, setprototypeof@1.2.0

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

scripts/postinstall.sh Outdated Show resolved Hide resolved
scripts/postinstall.sh Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
scripts/postinstall.sh Outdated Show resolved Hide resolved
@jiexi jiexi changed the title Pull @metamask/mobile-provider back into metamask-mobile build: Pull @metamask/mobile-provider back into metamask-mobile Oct 13, 2023
@jiexi jiexi added team-wallet-api-platform needs-qa Any New Features that needs a full manual QA prior to being added to a release. labels Oct 13, 2023
@jiexi
Copy link
Contributor Author

jiexi commented Oct 13, 2023

@SocketSecurity ignore @metamask/object-multiplex@1.2.0
@SocketSecurity ignore extension-port-stream@2.1.1

these are our packages. but i don't trust this gudahtt fellow

@jiexi jiexi marked this pull request as ready for review October 13, 2023 18:34
@jiexi jiexi requested a review from a team as a code owner October 13, 2023 18:34
scripts/postinstall.sh Outdated Show resolved Hide resolved
.storybook/storybook.requires.js Outdated Show resolved Hide resolved
app/util/streams.js Show resolved Hide resolved
ios/Podfile.lock Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (cd15dab) 34.61% compared to head (de52d61) 34.61%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7494   +/-   ##
=======================================
  Coverage   34.61%   34.61%           
=======================================
  Files        1019     1019           
  Lines       27193    27193           
  Branches     2218     2218           
=======================================
  Hits         9413     9413           
  Misses      17289    17289           
  Partials      491      491           
Files Coverage Δ
app/components/UI/Swaps/utils/index.js 16.12% <ø> (ø)
app/constants/network.js 100.00% <ø> (ø)
app/core/Engine.ts 53.74% <ø> (ø)
app/util/streams.js 21.42% <100.00%> (ø)

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

@Cal-L
Copy link
Contributor

Cal-L commented Oct 13, 2023

Since the Provider directory are files used during build time, seems better to move them out to maybe the top most level of the application. WDYT?

@jiexi
Copy link
Contributor Author

jiexi commented Oct 13, 2023

we can move them. Not sure what directory to park them in though. This is where inpage lives in extension for reference

https://github.com/MetaMask/metamask-extension/blob/a1fad6ab9ba50069953254ee51e4e8e65a53c3c8/app/scripts/inpage.js#L42

@Cal-L
Copy link
Contributor

Cal-L commented Oct 16, 2023

we can move them. Not sure what directory to park them in though. This is where inpage lives in extension for reference

https://github.com/MetaMask/metamask-extension/blob/a1fad6ab9ba50069953254ee51e4e8e65a53c3c8/app/scripts/inpage.js#L42

Hm, maybe we move them into our scripts dir?

.storybook/storybook.requires.js Outdated Show resolved Hide resolved
ios/Podfile.lock Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
@Cal-L
Copy link
Contributor

Cal-L commented Oct 18, 2023

Cal-L
Cal-L previously approved these changes Oct 18, 2023
Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

@jiexi jiexi removed the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Oct 18, 2023
@sonarqubecloud
Copy link

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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@jiexi
Copy link
Contributor Author

jiexi commented Oct 18, 2023

@SocketSecurity ignore setprototypeof@1.2.0

unmaintained

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

@jiexi jiexi merged commit bf25c3e into main Oct 18, 2023
25 checks passed
@jiexi jiexi deleted the jl/pull-in-mobile-provider branch October 18, 2023 21:21
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2023
@metamaskbot metamaskbot added the release-7.10.0 Issue or pull request that will be included in release 7.10.0 label Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.10.0 Issue or pull request that will be included in release 7.10.0 team-wallet-api-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants