예제 #1
0
def do_self(ctx: Context, prim, args, annots):
    p_type_expr = ctx.get('parameter')
    assert p_type_expr, f'parameter type is not initialized'

    entry_annot = next((a for a in annots if a[0] == '%'), '%default')
    ctx.print(f'use {entry_annot}')

    p_type_expr, _ = get_entry_expr(p_type_expr, entry_annot)
    res = Contract.new(ctx.dummy_gen.self + entry_annot, type_expr=p_type_expr)
    ctx.push(res, annots=['@self'])
예제 #2
0
def check_contract(ctx: Context, address, entry_annot, type_expr):
    network = ctx.get('NETWORK')
    if not network:
        ctx.print('skip check')
        return True
    try:
        ci = pytezos.using(network).contract(address)
        actual = get_entry_expr(ci.contract.parameter.code, entry_annot)
        if expr_equal(type_expr, actual):
            return True
        else:
            ctx.print('entry type mismatch')
    except Exception:
        ctx.print('not found')

    return False
예제 #3
0
def check_contract(ctx: Context, address, entry_annot, type_expr):
    network = ctx.get('NETWORK')
    if not network:
        ctx.print('skip check')
        return True
    try:
        script = Interop().using(network).shell.contracts[address].script()
        p_type_expr = next(s for s in script['code'] if s['prim'] == 'parameter')
        actual, _ = get_entry_expr(p_type_expr, entry_annot)
        if expr_equal(type_expr, actual):
            return True
        else:
            ctx.print('entry type mismatch')
    except Exception:
        ctx.print('not found')

    return False
예제 #4
0
def do_begin(ctx: Context, prim, args, annots):
    p_type_expr = ctx.get('parameter')
    assert p_type_expr, f'parameter type is not initialized'

    entrypoint = next((a for a in annots if a[0] == '%'), '%default')
    ctx.print(f'use {entrypoint}')

    network = ctx.get('NETWORK')
    if network:
        ctx.print(f'use {network}')

    p_type_expr = get_entry_expr(p_type_expr, entrypoint)
    parameter = ctx.big_maps.pre_alloc(args[0], p_type_expr, copy=True, network=network)

    s_type_expr = ctx.get('storage')
    assert s_type_expr, f'storage type is not initialized'
    s_val_expr = ctx.get('STORAGE') if is_prim(args[1], 'STORAGE') else args[1]
    storage = ctx.big_maps.pre_alloc(s_val_expr, s_type_expr, network=network)

    ctx.drop_all()
    run_input = Pair.new(parameter, storage)
    ctx.push(run_input, annots=annots)