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