From 2fb5637f20dcb6d58ffca5af45694ee7c2ec797a Mon Sep 17 00:00:00 2001 From: Kieran Prasch Date: Sat, 5 Dec 2020 08:11:46 -0800 Subject: [PATCH] Use s decimal casted referenced to economics for CLI's min. stake option. --- nucypher/cli/options.py | 6 ++++-- nucypher/cli/types.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nucypher/cli/options.py b/nucypher/cli/options.py index 877436ab4..aba37e9d3 100644 --- a/nucypher/cli/options.py +++ b/nucypher/cli/options.py @@ -27,7 +27,9 @@ from nucypher.cli.types import ( GWEI, NETWORK_PORT, NuCypherNetworkName, - WEI + WEI, + STAKED_TOKENS_RANGE, + MIN_ALLOWED_LOCKED_TOKENS ) from nucypher.utilities.logging import Logger @@ -49,7 +51,7 @@ 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) option_lonely = click.option('--lonely', help="Do not connect to seednodes", is_flag=True) option_m = click.option('--m', help="M-Threshold KFrags", type=click.INT) -option_min_stake = click.option('--min-stake', help="The minimum stake the teacher must have to be a teacher", type=click.INT, default=15000) +option_min_stake = click.option('--min-stake', help="The minimum stake the teacher must have to be locally accepted.", type=STAKED_TOKENS_RANGE, default=MIN_ALLOWED_LOCKED_TOKENS) option_n = click.option('--n', help="N-Total KFrags", type=click.INT) option_parameters = click.option('--parameters', help="Filepath to a JSON file containing additional parameters", type=EXISTING_READABLE_FILE) option_participant_address = click.option('--participant-address', help="Participant's checksum address.", type=EIP55_CHECKSUM_ADDRESS) diff --git a/nucypher/cli/types.py b/nucypher/cli/types.py index 8d8c30ad7..caa22ab13 100644 --- a/nucypher/cli/types.py +++ b/nucypher/cli/types.py @@ -20,6 +20,8 @@ from decimal import Decimal, DecimalException from eth_utils import to_checksum_address from ipaddress import ip_address +from nucypher.blockchain.economics import StandardTokenEconomics +from nucypher.blockchain.eth.token import NU from nucypher.blockchain.eth.interfaces import BlockchainInterface from nucypher.blockchain.eth.networks import NetworksInventory @@ -106,6 +108,10 @@ EIP55_CHECKSUM_ADDRESS = ChecksumAddress() WEI = click.IntRange(min=1, clamp=False) # TODO: Better validation for ether and wei values? GWEI = DecimalRange(min=0) +__min_allowed_locked = NU.from_nunits(StandardTokenEconomics._default_minimum_allowed_locked).to_tokens() +MIN_ALLOWED_LOCKED_TOKENS = Decimal(__min_allowed_locked) +STAKED_TOKENS_RANGE = DecimalRange(min=__min_allowed_locked) + # Filesystem EXISTING_WRITABLE_DIRECTORY = click.Path(exists=True, dir_okay=True, file_okay=False, writable=True) EXISTING_READABLE_FILE = click.Path(exists=True, dir_okay=False, file_okay=True, readable=True)