Skip to content

Commit d4d7f6b

Browse files
author
root28root
committed
Escrow: consume resources in entry_demo (destroy_* helpers)
1 parent 5d44ff5 commit d4d7f6b

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

escrow/sources/escrow.move

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,32 @@ module Escrow::escrow {
5252
bw.balance = bw.balance + d.amount;
5353
d.completed = true;
5454
}
55-
public entry fun entry_demo(_s: &signer) {
55+
56+
/// Утилиты, чтобы потребить ресурсы и избежать implicit drop
57+
fun destroy_wallet(w: Wallet) {
58+
let Wallet { balance: _ } = w;
59+
}
60+
fun destroy_deal(d: Deal) {
61+
let Deal { buyer: _, seller: _, amount: _, funded: _, completed: _ } = d;
62+
}
63+
64+
/// DEMO entry: депозит → фандинг → релиз
65+
public entry fun entry_demo(_s: &signer) {
5666
let bw = new_wallet();
5767
let sw = new_wallet();
68+
5869
deposit(&mut bw, 150);
5970
let d = create(@0x1, @0x2, 100);
71+
6072
fund(@0x1, &mut bw, &mut d);
6173
release(@0x2, &mut sw, &mut d);
74+
6275
assert!(balance(&bw) == 50, 0);
6376
assert!(balance(&sw) == 100, 1);
77+
78+
// Потребляем ресурсы
79+
destroy_deal(d);
80+
destroy_wallet(bw);
81+
destroy_wallet(sw);
6482
}
6583
}

0 commit comments

Comments
 (0)