From 2aa413ed6e5008e76f146a0eaf63359bb76656a2 Mon Sep 17 00:00:00 2001 From: Matt Solomon Date: Tue, 30 Apr 2024 06:04:23 -0700 Subject: [PATCH] add deployed contracts to UI --- script/checks/deployed-contracts.ts | 4 +- script/data/chain/1.json | 4 +- script/data/chain/10.json | 4 +- script/data/chain/42161.json | 4 +- script/data/feature/deployedContracts.json | 12 +-- script/index.ts | 24 +++-- src/components/diff/DiffDeployedContracts.tsx | 98 +++---------------- src/components/diff/DiffOpcodes.tsx | 2 +- src/pages/diff.tsx | 2 +- 9 files changed, 44 insertions(+), 110 deletions(-) diff --git a/script/checks/deployed-contracts.ts b/script/checks/deployed-contracts.ts index 33c18bed..b5bb7769 100644 --- a/script/checks/deployed-contracts.ts +++ b/script/checks/deployed-contracts.ts @@ -22,9 +22,9 @@ const deployedContracts: { name: string; address: Address }[] = [ }, { name: 'Create2Deployer', address: '0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2' }, // ERC-4337. - { name: 'ERC-4337 EntryPoint v0.6', address: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' }, + { name: 'ERC-4337 Entry Point v0.6', address: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' }, { - name: 'ERC-4337 SimpleAccountFactory v0.6', + name: 'ERC-4337 Simple Account Factory v0.6', address: '0x9406Cc6185a346906296840746125a0E44976454', }, // Other diff --git a/script/data/chain/1.json b/script/data/chain/1.json index 54d94efc..8b549c18 100644 --- a/script/data/chain/1.json +++ b/script/data/chain/1.json @@ -218,13 +218,13 @@ "hasCode": true }, { - "name": "ERC-4337 EntryPoint v0.6", + "name": "ERC-4337 Entry Point v0.6", "address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70", "hasCode": true }, { - "name": "ERC-4337 SimpleAccountFactory v0.6", + "name": "ERC-4337 Simple Account Factory v0.6", "address": "0x9406Cc6185a346906296840746125a0E44976454", "codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515", "hasCode": true diff --git a/script/data/chain/10.json b/script/data/chain/10.json index f3830fbc..2baf9731 100644 --- a/script/data/chain/10.json +++ b/script/data/chain/10.json @@ -204,13 +204,13 @@ "hasCode": true }, { - "name": "ERC-4337 EntryPoint v0.6", + "name": "ERC-4337 Entry Point v0.6", "address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70", "hasCode": true }, { - "name": "ERC-4337 SimpleAccountFactory v0.6", + "name": "ERC-4337 Simple Account Factory v0.6", "address": "0x9406Cc6185a346906296840746125a0E44976454", "codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515", "hasCode": true diff --git a/script/data/chain/42161.json b/script/data/chain/42161.json index 26da3a5b..36bf865a 100644 --- a/script/data/chain/42161.json +++ b/script/data/chain/42161.json @@ -202,13 +202,13 @@ "hasCode": true }, { - "name": "ERC-4337 EntryPoint v0.6", + "name": "ERC-4337 Entry Point v0.6", "address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70", "hasCode": true }, { - "name": "ERC-4337 SimpleAccountFactory v0.6", + "name": "ERC-4337 Simple Account Factory v0.6", "address": "0x9406Cc6185a346906296840746125a0E44976454", "codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515", "hasCode": true diff --git a/script/data/feature/deployedContracts.json b/script/data/feature/deployedContracts.json index 38f6d64d..5951cc8d 100644 --- a/script/data/feature/deployedContracts.json +++ b/script/data/feature/deployedContracts.json @@ -19,13 +19,13 @@ "hasCode": true }, { - "name": "ERC-4337 EntryPoint v0.6", + "name": "ERC-4337 Entry Point v0.6", "address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70", "hasCode": true }, { - "name": "ERC-4337 SimpleAccountFactory v0.6", + "name": "ERC-4337 Simple Account Factory v0.6", "address": "0x9406Cc6185a346906296840746125a0E44976454", "codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515", "hasCode": true @@ -63,13 +63,13 @@ "hasCode": true }, { - "name": "ERC-4337 EntryPoint v0.6", + "name": "ERC-4337 Entry Point v0.6", "address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70", "hasCode": true }, { - "name": "ERC-4337 SimpleAccountFactory v0.6", + "name": "ERC-4337 Simple Account Factory v0.6", "address": "0x9406Cc6185a346906296840746125a0E44976454", "codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515", "hasCode": true @@ -107,13 +107,13 @@ "hasCode": true }, { - "name": "ERC-4337 EntryPoint v0.6", + "name": "ERC-4337 Entry Point v0.6", "address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", "codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70", "hasCode": true }, { - "name": "ERC-4337 SimpleAccountFactory v0.6", + "name": "ERC-4337 Simple Account Factory v0.6", "address": "0x9406Cc6185a346906296840746125a0E44976454", "codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515", "hasCode": true diff --git a/script/index.ts b/script/index.ts index 56f9950d..e00d7cbc 100644 --- a/script/index.ts +++ b/script/index.ts @@ -1,6 +1,10 @@ import { http, fallback, createPublicClient } from 'viem'; import { checkDeployedContracts } from './checks/deployed-contracts'; -import { checkEvmStackAddresses, EVMStack, EVMStackResult } from './checks/evm-stack-addresses'; +import { + checkEvmStackAddresses, + type EVMStack, + type EVMStackResult, +} from './checks/evm-stack-addresses'; import { checkOpcodes } from './checks/opcodes'; import { checkPrecompiles } from './checks/precompiles'; import type { Metadata } from './types'; @@ -8,23 +12,23 @@ import type { Metadata } from './types'; export type Chain = { metadata: Metadata; opcodes: { - number: `0x${string}`; - name: string; - supported: string | boolean; + number: `0x${string}`; + name: string; + supported: string | boolean; }[]; deployedContracts: { name: string; - address: `0x${string}`; - codeHash: `0x${string}`; - hasCode: boolean; + address: `0x${string}`; + codeHash: `0x${string}`; + hasCode: boolean; }[]; precompiles: { name: string; - address: `0x${string}`; - implemented: boolean; + address: `0x${string}`; + implemented: boolean; }[]; evmStackAddresses: Record; -} +}; async function main() { // Initialize chain data. diff --git a/src/components/diff/DiffDeployedContracts.tsx b/src/components/diff/DiffDeployedContracts.tsx index 569d0137..57188a11 100644 --- a/src/components/diff/DiffDeployedContracts.tsx +++ b/src/components/diff/DiffDeployedContracts.tsx @@ -1,16 +1,9 @@ import { Address, getAddress } from 'viem'; -import { Abi } from '@/components/diff/utils/Abi'; -import { Collapsible } from '@/components/diff/utils/Collapsible'; -import { Markdown } from '@/components/diff/utils/Markdown'; +import { Chain } from '@/../script/index'; import { RenderDiff } from '@/components/diff/utils/RenderDiff'; import { Copyable } from '@/components/ui/Copyable'; -import { - DeployedContract, - DeployedContractKind, - ProxiedDeployedContract, - StandardDeployedContract, -} from '@/types'; +type DeployedContract = Chain['deployedContracts'][0]; type Props = { base: DeployedContract[]; target: DeployedContract[]; @@ -19,86 +12,34 @@ type Props = { const formatDeployedContract = (deployedContract: DeployedContract | undefined) => { if (!deployedContract) return

Not present

; - - const title = - deployedContract.kind === DeployedContractKind.WrappedNativeAsset ? ( - - ) : ( - - ); - const addr = getAddress(deployedContract.address); - const deployInstructions = deployedContract.deploymentInstructions || 'N/A'; - return ( <> -
{title}
-
- -
-
+
Address
-
+
-
Deploy Instructions
-
- -
-
-
- - +
Deployed?
+
{deployedContract.hasCode ? 'Yes' : 'No'}
); }; +export const convertToComparableContract = (contract: DeployedContract | undefined) => { + if (typeof contract === 'undefined') return undefined; + const slimmedContract = contract as any; + delete slimmedContract.codeHash; + return slimmedContract; +}; + const formatAddress = (addr: Address) => { addr = getAddress(addr); return {`${addr.slice(0, 6)}...${addr.slice(-4)}`}; }; -type OmittedStandardDeployedContract = Omit< - StandardDeployedContract, - 'description' | 'deploymentInstructions' | 'references' ->; -type OmittedProxiedDeployedContract = Omit< - ProxiedDeployedContract, - 'description' | 'deploymentInstructions' | 'references' ->; - -export const convertToComparableContract = ( - contract: DeployedContract | undefined -): OmittedStandardDeployedContract | OmittedProxiedDeployedContract | undefined => { - if (typeof contract === 'undefined') return undefined; - - const baseReturnData: OmittedStandardDeployedContract = { - name: contract.name, - kind: contract.kind, - tokenName: contract.tokenName, - tokenSymbol: contract.tokenSymbol, - address: contract.address, - notes: contract.notes, - logicAbi: contract.logicAbi.sort(), - }; - - if ('proxyAbi' in contract) { - const proxiedReturnData: OmittedProxiedDeployedContract = { - ...baseReturnData, - proxyAbi: contract.proxyAbi.sort(), - logicAddress: contract.logicAddress, - }; - return proxiedReturnData; - } - - return baseReturnData; -}; - export const DiffDeployedContracts = ({ base, target, onlyShowDiff }: Props) => { const sortedNames = [...base.map((c) => c.name), ...target.map((c) => c.name)].sort((a, b) => a.localeCompare(b) @@ -117,24 +58,13 @@ export const DiffDeployedContracts = ({ base, target, onlyShowDiff }: Props) => const showDeployedContract = !isEqual || !onlyShowDiff; - let formattedName: string | JSX.Element = name; - if (name.includes('Create2 Deployer')) { - const [first, _] = name.split('Create2 Deployer'); - formattedName = ( - <> -
{first}
-
Create2 Deployer
- - ); - } - return ( showDeployedContract && (
-
{formattedName}
+
{name}
{formatDeployedContract(baseDeployedContract)}
{formatDeployedContract(targetDeployedContract)}
diff --git a/src/components/diff/DiffOpcodes.tsx b/src/components/diff/DiffOpcodes.tsx index f89bfd47..8a1338eb 100644 --- a/src/components/diff/DiffOpcodes.tsx +++ b/src/components/diff/DiffOpcodes.tsx @@ -35,7 +35,7 @@ export const DiffOpcodes = ({ base, target, onlyShowDiff }: Props): JSX.Element const baseOpcode = base.find((opcode) => Number(opcode.number) === number); const targetOpcode = target.find((opcode) => Number(opcode.number) === number); if (!baseOpcode || !targetOpcode) { - return false + return false; } const isEqual = JSON.stringify(baseOpcode) === JSON.stringify(targetOpcode); diff --git a/src/pages/diff.tsx b/src/pages/diff.tsx index 6be1f994..10b838c3 100644 --- a/src/pages/diff.tsx +++ b/src/pages/diff.tsx @@ -33,12 +33,12 @@ interface Section { const SECTION_MAP: Record = { metadata: { title: 'Metadata', component: DiffMetadata }, opcodes: { title: 'Opcodes', component: DiffOpcodes }, + deployedContracts: { title: 'Deployed Contracts', component: DiffDeployedContracts }, // precompiles: { title: 'Precompiles', component: DiffPrecompiles }, // predeploys: { title: 'Predeploys', component: DiffPredeploys }, // signatureTypes: { title: 'Transaction and Signature Types', component: DiffSignatureTypes }, // accountTypes: { title: 'Account Types', component: DiffAccountTypes }, // mempools: { title: 'Mempools', component: DiffMempools }, - // deployedContracts: { title: 'Deployed Contracts', component: DiffDeployedContracts }, // eips: { title: 'Execution EIPs', component: DiffEIPs }, // executionNodes: { title: 'Execution Nodes', component: DiffNodes }, // consensusNodes: { title: 'Consensus Nodes', component: DiffNodes, hide: true }, // Hidden to scope UI to execution data