Zecale - Reconciling Privacy and Scalability on Smart-Contract Chains  0.5
Reference implementation of the Zecale protocol by Clearmatics
__main__.py
Go to the documentation of this file.
1 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
2 #
3 # SPDX-License-Identifier: LGPL-3.0+
4 
5 from zecale.cli.defaults import INSTANCE_FILE_DEFAULT, \
6  AGGREGATOR_SERVER_ENDPOINT_DEFAULT, AGGREGATOR_CONFIG_FILE_DEFAULT
7 from zecale.cli.command_context import CommandContext
8 from zecale.cli.zecale_get_verification_key import get_verification_key
9 from zecale.cli.zecale_deploy import deploy
11  nested_verification_key_hash
12 from zecale.cli.zecale_register import register
13 from zecale.cli.zecale_submit import submit
14 from zecale.cli.zecale_get_batch import get_batch
15 from zecale.cli.zecale_check_batch import check_batch
16 from zecale.cli.zecale_submit_batch import submit_batch
17 from zecale.cli.zecale_wait import wait
18 from zeth.cli.constants import ETH_NETWORK_FILE_DEFAULT
19 from grpc import RpcError
20 from click import group, option, pass_context, Context
21 from click_default_group import DefaultGroup # type: ignore
22 import sys
23 from typing import Optional, Any
24 
25 
27  """
28  A click group which handles uncaught RpcExceptions with a sensible message
29  (similar to ClickException).
30  """
31  def __call__(self, *args: Any, **kwargs: Any) -> Any:
32  try:
33  return DefaultGroup.__call__(self, *args, **kwargs)
34  except RpcError as err:
35  print(f"error: {err.details()}") # pylint: disable=no-member
36  sys.exit(1)
37 
38 
39 @group(cls=HandleRpcExceptions, default_if_no_args=True, default="--help")
40 @option(
41  "--aggregator-server", "-a",
42  default=AGGREGATOR_SERVER_ENDPOINT_DEFAULT,
43  help="Aggregator server endpoint "
44  f"(default={AGGREGATOR_SERVER_ENDPOINT_DEFAULT})")
45 @option(
46  "--aggregator-config-file", "-c",
47  default=AGGREGATOR_CONFIG_FILE_DEFAULT,
48  help="Aggregator configuration file "
49  f"(default={AGGREGATOR_CONFIG_FILE_DEFAULT})")
50 @option(
51  "--instance-file", "-i",
52  default=INSTANCE_FILE_DEFAULT,
53  help=f"Zecale contract instance file (default={INSTANCE_FILE_DEFAULT})")
54 @option(
55  "--eth-network",
56  help="Ethereum RPC endpoint, network or config file "
57  f"(default: '{ETH_NETWORK_FILE_DEFAULT}')")
58 @option("--eth-addr", help="Sender's eth address or address filename")
59 @option("--eth-private-key", help="Sender's eth private key file")
60 @pass_context
61 def zecale(
62  ctx: Context,
63  aggregator_server: str,
64  aggregator_config_file: str,
65  instance_file: str,
66  eth_network: Optional[str],
67  eth_addr: Optional[str],
68  eth_private_key: Optional[str]) -> None:
69  if ctx.invoked_subcommand == "help":
70  ctx.invoke(help)
71  ctx.obj = CommandContext(
72  aggregator_server,
73  aggregator_config_file,
74  instance_file,
75  eth_network,
76  eth_addr,
77  eth_private_key)
78 
79 
80 zecale.add_command(get_verification_key)
81 zecale.add_command(deploy)
82 zecale.add_command(nested_verification_key_hash)
83 zecale.add_command(register)
84 zecale.add_command(submit)
85 zecale.add_command(get_batch)
86 zecale.add_command(check_batch)
87 zecale.add_command(submit_batch)
88 zecale.add_command(wait)
zecale.cli.__main__.HandleRpcExceptions.__call__
Any __call__(self, *Any args, **Any kwargs)
Definition: __main__.py:31
zecale.cli.defaults
Definition: defaults.py:1
zecale.cli.zecale_register
Definition: zecale_register.py:1
zecale.cli.command_context.CommandContext
Definition: command_context.py:22
zecale.cli.zecale_get_batch
Definition: zecale_get_batch.py:1
zecale.cli.zecale_submit_batch
Definition: zecale_submit_batch.py:1
zeth_zecale.__main__.DefaultGroup
DefaultGroup
Definition: __main__.py:10
zecale.cli.__main__.zecale
None zecale(Context ctx, str aggregator_server, str aggregator_config_file, str instance_file, Optional[str] eth_network, Optional[str] eth_addr, Optional[str] eth_private_key)
Definition: __main__.py:61
zecale.cli.zecale_nested_verification_key_hash
Definition: zecale_nested_verification_key_hash.py:1
zecale.cli.zecale_check_batch
Definition: zecale_check_batch.py:1
zecale.cli.zecale_deploy
Definition: zecale_deploy.py:1
zecale.cli.command_context
Definition: command_context.py:1
zecale.cli.zecale_get_verification_key
Definition: zecale_get_verification_key.py:1
zecale.cli.zecale_submit
Definition: zecale_submit.py:1
zecale.cli.__main__.HandleRpcExceptions
Definition: __main__.py:26
zecale.cli.zecale_wait
Definition: zecale_wait.py:1