fix: guard token aggregator against duplicate chainId (#14 review)#17
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a duplicate-
chainIdguard tobuildTokensFromData(src/tokens/index.ts).Why
Addresses the Copilot review comment on #14 (the tokens-aggregator refactor). That refactor moved aggregation to
PER_CHAINbut dropped the prior duplicate protection: if the samechainIdwere listed twice inPER_CHAIN(a copy-paste in the array, or two chain modules reporting the samechainId), the flatten would silently overwrite the first chain's entries and produce a wrongTokens.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
patchchangeset.tsc --noEmitclean; 60 tests pass.🤖 Generated with Claude Code