add utility functions

pull/5367/head
Joseph Izang 4 weeks ago committed by Aniket
parent 257065f094
commit b775d9d52b
  1. 18
      libs/remix-ui/run-tab/src/lib/actions/evmmap.ts

@ -17,7 +17,7 @@ type HardFork =
| 'spuriousDragon'
| 'tangarineWhistle';
const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
export const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
['berlin', {
chainId: [
{ id: 1, name: "Ethereum Mainnet" },
@ -127,6 +127,18 @@ const evmMap: Map<HardFork, { chainId: ChainInfo[] }> = new Map([
{ id: 1, name: "Ethereum Mainnet" }
]
}]
]);
])
export default evmMap
export function getCompatibleChains(fork: HardFork): ChainInfo[] {
const forkData = evmMap.get(fork);
return forkData ? forkData.chainId : [];
}
export function isChainCompatible(fork: HardFork, chainId: number): boolean {
const compatibleChains = getCompatibleChains(fork);
return compatibleChains.some(chain => chain.id === chainId);
}
export function isChainCompatibleWithAnyFork(chainId: number, forks: HardFork[]): boolean {
return forks.some(fork => isChainCompatible(fork, chainId));
}

Loading…
Cancel
Save