@@ -115,29 +115,43 @@ def _contract2(self) -> Contract:
115
115
def _check (self ) -> List [Output ]:
116
116
contract1 = self ._contract1 ()
117
117
contract2 = self ._contract2 ()
118
- order1 = contract1 .stored_state_variables_ordered
119
- order2 = contract2 .stored_state_variables_ordered
120
118
121
119
results : List [Output ] = []
122
- for idx , _ in enumerate (order1 ):
123
- if len (order2 ) <= idx :
124
- # Handle by MissingVariable
125
- return results
126
-
127
- variable1 = order1 [idx ]
128
- variable2 = order2 [idx ]
129
- if (variable1 .name != variable2 .name ) or (variable1 .type != variable2 .type ):
130
- info : CHECK_INFO = [
131
- "Different variables between " ,
132
- contract1 ,
133
- " and " ,
134
- contract2 ,
135
- "\n " ,
136
- ]
137
- info += ["\t " , variable1 , "\n " ]
138
- info += ["\t " , variable2 , "\n " ]
139
- json = self .generate_result (info )
140
- results .append (json )
120
+
121
+ def _check_internal (
122
+ contract1 : Contract , contract2 : Contract , results : List [Output ], is_transient : bool
123
+ ):
124
+ if is_transient :
125
+ order1 = contract1 .transient_variables_ordered
126
+ order2 = contract2 .transient_variables_ordered
127
+ else :
128
+ order1 = contract1 .storage_variables_ordered
129
+ order2 = contract2 .storage_variables_ordered
130
+
131
+ for idx , _ in enumerate (order1 ):
132
+ if len (order2 ) <= idx :
133
+ # Handle by MissingVariable
134
+ return
135
+
136
+ variable1 = order1 [idx ]
137
+ variable2 = order2 [idx ]
138
+ if (variable1 .name != variable2 .name ) or (variable1 .type != variable2 .type ):
139
+ info : CHECK_INFO = [
140
+ "Different variables between " ,
141
+ contract1 ,
142
+ " and " ,
143
+ contract2 ,
144
+ "\n " ,
145
+ ]
146
+ info += ["\t " , variable1 , "\n " ]
147
+ info += ["\t " , variable2 , "\n " ]
148
+ json = self .generate_result (info )
149
+ results .append (json )
150
+
151
+ # Checking state variables with storage location
152
+ _check_internal (contract1 , contract2 , results , False )
153
+ # Checking state variables with transient location
154
+ _check_internal (contract1 , contract2 , results , True )
141
155
142
156
return results
143
157
@@ -236,22 +250,35 @@ def _contract2(self) -> Contract:
236
250
def _check (self ) -> List [Output ]:
237
251
contract1 = self ._contract1 ()
238
252
contract2 = self ._contract2 ()
239
- order1 = contract1 .stored_state_variables_ordered
240
- order2 = contract2 .stored_state_variables_ordered
241
253
242
- results = []
254
+ results : List [ Output ] = []
243
255
244
- if len (order2 ) <= len (order1 ):
245
- return []
256
+ def _check_internal (
257
+ contract1 : Contract , contract2 : Contract , results : List [Output ], is_transient : bool
258
+ ):
259
+ if is_transient :
260
+ order1 = contract1 .transient_variables_ordered
261
+ order2 = contract2 .transient_variables_ordered
262
+ else :
263
+ order1 = contract1 .storage_variables_ordered
264
+ order2 = contract2 .storage_variables_ordered
246
265
247
- idx = len (order1 )
266
+ if len (order2 ) <= len (order1 ):
267
+ return
248
268
249
- while idx < len (order2 ):
250
- variable2 = order2 [idx ]
251
- info : CHECK_INFO = ["Extra variables in " , contract2 , ": " , variable2 , "\n " ]
252
- json = self .generate_result (info )
253
- results .append (json )
254
- idx = idx + 1
269
+ idx = len (order1 )
270
+
271
+ while idx < len (order2 ):
272
+ variable2 = order2 [idx ]
273
+ info : CHECK_INFO = ["Extra variables in " , contract2 , ": " , variable2 , "\n " ]
274
+ json = self .generate_result (info )
275
+ results .append (json )
276
+ idx = idx + 1
277
+
278
+ # Checking state variables with storage location
279
+ _check_internal (contract1 , contract2 , results , False )
280
+ # Checking state variables with transient location
281
+ _check_internal (contract1 , contract2 , results , True )
255
282
256
283
return results
257
284
0 commit comments