Fix constructor for multisig transaction (#476)

This commit is contained in:
guibescos 2023-01-11 13:06:42 -06:00 committed by GitHub
parent d1f5e5955a
commit 5641008356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -35,7 +35,7 @@ test("Wormhole multisig instruction parse: send message without governance paylo
AnchorProvider.defaultOptions() AnchorProvider.defaultOptions()
) )
); );
const parser = new MultisigParser(cluster); const parser = MultisigParser.fromCluster(cluster);
wormholeProgram.methods wormholeProgram.methods
.postMessage(1, Buffer.from([0]), 1) .postMessage(1, Buffer.from([0]), 1)
@ -182,7 +182,7 @@ test("Wormhole multisig instruction parse: send message with governance payload"
AnchorProvider.defaultOptions() AnchorProvider.defaultOptions()
) )
); );
const parser = new MultisigParser(cluster); const parser = MultisigParser.fromCluster(cluster);
const executePostedVaaArgs: ExecutePostedVaaArgs = { const executePostedVaaArgs: ExecutePostedVaaArgs = {
targetChainId: "pythnet" as ChainName, targetChainId: "pythnet" as ChainName,

View File

@ -39,9 +39,18 @@ export class MultisigParser {
readonly pythOracleAddress: PublicKey; readonly pythOracleAddress: PublicKey;
readonly wormholeBridgeAddress: PublicKey | undefined; readonly wormholeBridgeAddress: PublicKey | undefined;
constructor(cluster: PythCluster) { constructor(
this.pythOracleAddress = getPythProgramKeyForCluster(cluster); pythOracleAddress: PublicKey,
this.wormholeBridgeAddress = WORMHOLE_ADDRESS[cluster]; wormholeBridgeAddress: PublicKey | undefined
) {
this.pythOracleAddress = pythOracleAddress;
this.wormholeBridgeAddress = wormholeBridgeAddress;
}
static fromCluster(cluster: PythCluster): MultisigParser {
return new MultisigParser(
getPythProgramKeyForCluster(cluster),
WORMHOLE_ADDRESS[cluster]
);
} }
parseInstruction(instruction: TransactionInstruction): MultisigInstruction { parseInstruction(instruction: TransactionInstruction): MultisigInstruction {