chainid to verify

pull/5370/head
Aniket-Engg 2 years ago committed by Aniket
parent 145073ed1b
commit 6ed1425fc3
  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) {
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) => {})
return result
}
@ -20,7 +20,7 @@ export class RemixClient extends PluginClient {
if (network === "vm") {
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)
return {
message: receiptStatus.result,

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

@ -14,20 +14,11 @@ export type receiptStatus = {
status: string
}
export const getEtherScanApi = (network: string, networkId: any) => {
let apiUrl
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`
export const getEtherScanApi = (networkId: any) => {
if (!(networkId in scanAPIurls)) {
throw new Error("no known network to verify against")
}
const apiUrl = (scanAPIurls as any)[networkId]
return apiUrl
}

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

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

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

Loading…
Cancel
Save