1
1
from typing import Iterable , Optional , List , Dict
2
2
3
- from aioetherscan .common import check_tag , check_sort_direction , check_blocktype , check_token_standard
3
+ from aioetherscan .common import (
4
+ check_tag ,
5
+ check_sort_direction ,
6
+ check_blocktype ,
7
+ check_token_standard ,
8
+ )
4
9
from aioetherscan .modules .base import BaseModule
5
10
6
11
@@ -16,28 +21,22 @@ def _module(self) -> str:
16
21
17
22
async def balance (self , address : str , tag : str = 'latest' ) -> str :
18
23
"""Get Ether Balance for a single Address."""
19
- return await self ._get (
20
- action = 'balance' ,
21
- address = address ,
22
- tag = check_tag (tag )
23
- )
24
+ return await self ._get (action = 'balance' , address = address , tag = check_tag (tag ))
24
25
25
26
async def balances (self , addresses : Iterable [str ], tag : str = 'latest' ) -> List [Dict ]:
26
27
"""Get Ether Balance for multiple Addresses in a single call."""
27
28
return await self ._get (
28
- action = 'balancemulti' ,
29
- address = ',' .join (addresses ),
30
- tag = check_tag (tag )
29
+ action = 'balancemulti' , address = ',' .join (addresses ), tag = check_tag (tag )
31
30
)
32
31
33
32
async def normal_txs (
34
- self ,
35
- address : str ,
36
- start_block : Optional [int ] = None ,
37
- end_block : Optional [int ] = None ,
38
- sort : Optional [str ] = None ,
39
- page : Optional [int ] = None ,
40
- offset : Optional [int ] = None
33
+ self ,
34
+ address : str ,
35
+ start_block : Optional [int ] = None ,
36
+ end_block : Optional [int ] = None ,
37
+ sort : Optional [str ] = None ,
38
+ page : Optional [int ] = None ,
39
+ offset : Optional [int ] = None ,
41
40
) -> List [Dict ]:
42
41
"""Get a list of 'Normal' Transactions By Address."""
43
42
return await self ._get (
@@ -47,18 +46,18 @@ async def normal_txs(
47
46
endblock = end_block ,
48
47
sort = check_sort_direction (sort ),
49
48
page = page ,
50
- offset = offset
49
+ offset = offset ,
51
50
)
52
51
53
52
async def internal_txs (
54
- self ,
55
- address : str ,
56
- start_block : Optional [int ] = None ,
57
- end_block : Optional [int ] = None ,
58
- sort : Optional [str ] = None ,
59
- page : Optional [int ] = None ,
60
- offset : Optional [int ] = None ,
61
- txhash : Optional [str ] = None
53
+ self ,
54
+ address : str ,
55
+ start_block : Optional [int ] = None ,
56
+ end_block : Optional [int ] = None ,
57
+ sort : Optional [str ] = None ,
58
+ page : Optional [int ] = None ,
59
+ offset : Optional [int ] = None ,
60
+ txhash : Optional [str ] = None ,
62
61
) -> List [Dict ]:
63
62
"""Get a list of 'Internal' Transactions by Address or Transaction Hash."""
64
63
return await self ._get (
@@ -69,30 +68,26 @@ async def internal_txs(
69
68
sort = check_sort_direction (sort ),
70
69
page = page ,
71
70
offset = offset ,
72
- txhash = txhash
71
+ txhash = txhash ,
73
72
)
74
73
75
74
async def token_transfers (
76
- self ,
77
- address : Optional [str ] = None ,
78
- contract_address : Optional [str ] = None ,
79
- start_block : Optional [int ] = None ,
80
- end_block : Optional [int ] = None ,
81
- sort : Optional [str ] = None ,
82
- page : Optional [int ] = None ,
83
- offset : Optional [int ] = None ,
84
- token_standard : str = 'erc20'
75
+ self ,
76
+ address : Optional [str ] = None ,
77
+ contract_address : Optional [str ] = None ,
78
+ start_block : Optional [int ] = None ,
79
+ end_block : Optional [int ] = None ,
80
+ sort : Optional [str ] = None ,
81
+ page : Optional [int ] = None ,
82
+ offset : Optional [int ] = None ,
83
+ token_standard : str = 'erc20' ,
85
84
) -> List [Dict ]:
86
85
"""Get a list of "ERC20 - Token Transfer Events" by Address"""
87
86
if not address and not contract_address :
88
87
raise ValueError ('At least one of address or contract_address must be specified.' )
89
88
90
89
token_standard = check_token_standard (token_standard )
91
- actions = dict (
92
- erc20 = 'tokentx' ,
93
- erc721 = 'tokennfttx' ,
94
- erc1155 = 'token1155tx'
95
- )
90
+ actions = dict (erc20 = 'tokentx' , erc721 = 'tokennfttx' , erc1155 = 'token1155tx' )
96
91
97
92
return await self ._get (
98
93
action = actions .get (token_standard ),
@@ -102,36 +97,35 @@ async def token_transfers(
102
97
sort = check_sort_direction (sort ),
103
98
page = page ,
104
99
offset = offset ,
105
- contractaddress = contract_address
100
+ contractaddress = contract_address ,
106
101
)
107
102
108
103
async def mined_blocks (
109
- self ,
110
- address : str ,
111
- blocktype : str = 'blocks' ,
112
- page : Optional [int ] = None ,
113
- offset : Optional [int ] = None
104
+ self ,
105
+ address : str ,
106
+ blocktype : str = 'blocks' ,
107
+ page : Optional [int ] = None ,
108
+ offset : Optional [int ] = None ,
114
109
) -> List :
115
110
"""Get list of Blocks Validated by Address"""
116
111
return await self ._get (
117
112
action = 'getminedblocks' ,
118
113
address = address ,
119
114
blocktype = check_blocktype (blocktype ),
120
115
page = page ,
121
- offset = offset
116
+ offset = offset ,
122
117
)
123
118
124
119
async def beacon_chain_withdrawals (
125
- self ,
126
- address : str ,
127
- start_block : Optional [int ] = None ,
128
- end_block : Optional [int ] = None ,
129
- sort : Optional [str ] = None ,
130
- page : Optional [int ] = None ,
131
- offset : Optional [int ] = None ,
120
+ self ,
121
+ address : str ,
122
+ start_block : Optional [int ] = None ,
123
+ end_block : Optional [int ] = None ,
124
+ sort : Optional [str ] = None ,
125
+ page : Optional [int ] = None ,
126
+ offset : Optional [int ] = None ,
132
127
) -> List [Dict ]:
133
128
"""Get Beacon Chain Withdrawals by Address and Block Range"""
134
- # todo: refactor
135
129
return await self ._get (
136
130
action = 'txsBeaconWithdrawal' ,
137
131
address = address ,
@@ -145,8 +139,5 @@ async def beacon_chain_withdrawals(
145
139
async def account_balance_by_blockno (self , address : str , blockno : int ) -> str :
146
140
"""Get Historical Ether Balance for a Single Address By BlockNo"""
147
141
return await self ._get (
148
- module = 'account' ,
149
- action = 'balancehistory' ,
150
- address = address ,
151
- blockno = blockno
142
+ module = 'account' , action = 'balancehistory' , address = address , blockno = blockno
152
143
)
0 commit comments