Skip to content

Commit 2aa413e

Browse files
committed
add deployed contracts to UI
1 parent df8838d commit 2aa413e

File tree

9 files changed

+44
-110
lines changed

9 files changed

+44
-110
lines changed

script/checks/deployed-contracts.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const deployedContracts: { name: string; address: Address }[] = [
2222
},
2323
{ name: 'Create2Deployer', address: '0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2' },
2424
// ERC-4337.
25-
{ name: 'ERC-4337 EntryPoint v0.6', address: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' },
25+
{ name: 'ERC-4337 Entry Point v0.6', address: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' },
2626
{
27-
name: 'ERC-4337 SimpleAccountFactory v0.6',
27+
name: 'ERC-4337 Simple Account Factory v0.6',
2828
address: '0x9406Cc6185a346906296840746125a0E44976454',
2929
},
3030
// Other

script/data/chain/1.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@
218218
"hasCode": true
219219
},
220220
{
221-
"name": "ERC-4337 EntryPoint v0.6",
221+
"name": "ERC-4337 Entry Point v0.6",
222222
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
223223
"codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70",
224224
"hasCode": true
225225
},
226226
{
227-
"name": "ERC-4337 SimpleAccountFactory v0.6",
227+
"name": "ERC-4337 Simple Account Factory v0.6",
228228
"address": "0x9406Cc6185a346906296840746125a0E44976454",
229229
"codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515",
230230
"hasCode": true

script/data/chain/10.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@
204204
"hasCode": true
205205
},
206206
{
207-
"name": "ERC-4337 EntryPoint v0.6",
207+
"name": "ERC-4337 Entry Point v0.6",
208208
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
209209
"codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70",
210210
"hasCode": true
211211
},
212212
{
213-
"name": "ERC-4337 SimpleAccountFactory v0.6",
213+
"name": "ERC-4337 Simple Account Factory v0.6",
214214
"address": "0x9406Cc6185a346906296840746125a0E44976454",
215215
"codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515",
216216
"hasCode": true

script/data/chain/42161.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@
202202
"hasCode": true
203203
},
204204
{
205-
"name": "ERC-4337 EntryPoint v0.6",
205+
"name": "ERC-4337 Entry Point v0.6",
206206
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
207207
"codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70",
208208
"hasCode": true
209209
},
210210
{
211-
"name": "ERC-4337 SimpleAccountFactory v0.6",
211+
"name": "ERC-4337 Simple Account Factory v0.6",
212212
"address": "0x9406Cc6185a346906296840746125a0E44976454",
213213
"codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515",
214214
"hasCode": true

script/data/feature/deployedContracts.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
"hasCode": true
2020
},
2121
{
22-
"name": "ERC-4337 EntryPoint v0.6",
22+
"name": "ERC-4337 Entry Point v0.6",
2323
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
2424
"codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70",
2525
"hasCode": true
2626
},
2727
{
28-
"name": "ERC-4337 SimpleAccountFactory v0.6",
28+
"name": "ERC-4337 Simple Account Factory v0.6",
2929
"address": "0x9406Cc6185a346906296840746125a0E44976454",
3030
"codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515",
3131
"hasCode": true
@@ -63,13 +63,13 @@
6363
"hasCode": true
6464
},
6565
{
66-
"name": "ERC-4337 EntryPoint v0.6",
66+
"name": "ERC-4337 Entry Point v0.6",
6767
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
6868
"codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70",
6969
"hasCode": true
7070
},
7171
{
72-
"name": "ERC-4337 SimpleAccountFactory v0.6",
72+
"name": "ERC-4337 Simple Account Factory v0.6",
7373
"address": "0x9406Cc6185a346906296840746125a0E44976454",
7474
"codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515",
7575
"hasCode": true
@@ -107,13 +107,13 @@
107107
"hasCode": true
108108
},
109109
{
110-
"name": "ERC-4337 EntryPoint v0.6",
110+
"name": "ERC-4337 Entry Point v0.6",
111111
"address": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
112112
"codeHash": "0xc93c806e738300b5357ecdc2e971d6438d34d8e4e17b99b758b1f9cac91c8e70",
113113
"hasCode": true
114114
},
115115
{
116-
"name": "ERC-4337 SimpleAccountFactory v0.6",
116+
"name": "ERC-4337 Simple Account Factory v0.6",
117117
"address": "0x9406Cc6185a346906296840746125a0E44976454",
118118
"codeHash": "0xe7ca0f7aa741031b27df24056c8000e7df56cf8a4ff434e28b1bbe1aa6eaa515",
119119
"hasCode": true

script/index.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
import { http, fallback, createPublicClient } from 'viem';
22
import { checkDeployedContracts } from './checks/deployed-contracts';
3-
import { checkEvmStackAddresses, EVMStack, EVMStackResult } from './checks/evm-stack-addresses';
3+
import {
4+
checkEvmStackAddresses,
5+
type EVMStack,
6+
type EVMStackResult,
7+
} from './checks/evm-stack-addresses';
48
import { checkOpcodes } from './checks/opcodes';
59
import { checkPrecompiles } from './checks/precompiles';
610
import type { Metadata } from './types';
711

812
export type Chain = {
913
metadata: Metadata;
1014
opcodes: {
11-
number: `0x${string}`;
12-
name: string;
13-
supported: string | boolean;
15+
number: `0x${string}`;
16+
name: string;
17+
supported: string | boolean;
1418
}[];
1519
deployedContracts: {
1620
name: string;
17-
address: `0x${string}`;
18-
codeHash: `0x${string}`;
19-
hasCode: boolean;
21+
address: `0x${string}`;
22+
codeHash: `0x${string}`;
23+
hasCode: boolean;
2024
}[];
2125
precompiles: {
2226
name: string;
23-
address: `0x${string}`;
24-
implemented: boolean;
27+
address: `0x${string}`;
28+
implemented: boolean;
2529
}[];
2630
evmStackAddresses: Record<EVMStack, EVMStackResult[]>;
27-
}
31+
};
2832

2933
async function main() {
3034
// Initialize chain data.

src/components/diff/DiffDeployedContracts.tsx

+14-84
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import { Address, getAddress } from 'viem';
2-
import { Abi } from '@/components/diff/utils/Abi';
3-
import { Collapsible } from '@/components/diff/utils/Collapsible';
4-
import { Markdown } from '@/components/diff/utils/Markdown';
2+
import { Chain } from '@/../script/index';
53
import { RenderDiff } from '@/components/diff/utils/RenderDiff';
64
import { Copyable } from '@/components/ui/Copyable';
7-
import {
8-
DeployedContract,
9-
DeployedContractKind,
10-
ProxiedDeployedContract,
11-
StandardDeployedContract,
12-
} from '@/types';
135

6+
type DeployedContract = Chain['deployedContracts'][0];
147
type Props = {
158
base: DeployedContract[];
169
target: DeployedContract[];
@@ -19,86 +12,34 @@ type Props = {
1912

2013
const formatDeployedContract = (deployedContract: DeployedContract | undefined) => {
2114
if (!deployedContract) return <p>Not present</p>;
22-
23-
const title =
24-
deployedContract.kind === DeployedContractKind.WrappedNativeAsset ? (
25-
<Markdown
26-
codeSize='0.9rem'
27-
content={`${deployedContract.tokenName!} (${deployedContract.tokenSymbol!})`}
28-
/>
29-
) : (
30-
<Markdown codeSize='0.9rem' content={deployedContract.name} />
31-
);
32-
3315
const addr = getAddress(deployedContract.address);
34-
const deployInstructions = deployedContract.deploymentInstructions || 'N/A';
35-
3616
return (
3717
<>
38-
<div>{title}</div>
39-
<div className='text-secondary text-sm'>
40-
<Markdown content={deployedContract.description} />
41-
</div>
42-
<div className='text-secondary mt-3 grid grid-cols-4 space-y-1 text-sm'>
18+
<div className='mt-3 grid grid-cols-8 space-y-1'>
4319
<div className='col-span-2'>Address</div>
44-
<div className='col-span-2'>
20+
<div className='col-span-6'>
4521
<Copyable content={formatAddress(addr)} textToCopy={getAddress(addr)} />
4622
</div>
4723

48-
<div className='col-span-2'>Deploy Instructions</div>
49-
<div className='col-span-2'>
50-
<Markdown content={deployInstructions} />
51-
</div>
52-
</div>
53-
<div className='mt-4'>
54-
<Abi contract={deployedContract} />
55-
<Collapsible kind='references' contents={deployedContract.references} />
24+
<div className='col-span-2'>Deployed?</div>
25+
<div className='col-span-6'>{deployedContract.hasCode ? 'Yes' : 'No'}</div>
5626
</div>
5727
</>
5828
);
5929
};
6030

31+
export const convertToComparableContract = (contract: DeployedContract | undefined) => {
32+
if (typeof contract === 'undefined') return undefined;
33+
const slimmedContract = contract as any;
34+
delete slimmedContract.codeHash;
35+
return slimmedContract;
36+
};
37+
6138
const formatAddress = (addr: Address) => {
6239
addr = getAddress(addr);
6340
return <code className='text-sm'>{`${addr.slice(0, 6)}...${addr.slice(-4)}`}</code>;
6441
};
6542

66-
type OmittedStandardDeployedContract = Omit<
67-
StandardDeployedContract,
68-
'description' | 'deploymentInstructions' | 'references'
69-
>;
70-
type OmittedProxiedDeployedContract = Omit<
71-
ProxiedDeployedContract,
72-
'description' | 'deploymentInstructions' | 'references'
73-
>;
74-
75-
export const convertToComparableContract = (
76-
contract: DeployedContract | undefined
77-
): OmittedStandardDeployedContract | OmittedProxiedDeployedContract | undefined => {
78-
if (typeof contract === 'undefined') return undefined;
79-
80-
const baseReturnData: OmittedStandardDeployedContract = {
81-
name: contract.name,
82-
kind: contract.kind,
83-
tokenName: contract.tokenName,
84-
tokenSymbol: contract.tokenSymbol,
85-
address: contract.address,
86-
notes: contract.notes,
87-
logicAbi: contract.logicAbi.sort(),
88-
};
89-
90-
if ('proxyAbi' in contract) {
91-
const proxiedReturnData: OmittedProxiedDeployedContract = {
92-
...baseReturnData,
93-
proxyAbi: contract.proxyAbi.sort(),
94-
logicAddress: contract.logicAddress,
95-
};
96-
return proxiedReturnData;
97-
}
98-
99-
return baseReturnData;
100-
};
101-
10243
export const DiffDeployedContracts = ({ base, target, onlyShowDiff }: Props) => {
10344
const sortedNames = [...base.map((c) => c.name), ...target.map((c) => c.name)].sort((a, b) =>
10445
a.localeCompare(b)
@@ -117,24 +58,13 @@ export const DiffDeployedContracts = ({ base, target, onlyShowDiff }: Props) =>
11758

11859
const showDeployedContract = !isEqual || !onlyShowDiff;
11960

120-
let formattedName: string | JSX.Element = name;
121-
if (name.includes('Create2 Deployer')) {
122-
const [first, _] = name.split('Create2 Deployer');
123-
formattedName = (
124-
<>
125-
<div>{first}</div>
126-
<div>Create2 Deployer</div>
127-
</>
128-
);
129-
}
130-
13161
return (
13262
showDeployedContract && (
13363
<div
13464
key={name}
13565
className='grid grid-cols-12 items-center border-b border-zinc-500/10 py-6 dark:border-zinc-500/20'
13666
>
137-
<div className='col-span-2'>{formattedName}</div>
67+
<div className='col-span-2'>{name}</div>
13868
<div className='col-span-5 pr-4'>{formatDeployedContract(baseDeployedContract)}</div>
13969
<div className='col-span-5'>{formatDeployedContract(targetDeployedContract)}</div>
14070
</div>

src/components/diff/DiffOpcodes.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const DiffOpcodes = ({ base, target, onlyShowDiff }: Props): JSX.Element
3535
const baseOpcode = base.find((opcode) => Number(opcode.number) === number);
3636
const targetOpcode = target.find((opcode) => Number(opcode.number) === number);
3737
if (!baseOpcode || !targetOpcode) {
38-
return false
38+
return false;
3939
}
4040

4141
const isEqual = JSON.stringify(baseOpcode) === JSON.stringify(targetOpcode);

src/pages/diff.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ interface Section {
3333
const SECTION_MAP: Record<string, Section> = {
3434
metadata: { title: 'Metadata', component: DiffMetadata },
3535
opcodes: { title: 'Opcodes', component: DiffOpcodes },
36+
deployedContracts: { title: 'Deployed Contracts', component: DiffDeployedContracts },
3637
// precompiles: { title: 'Precompiles', component: DiffPrecompiles },
3738
// predeploys: { title: 'Predeploys', component: DiffPredeploys },
3839
// signatureTypes: { title: 'Transaction and Signature Types', component: DiffSignatureTypes },
3940
// accountTypes: { title: 'Account Types', component: DiffAccountTypes },
4041
// mempools: { title: 'Mempools', component: DiffMempools },
41-
// deployedContracts: { title: 'Deployed Contracts', component: DiffDeployedContracts },
4242
// eips: { title: 'Execution EIPs', component: DiffEIPs },
4343
// executionNodes: { title: 'Execution Nodes', component: DiffNodes },
4444
// consensusNodes: { title: 'Consensus Nodes', component: DiffNodes, hide: true }, // Hidden to scope UI to execution data

0 commit comments

Comments
 (0)