18 | | - | @Callable(contextObj) |
---|
19 | | - | func castVote (vote) = if ((containsElement(assets, vote) == false)) |
---|
20 | | - | then throw("Incorrect vote!") |
---|
21 | | - | else { |
---|
22 | | - | let voiteKey = makeString(["vote", vote], "_") |
---|
23 | | - | let voteAddressKey = keyUserAssetBalance(toString(contextObj.caller), vote) |
---|
24 | | - | let userBalanceKey = keyUserBalance(contextObj.caller) |
---|
25 | | - | let payment = value(contextObj.payments[0]) |
---|
26 | | - | let assetIdReceived = payment.assetId |
---|
27 | | - | let tokenReceiveAmount = payment.amount |
---|
28 | | - | let voteNumberThis = valueOrElse(getInteger(this, voiteKey), 0) |
---|
29 | | - | let contractUserBalance = valueOrElse(getInteger(this, userBalanceKey), 0) |
---|
30 | | - | let voteOnAsset = valueOrElse(getInteger(this, voteAddressKey), 0) |
---|
31 | | - | if ((assetIdReceived != NSBTid)) |
---|
32 | | - | then throw("incorrect assets") |
---|
33 | | - | else if ((height >= heightEnd)) |
---|
34 | | - | then throw("vote finished") |
---|
35 | | - | else [IntegerEntry(voiteKey, (voteNumberThis + tokenReceiveAmount)), IntegerEntry(userBalanceKey, (contractUserBalance + tokenReceiveAmount)), IntegerEntry(voteAddressKey, (voteOnAsset + tokenReceiveAmount))] |
---|
36 | | - | } |
---|
| 12 | + | @Callable(i) |
---|
| 13 | + | func callableFoo () = [IntegerEntry(keyBar, (barOrZero() + 1))] |
---|
40 | | - | @Callable(contextObj) |
---|
41 | | - | func cancelVote () = { |
---|
42 | | - | let userBalanceKey = keyUserBalance(contextObj.caller) |
---|
43 | | - | let contractUserBalance = valueOrElse(getInteger(this, userBalanceKey), 0) |
---|
44 | | - | if ((contractUserBalance == 0)) |
---|
45 | | - | then nil |
---|
46 | | - | else { |
---|
47 | | - | func cancelVotePredicateNew (accumulatedResultList,assetCode) = { |
---|
48 | | - | let totalVotes4AssetKey = makeString(["vote", assetCode], "_") |
---|
49 | | - | let userNsbtBalance4AssetKey = keyUserAssetBalance(toString(contextObj.caller), assetCode) |
---|
50 | | - | let totalVotes4Asset = valueOrElse(getInteger(this, totalVotes4AssetKey), 0) |
---|
51 | | - | let userNsbtBalance4Asset = valueOrElse(getInteger(this, userNsbtBalance4AssetKey), 0) |
---|
52 | | - | if ((totalVotes4Asset == 0)) |
---|
53 | | - | then accumulatedResultList |
---|
54 | | - | else ((accumulatedResultList :+ IntegerEntry(totalVotes4AssetKey, (totalVotes4Asset - userNsbtBalance4Asset))) :+ IntegerEntry(userNsbtBalance4AssetKey, 0)) |
---|
55 | | - | } |
---|
56 | | - | |
---|
57 | | - | ({ |
---|
58 | | - | let $list27112800 = assets |
---|
59 | | - | let $size27112800 = size($list27112800) |
---|
60 | | - | let $acc027112800 = [IntegerEntry(userBalanceKey, 0)] |
---|
61 | | - | if (($size27112800 == 0)) |
---|
62 | | - | then $acc027112800 |
---|
63 | | - | else { |
---|
64 | | - | let $acc127112800 = cancelVotePredicateNew($acc027112800, $list27112800[0]) |
---|
65 | | - | if (($size27112800 == 1)) |
---|
66 | | - | then $acc127112800 |
---|
67 | | - | else { |
---|
68 | | - | let $acc227112800 = cancelVotePredicateNew($acc127112800, $list27112800[1]) |
---|
69 | | - | if (($size27112800 == 2)) |
---|
70 | | - | then $acc227112800 |
---|
71 | | - | else { |
---|
72 | | - | let $acc327112800 = cancelVotePredicateNew($acc227112800, $list27112800[2]) |
---|
73 | | - | if (($size27112800 == 3)) |
---|
74 | | - | then $acc327112800 |
---|
75 | | - | else { |
---|
76 | | - | let $acc427112800 = cancelVotePredicateNew($acc327112800, $list27112800[3]) |
---|
77 | | - | if (($size27112800 == 4)) |
---|
78 | | - | then $acc427112800 |
---|
79 | | - | else { |
---|
80 | | - | let $acc527112800 = cancelVotePredicateNew($acc427112800, $list27112800[4]) |
---|
81 | | - | if (($size27112800 == 5)) |
---|
82 | | - | then $acc527112800 |
---|
83 | | - | else { |
---|
84 | | - | let $acc627112800 = cancelVotePredicateNew($acc527112800, $list27112800[5]) |
---|
85 | | - | if (($size27112800 == 6)) |
---|
86 | | - | then $acc627112800 |
---|
87 | | - | else { |
---|
88 | | - | let $acc727112800 = cancelVotePredicateNew($acc627112800, $list27112800[6]) |
---|
89 | | - | if (($size27112800 == 7)) |
---|
90 | | - | then $acc727112800 |
---|
91 | | - | else { |
---|
92 | | - | let $acc827112800 = cancelVotePredicateNew($acc727112800, $list27112800[7]) |
---|
93 | | - | if (($size27112800 == 8)) |
---|
94 | | - | then $acc827112800 |
---|
95 | | - | else { |
---|
96 | | - | let $acc927112800 = cancelVotePredicateNew($acc827112800, $list27112800[8]) |
---|
97 | | - | if (($size27112800 == 9)) |
---|
98 | | - | then $acc927112800 |
---|
99 | | - | else { |
---|
100 | | - | let $acc1027112800 = cancelVotePredicateNew($acc927112800, $list27112800[9]) |
---|
101 | | - | if (($size27112800 == 10)) |
---|
102 | | - | then $acc1027112800 |
---|
103 | | - | else { |
---|
104 | | - | let $acc1127112800 = cancelVotePredicateNew($acc1027112800, $list27112800[10]) |
---|
105 | | - | if (($size27112800 == 11)) |
---|
106 | | - | then $acc1127112800 |
---|
107 | | - | else { |
---|
108 | | - | let $acc1227112800 = cancelVotePredicateNew($acc1127112800, $list27112800[11]) |
---|
109 | | - | if (($size27112800 == 12)) |
---|
110 | | - | then $acc1227112800 |
---|
111 | | - | else { |
---|
112 | | - | let $acc1327112800 = cancelVotePredicateNew($acc1227112800, $list27112800[12]) |
---|
113 | | - | if (($size27112800 == 13)) |
---|
114 | | - | then $acc1327112800 |
---|
115 | | - | else { |
---|
116 | | - | let $acc1427112800 = cancelVotePredicateNew($acc1327112800, $list27112800[13]) |
---|
117 | | - | if (($size27112800 == 14)) |
---|
118 | | - | then $acc1427112800 |
---|
119 | | - | else { |
---|
120 | | - | let $acc1527112800 = cancelVotePredicateNew($acc1427112800, $list27112800[14]) |
---|
121 | | - | if (($size27112800 == 15)) |
---|
122 | | - | then $acc1527112800 |
---|
123 | | - | else { |
---|
124 | | - | let $acc1627112800 = cancelVotePredicateNew($acc1527112800, $list27112800[15]) |
---|
125 | | - | if (($size27112800 == 16)) |
---|
126 | | - | then $acc1627112800 |
---|
127 | | - | else { |
---|
128 | | - | let $acc1727112800 = cancelVotePredicateNew($acc1627112800, $list27112800[16]) |
---|
129 | | - | if (($size27112800 == 17)) |
---|
130 | | - | then $acc1727112800 |
---|
131 | | - | else { |
---|
132 | | - | let $acc1827112800 = cancelVotePredicateNew($acc1727112800, $list27112800[17]) |
---|
133 | | - | if (($size27112800 == 18)) |
---|
134 | | - | then $acc1827112800 |
---|
135 | | - | else { |
---|
136 | | - | let $acc1927112800 = cancelVotePredicateNew($acc1827112800, $list27112800[18]) |
---|
137 | | - | if (($size27112800 == 19)) |
---|
138 | | - | then $acc1927112800 |
---|
139 | | - | else { |
---|
140 | | - | let $acc2027112800 = cancelVotePredicateNew($acc1927112800, $list27112800[19]) |
---|
141 | | - | if (($size27112800 == 20)) |
---|
142 | | - | then $acc2027112800 |
---|
143 | | - | else { |
---|
144 | | - | let $acc2127112800 = cancelVotePredicateNew($acc2027112800, $list27112800[20]) |
---|
145 | | - | throw("List size exceed 20") |
---|
146 | | - | } |
---|
147 | | - | } |
---|
148 | | - | } |
---|
149 | | - | } |
---|
150 | | - | } |
---|
151 | | - | } |
---|
152 | | - | } |
---|
153 | | - | } |
---|
154 | | - | } |
---|
155 | | - | } |
---|
156 | | - | } |
---|
157 | | - | } |
---|
158 | | - | } |
---|
159 | | - | } |
---|
160 | | - | } |
---|
161 | | - | } |
---|
162 | | - | } |
---|
163 | | - | } |
---|
164 | | - | } |
---|
165 | | - | } |
---|
166 | | - | } |
---|
167 | | - | } :+ ScriptTransfer(contextObj.caller, contractUserBalance, NSBTid)) |
---|
| 17 | + | @Callable(i) |
---|
| 18 | + | func foo () = { |
---|
| 19 | + | let stateBar = funcBar() |
---|
| 20 | + | if ((stateBar == stateBar)) |
---|
| 21 | + | then { |
---|
| 22 | + | let call = invoke(this, "callableFoo", nil, nil) |
---|
| 23 | + | if ((call == call)) |
---|
| 24 | + | then stateBar |
---|
| 25 | + | else throw("Strict value is not equal to itself.") |
---|