@@ -2,7 +2,7 @@ import { Logger } from "winston";
22import { ethers , providers , Transaction } from "ethers" ;
33import * as across from "@across-protocol/sdk" ;
44import { CHAIN_IDs } from "@across-protocol/constants" ;
5- import { formatFromAddressToChainFormat } from "../../utils" ;
5+ import { formatFromAddressToChainFormat , isTestnet } from "../../utils" ;
66import {
77 BlockRange ,
88 HYPERCORE_FLOW_EXECUTOR_ADDRESS ,
@@ -40,7 +40,6 @@ import {
4040 getCctpDestinationChainFromDomain ,
4141 isHypercoreWithdraw ,
4242} from "../adapter/cctp-v2/service" ;
43- import { createMapWithDefault } from "../../utils/map" ;
4443import { entities , SaveQueryResult } from "@repo/indexer-database" ;
4544
4645export type EvmBurnEventsPair = {
@@ -78,35 +77,21 @@ export type StoreEventsResult = {
7877} ;
7978
8079// Taken from https://developers.circle.com/cctp/evm-smart-contracts
81- const TOKEN_MESSENGER_ADDRESS : { [ key : number ] : string } = createMapWithDefault (
82- {
83- [ CHAIN_IDs . ARBITRUM_SEPOLIA ] : "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA" ,
84- [ CHAIN_IDs . HYPEREVM_TESTNET ] : "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA" ,
85- } ,
86- "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d" ,
87- ) ;
80+ const TOKEN_MESSENGER_ADDRESS_MAINNET : string =
81+ "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d" ;
82+ const TOKEN_MESSENGER_ADDRESS_TESTNET : string =
83+ "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA" ;
8884
8985// Taken from https://developers.circle.com/cctp/evm-smart-contracts
90- const MESSAGE_TRANSMITTER_ADDRESS : { [ key : number ] : string } =
91- createMapWithDefault (
92- {
93- [ CHAIN_IDs . ARBITRUM_SEPOLIA ] :
94- "0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275" ,
95- [ CHAIN_IDs . HYPEREVM_TESTNET ] :
96- "0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275" ,
97- } ,
98- "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64" ,
99- ) ;
86+ const MESSAGE_TRANSMITTER_ADDRESS_MAINNET : string =
87+ "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64" ;
88+ const MESSAGE_TRANSMITTER_ADDRESS_TESTNET : string =
89+ "0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275" ;
10090
10191// TODO: Update this address once the contract is deployed
102- const SPONSORED_CCTP_SRC_PERIPHERY_ADDRESS : { [ key : number ] : string } =
103- createMapWithDefault (
104- {
105- [ CHAIN_IDs . ARBITRUM_SEPOLIA ] :
106- "0x79176E2E91c77b57AC11c6fe2d2Ab2203D87AF85" ,
107- } ,
108- "0x79176E2E91c77b57AC11c6fe2d2Ab2203D87AF85" ,
109- ) ;
92+ const SPONSORED_CCTP_SRC_PERIPHERY_ADDRESS : { [ key : number ] : string } = {
93+ [ CHAIN_IDs . ARBITRUM_SEPOLIA ] : "0x79176E2E91c77b57AC11c6fe2d2Ab2203D87AF85" ,
94+ } ;
11095
11196const SWAP_API_CALLDATA_MARKER = "73c0de" ;
11297const WHITELISTED_FINALIZERS = [ "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D" ] ;
@@ -177,23 +162,19 @@ export class CCTPIndexerDataHandler implements IndexerDataHandler {
177162 private async fetchEventsByRange (
178163 blockRange : BlockRange ,
179164 ) : Promise < FetchEventsResult > {
180- const tokenMessengerAddress = TOKEN_MESSENGER_ADDRESS [ this . chainId ] ;
181- const messageTransmitterAddress = MESSAGE_TRANSMITTER_ADDRESS [ this . chainId ] ;
182165 const sponsoredCCTPSrcPeripheryAddress =
183166 SPONSORED_CCTP_SRC_PERIPHERY_ADDRESS [ this . chainId ] ;
184167 const hyperEvmExecutorAddress =
185168 HYPERCORE_FLOW_EXECUTOR_ADDRESS [ this . chainId ] ;
186169 const arbitraryEvmFlowExecutorAddress =
187170 ARBITRARY_EVM_FLOW_EXECUTOR_ADDRESS [ this . chainId ] ;
188171
189- if ( ! tokenMessengerAddress || ! messageTransmitterAddress ) {
190- const errorMessage = `CCTP contracts addresses not configured for chain ${ this . chainId } ` ;
191- this . logger . error ( {
192- at : "CCTPIndexerDataHandler#fetchEventsByRange" ,
193- message : errorMessage ,
194- } ) ;
195- throw new Error ( errorMessage ) ;
196- }
172+ const tokenMessengerAddress = isTestnet ( this . chainId )
173+ ? TOKEN_MESSENGER_ADDRESS_TESTNET
174+ : TOKEN_MESSENGER_ADDRESS_MAINNET ;
175+ const messageTransmitterAddress = isTestnet ( this . chainId )
176+ ? MESSAGE_TRANSMITTER_ADDRESS_TESTNET
177+ : MESSAGE_TRANSMITTER_ADDRESS_MAINNET ;
197178
198179 const tokenMessengerContract = new ethers . Contract (
199180 tokenMessengerAddress ,
0 commit comments