Skip to content

fix: replace computed Network enum initialisers with string literals - #101

Merged
hmalik88 merged 4 commits into
mainfrom
hm/fix-tron-v2
Aug 4, 2026
Merged

fix: replace computed Network enum initialisers with string literals#101
hmalik88 merged 4 commits into
mainfrom
hm/fix-tron-v2

Conversation

@hmalik88

@hmalik88 hmalik88 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Explanation

  • Network enum members were initialised from TrxScope.Mainnet / .Nile / .Shasta (a regular, non-const enum). TypeScript compiles any enum with computed initialisers using the bidirectional numeric-enum pattern, so Object.values(Network) returned 6 values: the 3 CAIP-2 scope IDs plus their reverse-mapped human-readable names ("Mainnet", "Nile", "Shasta").
  • bip44:discover iterates Object.values(Network) to check on-chain activity on every scope. When it reached "Mainnet", checkAddressActivity called getTransactionInfoByAddress("Mainnet", addr), which threw "No client configured for network: Mainnet", causing Promise.all to reject and every discovery attempt to silently return [].
  • Fix: replace the three enum initialisers with their string literal values. TypeScript emits a one-way map for string-literal enums, so Object.values(Network) now returns only the 3 scope IDs.

Test plan

  • yarn workspace @metamask/tron-wallet-snap run build — no type errors
  • yarn workspace @metamask/tron-wallet-snap run test — all tests pass
  • After publishing a new preview, re-enable the skipped discovers Tron accounts through Account 5 e2e test in metamask-extension and confirm it passes

References

N/A

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@hmalik88
hmalik88 marked this pull request as ready for review August 4, 2026 04:03
@hmalik88
hmalik88 requested a review from a team as a code owner August 4, 2026 04:03
@hmalik88

hmalik88 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@2.0.0-preview-f24e2ee
@metamask-previews/snap-networks-utils@0.0.0-preview-f24e2ee
@metamask-previews/tron-wallet-snap@2.0.0-preview-f24e2ee

@ccharly ccharly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should really ban enum 🥹

@hmalik88
hmalik88 enabled auto-merge August 4, 2026 09:25
@hmalik88
hmalik88 added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit b144065 Aug 4, 2026
50 checks passed
@hmalik88
hmalik88 deleted the hm/fix-tron-v2 branch August 4, 2026 09:42
@ulissesferreira ulissesferreira mentioned this pull request Aug 5, 2026
4 tasks
jeremytsng pushed a commit that referenced this pull request Aug 5, 2026
## Explanation

This PR introduces transaction-history synchronization and richer
Horizon-derived transaction mapping for the Stellar snap, including
decoding result_xdr for more accurate path-payment (swap/receive)
amounts and persisting per-account scan cursors.

<!--
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