def deploy_cmd(ctx, contract_name, network, wallet, config, wasm): """ Deploy contract to specified network. """ echo('\nDeploying your contract...') echo('===========================\n') try: deployment = Deployment(ctx.obj['PROJECT_DIR'], network, wallet, config) if len(contract_name) == 0: if wasm: wasm_file_list = deployment.get_all_wasm_file() for file in wasm_file_list: deployment.deploy_wasm_contract(file) else: avm_file_list = deployment.get_all_avm_file() for file in avm_file_list: deployment.deploy_neo_contract(file) else: if wasm: deployment.deploy_wasm_contract(contract_name) else: deployment.deploy_neo_contract(contract_name) except (PunicaException, SDKException) as e: echo_cli_exception(e)
def init_cmd(ctx): """ Initialize new and empty Ontology project. """ box = Box(ctx.obj['PROJECT_DIR']) try: box.init_box() except (PunicaException, SDKException) as e: echo_cli_exception(e)
def unbox_cmd(ctx, box_name): """ Download a Punica Box, a pre-built Punica project """ box = Box(ctx.obj['PROJECT_DIR']) try: box.unbox(box_name) except (PunicaException, SDKException) as e: echo_cli_exception(e)
def compile_cmd(ctx, contract_name: str, v1: bool): """ Compile contract source files. """ echo('\nCompiling your contracts...') echo('===========================\n') try: py_contract = PyContract(ctx.obj['PROJECT_DIR']) if len(contract_name) == 0: contract_name_list = py_contract.get_all_contract() for contract_name in contract_name_list: py_contract.compile_contract(contract_name, v1) return if not contract_name.endswith('.py'): contract_name += '.py' py_contract.compile_contract(contract_name, v1) except (PunicaException, SDKException) as e: echo_cli_exception(e)
def invoke_cmd(ctx, func_name, network, wallet, config, sleep, pre): """ Invoke the contract methods in contract config file. """ echo('\nInvoking your contracts...') echo('==========================\n') try: invocation = Invocation(ctx.obj['PROJECT_DIR'], network, wallet, config) punica_func_list = invocation.get_func_list() if len(func_name) == 0: for func in punica_func_list: invocation.invoke(func, pre) time.sleep(sleep) else: func = invocation.get_func_by_name(func_name) invocation.invoke(func, pre) except (PunicaException, SDKException) as e: echo_cli_exception(e)
def compile_cmd(ctx, contract_name: str, v1: bool, wasm: bool): """ Compile contract source files. """ try: if wasm: wasm_contract = WasmContract(ctx.obj['PROJECT_DIR']) wasm_contract.echo_compile_banner() wasm_contract.compile_contract() else: py_contract = PyContract(ctx.obj['PROJECT_DIR']) py_contract.echo_compile_banner() if len(contract_name) == 0: contract_name_list = py_contract.get_all_contract() for contract_name in contract_name_list: py_contract.compile_contract(contract_name, v1) return if not contract_name.endswith('.py'): contract_name += '.py' py_contract.compile_contract(contract_name, v1) except (PunicaException, SDKException) as e: echo_cli_exception(e)
def invoke_cmd(ctx, func_name, network, wallet_path, config, sleep, pre, wasm): """ Invoke the contract methods in contract config file. """ try: invocation = Invocation(ctx.obj['PROJECT_DIR'], network, wallet_path, config, wasm) invocation.echo_invoke_banner() if len(func_name) == 0: punica_func_list = invocation.get_func_list() for func in punica_func_list: if invocation.is_wasm: invocation.invoke_wasm_contract(func, pre) else: invocation.invoke_neo_contract(func, pre) time.sleep(sleep) else: func = invocation.get_func_by_name(func_name) if invocation.is_wasm: invocation.invoke_wasm_contract(func, pre) else: invocation.invoke_neo_contract(func, pre) except (PunicaException, SDKException) as e: echo_cli_exception(e)