Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ContractVerificationPluginClient extends PluginClient {

constructor() {
super()
this.methods = ['lookupAndSave', 'verifyOnDeploy']
this.methods = ['lookupAndSave', 'verifyOnDeploy', 'isVerificationSupportedForChain']
this.internalEvents = new EventManager()
createClient(this)
this.onload()
Expand Down Expand Up @@ -126,24 +126,15 @@ export class ContractVerificationPluginClient extends PluginClient {
const chainSettings = mergeChainSettingsWithDefaults(chainId, userSettings)

const verificationPromises = []
const verifiers: VerifierIdentifier[] = ['Sourcify', 'Etherscan', 'Blockscout', 'Routescan']

if (validConfiguration(chainSettings, 'Sourcify')) {
verificationPromises.push(this._verifyWithProvider('Sourcify', submittedContract, compilerAbstract, chainId, chainSettings))
}

if (currentChain.explorers && currentChain.explorers.some(explorer => explorer.name.toLowerCase().includes('routescan'))) {
verificationPromises.push(this._verifyWithProvider('Routescan', submittedContract, compilerAbstract, chainId, chainSettings))
}

if (currentChain.explorers && currentChain.explorers.some(explorer => explorer.url.includes('blockscout'))) {
verificationPromises.push(this._verifyWithProvider('Blockscout', submittedContract, compilerAbstract, chainId, chainSettings))
}

if (currentChain.explorers && currentChain.explorers.some(explorer => explorer.name.includes('etherscan'))) {
if (etherscanApiKey) {
verificationPromises.push(this._verifyWithProvider('Etherscan', submittedContract, compilerAbstract, chainId, chainSettings))
} else {
await this.call('terminal', 'log', { type: 'warn', value: 'Etherscan verification skipped: API key not found in global Settings.' })
for (const verifier of verifiers) {
if (validConfiguration(chainSettings, verifier)) {
if (verifier === 'Etherscan' && !etherscanApiKey) {
this.call('terminal', 'log', { type: 'warn', value: 'Etherscan verification skipped: API key not provided for auto-verification.' })
continue
}
verificationPromises.push(this._verifyWithProvider(verifier, submittedContract, compilerAbstract, chainId, chainSettings))
}
}

Expand All @@ -158,6 +149,23 @@ export class ContractVerificationPluginClient extends PluginClient {
}
}

async isVerificationSupportedForChain(chainId: string): Promise<boolean> {
try {
const userSettings = this.getUserSettingsFromLocalStorage()
const chainSettings = mergeChainSettingsWithDefaults(chainId, userSettings)

for (const verifierId of VERIFIERS) {
if (validConfiguration(chainSettings, verifierId as VerifierIdentifier)) {
return true
}
}
return false
} catch (e) {
console.error(e)
return false
}
}

private _verifyWithProvider = async (
providerName: VerifierIdentifier,
submittedContract: SubmittedContract,
Expand Down
3 changes: 3 additions & 0 deletions apps/contract-verification/src/app/utils/default-apis.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"1101": {
"explorerUrl": "https://zkevm.polygonscan.com"
},
"59141": {
"explorerUrl": "https://sepolia.lineascan.build"
},
"59144": {
"explorerUrl": "https://lineascan.build"
},
Expand Down
2 changes: 1 addition & 1 deletion libs/remix-ui/run-tab/src/lib/actions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export const createInstance = async (
const currentChain = allChains.find(chain => chain.chainId === currentChainId)

if (!currentChain) {
const errorMsg = `The current network (Chain ID: ${currentChainId}) is not supported for verification via this plugin. Please switch to a supported network like Sepolia or Mainnet.`
const errorMsg = `Could not find chain data for Chain ID: ${currentChainId}. Verification cannot proceed.`
const errorLog = logBuilder(errorMsg)
terminalLogger(plugin, errorLog)
return
Expand Down
46 changes: 35 additions & 11 deletions libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,45 @@ export function ContractDropdownUI(props: ContractDropdownProps) {

useEffect(() => {
const checkSupport = async () => {
if (props.plugin) {
const supportedChain = await getSupportedChain(props.plugin)
const isSupported = !!supportedChain
setNetworkSupported(isSupported)

if (isSupported) {
const saved = window.localStorage.getItem('deploy-verify-contract-checked')
setVerifyChecked(saved !== null ? JSON.parse(saved) : true)
} else {
if (props.plugin && props.networkName) {
try {
const supportedChain = await getSupportedChain(props.plugin)
const chainExistsInList = !!supportedChain

let isConfigValid = false
if (chainExistsInList) {
const status = props.plugin.blockchain.getCurrentNetworkStatus()
const currentChainId = status?.network?.id?.toString()
if (currentChainId) {
isConfigValid = await props.plugin.call(
'contract-verification',
'isVerificationSupportedForChain',
currentChainId
)
}
}

const isSupported = chainExistsInList && isConfigValid
setNetworkSupported(isSupported)

if (isSupported) {
const saved = window.localStorage.getItem('deploy-verify-contract-checked')
setVerifyChecked(saved !== null ? JSON.parse(saved) : true)
} else {
setVerifyChecked(false)
}
} catch (e) {
console.error("Failed to check verification support:", e)
setNetworkSupported(false)
setVerifyChecked(false)
}
} else {
setNetworkSupported(false)
setVerifyChecked(false)
}
};
}
checkSupport()
}, [props.networkName])
}, [props.networkName, props.plugin])

useEffect(() => {
enableContractNames(Object.keys(props.contracts.contractList).length > 0)
Expand Down