Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82f30d4

Browse files
author
Kotsias, Panagiotis-Christos
committed
Added build and dist
1 parent fea7b0d commit 82f30d4

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

build/lib/etherscan/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from .modules.accounts import Accounts as accounts
2+
from .modules.blocks import Blocks as blocks
3+
from .modules.contracts import Contracts as contracts
4+
from .modules.gastracker import GasTracker as gastracker
5+
from .modules.proxy import Proxy as proxy
6+
from .modules.stats import Stats as stats
7+
from .modules.tokens import Tokens as tokens
8+
from .modules.transactions import Transactions as transactions
9+
from .etherscan import Etherscan

build/lib/etherscan/etherscan.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import json
2+
3+
import requests
4+
5+
import etherscan
6+
from etherscan.enums.fields_enum import FieldsEnum as fields
7+
from etherscan.utils.parsing import ResponseParser as parser
8+
9+
10+
class Etherscan:
11+
@staticmethod
12+
def __load_config(config_path: str) -> dict:
13+
with open(config_path, "r") as f:
14+
return json.load(f)
15+
16+
@staticmethod
17+
def __run(func, api_key):
18+
def wrapper(*args, **kwargs):
19+
url = (
20+
f"{fields.PREFIX}"
21+
f"{func(*args, **kwargs)}"
22+
f"{fields.API_KEY}"
23+
f"{api_key}"
24+
)
25+
r = requests.get(url)
26+
return parser.parse(r)
27+
28+
return wrapper
29+
30+
@classmethod
31+
def from_config(cls, config_path: str, api_key: str):
32+
config = cls.__load_config(config_path)
33+
for func, v in config.items():
34+
if not func.startswith("_"): # disabled if _
35+
attr = getattr(getattr(etherscan, v["module"]), func)
36+
setattr(cls, func, cls.__run(attr, api_key))
37+
return cls

dist/etherscan-python-1.0.2.tar.gz

4.32 KB
Binary file not shown.
2.89 KB
Binary file not shown.

0 commit comments

Comments
 (0)