-
Notifications
You must be signed in to change notification settings - Fork 3
/
bobpaysalice.rho
38 lines (38 loc) · 1.79 KB
/
bobpaysalice.rho
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
new return(`rho:rchain:deployId`), lookup(`rho:registry:lookup`), ret, alicePurseCh, bobPurseCh,
initialAlicePurseBalanceCh, initialBobPurseBalanceCh,successCh, finalAlicePurseBalanceCh,
finalBobPurseBalanceCh, stdout(`rho:io:stdout`) in {
lookup!( `rho:id:rgd9xzheeo33tn765wjijox7kd7ciar4jr7qkq9g64n4qmdxxrd35m` , *ret) |
for (mint <- ret) {
stdout!("got mint") |
match (100000000, 1000) {
(aliceAmt, bobAmt) => {
stdout!("got init bals") |
// Alice's purse has maximum balance.
mint!("makePurse", aliceAmt, *alicePurseCh) |
mint!("makePurse", bobAmt, *bobPurseCh) |
for (alicePurse <- alicePurseCh;
bobPurse <- bobPurseCh) {
stdout!("got purses")|
alicePurse!("getBalance", *initialAlicePurseBalanceCh) |
bobPurse!("getBalance", *initialBobPurseBalanceCh) |
for (@initialAlicePurseBalance <- initialAlicePurseBalanceCh;
@initialBobPurseBalance <- initialBobPurseBalanceCh) {
stdout!("got init bals again")|
// Depositing any funds to Alice results in overflow.
alicePurse!("deposit", 1, *bobPurse, *successCh) |
for (@flag <- successCh) {
stdout!(["got success", flag])|
alicePurse!("getBalance", *finalAlicePurseBalanceCh) |
bobPurse!("getBalance", *finalBobPurseBalanceCh) |
for (@finalAlicePurseBalance <- finalAlicePurseBalanceCh;
@finalBobPurseBalance <- finalBobPurseBalanceCh) {
stdout!("got final")|
return!("bob bal", finalBobPurseBalance, "alice bal", finalAlicePurseBalance)
}
}
}
}
}
}
}
}