8 from zeth.core.contracts
import InstanceDescription
9 from zeth.core.utils
import hex_to_uint256_list
10 from zeth.cli.utils
import open_web3_from_network, load_eth_address, \
12 from click
import command, argument, option, pass_context, Context
13 from os.path
import join
18 CONTRACTS_DIR = join(ZECALE_DIR,
"contracts")
19 DUMMY_APP_CONTRACT_FILE = join(CONTRACTS_DIR,
"DummyApplication.sol")
20 DUMMY_APP_CONTRACT_DEPLOY_GAS = 500000
24 @argument(
"verification-key-hash")
26 "--dispatcher-instance-file",
27 default=INSTANCE_FILE_DEFAULT,
28 help=
"Dispatcher instance file")
31 default=APPLICATION_INSTANCE_FILE_DEFAULT,
32 help=
"File to write dummy app instance information to")
36 verification_key_hash: str,
37 dispatcher_instance_file: str,
38 instance_file: str) ->
None:
40 Deploy the contract for a dummy application.
43 eth_network = ctx.obj[
"eth_network"]
46 with open(dispatcher_instance_file,
"r")
as dispatcher_instance_f:
47 dispatcher_desc = InstanceDescription.from_json_dict(
48 json.load(dispatcher_instance_f))
51 verification_key_hash_evm = list(hex_to_uint256_list(verification_key_hash))
52 print(f
"verification_key_hash_evm = {verification_key_hash_evm}")
54 web3 = open_web3_from_network(eth_network)
55 eth_address = load_eth_address(ctx.obj[
"eth_addr"])
56 eth_private_key_data = load_eth_private_key(ctx.obj[
"eth_private_key"])
57 instance_desc = InstanceDescription.deploy(
59 DUMMY_APP_CONTRACT_FILE,
63 DUMMY_APP_CONTRACT_DEPLOY_GAS,
64 {
"allow_paths": CONTRACTS_DIR},
65 [dispatcher_desc.address, verification_key_hash_evm])
67 with open(instance_file,
"w")
as instance_file_f:
68 json.dump(instance_desc.to_json_dict(), instance_file_f)
70 print(f
"Instance file written to '{instance_file}'")