Move ABIs to directory

This commit is contained in:
Luke Van Seters 2021-07-25 20:00:05 -04:00
parent 08fb4972aa
commit de733ecfb3
6 changed files with 16 additions and 15 deletions

View File

@ -1,20 +1,22 @@
import json import json
from pathlib import Path
from typing import Optional from typing import Optional
from pydantic import parse_obj_as from pydantic import parse_obj_as
from mev_inspect.config import load_config
from mev_inspect.schemas import ABI from mev_inspect.schemas import ABI
ABI_CONFIG_KEY = "ABI" THIS_FILE_DIRECTORY = Path(__file__).parents[0]
ABI_DIRECTORY_PATH = THIS_FILE_DIRECTORY / "abis"
config = load_config()
def get_abi(abi_name: str) -> Optional[ABI]: def get_abi(abi_name: str) -> Optional[ABI]:
if abi_name in config[ABI_CONFIG_KEY]: abi_path = ABI_DIRECTORY_PATH / f"{abi_name}.json"
abi_json = json.loads(config[ABI_CONFIG_KEY][abi_name])
return parse_obj_as(ABI, abi_json) if abi_path.is_file():
with abi_path.open() as abi_file:
abi_json = json.load(abi_file)
return parse_obj_as(ABI, abi_json)
return None return None

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
[{"inputs": [{"internalType": "contract UniswapV2Factory", "name": "_uniswapFactory", "type": "address"}, {"internalType": "uint256", "name": "_start", "type": "uint256"}, {"internalType": "uint256", "name": "_stop", "type": "uint256"}], "name": "getPairsByIndexRange", "outputs": [{"internalType": "address[3][]", "name": "", "type": "address[3][]"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "contract IUniswapV2Pair[]", "name": "_pairs", "type": "address[]"}], "name": "getReservesByPairs", "outputs": [{"internalType": "uint256[3][]", "name": "", "type": "uint256[3][]"}], "stateMutability": "view", "type": "function"}]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long