From 77bf879243f1fd4bf73d4ee57ee708d90063d2c9 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Tue, 21 Feb 2023 15:12:48 +0100 Subject: [PATCH] refactor --- apps/etherscan/src/app/RemixPlugin.tsx | 7 ++++--- apps/etherscan/src/app/utils/utilities.ts | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/etherscan/src/app/RemixPlugin.tsx b/apps/etherscan/src/app/RemixPlugin.tsx index f9c6a4e18a..e4879ef6ce 100644 --- a/apps/etherscan/src/app/RemixPlugin.tsx +++ b/apps/etherscan/src/app/RemixPlugin.tsx @@ -23,9 +23,10 @@ export class RemixClient extends PluginClient { const etherscanApi = getEtherScanApi(network) const receiptStatus = await getReceiptStatus(receiptGuid, apiKey, etherscanApi) return { - status: receiptStatus, - message: receiptStatus, - succeed: true + status: receiptStatus.status, + message: receiptStatus.message, + result: receiptStatus.result, + succeed: receiptStatus.status === '0' ? false : true } } catch (e: any){ return { diff --git a/apps/etherscan/src/app/utils/utilities.ts b/apps/etherscan/src/app/utils/utilities.ts index d7300806a3..11cc6bd8e7 100644 --- a/apps/etherscan/src/app/utils/utilities.ts +++ b/apps/etherscan/src/app/utils/utilities.ts @@ -2,6 +2,12 @@ import { PluginClient } from "@remixproject/plugin" import axios from 'axios' type RemixClient = PluginClient +export type receiptStatus = { + result: string + message: string + status: string +} + export const getEtherScanApi = (network: string) => { return network === "main" ? `https://api.etherscan.io/api` @@ -20,12 +26,16 @@ export const getReceiptStatus = async ( receiptGuid: string, apiKey: string, etherscanApi: string -) => { +): Promise => { const params = `guid=${receiptGuid}&module=contract&action=checkverifystatus&apiKey=${apiKey}` try { const response = await axios.get(`${etherscanApi}?${params}`) - const { result } = response.data - return result + const { result, message, status } = response.data + return { + result, + message, + status, + } } catch (error) { console.error(error) }