From 462c9d239a59620719d4d47c7fdcf7e873ddf34b Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 24 Apr 2023 19:01:27 +0530 Subject: [PATCH] error color --- apps/etherscan/src/app/views/ReceiptsView.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/etherscan/src/app/views/ReceiptsView.tsx b/apps/etherscan/src/app/views/ReceiptsView.tsx index 6ad4a22b73..4eae34b120 100644 --- a/apps/etherscan/src/app/views/ReceiptsView.tsx +++ b/apps/etherscan/src/app/views/ReceiptsView.tsx @@ -12,7 +12,7 @@ interface FormValues { } export const ReceiptsView: React.FC = () => { - const [results, setResults] = useState("") + const [results, setResults] = useState({succeed: false, message: ''}) const onGetReceiptStatus = async ( values: FormValues, clientInstance: any, @@ -21,7 +21,10 @@ export const ReceiptsView: React.FC = () => { try { const network = await getNetworkName(clientInstance) if (network === "vm") { - setResults("Cannot verify in the selected network") + setResults({ + succeed: false, + message: "Cannot verify in the selected network" + }) return } const etherscanApi = getEtherScanApi(network) @@ -30,9 +33,15 @@ export const ReceiptsView: React.FC = () => { apiKey, etherscanApi ) - setResults(result.result) + setResults({ + succeed: result.status === '1' ? true : false, + message: result.result + }) } catch (error: any) { - setResults(error.message) + setResults({ + succeed: false, + message: error.message + }) } } @@ -93,8 +102,9 @@ export const ReceiptsView: React.FC = () => { marginTop: "2em", fontSize: "0.8em", textAlign: "center", + color: results['succeed'] ? "green" : "red" }} - dangerouslySetInnerHTML={{ __html: results }} + dangerouslySetInnerHTML={{ __html: results.message ? results.message : '' }} />