Skip to content

fix(explorer): scope tip20-roles config reads to requested chainId#1101

Open
Joslis wants to merge 1 commit into
tempoxyz:mainfrom
Joslis:fix/tip20-roles-chainid
Open

fix(explorer): scope tip20-roles config reads to requested chainId#1101
Joslis wants to merge 1 commit into
tempoxyz:mainfrom
Joslis:fix/tip20-roles-chainid

Conversation

@Joslis

@Joslis Joslis commented Jun 23, 2026

Copy link
Copy Markdown

RFC: Consistent chain selection in /api/tip20-roles

1. Problem Statement

The /api/tip20-roles endpoint accepts a chainId query parameter and uses it
to scope role-membership log reads via tempoQueryBuilder(chainId). However the
TIP-20 config reads (supplyCap, currency, paused, decimals, symbol,
totalSupply, transferPolicyId) were issued through readContracts(config, …)
without a chainId, so they executed against the wagmi default chain.

When a caller supplies a non-default chainId, the response therefore mixes
config from one chain with role data from another. Separately, Number(chainIdParam)
was never validated — a value like ?chainId=abc produces NaN, which then
flows into tempoQueryBuilder(NaN).

2. Background

readContracts resolves each contract entry against its own chainId, falling
back 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

  1. Validate the chainId parameter: it must be a positive integer, otherwise
    respond 400 Invalid chainId.
  2. Thread the resolved chainId into every entry of the readContracts call so
    config reads and role-log reads target the same chain.

4. Backwards Compatibility

Requests that omit chainId are unchanged — they continue to use the wagmi
default via getChainId(config). Requests that previously passed a non-numeric
chainId now receive a 400 instead of silently degrading to NaN.

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