diff --git a/packages/app/src/composables/useContractInteraction.ts b/packages/app/src/composables/useContractInteraction.ts index dea7b67cf..a6050b0c6 100644 --- a/packages/app/src/composables/useContractInteraction.ts +++ b/packages/app/src/composables/useContractInteraction.ts @@ -45,16 +45,16 @@ 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 methodArguments = abiFragmentNames.map((abiFragmentName) => { + if (params[abiFragmentName] === "true") { + return true; + } + if (params[abiFragmentName] === "false") { + return false; + } + return params[abiFragmentName]; + }); const valueMethodOption = { value: parseEther((params[PAYABLE_AMOUNT_PARAM_NAME] as string) ?? "0"), }; diff --git a/packages/app/tests/composables/useContractInteraction.spec.ts b/packages/app/tests/composables/useContractInteraction.spec.ts index 55a07fd4f..d3cc5b31e 100644 --- a/packages/app/tests/composables/useContractInteraction.spec.ts +++ b/packages/app/tests/composables/useContractInteraction.spec.ts @@ -115,7 +115,7 @@ describe("useContractInteraction:", () => { }, { [PAYABLE_AMOUNT_PARAM_NAME]: "0.1", - address: ["0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b"], + spender: ["0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b"], } ); expect(mock.mock.lastCall).toEqual([ @@ -162,7 +162,7 @@ describe("useContractInteraction:", () => { "0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b", { ...abiFragment, - inputs: [], + inputs: [{ internalType: "bool", name: "bool", type: "bool" }], stateMutability: "payable", }, {