1 | | - | {-# STDLIB_VERSION 4 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let sumazdeponowanychsrodkow = "suma_zdeponowanych_srodkow" |
---|
5 | | - | |
---|
6 | | - | @Callable(i) |
---|
7 | | - | func depozyt () = { |
---|
8 | | - | let pmt = i.payments[0] |
---|
9 | | - | if (isDefined(pmt.assetId)) |
---|
10 | | - | then throw("mozesz przechowywać tylko WAVES") |
---|
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 | | - | let wczesniejszasuma = match getInteger(this, sumazdeponowanychsrodkow) { |
---|
21 | | - | case a: Int => |
---|
22 | | - | a |
---|
23 | | - | case _ => |
---|
24 | | - | 0 |
---|
25 | | - | } |
---|
26 | | - | let aktualnasuma = (wczesniejszasuma + pmt.amount) |
---|
27 | | - | [IntegerEntry(currentKey, newAmount), IntegerEntry(sumazdeponowanychsrodkow, aktualnasuma)] |
---|
28 | | - | } |
---|
29 | | - | } |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | |
---|
33 | | - | @Callable(i) |
---|
34 | | - | func wyplac (kwota) = { |
---|
35 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
36 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
37 | | - | case a: Int => |
---|
38 | | - | a |
---|
39 | | - | case _ => |
---|
40 | | - | 0 |
---|
41 | | - | } |
---|
42 | | - | let newAmount = (currentAmount - kwota) |
---|
43 | | - | if ((0 > kwota)) |
---|
44 | | - | then throw("Niemożna wypłacić ujemnej liczby środków") |
---|
45 | | - | else if ((0 > newAmount)) |
---|
46 | | - | then throw("Niwystarczająca ilość środków") |
---|
47 | | - | else { |
---|
48 | | - | let wczesniejszasuma = match getInteger(this, sumazdeponowanychsrodkow) { |
---|
49 | | - | case a: Int => |
---|
50 | | - | a |
---|
51 | | - | case _ => |
---|
52 | | - | 0 |
---|
53 | | - | } |
---|
54 | | - | let aktualnasuma = (wczesniejszasuma - kwota) |
---|
55 | | - | [IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, kwota, unit), IntegerEntry(sumazdeponowanychsrodkow, aktualnasuma)] |
---|
56 | | - | } |
---|
57 | | - | } |
---|
58 | | - | |
---|
59 | | - | |
---|
| 1 | + | # no script |
---|