File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 11import json
2+ from importlib import resources
23
34import requests
45
56import etherscan
7+ from etherscan import configs
68from etherscan .enums .fields_enum import FieldsEnum as fields
79from etherscan .utils .parsing import ResponseParser as parser
810
911
1012class Etherscan :
13+ def __new__ (cls , api_key : str ):
14+ with resources .path (configs , "stable.json" ) as path :
15+ config_path = str (path )
16+ return cls .from_config (api_key = api_key , config_path = config_path )
17+
1118 @staticmethod
1219 def __load_config (config_path : str ) -> dict :
1320 with open (config_path , "r" ) as f :
1421 return json .load (f )
1522
1623 @staticmethod
17- def __run (func , api_key ):
24+ def __run (func , api_key : str ):
1825 def wrapper (* args , ** kwargs ):
1926 url = (
2027 f"{ fields .PREFIX } "
@@ -28,7 +35,7 @@ def wrapper(*args, **kwargs):
2835 return wrapper
2936
3037 @classmethod
31- def from_config (cls , config_path : str , api_key : str ):
38+ def from_config (cls , api_key : str , config_path : str ):
3239 config = cls .__load_config (config_path )
3340 for func , v in config .items ():
3441 if not func .startswith ("_" ): # disabled if _
You can’t perform that action at this time.
0 commit comments