Skip to content

Commit

Permalink
cache from json file
Browse files Browse the repository at this point in the history
  • Loading branch information
msabvid committed Feb 21, 2024
1 parent d6313a1 commit 04822d0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/verbs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Ethereum ABI and numerical utilities
"""

import json
import typing

import eth_abi
Expand Down Expand Up @@ -219,6 +220,28 @@ def cache_from_json(cache_json: typing.List) -> verbs.types.Cache:
return (cache_json[0], cache_json[1], accounts, storage)


def cache_from_file(cache_file: str) -> verbs.types.Cache:
"""
Loads a cache from a JSON file and converts a
cache JSON data into compatible env compatible format
Parameters
----------
cache_file: str
Cache JSON file.
Returns
-------
verbs.types.Cache
Cache converted to format for initialisation of a
simulation environment.
"""
with open(cache_file, "r") as f:
cache_json = json.load(f)

return verbs.utils.cache_from_json(cache_json)


def events_to_dataframe(events: typing.List[typing.Tuple]) -> pd.DataFrame:
"""
Convert a list of event tuples to a Pandas dataframe
Expand Down

0 comments on commit 04822d0

Please sign in to comment.