Skip to content

Commit

Permalink
split txs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagaprasadvr committed Jun 3, 2024
1 parent 2bc97bc commit 1910d01
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,27 @@ export const revertSettlementPreparationOperationHandler: OperationHandler<Rever
convergence,
scope.confirmOptions
);

const output = await builder.sendAndConfirm(convergence, confirmOptions);
scope.throwIfCanceled();

return output;
if (builder.checkTransactionFits()) {
const output = await builder.sendAndConfirm(
convergence,
confirmOptions
);
scope.throwIfCanceled();

return output;
}
const builders = builder.divideToMultipleBuildersThatFit();
const latestBlockhash = await convergence.rpc().getLatestBlockhash();
const txs = builders.map((b) => b.toTransaction(latestBlockhash));
const signedTxs = await convergence.identity().signAllTransactions(txs);
let output: SendAndConfirmTransactionResponse | undefined;
for (const signedTx of signedTxs) {
output = await convergence.rpc().serializeAndSendTransaction(signedTx);
}
if (!output) {
throw new Error('No transaction was sent');
}
return { response: output };
},
};

Expand Down

0 comments on commit 1910d01

Please sign in to comment.