6 ZETH_NESTED_TRANSACTION_FILE_DEFAULT, ZETH_APP_NAME
8 from zeth.core.mixer_client
import \
9 MixParameters, mix_parameters_to_dispatch_parameters
10 from zeth.core.prover_client
import ProverConfiguration
11 from zeth.core.zksnark
import get_zksnark_provider
12 from zeth.cli.constants
import PROVER_CONFIGURATION_FILE_DEFAULT
13 from click
import command, argument, option
18 @argument(
"zeth_tx_file")
20 "--prover-config-file",
21 default=PROVER_CONFIGURATION_FILE_DEFAULT,
22 help=f
"Prover config file (default={PROVER_CONFIGURATION_FILE_DEFAULT})")
26 default=ZETH_NESTED_TRANSACTION_FILE_DEFAULT,
27 help=f
"Output nested tx to file ({ZETH_NESTED_TRANSACTION_FILE_DEFAULT})")
30 prover_config_file: str,
31 output_file: str) ->
None:
33 Create a Zecale nested transaction from a zeth MixParameters object
37 with open(prover_config_file,
"r")
as prover_config_f:
39 ProverConfiguration.from_json_dict(json.load(prover_config_f))
40 zksnark = zksnark = get_zksnark_provider(prover_config.zksnark_name)
43 with open(zeth_tx_file,
"r")
as zeth_tx_f:
45 MixParameters.from_json_dict(zksnark, json.load(zeth_tx_f))
48 nested_tx = _create_zeth_nested_tx(zeth_mix_params, 0)
49 with open(output_file,
"w")
as output_f:
50 json.dump(nested_tx.to_json_dict(), output_f)
53 def _create_zeth_nested_tx(
54 mix_params: MixParameters,
55 fee_in_wei: int) -> NestedTransaction:
58 parameters = mix_parameters_to_dispatch_parameters(mix_params)
60 app_name=ZETH_APP_NAME,
61 ext_proof=mix_params.extended_proof,
62 parameters=parameters,
63 fee_in_wei=fee_in_wei)