From 0cd370b90eb53bd386b051d9aa1e5a6324ebcc9e Mon Sep 17 00:00:00 2001 From: Santiago Gonzalez Date: Tue, 2 Apr 2024 20:34:49 -0500 Subject: [PATCH] fix multicall tx ordering --- libs/tx-builder/src/utils/multicall.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/tx-builder/src/utils/multicall.ts b/libs/tx-builder/src/utils/multicall.ts index 850894ae..6e775587 100644 --- a/libs/tx-builder/src/utils/multicall.ts +++ b/libs/tx-builder/src/utils/multicall.ts @@ -169,8 +169,13 @@ const handleMulticallFormActions = ({ if (!validTxs.length) { throw new Error('No actions found'); } - // TODO: sort by tx.actionId.index - return validTxs.map((actionId: string) => { + const sortedTxs = validTxs.sort((actionA: string, actionB: string) => + Number(appState.formValues.tx[actionA].index) > + Number(appState.formValues.tx[actionB].index) + ? 1 + : -1 + ); + return sortedTxs.map((actionId: string) => { const action = appState.formValues.tx[actionId]; const { to, data, value, operation } = action; return {