Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Matching Engine address LUT script #195

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solana/ts/scripts/getTestnetInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as tokenRouterSdk from "../src/tokenRouter";

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

const CHAINS: Chain[] = [
export const CHAINS: Chain[] = [
"Sepolia",
"Avalanche",
"OptimismSepolia",
Expand Down
34 changes: 32 additions & 2 deletions solana/ts/scripts/setUpMatchingEngineLut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
} from "@solana/web3.js";
import "dotenv/config";
import { MatchingEngineProgram } from "../src/matchingEngine";
import { CHAINS } from "./getTestnetInfo";
import { toChainId } from "@wormhole-foundation/sdk-base";

const PROGRAM_ID = "mPydpGUWxzERTNpyvTKdvS7v8kvw5sgwfiP8WQFrXVS";
const USDC_MINT = new PublicKey("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU");
Expand Down Expand Up @@ -39,16 +41,44 @@ async function main() {
// ]);
// console.log("createTx", createTx);

const lookupTable = new PublicKey("pGTATFy5xgzdxu6XpiCzCu1uE3Ur473gGUD2pZykahf");
const lookupTable = new PublicKey("DaZU4eDFxq8hAHf78HLUyhWe8G2tszyaNUJoFgDCqqs8");

const usdcCommonAccounts = await matchingEngine.commonAccounts();

const addresses = [
...Object.values(usdcCommonAccounts).filter((key) => key !== undefined),
payer.publicKey,
];

const uniqueAddresses = new Map<string, PublicKey>();

for (const chainName of CHAINS) {
const { protocol } = await matchingEngine.fetchRouterEndpointInfo(toChainId(chainName));

if (protocol.cctp?.domain === undefined) {
console.warn(`Couldn't find cctp domain for ${chainName}`);
continue;
}
const { remoteTokenMessenger, tokenMessengerMinterEventAuthority } = await matchingEngine
.tokenMessengerMinterProgram()
.depositForBurnWithCallerAccounts(matchingEngine.mint, protocol.cctp?.domain);

uniqueAddresses.set(remoteTokenMessenger.toBase58(), remoteTokenMessenger);
// Note: Some of the tokenMessengerMinterEventAuthority addresses are the same across cctp domains.
uniqueAddresses.set(
tokenMessengerMinterEventAuthority.toBase58(),
tokenMessengerMinterEventAuthority,
);
}

addresses.push(...Array.from(uniqueAddresses.values()));

// Extend.
const extendIx = AddressLookupTableProgram.extendLookupTable({
payer: payer.publicKey,
authority: payer.publicKey,
lookupTable,
addresses: Object.values(usdcCommonAccounts).filter((key) => key !== undefined),
addresses,
});

const extendTx = await sendAndConfirmTransaction(
Expand Down
Loading