diff --git a/src/pages/Account/Tabs/ModulesTab/Contract.tsx b/src/pages/Account/Tabs/ModulesTab/Contract.tsx index 51b12dce..ef772413 100644 --- a/src/pages/Account/Tabs/ModulesTab/Contract.tsx +++ b/src/pages/Account/Tabs/ModulesTab/Contract.tsx @@ -112,9 +112,7 @@ function Contract({address, isRead}: {address: string; isRead: boolean}) { } const fns = module.abi.exposed_functions.filter((fn) => - isRead - ? fn.is_view - : fn.is_entry && fn.params.length > 0 && fn.params[0] === "&signer", + isRead ? fn.is_view : fn.is_entry, ); if (fns.length === 0) { return acc; @@ -294,6 +292,8 @@ function RunContractForm({ const {submitTransaction, transactionResponse, transactionInProcess} = useSubmitTransaction(); + const fnParams = removeSignerParam(fn); + const onSubmit: SubmitHandler = async (data) => { logEvent("write_button_clicked", fn.name); const payload: Types.TransactionPayload = { @@ -301,8 +301,7 @@ function RunContractForm({ function: `${module.address}::${module.name}::${fn.name}`, type_arguments: data.typeArgs, arguments: data.args.map((arg, i) => { - // use i+1 because the first argument is the signer - const type = fn.params[i + 1]; + const type = fnParams[i]; if (type.includes("vector")) { // when it's a vector, we support both hex and javascript array format return type === "vector" && arg.trim().startsWith("0x") @@ -633,6 +632,9 @@ function ContractForm({ }, }); + const fnParams = removeSignerParam(fn); + const hasSigner = fnParams.length !== fn.params.length; + useEffect(() => { setFormValid(isValid); }, [isValid, setFormValid]); @@ -668,7 +670,7 @@ function ContractForm({ )} /> ))} - {fn.is_entry && + {hasSigner && (account ? ( ))} - {fn.params.slice(fn.is_entry ? 1 : 0).map((param, i) => { + {fnParams.map((param, i) => { return ( p !== "signer" && p !== "&signer"); +} + export default Contract;