From 20b18e291de79f251fafdbe1104e89939c84a429 Mon Sep 17 00:00:00 2001 From: guibescos <59208140+guibescos@users.noreply.github.com> Date: Tue, 21 Feb 2023 11:55:44 -0600 Subject: [PATCH] Batch transactions (#619) --- .../packages/xc_admin_common/src/propose.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/governance/xc_admin/packages/xc_admin_common/src/propose.ts b/governance/xc_admin/packages/xc_admin_common/src/propose.ts index 52a046ff..a3b5e27d 100644 --- a/governance/xc_admin/packages/xc_admin_common/src/propose.ts +++ b/governance/xc_admin/packages/xc_admin_common/src/propose.ts @@ -20,6 +20,7 @@ import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa"; 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 SIZE_OF_SIGNED_BATCH = 30; type SquadInstruction = { instruction: TransactionInstruction; @@ -111,15 +112,18 @@ export async function proposeInstructions( ixToSend.push(await squad.buildApproveTransaction(vault, newProposalAddress)); const txToSend = batchIntoTransactions(ixToSend); - await new AnchorProvider( - squad.connection, - squad.wallet, - AnchorProvider.defaultOptions() - ).sendAll( - txToSend.map((tx) => { - return { tx, signers: [] }; - }) - ); + + for (let i = 0; i < txToSend.length; i += SIZE_OF_SIGNED_BATCH) { + await new AnchorProvider( + squad.connection, + squad.wallet, + AnchorProvider.defaultOptions() + ).sendAll( + txToSend.slice(i, i + SIZE_OF_SIGNED_BATCH).map((tx) => { + return { tx, signers: [] }; + }) + ); + } return newProposalAddress; }