Skip to content

Commit

Permalink
fix: pass arguments for the contract functions in the correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
tx-nikola committed Dec 4, 2024
1 parent 9317a70 commit fa4146d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/app/src/composables/useContractInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
};
Expand Down

0 comments on commit fa4146d

Please sign in to comment.