def wait(ctx: Context, transaction_id: str) -> None: """ Wait for a mix transaction and dump all log data. Does not update the wallet. Use sync to scan the chain for new notes. """ client_ctx = ctx.obj mixer_desc = load_mixer_description_from_ctx(client_ctx) instance_desc = mixer_desc.mixer # Retrieve the tx receipt and dump logs web3 = open_web3_from_ctx(client_ctx) # type: ignore instance = instance_desc.instantiate(web3) tx_receipt = web3.eth.waitForTransactionReceipt(transaction_id, 10000) \ # pylint: disable=no-member print("LogDebug events:") logs = get_event_logs_from_tx_receipt(instance, "LogDebug", tx_receipt) for log in logs: print(f" {log.args['message']}: {log.args['value']} " f"({hex(log.args['value'])})") print("LogMix events:") logs = get_event_logs_from_tx_receipt(instance, "LogMix", tx_receipt) for log in logs: print(f" {log}")
def ls_notes(ctx: Context, balance: bool, spent: bool) -> None: """ List the set of notes owned by this wallet """ client_ctx = ctx.obj web3 = open_web3_from_ctx(client_ctx) mixer_desc = load_mixer_description_from_ctx(client_ctx) mixer_instance = mixer_desc.mixer.instantiate(web3) js_secret = load_zeth_address_secret(client_ctx) wallet = open_wallet(mixer_instance, js_secret, client_ctx) total = EtherValue(0) for addr, short_commit, value in wallet.note_summaries(): print(f"{short_commit}: value={value.ether()}, addr={addr}") total = total + value if balance: print(f"TOTAL BALANCE: {total.ether()}") if not spent: return print("SPENT NOTES:") for addr, short_commit, value in wallet.spent_note_summaries(): print(f"{short_commit}: value={value.ether()}, addr={addr}")
def deploy( ctx: Context, eth_addr: Optional[str], eth_private_key: Optional[str], instance_out: str, token_address: str, deploy_gas: Optional[int]) -> None: """ Deploy the zeth contracts and record the instantiation details. """ eth_address = load_eth_address(eth_addr) eth_private_key_data = load_eth_private_key(eth_private_key) client_ctx = ctx.obj web3 = open_web3_from_ctx(client_ctx) print(f"deploy: eth_address={eth_address}") print(f"deploy: instance_out={instance_out}") print(f"deploy: token_address={token_address}") token_instance_desc = get_erc20_instance_description(token_address) \ if token_address else None prover_client = create_prover_client(client_ctx) _zeth_client, mixer_instance_desc = MixerClient.deploy( web3, prover_client, eth_address, eth_private_key_data, token_address, deploy_gas) mixer_desc = MixerDescription(mixer_instance_desc, token_instance_desc) write_mixer_description(instance_out, mixer_desc)
def sync(ctx: Context, wait_tx: Optional[str], batch_size: Optional[int]) -> None: """ Attempt to retrieve new notes for the key in <key-file> """ client_ctx = ctx.obj web3 = open_web3_from_ctx(client_ctx) mixer_desc = load_mixer_description_from_ctx(client_ctx) mixer_instance = mixer_desc.mixer.instantiate(web3) js_secret = load_zeth_address_secret(client_ctx) wallet = open_wallet(mixer_instance, js_secret, client_ctx) chain_block_number = do_sync(web3, wallet, wait_tx, zeth_note_short_print, batch_size) print(f"SYNCED to {chain_block_number}")
def deploy(ctx: Context, eth_addr: Optional[str], eth_private_key: Optional[str], instance_out: str, token_address: Optional[str], permitted_dispatcher: Optional[str], vk_hash: Optional[str], deploy_gas: Optional[int]) -> None: """ Deploy the zeth contracts and record the instantiation details. """ eth_address = load_eth_address(eth_addr) eth_private_key_data = load_eth_private_key(eth_private_key) client_ctx = ctx.obj web3 = open_web3_from_ctx(client_ctx) if bool(permitted_dispatcher) != bool(vk_hash): raise ClickException( "Must supply BOTH --permitted-dispatch AND --vk-hash, or NEITHER") print(f"deploy: eth_address={eth_address}") print(f"deploy: instance_out={instance_out}") print(f"deploy: token_address={token_address}") if permitted_dispatcher: permitted_dispatcher = load_contract_address(permitted_dispatcher) print(f"deploy: permitted_dispatcher={permitted_dispatcher}") print(f"deploy: vk_hash={vk_hash}") token_instance_desc = get_erc20_instance_description(token_address) \ if token_address else None prover_client = create_prover_client(client_ctx) _zeth_client, mixer_instance_desc = MixerClient.deploy( web3, prover_client, eth_address, eth_private_key_data, token_address, permitted_dispatcher=permitted_dispatcher, vk_hash=vk_hash, deploy_gas=deploy_gas) mixer_desc = MixerDescription(mixer=mixer_instance_desc, token=token_instance_desc, permitted_dispatcher=permitted_dispatcher, vk_hash=vk_hash) write_mixer_description(instance_out, mixer_desc)