chainid to verify

pull/3744/head
Aniket-Engg 2 years ago committed by Aniket
parent 48f56b25a3
commit a0fdb3e222
  1. 4
      apps/etherscan/src/app/RemixPlugin.tsx
  2. 2
      apps/etherscan/src/app/app.tsx
  3. 17
      apps/etherscan/src/app/utils/utilities.ts
  4. 14
      apps/etherscan/src/app/utils/verify.ts
  5. 2
      apps/etherscan/src/app/views/ReceiptsView.tsx
  6. 1
      apps/etherscan/src/app/views/VerifyView.tsx

@ -9,7 +9,7 @@ export class RemixClient extends PluginClient {
} }
async verify (apiKey: string, contractAddress: string, contractArguments: string, contractName: string, compilationResultParam: any) { async verify (apiKey: string, contractAddress: string, contractArguments: string, contractName: string, compilationResultParam: any) {
const result = await verify(apiKey, contractAddress, contractArguments, contractName, compilationResultParam, this, const result = await verify(apiKey, contractAddress, contractArguments, contractName, compilationResultParam, null, this,
(value: EtherScanReturn) => {}, (value: string) => {}) (value: EtherScanReturn) => {}, (value: string) => {})
return result return result
} }
@ -20,7 +20,7 @@ export class RemixClient extends PluginClient {
if (network === "vm") { if (network === "vm") {
throw new Error("Cannot check the receipt status in the selected network") throw new Error("Cannot check the receipt status in the selected network")
} }
const etherscanApi = getEtherScanApi(network, networkId) const etherscanApi = getEtherScanApi(networkId)
const receiptStatus = await getReceiptStatus(receiptGuid, apiKey, etherscanApi) const receiptStatus = await getReceiptStatus(receiptGuid, apiKey, etherscanApi)
return { return {
message: receiptStatus.result, message: receiptStatus.result,

@ -106,7 +106,7 @@ const App = () => {
const status = await getReceiptStatus( const status = await getReceiptStatus(
item.guid, item.guid,
apiKey, apiKey,
getEtherScanApi(network, networkId) getEtherScanApi(networkId)
) )
if (status.result === "Pass - Verified" || status.result === "Already Verified") { if (status.result === "Pass - Verified" || status.result === "Already Verified") {
newReceipts = newReceipts.map((currentReceipt: Receipt) => { newReceipts = newReceipts.map((currentReceipt: Receipt) => {

@ -14,20 +14,11 @@ export type receiptStatus = {
status: string status: string
} }
export const getEtherScanApi = (network: string, networkId: any) => { export const getEtherScanApi = (networkId: any) => {
let apiUrl if (!(networkId in scanAPIurls)) {
throw new Error("no known network to verify against")
if (network === "main") {
apiUrl = "https://api.etherscan.io/api"
} else if (network === "custom") {
if (!(networkId in scanAPIurls)) {
throw new Error("no known network to verify against")
}
apiUrl = (scanAPIurls as any)[networkId]
} else {
apiUrl = `https://api-${network}.etherscan.io/api`
} }
const apiUrl = (scanAPIurls as any)[networkId]
return apiUrl return apiUrl
} }

@ -20,19 +20,25 @@ export const verify = async (
contractAddress: string, contractAddress: string,
contractArgumentsParam: string, contractArgumentsParam: string,
contractName: string, contractName: string,
compilationResultParam: CompilerAbstract, compilationResultParam: CompilerAbstract,
chainId: number | string,
client: PluginClient, client: PluginClient,
onVerifiedContract: (value: EtherScanReturn) => void, onVerifiedContract: (value: EtherScanReturn) => void,
setResults: (value: string) => void setResults: (value: string) => void
) => { ) => {
const { network, networkId } = await getNetworkName(client) let networkChainId
if (network === "vm") { if (chainId) networkChainId = chainId
else {
const { network, networkId } = await getNetworkName(client)
if (network === "vm") {
return { return {
succeed: false, succeed: false,
message: "Cannot verify in the selected network" message: "Cannot verify in the selected network"
} }
} else networkChainId = networkId
} }
const etherscanApi = getEtherScanApi(network, networkId)
const etherscanApi = getEtherScanApi(networkChainId)
try { try {
const contractMetadata = getContractMetadata( const contractMetadata = getContractMetadata(

@ -28,7 +28,7 @@ export const ReceiptsView: React.FC = () => {
}) })
return return
} }
const etherscanApi = getEtherScanApi(network, networkId) const etherscanApi = getEtherScanApi(networkId)
const result = await getReceiptStatus( const result = await getReceiptStatus(
values.receiptGuid, values.receiptGuid,
apiKey, apiKey,

@ -64,6 +64,7 @@ export const VerifyView: React.FC<Props> = ({
contractArguments, contractArguments,
values.contractName, values.contractName,
compilationResult, compilationResult,
null,
client, client,
onVerifiedContract, onVerifiedContract,
setResults, setResults,

Loading…
Cancel
Save