fix(explorer): scope tip20-roles config reads to requested chainId#1101
Open
Joslis wants to merge 1 commit into
Open
fix(explorer): scope tip20-roles config reads to requested chainId#1101Joslis wants to merge 1 commit into
Joslis wants to merge 1 commit into
Conversation
Config reads ran against the wagmi default chain while role logs used the requested chainId, producing cross-chain responses. Validate chainId and pass it to every readContracts entry.
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.
RFC: Consistent chain selection in
/api/tip20-roles1. Problem Statement
The
/api/tip20-rolesendpoint accepts achainIdquery parameter and uses itto scope role-membership log reads via
tempoQueryBuilder(chainId). However theTIP-20 config reads (
supplyCap,currency,paused,decimals,symbol,totalSupply,transferPolicyId) were issued throughreadContracts(config, …)without a
chainId, so they executed against the wagmi default chain.When a caller supplies a non-default
chainId, the response therefore mixesconfig from one chain with role data from another. Separately,
Number(chainIdParam)was never validated — a value like
?chainId=abcproducesNaN, which thenflows into
tempoQueryBuilder(NaN).2. Background
readContractsresolves each contract entry against its ownchainId, fallingback to the connected/default chain when omitted. The two data sources in this
handler (contract reads vs. indexed logs) had diverged because only one of them
was chain-aware.
3. Proposed Change
chainIdparameter: it must be a positive integer, otherwiserespond
400 Invalid chainId.chainIdinto every entry of thereadContractscall soconfig reads and role-log reads target the same chain.
4. Backwards Compatibility
Requests that omit
chainIdare unchanged — they continue to use the wagmidefault via
getChainId(config). Requests that previously passed a non-numericchainIdnow receive a400instead of silently degrading toNaN.