9 from click
import command, option, argument
10 from typing
import Optional
14 @argument(
"eth-network", default=ETH_NETWORK_DEFAULT)
15 @option(
"--eth-rpc-endpoint", help=
"(Optional) Override endpoint URL.")
17 "--eth-rpc-certificate",
18 help=
"(Optional) Path to TLS certificate for endpoint")
22 help=
"(Optional) Skip TLS certificate checks")
25 default=ETH_NETWORK_FILE_DEFAULT,
26 help=f
"Output filename (default: {ETH_NETWORK_FILE_DEFAULT})")
29 eth_rpc_endpoint: Optional[str],
30 eth_rpc_certificate: Optional[str],
31 eth_rpc_insecure: bool,
32 output_file: str) ->
None:
34 Generate a network config file. ETH_NETWORK is a network name or
35 pre-existing network config file.
40 # Write default config for "ganache" to the default file
41 $ zeth-helper eth-gen-network-config ganache
44 # Write "geth" config with a custom endpoint to default file
45 $ zeth-helper eth-gen-network-config geth \\
46 --eth-rpc-endpoint http://localhost:8080
49 # Write a custom https endpoint to file, specifying the certificate
50 $ zeth-helper eth-gen-network-config \\
52 --eth-rpc-endpoint https://rpc.my-network.io:8545 \\
53 --eth-rpc-certificate rpc.my-network.io.crt
56 # Write default network and endpoint to file "default-network"
57 $ zeth-helper eth-gen-network-config --output-file default-network
60 if eth_rpc_endpoint
is not None:
63 endpoint=eth_rpc_endpoint,
64 certificate=eth_rpc_certificate,
65 insecure=eth_rpc_insecure)
69 network_json = network.to_json()
70 print(f
"network: {network_json}")
72 with open(output_file,
"w")
as eth_network_f:
73 eth_network_f.write(network_json)
74 print(f
"written to \"{output_file}\"")