Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
zeth_helper.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.helper.eth_gen_network_config import eth_gen_network_config
8 from zeth.helper.eth_gen_address import eth_gen_address
9 from zeth.helper.eth_get_balance import eth_get_balance
10 from zeth.helper.eth_fund import eth_fund
11 from zeth.helper.eth_send import eth_send
12 from zeth.helper.eth_get_contract_address import eth_get_contract_address
13 from zeth.helper.token_approve import token_approve
14 from zeth.cli.constants import ETH_NETWORK_FILE_DEFAULT, ETH_NETWORK_DEFAULT
15 from click import group, command, option, pass_context, ClickException, Context
16 from click_default_group import DefaultGroup # type: ignore
17 
18 
19 # pylint: disable=redefined-builtin
20 @command()
21 @pass_context
22 def help(ctx: Context) -> None:
23  """
24  Print help and exit
25  """
26  # Note, this command is implemented to ensure that an error is raised if no
27  # subcommand is specified (which also catches errors in scripts).
28  print(ctx.parent.get_help()) # type: ignore
29  raise ClickException("no command specified")
30 
31 
32 @group(cls=DefaultGroup, default_if_no_args=True, default="help")
33 @option(
34  "--eth-network",
35  default=None,
36  help="Ethereum RPC endpoint, network or config file "
37  f"(default: '{ETH_NETWORK_FILE_DEFAULT}' if it exists, otherwise "
38  f"'{ETH_NETWORK_DEFAULT}')")
39 @pass_context
40 def zeth_helper(ctx: Context, eth_network: str) -> None:
41  if ctx.invoked_subcommand == "help":
42  ctx.invoke(help)
43  ctx.ensure_object(dict)
44  ctx.obj = {
45  "eth_network": eth_network,
46  }
47 
48 
49 zeth_helper.add_command(eth_gen_network_config)
50 zeth_helper.add_command(eth_gen_address)
51 zeth_helper.add_command(eth_get_balance)
52 zeth_helper.add_command(eth_fund)
53 zeth_helper.add_command(eth_send)
54 zeth_helper.add_command(eth_get_contract_address)
55 zeth_helper.add_command(token_approve)
56 zeth_helper.add_command(help)
57 
58 
59 if __name__ == "__main__":
60  zeth_helper() # pylint: disable=no-value-for-parameter
zeth.helper.eth_gen_network_config
Definition: eth_gen_network_config.py:1
zeth.helper.token_approve
Definition: token_approve.py:1
zeth.helper.eth_gen_address
Definition: eth_gen_address.py:1
zeth.cli.constants
Definition: constants.py:1
zeth.helper.eth_get_contract_address
Definition: eth_get_contract_address.py:1
zeth.helper.zeth_helper.help
None help(Context ctx)
Definition: zeth_helper.py:22
zeth.helper.eth_get_balance
Definition: eth_get_balance.py:1
zeth.helper.eth_send
Definition: eth_send.py:1
zeth.helper.eth_fund
Definition: eth_fund.py:1
zeth.helper.zeth_helper.zeth_helper
None zeth_helper(Context ctx, str eth_network)
Definition: zeth_helper.py:40