Skip to content

Commit a0d2422

Browse files
authored
[multisig] Improve verify, add localnet (#420)
* Improve verify, add localnet * Restore something * Format * Remove option
1 parent e536b3a commit a0d2422

File tree

1 file changed

+15
-23
lines changed
  • third_party/pyth/multisig-wh-message-builder/src

1 file changed

+15
-23
lines changed

third_party/pyth/multisig-wh-message-builder/src/index.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import { program } from "commander";
2222
import * as fs from "fs";
2323
import { LedgerNodeWallet } from "./wallet";
2424
import lodash from "lodash";
25+
import { getActiveProposals, getProposalInstructions } from "./multisig";
2526

2627
setDefaultWasm("node");
2728

28-
type Cluster = "devnet" | "mainnet";
29-
type WormholeNetwork = "TESTNET" | "MAINNET";
29+
type Cluster = "devnet" | "mainnet" | "localnet";
30+
type WormholeNetwork = "TESTNET" | "MAINNET" | "DEVNET";
3031

3132
type Config = {
3233
wormholeClusterName: WormholeNetwork;
@@ -45,6 +46,11 @@ const CONFIG: Record<Cluster, Config> = {
4546
vault: new PublicKey("FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj"),
4647
wormholeRpcEndpoint: "https://wormhole-v2-mainnet-api.certus.one",
4748
},
49+
localnet: {
50+
wormholeClusterName: "DEVNET",
51+
vault: new PublicKey("2VVHgWVHi32P1aoMjHmL3e1Hf6yi7uERahXF1T5n6EHx"), // Placeholder
52+
wormholeRpcEndpoint: "https://wormhole-v2-mainnet-api.certus.one", // Placeholder
53+
},
4854
};
4955

5056
program
@@ -374,7 +380,11 @@ async function getSquadsClient(
374380
console.log(`Loaded wallet with address: ${wallet.publicKey.toBase58()}`);
375381
}
376382
const squad =
377-
cluster === "devnet" ? Squads.devnet(wallet) : Squads.mainnet(wallet);
383+
cluster === "devnet"
384+
? Squads.devnet(wallet)
385+
: cluster == "mainnet"
386+
? Squads.mainnet(wallet)
387+
: Squads.endpoint("http://127.0.0.1:8899", wallet);
378388
return squad;
379389
}
380390

@@ -582,34 +592,16 @@ async function verifyWormholePayload(
582592
console.log(`Emitter Address: ${emitter.toBase58()}`);
583593

584594
const tx = await squad.getTransaction(txPubkey);
595+
const onChainInstructions = await getProposalInstructions(squad, tx);
585596

586-
if (tx.instructionIndex !== 2) {
597+
if (onChainInstructions.length !== 2) {
587598
throw new Error(
588599
`Expected 2 instructions in the transaction, found ${
589600
tx.instructionIndex + 1
590601
}`
591602
);
592603
}
593604

594-
const [ix1PubKey] = getIxPDA(
595-
txPubkey,
596-
new anchor.BN(1),
597-
squad.multisigProgramId
598-
);
599-
const [ix2PubKey] = getIxPDA(
600-
txPubkey,
601-
new anchor.BN(2),
602-
squad.multisigProgramId
603-
);
604-
605-
const onChainInstructions = await squad.getInstructions([
606-
ix1PubKey,
607-
ix2PubKey,
608-
]);
609-
610-
console.log(onChainInstructions[0]);
611-
console.log(onChainInstructions[1]);
612-
613605
const [messagePDA] = getIxAuthorityPDA(
614606
txPubkey,
615607
new anchor.BN(1),

0 commit comments

Comments
 (0)