From 605d11be6fa43bb707f19551e900ccb346bff014 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 1 Jun 2023 19:00:18 +0530 Subject: [PATCH] check if receipt is for proxy contract --- apps/etherscan/src/app/app.tsx | 21 ++++++++++++------- apps/etherscan/src/app/types/Receipt.ts | 3 +++ apps/etherscan/src/app/utils/verify.ts | 6 ++++-- apps/etherscan/src/app/views/ReceiptsView.tsx | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/apps/etherscan/src/app/app.tsx b/apps/etherscan/src/app/app.tsx index b5f06bc166..19323fff8d 100644 --- a/apps/etherscan/src/app/app.tsx +++ b/apps/etherscan/src/app/app.tsx @@ -13,7 +13,7 @@ import { DisplayRoutes } from "./routes" import { useLocalStorage } from "./hooks/useLocalStorage" -import { getReceiptStatus, getEtherScanApi, getNetworkName } from "./utils" +import { getReceiptStatus, getEtherScanApi, getNetworkName, getProxyContractReceiptStatus } from "./utils" import { Receipt, ThemeType } from "./types" import "./App.css" @@ -102,12 +102,19 @@ const App = () => { let newReceipts = receipts for (const item of receiptsNotVerified) { await new Promise(r => setTimeout(r, 500)) // avoid api rate limit exceed. - console.log('checking receipt', item.guid) - const status = await getReceiptStatus( - item.guid, - apiKey, - getEtherScanApi(networkId) - ) + let status + if (item.isProxyContract) + status = await getProxyContractReceiptStatus( + item.guid, + apiKey, + getEtherScanApi(networkId) + ) + else + status = await getReceiptStatus( + item.guid, + apiKey, + getEtherScanApi(networkId) + ) if (status.result === "Pass - Verified" || status.result === "Already Verified") { newReceipts = newReceipts.map((currentReceipt: Receipt) => { if (currentReceipt.guid === item.guid) { diff --git a/apps/etherscan/src/app/types/Receipt.ts b/apps/etherscan/src/app/types/Receipt.ts index 2469aa02a8..28d104622c 100644 --- a/apps/etherscan/src/app/types/Receipt.ts +++ b/apps/etherscan/src/app/types/Receipt.ts @@ -3,4 +3,7 @@ export type ReceiptStatus = "Pending in queue" | "Pass - Verified" | "Already Ve export interface Receipt { guid: string status: ReceiptStatus + isProxyContract: boolean + message?: string + succeed?: boolean } diff --git a/apps/etherscan/src/app/utils/verify.ts b/apps/etherscan/src/app/utils/verify.ts index 3119e5f05f..f813192cdc 100644 --- a/apps/etherscan/src/app/utils/verify.ts +++ b/apps/etherscan/src/app/utils/verify.ts @@ -131,7 +131,8 @@ export const verify = async ( guid: result, status: receiptStatus.result, message: `Verification process started correctly. Receipt GUID ${result}`, - succeed: true + succeed: true, + isProxyContract } onVerifiedContract(returnValue) return returnValue @@ -143,7 +144,8 @@ export const verify = async ( }) const returnValue = { message: result, - succeed: false + succeed: false, + isProxyContract } resetAfter10Seconds(client, setResults) return returnValue diff --git a/apps/etherscan/src/app/views/ReceiptsView.tsx b/apps/etherscan/src/app/views/ReceiptsView.tsx index a65e935dab..ca65a85f59 100644 --- a/apps/etherscan/src/app/views/ReceiptsView.tsx +++ b/apps/etherscan/src/app/views/ReceiptsView.tsx @@ -25,7 +25,7 @@ export const ReceiptsView: React.FC = () => { setResults({ succeed: false, message: "Cannot verify in the selected network" - }) + }) return } const etherscanApi = getEtherScanApi(networkId)