Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
zeth.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
4 #
5 # SPDX-License-Identifier: LGPL-3.0+
6 
7 from zeth.cli.constants import \
8  PROVER_SERVER_ENDPOINT_DEFAULT, PROVER_CONFIGURATION_FILE_DEFAULT, \
9  INSTANCE_FILE_DEFAULT, ZETH_SECRET_ADDRESS_FILE_DEFAULT, WALLET_DIR_DEFAULT, \
10  ETH_NETWORK_FILE_DEFAULT, ETH_NETWORK_DEFAULT
11 from zeth.cli.utils import ClientConfig
12 from zeth.cli.zeth_get_verification_key import get_verification_key
13 from zeth.cli.zeth_deploy import deploy
14 from zeth.cli.zeth_gen_address import gen_address
15 from zeth.cli.zeth_sync import sync
16 from zeth.cli.zeth_mix import mix
17 from zeth.cli.zeth_wait import wait
18 from zeth.cli.zeth_ls_notes import ls_notes
19 from zeth.cli.zeth_ls_commits import ls_commits
20 from click import group, command, option, pass_context, ClickException, Context
21 from click_default_group import DefaultGroup # type: ignore
22 from typing import Optional
23 
24 
25 # pylint: disable=redefined-builtin
26 @command()
27 @pass_context
28 def help(ctx: Context) -> None:
29  """
30  Print help and exit
31  """
32  # Note, this command is implemented to ensure that an error is raised if no
33  # subcommand is specified (which also catches errors in scripts).
34  print(ctx.parent.get_help()) # type: ignore
35  raise ClickException("no command specified")
36 
37 
38 @group(cls=DefaultGroup, default_if_no_args=True, default="help")
39 @option(
40  "--eth-network",
41  default=None,
42  help="Ethereum RPC endpoint, network or config file "
43  f"(default: '{ETH_NETWORK_FILE_DEFAULT}' if it exists, otherwise "
44  f"'{ETH_NETWORK_DEFAULT}')")
45 @option(
46  "--prover-server",
47  default=PROVER_SERVER_ENDPOINT_DEFAULT,
48  help=f"Prover server endpoint (default={PROVER_SERVER_ENDPOINT_DEFAULT})")
49 @option(
50  "--prover-config-file",
51  default=PROVER_CONFIGURATION_FILE_DEFAULT,
52  help=f"Prover config file (default={PROVER_CONFIGURATION_FILE_DEFAULT})")
53 @option(
54  "--instance-file",
55  default=INSTANCE_FILE_DEFAULT,
56  help=f"Instance file (default={INSTANCE_FILE_DEFAULT})")
57 @option(
58  "--address-file",
59  default=ZETH_SECRET_ADDRESS_FILE_DEFAULT,
60  help=f"Zeth zecret address file (default={ZETH_SECRET_ADDRESS_FILE_DEFAULT})")
61 @option(
62  "--wallet-dir",
63  default=WALLET_DIR_DEFAULT,
64  help=f"Wallet directory (default={WALLET_DIR_DEFAULT})")
65 @pass_context
66 def zeth(
67  ctx: Context,
68  eth_network: Optional[str],
69  prover_server: str,
70  prover_config_file: str,
71  instance_file: str,
72  address_file: str,
73  wallet_dir: str) -> None:
74  if ctx.invoked_subcommand == "help":
75  ctx.invoke(help)
76  ctx.ensure_object(dict)
77  ctx.obj = ClientConfig(
78  eth_network=eth_network,
79  prover_server_endpoint=prover_server,
80  prover_config_file=prover_config_file,
81  instance_file=instance_file,
82  address_file=address_file,
83  wallet_dir=wallet_dir)
84 
85 
86 zeth.add_command(get_verification_key)
87 zeth.add_command(deploy)
88 zeth.add_command(gen_address)
89 zeth.add_command(sync)
90 zeth.add_command(mix)
91 zeth.add_command(wait)
92 zeth.add_command(ls_notes)
93 zeth.add_command(ls_commits)
94 zeth.add_command(help)
95 
96 
97 if __name__ == "__main__":
98  zeth() # pylint: disable=no-value-for-parameter
zeth.cli.zeth_gen_address
Definition: zeth_gen_address.py:1
zeth
Definition: __init__.py:1
zeth.cli.zeth.help
None help(Context ctx)
Definition: zeth.py:28
zeth.cli.utils
Definition: utils.py:1
zeth.cli.zeth_wait
Definition: zeth_wait.py:1
zeth.cli.zeth_ls_commits
Definition: zeth_ls_commits.py:1
zeth.cli.zeth.zeth
None zeth(Context ctx, Optional[str] eth_network, str prover_server, str prover_config_file, str instance_file, str address_file, str wallet_dir)
Definition: zeth.py:66
zeth.cli.utils.ClientConfig
Definition: utils.py:64
zeth.cli.constants
Definition: constants.py:1
zeth.cli.zeth_deploy
Definition: zeth_deploy.py:1
zeth.cli.zeth_mix
Definition: zeth_mix.py:1
zeth.cli.zeth_ls_notes
Definition: zeth_ls_notes.py:1
zeth.cli.zeth_get_verification_key
Definition: zeth_get_verification_key.py:1
zeth.cli.zeth_sync
Definition: zeth_sync.py:1