add min compiler version to map

pull/5367/head
Joseph Izang 3 weeks ago committed by Aniket
parent 9e3329153f
commit 078700b67f
  1. 42
      libs/remix-ui/run-tab/src/lib/actions/evmmap.ts
  2. 40
      libs/remix-ui/run-tab/src/lib/run-tab.tsx

@ -17,7 +17,7 @@ export type HardFork =
| 'tangerineWhistle' | 'tangerineWhistle'
| 'homestead' | 'homestead'
export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([ export const evmMap: Map<HardFork, { chainId: ChainInfo[], minCompilerVersion: string }> = new Map([
['cancun', { ['cancun', {
chainId: [ chainId: [
{ id: 1, name: "Ethereum Mainnet" }, { id: 1, name: "Ethereum Mainnet" },
@ -36,7 +36,8 @@ export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 421614, name: "Arbitrum Sepolia" }, { id: 421614, name: "Arbitrum Sepolia" },
{ id: 534352, name: "Scroll" }, { id: 534352, name: "Scroll" },
{ id: 11155111, name: "Sepolia" } { id: 11155111, name: "Sepolia" }
] ],
minCompilerVersion: "0.8.24"
}], }],
['shanghai', { ['shanghai', {
chainId: [ chainId: [
@ -58,10 +59,8 @@ export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 1088, name: "Metis Andromeda Mainnet" }, { id: 1088, name: "Metis Andromeda Mainnet" },
{ id: 1284, name: "Moonbeam" }, { id: 1284, name: "Moonbeam" },
{ id: 2000, name: "Dogechain Mainnet" }, { id: 2000, name: "Dogechain Mainnet" },
{ id: 42220, name: "Celo Mainnet" },
{ id: 42161, name: "Arbitrum One" }, { id: 42161, name: "Arbitrum One" },
{ id: 42170, name: "Arbitrum Nova" }, { id: 42170, name: "Arbitrum Nova" },
{ id: 44787, name: "Celo Alfajores Testnet" },
{ id: 59144, name: "Linea Mainnet" }, { id: 59144, name: "Linea Mainnet" },
{ id: 59141, name: "Linea Testnet" }, { id: 59141, name: "Linea Testnet" },
{ id: 59902, name: "Metis Sepolia Testnet" }, { id: 59902, name: "Metis Sepolia Testnet" },
@ -69,7 +68,8 @@ export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 11155111, name: "Sepolia" }, { id: 11155111, name: "Sepolia" },
{ id: 11155420, name: "Optimism Sepolia Testnet" }, { id: 11155420, name: "Optimism Sepolia Testnet" },
{ id: 1666600000, name: "Harmony Mainnet Shard 0" } { id: 1666600000, name: "Harmony Mainnet Shard 0" }
] ],
minCompilerVersion: "0.8.20"
}], }],
['paris', { ['paris', {
chainId: [ chainId: [
@ -102,7 +102,8 @@ export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 11155111, name: "Sepolia" }, { id: 11155111, name: "Sepolia" },
{ id: 11155420, name: "Optimism Sepolia Testnet" }, { id: 11155420, name: "Optimism Sepolia Testnet" },
{ id: 1666600000, name: "Harmony Mainnet Shard 0" } { id: 1666600000, name: "Harmony Mainnet Shard 0" }
] ],
minCompilerVersion: "0.8.18"
}], }],
['london', { ['london', {
chainId: [ chainId: [
@ -121,7 +122,8 @@ export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 59144, name: "Linea Mainnet" }, { id: 59144, name: "Linea Mainnet" },
{ id: 59141, name: "Linea Testnet" }, { id: 59141, name: "Linea Testnet" },
{ id: 11155111, name: "Sepolia" }, { id: 11155111, name: "Sepolia" },
] ],
minCompilerVersion: "0.8.7"
}], }],
['berlin', { ['berlin', {
chainId: [ chainId: [
@ -140,7 +142,8 @@ export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 59144, name: "Linea Mainnet" }, { id: 59144, name: "Linea Mainnet" },
{ id: 59141, name: "Linea Testnet" }, { id: 59141, name: "Linea Testnet" },
{ id: 11155111, name: "Sepolia" } { id: 11155111, name: "Sepolia" }
] ],
minCompilerVersion: "0.8.5"
}], }],
['istanbul', { ['istanbul', {
chainId: [ chainId: [
@ -159,44 +162,51 @@ export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 59144, name: "Linea Mainnet" }, { id: 59144, name: "Linea Mainnet" },
{ id: 59141, name: "Linea Testnet" }, { id: 59141, name: "Linea Testnet" },
{ id: 11155111, name: "Sepolia" } { id: 11155111, name: "Sepolia" }
] ],
minCompilerVersion: "0.5.14"
}], }],
['petersburg', { ['petersburg', {
chainId: [ chainId: [
{ id: 1, name: "Ethereum Mainnet" }, { id: 1, name: "Ethereum Mainnet" },
{ id: 5, name: "Goerli" }, { id: 5, name: "Goerli" },
{ id: 11155111, name: "Sepolia" } { id: 11155111, name: "Sepolia" }
] ],
minCompilerVersion: "0.5.5"
}], }],
['constantinople', { ['constantinople', {
chainId: [ chainId: [
{ id: 1, name: "Ethereum Mainnet" }, { id: 1, name: "Ethereum Mainnet" },
{ id: 5, name: "Goerli" }, { id: 5, name: "Goerli" },
{ id: 11155111, name: "Sepolia" } { id: 11155111, name: "Sepolia" }
] ],
minCompilerVersion: "0.5.5"
}], }],
['byzantium', { ['byzantium', {
chainId: [ chainId: [
{ id: 1, name: "Ethereum Mainnet" } { id: 1, name: "Ethereum Mainnet" }
] ],
minCompilerVersion: "0.4.21"
}], }],
['spuriousDragon', { ['spuriousDragon', {
chainId: [ chainId: [
{ id: 1, name: "Ethereum Mainnet" } { id: 1, name: "Ethereum Mainnet" }
] ],
minCompilerVersion: "0.4.9"
}], }],
['tangerineWhistle', { ['tangerineWhistle', {
chainId: [ chainId: [
{ id: 1, name: "Ethereum Mainnet" } { id: 1, name: "Ethereum Mainnet" }
] ],
minCompilerVersion: "0.4.0"
}], }],
['homestead', { ['homestead', {
chainId: [ chainId: [
{ id: 1, name: "Ethereum Mainnet" }, { id: 1, name: "Ethereum Mainnet" },
{ id: 5, name: "Goerli" }, { id: 5, name: "Goerli" },
{ id: 11155111, name: "Sepolia" } { id: 11155111, name: "Sepolia" }
] ],
}] minCompilerVersion: "0.1.2"
}],
]) ])
export function getCompatibleChains(fork: HardFork): ChainInfo[] { export function getCompatibleChains(fork: HardFork): ChainInfo[] {

@ -110,25 +110,24 @@ export function RunTabUI(props: RunTabProps) {
return getCompatibleChain(evmVersion ?? 'cancun', targetChainId) return getCompatibleChain(evmVersion ?? 'cancun', targetChainId)
} }
const checkEvmChainCompatibilityOkFunction = async (targetChainId: number, fetchDetails: any, currentFile: string) => { const checkEvmChainCompatibilityOkFunction = async (targetChainId: number, fetchDetails: any) => {
() => { const compilerParams = {
const compatibleChain = returnCompatibleChain(fetchDetails.evmVersion, targetChainId) evmVersion: 'paris',
console.log('compatibleChain', compatibleChain) optimize: false,
plugin.call('manager', 'activatePlugin', 'environmentExplorer') language: 'Solidity',
plugin.call('tabs', 'focus', 'environmentExplorer') runs: 200,
plugin.call('environmentExplorer', 'setChain', compatibleChain) version: '0.8.27+commit.40a35a09'
plugin.call('environmentExplorer', 'setEvmVersion', 'paris')
plugin.call('solidity', 'compile', currentFile)
} }
await plugin.call('solidity', 'setCompilerConfig', compilerParams)
const compilerState = await plugin.call('solidity', 'getCompilerState')
console.log('compilerState', compilerState)
const currentFile = await plugin.call('fileManager', 'getCurrentFile')
await plugin.call('solidity', 'compile', currentFile)
} }
const checkEvmChainCompatibilityCancelFunction = async (targetChainId: number, fetchDetails: any, currentFile: string) => { const checkEvmChainCompatibilityCancelFunction = async (targetChainId: number, fetchDetails: any, currentFile: string) => {
() => { () => {
plugin.call('manager', 'activatePlugin', 'environmentExplorer') console.log('cancel')
plugin.call('tabs', 'focus', 'environmentExplorer')
plugin.call('environmentExplorer', 'setChain', targetChainId)
plugin.call('environmentExplorer', 'setEvmVersion', fetchDetails.evmVersion)
plugin.call('solidity', 'compile', currentFile)
} }
} }
@ -149,12 +148,19 @@ export function RunTabUI(props: RunTabProps) {
console.log('chain is undefined') console.log('chain is undefined')
//show modal //show modal
plugin.call('notification', 'modal', { plugin.call('notification', 'modal', {
id: 'evm-incompatible', id: 'evm-chainId-incompatible',
title: 'Incompatible EVM - ChainId Detected', title: 'Incompatible EVM - ChainId Detected',
message: `The selected chain is not compatible with the selected compiler version. Please select a one of the two options below.`, message: <div className="px-3">
<p>The selected chain is not compatible with the selected EVM version. Please select a one of the options below.</p>
<ul className="px-3">
<li>Have Remix switch to a compatible EVM version for this chain and recompile the contract.</li>
<li>Cancel to keep the current EVM version.</li>
</ul>
<p>To manually change the EVM version, go to the Advanced Configurations section of the Solidity compiler.</p>
</div>,
modalType: 'modal', modalType: 'modal',
okLabel: 'Switch EVM and Recompile', okLabel: 'Switch EVM and Recompile',
cancelLabel: 'Do not Switch EVM', cancelLabel: 'Cancel',
okFn: checkEvmChainCompatibilityOkFunction, okFn: checkEvmChainCompatibilityOkFunction,
cancelFn: checkEvmChainCompatibilityCancelFunction cancelFn: checkEvmChainCompatibilityCancelFunction
}) })

Loading…
Cancel
Save