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

safe-global / safe-cli / 9679828121

26 Jun 2024 12:41PM UTC coverage: 87.47% (+0.2%) from 87.279%
9679828121

push

github

web-flow
Adding support for executing transactions in scripting mode (#419)

* Add send_ether command

* Add send_custom, send_erc20 and send_erc721 commands

* Add tx_builder command

* Add support for env keys

* Add test to tx_builder_decoder

* Update Readme

* Fix encoding of tuple type

* Merge safe-cli and safe-runner

* Apply PR suggestions

* Revert tx_builder command

* Update feedback messages to user.

* Improve default command validation

* Add interactive/no-interactive option

* Update common parameters

750 of 869 branches covered (86.31%)

Branch coverage included in aggregate %.

291 of 319 new or added lines in 7 files covered. (91.22%)

6 existing lines in 2 files now uncovered.

2552 of 2906 relevant lines covered (87.82%)

3.51 hits per line

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

97.37
/src/safe_cli/typer_validators.py
1
import os
4✔
2
from binascii import Error
4✔
3
from typing import List
4✔
4

5
import click
4✔
6
import typer
4✔
7
from eth_account import Account
4✔
8
from eth_typing import ChecksumAddress
4✔
9
from hexbytes import HexBytes
4✔
10
from web3 import Web3
4✔
11

12

13
def check_ethereum_address(address: str) -> ChecksumAddress:
4✔
14
    """
15
    Ethereum address validator
16
    """
17
    if not Web3.is_checksum_address(address):
4✔
18
        raise typer.BadParameter("Invalid ethereum address")
4✔
19
    return ChecksumAddress(address)
4✔
20

21

22
class ChecksumAddressParser(click.ParamType):
4✔
23
    name = "ChecksumAddress"
4✔
24

25
    def convert(self, value, param, ctx):
4✔
26
        """
27
        ChecksumAddress parser from str
28
        """
29
        return ChecksumAddress(value)
4✔
30

31

32
def check_private_keys(private_keys: List[str]) -> List[str]:
4✔
33
    """
34
    Private Keys validator
35
    """
36
    if private_keys is None:
4✔
NEW
37
        raise typer.BadParameter("At least one private key is required")
×
38
    for private_key in private_keys:
4✔
39
        try:
4✔
40
            Account.from_key(os.environ.get(private_key, default=private_key))
4✔
41
        except (ValueError, Error):
4✔
42
            raise typer.BadParameter(f"{private_key} is not a valid private key")
4✔
43
    return private_keys
4✔
44

45

46
def check_hex_str(hex_str: str) -> HexBytes:
4✔
47
    """
48
    HexBytes string validator
49
    """
50
    try:
4✔
51
        return HexBytes(hex_str)
4✔
52
    except ValueError:
4✔
53
        raise typer.BadParameter(f"{hex_str} is not a valid hexadecimal string")
4✔
54

55

56
class HexBytesParser(click.ParamType):
4✔
57
    name = "HexBytes"
4✔
58

59
    def convert(self, value, param, ctx):
4✔
60
        """
61
        HexBytes string parser from str
62
        """
63
        return HexBytes(value)
4✔
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