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

Skip to content

Commit a9a91ca

Browse files
author
Kotsias, Panagiotis-Christos
committed
Refactored to include kwargs and module
1 parent 7f72b21 commit a9a91ca

File tree

2 files changed

+108
-17
lines changed

2 files changed

+108
-17
lines changed

etherscan/client.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ def wrapper(*args, **kwargs):
2323
f"{api_key}"
2424
)
2525
r = requests.get(url)
26-
return parser.get_result(r)
26+
return (parser.get_result(r), parser.get_status(r), parser.get_message(r))
2727

2828
return wrapper
2929

3030
@classmethod
3131
def from_config(cls, config_path: str, api_key: str):
3232
config = cls.__load_config(config_path)
33-
for k, v in config.items():
34-
if not k.startswith("_"):
35-
attr = getattr(getattr(etherscan, v), k)
36-
setattr(cls, k, cls.__auth(attr, api_key))
33+
for func, v in config.items():
34+
if not func.startswith("_"):
35+
attr = getattr(getattr(etherscan, v["module"]), func)
36+
setattr(cls, func, cls.__auth(attr, api_key))
3737
return cls

etherscan/configs/stable.json

+103-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,105 @@
11
{
2-
"get_eth_balance": "accounts",
3-
"get_eth_balance_multiple": "accounts",
4-
"get_hist_eth_balance_by_block": "accounts",
5-
"get_normal_txs_by_address": "accounts",
6-
"get_normal_txs_by_address_paginated": "accounts",
7-
"get_internal_txs_by_address": "accounts",
8-
"get_internal_txs_by_address_paginated": "accounts",
9-
"get_internal_txs_by_txhash": "accounts",
10-
"get_internal_txs_by_block_range_paginated": "accounts",
11-
"get_erc20_token_transfer_events_by_address": "accounts",
12-
"get_erc721_token_transfer_events_by_address": "accounts",
13-
"get_mined_blocks_by_address": "accounts"
2+
"get_eth_balance": {
3+
"module": "accounts",
4+
"kwargs": {
5+
"wallet": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a"
6+
}
7+
},
8+
"get_eth_balance_multiple": {
9+
"module": "accounts",
10+
"kwargs": {
11+
"wallets": [
12+
"0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a",
13+
"0x63a9975ba31b0b9626b34300f7f627147df1f526",
14+
"0x198ef1ec325a96cc354c7266a038be8b5c558f67"
15+
]
16+
}
17+
},
18+
"get_hist_eth_balance_by_block": {
19+
"module": "accounts",
20+
"kwargs": {
21+
"wallet": "0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae",
22+
"block": 8000000
23+
}
24+
},
25+
"get_normal_txs_by_address": {
26+
"module": "accounts",
27+
"kwargs": {
28+
"wallet": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a",
29+
"startblock": 0,
30+
"endblock": 99999999,
31+
"sort": "asc"
32+
}
33+
},
34+
"get_normal_txs_by_address_paginated": {
35+
"module": "accounts",
36+
"kwargs": {
37+
"wallet": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a",
38+
"startblock": 0,
39+
"endblock": 99999999,
40+
"page": 1,
41+
"offset": 10,
42+
"sort": "asc"
43+
}
44+
},
45+
"get_internal_txs_by_address": {
46+
"module": "accounts",
47+
"kwargs": {
48+
"wallet": "0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3",
49+
"startblock": 0,
50+
"endblock": 2702578,
51+
"sort": "asc"
52+
}
53+
},
54+
"get_internal_txs_by_address_paginated": {
55+
"module": "accounts",
56+
"kwargs": {
57+
"wallet": "0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3",
58+
"startblock": 0,
59+
"endblock": 2702578,
60+
"page": 1,
61+
"offset": 10,
62+
"sort": "asc"
63+
}
64+
},
65+
"get_internal_txs_by_txhash": {
66+
"module": "accounts",
67+
"kwargs": {
68+
"txhash": "0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170"
69+
}
70+
},
71+
"get_internal_txs_by_block_range_paginated": {
72+
"module": "accounts",
73+
"kwargs": {
74+
"startblock": 0,
75+
"endblock": 2702578,
76+
"page": 1,
77+
"offset": 10,
78+
"sort": "asc"
79+
}
80+
},
81+
"get_erc20_token_transfer_events_by_address": {
82+
"module": "accounts",
83+
"kwargs": {
84+
"wallet": "0x4e83362442b8d1bec281594cea3050c8eb01311c",
85+
"startblock": 0,
86+
"endblock": 999999999,
87+
"sort": "asc"
88+
}
89+
},
90+
"get_erc721_token_transfer_events_by_address": {
91+
"module": "accounts",
92+
"kwargs": {
93+
"wallet": "0x6975be450864c02b4613023c2152ee0743572325",
94+
"startblock": 0,
95+
"endblock": 999999999,
96+
"sort": "asc"
97+
}
98+
},
99+
"get_mined_blocks_by_address": {
100+
"module": "accounts",
101+
"kwargs": {
102+
"wallet": "0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b"
103+
}
104+
}
14105
}

0 commit comments

Comments
 (0)