Batch transactions (#619)
This commit is contained in:
parent
b34ec4e882
commit
20b18e291d
|
@ -20,6 +20,7 @@ import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa";
|
||||||
import { OPS_KEY } from "./multisig";
|
import { OPS_KEY } from "./multisig";
|
||||||
|
|
||||||
export const MAX_EXECUTOR_PAYLOAD_SIZE = PACKET_DATA_SIZE - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal
|
export const MAX_EXECUTOR_PAYLOAD_SIZE = PACKET_DATA_SIZE - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal
|
||||||
|
export const SIZE_OF_SIGNED_BATCH = 30;
|
||||||
|
|
||||||
type SquadInstruction = {
|
type SquadInstruction = {
|
||||||
instruction: TransactionInstruction;
|
instruction: TransactionInstruction;
|
||||||
|
@ -111,15 +112,18 @@ export async function proposeInstructions(
|
||||||
ixToSend.push(await squad.buildApproveTransaction(vault, newProposalAddress));
|
ixToSend.push(await squad.buildApproveTransaction(vault, newProposalAddress));
|
||||||
|
|
||||||
const txToSend = batchIntoTransactions(ixToSend);
|
const txToSend = batchIntoTransactions(ixToSend);
|
||||||
await new AnchorProvider(
|
|
||||||
squad.connection,
|
for (let i = 0; i < txToSend.length; i += SIZE_OF_SIGNED_BATCH) {
|
||||||
squad.wallet,
|
await new AnchorProvider(
|
||||||
AnchorProvider.defaultOptions()
|
squad.connection,
|
||||||
).sendAll(
|
squad.wallet,
|
||||||
txToSend.map((tx) => {
|
AnchorProvider.defaultOptions()
|
||||||
return { tx, signers: [] };
|
).sendAll(
|
||||||
})
|
txToSend.slice(i, i + SIZE_OF_SIGNED_BATCH).map((tx) => {
|
||||||
);
|
return { tx, signers: [] };
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
return newProposalAddress;
|
return newProposalAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue