Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ var (
EIP3009Name: "USD Coin",
EIP3009Version: "2",
}

// XDCMainnet is the configuration for XDC Network mainnet.
// Native Circle USDC; EIP-3009 parameters verified on-chain.
XDCMainnet = ChainConfig{
NetworkID: "xdc",
USDCAddress: "0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1",
Decimals: 6,
EIP3009Name: "USDC",
EIP3009Version: "2",
}
)

// Testnet chain configurations
Expand Down Expand Up @@ -154,6 +164,16 @@ var (
EIP3009Name: "USD Coin",
EIP3009Version: "2",
}

// XDCApothem is the configuration for XDC Apothem testnet.
// Native Circle USDC; EIP-3009 parameters verified on-chain.
XDCApothem = ChainConfig{
NetworkID: "xdc-testnet",
USDCAddress: "0xb5AB69F7bBada22B28e79C8FFAECe55eF1c771D4",
Decimals: 6,
EIP3009Name: "USDC",
EIP3009Version: "2",
}
)

// NewUSDCTokenConfig creates a TokenConfig for USDC on the given chain with the specified priority.
Expand Down
24 changes: 24 additions & 0 deletions v2/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ const (
NetworkPolygon = "eip155:137"
NetworkAvalanche = "eip155:43114"
NetworkEthereum = "eip155:1"
NetworkXDC = "eip155:50"

// EVM Testnets
NetworkBaseSepolia = "eip155:84532"
NetworkPolygonAmoy = "eip155:80002"
NetworkAvalancheFuji = "eip155:43113"
NetworkSepolia = "eip155:11155111"
NetworkXDCTestnet = "eip155:51"

// Solana networks (using genesis hash as reference per CAIP-2)
NetworkSolanaMainnet = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
Expand Down Expand Up @@ -96,6 +98,16 @@ var (
EIP3009Name: "USD Coin",
EIP3009Version: "2",
}

// XDCMainnet is the configuration for XDC Network mainnet.
// Native Circle USDC; EIP-3009 parameters verified on-chain.
XDCMainnet = ChainConfig{
Network: NetworkXDC,
USDCAddress: "0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1",
Decimals: 6,
EIP3009Name: "USDC",
EIP3009Version: "2",
}
)

// Predefined chain configurations - EVM Testnets
Expand Down Expand Up @@ -139,6 +151,16 @@ var (
EIP3009Name: "USDC",
EIP3009Version: "2",
}

// XDCApothem is the configuration for XDC Apothem testnet.
// Native Circle USDC; EIP-3009 parameters verified on-chain.
XDCApothem = ChainConfig{
Network: NetworkXDCTestnet,
USDCAddress: "0xb5AB69F7bBada22B28e79C8FFAECe55eF1c771D4",
Decimals: 6,
EIP3009Name: "USDC",
EIP3009Version: "2",
}
)

// Predefined chain configurations - Solana
Expand Down Expand Up @@ -171,11 +193,13 @@ var chainConfigByNetwork = map[string]ChainConfig{
NetworkPolygon: PolygonMainnet,
NetworkAvalanche: AvalancheMainnet,
NetworkEthereum: EthereumMainnet,
NetworkXDC: XDCMainnet,
// EVM Testnets
NetworkBaseSepolia: BaseSepolia,
NetworkPolygonAmoy: PolygonAmoy,
NetworkAvalancheFuji: AvalancheFuji,
NetworkSepolia: Sepolia,
NetworkXDCTestnet: XDCApothem,
Comment on lines +196 to +202

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.

// Solana
NetworkSolanaMainnet: SolanaMainnet,
NetworkSolanaDevnet: SolanaDevnet,
Expand Down