-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathblocks.py
44 lines (40 loc) · 1.28 KB
/
blocks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from etherscan.enums.actions_enum import ActionsEnum as actions
from etherscan.enums.fields_enum import FieldsEnum as fields
from etherscan.enums.modules_enum import ModulesEnum as modules
class Blocks:
@staticmethod
def get_block_reward_by_block_number(block_no: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.BLOCK}"
f"{fields.ACTION}"
f"{actions.GET_BLOCK_REWARD}"
f"{fields.BLOCKNO}"
f"{block_no}"
)
return url
@staticmethod
def get_est_block_countdown_time_by_block_number(block_no: str) -> str:
url = (
f"{fields.MODULE}"
f"{modules.BLOCK}"
f"{fields.ACTION}"
f"{actions.GET_BLOCK_COUNTDOWN}"
f"{fields.BLOCKNO}"
f"{block_no}"
)
return url
@staticmethod
def get_block_number_by_timestamp(timestamp: int, closest: str) -> str:
# NOTE: Supports UNIX timestamps in seconds
url = (
f"{fields.MODULE}"
f"{modules.BLOCK}"
f"{fields.ACTION}"
f"{actions.GET_BLOCK_NUMBER_BY_TIME}"
f"{fields.TIMESTAMP}"
f"{timestamp}"
f"{fields.CLOSEST}"
f"{closest}"
)
return url