File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import json
2
+ from importlib import resources
2
3
3
4
import requests
4
5
5
6
import etherscan
7
+ from etherscan import configs
6
8
from etherscan .enums .fields_enum import FieldsEnum as fields
7
9
from etherscan .utils .parsing import ResponseParser as parser
8
10
9
11
10
12
class 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
+
11
18
@staticmethod
12
19
def __load_config (config_path : str ) -> dict :
13
20
with open (config_path , "r" ) as f :
14
21
return json .load (f )
15
22
16
23
@staticmethod
17
- def __run (func , api_key ):
24
+ def __run (func , api_key : str ):
18
25
def wrapper (* args , ** kwargs ):
19
26
url = (
20
27
f"{ fields .PREFIX } "
@@ -28,7 +35,7 @@ def wrapper(*args, **kwargs):
28
35
return wrapper
29
36
30
37
@classmethod
31
- def from_config (cls , config_path : str , api_key : str ):
38
+ def from_config (cls , api_key : str , config_path : str ):
32
39
config = cls .__load_config (config_path )
33
40
for func , v in config .items ():
34
41
if not func .startswith ("_" ): # disabled if _
You can’t perform that action at this time.
0 commit comments