|
@@ -17,7 +17,7 @@ import {
|
|
|
deriveFeeCollectorKey,
|
|
deriveFeeCollectorKey,
|
|
|
} from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole";
|
|
} from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole";
|
|
|
import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa";
|
|
import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa";
|
|
|
-import { getOpsKey, PRICE_FEED_OPS_KEY } from "./multisig";
|
|
|
|
|
|
|
+import { getOpsKey, getProposalInstructions } from "./multisig";
|
|
|
import { PythCluster } from "@pythnetwork/client/lib/cluster";
|
|
import { PythCluster } from "@pythnetwork/client/lib/cluster";
|
|
|
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
|
|
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
|
|
|
import SquadsMesh, { getIxAuthorityPDA, getTxPDA } from "@sqds/mesh";
|
|
import SquadsMesh, { getIxAuthorityPDA, getTxPDA } from "@sqds/mesh";
|
|
@@ -203,29 +203,38 @@ export class MultisigVault {
|
|
|
* will have `this.getVaultAuthorityPda()` as its emitter address.
|
|
* will have `this.getVaultAuthorityPda()` as its emitter address.
|
|
|
* @param payloads array of the bytes to send as the wormhole message's payload.
|
|
* @param payloads array of the bytes to send as the wormhole message's payload.
|
|
|
* @param messagePayer key used as the payer for the wormhole message instruction
|
|
* @param messagePayer key used as the payer for the wormhole message instruction
|
|
|
|
|
+ * @param proposalAddress the proposal address to use. If not provided, a new proposal will be created. This is useful when because of RPC issues the script can not run until the end successfully.
|
|
|
* @returns the newly created proposal's public key
|
|
* @returns the newly created proposal's public key
|
|
|
*/
|
|
*/
|
|
|
public async proposeWormholeMultipleMessagesWithPayer(
|
|
public async proposeWormholeMultipleMessagesWithPayer(
|
|
|
payloads: Buffer[],
|
|
payloads: Buffer[],
|
|
|
- messagePayer: PublicKey
|
|
|
|
|
|
|
+ messagePayer: PublicKey,
|
|
|
|
|
+ proposalAddress?: PublicKey
|
|
|
): Promise<PublicKey> {
|
|
): Promise<PublicKey> {
|
|
|
const msAccount = await this.getMultisigAccount();
|
|
const msAccount = await this.getMultisigAccount();
|
|
|
|
|
|
|
|
let ixToSend: TransactionInstruction[] = [];
|
|
let ixToSend: TransactionInstruction[] = [];
|
|
|
- const [proposalIx, newProposalAddress] = await this.createProposalIx(
|
|
|
|
|
- msAccount.transactionIndex + 1
|
|
|
|
|
- );
|
|
|
|
|
- ixToSend.push(proposalIx);
|
|
|
|
|
|
|
+ let startingIndex = 0;
|
|
|
|
|
+ if (proposalAddress === undefined) {
|
|
|
|
|
+ const [proposalIx, newProposalAddress] = await this.createProposalIx(
|
|
|
|
|
+ msAccount.transactionIndex + 1
|
|
|
|
|
+ );
|
|
|
|
|
+ ixToSend.push(proposalIx);
|
|
|
|
|
+ proposalAddress = newProposalAddress;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const transaction = await this.squad.getTransaction(proposalAddress);
|
|
|
|
|
+ startingIndex = transaction.instructionIndex;
|
|
|
|
|
+ }
|
|
|
if (payloads.length > MAX_INSTRUCTIONS_PER_PROPOSAL)
|
|
if (payloads.length > MAX_INSTRUCTIONS_PER_PROPOSAL)
|
|
|
throw new Error(
|
|
throw new Error(
|
|
|
"Too many messages in proposal, multiple proposal not supported yet"
|
|
"Too many messages in proposal, multiple proposal not supported yet"
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- for (let i = 0; i < payloads.length; i++) {
|
|
|
|
|
|
|
+ for (let i = startingIndex; i < payloads.length; i++) {
|
|
|
const instructionToPropose = await getPostMessageInstruction(
|
|
const instructionToPropose = await getPostMessageInstruction(
|
|
|
this.squad,
|
|
this.squad,
|
|
|
this.vault,
|
|
this.vault,
|
|
|
- newProposalAddress,
|
|
|
|
|
|
|
+ proposalAddress,
|
|
|
1 + i,
|
|
1 + i,
|
|
|
this.wormholeAddress()!,
|
|
this.wormholeAddress()!,
|
|
|
payloads[i],
|
|
payloads[i],
|
|
@@ -234,7 +243,7 @@ export class MultisigVault {
|
|
|
ixToSend.push(
|
|
ixToSend.push(
|
|
|
await this.squad.buildAddInstruction(
|
|
await this.squad.buildAddInstruction(
|
|
|
this.vault,
|
|
this.vault,
|
|
|
- newProposalAddress,
|
|
|
|
|
|
|
+ proposalAddress,
|
|
|
instructionToPropose.instruction,
|
|
instructionToPropose.instruction,
|
|
|
1 + i,
|
|
1 + i,
|
|
|
instructionToPropose.authorityIndex,
|
|
instructionToPropose.authorityIndex,
|
|
@@ -243,8 +252,8 @@ export class MultisigVault {
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
- ixToSend.push(await this.activateProposalIx(newProposalAddress));
|
|
|
|
|
- ixToSend.push(await this.approveProposalIx(newProposalAddress));
|
|
|
|
|
|
|
+ ixToSend.push(await this.activateProposalIx(proposalAddress));
|
|
|
|
|
+ ixToSend.push(await this.approveProposalIx(proposalAddress));
|
|
|
|
|
|
|
|
const txToSend = batchIntoTransactions(ixToSend);
|
|
const txToSend = batchIntoTransactions(ixToSend);
|
|
|
for (let i = 0; i < txToSend.length; i += SIZE_OF_SIGNED_BATCH) {
|
|
for (let i = 0; i < txToSend.length; i += SIZE_OF_SIGNED_BATCH) {
|
|
@@ -254,7 +263,7 @@ export class MultisigVault {
|
|
|
})
|
|
})
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
- return newProposalAddress;
|
|
|
|
|
|
|
+ return proposalAddress;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|