Fix: Override StudioNet consensus address to prevent 0x0...0 routing#141
Fix: Override StudioNet consensus address to prevent 0x0...0 routing#141ngh1105 wants to merge 1 commit intogenlayerlabs:mainfrom
Conversation
📝 WalkthroughWalkthroughThe pull request introduces a conditional override in the chain actions logic that, when the chain is studionet, sets the consensusMainContract address to a hard-coded value, bypassing an associated warning. The change is localized and does not affect public API signatures. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/chains/actions.ts (2)
55-58: Make StudioNet override a zero-address fallback and avoid duplicated address literals.The current logic overwrites any StudioNet RPC address unconditionally. That can hide future contract rotations and route to a stale address. Prefer overriding only when RPC returns the zero address, and source fallback from
studionet.consensusMainContract.address.🛠️ Suggested update
- // --- LexNet Hack: Force the transaction destination to bypass MetaMaks 0x0...0 warning + // StudioNet fallback: override only when RPC returns the zero address. if (client.chain?.id === studionet.id) { - consensusMainContract.result.address = "0xb7278A61aa25c888815aFC32Ad3cC52fF24fE575"; + const rpcAddress = consensusMainContract.result.address?.toLowerCase(); + const isZeroAddress = + rpcAddress === "0x0000000000000000000000000000000000000000"; + const fallbackAddress = studionet.consensusMainContract?.address; + if (isZeroAddress && fallbackAddress) { + consensusMainContract.result.address = fallbackAddress; + } }Based on learnings: Applies to
**/*chain*.{ts,tsx}: Extend viem'sChaintype with GenLayer-specific properties includingconsensusMainContract.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/chains/actions.ts` around lines 55 - 58, Currently the code unconditionally sets consensusMainContract.result.address to a hard-coded literal when client.chain?.id === studionet.id; instead change the logic to only override when the RPC returned the zero address (e.g., "0x0000000000000000000000000000000000000000") and otherwise leave the RPC value intact, and when overriding use the canonical fallback value studionet.consensusMainContract.address rather than repeating the literal; update the block referencing client.chain?.id, studionet.id, and consensusMainContract.result.address to perform a zero-address check and assign studionet.consensusMainContract.address only in that case.
1-4: Use@/*aliases for internalsrcimports.Lines 2-4 currently use relative imports in a
srcTypeScript file. Please switch these to the configured path alias style.♻️ Suggested update
import { GenLayerClient, GenLayerChain } from "@/types"; -import { localnet } from "./localnet"; -import { studionet } from "./studionet"; -import { testnetAsimov } from "./testnetAsimov"; +import { localnet } from "@/chains/localnet"; +import { studionet } from "@/chains/studionet"; +import { testnetAsimov } from "@/chains/testnetAsimov";As per coding guidelines
**/*.{ts,tsx}: Use path alias@/*to reference./src/*and@@/tests/*to reference./tests/*.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/chains/actions.ts` around lines 1 - 4, Replace the relative imports at the top of the file by switching to the project path alias: change the import statements that reference localnet, studionet and testnetAsimov to use "@/…" style (e.g., import { localnet } from "@/chains/localnet";) so the symbols localnet, studionet and testnetAsimov are imported via the `@/`* alias instead of relative paths; update the import lines in the module that defines GenLayerClient/GenLayerChain accordingly and ensure TypeScript resolves the new aliases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/chains/actions.ts`:
- Around line 55-58: Currently the code unconditionally sets
consensusMainContract.result.address to a hard-coded literal when
client.chain?.id === studionet.id; instead change the logic to only override
when the RPC returned the zero address (e.g.,
"0x0000000000000000000000000000000000000000") and otherwise leave the RPC value
intact, and when overriding use the canonical fallback value
studionet.consensusMainContract.address rather than repeating the literal;
update the block referencing client.chain?.id, studionet.id, and
consensusMainContract.result.address to perform a zero-address check and assign
studionet.consensusMainContract.address only in that case.
- Around line 1-4: Replace the relative imports at the top of the file by
switching to the project path alias: change the import statements that reference
localnet, studionet and testnetAsimov to use "@/…" style (e.g., import {
localnet } from "@/chains/localnet";) so the symbols localnet, studionet and
testnetAsimov are imported via the `@/`* alias instead of relative paths; update
the import lines in the module that defines GenLayerClient/GenLayerChain
accordingly and ensure TypeScript resolves the new aliases.
Fixes # (Leave blank if there is no linked issue)
WHAT TO PUT IN "What"
WHAT TO PUT IN "Why"
WHAT TO PUT IN "Testing done"
WHAT TO PUT IN "Decisions made"
WHAT TO PUT IN "Checks"
[x] I have tested this code
[x] I have reviewed my own PR
[ ] I have created an issue for this PR
[x] I have set a descriptive PR title compliant with conventional commits
WHAT TO PUT IN "Reviewing tips"
WHAT TO PUT IN "User facing release notes"
Summary by CodeRabbit
Bug Fixes
Style