Skip to content

Commit 20b18e2

Browse files
authored
Batch transactions (#619)
1 parent b34ec4e commit 20b18e2

File tree

1 file changed

+13
-9
lines changed
  • governance/xc_admin/packages/xc_admin_common/src

1 file changed

+13
-9
lines changed

governance/xc_admin/packages/xc_admin_common/src/propose.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa";
2020
import { OPS_KEY } from "./multisig";
2121

2222
export const MAX_EXECUTOR_PAYLOAD_SIZE = PACKET_DATA_SIZE - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal
23+
export const SIZE_OF_SIGNED_BATCH = 30;
2324

2425
type SquadInstruction = {
2526
instruction: TransactionInstruction;
@@ -111,15 +112,18 @@ export async function proposeInstructions(
111112
ixToSend.push(await squad.buildApproveTransaction(vault, newProposalAddress));
112113

113114
const txToSend = batchIntoTransactions(ixToSend);
114-
await new AnchorProvider(
115-
squad.connection,
116-
squad.wallet,
117-
AnchorProvider.defaultOptions()
118-
).sendAll(
119-
txToSend.map((tx) => {
120-
return { tx, signers: [] };
121-
})
122-
);
115+
116+
for (let i = 0; i < txToSend.length; i += SIZE_OF_SIGNED_BATCH) {
117+
await new AnchorProvider(
118+
squad.connection,
119+
squad.wallet,
120+
AnchorProvider.defaultOptions()
121+
).sendAll(
122+
txToSend.slice(i, i + SIZE_OF_SIGNED_BATCH).map((tx) => {
123+
return { tx, signers: [] };
124+
})
125+
);
126+
}
123127
return newProposalAddress;
124128
}
125129

0 commit comments

Comments
 (0)