@@ -109,7 +109,9 @@ def application(self) -> KInner:
109
109
methods : Tuple [Method , ...]
110
110
test_methods : Tuple [Method , ...]
111
111
fields : FrozenDict
112
- srcmap : Optional [Dict [int , str ]]
112
+ srcmap : Optional [Dict [int , Tuple [int , int , int , str , int ]]]
113
+ contract_id : int
114
+ contract_path : Path
113
115
114
116
def __init__ (self , contract_name : str , contract_json : Dict , foundry : bool = False ) -> None :
115
117
def _get_method_abi (_mname : str ) -> Dict :
@@ -152,6 +154,8 @@ def _get_method_abi(_mname: str) -> Dict:
152
154
self .fields = FrozenDict (_fields )
153
155
154
156
self .srcmap = None
157
+ self .contract_id = contract_json ['id' ]
158
+ self .contract_path = contract_json ['ast' ]['absolutePath' ]
155
159
if len (self .bytecode ) > 0 :
156
160
instr_to_pc = {}
157
161
pc = 0
@@ -166,13 +170,29 @@ def _get_method_abi(_mname: str) -> Dict:
166
170
pc += 1
167
171
instr += 1
168
172
169
- instr_srcmap = (
173
+ instrs_srcmap = (
170
174
contract_json ['evm' ]['deployedBytecode' ]['sourceMap' ]
171
175
if not foundry
172
176
else contract_json ['deployedBytecode' ]['sourceMap' ]
173
177
).split (';' )
174
178
175
- self .srcmap = {instr_to_pc [instr ]: src for instr , src in enumerate (instr_srcmap )}
179
+ s , l , f , j , m = (0 , 0 , 0 , '' , 0 )
180
+ _srcmap = {}
181
+ for i , instr_srcmap in enumerate (instrs_srcmap ):
182
+ fields = instr_srcmap .split (':' )
183
+ if len (fields ) > 0 and fields [0 ] != '' :
184
+ s = int (fields [0 ])
185
+ if len (fields ) > 1 and fields [1 ] != '' :
186
+ l = int (fields [1 ])
187
+ if len (fields ) > 2 and fields [2 ] != '' :
188
+ f = int (fields [2 ])
189
+ if len (fields ) > 3 and fields [3 ] != '' :
190
+ j = fields [3 ]
191
+ if len (fields ) > 4 and fields [4 ] != '' :
192
+ m = int (fields [4 ])
193
+ _srcmap [i ] = (s , l , f , j , m )
194
+
195
+ self .srcmap = _srcmap
176
196
177
197
@staticmethod
178
198
def contract_to_module_name (c : str , spec : bool = True ) -> str :
0 commit comments