Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations (do-not-merge) #180

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions eth2deposit/cli/existing_mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,40 @@ def validate_mnemonic(cts: click.Context, param: Any, mnemonic: str) -> str:
if verify_mnemonic(mnemonic, WORD_LISTS_PATH):
return mnemonic
else:
raise ValidationError('That is not a valid mnemonic, please check for typos.')
raise ValidationError('That is not a valid mnemonic, please check for typos.') # Translate


@click.command(
help='Generate (or recover) keys from an existing mnemonic',
help='Generate (or recover) keys from an existing mnemonic', # Translate
)
@click.pass_context
@click.option(
'--mnemonic',
'--mnemonic', # Do not translate
callback=validate_mnemonic,
help=('The mnemonic that you used to generate your keys. (It is recommended not to use this argument, and wait for '
'the CLI to ask you for your mnemonic as otherwise it will appear in your shell history.)'),
prompt='Please enter your mnemonic separated by spaces (" ")',
'the CLI to ask you for your mnemonic as otherwise it will appear in your shell history.)'), # Translate
prompt='Please enter your mnemonic separated by spaces (" ")', # Translate
required=True,
type=str,
)
@click.password_option(
'--mnemonic-password',
'--mnemonic-password', # Do not translate
default='',
help=('This is almost certainly not the argument you are looking for: it is for mnemonic passwords, not keystore '
'passwords. Providing a password here when you didn\'t use one initially, can result in lost keys (and '
'therefore funds)! Also note that if you used this tool to generate your mnemonic intially, then you did not '
'use a mnemonic password. However, if you are certain you used a password to "increase" the security of your '
'mnemonic, this is where you enter it.'),
'mnemonic, this is where you enter it.'), # Translate
prompt=False,
)
@click.option(
'--validator_start_index',
'--validator_start_index', # Do not translate
confirmation_prompt=True,
default=0,
help=('Enter the index (key number) you wish to start generating more keys from. '
'For example, if you\'ve generated 4 keys in the past, you\'d enter 4 here,'),
'For example, if you\'ve generated 4 keys in the past, you\'d enter 4 here,'), # Translate
prompt=('Enter the index (key number) you wish to start generating more keys from. '
'For example, if you\'ve generated 4 keys in the past, you\'d enter 4 here,'),
'For example, if you\'ve generated 4 keys in the past, you\'d enter 4 here,'), # Translate
type=click.IntRange(0, 2**32 - 1),
)
@generate_keys_arguments_decorator
Expand All @@ -63,7 +63,7 @@ def existing_mnemonic(ctx: click.Context, mnemonic: str, mnemonic_password: str,
click.confirm(
('Are you absolutely certain that you used a mnemonic password? '
'(This is different from a keystore password!) '
'Using one when you are not supposed to can result in loss of funds!'),
'Using one when you are not supposed to can result in loss of funds!'), # Translate
abort=True)

ctx.obj = {'mnemonic': mnemonic, 'mnemonic_password': mnemonic_password}
Expand Down
46 changes: 23 additions & 23 deletions eth2deposit/cli/generate_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ def validate_password(cts: click.Context, param: Any, password: str) -> str:
try:
validate_password_strength(password)
except ValidationError as e:
click.echo(f'Error: {e} Please retype.')
click.echo(f'Error: {e} Please retype.') # Translate
else:
is_valid_password = True

while not is_valid_password:
password = get_password(text='Type the password that secures your validator keystore(s)')
password = get_password(text='Type the password that secures your validator keystore(s)') # Translate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it more clear this step creates a password, e.g. "Create a password that will secure your validator keystore(s)"

try:
validate_password_strength(password)
except ValidationError as e:
click.echo(f'Error: {e} Please retype.')
click.echo(f'Error: {e} Please retype.') # Translate
else:
# Confirm password
password_confirmation = get_password(text='Repeat for confirmation')
password_confirmation = get_password(text='Repeat for confirmation') # Translate
if password == password_confirmation:
is_valid_password = True
else:
click.echo('Error: the two entered values do not match. Please retype again.')
click.echo('Error: the two entered values do not match. Please retype again.') # Translate

return password

Expand All @@ -61,35 +61,35 @@ def generate_keys_arguments_decorator(function: Callable[..., Any]) -> Callable[
'''
This is a decorator that, when applied to a parent-command, implements the
to obtain the necessary arguments for the generate_keys() subcommand.
'''
''' # Do not translate
decorators = [
click.option(
'--num_validators',
prompt='Please choose how many validators you wish to run',
help='The number of validators keys you want to generate (you can always generate more later)',
'--num_validators', # Do not translate
prompt='Please choose how many validators you wish to run', # Translate
help='The number of validators keys you want to generate (you can always generate more later)', # Translate
required=True,
type=click.IntRange(0, 2**32 - 1),
),
click.option(
'--folder',
'--folder', # Do not translate
default=os.getcwd(),
help='The folder to place the generated keystores and deposit_data.json in',
help='The folder to place the generated keystores and deposit_data.json in', # Translate
type=click.Path(exists=True, file_okay=False, dir_okay=True),
),
click.option(
'--chain',
'--chain', # Do not translate
default=MAINNET,
help='The version of eth2 you are targeting. use "mainnet" if you are depositing ETH',
prompt='Please choose the (mainnet or testnet) network/chain name',
help='The version of eth2 you are targeting. use "mainnet" if you are depositing ETH', # Translate
prompt='Please choose the (mainnet or testnet) network/chain name', # Translate all except "mainnet" and "testnet"
type=click.Choice(ALL_CHAINS.keys(), case_sensitive=False),
),
click.password_option(
'--keystore_password',
'--keystore_password', # Do not translate
callback=validate_password,
help=('The password that will secure your keystores. You will need to re-enter this to decrypt them when '
'you setup your eth2 validators. (It is reccomened not to use this argument, and wait for the CLI '
'to ask you for your mnemonic as otherwise it will appear in your shell history.)'),
prompt='Type the password that secures your validator keystore(s)',
'you setup your eth2 validators. (It is recommended not to use this argument, and wait for the CLI '
'to ask you for your mnemonic as otherwise it will appear in your shell history.)'), # Translate
prompt='Type the password that secures your validator keystore(s)', # Translate
),
]
for decorator in reversed(decorators):
Expand All @@ -110,7 +110,7 @@ def generate_keys(ctx: click.Context, validator_start_index: int,
os.mkdir(folder)
click.clear()
click.echo(RHINO_0)
click.echo('Creating your keys.')
click.echo('Creating your keys.') # Translate
credentials = CredentialList.from_mnemonic(
mnemonic=mnemonic,
mnemonic_password=mnemonic_password,
Expand All @@ -122,8 +122,8 @@ def generate_keys(ctx: click.Context, validator_start_index: int,
keystore_filefolders = credentials.export_keystores(password=keystore_password, folder=folder)
deposits_file = credentials.export_deposit_data_json(folder=folder)
if not credentials.verify_keystores(keystore_filefolders=keystore_filefolders, password=keystore_password):
raise ValidationError("Failed to verify the keystores.")
raise ValidationError("Failed to verify the keystores.") # Translate
if not verify_deposit_data_json(deposits_file):
raise ValidationError("Failed to verify the deposit data JSON files.")
click.echo('\nSuccess!\nYour keys can be found at: %s' % folder)
click.pause('\n\nPress any key.')
raise ValidationError("Failed to verify the deposit data JSON files.") # Translate
click.echo('\nSuccess!\nYour keys can be found at: %s' % folder) # Translate
click.pause('\n\nPress any key.') # Translate
17 changes: 10 additions & 7 deletions eth2deposit/cli/new_mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@


@click.command(
help='Generate a new mnemonic and keys',
help='Generate a new mnemonic and keys', # Translate
)
@click.pass_context
@click.option(
'--mnemonic_language',
default='english',
help='The language that your mnemonic is in.',
prompt='Please choose your mnemonic language',
'--mnemonic_language', # Do not translate
default='english', # Translate
# Ideally the language names are displayed in the users native language, feasible?
help='The language that your mnemonic is in.', # Translate
prompt='Please choose your mnemonic language', # Translate
type=click.Choice(languages, case_sensitive=False),
)
@generate_keys_arguments_decorator
Expand All @@ -35,11 +36,13 @@ def new_mnemonic(ctx: click.Context, mnemonic_language: str, **kwargs: Any) -> N
while mnemonic != test_mnemonic:
click.clear()
click.echo('This is your seed phrase. Write it down and store it safely, it is the ONLY way to retrieve your deposit.') # noqa: E501
click.echo('\n\n%s\n\n' % mnemonic)
click.pause('Press any key when you have written down your mnemonic.')
# Translate above
click.echo('\n\n%s\n\n' % mnemonic) # Do not translate
click.pause('Press any key when you have written down your mnemonic.') # Translate

click.clear()
test_mnemonic = click.prompt('Please type your mnemonic (separated by spaces) to confirm you have written it down\n\n') # noqa: E501
# Translate above
test_mnemonic = test_mnemonic.lower()
click.clear()
# Do NOT use mnemonic_password.
Expand Down
14 changes: 7 additions & 7 deletions eth2deposit/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def verify_keystore(self, keystore_filefolder: str, password: str) -> bool:
class CredentialList:
"""
A collection of multiple Credentials, one for each validator.
"""
""" # Do not translate
def __init__(self, credentials: List[Credential]):
self.credentials = credentials

Expand All @@ -132,31 +132,31 @@ def from_mnemonic(cls,
start_index: int) -> 'CredentialList':
if len(amounts) != num_keys:
raise ValueError(
f"The number of keys ({num_keys}) doesn't equal to the corresponding deposit amounts ({len(amounts)})."
f"The number of keys ({num_keys}) doesn't equal to the corresponding deposit amounts ({len(amounts)})." # Translate
)
key_indices = range(start_index, start_index + num_keys)
with click.progressbar(key_indices, label='Creating your keys:\t\t',
with click.progressbar(key_indices, label='Creating your keys:\t\t', # Translate
show_percent=False, show_pos=True) as indices:
return cls([Credential(mnemonic=mnemonic, mnemonic_password=mnemonic_password,
index=index, amount=amounts[index - start_index], chain_setting=chain_setting)
for index in indices])

def export_keystores(self, password: str, folder: str) -> List[str]:
with click.progressbar(self.credentials, label='Creating your keystores:\t',
with click.progressbar(self.credentials, label='Creating your keystores:\t', # Translate
show_percent=False, show_pos=True) as credentials:
return [credential.save_signing_keystore(password=password, folder=folder) for credential in credentials]

def export_deposit_data_json(self, folder: str) -> str:
with click.progressbar(self.credentials, label='Creating your depositdata:\t',
with click.progressbar(self.credentials, label='Creating your depositdata:\t', # Translate
show_percent=False, show_pos=True) as credentials:
deposit_data = [cred.deposit_datum_dict for cred in credentials]
filefolder = os.path.join(folder, 'deposit_data-%i.json' % time.time())
filefolder = os.path.join(folder, 'deposit_data-%i.json' % time.time()) # Do not translate
with open(filefolder, 'w') as f:
json.dump(deposit_data, f, default=lambda x: x.hex())
return filefolder

def verify_keystores(self, keystore_filefolders: List[str], password: str) -> bool:
with click.progressbar(zip(self.credentials, keystore_filefolders), label='Verifying your keystores:\t',
with click.progressbar(zip(self.credentials, keystore_filefolders), label='Verifying your keystores:\t', # Translate
length=len(self.credentials), show_percent=False, show_pos=True) as items:
return all(credential.verify_keystore(keystore_filefolder=filefolder, password=password)
for credential, filefolder in items)
4 changes: 2 additions & 2 deletions eth2deposit/deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
def check_python_version() -> None:
'''
Checks that the python version running is sufficient and exits if not.
'''
''' # Do not translate
if sys.version_info < (3, 7):
click.pause('Your python version is insufficient, please install version 3.7 or greater.')
click.pause('Your python version is insufficient, please install version 3.7 or greater.') # Translate
sys.exit()


Expand Down
2 changes: 1 addition & 1 deletion eth2deposit/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class BaseChainSetting(NamedTuple):
GENESIS_FORK_VERSION: bytes


# Do not translate the following:
MAINNET = 'mainnet'
WITTI = 'witti'
ALTONA = 'altona'
Expand All @@ -17,7 +18,6 @@ class BaseChainSetting(NamedTuple):
ZINKEN = 'zinken'
PYRMONT = 'pyrmont'


# Eth2 Mainnet setting
MainnetSetting = BaseChainSetting(ETH2_NETWORK_NAME=MAINNET, GENESIS_FORK_VERSION=bytes.fromhex('00000000'))
# Eth2 spec v0.11.3 testnet
Expand Down