Skip to content

feat: add XDC Network and XDC Apothem testnet chain configs - #29

Open
AnilChinchawale wants to merge 1 commit into
mark3labs:mainfrom
AnilChinchawale:feat/add-xdc
Open

feat: add XDC Network and XDC Apothem testnet chain configs#29
AnilChinchawale wants to merge 1 commit into
mark3labs:mainfrom
AnilChinchawale:feat/add-xdc

Conversation

@AnilChinchawale

@AnilChinchawale AnilChinchawale commented Jun 24, 2026

Copy link
Copy Markdown

Adds XDCMainnet (network xdc) and XDCApothem (xdc-testnet) to chains.go.

XDC is an EVM-compatible L1 (XDPoS) with native Circle USDC supporting EIP-3009. USDC address + EIP-712 domain verified on-chain:

network USDC name / version
mainnet xdc (50) 0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1 USDC / 2
testnet xdc-testnet (51) 0xb5AB69F7bBada22B28e79C8FFAECe55eF1c771D4 USDC / 2

gofmt clean, go build ./... passes.

Summary by CodeRabbit

  • New Features
    • Added XDC network configurations for USDC on both mainnet and testnet.
    • Included new exported network identifiers and chain settings, including network ID, native USDC address, token decimals, and EIP-3009 domain details.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

XDC mainnet and testnet chain configurations are added in chains.go and v2/chains.go. The v2 registry also gains a new XDC network identifier and mappings from XDC network IDs to the new configs.

Changes

XDC Chain Support

Layer / File(s) Summary
XDC network registry entries
v2/chains.go
Adds NetworkXDC, defines XDCMainnet and XDCApothem, and maps both XDC network identifiers to their chain configurations in chainConfigByNetwork.
Root XDC chain configs
chains.go
Exports XDCMainnet and XDCApothem ChainConfig values in chains.go with XDC network IDs, native Circle USDC addresses, Decimals: 6, and EIP-3009 domain fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop hop, XDC lands in the grove,
Mainnet and testnet now both smoothlyোভ?
USDC shines bright with six-decimal cheer,
And bunny hops on through the chain frontier.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change by describing the added XDC mainnet and Apothem chain configs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Adds XDCMainnet ("xdc" / eip155:50) and XDCApothem ("xdc-testnet" /
eip155:51) to both chains.go (v1) and v2/chains.go (incl. the
chainConfigByNetwork registry). XDC is an EVM L1 (XDPoS) with native Circle
USDC supporting EIP-3009. USDC + EIP-712 domain verified on-chain: mainnet
0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1, Apothem
0xb5AB69F7bBada22B28e79C8FFAECe55eF1c771D4 (name "USDC", version "2").
gofmt clean, go build ./... passes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@v2/chains.go`:
- Around line 196-202: Add the missing XDC coverage in the chain verification
tests by updating TestGetChainID to include cases for eip155:50 and eip155:51,
and update TestEIP3009Parameters so the evmChains slice includes XDCMainnet and
XDCApothem. Use the existing test helpers in v2/chains_test.go to verify these
new chains resolve correctly and still expose EIP3009Name and EIP3009Version.
🪄 Autofix

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0659b01e-b41b-4b38-9a4b-d1b2ffb0c5a4

📥 Commits

Reviewing files that changed from the base of the PR and between cf17264 and d9d3447.

📒 Files selected for processing (2)
  • chains.go
  • v2/chains.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • chains.go

Comment thread v2/chains.go
Comment on lines +196 to +202
NetworkXDC: XDCMainnet,
// EVM Testnets
NetworkBaseSepolia: BaseSepolia,
NetworkPolygonAmoy: PolygonAmoy,
NetworkAvalancheFuji: AvalancheFuji,
NetworkSepolia: Sepolia,
NetworkXDCTestnet: XDCApothem,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect test coverage for newly added XDC networks/configs.
fd -a '^chains_test\.go$' v2 | xargs -I{} sh -c '
  echo "== File: {} ==";
  ast-grep outline "{}" --view expanded | sed -n "1,220p";
  rg -n "TestGetChainID|TestEIP3009Parameters|eip155:50|eip155:51|NetworkXDC|NetworkXDCTestnet|XDCMainnet|XDCApothem" "{}";
'

Repository: mark3labs/x402-go

Length of output: 813


🏁 Script executed:

sed -n '158,230p' v2/chains_test.go && echo "---SEPARATOR---" && sed -n '334,362p' v2/chains_test.go

Repository: mark3labs/x402-go

Length of output: 2363


Add XDC Mainnet and Testnet to chain-config verification tests.

The v2/chains.go changes are internal valid, but the new XDC networks are missing from the coverage in v2/chains_test.go:

  • In TestGetChainID, add test cases for eip155:50 (ChainID 50) and eip155:51 (ChainID 51).
  • In TestEIP3009Parameters, include XDCMainnet and XDCApothem in the evmChains slice to verify they correctly possess the EIP3009Name and EIP3009Version fields.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v2/chains.go` around lines 196 - 202, Add the missing XDC coverage in the
chain verification tests by updating TestGetChainID to include cases for
eip155:50 and eip155:51, and update TestEIP3009Parameters so the evmChains slice
includes XDCMainnet and XDCApothem. Use the existing test helpers in
v2/chains_test.go to verify these new chains resolve correctly and still expose
EIP3009Name and EIP3009Version.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

An unexpected error occurred while generating fixes: Not Found - https://docs.github.com/rest/git/refs#get-a-reference

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