Skip to content

Commit cec1bb8

Browse files
Merge branch 'nikolas/remove-default-mapping' into nikolas/track-FallbackHyperEVMFlowCompleted
2 parents 99495e2 + db2174d commit cec1bb8

File tree

5 files changed

+37
-68
lines changed

5 files changed

+37
-68
lines changed

packages/indexer/src/data-indexing/adapter/oft/service.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import { CHAIN_IDs } from "@across-protocol/constants";
2-
import { createMapWithDefault } from "../../../utils/map";
32

43
// Taken from sample tx: https://layerzeroscan.com/tx/0x2bc0a3844389de155fac8a91cae44a01379ab9b13aa135cb69f368985b0ae85a
5-
export const SPONSORED_OFT_SRC_PERIPHERY_ADDRESS: { [key: number]: string } =
6-
createMapWithDefault(
7-
{
8-
[CHAIN_IDs.ARBITRUM]: "0x1235Ac1010FeeC8ae22744f323416cBBE37feDbE",
9-
},
10-
"0x1235Ac1010FeeC8ae22744f323416cBBE37feDbE",
11-
);
4+
export const SPONSORED_OFT_SRC_PERIPHERY_ADDRESS: { [key: number]: string } = {
5+
[CHAIN_IDs.ARBITRUM]: "0x1235Ac1010FeeC8ae22744f323416cBBE37feDbE",
6+
};
127

138
export type OftTokenKey = "usdt0";
149

packages/indexer/src/data-indexing/service/CCTPIndexerDataHandler.ts

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Logger } from "winston";
22
import { ethers, providers, Transaction } from "ethers";
33
import * as across from "@across-protocol/sdk";
44
import { CHAIN_IDs } from "@across-protocol/constants";
5-
import { formatFromAddressToChainFormat } from "../../utils";
5+
import { formatFromAddressToChainFormat, isTestnet } from "../../utils";
66
import {
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";
4443
import { entities, SaveQueryResult } from "@repo/indexer-database";
4544

4645
export 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

11196
const SWAP_API_CALLDATA_MARKER = "73c0de";
11297
const 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,

packages/indexer/src/utils/adressUtils.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { utils, arch } from "@across-protocol/sdk";
2+
import { CHAIN_IDs } from "@across-protocol/constants";
23

34
const { chainIsEvm, chainIsSvm } = utils;
45

@@ -24,3 +25,18 @@ export function formatFromAddressToChainFormat(
2425
// Fallback to bytes32 when address is malformed for the chain
2526
return address.toBytes32();
2627
}
28+
29+
export const isTestnet = (chainId: number): boolean => {
30+
return (
31+
chainId === CHAIN_IDs.ARBITRUM_SEPOLIA ||
32+
chainId === CHAIN_IDs.HYPEREVM_TESTNET ||
33+
chainId === CHAIN_IDs.BASE_SEPOLIA ||
34+
chainId === CHAIN_IDs.BLAST_SEPOLIA ||
35+
chainId === CHAIN_IDs.LISK_SEPOLIA ||
36+
chainId === CHAIN_IDs.MODE_SEPOLIA ||
37+
chainId === CHAIN_IDs.OPTIMISM_SEPOLIA ||
38+
chainId === CHAIN_IDs.POLYGON_AMOY ||
39+
chainId === CHAIN_IDs.SEPOLIA ||
40+
chainId === CHAIN_IDs.SOLANA_DEVNET
41+
);
42+
};

packages/indexer/src/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ export * from "./contractFactoryUtils";
44
export * from "./bundleBuilderUtils";
55
export * from "./spokePoolUtils";
66
export * from "./currencyUtils";
7-
export * from "./map";

packages/indexer/src/utils/map.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)