diff --git a/types/api/contract.ts b/types/api/contract.ts index b7589f618e..9a88813175 100644 --- a/types/api/contract.ts +++ b/types/api/contract.ts @@ -55,7 +55,7 @@ export interface SmartContractExternalLibrary { export interface SmartContractMethodBase { inputs: Array; - outputs: Array; + outputs?: Array; constant: boolean; name: string; stateMutability: SmartContractMethodStateMutability; diff --git a/ui/address/contract/ContractMethodCallable.tsx b/ui/address/contract/ContractMethodCallable.tsx index a9ce55bf0e..d0e423ecc4 100644 --- a/ui/address/contract/ContractMethodCallable.tsx +++ b/ui/address/contract/ContractMethodCallable.tsx @@ -82,6 +82,8 @@ const ContractMethodCallable = ({ data, onSubmit, }); }, [ inputs, onSubmit, data, isWrite ]); + const outputs = 'outputs' in data && data.outputs ? data.outputs : []; + return ( @@ -163,16 +165,16 @@ const ContractMethodCallable = ({ data, onSubmit, - { 'outputs' in data && !isWrite && data.outputs.length > 0 && ( + { !isWrite && outputs.length > 0 && (

- { data.outputs.map(({ type, name }, index) => { + { outputs.map(({ type, name }, index) => { return ( <> { name } { name ? `(${ type })` : type } - { index < data.outputs.length - 1 && , } + { index < outputs.length - 1 && , } ); }) } diff --git a/ui/address/contract/ContractRead.tsx b/ui/address/contract/ContractRead.tsx index 88330196ea..412c409f6d 100644 --- a/ui/address/contract/ContractRead.tsx +++ b/ui/address/contract/ContractRead.tsx @@ -63,7 +63,7 @@ const ContractRead = () => { return { item.error }; } - if (item.outputs.some(({ value }) => value !== undefined && value !== null)) { + if (item.outputs?.some(({ value }) => value !== undefined && value !== null)) { return ( { item.outputs.map((output, index) => ) } diff --git a/ui/address/contract/useContractAbi.tsx b/ui/address/contract/useContractAbi.tsx index 7f85bb4d8e..d2bd337951 100644 --- a/ui/address/contract/useContractAbi.tsx +++ b/ui/address/contract/useContractAbi.tsx @@ -50,7 +50,7 @@ export default function useContractAbi({ addressHash, isProxy, isCustomAbi }: Pa } if (isCustomAbi) { - return customInfo; + return customInfo as Abi; } return contractInfo?.abi ?? undefined;