-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add etherlink #487
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
base: master
Are you sure you want to change the base?
feat: add etherlink #487
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,15 @@ | ||
| import { type Address, type Chain, defineChain } from 'viem'; | ||
| import { arbitrum, base, mainnet, monad, optimism, polygon, unichain, hyperEvm as hyperEvmOld } from 'viem/chains'; | ||
| import { | ||
| arbitrum, | ||
| base, | ||
| etherlink as etherlinkChain, | ||
| mainnet, | ||
| monad, | ||
| optimism, | ||
| polygon, | ||
| unichain, | ||
| hyperEvm as hyperEvmOld, | ||
| } from 'viem/chains'; | ||
| import { v2AgentsBase } from './monarch-agent'; | ||
| import type { AgentMetadata } from './types'; | ||
|
|
||
|
|
@@ -13,10 +23,10 @@ const _apiKey = process.env.NEXT_PUBLIC_THEGRAPH_API_KEY; | |
| * - If NEXT_PUBLIC_RPC_PRIORITY === 'ALCHEMY': Use Alchemy first, fall back to specific RPC | ||
| * - Otherwise (default): Use specific network RPC first, fall back to Alchemy | ||
| */ | ||
| const getRpcUrl = (specificRpcUrl: string | undefined, alchemySubdomain: string): string => { | ||
| const getRpcUrl = (specificRpcUrl: string | undefined, alchemySubdomain?: string): string => { | ||
| // Sanitize empty strings to undefined for correct fallback behavior | ||
| const targetRpc = specificRpcUrl || undefined; | ||
| const alchemyUrl = alchemyKey ? `https://${alchemySubdomain}.g.alchemy.com/v2/${alchemyKey}` : undefined; | ||
| const alchemyUrl = alchemyKey && alchemySubdomain ? `https://${alchemySubdomain}.g.alchemy.com/v2/${alchemyKey}` : undefined; | ||
|
|
||
| if (rpcPriority === 'ALCHEMY') { | ||
| // Prioritize Alchemy when explicitly set | ||
|
|
@@ -34,6 +44,7 @@ export enum SupportedNetworks { | |
| Polygon = 137, | ||
| Unichain = 130, | ||
| Arbitrum = 42_161, | ||
| Etherlink = 42_793, | ||
| HyperEVM = 999, | ||
| Monad = 143, | ||
| } | ||
|
|
@@ -45,6 +56,7 @@ export const ALL_SUPPORTED_NETWORKS = [ | |
| SupportedNetworks.Polygon, | ||
| SupportedNetworks.Unichain, | ||
| SupportedNetworks.Arbitrum, | ||
| SupportedNetworks.Etherlink, | ||
| SupportedNetworks.HyperEVM, | ||
| SupportedNetworks.Monad, | ||
| ]; | ||
|
|
@@ -161,6 +173,18 @@ export const networks: NetworkConfig[] = [ | |
| explorerUrl: 'https://arbiscan.io', | ||
| wrappedNativeToken: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', | ||
| }, | ||
| { | ||
| network: SupportedNetworks.Etherlink, | ||
| chain: etherlinkChain, | ||
| logo: require('../imgs/chains/etherlink.svg') as string, | ||
| name: 'Etherlink', | ||
| defaultRPC: getRpcUrl(process.env.NEXT_PUBLIC_ETHERLINK_RPC), | ||
| blocktime: 4.83, | ||
| maxBlockDelay: 10, | ||
| explorerUrl: 'https://explorer.etherlink.com', | ||
| nativeTokenSymbol: 'XTZ', | ||
| wrappedNativeToken: '0xc9B53AB2679f573e480d01e0f49e2B5CFB7a3EAb', | ||
| }, | ||
|
Comment on lines
+176
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify default Etherlink public RPC is functional
curl -s -X POST "https://node.mainnet.etherlink.com" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' | jq .Repository: antoncoding/monarch Length of output: 118 🏁 Script executed: # Check getRpcUrl implementation and alchemySubdomain handling
rg "function getRpcUrl|const getRpcUrl" -A 15 src/Repository: antoncoding/monarch Length of output: 1023 🏁 Script executed: # Search for http() transport usage and how empty URLs are handled
rg "http\(" src/utils/rpc.ts -A 3 -B 3Repository: antoncoding/monarch Length of output: 1723 🏁 Script executed: # Look for env var documentation and examples
find . -name ".env*" -o -name "README*" -o -name "docs" -type f | head -20Repository: antoncoding/monarch Length of output: 171 🏁 Script executed: # Check if there are any error handlers or validation for missing RPC URLs
rg "NEXT_PUBLIC.*RPC|getRpcUrl" -B 2 -A 2 src/Repository: antoncoding/monarch Length of output: 4177 🏁 Script executed: # Check .env.local.example for Etherlink RPC documentation
cat -n .env.local.example | grep -i etherlinkRepository: antoncoding/monarch Length of output: 96 🏁 Script executed: # Search for error handling or validation around http() or createPublicClient
rg "createPublicClient|http\(" src/utils/rpc.ts -B 3 -A 5 | head -50Repository: antoncoding/monarch Length of output: 2083 🏁 Script executed: # Check if there's any error handling for empty or invalid RPC URLs
rg "RPC|rpcUrl" src/utils/rpc.ts -B 2 -A 2Repository: antoncoding/monarch Length of output: 2341 🏁 Script executed: # Check if Alchemy supports Etherlink subdomain
rg "etherlink" -i src/utils/networks.ts | grep -i alchemyRepository: antoncoding/monarch Length of output: 45 🏁 Script executed: # Verify viem's http() behavior with empty string - check if there's any validation or error handling in documentation or code comments
rg "http\(" -B 5 -A 5 src/ | grep -i "empty\|url\|validate\|error" | head -20Repository: antoncoding/monarch Length of output: 428 🏁 Script executed: # Check getDefaultRPC function to see if it's the same as getRpcUrl
rg "function getDefaultRPC|const getDefaultRPC|export.*getDefaultRPC" -A 10 src/utils/networks.tsRepository: antoncoding/monarch Length of output: 436 🏁 Script executed: # Check if there's initialization validation or error handling that would catch empty RPC URLs
rg "initializeDefaultClients|getClient" src/utils/rpc.ts -B 2 -A 10Repository: antoncoding/monarch Length of output: 940 🏁 Script executed: # Look for any error boundaries or RPC validation in the app initialization
rg "try|catch|Error|throw" src/utils/rpc.ts | head -20Repository: antoncoding/monarch Length of output: 174 🏁 Script executed: # Verify what happens with empty URL in http() - check if viem has inline validation
rg "http\(" -B 2 -A 2 src/utils/rpc.tsRepository: antoncoding/monarch Length of output: 1694 🏁 Script executed: # Check if there's documentation in README about environment variables and Etherlink RPC requirement
grep -i "etherlink\|rpc\|environment" README.md | head -20Repository: antoncoding/monarch Length of output: 45 🏁 Script executed: # Search for any error handling or runtime validation that might catch empty URLs
rg "defaultRPC|getDefaultRPC" src/ -B 3 -A 3 | grep -i "error\|throw\|valid\|empty" | head -20Repository: antoncoding/monarch Length of output: 145 🏁 Script executed: # Check if there's a startup validation function that checks RPC URLs
rg "validate|check|init" src/utils/rpc.ts -iRepository: antoncoding/monarch Length of output: 163 🏁 Script executed: # Check if there's any initialization code that validates RPC URLs on startup
rg "_app|initialization|startup" src/pages -i | head -10Repository: antoncoding/monarch Length of output: 112 🏁 Script executed: # Verify if http() from viem throws on empty URL or just fails silently on request
rg "import.*http|from.*viem" src/utils/rpc.ts -A 2Repository: antoncoding/monarch Length of output: 320 🏁 Script executed: # Check all network configs to compare Etherlink's RPC setup with others
rg "defaultRPC: getRpcUrl" src/utils/networks.tsRepository: antoncoding/monarch Length of output: 780 🏁 Script executed: # Search for how the app uses these clients to see if there's error handling at usage time
rg "getClient|defaultClients" src/ | head -20Repository: antoncoding/monarch Length of output: 1614 🏁 Script executed: # Check if the public Etherlink RPC is documented anywhere in the codebase or comments
rg "node.mainnet.etherlink|etherlink.com" src/Repository: antoncoding/monarch Length of output: 135 🏁 Script executed: # Verify one more time that Etherlink is the only chain without alchemySubdomain
rg "getRpcUrl\(" src/utils/networks.ts | grep -v "alchemySubdomain"Repository: antoncoding/monarch Length of output: 780 Etherlink RPC lacks fallback—empty string if env var unset. Unlike other chains, Etherlink's Other networks all have Alchemy subdomains: eth-mainnet, opt-mainnet, base-mainnet, polygon-mainnet, unichain-mainnet, arb-mainnet, hyperliquid-mainnet, monad-mainnet. Options:
🧰 Tools🪛 Betterleaks (1.1.1)[high] 186-186: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) 🤖 Prompt for AI Agents |
||
| { | ||
| network: SupportedNetworks.HyperEVM, | ||
| chain: hyperEvm, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.