tx · D6MbMuk1EUqS8UQ3Z34NeEFBv5rSJm8YteXRWvNRWAxH 3N2HzcM61QM3LsUrsq4UBvi2btJMHyxvVMD: -0.00400000 Waves 2022.07.14 19:44 [2139648] smart account 3N2HzcM61QM3LsUrsq4UBvi2btJMHyxvVMD > SELF 0.00000000 Waves
{ "type": 13, "id": "D6MbMuk1EUqS8UQ3Z34NeEFBv5rSJm8YteXRWvNRWAxH", "fee": 400000, "feeAssetId": null, "timestamp": 1657817146931, "version": 2, "chainId": 84, "sender": "3N2HzcM61QM3LsUrsq4UBvi2btJMHyxvVMD", "senderPublicKey": "CU5wMqCBg4bC4Zgs8QGiqjjvmeMkSiKo3Ff6k5axJZwr", "proofs": [ "mWJx8ySEeJs1iPSwVRpXo55sc5kW3LhDwvm9g3TLTEwhFWeu9j3KBvtDoynt2fztF4PwVoN9PeS5oDMxKnSJ5AV" ], "script": "base64:AAIDAAAAAAAAABQIARIAEgMKAQESAwoBARIECgIBCAAAAAAAAAAEAAAAAWkBAAAAB2RlcG9zaXQAAAAABAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAWkAAAAHcGF5bWVudAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAADcG10AAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAhY2FuIGhvZGwgd2F2ZXMgb25seSBhdCB0aGUgbW9tZW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAAEnh4eEludmVzdG9yQmFsYW5jZQkAASwAAAACCQABLAAAAAIFAAAACmN1cnJlbnRLZXkCAAAAAV8CAAAAAmliBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAEnh4eEludmVzdG9yQmFsYW5jZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABAAAAAluZXdBbW91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m90ZXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAQAAAALY3VycmVudEZ1bmQEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAOeHh4U3RhcnR1cEZ1bmQDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAMJAABnAAAAAgAAAAAAAAAAAAUAAAAGYW1vdW50CQAAAgAAAAECAAAAHkNhbid0IHdpdGhkcmF3IG5lZ2F0aXZlIGFtb3VudAMJAABmAAAAAgUAAAAGYW1vdW50BQAAAA1jdXJyZW50QW1vdW50CQAAAgAAAAECAAAAE05vdCBlbm91Z2ggYmFsYW5jZSEDCQAAZgAAAAIFAAAABGZsYWcAAAAAAAAAAAAJAAACAAAAAQIAAAAmT25seSBvbmUgdm90ZSBwZXIgcHJvamVjdCBpcyBwb3NzaWJsZSEJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAEnh4eEludmVzdG9yQmFsYW5jZQkAAGUAAAACBQAAAA1jdXJyZW50QW1vdW50BQAAAAZhbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAD3h4eFN0YXJ0dXBWb3RlcwkAAGQAAAACBQAAAAxjdXJyZW50Vm90ZXMAAAAAAAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAB2ZsYWdLZXkAAAAAAAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAADnh4eFN0YXJ0dXBGdW5kCQAAZAAAAAIFAAAAC2N1cnJlbnRGdW5kBQAAAAZhbW91bnQFAAAAA25pbAAAAAAzz6it", "height": 2139648, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5F3pKCFMx5YJiFho5YYn7tbZJNyXQLWLeJXdLVpRVf6K Next: 4jZtWxoN6tUH5MYMiM5BnwrsZBowbxskuGTKnWc69MUe Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | ||
4 | + | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func deposit () = { | |
8 | 8 | let pmt = extract(i.payment) | |
9 | - | if ((pmt.assetId | |
10 | - | then throw(" | |
9 | + | if (isDefined(pmt.assetId)) | |
10 | + | then throw("can hodl waves only at the moment") | |
11 | 11 | else { | |
12 | 12 | let currentKey = toBase58String(i.caller.bytes) | |
13 | - | let currentAmount = match getInteger(this, currentKey) { | |
13 | + | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
14 | + | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
14 | 15 | case a: Int => | |
15 | 16 | a | |
16 | 17 | case _ => | |
17 | 18 | 0 | |
18 | 19 | } | |
19 | 20 | let newAmount = (currentAmount + pmt.amount) | |
20 | - | WriteSet([DataEntry( | |
21 | + | WriteSet([DataEntry(xxxInvestorBalance, newAmount)]) | |
21 | 22 | } | |
22 | 23 | } | |
23 | 24 | ||
26 | 27 | @Callable(i) | |
27 | 28 | func withdraw (amount) = { | |
28 | 29 | let currentKey = toBase58String(i.caller.bytes) | |
29 | - | let currentAmount = match getInteger(this, currentKey) { | |
30 | + | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
31 | + | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
30 | 32 | case a: Int => | |
31 | 33 | a | |
32 | 34 | case _ => | |
37 | 39 | then throw("Can't withdraw negative amount") | |
38 | 40 | else if ((0 > newAmount)) | |
39 | 41 | then throw("Not enough balance") | |
40 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
42 | + | else ScriptResult(WriteSet([DataEntry(xxxInvestorBalance, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | ||
47 | + | @Callable(i) | |
48 | + | func getFunds (amount) = { | |
49 | + | let quorum = 2 | |
50 | + | let currentKey = toBase58String(i.caller.bytes) | |
51 | + | let xxxStartupFund = ((currentKey + "_") + "sf") | |
52 | + | let xxxStartupVotes = ((currentKey + "_") + "sv") | |
53 | + | let currentAmount = match getInteger(this, xxxStartupFund) { | |
54 | + | case a: Int => | |
55 | + | a | |
56 | + | case _ => | |
57 | + | 0 | |
58 | + | } | |
59 | + | let totalVotes = match getInteger(this, xxxStartupVotes) { | |
60 | + | case a: Int => | |
61 | + | a | |
62 | + | case _ => | |
63 | + | 0 | |
64 | + | } | |
65 | + | let newAmount = (currentAmount - amount) | |
66 | + | if ((0 > amount)) | |
67 | + | then throw("Can't withdraw negative amount") | |
68 | + | else if ((0 > newAmount)) | |
69 | + | then throw("Not enough balance") | |
70 | + | else if ((quorum > totalVotes)) | |
71 | + | then throw("Not enough votes. At least 2 votes required!") | |
72 | + | else ScriptResult(WriteSet([DataEntry(xxxStartupFund, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func vote (amount,address) = { | |
79 | + | let currentKey = toBase58String(i.caller.bytes) | |
80 | + | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
81 | + | let xxxStartupFund = ((address + "_") + "sf") | |
82 | + | let xxxStartupVotes = ((address + "_") + "sv") | |
83 | + | let flagKey = ((address + "_") + currentKey) | |
84 | + | let flag = match getInteger(this, flagKey) { | |
85 | + | case a: Int => | |
86 | + | a | |
87 | + | case _ => | |
88 | + | 0 | |
89 | + | } | |
90 | + | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
91 | + | case a: Int => | |
92 | + | a | |
93 | + | case _ => | |
94 | + | 0 | |
95 | + | } | |
96 | + | let currentVotes = match getInteger(this, xxxStartupVotes) { | |
97 | + | case a: Int => | |
98 | + | a | |
99 | + | case _ => | |
100 | + | 0 | |
101 | + | } | |
102 | + | let currentFund = match getInteger(this, xxxStartupFund) { | |
103 | + | case a: Int => | |
104 | + | a | |
105 | + | case _ => | |
106 | + | 0 | |
107 | + | } | |
108 | + | if ((0 >= amount)) | |
109 | + | then throw("Can't withdraw negative amount") | |
110 | + | else if ((amount > currentAmount)) | |
111 | + | then throw("Not enough balance!") | |
112 | + | else if ((flag > 0)) | |
113 | + | then throw("Only one vote per project is possible!") | |
114 | + | else WriteSet([DataEntry(xxxInvestorBalance, (currentAmount - amount)), DataEntry(xxxStartupVotes, (currentVotes + 1)), DataEntry(flagKey, 1), DataEntry(xxxStartupFund, (currentFund + amount))]) | |
41 | 115 | } | |
42 | 116 | ||
43 | 117 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | ||
4 | + | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func deposit () = { | |
8 | 8 | let pmt = extract(i.payment) | |
9 | - | if ((pmt.assetId | |
10 | - | then throw(" | |
9 | + | if (isDefined(pmt.assetId)) | |
10 | + | then throw("can hodl waves only at the moment") | |
11 | 11 | else { | |
12 | 12 | let currentKey = toBase58String(i.caller.bytes) | |
13 | - | let currentAmount = match getInteger(this, currentKey) { | |
13 | + | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
14 | + | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
14 | 15 | case a: Int => | |
15 | 16 | a | |
16 | 17 | case _ => | |
17 | 18 | 0 | |
18 | 19 | } | |
19 | 20 | let newAmount = (currentAmount + pmt.amount) | |
20 | - | WriteSet([DataEntry( | |
21 | + | WriteSet([DataEntry(xxxInvestorBalance, newAmount)]) | |
21 | 22 | } | |
22 | 23 | } | |
23 | 24 | ||
24 | 25 | ||
25 | 26 | ||
26 | 27 | @Callable(i) | |
27 | 28 | func withdraw (amount) = { | |
28 | 29 | let currentKey = toBase58String(i.caller.bytes) | |
29 | - | let currentAmount = match getInteger(this, currentKey) { | |
30 | + | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
31 | + | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
30 | 32 | case a: Int => | |
31 | 33 | a | |
32 | 34 | case _ => | |
33 | 35 | 0 | |
34 | 36 | } | |
35 | 37 | let newAmount = (currentAmount - amount) | |
36 | 38 | if ((0 > amount)) | |
37 | 39 | then throw("Can't withdraw negative amount") | |
38 | 40 | else if ((0 > newAmount)) | |
39 | 41 | then throw("Not enough balance") | |
40 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
42 | + | else ScriptResult(WriteSet([DataEntry(xxxInvestorBalance, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | ||
47 | + | @Callable(i) | |
48 | + | func getFunds (amount) = { | |
49 | + | let quorum = 2 | |
50 | + | let currentKey = toBase58String(i.caller.bytes) | |
51 | + | let xxxStartupFund = ((currentKey + "_") + "sf") | |
52 | + | let xxxStartupVotes = ((currentKey + "_") + "sv") | |
53 | + | let currentAmount = match getInteger(this, xxxStartupFund) { | |
54 | + | case a: Int => | |
55 | + | a | |
56 | + | case _ => | |
57 | + | 0 | |
58 | + | } | |
59 | + | let totalVotes = match getInteger(this, xxxStartupVotes) { | |
60 | + | case a: Int => | |
61 | + | a | |
62 | + | case _ => | |
63 | + | 0 | |
64 | + | } | |
65 | + | let newAmount = (currentAmount - amount) | |
66 | + | if ((0 > amount)) | |
67 | + | then throw("Can't withdraw negative amount") | |
68 | + | else if ((0 > newAmount)) | |
69 | + | then throw("Not enough balance") | |
70 | + | else if ((quorum > totalVotes)) | |
71 | + | then throw("Not enough votes. At least 2 votes required!") | |
72 | + | else ScriptResult(WriteSet([DataEntry(xxxStartupFund, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func vote (amount,address) = { | |
79 | + | let currentKey = toBase58String(i.caller.bytes) | |
80 | + | let xxxInvestorBalance = ((currentKey + "_") + "ib") | |
81 | + | let xxxStartupFund = ((address + "_") + "sf") | |
82 | + | let xxxStartupVotes = ((address + "_") + "sv") | |
83 | + | let flagKey = ((address + "_") + currentKey) | |
84 | + | let flag = match getInteger(this, flagKey) { | |
85 | + | case a: Int => | |
86 | + | a | |
87 | + | case _ => | |
88 | + | 0 | |
89 | + | } | |
90 | + | let currentAmount = match getInteger(this, xxxInvestorBalance) { | |
91 | + | case a: Int => | |
92 | + | a | |
93 | + | case _ => | |
94 | + | 0 | |
95 | + | } | |
96 | + | let currentVotes = match getInteger(this, xxxStartupVotes) { | |
97 | + | case a: Int => | |
98 | + | a | |
99 | + | case _ => | |
100 | + | 0 | |
101 | + | } | |
102 | + | let currentFund = match getInteger(this, xxxStartupFund) { | |
103 | + | case a: Int => | |
104 | + | a | |
105 | + | case _ => | |
106 | + | 0 | |
107 | + | } | |
108 | + | if ((0 >= amount)) | |
109 | + | then throw("Can't withdraw negative amount") | |
110 | + | else if ((amount > currentAmount)) | |
111 | + | then throw("Not enough balance!") | |
112 | + | else if ((flag > 0)) | |
113 | + | then throw("Only one vote per project is possible!") | |
114 | + | else WriteSet([DataEntry(xxxInvestorBalance, (currentAmount - amount)), DataEntry(xxxStartupVotes, (currentVotes + 1)), DataEntry(flagKey, 1), DataEntry(xxxStartupFund, (currentFund + amount))]) | |
41 | 115 | } | |
42 | 116 | ||
43 | 117 |
github/deemru/w8io/026f985 25.97 ms ◑