pull/5370/head
filip mertens 2 years ago committed by Aniket
parent f595099546
commit 77bf879243
  1. 7
      apps/etherscan/src/app/RemixPlugin.tsx
  2. 16
      apps/etherscan/src/app/utils/utilities.ts

@ -23,9 +23,10 @@ export class RemixClient extends PluginClient {
const etherscanApi = getEtherScanApi(network) const etherscanApi = getEtherScanApi(network)
const receiptStatus = await getReceiptStatus(receiptGuid, apiKey, etherscanApi) const receiptStatus = await getReceiptStatus(receiptGuid, apiKey, etherscanApi)
return { return {
status: receiptStatus, status: receiptStatus.status,
message: receiptStatus, message: receiptStatus.message,
succeed: true result: receiptStatus.result,
succeed: receiptStatus.status === '0' ? false : true
} }
} catch (e: any){ } catch (e: any){
return { return {

@ -2,6 +2,12 @@ import { PluginClient } from "@remixproject/plugin"
import axios from 'axios' import axios from 'axios'
type RemixClient = PluginClient type RemixClient = PluginClient
export type receiptStatus = {
result: string
message: string
status: string
}
export const getEtherScanApi = (network: string) => { export const getEtherScanApi = (network: string) => {
return network === "main" return network === "main"
? `https://api.etherscan.io/api` ? `https://api.etherscan.io/api`
@ -20,12 +26,16 @@ export const getReceiptStatus = async (
receiptGuid: string, receiptGuid: string,
apiKey: string, apiKey: string,
etherscanApi: string etherscanApi: string
) => { ): Promise<receiptStatus> => {
const params = `guid=${receiptGuid}&module=contract&action=checkverifystatus&apiKey=${apiKey}` const params = `guid=${receiptGuid}&module=contract&action=checkverifystatus&apiKey=${apiKey}`
try { try {
const response = await axios.get(`${etherscanApi}?${params}`) const response = await axios.get(`${etherscanApi}?${params}`)
const { result } = response.data const { result, message, status } = response.data
return result return {
result,
message,
status,
}
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }

Loading…
Cancel
Save