module Token { resource T {balance: u64} public new(balance: u64): R#Self.T { return T{balance: copy(balance)}; } public value(this: &R#Self.T): u64 { let b: u64; let b_ref: &u64; b_ref = &move(this).balance; b = *move(b_ref); return move(b); } public bump(this: &mut R#Self.T) { let val: &mut u64; let x: u64; val = &mut move(this).balance; x = *copy(val) + 1; *move(val) = copy(x); return; } public publish(t: R#Self.T) { move_to_sender(move(t)); return; } public test() { let z: R#Self.T; let addr1: address; let struct1: &mut R#Self.T; let imm_struct1: &R#Self.T; let struct1_original_balance: u64; let struct1_new_balance: u64; z = Self.new(0); Self.publish(move(z)); addr1 = get_txn_sender(); struct1 = borrow_global(copy(addr1)); imm_struct1 = freeze(copy(struct1)); struct1_original_balance = Self.value(move(imm_struct1)); if (move(struct1_original_balance) != 0) { abort 42; } Self.bump(copy(struct1)); imm_struct1 = freeze(move(struct1)); struct1_new_balance = Self.value(move(imm_struct1)); if (move(struct1_new_balance) != 1) { abort 42; } return; } } //! new-transaction import {{default}}.Token; main() { Token.test(); return; }