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