1
1
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' ;
5
3
import { RenderDiff } from '@/components/diff/utils/RenderDiff' ;
6
4
import { Copyable } from '@/components/ui/Copyable' ;
7
- import {
8
- DeployedContract ,
9
- DeployedContractKind ,
10
- ProxiedDeployedContract ,
11
- StandardDeployedContract ,
12
- } from '@/types' ;
13
5
6
+ type DeployedContract = Chain [ 'deployedContracts' ] [ 0 ] ;
14
7
type Props = {
15
8
base : DeployedContract [ ] ;
16
9
target : DeployedContract [ ] ;
@@ -19,86 +12,34 @@ type Props = {
19
12
20
13
const formatDeployedContract = ( deployedContract : DeployedContract | undefined ) => {
21
14
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
-
33
15
const addr = getAddress ( deployedContract . address ) ;
34
- const deployInstructions = deployedContract . deploymentInstructions || 'N/A' ;
35
-
36
16
return (
37
17
< >
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' >
43
19
< div className = 'col-span-2' > Address</ div >
44
- < div className = 'col-span-2 ' >
20
+ < div className = 'col-span-6 ' >
45
21
< Copyable content = { formatAddress ( addr ) } textToCopy = { getAddress ( addr ) } />
46
22
</ div >
47
23
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 >
56
26
</ div >
57
27
</ >
58
28
) ;
59
29
} ;
60
30
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
+
61
38
const formatAddress = ( addr : Address ) => {
62
39
addr = getAddress ( addr ) ;
63
40
return < code className = 'text-sm' > { `${ addr . slice ( 0 , 6 ) } ...${ addr . slice ( - 4 ) } ` } </ code > ;
64
41
} ;
65
42
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
-
102
43
export const DiffDeployedContracts = ( { base, target, onlyShowDiff } : Props ) => {
103
44
const sortedNames = [ ...base . map ( ( c ) => c . name ) , ...target . map ( ( c ) => c . name ) ] . sort ( ( a , b ) =>
104
45
a . localeCompare ( b )
@@ -117,24 +58,13 @@ export const DiffDeployedContracts = ({ base, target, onlyShowDiff }: Props) =>
117
58
118
59
const showDeployedContract = ! isEqual || ! onlyShowDiff ;
119
60
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
-
131
61
return (
132
62
showDeployedContract && (
133
63
< div
134
64
key = { name }
135
65
className = 'grid grid-cols-12 items-center border-b border-zinc-500/10 py-6 dark:border-zinc-500/20'
136
66
>
137
- < div className = 'col-span-2' > { formattedName } </ div >
67
+ < div className = 'col-span-2' > { name } </ div >
138
68
< div className = 'col-span-5 pr-4' > { formatDeployedContract ( baseDeployedContract ) } </ div >
139
69
< div className = 'col-span-5' > { formatDeployedContract ( targetDeployedContract ) } </ div >
140
70
</ div >
0 commit comments