|
8 | 8 | } from "@solana/web3.js";
|
9 | 9 | import "dotenv/config";
|
10 | 10 | import { MatchingEngineProgram } from "../src/matchingEngine";
|
| 11 | +import { CHAINS } from "./getTestnetInfo"; |
| 12 | +import { toChainId } from "@wormhole-foundation/sdk-base"; |
11 | 13 |
|
12 | 14 | const PROGRAM_ID = "mPydpGUWxzERTNpyvTKdvS7v8kvw5sgwfiP8WQFrXVS";
|
13 | 15 | const USDC_MINT = new PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU");
|
@@ -39,16 +41,44 @@ async function main() {
|
39 | 41 | // ]);
|
40 | 42 | // console.log("createTx", createTx);
|
41 | 43 |
|
42 |
| - const lookupTable = new PublicKey("pGTATFy5xgzdxu6XpiCzCu1uE3Ur473gGUD2pZykahf"); |
| 44 | + const lookupTable = new PublicKey("DaZU4eDFxq8hAHf78HLUyhWe8G2tszyaNUJoFgDCqqs8"); |
43 | 45 |
|
44 | 46 | const usdcCommonAccounts = await matchingEngine.commonAccounts();
|
45 | 47 |
|
| 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 | + |
46 | 76 | // Extend.
|
47 | 77 | const extendIx = AddressLookupTableProgram.extendLookupTable({
|
48 | 78 | payer: payer.publicKey,
|
49 | 79 | authority: payer.publicKey,
|
50 | 80 | lookupTable,
|
51 |
| - addresses: Object.values(usdcCommonAccounts).filter((key) => key !== undefined), |
| 81 | + addresses, |
52 | 82 | });
|
53 | 83 |
|
54 | 84 | const extendTx = await sendAndConfirmTransaction(
|
|
0 commit comments