Example #1
0
def do_patch(ctx: Context, prim, args, annots):
    key, _ = parse_prim_expr(args[0])
    assert key in patch_prim, f'expected one of {", ".join(patch_prim)}, got {args[0]}'
    if key in ['AMOUNT', 'BALANCE']:
        res = Mutez(get_int(args[1]))
    elif key == 'NOW':
        res = Timestamp(get_int(args[1]))
    elif key in ['SOURCE', 'SENDER']:
        res = Address.new(get_string(args[1]))
    elif key == 'CHAIN_ID':
        res = ChainID(get_string(args[1]))
    else:
        assert False
    ctx.set(key, res)
Example #2
0
def do_reset(ctx: Context, prim, args, annots):
    network = get_string(args[0])
    assert network in networks, f'expected on of {", ".join(networks)}, got {network}'
    ctx.set('NETWORK', network)
    chain_id = ChainID(Interop().using(network).shell.chains.main.chain_id())
    ctx.set('CHAIN_ID', chain_id)
    ctx.big_maps.reset()
    ctx.drop_all()
Example #3
0
def do_include(ctx: Context, prim, args, annots):
    path = get_string(args[0])

    if isfile(path):
        code = Contract.from_file(path).code
    else:
        parts = path.split(':')
        network = parts[0] if len(parts) > 1 else ctx.get('NETWORK', 'mainnet')
        address = parts[1] if len(parts) > 1 else parts[0]
        assert is_kt(address), f'expected filename or KT address (with network), got {path}'
        script = Interop().using(network).shell.contracts[address].script()
        code = script['code']
        ctx.set('STORAGE', script['storage'])

    do_interpret(ctx, code)
Example #4
0
def do_print(ctx: Context, prim, args, annots):
    ctx.printf(template=get_string(args[0]))