From 022ff359755e9e98af16a2d7434826617602fa98 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Tue, 10 Aug 2021 16:26:00 -0300 Subject: [PATCH] Add decode to utf-8 input option --- src/transaction/Details.tsx | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 6a1f4d6..500d45e 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -1,5 +1,6 @@ -import React from "react"; +import React, { useMemo, useState } from "react"; import { formatEther } from "@ethersproject/units"; +import { toUtf8String } from "@ethersproject/strings"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCheckCircle } from "@fortawesome/free-solid-svg-icons/faCheckCircle"; import { faCube } from "@fortawesome/free-solid-svg-icons/faCube"; @@ -40,6 +41,17 @@ const Details: React.FC = ({ const hasEIP1559 = txData.blockBaseFeePerGas !== undefined && txData.blockBaseFeePerGas !== null; + const [inputMode, setInputMode] = useState(0); + + const utfInput = useMemo(() => { + try { + return txData && toUtf8String(txData.data); + } catch (err) { + console.error("Error while converting input data to string"); + console.error(err); + return ""; + } + }, [txData]); return ( @@ -252,11 +264,31 @@ const Details: React.FC = ({ N/A -