@@ -10,8 +10,7 @@ import { Format } from './types.ts'
1010import { withDateTimestamp } from './utils.ts'
1111
1212// Circle CCTP Domain ID mapping based on https://developers.circle.com/cctp/cctp-supported-blockchains#cctp-v2-supported-domains
13- const CHAIN_ID_TO_CIRCLE_DOMAIN : Record < number , number > = {
14- // Mainnet
13+ const MAINNET_CHAIN_ID_TO_CIRCLE_DOMAIN : Record < number , number > = {
1514 1 : 0 , // Ethereum
1615 43114 : 1 , // Avalanche
1716 10 : 2 , // OP Mainnet
@@ -25,8 +24,9 @@ const CHAIN_ID_TO_CIRCLE_DOMAIN: Record<number, number> = {
2524 480 : 14 , // World Chain
2625 1329 : 16 , // Sei
2726 56 : 17 , // BNB Smart Chain
27+ }
2828
29- // Testnet
29+ const TESTNET_CHAIN_ID_TO_CIRCLE_DOMAIN : Record < number , number > = {
3030 421614 : 3 , // Arbitrum Sepolia
3131 43113 : 1 , // Avalanche Fuji
3232 84532 : 6 , // Base Sepolia
@@ -41,6 +41,11 @@ const CHAIN_ID_TO_CIRCLE_DOMAIN: Record<number, number> = {
4141 51 : 50 , // XDC Apothem
4242}
4343
44+ const CHAIN_ID_TO_CIRCLE_DOMAIN = {
45+ ...MAINNET_CHAIN_ID_TO_CIRCLE_DOMAIN ,
46+ ...TESTNET_CHAIN_ID_TO_CIRCLE_DOMAIN ,
47+ }
48+
4449// USDC MessageSent event for extracting the message from logs (v1 API)
4550const USDC_EVENT = EventFragment . from ( 'MessageSent(bytes message)' )
4651
@@ -115,16 +120,12 @@ export async function getUSDCAttestationStatus(
115120 }
116121
117122 const apiVersion = argv . apiVersion || 'v2'
118-
119123 try {
120124 let data : CircleApiResponse
121125
122126 if ( apiVersion === 'v2' ) {
123- // Call the new Circle API v2
124127 data = await getUsdcAttestationV2 ( sourceDomainId , txHash )
125128 } else {
126- // v1 API - extract message from transaction logs
127- // Make sure we have chainId for determining testnet status
128129 if ( chainId === undefined ) {
129130 const network = await source . getNetwork ( )
130131 chainId = Number ( network . chainId )
@@ -244,16 +245,10 @@ async function fetchUsdcAttestationV1(
244245 receipt : TransactionReceipt ,
245246 chainId : number ,
246247) : Promise < CircleApiResponse > {
247- // Determine if testnet based on known testnet chain IDs
248- // Mainnet chain IDs that support CCTP
249- const mainnetChainIds = new Set ( [
250- 1 , 43114 , 10 , 42161 , 8453 , 137 , 1829 , 59144 , 81457 , 146 , 480 , 1329 , 56 ,
251- ] )
252- const isTestnet = ! mainnetChainIds . has ( chainId )
248+ const isTestnet = chainId in TESTNET_CHAIN_ID_TO_CIRCLE_DOMAIN
253249
254250 // Find USDC MessageSent event in transaction logs
255251 const messageSentLog = receipt . logs . find ( ( log ) => log . topics [ 0 ] === USDC_EVENT . topicHash )
256-
257252 if ( ! messageSentLog ) {
258253 throw new Error ( 'USDC MessageSent event not found in transaction logs' )
259254 }
0 commit comments