Skip to content

fix: guard token aggregator against duplicate chainId (#14 review)#17

Merged
chrisli30 merged 1 commit into
mainfrom
fix/tokens-duplicate-chainid-guard
Jun 9, 2026
Merged

fix: guard token aggregator against duplicate chainId (#14 review)#17
chrisli30 merged 1 commit into
mainfrom
fix/tokens-duplicate-chainid-guard

Conversation

@chrisli30

Copy link
Copy Markdown
Member

What

Adds a duplicate-chainId guard to buildTokensFromData (src/tokens/index.ts).

Why

Addresses the Copilot review comment on #14 (the tokens-aggregator refactor). That refactor moved aggregation to PER_CHAIN but dropped the prior duplicate protection: if the same chainId were listed twice in PER_CHAIN (a copy-paste in the array, or two chain modules reporting the same chainId), the flatten would silently overwrite the first chain's entries and produce a wrong Tokens.SYMBOL[chainId] map with no error at module load.

It now throws fast, pointing at the duplicate chain — a one-off startup error instead of silent data corruption.

Notes

  • Internal hardening, no API change → patch changeset.
  • tsc --noEmit clean; 60 tests pass.

🤖 Generated with Claude Code

Addresses Copilot review on #14: the tokens-aggregator refactor dropped
duplicate protection, so a chain listed twice in PER_CHAIN would silently
overwrite the first chain's entries (wrong Tokens.SYMBOL[chainId], no
error at module load). Now throws fast pointing at the duplicate. Patch
changeset; no API change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chrisli30 chrisli30 merged commit 0124250 into main Jun 9, 2026
6 checks passed
@chrisli30 chrisli30 deleted the fix/tokens-duplicate-chainid-guard branch June 9, 2026 01:52
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.

1 participant