-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use TransactionServiceApi from safe-eth-py * Add tests for entrypoint * Add test for SafeLexer * Add tests for safe completer and utils * Add test for safe_creator * Remove pyfiglet (replace by art, due to Python 3.8 not supported anymore) * Check safe-cli package is valid before release * Add tx service operator delegate tests * Add test for submit_signatures * Split argparse validators into file * Add mock files for tx service * Test some missing functions for tx service operator * Remove old gnosis tx service test * Add missing docs * Remove redundant information
- Loading branch information
Showing
33 changed files
with
1,503 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import argparse | ||
from binascii import Error | ||
|
||
from eth_account import Account | ||
from eth_typing import ChecksumAddress | ||
from hexbytes import HexBytes | ||
from web3 import Web3 | ||
|
||
|
||
def check_positive_integer(number: str) -> int: | ||
""" | ||
Positive integer validator for Argparse | ||
:param number: | ||
:return: Positive integer | ||
""" | ||
number = int(number) | ||
if number <= 0: | ||
raise argparse.ArgumentTypeError( | ||
f"{number} is not a valid threshold. Must be > 0" | ||
) | ||
return number | ||
|
||
|
||
def check_ethereum_address(address: str) -> ChecksumAddress: | ||
""" | ||
Ethereum address validator for Argparse | ||
:param address: | ||
:return: Checksummed ethereum address | ||
""" | ||
if not Web3.is_checksum_address(address): | ||
raise argparse.ArgumentTypeError( | ||
f"{address} is not a valid checksummed ethereum address" | ||
) | ||
return ChecksumAddress(address) | ||
|
||
|
||
def check_private_key(private_key: str) -> str: | ||
""" | ||
Ethereum private key validator for ArgParse | ||
:param private_key: Ethereum Private key | ||
:return: Ethereum Private key | ||
""" | ||
try: | ||
Account.from_key(private_key) | ||
except (ValueError, Error): # TODO Report `Error` exception as a bug of eth_account | ||
raise argparse.ArgumentTypeError(f"{private_key} is not a valid private key") | ||
return private_key | ||
|
||
|
||
def check_hex_str(hex_str: str) -> HexBytes: | ||
""" | ||
Hexadecimal string validator for Argparse | ||
:param hex_str: | ||
:return: HexBytes from the provided hex string | ||
""" | ||
try: | ||
return HexBytes(hex_str) | ||
except ValueError: | ||
raise argparse.ArgumentTypeError(f"{hex_str} is not a valid hexadecimal string") | ||
|
||
|
||
def check_keccak256_hash(hex_str: str) -> HexBytes: | ||
""" | ||
Hexadecimal keccak256 validator for Argparse | ||
:param hex_str: | ||
:return: HexBytes from the provided hex string | ||
""" | ||
hex_str_bytes = check_hex_str(hex_str) | ||
if len(hex_str_bytes) != 32: | ||
raise argparse.ArgumentTypeError( | ||
f"{hex_str} is not a valid keccak256 hash hexadecimal string" | ||
) | ||
return hex_str_bytes |
Oops, something went wrong.