update receipt status script

pull/5370/head
Aniket-Engg 1 year ago committed by yann300
parent 64b488982c
commit 3040da59d6
  1. 9
      apps/etherscan/src/app/RemixPlugin.tsx
  2. 5
      apps/etherscan/src/app/utils/scripts.ts
  3. 5
      libs/remix-ui/workspace/src/lib/scripts/etherscan/receiptGuidScript.ts

@ -1,6 +1,6 @@
import { PluginClient } from '@remixproject/plugin';
import { verify, EtherScanReturn } from './utils/verify';
import { getReceiptStatus, getEtherScanApi, getNetworkName } from './utils';
import { getReceiptStatus, getEtherScanApi, getNetworkName, getProxyContractReceiptStatus } from './utils';
export class RemixClient extends PluginClient {
@ -14,14 +14,17 @@ export class RemixClient extends PluginClient {
return result
}
async receiptStatus (receiptGuid: string, apiKey: string) {
async receiptStatus (receiptGuid: string, apiKey: string, isProxyContract: boolean) {
try {
const { network, networkId } = await getNetworkName(this)
if (network === "vm") {
throw new Error("Cannot check the receipt status in the selected network")
}
const etherscanApi = getEtherScanApi(networkId)
const receiptStatus = await getReceiptStatus(receiptGuid, apiKey, etherscanApi)
let receiptStatus
if (isProxyContract) receiptStatus = await getProxyContractReceiptStatus(receiptGuid, apiKey, etherscanApi)
else receiptStatus = await getReceiptStatus(receiptGuid, apiKey, etherscanApi)
return {
message: receiptStatus.result,
succeed: receiptStatus.status === '0' ? false : true

@ -21,9 +21,10 @@ export const receiptGuidScript = `
/**
* @param {string} apikey - etherscan api key
* @param {string} guid - receipt id
* @param {boolean} isProxyContract - true, if contract is a proxy contract (optional)
* @returns {{ status, message, succeed }} receiptStatus
*/
export const receiptStatus = async (apikey: string, guid: string) => {
return await remix.call('etherscan' as any, 'receiptStatus', guid, apikey)
export const receiptStatus = async (apikey: string, guid: string, isProxyContract?: boolean) => {
return await remix.call('etherscan' as any, 'receiptStatus', guid, apikey, isProxyContract)
}
`

@ -1,8 +1,9 @@
/**
* @param {string} apikey - etherscan api key
* @param {string} guid - receipt id
* @param {boolean} isProxyContract - true, if contract is a proxy contract (optional)
* @returns {{ status, message, succeed }} receiptStatus
*/
export const receiptStatus = async (apikey: string, guid: string) => {
return await remix.call('etherscan' as any, 'receiptStatus', guid, apikey)
export const receiptStatus = async (apikey: string, guid: string, isProxyContract?: boolean) => {
return await remix.call('etherscan' as any, 'receiptStatus', guid, apikey, isProxyContract)
}
Loading…
Cancel
Save