2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | func depositImpl (pmt,caller) = if (isDefined(pmt.assetId)) |
---|
5 | | - | then throw("can hodl waves only at the moment") |
---|
6 | | - | else { |
---|
7 | | - | let currentKey = toBase58String(caller.bytes) |
---|
8 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
9 | | - | case a: Int => |
---|
10 | | - | a |
---|
11 | | - | case _ => |
---|
12 | | - | 0 |
---|
13 | | - | } |
---|
14 | | - | let newAmount = (currentAmount + pmt.amount) |
---|
15 | | - | WriteSet([DataEntry(currentKey, newAmount)]) |
---|
16 | | - | } |
---|
17 | | - | |
---|
18 | | - | |
---|
19 | | - | @Callable(i) |
---|
20 | | - | func default () = depositImpl(extract(i.payment), i.caller) |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | |
---|
24 | | - | @Callable(i) |
---|
25 | | - | func deposit () = depositImpl(extract(i.payment), i.caller) |
---|
26 | | - | |
---|
27 | | - | |
---|
28 | | - | |
---|
29 | | - | @Callable(i) |
---|
30 | | - | func withdraw (amount,donate,name,vec) = { |
---|
31 | | - | let expectedVec = toBytes("Hello, Ride4DApp!") |
---|
32 | | - | let donationAddress = extract(addressFromString("3N4sxBoGovhPyScZ8DyXaXL9tWKtG6kBvSj")) |
---|
33 | | - | let withdrawTotal = if (donate) |
---|
34 | | - | then (2 * amount) |
---|
35 | | - | else amount |
---|
36 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
37 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
38 | | - | case a: Int => |
---|
39 | | - | a |
---|
40 | | - | case _ => |
---|
41 | | - | 0 |
---|
42 | | - | } |
---|
43 | | - | let newAmount = (currentAmount - withdrawTotal) |
---|
44 | | - | if ((0 > withdrawTotal)) |
---|
45 | | - | then throw("Can't withdraw negative amount") |
---|
46 | | - | else if ((0 > newAmount)) |
---|
47 | | - | then throw("Not enough balance") |
---|
48 | | - | else if ((expectedVec != vec)) |
---|
49 | | - | then throw("vec parameter doesn't match expected value") |
---|
50 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount), DataEntry((name + " Total"), withdrawTotal), DataEntry((name + " Donation"), amount)]), TransferSet([ScriptTransfer(i.caller, amount, unit), ScriptTransfer(donationAddress, amount, unit)])) |
---|
51 | | - | } |
---|
52 | | - | |
---|
53 | | - | |
---|
54 | | - | @Verifier(tx) |
---|
55 | | - | func verify () = true |
---|
56 | | - | |
---|
| 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) |
---|