Fixed inputs serialization
This commit is contained in:
parent
3795336fd8
commit
f204620fea
@ -1,6 +1,6 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
from mev_inspect.schemas.utils import to_json
|
||||
from mev_inspect.models.classified_traces import ClassifiedTraceModel
|
||||
from mev_inspect.schemas.classified_traces import ClassifiedTrace
|
||||
|
||||
@ -36,7 +36,7 @@ def write_classified_traces(
|
||||
"abi_name": trace.abi_name,
|
||||
"function_name": trace.function_name,
|
||||
"function_signature": trace.function_signature,
|
||||
# "inputs": json.dumps(trace.inputs),
|
||||
"inputs": to_json(trace.inputs),
|
||||
"from_address": trace.from_address,
|
||||
"to_address": trace.to_address,
|
||||
"gas": trace.gas,
|
||||
|
@ -15,6 +15,25 @@ def to_original_json_dict(model: BaseModel) -> dict:
|
||||
return json.loads(model.json(by_alias=True, exclude_unset=True))
|
||||
|
||||
|
||||
def to_json(d):
|
||||
if isinstance(d, dict):
|
||||
tmp = {}
|
||||
for key, value in d.items():
|
||||
if isinstance(value, bytes):
|
||||
tmp[key] = value.hex()
|
||||
if isinstance(value, tuple):
|
||||
res = []
|
||||
for val in value:
|
||||
if isinstance(val, bytes):
|
||||
res.append(val.hex())
|
||||
else:
|
||||
res.append(val)
|
||||
tmp[key] = res
|
||||
|
||||
d.update(tmp)
|
||||
return json.dumps(d)
|
||||
|
||||
|
||||
class Web3Model(BaseModel):
|
||||
"""BaseModel that handles web3's unserializable objects"""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user