-
Notifications
You must be signed in to change notification settings - Fork 6
Add SKALE on Base network support and fix facilitator fee calculation #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying x402-exec with
|
| Latest commit: |
2c1971f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://57e9c430.x402-exec.pages.dev |
| Branch Preview URL: | https://feature-skale-base-network.x402-exec.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for the SKALE on Base network and fixes a critical bug in the facilitator fee calculation where CAIP-2 network identifiers weren't properly matched to token prices. Additionally, it establishes a shared network infrastructure by generating networks.json from TypeScript sources for use by shell deployment scripts.
Key Changes:
- Adds SKALE on Base mainnet (
eip155:1187947933) with deployed contracts and USDC token configuration - Fixes facilitator fee calculation to convert CAIP-2 IDs to aliases before price matching using
getNetworkAlias() - Creates
generate-networks-jsonscript to generatenetworks.jsonfrom TypeScript configuration as a single source of truth
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| typescript/packages/extensions/src/networks.ts | Adds SKALE on Base network configuration with contract addresses |
| typescript/packages/extensions/src/network-utils.ts | Adds SKALE Base network aliases and default USDC asset configuration |
| typescript/packages/extensions/src/chains.ts | Adds SKALE Base chain definition with RPC and explorer URLs |
| typescript/packages/extensions/scripts/generate-networks-json.ts | New script to generate networks.json from TypeScript sources |
| typescript/packages/extensions/scripts/generate-networks-json.mjs | ESM wrapper for the generation script |
| typescript/packages/extensions/package.json | Adds generate-networks-json script and tsx dependency |
| package.json | Adds root-level generate:networks command |
| facilitator/src/config.ts | Fixes fee calculation by converting CAIP-2 to alias with getNetworkAlias |
| facilitator/src/defaults.ts | Adds CREDIT token price constant ($0.25) |
| contracts/networks.json | Generated network configuration for shell scripts |
| contracts/deploy-contract.sh | Refactored to use networks.json and support CAIP-2 format |
| contracts/verify-usdc-eip712.sh | New utility script to verify USDC EIP-712 domain configuration |
| pnpm-lock.yaml | Lock file updates for tsx dependency |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
contracts/networks.json
Outdated
| "explorerUrl": "https://base-sepolia-testnet-explorer.skalenodes.com", | ||
| "gasModel": "legacy", | ||
| "type": "testnet", | ||
| "nativeToken": "Credits" |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent nativeToken naming between the two SKALE networks. SKALE Base Sepolia uses "Credits" (line 87) while SKALE on Base uses "CREDIT" (line 99). These should be consistent, preferably using "CREDIT" to match the TypeScript configuration and the CREDIT token price constant in the facilitator code.
| "nativeToken": "Credits" | |
| "nativeToken": "CREDIT" |
| "xlayer-testnet": "eip155:1952", // Legacy alias for backward compatibility | ||
| "skale-base-sepolia": "eip155:324705682", | ||
| "skale-base": "eip155:1187947933", | ||
| base: "eip155:8453", | ||
| "x-layer": "eip155:196", | ||
| xlayer: "eip155:196", // Legacy alias for backward compatibility |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of legacy aliases "xlayer-testnet" and "xlayer" creates a potential issue. When NETWORK_ALIASES is generated from NETWORK_ALIASES_V1_TO_V2, multiple aliases mapping to the same CAIP-2 ID will cause the last one to overwrite earlier ones. This means "eip155:1952" will map to "xlayer-testnet" instead of the canonical "x-layer-testnet", and "eip155:196" will map to "xlayer" instead of "x-layer". Consider documenting which alias takes precedence or restructuring to ensure the canonical alias is used.
## Network Configuration - Add SKALE on Base (eip155:1187947933, chainId: 1187947933) - Add SKALE Base Sepolia (eip155:324705682, chainId: 324705682) - Configure USDC (Bridged USDC with EIP-712 verification) - Configure CREDIT token pricing: $0.25 (1 USD = 4 CREDIT) ## Shared Network Configuration - Create networks.json generation script from TypeScript source - Update deploy-contract.sh to support CAIP-2 network identifiers - Add getNetworkAlias import for network name matching ## Facilitator Improvements - Fix native token price matching for SKALE networks - Convert CAIP-2 IDs to aliases before price matching - Add CREDIT token price configuration ## Deployed Contracts (SKALE on Base) - SettlementRouter: 0x1Ae0E196dC18355aF3a19985faf67354213F833D - TransferHook: 0x2f05fe5674aE756E25C26855258B4877E9e021Fd - NFTMintHook: 0x73fc659Cd5494E69852bE8D9D23FE05Aab14b29B - RandomNFT: 0x081258287F692D61575387ee2a4075f34dd7Aef7 - RewardHook: 0xC20634ea518985901e32Fbc1bA27fa673D37601A - RewardToken: 0x9Fc2c199170B039f093ABCd54008038F0C0a31d6 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
80bd825 to
a058f58
Compare
…ence ## Fix 1: Standardize nativeToken to "CREDIT" for SKALE networks - Change SKALE Base Sepolia nativeToken from "Credits" to "CREDIT" - Update chains.ts nativeCurrency.symbol from "sFUEL" to "CREDIT" - Update networks.ts metadata.nativeToken to "CREDIT" - Ensure consistency across all SKALE network configurations ## Fix 2: Ensure canonical network aliases take precedence - Reorder NETWORK_ALIASES_V1_TO_V2 to place canonical aliases after legacy ones - This ensures "x-layer-testnet" and "x-layer" override "xlayer-testnet" and "xlayer" - Prevents non-canonical aliases from being returned by getNetworkAlias() ## Impact These changes ensure: 1. Consistent native token naming across all SKALE networks 2. Reverse mapping (CAIP-2 -> alias) returns canonical aliases 3. Generated networks.json uses correct token symbols 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
## Changes ### Update test expectations for legacy aliases - Add "skale-base" to EXPECTED_V1_NETWORKS (was missing) - Add LEGACY_V1_ALIASES constant for backward compatibility aliases - Create ALL_EXPECTED_ALIASES combining canonical and legacy ### Update test logic to handle non-bijective mappings - "should have v2 mappings" test: Verify total alias count includes legacy ones - "should have no duplicate" test: Allow CAIP-2 duplicates for legacy aliases - "should have bijective relationship" test: Only test canonical aliases - "toCanonicalNetworkKey" test: Add legacy alias test cases ## Rationale Legacy aliases (xlayer-testnet, xlayer) are intentionally supported for backward compatibility. This means v1 names are no longer in a strict one-to-one relationship with CAIP-2 IDs. Tests now reflect this reality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary
This PR adds support for SKALE on Base network and fixes a critical bug in facilitator fee calculation where CAIP-2 network identifiers weren't properly matched to token prices.
Changes
Network Configuration
eip155:1187947933, chainId: 1187947933)Shared Network Infrastructure
contracts/networks.jsongeneration from TypeScript sourcetypescript/packages/extensions/scripts/generate-networks-json.tspnpm generate:networkscontracts/deploy-contract.shto support CAIP-2 formateip155:1187947933andskale-basegetNetworkAliasimport for proper network name matchingFacilitator Fee Calculation Fix
eip155:1187947933didn't match "skale" in price lookupDeployed Contracts
SKALE on Base (eip155:1187947933)
0x1Ae0E196dC18355aF3a19985faf67354213F833D0x2f05fe5674aE756E25C26855258B4877E9e021Fd0x73fc659Cd5494E69852bE8D9D23FE05Aab14b29B0x081258287F692D61575387ee2a4075f34dd7Aef70xC20634ea518985901e32Fbc1bA27fa673D37601A0x9Fc2c199170B039f093ABCd54008038F0C0a31d6SKALE Base Sepolia (eip155:324705682)
0x1Ae0E196dC18355aF3a19985faf67354213F833D0x2f05fe5674aE756E25C26855258B4877E9e021Fd0x73fc659Cd5494E69852bE8D9D23FE05Aab14b29B0x081258287F692D61575387ee2a4075f34dd7Aef70xc20634ea518985901e32fbc1ba27fa673d37601a0x9fc2c199170b039f093abcd54008038f0c0a31d6Test Plan
Related Issues
None
Breaking Changes
None. This is a new network addition and bug fix.
🤖 Generated with Claude Code