From fa4146d331cc842e2d8aab5bf894107fccdca6c0 Mon Sep 17 00:00:00 2001 From: Nikola Pavlov <144679078+tx-nikola@users.noreply.github.com> Date: Wed, 4 Dec 2024 13:52:18 +0100 Subject: [PATCH] fix: pass arguments for the contract functions in the correct order --- .../src/composables/useContractInteraction.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/app/src/composables/useContractInteraction.ts b/packages/app/src/composables/useContractInteraction.ts index dea7b67cf..e87c434ea 100644 --- a/packages/app/src/composables/useContractInteraction.ts +++ b/packages/app/src/composables/useContractInteraction.ts @@ -45,16 +45,19 @@ export default (context = useContext()) => { const signer = await getL2Signer(); const contract = new Contract(address, [abiFragment], signer!); const method = contract[abiFragment.name]; - const methodArguments = Object.entries(params) - .filter(([key]) => key !== PAYABLE_AMOUNT_PARAM_NAME) - .map(([, inputValue]) => { - if (inputValue === "true") { - inputValue = true; - } else if (inputValue === "false") { - inputValue = false; - } - return inputValue; - }); + const abiFragmentNames = abiFragment.inputs.map((abiInput) => abiInput.name); + const filteredParams = Object.fromEntries( + Object.entries(params).filter(([key]) => key !== PAYABLE_AMOUNT_PARAM_NAME) + ); + const methodArguments = abiFragmentNames.map((abiFragmentName) => { + if (filteredParams[abiFragmentName] === "true") { + return true; + } else if (filteredParams[abiFragmentName] === "false") { + return false; + } else { + return filteredParams[abiFragmentName]; + } + }); const valueMethodOption = { value: parseEther((params[PAYABLE_AMOUNT_PARAM_NAME] as string) ?? "0"), };