Преглед изворни кода

Fix constructor for multisig transaction (#476)

guibescos пре 2 година
родитељ
комит
5641008356

+ 2 - 2
xc-admin/packages/xc-admin-common/src/__tests__/WormholeMultisigInstruction.test.ts

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

+ 12 - 3
xc-admin/packages/xc-admin-common/src/multisig_transaction/index.ts

@@ -39,9 +39,18 @@ export class MultisigParser {
   readonly pythOracleAddress: PublicKey;
   readonly wormholeBridgeAddress: PublicKey | undefined;
 
-  constructor(cluster: PythCluster) {
-    this.pythOracleAddress = getPythProgramKeyForCluster(cluster);
-    this.wormholeBridgeAddress = WORMHOLE_ADDRESS[cluster];
+  constructor(
+    pythOracleAddress: PublicKey,
+    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 {