From 9390eb799b316fc9ba821537076b2347490bfe04 Mon Sep 17 00:00:00 2001 From: isstuev Date: Wed, 6 Sep 2023 10:15:38 -0300 Subject: [PATCH] support no-hex revert reason --- lib/regexp.ts | 2 ++ ui/tx/details/TxRevertReason.tsx | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/regexp.ts b/lib/regexp.ts index a213d8f1fd..a8be3869a8 100644 --- a/lib/regexp.ts +++ b/lib/regexp.ts @@ -1,3 +1,5 @@ export const URL_PREFIX = /^https?:\/\//i; export const IPFS_PREFIX = /^ipfs:\/\//i; + +export const HEX_REGEXP = /^(?:0x)?[\da-fA-F]+$/; diff --git a/ui/tx/details/TxRevertReason.tsx b/ui/tx/details/TxRevertReason.tsx index 3c57314241..bec52e7dac 100644 --- a/ui/tx/details/TxRevertReason.tsx +++ b/ui/tx/details/TxRevertReason.tsx @@ -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; @@ -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 { props.raw }; + } + const decoded = hexToUtf8(props.raw); + return (