Commit e6354ba1 authored by tom's avatar tom

tx revert reason

parent 23e48718
...@@ -3,6 +3,11 @@ import type { DecodedInput } from './decodedInput'; ...@@ -3,6 +3,11 @@ import type { DecodedInput } from './decodedInput';
import type { Fee } from './fee'; import type { Fee } from './fee';
import type { TokenTransfer } from './tokenTransfer'; import type { TokenTransfer } from './tokenTransfer';
export type TransactionRevertReason = {
raw: string;
decoded: string;
} | DecodedInput;
export interface Transaction { export interface Transaction {
hash: string; hash: string;
result: string; result: string;
...@@ -27,10 +32,7 @@ export interface Transaction { ...@@ -27,10 +32,7 @@ export interface Transaction {
tx_burnt_fee: number | null; tx_burnt_fee: number | null;
nonce: number; nonce: number;
position: number; position: number;
revert_reason: { revert_reason: TransactionRevertReason | null;
raw: string;
decoded: string;
} | null;
raw_input: string; raw_input: string;
decoded_input: DecodedInput | null; decoded_input: DecodedInput | null;
token_transfers: Array<TokenTransfer> | null; token_transfers: Array<TokenTransfer> | null;
......
...@@ -111,45 +111,49 @@ const TxDecodedInputData = ({ data }: Props) => { ...@@ -111,45 +111,49 @@ const TxDecodedInputData = ({ data }: Props) => {
{ data.method_call } { data.method_call }
</GridItem> </GridItem>
{ /* TABLE INSIDE OF BLOCK */ } { /* TABLE INSIDE OF BLOCK */ }
<GridItem { data.parameters.length > 0 && (
pl={ PADDING } <>
pr={ GAP } <GridItem
pt={ PADDING } pl={ PADDING }
pb={ 1 } pr={ GAP }
bgColor={ bgColor } pt={ PADDING }
fontWeight={ 600 } pb={ 1 }
> bgColor={ bgColor }
fontWeight={ 600 }
>
Name Name
</GridItem> </GridItem>
<GridItem <GridItem
pr={ GAP } pr={ GAP }
pt={ PADDING } pt={ PADDING }
pb={ 1 } pb={ 1 }
bgColor={ bgColor } bgColor={ bgColor }
fontWeight={ 600 } fontWeight={ 600 }
> >
Type Type
</GridItem> </GridItem>
{ hasIndexed && ( { hasIndexed && (
<GridItem <GridItem
pr={ GAP } pr={ GAP }
pt={ PADDING } pt={ PADDING }
pb={ 1 } pb={ 1 }
bgColor={ bgColor } bgColor={ bgColor }
fontWeight={ 600 } fontWeight={ 600 }
> >
Inde<wbr/>xed? Inde<wbr/>xed?
</GridItem> </GridItem>
) } ) }
<GridItem <GridItem
pr={ PADDING } pr={ PADDING }
pt={ PADDING } pt={ PADDING }
pb={ 1 } pb={ 1 }
bgColor={ bgColor } bgColor={ bgColor }
fontWeight={ 600 } fontWeight={ 600 }
> >
Data Data
</GridItem> </GridItem>
</>
) }
{ data.parameters.map(({ name, type, value, indexed }, index) => { { data.parameters.map(({ name, type, value, indexed }, index) => {
return ( return (
<TableRow key={ name } name={ name } type={ type } isLast={ index === data.parameters.length - 1 } indexed={ indexed }> <TableRow key={ name } name={ name } type={ type } isLast={ index === data.parameters.length - 1 } indexed={ indexed }>
......
...@@ -31,6 +31,7 @@ import TextSeparator from 'ui/shared/TextSeparator'; ...@@ -31,6 +31,7 @@ import TextSeparator from 'ui/shared/TextSeparator';
import TxStatus from 'ui/shared/TxStatus'; import TxStatus from 'ui/shared/TxStatus';
import Utilization from 'ui/shared/Utilization'; import Utilization from 'ui/shared/Utilization';
import TxDetailsSkeleton from 'ui/tx/details/TxDetailsSkeleton'; import TxDetailsSkeleton from 'ui/tx/details/TxDetailsSkeleton';
import TxRevertReason from 'ui/tx/details/TxRevertReason';
import TokenTransfer from 'ui/tx/TokenTransfer'; import TokenTransfer from 'ui/tx/TokenTransfer';
import TxDecodedInputData from 'ui/tx/TxDecodedInputData'; import TxDecodedInputData from 'ui/tx/TxDecodedInputData';
...@@ -85,6 +86,14 @@ const TxDetails = () => { ...@@ -85,6 +86,14 @@ const TxDetails = () => {
> >
<TxStatus status={ data.status } errorText={ data.status === 'error' ? data.result : undefined }/> <TxStatus status={ data.status } errorText={ data.status === 'error' ? data.result : undefined }/>
</DetailsInfoItem> </DetailsInfoItem>
{ data.revert_reason && (
<DetailsInfoItem
title="Revert reason"
hint="The revert reason of the transaction."
>
<TxRevertReason { ...data.revert_reason }/>
</DetailsInfoItem>
) }
<DetailsInfoItem <DetailsInfoItem
title="Block" title="Block"
hint="Block number containing the transaction." hint="Block number containing the transaction."
......
import { Grid, GridItem, useColorModeValue } from '@chakra-ui/react';
import React from 'react';
import type { TransactionRevertReason } from 'types/api/transaction';
import TxDecodedInputData from 'ui/tx/TxDecodedInputData';
type Props = TransactionRevertReason;
const TxRevertReason = (props: Props) => {
const bgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');
if ('raw' in props) {
return (
<Grid
bgColor={ bgColor }
p={ 4 }
fontSize="sm"
borderRadius="md"
templateColumns="auto minmax(0, 1fr)"
rowGap={ 2 }
columnGap={ 4 }
whiteSpace="normal"
>
<GridItem fontWeight={ 500 }>Raw:</GridItem>
<GridItem>{ props.raw }</GridItem>
<GridItem fontWeight={ 500 }>Decoded:</GridItem>
<GridItem>{ props.decoded }</GridItem>
</Grid>
);
}
return <TxDecodedInputData data={ props }/>;
};
export default React.memo(TxRevertReason);
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