Exemple #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)
Exemple #2
0
def do_dig(ctx: Context, prim, args, annots):
    assert_no_annots(prim, annots)
    index = get_int(args[0])
    ctx.protect(index)
    res = ctx.pop1()
    ctx.restore(index)
    ctx.push(res)
Exemple #3
0
 def _check_allocated(self, val_expr, type_expr, network=None):
     big_map_id = get_int(val_expr)
     assert big_map_id >= 0, f'expected an allocated big map (>=0), got {big_map_id}'
     if big_map_id in self.maps:
         big_map = self.maps[big_map_id]
         _ = [
             assert_expr_equal(type_expr['args'][i],
                               big_map.type_expr['args'][i])
             for i in [0, 1]
         ]
         return big_map_id, {'_diff': {}}
     else:
         assert network, f'big map #{big_map_id} is not allocated'
         self.alloc_id = max(self.alloc_id, big_map_id + 1)
         return big_map_id, {'_diff': {}, '_network': network}
Exemple #4
0
def do_dump(ctx: Context, prim, args, annots):
    res = ctx.dump(count=get_int(args[0]))
    if res:
        return {'kind': 'stack', 'stack': res}
    else:
        return {'kind': 'message', 'value': 'stack is empty'}
Exemple #5
0
def do_drop(ctx: Context, prim, args, annots):
    assert_no_annots(prim, annots)
    count = get_int(args[0])
    _ = ctx.pop(count=count)
Exemple #6
0
def do_dip(ctx: Context, prim, args, annots):
    assert_no_annots(prim, annots)
    count = get_int(args[0])
    ctx.protect(count)
    do_interpret(ctx, args[1])
    ctx.restore(count)