Commit 8e8383c5 authored by tom's avatar tom

handle boolean type in output result of contract method read

parent 28f41ddd
......@@ -91,7 +91,7 @@ export interface SmartContractMethodInput {
}
export interface SmartContractMethodOutput extends SmartContractMethodInput {
value?: string;
value?: string | boolean;
}
export interface SmartContractQueryMethodReadSuccess {
......
......@@ -17,11 +17,11 @@ interface Props {
const ContractMethodStatic = ({ data }: Props) => {
const isBigInt = data.type.includes('int256') || data.type.includes('int128');
const [ value, setValue ] = React.useState(isBigInt && data.value ? BigNumber(data.value).toFixed() : data.value);
const [ value, setValue ] = React.useState(isBigInt && data.value && typeof data.value === 'string' ? BigNumber(data.value).toFixed() : data.value);
const [ label, setLabel ] = React.useState('WEI');
const handleCheckboxChange = React.useCallback((event: ChangeEvent<HTMLInputElement>) => {
if (!data.value) {
if (!data.value || typeof data.value !== 'string') {
return;
}
......@@ -35,7 +35,7 @@ const ContractMethodStatic = ({ data }: Props) => {
}, [ data.value ]);
const content = (() => {
if (data.type === 'address' && data.value) {
if (typeof data.value === 'string' && data.type === 'address' && data.value) {
return (
<Address>
<AddressLink type="address" hash={ data.value }/>
......@@ -44,7 +44,7 @@ const ContractMethodStatic = ({ data }: Props) => {
);
}
return <chakra.span wordBreak="break-all">({ data.type }): { value }</chakra.span>;
return <chakra.span wordBreak="break-all">({ data.type }): { String(value) }</chakra.span>;
})();
return (
......
......@@ -61,7 +61,7 @@ const ContractRead = ({ addressHash, isProxy, isCustomAbi }: Props) => {
return <Alert status="error" fontSize="sm" wordBreak="break-word">{ item.error }</Alert>;
}
if (item.outputs.some(({ value }) => value)) {
if (item.outputs.some(({ value }) => value !== undefined && value !== null)) {
return (
<Flex flexDir="column" rowGap={ 1 }>
{ item.outputs.map((output, index) => <ContractMethodConstant key={ index } data={ output }/>) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment