2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | |
---|
5 | | - | |
---|
6 | | - | @Callable(i) |
---|
7 | | - | func default () = { |
---|
8 | | - | let pmt = extract(i.payment) |
---|
9 | | - | if (isDefined(pmt.assetId)) |
---|
10 | | - | then throw("can hodl waves only at the moment") |
---|
11 | | - | else { |
---|
12 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
13 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
14 | | - | case a: Int => |
---|
15 | | - | a |
---|
16 | | - | case _ => |
---|
17 | | - | 0 |
---|
18 | | - | } |
---|
19 | | - | let newAmount = (currentAmount + pmt.amount) |
---|
20 | | - | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
21 | | - | } |
---|
22 | | - | } |
---|
23 | | - | |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | @Callable(i) |
---|
27 | | - | func deposit () = { |
---|
28 | | - | let pmt = extract(i.payment) |
---|
29 | | - | if (isDefined(pmt.assetId)) |
---|
30 | | - | then throw("can hodl waves only at the moment") |
---|
31 | | - | else { |
---|
32 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
33 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
34 | | - | case a: Int => |
---|
35 | | - | a |
---|
36 | | - | case _ => |
---|
37 | | - | 0 |
---|
38 | | - | } |
---|
39 | | - | let newAmount = (currentAmount + pmt.amount) |
---|
40 | | - | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
41 | | - | } |
---|
42 | | - | } |
---|
43 | | - | |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | @Callable(i) |
---|
47 | | - | func withdraw (amount) = { |
---|
48 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
49 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
50 | | - | case a: Int => |
---|
51 | | - | a |
---|
52 | | - | case _ => |
---|
53 | | - | 0 |
---|
54 | | - | } |
---|
55 | | - | let newAmount = (currentAmount - amount) |
---|
56 | | - | if ((0 > amount)) |
---|
57 | | - | then throw("Can't withdraw negative amount") |
---|
58 | | - | else if ((0 > newAmount)) |
---|
59 | | - | then throw("Not enough balance") |
---|
60 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
61 | | - | } |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | @Verifier(tx) |
---|
65 | | - | func verify () = true |
---|
66 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
| 6 | + | then 1 |
---|
| 7 | + | else 0 |
---|
| 8 | + | let sig2 = if (sigVerify(tx.bodyBytes, tx.proofs[1], PubKey2)) |
---|
| 9 | + | then 1 |
---|
| 10 | + | else 0 |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|