Skip to content

Commit dcaf657

Browse files
abhidtu2014a5-pickle
authored andcommitted
Update LUT script
1 parent 8822c3f commit dcaf657

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

solana/ts/scripts/getTestnetInfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as tokenRouterSdk from "../src/tokenRouter";
66

77
const USDC_MINT = new PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU");
88

9-
const CHAINS: Chain[] = [
9+
export const CHAINS: Chain[] = [
1010
"Sepolia",
1111
"Avalanche",
1212
"OptimismSepolia",

solana/ts/scripts/setUpMatchingEngineLut.ts

+32-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
} from "@solana/web3.js";
99
import "dotenv/config";
1010
import { MatchingEngineProgram } from "../src/matchingEngine";
11+
import { CHAINS } from "./getTestnetInfo";
12+
import { toChainId } from "@wormhole-foundation/sdk-base";
1113

1214
const PROGRAM_ID = "mPydpGUWxzERTNpyvTKdvS7v8kvw5sgwfiP8WQFrXVS";
1315
const USDC_MINT = new PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU");
@@ -39,16 +41,44 @@ async function main() {
3941
// ]);
4042
// console.log("createTx", createTx);
4143

42-
const lookupTable = new PublicKey("pGTATFy5xgzdxu6XpiCzCu1uE3Ur473gGUD2pZykahf");
44+
const lookupTable = new PublicKey("DaZU4eDFxq8hAHf78HLUyhWe8G2tszyaNUJoFgDCqqs8");
4345

4446
const usdcCommonAccounts = await matchingEngine.commonAccounts();
4547

48+
const addresses = [
49+
...Object.values(usdcCommonAccounts).filter((key) => key !== undefined),
50+
payer.publicKey,
51+
];
52+
53+
const uniqueAddresses = new Map<string, PublicKey>();
54+
55+
for (const chainName of CHAINS) {
56+
const { protocol } = await matchingEngine.fetchRouterEndpointInfo(toChainId(chainName));
57+
58+
if (protocol.cctp?.domain === undefined) {
59+
console.warn(`Couldn't find cctp domain for ${chainName}`);
60+
continue;
61+
}
62+
const { remoteTokenMessenger, tokenMessengerMinterEventAuthority } = await matchingEngine
63+
.tokenMessengerMinterProgram()
64+
.depositForBurnWithCallerAccounts(matchingEngine.mint, protocol.cctp?.domain);
65+
66+
uniqueAddresses.set(remoteTokenMessenger.toBase58(), remoteTokenMessenger);
67+
// Note: Some of the tokenMessengerMinterEventAuthority addresses are the same across cctp domains.
68+
uniqueAddresses.set(
69+
tokenMessengerMinterEventAuthority.toBase58(),
70+
tokenMessengerMinterEventAuthority,
71+
);
72+
}
73+
74+
addresses.push(...Array.from(uniqueAddresses.values()));
75+
4676
// Extend.
4777
const extendIx = AddressLookupTableProgram.extendLookupTable({
4878
payer: payer.publicKey,
4979
authority: payer.publicKey,
5080
lookupTable,
51-
addresses: Object.values(usdcCommonAccounts).filter((key) => key !== undefined),
81+
addresses,
5282
});
5383

5484
const extendTx = await sendAndConfirmTransaction(

0 commit comments

Comments
 (0)