Move ABIs to directory
This commit is contained in:
parent
08fb4972aa
commit
de733ecfb3
@ -1,20 +1,22 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import parse_obj_as
|
||||
|
||||
from mev_inspect.config import load_config
|
||||
from mev_inspect.schemas import ABI
|
||||
|
||||
|
||||
ABI_CONFIG_KEY = "ABI"
|
||||
|
||||
config = load_config()
|
||||
THIS_FILE_DIRECTORY = Path(__file__).parents[0]
|
||||
ABI_DIRECTORY_PATH = THIS_FILE_DIRECTORY / "abis"
|
||||
|
||||
|
||||
def get_abi(abi_name: str) -> Optional[ABI]:
|
||||
if abi_name in config[ABI_CONFIG_KEY]:
|
||||
abi_json = json.loads(config[ABI_CONFIG_KEY][abi_name])
|
||||
abi_path = ABI_DIRECTORY_PATH / f"{abi_name}.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
|
||||
|
2
mev_inspect/abis/AaveLendingPool.json
Normal file
2
mev_inspect/abis/AaveLendingPool.json
Normal file
File diff suppressed because one or more lines are too long
1
mev_inspect/abis/ReserveLookUp.json
Normal file
1
mev_inspect/abis/ReserveLookUp.json
Normal 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"}]
|
2
mev_inspect/abis/UniswapV2Pair.json
Normal file
2
mev_inspect/abis/UniswapV2Pair.json
Normal file
File diff suppressed because one or more lines are too long
2
mev_inspect/abis/UniswapV2Router.json
Normal file
2
mev_inspect/abis/UniswapV2Router.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user