Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support no-hex revert reason #1148

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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