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

bump @metamask/assets-controllers to ^13.0.0 #20916

Merged
merged 34 commits into from
Oct 3, 2023

Conversation

jiexi
Copy link
Contributor

@jiexi jiexi commented Sep 15, 2023

Explanation

Needed to help get us closer to phasing out a single globally selected network.

Bumps @metamask/assets-controllers to ^13.0.0 and passes networkClientId arg to newly updated TokenController.addToken(), TokenController.addTokens(), and TokenController.watchAsset(). Adopts changes in other asset-related controllers

Screenshots/Screencaps

None. Should be no changes apparent to user.

Manual Testing Steps

Via Dapp API

  • Visit any coingecko token page
    • On a supported built-in network (switch to mainnet)
  • Click the metamask icon on the page
    • Tooltip says: "Add to MetaMask"
  • Accept
  • Verify the token shows up in wallet UI

Via Wallet UI

  • From wallet ui
  • Import new token
  • Fill in token details
    • Use 0xc18360217d8f7ab5e7c516566761ea12ce7f9d72 contract address for ENS
  • Verify the token shows up in wallet UI

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@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/mmp 1020/multichain v1 tokens controller Spike: multichain v1 tokens controller Sep 15, 2023
@jiexi jiexi changed the title Spike: multichain v1 tokens controller Spike: Multichain v1 TokensController Sep 15, 2023
@jiexi jiexi changed the title Spike: Multichain v1 TokensController wallet_watchAsset ERC-20 use networkClientId from request Sep 20, 2023
package.json Outdated Show resolved Hide resolved
jiexi added a commit to MetaMask/core that referenced this pull request Sep 22, 2023
Currently, TokenController only uses the global selected provider. We
want to see how it feels making this controller consume any network
provider the NetworkController may have available. We do this by
extending the `addToken()` interface with an optional `networkClientId`
param, but continuing to use the provider proxy as a fallback.

~~TODO: specs have not been updated to test the networkClientId case~~
added


* Fixes MetaMask/MetaMask-planning#1020
* See MetaMask/metamask-extension#20916

## Explanation

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

## References

<!--
Are there any issues that this pull request is tied to? Are there other
links that reviewers should consult to understand these changes better?

For example:

* Fixes #12345
* Related to #67890
-->

## Changelog

<!--
If you're making any consumer-facing changes, list those changes here as
if you were updating a changelog, using the template below as a guide.

(CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or
FIXED. For security-related issues, follow the Security Advisory
process.)

Please take care to name the exact pieces of the API you've added or
changed (e.g. types, interfaces, functions, or methods).

If there are any breaking changes, make sure to offer a solution for
consumers to follow once they upgrade to the changes.

Finally, if you're only making changes to development scripts or tests,
you may replace the template below with "None".
-->

### `@metamask/assets-controllers`

- **BREAKING**: `TokensController` now expects `getNetworkClientById` in
constructor options
- **BREAKING**: `TokensController. addToken()` now accepts a single
options object
  ```
    {
      address: string;
      symbol: string;
      decimals: number;
      name?: string;
      image?: string;
      interactingAddress?: string;
      networkClientId?: NetworkClientId;
    }
  ```  
- **CHANGED**: `TokensController. addToken()` will use the chain ID
value derived from state for `networkClientId` if provided
- **CHANGED**: `TokensController. addTokens()` now accepts an optional
`networkClientId` as the last parameter
- **CHANGED**: `TokensController. addTokens()` will use the chain ID
value derived from state for `networkClientId` if provided
- **CHANGED**: `TokensController. watchAsset()` options now accepts
optional `networkClientId` which is used to get the ERC-20 token name if
provided

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
@socket-security
Copy link

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@metamask/assets-controllers 9.2.0...13.0.0 None +1/-2 870 kB metamaskbot

@jiexi
Copy link
Contributor Author

jiexi commented Sep 26, 2023

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@jiexi jiexi marked this pull request as ready for review September 26, 2023 23:16
@jiexi jiexi requested review from a team as code owners September 26, 2023 23:16
@metamaskbot
Copy link
Collaborator

Builds ready [38512df]
Page Load Metrics (1077 ± 428 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint89147114178
domContentLoaded69139103178
load8523291077891428
domInteractive69139103178
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -62.87 KiB (-1.68%)
  • ui: 365 Bytes (0.00%)
  • common: 81.52 KiB (1.75%)

@metamaskbot
Copy link
Collaborator

Builds ready [eaf661f]
Page Load Metrics (802 ± 448 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint801711242612
domContentLoaded751491132411
load862402802933448
domInteractive751491122411
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -62.87 KiB (-1.68%)
  • ui: 365 Bytes (0.00%)
  • common: 81.52 KiB (1.75%)

@codecov
Copy link

codecov bot commented Sep 27, 2023

Codecov Report

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

Comparison is base (0139b99) 68.58% compared to head (d773e0c) 68.58%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #20916   +/-   ##
========================================
  Coverage    68.58%   68.58%           
========================================
  Files         1013     1013           
  Lines        40614    40615    +1     
  Branches     10854    10858    +4     
========================================
+ Hits         27854    27855    +1     
  Misses       12760    12760           
Files Coverage Δ
.../lib/rpc-method-middleware/handlers/watch-asset.js 87.50% <100.00%> (+9.72%) ⬆️
ui/components/app/nfts-items/nfts-items.js 93.42% <100.00%> (ø)
ui/components/app/detected-token/detected-token.js 46.03% <50.00%> (+0.87%) ⬆️
...tichain/import-tokens-modal/import-tokens-modal.js 66.24% <50.00%> (+0.14%) ⬆️
ui/ducks/swaps/swaps.js 41.03% <0.00%> (-0.08%) ⬇️
ui/store/actions.ts 43.36% <0.00%> (+0.12%) ⬆️
app/scripts/metamask-controller.js 53.85% <76.47%> (-0.17%) ⬇️

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

@metamaskbot
Copy link
Collaborator

Builds ready [5557313]
Page Load Metrics (1236 ± 361 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint84154108189
domContentLoaded72143101199
load8620071236752361
domInteractive72143101199
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -62.87 KiB (-1.68%)
  • ui: 365 Bytes (0.00%)
  • common: 81.52 KiB (1.74%)

@metamaskbot
Copy link
Collaborator

Builds ready [d773e0c]
Page Load Metrics (963 ± 373 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint85134103157
domContentLoaded7112798157
load851754963777373
domInteractive7112798157
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -62.87 KiB (-1.71%)
  • ui: 365 Bytes (0.00%)
  • common: 81.5 KiB (1.72%)

@brad-decker brad-decker mentioned this pull request Oct 3, 2023
14 tasks
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM

@adonesky1 adonesky1 merged commit f814c41 into develop Oct 3, 2023
64 checks passed
@adonesky1 adonesky1 deleted the jl/mmp-1020/multichain-v1-tokens-controller branch October 3, 2023 20:09
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2023
@metamaskbot metamaskbot added the release-11.4.0 Issue or pull request that will be included in release 11.4.0 label Oct 3, 2023
jiexi added a commit that referenced this pull request Oct 4, 2023
…1197)

Fixes bug with TokensRateController no longer starting automatically on
instantiation and requiring explicit `start()` to be called. Also
replaces `configure({disabled})` with `start()` or `stop()`

## **Manual testing steps**

* Open wallet
* Check privacy settings to ensure price conversion is enabled
* Restart wallet
* Click send
* Select ERC-20 token
* Enter some amount
* See that there is a conversion amount
* Visit privacy settings and disable price conversion
* Click send
* Select ERC-20 token
* Enter some amount
* See that there is NO conversion amount


## **Screenshots/Recordings**

_If applicable, add screenshots and/or recordings to visualize the
before and after of your change._

### **Before**


![image](https://github.com/MetaMask/metamask-extension/assets/918701/e595db79-276c-409e-894a-ae1dc5ce56cd)

### **After**

![Screenshot 2023-10-04 at 2 46 38
PM](https://github.com/MetaMask/metamask-extension/assets/918701/0c46e5bb-3dfb-4186-973d-e0f81ff2dd2f)


## **Related issues**

Fixes #20916

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained:
  - [x] What problem this PR is solving.
  - [x] How this problem was solved.
  - [x] How reviewers can test my changes.
- [x] I’ve indicated what issue this PR is linked to: Fixes #???
- [ ] I’ve included tests if applicable.
- [ ] I’ve documented any added code.
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
- [x] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [x] 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.
k-g-j pushed a commit that referenced this pull request Nov 1, 2023
…1197)

Fixes bug with TokensRateController no longer starting automatically on
instantiation and requiring explicit `start()` to be called. Also
replaces `configure({disabled})` with `start()` or `stop()`

## **Manual testing steps**

* Open wallet
* Check privacy settings to ensure price conversion is enabled
* Restart wallet
* Click send
* Select ERC-20 token
* Enter some amount
* See that there is a conversion amount
* Visit privacy settings and disable price conversion
* Click send
* Select ERC-20 token
* Enter some amount
* See that there is NO conversion amount


## **Screenshots/Recordings**

_If applicable, add screenshots and/or recordings to visualize the
before and after of your change._

### **Before**


![image](https://github.com/MetaMask/metamask-extension/assets/918701/e595db79-276c-409e-894a-ae1dc5ce56cd)

### **After**

![Screenshot 2023-10-04 at 2 46 38
PM](https://github.com/MetaMask/metamask-extension/assets/918701/0c46e5bb-3dfb-4186-973d-e0f81ff2dd2f)


## **Related issues**

Fixes #20916

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained:
  - [x] What problem this PR is solving.
  - [x] How this problem was solved.
  - [x] How reviewers can test my changes.
- [x] I’ve indicated what issue this PR is linked to: Fixes #???
- [ ] I’ve included tests if applicable.
- [ ] I’ve documented any added code.
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
- [x] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [x] 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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-11.4.0 Issue or pull request that will be included in release 11.4.0 team-wallet-api-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants