Skip to content

Commit

Permalink
Merge pull request #1148 from blockscout/tx-revert-reason-hex-no-hex
Browse files Browse the repository at this point in the history
support no-hex revert reason
  • Loading branch information
isstuev authored Sep 8, 2023
2 parents 24d14e8 + 9390eb7 commit c367613
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/regexp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const URL_PREFIX = /^https?:\/\//i;

export const IPFS_PREFIX = /^ipfs:\/\//i;

export const HEX_REGEXP = /^(?:0x)?[\da-fA-F]+$/;
8 changes: 7 additions & 1 deletion ui/tx/details/TxRevertReason.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Grid, GridItem, useColorModeValue } from '@chakra-ui/react';
import { Grid, GridItem, Text, useColorModeValue } from '@chakra-ui/react';
import React from 'react';

import type { TransactionRevertReason } from 'types/api/transaction';

import hexToUtf8 from 'lib/hexToUtf8';
import { HEX_REGEXP } from 'lib/regexp';
import LogDecodedInputData from 'ui/shared/logs/LogDecodedInputData';

type Props = TransactionRevertReason;
Expand All @@ -12,7 +13,12 @@ const TxRevertReason = (props: Props) => {
const bgColor = useColorModeValue('blackAlpha.50', 'whiteAlpha.50');

if ('raw' in props) {
if (!HEX_REGEXP.test(props.raw)) {
return <Text>{ props.raw }</Text>;
}

const decoded = hexToUtf8(props.raw);

return (
<Grid
bgColor={ bgColor }
Expand Down

0 comments on commit c367613

Please sign in to comment.