poa-app: per-chain contract config + generalized checkNetwork (#517)#69
Open
ClawDAOBot wants to merge 1 commit into
Open
poa-app: per-chain contract config + generalized checkNetwork (#517)#69ClawDAOBot wants to merge 1 commit into
ClawDAOBot wants to merge 1 commit into
Conversation
Resolves task #517 (the architectural blockers documented in PR poa-box#68's description). Three coordinated changes: src/util/networks.js (new): - CONTRACT_ADDRESSES_BY_CHAIN_ID map keyed on chainId - getContractAddress(name, chainId) with polygonAmoy fallback for backward compat - isSupportedChain(chainId) for network-gate checks - SUPPORTED_CHAIN_IDS exported for any UI that wants to surface the list (e.g. NetworkModalControl). - Only polygonAmoy has AccountManager wired today; other chains have empty entries so callers see an explicit console.warn instead of silent fallback. src/context/web3Context.js: - AccountManagerAddress = getContractAddress('AccountManager', chainId) instead of the hardcoded polygonAmoy literal. - checkNetwork() now uses isSupportedChain(chainId) instead of the hardcoded `chainId !== 80002` gate. Users on Arb / Gnosis no longer immediately get the wrong-network modal; the gate fails only on chains we haven't enumerated yet. src/pages/_app.js: - wagmi chains list expanded to include arbitrum + gnosis. polygonAmoy stays as initialChain (it's the only chain with deployed AccountManager today). RainbowKit now surfaces Arb / Gnosis as options so a wallet can connect there for read-side browsing via the chainId-aware subgraph routing from PR poa-box#68. Pairs with PR poa-box#68 (apolloClient chainId routing) which is independent on disk — both can land in either order. Together they close the read path: subgraph queries route per chain (poa-box#68) + write actions resolve chain-correct contract addresses (this). Acceptance: existing polygonAmoy deploys are unaffected (fallback path); a user wallet-switched to Gnosis or Arb is no longer hard-failed by checkNetwork. Full write-side support on those chains still requires deploying AccountManager + other contracts to them (separate ops work, not in scope for #517's code refactor). Co-Authored-By: Claude Opus 4.7 (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.
Summary
Resolves task #517 — the two architectural blockers PR #68 documented as out-of-scope for path A. Together with #68 (chainId-aware subgraph routing), this closes the read path for a wallet connected on Arbitrum or Gnosis: subgraph queries route per chain (#68) + write actions resolve chain-correct contract addresses (this PR).
What changed
poa-app/src/util/networks.js(new, 53 LoC)CONTRACT_ADDRESSES_BY_CHAIN_IDkeyed on EIP-155 chainIdgetContractAddress(name, chainId)with polygonAmoy fallbackisSupportedChain(chainId)for network-gate checksSUPPORTED_CHAIN_IDSexported for any UI that surfaces the listOnly polygonAmoy has AccountManager deployed today; other chains have empty entries so callers get an explicit
console.warninstead of silent fallback.poa-app/src/context/web3Context.jsAccountManagerAddressnow reads fromgetContractAddress('AccountManager', chainId)instead of the hardcoded polygonAmoy literal at the old line 53.checkNetwork()usesisSupportedChain(chainId)instead of the hardcodedchainId !== 80002gate at the old line 60. Users on Arb / Gnosis no longer immediately get the wrong-network modal.poa-app/src/pages/_app.js[polygonAmoy, polygon, sepolia, arbitrum, gnosis]initialChain(only chain with deployed AccountManager today)Relationship to PR #68
PR #68 (#460 path A — chainId-aware Apollo provider) is independent on disk; the file sets don't overlap. Either PR can land first. Together they form the read-path-multi-chain pair.
What this PR does NOT do (deliberate out-of-scope)
Acceptance check
The original #517 acceptance asked: "viewing an Arb org renders Arb data via the subgraph; user can wallet-switch to either chain via RainbowKit; contract write actions on the connected chain succeed (or fail with a meaningful 'chain not supported' message rather than a hard polygonAmoy gate)."
With this PR + PR #68:
checkNetwork()reports cleanly per supported-chain list: works (no more hardcoded 80002)Full Arb / Gnosis write support requires deploying the contract suite + populating
CONTRACT_ADDRESSES_BY_CHAIN_ID[chainId]with the resulting addresses. That's a separate ops task.Test plan
NEXT_PUBLIC_SUBGRAPH_URLonly set — verify polygonAmoy flow unchangedcheckNetwork()does NOT immediately open the wrong-network modal; verify subgraph read-side works (requires PR poa-app: chainId-aware subgraph routing (path A for #460) #68 also merged +NEXT_PUBLIC_GNOSIS_SUBGRAPH_URLenv var)🤖 Generated with Claude Code