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

feat(ramps): introduces dynamic support for rampable networks #24041

Open
wants to merge 53 commits into
base: develop
Choose a base branch
from

Conversation

georgeweiler
Copy link
Contributor

@georgeweiler georgeweiler commented Apr 16, 2024

Description

This PR introduces a new reducer for Ramps to store an array of "buyable" networks. A "buyable chain" is one that the native token has onramp support for. This BUYABLE_CHAINS_MAP list is currently hard-coded, and this PR fetches a dynamic network list from the Ramps API instead. The list of supported networks by the MetMask onramp team is dynamic and is based on provider support among other things.

There are several fallback protections in place. Buyable chains will default to the current hard-coded list before loading and will default to that same list if there are any errors. There is no need for loading or error states.

The ramps base API url has been added as a new environment variable, defaulted to production. example: METAMASK_RAMP_API_BASE_URL=https://on-ramp-content.metaswap.codefi.network

Here's screenshot to show the issue this PR will fix. Base network is supported as a buyable network. but because the hard-coded array of networks does not include base we do not enable the buy CTAs:

image

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Video Description of the changes in the PR (5 min)
https://www.loom.com/share/973960816e7e497aae51ed1cdc3cebf5

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

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.

@georgeweiler georgeweiler requested review from a team as code owners April 16, 2024 00:49
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.

@metamaskbot
Copy link
Collaborator

Builds ready [7c4ba77]
Page Load Metrics (879 ± 575 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint861591152512
domContentLoaded127629189
load7231068791198575
domInteractive127629189
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 5.45 KiB (0.09%)
  • common: -1014 Bytes (-0.02%)

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.43%. Comparing base (43eac4b) to head (53606d7).

Current head 53606d7 differs from pull request most recent head 4cb8b13

Please upload reports for the commit 4cb8b13 to get more accurate results.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #24041      +/-   ##
===========================================
+ Coverage    67.40%   67.43%   +0.04%     
===========================================
  Files         1289     1292       +3     
  Lines        50248    50269      +21     
  Branches     13011    13019       +8     
===========================================
+ Hits         33865    33897      +32     
+ Misses       16383    16372      -11     

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

@metamaskbot
Copy link
Collaborator

Builds ready [7fe1f84]
Page Load Metrics (352 ± 384 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint641851073517
domContentLoaded96726189
load483032352799384
domInteractive96726189
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 5.45 KiB (0.09%)
  • common: -1014 Bytes (-0.02%)

@metamaskbot
Copy link
Collaborator

Builds ready [91521fc]
Page Load Metrics (491 ± 459 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint673621348641
domContentLoaded107231209
load543055491955459
domInteractive107231209
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 5.62 KiB (0.09%)
  • common: -1014 Bytes (-0.02%)

@bkirb
Copy link

bkirb commented Apr 18, 2024

LGTM for QA, I tested with Base and other networks ✅
Screenshot 2024-04-18 at 6 11 18 AM
Screenshot 2024-04-18 at 6 12 50 AM

builds.yml Outdated Show resolved Hide resolved
ui/ducks/ramps/types.ts Outdated Show resolved Hide resolved
ui/ducks/ramps/ramps.ts Outdated Show resolved Hide resolved
wachunei
wachunei previously approved these changes May 16, 2024
nikoferro
nikoferro previously approved these changes May 16, 2024
@wachunei
Copy link
Member

I’m okay with the approach of requiring all selectors and mocking only some of them, but there must be a reason why originally this was not done this way, if no one from extension team raises a concern, then we can just merge.

@danjm
Copy link
Contributor

danjm commented May 17, 2024

@georgeweiler @pedronfigueiredo @nikoferro I am okay with the use of "requireActual" as done in this PR. We do already use it in some other places. The reasons for not using it would be to have greater control, and visibility into that control, of the state and related dependencies. If we mock only what we need, and everything that we need, it becomes clear that the component unit test is only testing the component. But I don't think it is a strict requirement to do that.

Maybe we should establish clearer and stricter guidelines, but as we don't have them, I think what is in this PR is fine.

With that said, I don't think the usage of requireActual in question in this PR is necessary. Here is a PR I created against this branch that shows the unit tests passing without the instances of requireActual #24589

I would say, at least, that you can remove the instances in the routes component test, which seems to be unnecessary

@georgeweiler georgeweiler dismissed stale reviews from nikoferro and wachunei via 8862e20 May 17, 2024 16:21
@metamaskbot
Copy link
Collaborator

Builds ready [53606d7]
Page Load Metrics (829 ± 501 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint62166922512
domContentLoaded96416147
load5125388291043501
domInteractive96416147
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 6.58 KiB (0.10%)
  • common: -1007 Bytes (-0.02%)

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

This is an approval of the privacy-snapshot changes

@legobeat

This comment was marked as resolved.

@metamaskbot
Copy link
Collaborator

Builds ready [4cb8b13]
Page Load Metrics (165 ± 217 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint651057484
domContentLoaded9391163
load532139165453217
domInteractive9391163
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 6.58 KiB (0.10%)
  • common: -1007 Bytes (-0.02%)

@danjm danjm mentioned this pull request May 21, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [a9cfbf2]
Page Load Metrics (399 ± 366 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint62176962814
domContentLoaded1065242110
load512287399763366
domInteractive1065242110
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 6.58 KiB (0.10%)
  • common: -1007 Bytes (-0.02%)

Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

I reviewed files owned by confirmations team, changes look good 👍

@wachunei
Copy link
Member

Hey @MetaMask/confirmations-system-team, your review is the last one missing to merge this PR please 🙏

@metamaskbot
Copy link
Collaborator

Builds ready [d75e639]
Page Load Metrics (180 ± 221 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint59244914120
domContentLoaded9150193115
load472184180461221
domInteractive9150193115
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 0 Bytes (0.00%)
  • ui: 6.58 KiB (0.10%)
  • common: -1007 Bytes (-0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review finalised - Ready to be merged
Development

Successfully merging this pull request may close these issues.

None yet

8 participants