Ejemplo n.º 1
0
def ctez(config: Config, repo_path):
    """
    Deploy a ctez contract (dev only)
    """
    shell = construct_url(config.tezos_address, config.tezos_port)
    click.echo(f"Connecting to tezos node at: {shell}")
    client = pytezos.pytezos.using(shell=shell, key=config.tezos_key)
    client.loglevel = logging.WARNING
    ctez = checker_lib.deploy_ctez(client,
                                   repo=CheckerRepo(repo_path),
                                   ttl=_patch_operation_ttl(config))
    click.echo(
        f"ctez contract deployed with FA1.2 address: {ctez['fa12_ctez'].context.address} and cfmm address: {ctez['cfmm'].context.address}"
    )
    config.ctez_fa12_address = ctez["fa12_ctez"].context.address
    config.ctez_cfmm_address = ctez["cfmm"].context.address
    config.dump()
Ejemplo n.º 2
0
def mock_fa2(config: Config, repo_path):
    """
    Deploy the mock FA2 contract.
    """
    shell = construct_url(config.tezos_address, config.tezos_port)
    click.echo(f"Connecting to tezos node at: {shell}")
    client = pytezos.pytezos.using(shell=shell, key=config.tezos_key)
    client.loglevel = logging.WARNING
    mockFA2 = checker_lib.deploy_mockFA2(
        client,
        CheckerRepo(repo_path),
        ttl=_patch_operation_ttl(config),
    )
    click.echo(
        f"mock FA2 contract deployed with address: {mockFA2.context.address}")
    config.mock_fa2_address = mockFA2.context.address
    config.dump()
Ejemplo n.º 3
0
def wtez(config: Config, repo_path):
    """
    Deploy Tez FA2 wrapper contract.
    """
    shell = construct_url(config.tezos_address, config.tezos_port)
    click.echo(f"Connecting to tezos node at: {shell}")
    client = pytezos.pytezos.using(shell=shell, key=config.tezos_key)
    client.loglevel = logging.WARNING
    wrapper = checker_lib.deploy_wtez(
        client,
        CheckerRepo(repo_path),
        ttl=_patch_operation_ttl(config),
    )
    click.echo(
        f"Tez wrapper contract deployed with address: {wrapper.context.address}"
    )
    config.wtez_address = wrapper.context.address
    config.dump()
Ejemplo n.º 4
0
def mock_cfmm_oracle(config: Config, repo_path):
    """
    Deploy the mock cfmm oracle contract (dev only)
    """
    shell = construct_url(config.tezos_address, config.tezos_port)
    click.echo(f"Connecting to tezos node at: {shell}")
    client = pytezos.pytezos.using(shell=shell, key=config.tezos_key)
    client.loglevel = logging.WARNING
    cfmm_oracle = checker_lib.deploy_contract(
        client,
        source_file=CheckerRepo(repo_path).mock_cfmm_oracle_contract,
        initial_storage=(client.key.public_key_hash(), (1000000, 1000000)),
        ttl=_patch_operation_ttl(config),
    )
    click.echo(
        f"mock cfmm oracle contract deployed with address: {cfmm_oracle.context.address}"
    )
    config.cfmm_oracle_address = cfmm_oracle.context.address
    config.dump()
Ejemplo n.º 5
0
def checker(config: Config, repo_path, oracle, collateral_fa2, cfmm_token_fa2,
            ctez_cfmm):
    """
    Deploy checker. Requires addresses for oracle and ctez contracts.
    """
    if not oracle:
        raise ValueError("Oracle address was not provided as an argument.")
    if not collateral_fa2:
        raise ValueError(
            "Collateral FA2 contract address was not provided as an argument.")
    if not cfmm_token_fa2:
        raise ValueError(
            "CFMM FA2 contract address was not provided as an argument.")
    if not config.ctez_cfmm_address and not ctez_cfmm:
        raise ValueError(
            "ctez cfmm address was neither specified in the CLI config nor provided as an argument."
        )
    if ctez_cfmm:
        config.ctez_cfmm_address = ctez_cfmm

    shell = construct_url(config.tezos_address, config.tezos_port)
    click.echo(f"Connecting to tezos node at: {shell}")
    client = pytezos.pytezos.using(shell=shell, key=config.tezos_key)
    client.loglevel = logging.WARNING
    checker = checker_lib.deploy_checker(
        client,
        CheckerRepo(repo_path),
        oracle=oracle,
        collateral_fa2=collateral_fa2,
        cfmm_token_fa2=cfmm_token_fa2,
        ctez_cfmm=config.ctez_cfmm_address,
        ttl=_patch_operation_ttl(config),
    )
    click.echo(
        f"Checker contract deployed with address: {checker.context.address}")
    config.checker_address = checker.context.address
    # FIXME: Do we need a separate configuration file? This is troublesome.
    config.dump()
Ejemplo n.º 6
0
def wrapped_ctez(config: Config, repo_path, ctez_fa12):
    """
    Deploy wctez contract (FA2-wrapped ctez).
    """
    if not config.ctez_fa12_address and not ctez_fa12:
        raise ValueError(
            "ctez fa12 address was neither specified in the CLI config nor provided as an argument."
        )
    if ctez_fa12:
        config.ctez_fa12_address = ctez_fa12
    shell = construct_url(config.tezos_address, config.tezos_port)
    click.echo(f"Connecting to tezos node at: {shell}")
    client = pytezos.pytezos.using(shell=shell, key=config.tezos_key)
    client.loglevel = logging.WARNING
    wctez = checker_lib.deploy_wctez(
        client,
        CheckerRepo(repo_path),
        config.ctez_fa12_address,
        ttl=_patch_operation_ttl(config),
    )
    click.echo(
        f"wctez contract deployed with address: {wctez.context.address}")
    config.wctez_address = wctez.context.address
    config.dump()