Introduce a GWEI type for click, based on DecimalRange

pull/2425/head
David Núñez 2020-11-07 01:21:08 +01:00
parent b051457e83
commit 471ebb11a0
3 changed files with 7 additions and 4 deletions

View File

@ -101,6 +101,7 @@ from nucypher.cli.painting.transactions import paint_receipt_summary
from nucypher.cli.types import (
EIP55_CHECKSUM_ADDRESS,
EXISTING_READABLE_FILE,
GWEI,
DecimalRange)
from nucypher.cli.utils import setup_emitter
from nucypher.config.characters import StakeHolderConfiguration
@ -1302,7 +1303,7 @@ def events(general_config, staker_options, config_file, event_name):
@option_config_file
@option_force
@group_general_config
@click.option('--min-rate', help="Minimum acceptable fee rate (in GWEI), set by staker", type=DecimalRange(min=0))
@click.option('--min-rate', help="Minimum acceptable fee rate (in GWEI), set by staker", type=GWEI)
def set_min_rate(general_config: GroupGeneralConfig,
transacting_staker_options: TransactingStakerOptions,
config_file, force, min_rate):

View File

@ -24,10 +24,11 @@ from nucypher.blockchain.eth.constants import NUCYPHER_CONTRACT_NAMES
from nucypher.cli.types import (
EIP55_CHECKSUM_ADDRESS,
EXISTING_READABLE_FILE,
GWEI,
NETWORK_PORT,
NuCypherNetworkName,
WEI,
DecimalRange)
WEI
)
from nucypher.utilities.logging import Logger
# Alphabetical
@ -42,7 +43,7 @@ option_etherscan = click.option('--etherscan/--no-etherscan', help="Enable/disab
option_event_name = click.option('--event-name', help="Specify an event by name", type=click.STRING)
option_federated_only = click.option('--federated-only/--decentralized', '-F', help="Connect only to federated nodes", is_flag=True, default=None)
option_force = click.option('--force', help="Don't ask for confirmation", is_flag=True)
option_gas_price = click.option('--gas-price', help="Use this gas price (in GWEI)", type=DecimalRange(min=0))
option_gas_price = click.option('--gas-price', help="Use this gas price (in GWEI)", type=GWEI)
option_geth = click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True)
option_hw_wallet = click.option('--hw-wallet/--no-hw-wallet')
option_light = click.option('--light', help="Indicate that node is light", is_flag=True, default=None)

View File

@ -104,6 +104,7 @@ class NuCypherNetworkName(click.ParamType):
# Ethereum
EIP55_CHECKSUM_ADDRESS = ChecksumAddress()
WEI = click.IntRange(min=1, clamp=False) # TODO: Better validation for ether and wei values?
GWEI = DecimalRange(min=0)
# Filesystem
EXISTING_WRITABLE_DIRECTORY = click.Path(exists=True, dir_okay=True, file_okay=False, writable=True)