Skip to content

feat: add shared AssetsService to snap-networks-utils - #80

Closed
ulissesferreira wants to merge 10 commits into
WPN-1632-scaffold-snap-networks-utilsfrom
shared-assets-service
Closed

feat: add shared AssetsService to snap-networks-utils#80
ulissesferreira wants to merge 10 commits into
WPN-1632-scaffold-snap-networks-utilsfrom
shared-assets-service

Conversation

@ulissesferreira

Copy link
Copy Markdown
Contributor

Summary

  • Stacked on #79 (WPN-1632-scaffold-snap-networks-utils)
  • Ports the shared-assets-service proposal into @metamask/snap-networks-utils
  • Adds AssetsService, mapControllerAsset, toUiAmount, and Core messenger types, with an ./assets subpath export

Test plan

  • yarn workspace @metamask/snap-networks-utils run build
  • yarn workspace @metamask/snap-networks-utils run test
  • yarn constraints
  • Confirm this PR targets WPN-1632-scaffold-snap-networks-utils, not main

Port the thin Core AssetsController read layer from the shared-assets
proposal into the real shared package, stacked on WPN-1632.
@ulissesferreira
ulissesferreira requested review from a team as code owners July 31, 2026 08:41
Comment thread packages/snap-networks-utils/src/utils/toUiAmount.ts Fixed
cursoragent and others added 2 commits July 31, 2026 10:04
Move assets under services/, use scope params, return ID maps,
assert account refs, adopt with* test helpers, and fix toUiAmount
trailing-zero trimming for CodeQL.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Create mocks inside the helper, take only the callback, and use
payload / assetsService / mockCoreMessenger naming.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@ulissesferreira
ulissesferreira marked this pull request as draft July 31, 2026 10:35
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from socket-security Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from socket-security Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Jul 31, 2026
Follow Core's root-only exports pattern; AssetsService remains available
from the package root. Leave ./logger as it came from the base branch.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@socket-security

socket-security Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​metamask/​keyring-internal-api@​11.0.21001007395100
Addednpm/​@​metamask/​assets-controller@​11.2.07610080100100

View full report

@socket-security

socket-security Bot commented Jul 31, 2026

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

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

Ignoring alerts on:

  • npm/@metamask/assets-controller@11.2.0
  • npm/@metamask/core-backend@7.0.0
  • npm/@metamask/core-backend@8.0.0
  • npm/@ethersproject/providers@5.8.0
  • npm/@metamask/assets-controllers@110.0.2
  • npm/@metamask/network-controller@34.0.0
  • npm/@metamask/phishing-controller@17.3.0
  • npm/@metamask/remote-feature-flag-controller@4.2.2
  • npm/@metamask/transaction-controller@69.3.0
  • npm/@metamask/profile-sync-controller@28.3.0
  • npm/@tanstack/query-core@5.101.4
  • npm/@metamask/multichain-network-controller@3.2.1
  • npm/ethereumjs-wallet@1.0.2
  • npm/ulid@2.4.0
  • npm/@metamask/eth-json-rpc-infura@10.3.0
  • npm/@metamask/config-registry-controller@1.0.0
  • npm/keccak@3.0.4
  • npm/rlp@2.2.7
  • npm/ws@8.18.0
  • npm/@metamask/snaps-controllers@19.0.1

View full report

Comment thread packages/snap-networks-utils/src/services/assets/AssetsService.ts Outdated
Comment thread packages/snap-networks-utils/src/services/assets/index.ts Outdated
Drop the internal account ref helper, type account IDs as AccountId, move mapControllerAsset under services/assets/utils, and export from the package root without a barrel file.
@ulissesferreira

ulissesferreira commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore npm/@metamask/assets-controller@11.2.0
@SocketSecurity ignore npm/@metamask/snaps-controllers@19.0.1

These are first-party MetaMask packages. @metamask/assets-controller is an intentional direct dependency for the shared AssetsService Core messenger reads. @metamask/snaps-controllers is a transitive dependency of assets-controller.

Reorder package.json dependencies and apply formatting fixes flagged by lint:misc:check.
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore npm/@metamask/assets-controller@11.2.0
@SocketSecurity ignore npm/@metamask/snaps-controllers@19.0.1
@SocketSecurity ignore npm/@metamask/assets-controllers@110.0.2
@SocketSecurity ignore npm/@metamask/config-registry-controller@1.0.0
@SocketSecurity ignore npm/@metamask/core-backend@7.0.0
@SocketSecurity ignore npm/@metamask/core-backend@8.0.0
@SocketSecurity ignore npm/@metamask/eth-json-rpc-infura@10.3.0
@SocketSecurity ignore npm/@metamask/multichain-network-controller@3.2.1
@SocketSecurity ignore npm/@metamask/network-controller@34.0.0
@SocketSecurity ignore npm/@metamask/phishing-controller@17.3.0
@SocketSecurity ignore npm/@metamask/profile-sync-controller@28.3.0
@SocketSecurity ignore npm/@metamask/remote-feature-flag-controller@4.2.2
@SocketSecurity ignore npm/@metamask/transaction-controller@69.3.0
@SocketSecurity ignore npm/@ethersproject/providers@5.8.0
@SocketSecurity ignore npm/@tanstack/query-core@5.101.4
@SocketSecurity ignore npm/keccak@3.0.4
@SocketSecurity ignore npm/ethereumjs-wallet@1.0.2
@SocketSecurity ignore npm/rlp@2.2.7
@SocketSecurity ignore npm/ulid@2.4.0
@SocketSecurity ignore npm/ws@8.18.0

Reviewed transitive tree introduced by intentional @metamask/assets-controller dependency for shared AssetsService types and Core messenger reads. All @metamask/* packages are first-party Core controllers. Remaining alerts are standard Ethereum/third-party transitive deps; ethereumjs-wallet deprecation is upstream of assets-controller.

Rename getAccountAssets to getAccountAssetsByScope with a required chain
filter, update tests accordingly, and align tsconfig Jest types setup.
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

Head branch renamed to WPN-1784-shared-assets-service; continued in #82.

cursor Bot pushed a commit that referenced this pull request Jul 31, 2026
jeremytsng pushed a commit that referenced this pull request Aug 5, 2026
## 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?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

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

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants