• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ape364 / aioetherscan / 11508304044

24 Oct 2024 10:16PM UTC coverage: 100.0%. Remained the same
11508304044

Pull #33

github

ape364
fix: pragma: no cover
Pull Request #33: feat: add api keys rotating

41 of 41 new or added lines in 4 files covered. (100.0%)

699 of 699 relevant lines covered (100.0%)

4.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/aioetherscan/common.py
1
from datetime import date
4✔
2
from typing import Union
4✔
3

4

5
def check_value(value: str, values: tuple[str, ...]) -> str:
4✔
6
    if value and value.lower() not in values:
4✔
7
        raise ValueError(f'Invalid value {value!r}, only {values} are supported.')
4✔
8
    return value
4✔
9

10

11
def check_hex(number: Union[str, int]) -> str:
4✔
12
    if isinstance(number, int):
4✔
13
        return hex(number)
4✔
14
    try:
4✔
15
        int(number, 16)
4✔
16
    except ValueError as e:
4✔
17
        raise ValueError(f'Invalid hex parameter {number!r}: {e}')
4✔
18
    else:
19
        return number
4✔
20

21

22
def check_tag(tag: Union[str, int]) -> str:
4✔
23
    _TAGS = (
4✔
24
        'earliest',  # the earliest/genesis block
25
        'latest',  # the latest mined block
26
        'pending',  # for the pending state/transactions
27
    )
28

29
    if tag in _TAGS:
4✔
30
        return tag
4✔
31
    return check_hex(tag)
4✔
32

33

34
def check_sort_direction(sort: str) -> str:
4✔
35
    _SORT_ORDERS = (
4✔
36
        'asc',  # ascending order
37
        'desc',  # descending order
38
    )
39
    return check_value(sort, _SORT_ORDERS)
4✔
40

41

42
def check_blocktype(blocktype: str) -> str:
4✔
43
    _BLOCK_TYPES = (
4✔
44
        'blocks',  # full blocks only
45
        'uncles',  # uncle blocks only
46
    )
47
    return check_value(blocktype, _BLOCK_TYPES)
4✔
48

49

50
def check_closest_value(closest_value: str) -> str:
4✔
51
    _CLOSEST_VALUES = (
4✔
52
        'before',  # ascending order
53
        'after',  # descending order
54
    )
55

56
    return check_value(closest_value, _CLOSEST_VALUES)
4✔
57

58

59
def check_client_type(client_type: str) -> str:
4✔
60
    _CLIENT_TYPES = (
4✔
61
        'geth',
62
        'parity',
63
    )
64

65
    return check_value(client_type, _CLIENT_TYPES)
4✔
66

67

68
def check_sync_mode(sync_mode: str) -> str:
4✔
69
    _SYNC_MODES = (
4✔
70
        'default',
71
        'archive',
72
    )
73

74
    return check_value(sync_mode, _SYNC_MODES)
4✔
75

76

77
def check_token_standard(token_standard: str) -> str:
4✔
78
    _TOKEN_STANDARDS = (
4✔
79
        'erc20',
80
        'erc721',
81
        'erc1155',
82
    )
83

84
    return check_value(token_standard, _TOKEN_STANDARDS)
4✔
85

86

87
def get_daily_stats_params(action: str, start_date: date, end_date: date, sort: str) -> dict:
4✔
88
    return dict(
4✔
89
        module='stats',
90
        action=action,
91
        startdate=start_date.isoformat(),
92
        enddate=end_date.isoformat(),
93
        sort=check_sort_direction(sort),
94
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc