//# publish module 0x1.Coin { struct Coin has store { value: u64 } public value(c: &Self.Coin): u64 { label b0: return *&move(c).Coin::value; } public zero(): Self.Coin { label b0: return Coin { value: 0 }; } } //# publish module 0x42.M { import 0x1.Coin; import 0x1.vector; import 0x1.signer; struct Coins has key { f: vector } public new(account: &signer) { let coin_vec: vector; let coins: Self.Coins; label b0: coin_vec = vector.empty(); coins = Coins { f: move(coin_vec)}; move_to(move(account), move(coins)); return; } public put_coin(account: &signer, coin: Coin.Coin) acquires Coins { let coins_ref: &mut Self.Coins; let v_ref: &mut vector; label b0: coins_ref = borrow_global_mut(signer.address_of(move(account))); v_ref = &mut move(coins_ref).Coins::f; vector.push_back(move(v_ref), move(coin)); return; } public get_value(account: &signer, i: u64): u64 acquires Coins { let coins_ref: &Self.Coins; let v_ref: &vector; let coin_ref: &Coin.Coin; label b0: coins_ref = borrow_global(signer.address_of(move(account))); v_ref = &move(coins_ref).Coins::f; coin_ref = vector.borrow(move(v_ref), move(i)); return Coin.value(move(coin_ref)); } public pop(account: &signer): Coin.Coin acquires Coins { let coins_ref: &mut Self.Coins; let v_ref: &mut vector; label b0: coins_ref = borrow_global_mut(signer.address_of(move(account))); v_ref = &mut move(coins_ref).Coins::f; return vector.pop_back(move(v_ref)); } } //# run --signers 0x1 import 0x42.M; import 0x1.Coin; main(account: signer) { label b0: M.new(&account); M.put_coin(&account, Coin.zero()); return; }