Skip to content

refactor(tron-wallet-snap): extract SnapAssetsAdapter from existing AssetsService logic - #91

Merged
ulissesferreira merged 8 commits into
mainfrom
WPN-1497-snap-adapter
Aug 4, 2026
Merged

refactor(tron-wallet-snap): extract SnapAssetsAdapter from existing AssetsService logic#91
ulissesferreira merged 8 commits into
mainfrom
WPN-1497-snap-adapter

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract legacy assets logic into adapters/SnapAssetsAdapter.ts
  • Replace AssetsService with a thin facade that delegates all public methods to the snap adapter

Jira

Test plan

  • yarn workspace @metamask/tron-wallet-snap build
  • yarn workspace @metamask/tron-wallet-snap run test

Stacks on #90 (Step 2/3).

Comment thread packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.ts Dismissed
Comment thread packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.ts Dismissed
Comment thread packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.ts Dismissed
Comment thread packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.ts Dismissed
Comment thread packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.ts Dismissed
@ulissesferreira ulissesferreira changed the title refactor(tron-wallet-snap): extract SnapAssetsAdapter behind AssetsService (WPN-1497) refactor(tron-wallet-snap): extract SnapAssetsAdapter from existing AssetsService logic Jul 31, 2026
@ulissesferreira
ulissesferreira requested a review from a team as a code owner July 31, 2026 22:01
@ulissesferreira
ulissesferreira marked this pull request as draft August 2, 2026 17:39
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-handlers-and-renames branch from 2960d5a to 414cba1 Compare August 2, 2026 20:48
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-snap-adapter branch 2 times, most recently from 8b77a78 to 30a99f6 Compare August 2, 2026 23:20
@ulissesferreira
ulissesferreira force-pushed the WPN-1497-handlers-and-renames branch from 414cba1 to 0e17e41 Compare August 2, 2026 23:20
Base automatically changed from WPN-1497-handlers-and-renames to main August 3, 2026 14:53
@ulissesferreira
ulissesferreira marked this pull request as ready for review August 3, 2026 15:06
@cursor
cursor Bot force-pushed the WPN-1497-snap-adapter branch from 30a99f6 to 4e73383 Compare August 3, 2026 15:09
@MetaMask MetaMask deleted a comment from cursor Bot Aug 4, 2026
@MetaMask MetaMask deleted a comment from cursor Bot Aug 4, 2026
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

@cursoragent rebase with latest main

@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Rebased onto latest main and fixed the follow-up CI issue.

Rebase

  • Rebased WPN-1497-snap-adapter onto origin/main (27aa57bc — feat: tron v2 feat: tron v2 #56)
  • Resolved conflicts in packages/tron-wallet-snap/snap.manifest.json during rebase
  • Force-pushed the rebased branch

Shasum fix

After the rebase, CI failed on the manifest shasum (same issue as before — Linux CI uses secret mainnet RPC URLs). Updated to the CI-expected value:

d+4EA5VWJknz8ahgtwMFrhFIp/RohdmBbKWZmc5IeYo=

Verification

  • yarn lint — passed
  • yarn workspace @metamask/tron-wallet-snap run test — passed

PR #91: #91

Open in Web Open in Cursor 

@cursor
cursor Bot force-pushed the WPN-1497-snap-adapter branch from a6cbab4 to e34f69c Compare August 4, 2026 07:44
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

@cursoragent rebase latest main resolving conflicts, lint and update shasum

@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Rebased onto latest main, resolved conflicts, linted, and updated the manifest shasum.

Rebase

Shasum

Linux CI uses secret mainnet RPC URLs, so the local shasum (SNtdYF0JkH5ubXZTB4QQnEow8OrOwBBAeXEr7YDtWxA=) did not match CI. Updated to the CI-expected value from the failed build job:

TEEXgH0mFwQ1x70iGzw0kNN7P/lPzIiLa+ATCM2v/vY=

Verification

  • yarn lint — passed
  • yarn workspace @metamask/tron-wallet-snap run test — passed
  • CI — build, lint, and all test jobs green (including tron-wallet-snap on Node 20.x and 22.x)

PR #91: #91

Open in Web Open in Cursor 

@cursor
cursor Bot force-pushed the WPN-1497-snap-adapter branch from da939f6 to cb7a717 Compare August 4, 2026 10:12
@gabrieledm

Copy link
Copy Markdown
Contributor

Few comments:

  • Are we sure about to discard the comments from github-advanced-security with WONT_FIX ?
  • Are we sure the file packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.test.ts is not needed ?
    • Or is it planned to add iit in another PR ?

@ulissesferreira

Copy link
Copy Markdown
Contributor Author

Few comments:

* Are we sure about to discard the comments from `github-advanced-security` with `WONT_FIX` ?

* Are we sure the file `packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.test.ts` is not needed ?
  
  * Or is it planned to add iit in another PR ?

github-advanced-security > yes because the code is already existing one and we want minimal changes during the migration to the new logic. I guess we only got notified of them because it was detected as changes. But we want to move as little as possible.

packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.test.ts - hmmm I see what you mean, it's kinda useless right? Well it will be changes in one of the follow up PRs

@gabrieledm

Copy link
Copy Markdown
Contributor

github-advanced-security > yes because the code is already existing one and we want minimal changes during the migration to the new logic. I guess we only got notified of them because it was detected as changes. But we want to move as little as possible.

packages/tron-wallet-snap/src/services/assets/adapters/SnapAssetsAdapter.test.ts - hmmm I see what you mean, it's kinda useless right? Well it will be changes in one of the follow up PRs

Makes sense.
Happy to give a review for the additional PRs

gabrieledm
gabrieledm previously approved these changes Aug 4, 2026
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

@cursoragent rebase with latest main, make sure lint is good and then babysit the PR until green

@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Rebased onto latest main, lint passed, and CI is green on PR #91.

Rebase

Lint & tests

  • yarn lint — passed
  • yarn workspace @metamask/tron-wallet-snap run test — passed

Shasum

Linux CI uses secret mainnet RPC URLs, so the local value did not match. Updated to the CI-expected value:

uocZF1RsEzCWGmRM3X3mMv42laNfJWpwVXOfNViikl8=

CI status — green

All 49 checks passed (0 failed), including:

  • Build (24.x)
  • All lint jobs
  • All test jobs (bitcoin, solana, snap-networks-utils, tron-wallet-snap on Node 20.x and 22.x)
  • Security scans (CodeQL, Semgrep, zizmor)
  • Main / All jobs pass (required)

PR is mergeable (mergeable: true). mergeable_state: blocked is likely from review/approval requirements, not CI.

PR #91: #91

Open in Web Open in Cursor 

ulissesferreira and others added 7 commits August 4, 2026 16:22
…rvice

Move existing assets logic into SnapAssetsAdapter and keep AssetsService as a
thin facade that always delegates to the Snap adapter. Behavior unchanged;
prepares for a later Core adapter / feature-flag routing PR.
Adapter lives one directory deeper than AssetsService; bump client,
constants, and types imports to ../../../ and ../types respectively.
Update the manifest shasum, cover AssetsService facade delegation in tests,
and use SnapAssetsAdapter.isFiat inside the adapter implementation.
Move import suppressions to SnapAssetsAdapter and align test assertions
with jest prefer-strict-equal rules.
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@cursor
cursor Bot force-pushed the WPN-1497-snap-adapter branch from a122613 to 772082a Compare August 4, 2026 16:23
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@ulissesferreira
ulissesferreira added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit be07f23 Aug 4, 2026
49 checks passed
@ulissesferreira
ulissesferreira deleted the WPN-1497-snap-adapter branch August 4, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants