tx · 7hmnd21idCYknowb9sEYeKDBrtGLDQeHpe8FTa2kj6MA 3MwyBKGZcdChEK9Z55HwLn3A2EgwEJJpqC1: -0.01000000 Waves 2024.01.09 14:20 [2923870] smart account 3MwyBKGZcdChEK9Z55HwLn3A2EgwEJJpqC1 > SELF 0.00000000 Waves
{ "type": 13, "id": "7hmnd21idCYknowb9sEYeKDBrtGLDQeHpe8FTa2kj6MA", "fee": 1000000, "feeAssetId": null, "timestamp": 1704799264234, "version": 2, "chainId": 84, "sender": "3MwyBKGZcdChEK9Z55HwLn3A2EgwEJJpqC1", "senderPublicKey": "7c3qLtcJ7EaPS2JDjXv8MBbd4kpyc6R27wcn5GgvZhur", "proofs": [ "3DvS3D3jEsATfikQ48ykQnEvjMzsE2Az493dw5ZrhkoZY9RiPA7xwtcv77hNm7H9pmqWTEKuip3mUrwmbEyyYV5P" ], "script": "base64:BgIMCAISBgoECAEBARIAFQAMY29udHJhY3RGaWxlAhB2ZXN0aW5nX25lby5yaWRlAANTRVACAl9fAAhJRFNfTElTVAkAzAgCAAAJAMwIAgABCQDMCAIAAgkAzAgCAAMJAMwIAgAECQDMCAIABQkAzAgCAAYJAMwIAgAHCQDMCAIACAkAzAgCAAkJAMwIAgAKCQDMCAIACwkAzAgCAAwJAMwIAgANCQDMCAIADgkAzAgCAA8JAMwIAgAQCQDMCAIAEQkAzAgCABIJAMwIAgATCQDMCAIAFAkAzAgCABUJAMwIAgAWCQDMCAIAFwkAzAgCABgJAMwIAgAZCQDMCAIAGgkAzAgCABsJAMwIAgAcCQDMCAIAHQUDbmlsABFNQVhfVkVTVElOR19DT1VOVAkAkAMBBQhJRFNfTElTVAEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAANYXNzZXRJZFN0cmluZwkBC3ZhbHVlT3JFbHNlAgkAnQgCBQ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XN0b3J5AwIGdmVzdGVkBQt1c2VyQWRkcmVzcwkA2AQBCAUBaQ10cmFuc2FjdGlvbklkBQ12ZXN0aW5nQW1vdW50BQNuaWwJAM4IAgkBFGdldE5ld1Zlc3RpbmdBY3Rpb25zBQULdXNlckFkZHJlc3MFAmlkBQ12ZXN0aW5nQW1vdW50BQpzdGFydEJsb2NrBQpsb2NrTGVuZ3RoBQ5oaXN0b3J5QWN0aW9ucwkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQhjbGFpbUFsbAAEC3VzZXJBZGRyZXNzCQClCAEIBQFpBmNhbGxlcgQLJHQwNTU4MTU2NTAJARZnZXRBbGxVc2VyQ2xhaW1BY3Rpb25zAQULdXNlckFkZHJlc3MEDGNsYWltQWN0aW9ucwgFCyR0MDU1ODE1NjUwAl8xBAt0b3RhbEFtb3VudAgFCyR0MDU1ODE1NjUwAl8yBA5oaXN0b3J5QWN0aW9ucwkAzAgCCQEMSW50ZWdlckVudHJ5AgkBEWtleVZlc3RpbmdIaXN0b3J5AwIHY2xhaW1lZAULdXNlckFkZHJlc3MJANgEAQgFAWkNdHJhbnNhY3Rpb25JZAULdG90YWxBbW91bnQFA25pbAMJAGYCBQt0b3RhbEFtb3VudAAACQDOCAIFDGNsYWltQWN0aW9ucwUOaGlzdG9yeUFjdGlvbnMJAQh0aHJvd0VycgECEG5vdGhpbmcgdG8gY2xhaW0ARGKYrw==", "height": 2923870, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Cn926qYzCguhiwet5fkjp8W14KPi4eEL1QDpW6xiatLh Next: Ber9vaDCWa8ar6yvgyDuEwc45ShDrSbTysEn4bj4xXnM Diff:
Old | New | Differences | |
---|---|---|---|
212 | 212 | let claimActions = $t055815650._1 | |
213 | 213 | let totalAmount = $t055815650._2 | |
214 | 214 | let historyActions = [IntegerEntry(keyVestingHistory("claimed", userAddress, toBase58String(i.transactionId)), totalAmount)] | |
215 | - | (claimActions ++ historyActions) | |
215 | + | if ((totalAmount > 0)) | |
216 | + | then (claimActions ++ historyActions) | |
217 | + | else throwErr("nothing to claim") | |
216 | 218 | } | |
217 | 219 | ||
218 | 220 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "vesting_neo.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let IDS_LIST = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] | |
9 | 9 | ||
10 | 10 | let MAX_VESTING_COUNT = size(IDS_LIST) | |
11 | 11 | ||
12 | 12 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
16 | 16 | ||
17 | 17 | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
18 | 18 | ||
19 | 19 | let assetIdBytes = if ((assetIdString == "WAVES")) | |
20 | 20 | then unit | |
21 | 21 | else fromBase58String(assetIdString) | |
22 | 22 | ||
23 | 23 | let keyAdminList = makeString(["%s", "adminList"], SEP) | |
24 | 24 | ||
25 | 25 | let adminList = match getString(this, keyAdminList) { | |
26 | 26 | case s: String => | |
27 | 27 | split(s, SEP) | |
28 | 28 | case _ => | |
29 | 29 | nil | |
30 | 30 | } | |
31 | 31 | ||
32 | 32 | func isValidAddressString (addressString) = match addressFromString(addressString) { | |
33 | 33 | case a: Address => | |
34 | 34 | true | |
35 | 35 | case _ => | |
36 | 36 | false | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func keyUserVesting (userAddress,id) = { | |
41 | 41 | let checks = [if (isValidAddressString(userAddress)) | |
42 | 42 | then true | |
43 | 43 | else throwErr(makeString(["address is not valid:", userAddress], " ")), if (if ((id >= 0)) | |
44 | 44 | then (MAX_VESTING_COUNT > id) | |
45 | 45 | else false) | |
46 | 46 | then true | |
47 | 47 | else throwErr(makeString(["id should be less than", toString(MAX_VESTING_COUNT), "got:", toString(id)], " "))] | |
48 | 48 | if ((checks == checks)) | |
49 | 49 | then makeString(["%s%d", userAddress, toString(id)], SEP) | |
50 | 50 | else throw("Strict value is not equal to itself.") | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func formatUserVesting (vestingAmount,startBlock,lockLength) = { | |
55 | 55 | let checks = [if ((vestingAmount >= 0)) | |
56 | 56 | then true | |
57 | 57 | else throwErr("vesting amount cannot be negative"), if ((startBlock >= 0)) | |
58 | 58 | then true | |
59 | 59 | else throwErr("start block cannot be negative"), if ((lockLength >= 0)) | |
60 | 60 | then true | |
61 | 61 | else throwErr("lock length cannot be negative")] | |
62 | 62 | if ((checks == checks)) | |
63 | 63 | then makeString(["%d%d%d%d%d", toString(vestingAmount), toString(startBlock), toString(lockLength)], SEP) | |
64 | 64 | else throw("Strict value is not equal to itself.") | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func parseUserVesting (userAddress,id) = match getString(this, keyUserVesting(userAddress, id)) { | |
69 | 69 | case rawString: String => | |
70 | 70 | let splitString = split(rawString, SEP) | |
71 | 71 | let vestingAmount = parseIntValue(splitString[1]) | |
72 | 72 | let startBlock = parseIntValue(splitString[2]) | |
73 | 73 | let lockLength = parseIntValue(splitString[3]) | |
74 | 74 | $Tuple3(vestingAmount, startBlock, lockLength) | |
75 | 75 | case _ => | |
76 | 76 | $Tuple3(0, 0, 0) | |
77 | 77 | } | |
78 | 78 | ||
79 | 79 | ||
80 | 80 | func keyVestingHistory (action,userAddress,txId) = makeString(["%s%s%s", action, userAddress, txId], SEP) | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | func calcUnlockedAmount (amount,startBlock,lockLength) = { | |
84 | 84 | let elapsedBlocks = (height - startBlock) | |
85 | 85 | let unlockedAmount = if (if ((lockLength != 0)) | |
86 | 86 | then (elapsedBlocks > 0) | |
87 | 87 | else false) | |
88 | 88 | then min([fraction(amount, elapsedBlocks, lockLength), amount]) | |
89 | 89 | else 0 | |
90 | 90 | $Tuple2(unlockedAmount, (amount - unlockedAmount)) | |
91 | 91 | } | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func getUserUnlockedAmount (userAddress,id) = { | |
95 | 95 | let $t027472826 = parseUserVesting(userAddress, id) | |
96 | 96 | let vestingAmount = $t027472826._1 | |
97 | 97 | let startBlock = $t027472826._2 | |
98 | 98 | let lockLength = $t027472826._3 | |
99 | 99 | let $t028292926 = calcUnlockedAmount(vestingAmount, startBlock, lockLength) | |
100 | 100 | let unlockedAmount = $t028292926._1 | |
101 | 101 | let remainingAmount = $t028292926._2 | |
102 | 102 | $Tuple2(unlockedAmount, remainingAmount) | |
103 | 103 | } | |
104 | 104 | ||
105 | 105 | ||
106 | 106 | func getUserClaimActions (userAddress,id) = { | |
107 | 107 | let $t030293108 = parseUserVesting(userAddress, id) | |
108 | 108 | let vestingAmount = $t030293108._1 | |
109 | 109 | let startBlock = $t030293108._2 | |
110 | 110 | let lockLength = $t030293108._3 | |
111 | 111 | let $t031113189 = getUserUnlockedAmount(userAddress, id) | |
112 | 112 | let unlockedAmount = $t031113189._1 | |
113 | 113 | let remainingAmount = $t031113189._2 | |
114 | 114 | let remainingBlocks = max([((startBlock + lockLength) - height), 0]) | |
115 | 115 | let actions = if ((unlockedAmount != 0)) | |
116 | 116 | then [ScriptTransfer(addressFromStringValue(userAddress), unlockedAmount, assetIdBytes), StringEntry(keyUserVesting(userAddress, id), formatUserVesting(remainingAmount, height, remainingBlocks))] | |
117 | 117 | else nil | |
118 | 118 | $Tuple2(actions, unlockedAmount) | |
119 | 119 | } | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | func getNewVestingActions (userAddress,id,vestingAmount,startBlock,lockLength) = [StringEntry(keyUserVesting(userAddress, id), formatUserVesting(vestingAmount, startBlock, lockLength))] | |
123 | 123 | ||
124 | 124 | ||
125 | 125 | func getAllUserClaimActions (userAddress) = { | |
126 | 126 | func actionsHelper (acc,a) = { | |
127 | 127 | let $t039483975 = acc | |
128 | 128 | let allActions = $t039483975._1 | |
129 | 129 | let sum = $t039483975._2 | |
130 | 130 | let $t039804049 = getUserClaimActions(userAddress, a) | |
131 | 131 | let claimActions = $t039804049._1 | |
132 | 132 | let claimAmount = $t039804049._2 | |
133 | 133 | $Tuple2((allActions ++ claimActions), (sum + claimAmount)) | |
134 | 134 | } | |
135 | 135 | ||
136 | 136 | let $l = IDS_LIST | |
137 | 137 | let $s = size($l) | |
138 | 138 | let $acc0 = $Tuple2(nil, 0) | |
139 | 139 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
140 | 140 | then $a | |
141 | 141 | else actionsHelper($a, $l[$i]) | |
142 | 142 | ||
143 | 143 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
144 | 144 | then $a | |
145 | 145 | else throw("List size exceeds 30") | |
146 | 146 | ||
147 | 147 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
148 | 148 | } | |
149 | 149 | ||
150 | 150 | ||
151 | 151 | func getAvailableVestingId (userAddress) = { | |
152 | 152 | func helper (availableId,id) = { | |
153 | 153 | let $t042574336 = parseUserVesting(userAddress, id) | |
154 | 154 | let vestingAmount = $t042574336._1 | |
155 | 155 | let startBlock = $t042574336._2 | |
156 | 156 | let lockLength = $t042574336._3 | |
157 | 157 | if ((vestingAmount > 0)) | |
158 | 158 | then availableId | |
159 | 159 | else if ((availableId == -1)) | |
160 | 160 | then id | |
161 | 161 | else min([availableId, id]) | |
162 | 162 | } | |
163 | 163 | ||
164 | 164 | let availableId = { | |
165 | 165 | let $l = IDS_LIST | |
166 | 166 | let $s = size($l) | |
167 | 167 | let $acc0 = -1 | |
168 | 168 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
169 | 169 | then $a | |
170 | 170 | else helper($a, $l[$i]) | |
171 | 171 | ||
172 | 172 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
173 | 173 | then $a | |
174 | 174 | else throw("List size exceeds 30") | |
175 | 175 | ||
176 | 176 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
177 | 177 | } | |
178 | 178 | if ((availableId == -1)) | |
179 | 179 | then throwErr(makeString(["user exceeded max active vesting count: ", userAddress], " ")) | |
180 | 180 | else availableId | |
181 | 181 | } | |
182 | 182 | ||
183 | 183 | ||
184 | 184 | @Callable(i) | |
185 | 185 | func vestingForUser (userAddress,vestingAmount,startBlock,lockLength) = { | |
186 | 186 | let check = [if ((size(i.payments) == 1)) | |
187 | 187 | then true | |
188 | 188 | else throwErr("should be with exactly 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
189 | 189 | then true | |
190 | 190 | else throwErr(makeString(["payment assetId should be: ", assetIdString], " ")), if ((i.payments[0].amount == vestingAmount)) | |
191 | 191 | then true | |
192 | 192 | else throwErr("payment amount should be equal to vestingAmount"), if (if ((adminList == nil)) | |
193 | 193 | then true | |
194 | 194 | else containsElement(adminList, toString(i.caller))) | |
195 | 195 | then true | |
196 | 196 | else throwErr("you must be admin")] | |
197 | 197 | if ((check == check)) | |
198 | 198 | then { | |
199 | 199 | let id = getAvailableVestingId(userAddress) | |
200 | 200 | let historyActions = [IntegerEntry(keyVestingHistory("vested", userAddress, toBase58String(i.transactionId)), vestingAmount)] | |
201 | 201 | (getNewVestingActions(userAddress, id, vestingAmount, startBlock, lockLength) ++ historyActions) | |
202 | 202 | } | |
203 | 203 | else throw("Strict value is not equal to itself.") | |
204 | 204 | } | |
205 | 205 | ||
206 | 206 | ||
207 | 207 | ||
208 | 208 | @Callable(i) | |
209 | 209 | func claimAll () = { | |
210 | 210 | let userAddress = toString(i.caller) | |
211 | 211 | let $t055815650 = getAllUserClaimActions(userAddress) | |
212 | 212 | let claimActions = $t055815650._1 | |
213 | 213 | let totalAmount = $t055815650._2 | |
214 | 214 | let historyActions = [IntegerEntry(keyVestingHistory("claimed", userAddress, toBase58String(i.transactionId)), totalAmount)] | |
215 | - | (claimActions ++ historyActions) | |
215 | + | if ((totalAmount > 0)) | |
216 | + | then (claimActions ++ historyActions) | |
217 | + | else throwErr("nothing to claim") | |
216 | 218 | } | |
217 | 219 | ||
218 | 220 |
github/deemru/w8io/026f985 29.45 ms ◑