Commit c7106b77 authored by tom's avatar tom

fix decoded input data

parent 1d6236ad
...@@ -39,5 +39,11 @@ export const withIndexedFields: DecodedInput = { ...@@ -39,5 +39,11 @@ export const withIndexedFields: DecodedInput = {
type: 'uint256', type: 'uint256',
value: '31567373703130350', value: '31567373703130350',
}, },
{
indexed: true,
name: 'inputArray',
type: 'uint256[2][2]',
value: [ [ '1', '1' ], [ '1', '1' ] ],
},
], ],
}; };
...@@ -7,6 +7,6 @@ export interface DecodedInput { ...@@ -7,6 +7,6 @@ export interface DecodedInput {
export interface DecodedInputParams { export interface DecodedInputParams {
name: string; name: string;
type: string; type: string;
value: string; value: string | Array<unknown> | Record<string, unknown>;
indexed?: boolean; indexed?: boolean;
} }
...@@ -155,19 +155,37 @@ const LogDecodedInputData = ({ data }: Props) => { ...@@ -155,19 +155,37 @@ const LogDecodedInputData = ({ data }: Props) => {
</> </>
) } ) }
{ data.parameters.map(({ name, type, value, indexed }, index) => { { data.parameters.map(({ name, type, value, indexed }, index) => {
const content = (() => {
if (type === 'address' && typeof value === 'string') {
return ( return (
<TableRow key={ name } name={ name } type={ type } isLast={ index === data.parameters.length - 1 } indexed={ indexed }>
{ type === 'address' ? (
<Address justifyContent="space-between"> <Address justifyContent="space-between">
<AddressLink type="address" hash={ value }/> <AddressLink type="address" hash={ value }/>
<CopyToClipboard text={ value }/> <CopyToClipboard text={ value }/>
</Address> </Address>
) : ( );
}
if (typeof value === 'object') {
const text = JSON.stringify(value, undefined, 4);
return (
<Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all">
<div>{ text }</div>
<CopyToClipboard text={ text }/>
</Flex>
);
}
return (
<Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all"> <Flex alignItems="flex-start" justifyContent="space-between" whiteSpace="normal" wordBreak="break-all">
<Text>{ String(value) }</Text> <Text>{ value }</Text>
<CopyToClipboard text={ value }/> <CopyToClipboard text={ value }/>
</Flex> </Flex>
) } );
})();
return (
<TableRow key={ name } name={ name } type={ type } isLast={ index === data.parameters.length - 1 } indexed={ indexed }>
{ content }
</TableRow> </TableRow>
); );
}) } }) }
......
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