def activate(_ctx, path: str, network: str) -> None: ptz = pytezos.using(key=path, shell=network) logger.info( 'Activating %s in the %s', ptz.key.public_key_hash(), network, ) if ptz.balance() == 0: try: opg = ptz.reveal().autofill().sign() logger.info('Injecting reveal operation:') logger.info(pformat(opg.json_payload())) opg.inject(_async=False) except RpcError as e: logger.critical(pformat(e)) sys.exit(-1) else: logger.info('Activation succeeded! Claimed balance: %s ꜩ', ptz.balance()) else: logger.info('Already activated') try: opg = ptz.reveal().autofill().sign() logger.info('Injecting reveal operation:') logger.info(pformat(opg.json_payload())) opg.inject(_async=False) except RpcError as e: logger.critical(pformat(e)) sys.exit(-1) else: logger.info('Your key %s is now active and revealed', ptz.key.public_key_hash())
def deploy( _ctx, path: str, storage: Optional[str], # pylint: disable=redefined-outer-name network: str, key: Optional[str], github_repo_slug: Optional[str], github_oauth_token: Optional[str], dry_run: bool, ): ptz = pytezos.using(shell=network, key=key) logger.info('Deploying contract using %s in the %s', ptz.key.public_key_hash(), network) contract = get_contract(path) try: opg = ptz.origination(script=contract.script( initial_storage=storage)).autofill().sign() logger.info('Injecting origination operation:') logger.info(pformat(opg.json_payload())) if dry_run: logger.info(pformat(opg.preapply())) sys.exit(0) else: opg = opg.inject(_async=False) except RpcError as e: logger.critical(pformat(e)) sys.exit(-1) else: originated_contracts = OperationResult.originated_contracts(opg) if len(originated_contracts) != 1: raise Exception( 'Operation group must has exactly one originated contract') bcd_link = make_bcd_link(network, originated_contracts[0]) logger.info('Contract was successfully deployed: %s', bcd_link) if github_repo_slug: deployment = create_deployment( github_repo_slug, github_oauth_token, environment=network, ) logger.info(pformat(deployment)) status = create_deployment_status( github_repo_slug, github_oauth_token, deployment_id=deployment['id'], state='success', environment=network, environment_url=bcd_link, ) logger.info(status)