Skip to content

Commit d12bb5a

Browse files
committed
fix: Correct verification support check logic on deploy
1 parent 8112e11 commit d12bb5a

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@ export function ContractDropdownUI(props: ContractDropdownProps) {
5151
const checkSupport = async () => {
5252
if (props.plugin && props.networkName) {
5353
try {
54-
const status = props.plugin.blockchain.getCurrentNetworkStatus()
55-
if (status.error || !status.network) {
56-
setNetworkSupported(false)
57-
return
54+
const supportedChain = await getSupportedChain(props.plugin)
55+
const chainExistsInList = !!supportedChain
56+
57+
let isConfigValid = false
58+
if (chainExistsInList) {
59+
const status = props.plugin.blockchain.getCurrentNetworkStatus()
60+
const currentChainId = status?.network?.id?.toString()
61+
if (currentChainId) {
62+
isConfigValid = await props.plugin.call(
63+
'contract-verification',
64+
'isVerificationSupportedForChain',
65+
currentChainId
66+
)
67+
}
5868
}
59-
const currentChainId = status.network.id.toString()
60-
61-
const isSupported = await props.plugin.call(
62-
'contract-verification',
63-
'isVerificationSupportedForChain',
64-
currentChainId
65-
)
6669

70+
const isSupported = chainExistsInList && isConfigValid
6771
setNetworkSupported(isSupported)
6872

6973
if (isSupported) {
@@ -75,7 +79,11 @@ export function ContractDropdownUI(props: ContractDropdownProps) {
7579
} catch (e) {
7680
console.error("Failed to check verification support:", e)
7781
setNetworkSupported(false)
82+
setVerifyChecked(false)
7883
}
84+
} else {
85+
setNetworkSupported(false)
86+
setVerifyChecked(false)
7987
}
8088
}
8189
checkSupport()
@@ -353,6 +361,23 @@ export function ContractDropdownUI(props: ContractDropdownProps) {
353361
return props.isValidProxyUpgrade(proxyAddress, loadedContractData.contractName || loadedContractData.name, loadedContractData.compiler.source, loadedContractData.compiler.data, solcVersion)
354362
}
355363

364+
const getSupportedChain = async (plugin: any): Promise<any> => {
365+
try {
366+
const response = await fetch('https://chainid.network/chains.json')
367+
if (!response.ok) return null
368+
const allChains = await response.json()
369+
370+
const status = plugin.blockchain.getCurrentNetworkStatus()
371+
if (status.error || !status.network) return null
372+
373+
const currentChainId = parseInt(status.network.id)
374+
return allChains.find(chain => chain.chainId === currentChainId) || null
375+
} catch (e) {
376+
console.error(e)
377+
return null
378+
}
379+
}
380+
356381
const checkSumWarning = () => {
357382
return (
358383
<span className="text-start">

0 commit comments

Comments
 (0)