tx · F85abB5RAhaDewZHwtxKQE7YZRptbphgTcgBMJcqZbKX 3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh: -0.01300000 Waves 2022.10.27 10:05 [2290508] smart account 3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh > SELF 0.00000000 Waves
{ "type": 13, "id": "F85abB5RAhaDewZHwtxKQE7YZRptbphgTcgBMJcqZbKX", "fee": 1300000, "feeAssetId": null, "timestamp": 1666854343339, "version": 1, "sender": "3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh", "senderPublicKey": "33fpjdpM9FMu87RZKePniPardKqQXM96sm7VhAk3JEVQ", "proofs": [ "HeedSysnoanmvtsM3AQSaH2r1y65mVTeC7rZN9oNWBDNQiCjp9ok45CZegarpMyhZnnkG6vqVmtELyyd516fttH" ], "script": "base64:BgL3CwgCEgYKBAgICAgSBgoECAgIAhIFCgMICAQSBgoECAgBARIDCgEIEgQKAggIEgMKAQgSACIJc2VwYXJhdG9yIhNrZXlCYWNrZW5kUHVibGljS2V5IhtrZXlFeGlzdHNSZWZlcnJlclRvUmVmZXJyYWwiC3Byb2dyYW1OYW1lIg9yZWZlcnJlckFkZHJlc3MiD3JlZmVycmFsQWRkcmVzcyISa2V5Q2xhaW1lZFJlZmVycmVyIg5jbGFpbWVyQWRkcmVzcyISa2V5Q2xhaW1lZFJlZmVycmFsIhRrZXlVbmNsYWltZWRSZWZlcnJlciIUa2V5VW5jbGFpbWVkUmVmZXJyYWwiC2tleVJlZmVycmVyIg5rZXlQcm9ncmFtTmFtZSIVa2V5VG90YWxSZWZlcnJhbENvdW50IhZrZXlBY3RpdmVSZWZlcnJhbENvdW50IhNrZXlJc1JlZmVycmFsQWN0aXZlIg9rZXlDbGFpbWVkVG90YWwiD2tleVJld2FyZHNUb3RhbCIQa2V5UmV3YXJkQXNzZXRJZCITa2V5VHJlYXN1cnlDb250cmFjdCIZa2V5SW1wbGVtZW50YXRpb25Db250cmFjdCITa2V5TWFuY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MJAAACBQJhSwUCYUsJAMwIAgkBC1N0cmluZ0VudHJ5AgkBAXYACQDYBAEJAQV2YWx1ZQEFAmFJCQDMCAIJAQtEZWxldGVFbnRyeQEJAQF3AAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJhTAECYU0ABAJhTgQBRwkBAUYAAwkAAQIFAUcCCkJ5dGVWZWN0b3IEAU0FAUcFAU0DCQABAgUBRwIEVW5pdAgFAmFMD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJhTAlib2R5Qnl0ZXMJAJEDAggFAmFMBnByb29mcwAABQJhTsEbkhc=", "chainId": 84, "height": 2290508, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FVGFexPdz6tRJnWb5YCRvfP7Y9Fnhw1fzA5DhEQq8deA Next: 9WA53dYhMo8abNYSBSwUrCkdBbMjbk8LkVPrdeeGrnYK Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | - | ||
6 | - | func keyWxAssetId () = makeString(["%s", "wxAssetId"], separator) | |
7 | - | ||
8 | 5 | ||
9 | 6 | let keyBackendPublicKey = makeString(["%s", "backendPublicKey"], separator) | |
10 | 7 | ||
11 | 8 | func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator) | |
12 | 9 | ||
13 | 10 | ||
14 | - | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
11 | + | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
15 | 12 | ||
16 | 13 | ||
17 | - | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
14 | + | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
18 | 15 | ||
19 | 16 | ||
20 | - | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
17 | + | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
21 | 18 | ||
22 | 19 | ||
23 | - | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
20 | + | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
24 | 21 | ||
25 | 22 | ||
26 | 23 | func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator) | |
38 | 35 | func keyIsReferralActive (programName,referralAddress) = makeString(["%s%s%s", "activeReferral", programName, referralAddress], separator) | |
39 | 36 | ||
40 | 37 | ||
41 | - | func keyClaimedTotalAddress (address) = makeString(["%s%s", "claimedTotalAddress", address], separator) | |
42 | - | ||
43 | - | ||
44 | - | func keyUnclaimedTotalAddress (address) = makeString(["%s%s", "unclaimedTotalAddress", address], separator) | |
45 | - | ||
46 | - | ||
47 | 38 | func keyClaimedTotal (programName) = makeString(["%s%s", "claimedTotal", programName], separator) | |
48 | 39 | ||
49 | 40 | ||
57 | 48 | ||
58 | 49 | ||
59 | 50 | func keyImplementationContract (programName) = makeString(["%s%s", "implementationContract", programName], separator) | |
60 | - | ||
61 | - | ||
62 | - | func keyAllReferralPrograms (address) = makeString(["%s%s", "allReferralPrograms", address], separator) | |
63 | - | ||
64 | - | ||
65 | - | func keyLastIncUnclaimedWithPaymentCallBlock (address) = makeString(["%s%s", "lastIncUnclaimedWithPaymentCallBlock", address], separator) | |
66 | 51 | ||
67 | 52 | ||
68 | 53 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
115 | 100 | throw("Match error") | |
116 | 101 | } | |
117 | 102 | } | |
118 | - | ||
119 | - | ||
120 | - | func updateAllReferralPrograms (address,programName) = { | |
121 | - | let allReferralPrograms = valueOrElse(getString(keyAllReferralPrograms(address)), "") | |
122 | - | let updatedAllReferralPrograms = if (contains(allReferralPrograms, programName)) | |
123 | - | then nil | |
124 | - | else { | |
125 | - | let newAllReferralPrograms = if ((allReferralPrograms == "")) | |
126 | - | then programName | |
127 | - | else makeString([allReferralPrograms, programName], separator) | |
128 | - | [StringEntry(keyAllReferralPrograms(address), newAllReferralPrograms)] | |
129 | - | } | |
130 | - | updatedAllReferralPrograms | |
131 | - | } | |
132 | - | ||
133 | - | ||
134 | - | @Callable(i) | |
135 | - | func claimInternal (programName,claimerAddress,isImplementationContract) = { | |
136 | - | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
137 | - | then true | |
138 | - | else throwErr("program does not exist") | |
139 | - | if ((checkProgramExists == checkProgramExists)) | |
140 | - | then { | |
141 | - | let $t048215758 = if (isImplementationContract) | |
142 | - | then $Tuple5(valueOrElse(getInteger(keyClaimedReferral(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, claimerAddress)), 0), keyClaimedReferral(programName, claimerAddress), keyUnclaimedReferral(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferral")) | |
143 | - | else $Tuple5(valueOrElse(getInteger(keyClaimedReferrer(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimerAddress)), 0), keyClaimedReferrer(programName, claimerAddress), keyUnclaimedReferrer(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferrer")) | |
144 | - | let claimerClaimed = $t048215758._1 | |
145 | - | let claimerUnclaimed = $t048215758._2 | |
146 | - | let keyClaimed = $t048215758._3 | |
147 | - | let keyUnclaimed = $t048215758._4 | |
148 | - | let claimHistoryKey = $t048215758._5 | |
149 | - | let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0) | |
150 | - | let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName))))) | |
151 | - | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
152 | - | let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimerAddress)), 0) | |
153 | - | let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimerAddress)), 0) | |
154 | - | if (if (isImplementationContract) | |
155 | - | then (claimerUnclaimed == 0) | |
156 | - | else false) | |
157 | - | then $Tuple2(nil, 0) | |
158 | - | else { | |
159 | - | let checkCanClaim = if ((claimerUnclaimed > 0)) | |
160 | - | then true | |
161 | - | else throwErr("nothing to claim") | |
162 | - | if ((checkCanClaim == checkCanClaim)) | |
163 | - | then { | |
164 | - | let newClaimerClaimed = (claimerClaimed + claimerUnclaimed) | |
165 | - | let newClaimedTotal = (claimedTotal + claimerUnclaimed) | |
166 | - | let newClaimedTotalAddress = (claimedTotalAddress + claimerUnclaimed) | |
167 | - | let newUnclaimedTotalAddress = (unclaimedTotalAddress - claimerUnclaimed) | |
168 | - | let balanceBefore = value(assetBalance(this, rewardAssetId)) | |
169 | - | if ((balanceBefore == balanceBefore)) | |
170 | - | then { | |
171 | - | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
172 | - | if ((res == res)) | |
173 | - | then { | |
174 | - | let balanceAfter = value(assetBalance(this, rewardAssetId)) | |
175 | - | if ((balanceAfter == balanceAfter)) | |
176 | - | then { | |
177 | - | let balanceDiff = (balanceAfter - balanceBefore) | |
178 | - | if ((balanceDiff == balanceDiff)) | |
179 | - | then { | |
180 | - | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
181 | - | then true | |
182 | - | else throwErr("insufficient balance on referral contract") | |
183 | - | if ((checkBalance == checkBalance)) | |
184 | - | then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyUnclaimed, 0), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyClaimedTotalAddress(claimerAddress), newClaimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(claimerAddress), newUnclaimedTotalAddress), ScriptTransfer(addressFromStringValue(claimerAddress), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed) | |
185 | - | else throw("Strict value is not equal to itself.") | |
186 | - | } | |
187 | - | else throw("Strict value is not equal to itself.") | |
188 | - | } | |
189 | - | else throw("Strict value is not equal to itself.") | |
190 | - | } | |
191 | - | else throw("Strict value is not equal to itself.") | |
192 | - | } | |
193 | - | else throw("Strict value is not equal to itself.") | |
194 | - | } | |
195 | - | else throw("Strict value is not equal to itself.") | |
196 | - | } | |
197 | - | } | |
198 | - | else throw("Strict value is not equal to itself.") | |
199 | - | } | |
200 | - | ||
201 | - | ||
202 | - | ||
203 | - | @Callable(i) | |
204 | - | func claimBulkInternal (claimer,programNames,currentIter) = { | |
205 | - | let checkCaller = if ((i.caller == this)) | |
206 | - | then true | |
207 | - | else throwErr("permission denied") | |
208 | - | if ((checkCaller == checkCaller)) | |
209 | - | then if ((currentIter == size(programNames))) | |
210 | - | then nil | |
211 | - | else { | |
212 | - | let programName = programNames[currentIter] | |
213 | - | let programUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0) | |
214 | - | let claimHistoryKey = keyClaimHistory(programName, claimer, toBase58String(i.transactionId), "claimBulk") | |
215 | - | let claimBulkInternal = invoke(this, "claimBulkInternal", [claimer, programNames, (currentIter + 1)], nil) | |
216 | - | if ((claimBulkInternal == claimBulkInternal)) | |
217 | - | then { | |
218 | - | let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0) | |
219 | - | let claim = if ((unclaimedReferrer > 0)) | |
220 | - | then invoke(this, "claimInternal", [programName, claimer, false], nil) | |
221 | - | else unit | |
222 | - | if ((claim == claim)) | |
223 | - | then $Tuple2(nil, [claimBulkInternal, claim]) | |
224 | - | else throw("Strict value is not equal to itself.") | |
225 | - | } | |
226 | - | else throw("Strict value is not equal to itself.") | |
227 | - | } | |
228 | - | else throw("Strict value is not equal to itself.") | |
229 | - | } | |
230 | - | ||
231 | - | ||
232 | - | ||
233 | - | @Callable(i) | |
234 | - | func incUnclaimedWithPaymentInternal (paymentAmounts,programName,referrerAddresses,currentIter,resAmount) = { | |
235 | - | let checkCaller = if ((i.caller == this)) | |
236 | - | then true | |
237 | - | else throwErr("permission denied") | |
238 | - | if ((checkCaller == checkCaller)) | |
239 | - | then { | |
240 | - | let argsComparison = (size(paymentAmounts) == size(referrerAddresses)) | |
241 | - | let check = if (argsComparison) | |
242 | - | then true | |
243 | - | else throwErr("lists in args must be same size") | |
244 | - | if ((check == check)) | |
245 | - | then if ((currentIter == size(paymentAmounts))) | |
246 | - | then $Tuple2(nil, resAmount) | |
247 | - | else { | |
248 | - | let referrerAddress = referrerAddresses[currentIter] | |
249 | - | let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0) | |
250 | - | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
251 | - | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
252 | - | let newUnclaimedTotalAddress = (unclaimedTotalAddress + paymentAmounts[currentIter]) | |
253 | - | let newReferrerUnclaimed = (referrerUnclaimed + paymentAmounts[currentIter]) | |
254 | - | let newResAmount = (resAmount + paymentAmounts[currentIter]) | |
255 | - | let inv = invoke(this, "incUnclaimedWithPaymentInternal", [paymentAmounts, programName, referrerAddresses, (currentIter + 1), newResAmount], nil) | |
256 | - | if ((inv == inv)) | |
257 | - | then { | |
258 | - | let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName) | |
259 | - | $Tuple2(([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalAddress), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyRewardsTotal(programName), (rewardsTotal + paymentAmounts[currentIter]))] ++ updatedAllReferrerPrograms), inv) | |
260 | - | } | |
261 | - | else throw("Strict value is not equal to itself.") | |
262 | - | } | |
263 | - | else throw("Strict value is not equal to itself.") | |
264 | - | } | |
265 | - | else throw("Strict value is not equal to itself.") | |
266 | - | } | |
267 | - | ||
268 | 103 | ||
269 | 104 | ||
270 | 105 | @Callable(i) | |
327 | 162 | then { | |
328 | 163 | let totalReferralCount = valueOrElse(getInteger(keyTotalReferralCount(programName, referrerAddress)), 0) | |
329 | 164 | let newTotalReferralCount = (totalReferralCount + 1) | |
330 | - | let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName) | |
331 | - | let updatedAllReferralPrograms = updateAllReferralPrograms(referralAddress, programName) | |
332 | - | $Tuple2((([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)] ++ updatedAllReferrerPrograms) ++ updatedAllReferralPrograms), unit) | |
165 | + | $Tuple2([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)], unit) | |
333 | 166 | } | |
334 | 167 | else throw("Strict value is not equal to itself.") | |
335 | 168 | } | |
376 | 209 | @Callable(i) | |
377 | 210 | func incUnclaimed (programName,referralAddress,referrerReward,referralReward) = { | |
378 | 211 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
379 | - | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
380 | 212 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
381 | 213 | then true | |
382 | 214 | else throwErr("permission denied") | |
383 | 215 | if ((checkCaller == checkCaller)) | |
384 | 216 | then { | |
385 | - | let checkProgram = if ((programName == "wxlock")) | |
386 | - | then true | |
387 | - | else throwErr("invalid program") | |
388 | - | if ((checkProgram == checkProgram)) | |
389 | - | then { | |
390 | - | let checkReferrerInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referrerAddress)), ""), programName)) | |
391 | - | then true | |
392 | - | else throwErr("referrer not in program") | |
393 | - | if ((checkReferrerInProgram == checkReferrerInProgram)) | |
394 | - | then { | |
395 | - | let checkReferralInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referralAddress)), ""), programName)) | |
396 | - | then true | |
397 | - | else throwErr("referral not in program") | |
398 | - | if ((checkReferralInProgram == checkReferralInProgram)) | |
399 | - | then { | |
400 | - | let unclaimedTotalReferrer = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0) | |
401 | - | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
402 | - | let unclaimedTotalReferral = valueOrElse(getInteger(keyUnclaimedTotalAddress(referralAddress)), 0) | |
403 | - | let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0) | |
404 | - | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
405 | - | let newUnclaimedTotalReferrer = (unclaimedTotalReferrer + referrerReward) | |
406 | - | let newReferrerUnclaimed = (referrerUnclaimed + referrerReward) | |
407 | - | let newUnclaimedTotalReferral = (unclaimedTotalReferral + referralReward) | |
408 | - | let newReferralUnclaimed = (referralUnclaimed + referralReward) | |
409 | - | $Tuple2([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalReferrer), IntegerEntry(keyUnclaimedTotalAddress(referralAddress), newUnclaimedTotalReferral), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit) | |
410 | - | } | |
411 | - | else throw("Strict value is not equal to itself.") | |
412 | - | } | |
413 | - | else throw("Strict value is not equal to itself.") | |
414 | - | } | |
415 | - | else throw("Strict value is not equal to itself.") | |
416 | - | } | |
417 | - | else throw("Strict value is not equal to itself.") | |
418 | - | } | |
419 | - | ||
420 | - | ||
421 | - | ||
422 | - | @Callable(i) | |
423 | - | func incUnclaimedWithPayment (programName,referrerAddresses) = { | |
424 | - | let checkProgram = if ((programName == "wxSpotFee")) | |
425 | - | then true | |
426 | - | else throwErr("invalid program") | |
427 | - | if ((checkProgram == checkProgram)) | |
428 | - | then { | |
429 | - | let callerAddress = toString(i.caller) | |
430 | - | let lastCall = valueOrElse(getInteger(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress)), 0) | |
431 | - | let waitBlocks = ((lastCall - height) + 3) | |
432 | - | let lastCallCheck = if (((height - 3) > lastCall)) | |
433 | - | then true | |
434 | - | else throwErr(makeString(["wait", toString(waitBlocks), "blocks"], " ")) | |
435 | - | if ((lastCallCheck == lastCallCheck)) | |
436 | - | then { | |
437 | - | func map (accum,next) = { | |
438 | - | let assetIdCheck = (toBase58String(value(next.assetId)) == value(getString(keyRewardAssetId(programName)))) | |
439 | - | let amountCheck = if (assetIdCheck) | |
440 | - | then true | |
441 | - | else throwErr("invalid asset id") | |
442 | - | if ((amountCheck == amountCheck)) | |
443 | - | then (accum :+ next.amount) | |
444 | - | else throw("Strict value is not equal to itself.") | |
445 | - | } | |
446 | - | ||
447 | - | let payments = { | |
448 | - | let $l = i.payments | |
449 | - | let $s = size($l) | |
450 | - | let $acc0 = nil | |
451 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
452 | - | then $a | |
453 | - | else map($a, $l[$i]) | |
454 | - | ||
455 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
456 | - | then $a | |
457 | - | else throw("List size exceeds 10") | |
458 | - | ||
459 | - | $f0_2($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) | |
460 | - | } | |
461 | - | let resAmount = { | |
462 | - | let @ = invoke(this, "incUnclaimedWithPaymentInternal", [payments, programName, referrerAddresses, 0, 0], nil) | |
463 | - | if ($isInstanceOf(@, "Int")) | |
464 | - | then @ | |
465 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
466 | - | } | |
467 | - | if ((resAmount == resAmount)) | |
468 | - | then { | |
469 | - | let treasuryContract = addressFromStringValue(value(getString(keyTreasuryContract(programName)))) | |
470 | - | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
471 | - | [ScriptTransfer(treasuryContract, resAmount, rewardAssetId), IntegerEntry(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress), height)] | |
472 | - | } | |
473 | - | else throw("Strict value is not equal to itself.") | |
474 | - | } | |
475 | - | else throw("Strict value is not equal to itself.") | |
217 | + | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
218 | + | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
219 | + | let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0) | |
220 | + | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
221 | + | let newReferrerUnclaimed = (referrerUnclaimed + referrerReward) | |
222 | + | let newReferralUnclaimed = (referralUnclaimed + referralReward) | |
223 | + | $Tuple2([IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit) | |
476 | 224 | } | |
477 | 225 | else throw("Strict value is not equal to itself.") | |
478 | 226 | } | |
487 | 235 | if ((checkProgramExists == checkProgramExists)) | |
488 | 236 | then { | |
489 | 237 | let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName)))) | |
490 | - | let claimerAddress = if (isImplementationContract) | |
491 | - | then toString(i.originCaller) | |
492 | - | else toString(i.caller) | |
493 | - | let claimInternal = invoke(this, "claimInternal", [programName, claimerAddress, isImplementationContract], nil) | |
494 | - | if ((claimInternal == claimInternal)) | |
495 | - | then $Tuple2(nil, claimInternal) | |
496 | - | else throw("Strict value is not equal to itself.") | |
497 | - | } | |
498 | - | else throw("Strict value is not equal to itself.") | |
499 | - | } | |
500 | - | ||
501 | - | ||
502 | - | ||
503 | - | @Callable(i) | |
504 | - | func claimBulk () = { | |
505 | - | let callerAddress = toString(i.caller) | |
506 | - | let callerProgramsStr = getString(keyAllReferralPrograms(toString(i.caller))) | |
507 | - | let programsExists = if (isDefined(callerProgramsStr)) | |
508 | - | then true | |
509 | - | else throwErr("no referral programs") | |
510 | - | if ((programsExists == programsExists)) | |
511 | - | then { | |
512 | - | let callerPrograms = split(value(callerProgramsStr), "__") | |
513 | - | let bulkClaim = invoke(this, "claimBulkInternal", [callerAddress, callerPrograms, 0], nil) | |
514 | - | if ((bulkClaim == bulkClaim)) | |
515 | - | then $Tuple2(nil, bulkClaim) | |
516 | - | else throw("Strict value is not equal to itself.") | |
238 | + | let $t084179346 = if (isImplementationContract) | |
239 | + | then { | |
240 | + | let user = toString(i.originCaller) | |
241 | + | $Tuple6(user, valueOrElse(getInteger(keyClaimedReferral(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferral")) | |
242 | + | } | |
243 | + | else { | |
244 | + | let user = toString(i.caller) | |
245 | + | $Tuple6(user, valueOrElse(getInteger(keyClaimedReferrer(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, user)), 0), keyClaimedReferrer(programName, user), keyUnclaimedReferrer(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferrer")) | |
246 | + | } | |
247 | + | let userAddressStr = $t084179346._1 | |
248 | + | let claimerClaimed = $t084179346._2 | |
249 | + | let claimerUnclaimed = $t084179346._3 | |
250 | + | let keyClaimed = $t084179346._4 | |
251 | + | let keyUnclaimed = $t084179346._5 | |
252 | + | let claimHistoryKey = $t084179346._6 | |
253 | + | let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0) | |
254 | + | let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName))))) | |
255 | + | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
256 | + | if (if (isImplementationContract) | |
257 | + | then (claimerUnclaimed == 0) | |
258 | + | else false) | |
259 | + | then $Tuple2(nil, 0) | |
260 | + | else { | |
261 | + | let checkCanClaim = if ((claimerUnclaimed > 0)) | |
262 | + | then true | |
263 | + | else throwErr("nothing to claim") | |
264 | + | if ((checkCanClaim == checkCanClaim)) | |
265 | + | then { | |
266 | + | let newClaimerClaimed = (claimerClaimed + claimerUnclaimed) | |
267 | + | let newClaimedTotal = (claimedTotal + claimerUnclaimed) | |
268 | + | let balanceBefore = value(assetBalance(this, rewardAssetId)) | |
269 | + | if ((balanceBefore == balanceBefore)) | |
270 | + | then { | |
271 | + | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
272 | + | if ((res == res)) | |
273 | + | then { | |
274 | + | let balanceAfter = value(assetBalance(this, rewardAssetId)) | |
275 | + | if ((balanceAfter == balanceAfter)) | |
276 | + | then { | |
277 | + | let balanceDiff = (balanceAfter - balanceBefore) | |
278 | + | if ((balanceDiff == balanceDiff)) | |
279 | + | then { | |
280 | + | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
281 | + | then true | |
282 | + | else throwErr("insufficient balance on referral contract") | |
283 | + | if ((checkBalance == checkBalance)) | |
284 | + | then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed, 0), ScriptTransfer(addressFromStringValue(userAddressStr), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed) | |
285 | + | else throw("Strict value is not equal to itself.") | |
286 | + | } | |
287 | + | else throw("Strict value is not equal to itself.") | |
288 | + | } | |
289 | + | else throw("Strict value is not equal to itself.") | |
290 | + | } | |
291 | + | else throw("Strict value is not equal to itself.") | |
292 | + | } | |
293 | + | else throw("Strict value is not equal to itself.") | |
294 | + | } | |
295 | + | else throw("Strict value is not equal to itself.") | |
296 | + | } | |
517 | 297 | } | |
518 | 298 | else throw("Strict value is not equal to itself.") | |
519 | 299 | } | |
525 | 305 | let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0) | |
526 | 306 | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0) | |
527 | 307 | $Tuple2(nil, [claimerUnclaimed, claimerClaimed]) | |
528 | - | } | |
529 | - | ||
530 | - | ||
531 | - | ||
532 | - | @Callable(i) | |
533 | - | func claimBulkREADONLY (claimer) = { | |
534 | - | let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimer)), 0) | |
535 | - | let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimer)), 0) | |
536 | - | $Tuple2(nil, [unclaimedTotalAddress, claimedTotalAddress]) | |
537 | - | } | |
538 | - | ||
539 | - | ||
540 | - | ||
541 | - | @Callable(i) | |
542 | - | func setTotalKeys (programName,address) = { | |
543 | - | let claimedReferrer = valueOrElse(getInteger(keyClaimedReferrer(programName, address)), 0) | |
544 | - | let claimedReferral = valueOrElse(getInteger(keyClaimedReferral(programName, address)), 0) | |
545 | - | let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, address)), 0) | |
546 | - | let unclaimedReferral = valueOrElse(getInteger(keyUnclaimedReferral(programName, address)), 0) | |
547 | - | let claimedTotalAddress = (claimedReferrer + claimedReferral) | |
548 | - | let unclaimedTotalAddress = (unclaimedReferrer + unclaimedReferral) | |
549 | - | $Tuple2([IntegerEntry(keyClaimedTotalAddress(address), claimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(address), unclaimedTotalAddress)], unit) | |
550 | 308 | } | |
551 | 309 | ||
552 | 310 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | - | ||
6 | - | func keyWxAssetId () = makeString(["%s", "wxAssetId"], separator) | |
7 | - | ||
8 | 5 | ||
9 | 6 | let keyBackendPublicKey = makeString(["%s", "backendPublicKey"], separator) | |
10 | 7 | ||
11 | 8 | func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator) | |
12 | 9 | ||
13 | 10 | ||
14 | - | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
11 | + | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
15 | 12 | ||
16 | 13 | ||
17 | - | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
14 | + | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
18 | 15 | ||
19 | 16 | ||
20 | - | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
17 | + | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
21 | 18 | ||
22 | 19 | ||
23 | - | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
20 | + | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
24 | 21 | ||
25 | 22 | ||
26 | 23 | func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator) | |
27 | 24 | ||
28 | 25 | ||
29 | 26 | func keyProgramName (programName) = makeString(["%s%s", "programName", programName], separator) | |
30 | 27 | ||
31 | 28 | ||
32 | 29 | func keyTotalReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "totalReferralCount", programName, referrerAddress], separator) | |
33 | 30 | ||
34 | 31 | ||
35 | 32 | func keyActiveReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "activeReferralCount", programName, referrerAddress], separator) | |
36 | 33 | ||
37 | 34 | ||
38 | 35 | func keyIsReferralActive (programName,referralAddress) = makeString(["%s%s%s", "activeReferral", programName, referralAddress], separator) | |
39 | 36 | ||
40 | 37 | ||
41 | - | func keyClaimedTotalAddress (address) = makeString(["%s%s", "claimedTotalAddress", address], separator) | |
42 | - | ||
43 | - | ||
44 | - | func keyUnclaimedTotalAddress (address) = makeString(["%s%s", "unclaimedTotalAddress", address], separator) | |
45 | - | ||
46 | - | ||
47 | 38 | func keyClaimedTotal (programName) = makeString(["%s%s", "claimedTotal", programName], separator) | |
48 | 39 | ||
49 | 40 | ||
50 | 41 | func keyRewardsTotal (programName) = makeString(["%s%s", "rewardsTotal", programName], separator) | |
51 | 42 | ||
52 | 43 | ||
53 | 44 | func keyRewardAssetId (programName) = makeString(["%s%s", "rewardAssetId", programName], separator) | |
54 | 45 | ||
55 | 46 | ||
56 | 47 | func keyTreasuryContract (programName) = makeString(["%s%s", "treasuryContract", programName], separator) | |
57 | 48 | ||
58 | 49 | ||
59 | 50 | func keyImplementationContract (programName) = makeString(["%s%s", "implementationContract", programName], separator) | |
60 | - | ||
61 | - | ||
62 | - | func keyAllReferralPrograms (address) = makeString(["%s%s", "allReferralPrograms", address], separator) | |
63 | - | ||
64 | - | ||
65 | - | func keyLastIncUnclaimedWithPaymentCallBlock (address) = makeString(["%s%s", "lastIncUnclaimedWithPaymentCallBlock", address], separator) | |
66 | 51 | ||
67 | 52 | ||
68 | 53 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
69 | 54 | ||
70 | 55 | ||
71 | 56 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
72 | 57 | ||
73 | 58 | ||
74 | 59 | func keyClaimHistory (programName,userAddress,transactionId,type) = makeString(["%s%s%s%s%s", "history", type, programName, userAddress, transactionId], separator) | |
75 | 60 | ||
76 | 61 | ||
77 | 62 | func formatClaimHistory (amount) = makeString(["%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], separator) | |
78 | 63 | ||
79 | 64 | ||
80 | 65 | func throwErr (msg) = throw(makeString(["referral.ride:", msg], " ")) | |
81 | 66 | ||
82 | 67 | ||
83 | 68 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
84 | 69 | case s: String => | |
85 | 70 | fromBase58String(s) | |
86 | 71 | case _: Unit => | |
87 | 72 | unit | |
88 | 73 | case _ => | |
89 | 74 | throw("Match error") | |
90 | 75 | } | |
91 | 76 | ||
92 | 77 | ||
93 | 78 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
94 | 79 | case s: String => | |
95 | 80 | fromBase58String(s) | |
96 | 81 | case _: Unit => | |
97 | 82 | unit | |
98 | 83 | case _ => | |
99 | 84 | throw("Match error") | |
100 | 85 | } | |
101 | 86 | ||
102 | 87 | ||
103 | 88 | func mustManager (i) = { | |
104 | 89 | let pd = throwErr("permission denied") | |
105 | 90 | match managerPublicKeyOrUnit() { | |
106 | 91 | case pk: ByteVector => | |
107 | 92 | if ((i.callerPublicKey == pk)) | |
108 | 93 | then true | |
109 | 94 | else pd | |
110 | 95 | case _: Unit => | |
111 | 96 | if ((i.caller == this)) | |
112 | 97 | then true | |
113 | 98 | else pd | |
114 | 99 | case _ => | |
115 | 100 | throw("Match error") | |
116 | 101 | } | |
117 | 102 | } | |
118 | - | ||
119 | - | ||
120 | - | func updateAllReferralPrograms (address,programName) = { | |
121 | - | let allReferralPrograms = valueOrElse(getString(keyAllReferralPrograms(address)), "") | |
122 | - | let updatedAllReferralPrograms = if (contains(allReferralPrograms, programName)) | |
123 | - | then nil | |
124 | - | else { | |
125 | - | let newAllReferralPrograms = if ((allReferralPrograms == "")) | |
126 | - | then programName | |
127 | - | else makeString([allReferralPrograms, programName], separator) | |
128 | - | [StringEntry(keyAllReferralPrograms(address), newAllReferralPrograms)] | |
129 | - | } | |
130 | - | updatedAllReferralPrograms | |
131 | - | } | |
132 | - | ||
133 | - | ||
134 | - | @Callable(i) | |
135 | - | func claimInternal (programName,claimerAddress,isImplementationContract) = { | |
136 | - | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
137 | - | then true | |
138 | - | else throwErr("program does not exist") | |
139 | - | if ((checkProgramExists == checkProgramExists)) | |
140 | - | then { | |
141 | - | let $t048215758 = if (isImplementationContract) | |
142 | - | then $Tuple5(valueOrElse(getInteger(keyClaimedReferral(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, claimerAddress)), 0), keyClaimedReferral(programName, claimerAddress), keyUnclaimedReferral(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferral")) | |
143 | - | else $Tuple5(valueOrElse(getInteger(keyClaimedReferrer(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimerAddress)), 0), keyClaimedReferrer(programName, claimerAddress), keyUnclaimedReferrer(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferrer")) | |
144 | - | let claimerClaimed = $t048215758._1 | |
145 | - | let claimerUnclaimed = $t048215758._2 | |
146 | - | let keyClaimed = $t048215758._3 | |
147 | - | let keyUnclaimed = $t048215758._4 | |
148 | - | let claimHistoryKey = $t048215758._5 | |
149 | - | let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0) | |
150 | - | let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName))))) | |
151 | - | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
152 | - | let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimerAddress)), 0) | |
153 | - | let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimerAddress)), 0) | |
154 | - | if (if (isImplementationContract) | |
155 | - | then (claimerUnclaimed == 0) | |
156 | - | else false) | |
157 | - | then $Tuple2(nil, 0) | |
158 | - | else { | |
159 | - | let checkCanClaim = if ((claimerUnclaimed > 0)) | |
160 | - | then true | |
161 | - | else throwErr("nothing to claim") | |
162 | - | if ((checkCanClaim == checkCanClaim)) | |
163 | - | then { | |
164 | - | let newClaimerClaimed = (claimerClaimed + claimerUnclaimed) | |
165 | - | let newClaimedTotal = (claimedTotal + claimerUnclaimed) | |
166 | - | let newClaimedTotalAddress = (claimedTotalAddress + claimerUnclaimed) | |
167 | - | let newUnclaimedTotalAddress = (unclaimedTotalAddress - claimerUnclaimed) | |
168 | - | let balanceBefore = value(assetBalance(this, rewardAssetId)) | |
169 | - | if ((balanceBefore == balanceBefore)) | |
170 | - | then { | |
171 | - | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
172 | - | if ((res == res)) | |
173 | - | then { | |
174 | - | let balanceAfter = value(assetBalance(this, rewardAssetId)) | |
175 | - | if ((balanceAfter == balanceAfter)) | |
176 | - | then { | |
177 | - | let balanceDiff = (balanceAfter - balanceBefore) | |
178 | - | if ((balanceDiff == balanceDiff)) | |
179 | - | then { | |
180 | - | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
181 | - | then true | |
182 | - | else throwErr("insufficient balance on referral contract") | |
183 | - | if ((checkBalance == checkBalance)) | |
184 | - | then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyUnclaimed, 0), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyClaimedTotalAddress(claimerAddress), newClaimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(claimerAddress), newUnclaimedTotalAddress), ScriptTransfer(addressFromStringValue(claimerAddress), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed) | |
185 | - | else throw("Strict value is not equal to itself.") | |
186 | - | } | |
187 | - | else throw("Strict value is not equal to itself.") | |
188 | - | } | |
189 | - | else throw("Strict value is not equal to itself.") | |
190 | - | } | |
191 | - | else throw("Strict value is not equal to itself.") | |
192 | - | } | |
193 | - | else throw("Strict value is not equal to itself.") | |
194 | - | } | |
195 | - | else throw("Strict value is not equal to itself.") | |
196 | - | } | |
197 | - | } | |
198 | - | else throw("Strict value is not equal to itself.") | |
199 | - | } | |
200 | - | ||
201 | - | ||
202 | - | ||
203 | - | @Callable(i) | |
204 | - | func claimBulkInternal (claimer,programNames,currentIter) = { | |
205 | - | let checkCaller = if ((i.caller == this)) | |
206 | - | then true | |
207 | - | else throwErr("permission denied") | |
208 | - | if ((checkCaller == checkCaller)) | |
209 | - | then if ((currentIter == size(programNames))) | |
210 | - | then nil | |
211 | - | else { | |
212 | - | let programName = programNames[currentIter] | |
213 | - | let programUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0) | |
214 | - | let claimHistoryKey = keyClaimHistory(programName, claimer, toBase58String(i.transactionId), "claimBulk") | |
215 | - | let claimBulkInternal = invoke(this, "claimBulkInternal", [claimer, programNames, (currentIter + 1)], nil) | |
216 | - | if ((claimBulkInternal == claimBulkInternal)) | |
217 | - | then { | |
218 | - | let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0) | |
219 | - | let claim = if ((unclaimedReferrer > 0)) | |
220 | - | then invoke(this, "claimInternal", [programName, claimer, false], nil) | |
221 | - | else unit | |
222 | - | if ((claim == claim)) | |
223 | - | then $Tuple2(nil, [claimBulkInternal, claim]) | |
224 | - | else throw("Strict value is not equal to itself.") | |
225 | - | } | |
226 | - | else throw("Strict value is not equal to itself.") | |
227 | - | } | |
228 | - | else throw("Strict value is not equal to itself.") | |
229 | - | } | |
230 | - | ||
231 | - | ||
232 | - | ||
233 | - | @Callable(i) | |
234 | - | func incUnclaimedWithPaymentInternal (paymentAmounts,programName,referrerAddresses,currentIter,resAmount) = { | |
235 | - | let checkCaller = if ((i.caller == this)) | |
236 | - | then true | |
237 | - | else throwErr("permission denied") | |
238 | - | if ((checkCaller == checkCaller)) | |
239 | - | then { | |
240 | - | let argsComparison = (size(paymentAmounts) == size(referrerAddresses)) | |
241 | - | let check = if (argsComparison) | |
242 | - | then true | |
243 | - | else throwErr("lists in args must be same size") | |
244 | - | if ((check == check)) | |
245 | - | then if ((currentIter == size(paymentAmounts))) | |
246 | - | then $Tuple2(nil, resAmount) | |
247 | - | else { | |
248 | - | let referrerAddress = referrerAddresses[currentIter] | |
249 | - | let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0) | |
250 | - | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
251 | - | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
252 | - | let newUnclaimedTotalAddress = (unclaimedTotalAddress + paymentAmounts[currentIter]) | |
253 | - | let newReferrerUnclaimed = (referrerUnclaimed + paymentAmounts[currentIter]) | |
254 | - | let newResAmount = (resAmount + paymentAmounts[currentIter]) | |
255 | - | let inv = invoke(this, "incUnclaimedWithPaymentInternal", [paymentAmounts, programName, referrerAddresses, (currentIter + 1), newResAmount], nil) | |
256 | - | if ((inv == inv)) | |
257 | - | then { | |
258 | - | let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName) | |
259 | - | $Tuple2(([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalAddress), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyRewardsTotal(programName), (rewardsTotal + paymentAmounts[currentIter]))] ++ updatedAllReferrerPrograms), inv) | |
260 | - | } | |
261 | - | else throw("Strict value is not equal to itself.") | |
262 | - | } | |
263 | - | else throw("Strict value is not equal to itself.") | |
264 | - | } | |
265 | - | else throw("Strict value is not equal to itself.") | |
266 | - | } | |
267 | - | ||
268 | 103 | ||
269 | 104 | ||
270 | 105 | @Callable(i) | |
271 | 106 | func createReferralProgram (programName,treasuryContract,implementationContract,rewardAssetId) = { | |
272 | 107 | let checkCaller = mustManager(i) | |
273 | 108 | if ((checkCaller == checkCaller)) | |
274 | 109 | then { | |
275 | 110 | let checkProgramName = if ((getBoolean(keyProgramName(programName)) == unit)) | |
276 | 111 | then true | |
277 | 112 | else throwErr("program name already exists") | |
278 | 113 | if ((checkProgramName == checkProgramName)) | |
279 | 114 | then { | |
280 | 115 | let programNameIsValid = if (!(contains(programName, separator))) | |
281 | 116 | then !(contains(programName, " ")) | |
282 | 117 | else false | |
283 | 118 | let checkProgramExists = if (programNameIsValid) | |
284 | 119 | then true | |
285 | 120 | else throwErr("invalid program name") | |
286 | 121 | if ((checkProgramExists == checkProgramExists)) | |
287 | 122 | then { | |
288 | 123 | let checkRewardAsset = if ((assetInfo(fromBase58String(rewardAssetId)) != unit)) | |
289 | 124 | then true | |
290 | 125 | else throwErr("invalid reward asset id") | |
291 | 126 | if ((checkRewardAsset == checkRewardAsset)) | |
292 | 127 | then $Tuple2([BooleanEntry(keyProgramName(programName), true), StringEntry(keyTreasuryContract(programName), treasuryContract), StringEntry(keyImplementationContract(programName), implementationContract), StringEntry(keyRewardAssetId(programName), rewardAssetId), IntegerEntry(keyRewardsTotal(programName), 0)], unit) | |
293 | 128 | else throw("Strict value is not equal to itself.") | |
294 | 129 | } | |
295 | 130 | else throw("Strict value is not equal to itself.") | |
296 | 131 | } | |
297 | 132 | else throw("Strict value is not equal to itself.") | |
298 | 133 | } | |
299 | 134 | else throw("Strict value is not equal to itself.") | |
300 | 135 | } | |
301 | 136 | ||
302 | 137 | ||
303 | 138 | ||
304 | 139 | @Callable(i) | |
305 | 140 | func createPair (programName,referrerAddress,referralAddress,signature) = { | |
306 | 141 | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
307 | 142 | then true | |
308 | 143 | else throwErr("program does not exist") | |
309 | 144 | if ((checkProgramExists == checkProgramExists)) | |
310 | 145 | then { | |
311 | 146 | let pairReferrerToReferralExistCheck = if ((getBoolean(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress)) == unit)) | |
312 | 147 | then true | |
313 | 148 | else throwErr("pair already exists") | |
314 | 149 | if ((pairReferrerToReferralExistCheck == pairReferrerToReferralExistCheck)) | |
315 | 150 | then { | |
316 | 151 | let noRefSelf = if ((referrerAddress != referralAddress)) | |
317 | 152 | then true | |
318 | 153 | else throwErr("cannot refer to self") | |
319 | 154 | if ((noRefSelf == noRefSelf)) | |
320 | 155 | then { | |
321 | 156 | let pair = toBytes(makeString([programName, referrerAddress, referralAddress], ":")) | |
322 | 157 | let backendPublicKey = fromBase58String(value(getString(keyBackendPublicKey))) | |
323 | 158 | let validateSignature = if (sigVerify(pair, signature, backendPublicKey)) | |
324 | 159 | then true | |
325 | 160 | else throwErr("bad signature") | |
326 | 161 | if ((validateSignature == validateSignature)) | |
327 | 162 | then { | |
328 | 163 | let totalReferralCount = valueOrElse(getInteger(keyTotalReferralCount(programName, referrerAddress)), 0) | |
329 | 164 | let newTotalReferralCount = (totalReferralCount + 1) | |
330 | - | let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName) | |
331 | - | let updatedAllReferralPrograms = updateAllReferralPrograms(referralAddress, programName) | |
332 | - | $Tuple2((([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)] ++ updatedAllReferrerPrograms) ++ updatedAllReferralPrograms), unit) | |
165 | + | $Tuple2([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)], unit) | |
333 | 166 | } | |
334 | 167 | else throw("Strict value is not equal to itself.") | |
335 | 168 | } | |
336 | 169 | else throw("Strict value is not equal to itself.") | |
337 | 170 | } | |
338 | 171 | else throw("Strict value is not equal to itself.") | |
339 | 172 | } | |
340 | 173 | else throw("Strict value is not equal to itself.") | |
341 | 174 | } | |
342 | 175 | ||
343 | 176 | ||
344 | 177 | ||
345 | 178 | @Callable(i) | |
346 | 179 | func updateReferralActivity (programName,referralAddress,isActive) = { | |
347 | 180 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
348 | 181 | let isReferralActive = (getBoolean(keyIsReferralActive(programName, referralAddress)) != unit) | |
349 | 182 | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
350 | 183 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
351 | 184 | then true | |
352 | 185 | else throwErr("permission denied") | |
353 | 186 | if ((checkCaller == checkCaller)) | |
354 | 187 | then { | |
355 | 188 | let update = if ((isReferralActive == isActive)) | |
356 | 189 | then $Tuple2(nil, unit) | |
357 | 190 | else { | |
358 | 191 | let update = if ((isActive == true)) | |
359 | 192 | then { | |
360 | 193 | let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) + 1) | |
361 | 194 | $Tuple2([BooleanEntry(keyIsReferralActive(programName, referralAddress), true), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit) | |
362 | 195 | } | |
363 | 196 | else { | |
364 | 197 | let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) - 1) | |
365 | 198 | $Tuple2([DeleteEntry(keyIsReferralActive(programName, referralAddress)), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit) | |
366 | 199 | } | |
367 | 200 | update | |
368 | 201 | } | |
369 | 202 | update | |
370 | 203 | } | |
371 | 204 | else throw("Strict value is not equal to itself.") | |
372 | 205 | } | |
373 | 206 | ||
374 | 207 | ||
375 | 208 | ||
376 | 209 | @Callable(i) | |
377 | 210 | func incUnclaimed (programName,referralAddress,referrerReward,referralReward) = { | |
378 | 211 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
379 | - | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
380 | 212 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
381 | 213 | then true | |
382 | 214 | else throwErr("permission denied") | |
383 | 215 | if ((checkCaller == checkCaller)) | |
384 | 216 | then { | |
385 | - | let checkProgram = if ((programName == "wxlock")) | |
386 | - | then true | |
387 | - | else throwErr("invalid program") | |
388 | - | if ((checkProgram == checkProgram)) | |
389 | - | then { | |
390 | - | let checkReferrerInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referrerAddress)), ""), programName)) | |
391 | - | then true | |
392 | - | else throwErr("referrer not in program") | |
393 | - | if ((checkReferrerInProgram == checkReferrerInProgram)) | |
394 | - | then { | |
395 | - | let checkReferralInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referralAddress)), ""), programName)) | |
396 | - | then true | |
397 | - | else throwErr("referral not in program") | |
398 | - | if ((checkReferralInProgram == checkReferralInProgram)) | |
399 | - | then { | |
400 | - | let unclaimedTotalReferrer = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0) | |
401 | - | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
402 | - | let unclaimedTotalReferral = valueOrElse(getInteger(keyUnclaimedTotalAddress(referralAddress)), 0) | |
403 | - | let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0) | |
404 | - | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
405 | - | let newUnclaimedTotalReferrer = (unclaimedTotalReferrer + referrerReward) | |
406 | - | let newReferrerUnclaimed = (referrerUnclaimed + referrerReward) | |
407 | - | let newUnclaimedTotalReferral = (unclaimedTotalReferral + referralReward) | |
408 | - | let newReferralUnclaimed = (referralUnclaimed + referralReward) | |
409 | - | $Tuple2([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalReferrer), IntegerEntry(keyUnclaimedTotalAddress(referralAddress), newUnclaimedTotalReferral), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit) | |
410 | - | } | |
411 | - | else throw("Strict value is not equal to itself.") | |
412 | - | } | |
413 | - | else throw("Strict value is not equal to itself.") | |
414 | - | } | |
415 | - | else throw("Strict value is not equal to itself.") | |
416 | - | } | |
417 | - | else throw("Strict value is not equal to itself.") | |
418 | - | } | |
419 | - | ||
420 | - | ||
421 | - | ||
422 | - | @Callable(i) | |
423 | - | func incUnclaimedWithPayment (programName,referrerAddresses) = { | |
424 | - | let checkProgram = if ((programName == "wxSpotFee")) | |
425 | - | then true | |
426 | - | else throwErr("invalid program") | |
427 | - | if ((checkProgram == checkProgram)) | |
428 | - | then { | |
429 | - | let callerAddress = toString(i.caller) | |
430 | - | let lastCall = valueOrElse(getInteger(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress)), 0) | |
431 | - | let waitBlocks = ((lastCall - height) + 3) | |
432 | - | let lastCallCheck = if (((height - 3) > lastCall)) | |
433 | - | then true | |
434 | - | else throwErr(makeString(["wait", toString(waitBlocks), "blocks"], " ")) | |
435 | - | if ((lastCallCheck == lastCallCheck)) | |
436 | - | then { | |
437 | - | func map (accum,next) = { | |
438 | - | let assetIdCheck = (toBase58String(value(next.assetId)) == value(getString(keyRewardAssetId(programName)))) | |
439 | - | let amountCheck = if (assetIdCheck) | |
440 | - | then true | |
441 | - | else throwErr("invalid asset id") | |
442 | - | if ((amountCheck == amountCheck)) | |
443 | - | then (accum :+ next.amount) | |
444 | - | else throw("Strict value is not equal to itself.") | |
445 | - | } | |
446 | - | ||
447 | - | let payments = { | |
448 | - | let $l = i.payments | |
449 | - | let $s = size($l) | |
450 | - | let $acc0 = nil | |
451 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
452 | - | then $a | |
453 | - | else map($a, $l[$i]) | |
454 | - | ||
455 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
456 | - | then $a | |
457 | - | else throw("List size exceeds 10") | |
458 | - | ||
459 | - | $f0_2($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) | |
460 | - | } | |
461 | - | let resAmount = { | |
462 | - | let @ = invoke(this, "incUnclaimedWithPaymentInternal", [payments, programName, referrerAddresses, 0, 0], nil) | |
463 | - | if ($isInstanceOf(@, "Int")) | |
464 | - | then @ | |
465 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
466 | - | } | |
467 | - | if ((resAmount == resAmount)) | |
468 | - | then { | |
469 | - | let treasuryContract = addressFromStringValue(value(getString(keyTreasuryContract(programName)))) | |
470 | - | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
471 | - | [ScriptTransfer(treasuryContract, resAmount, rewardAssetId), IntegerEntry(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress), height)] | |
472 | - | } | |
473 | - | else throw("Strict value is not equal to itself.") | |
474 | - | } | |
475 | - | else throw("Strict value is not equal to itself.") | |
217 | + | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
218 | + | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
219 | + | let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0) | |
220 | + | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
221 | + | let newReferrerUnclaimed = (referrerUnclaimed + referrerReward) | |
222 | + | let newReferralUnclaimed = (referralUnclaimed + referralReward) | |
223 | + | $Tuple2([IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit) | |
476 | 224 | } | |
477 | 225 | else throw("Strict value is not equal to itself.") | |
478 | 226 | } | |
479 | 227 | ||
480 | 228 | ||
481 | 229 | ||
482 | 230 | @Callable(i) | |
483 | 231 | func claim (programName) = { | |
484 | 232 | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
485 | 233 | then true | |
486 | 234 | else throwErr("program does not exist") | |
487 | 235 | if ((checkProgramExists == checkProgramExists)) | |
488 | 236 | then { | |
489 | 237 | let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName)))) | |
490 | - | let claimerAddress = if (isImplementationContract) | |
491 | - | then toString(i.originCaller) | |
492 | - | else toString(i.caller) | |
493 | - | let claimInternal = invoke(this, "claimInternal", [programName, claimerAddress, isImplementationContract], nil) | |
494 | - | if ((claimInternal == claimInternal)) | |
495 | - | then $Tuple2(nil, claimInternal) | |
496 | - | else throw("Strict value is not equal to itself.") | |
497 | - | } | |
498 | - | else throw("Strict value is not equal to itself.") | |
499 | - | } | |
500 | - | ||
501 | - | ||
502 | - | ||
503 | - | @Callable(i) | |
504 | - | func claimBulk () = { | |
505 | - | let callerAddress = toString(i.caller) | |
506 | - | let callerProgramsStr = getString(keyAllReferralPrograms(toString(i.caller))) | |
507 | - | let programsExists = if (isDefined(callerProgramsStr)) | |
508 | - | then true | |
509 | - | else throwErr("no referral programs") | |
510 | - | if ((programsExists == programsExists)) | |
511 | - | then { | |
512 | - | let callerPrograms = split(value(callerProgramsStr), "__") | |
513 | - | let bulkClaim = invoke(this, "claimBulkInternal", [callerAddress, callerPrograms, 0], nil) | |
514 | - | if ((bulkClaim == bulkClaim)) | |
515 | - | then $Tuple2(nil, bulkClaim) | |
516 | - | else throw("Strict value is not equal to itself.") | |
238 | + | let $t084179346 = if (isImplementationContract) | |
239 | + | then { | |
240 | + | let user = toString(i.originCaller) | |
241 | + | $Tuple6(user, valueOrElse(getInteger(keyClaimedReferral(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferral")) | |
242 | + | } | |
243 | + | else { | |
244 | + | let user = toString(i.caller) | |
245 | + | $Tuple6(user, valueOrElse(getInteger(keyClaimedReferrer(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, user)), 0), keyClaimedReferrer(programName, user), keyUnclaimedReferrer(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferrer")) | |
246 | + | } | |
247 | + | let userAddressStr = $t084179346._1 | |
248 | + | let claimerClaimed = $t084179346._2 | |
249 | + | let claimerUnclaimed = $t084179346._3 | |
250 | + | let keyClaimed = $t084179346._4 | |
251 | + | let keyUnclaimed = $t084179346._5 | |
252 | + | let claimHistoryKey = $t084179346._6 | |
253 | + | let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0) | |
254 | + | let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName))))) | |
255 | + | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
256 | + | if (if (isImplementationContract) | |
257 | + | then (claimerUnclaimed == 0) | |
258 | + | else false) | |
259 | + | then $Tuple2(nil, 0) | |
260 | + | else { | |
261 | + | let checkCanClaim = if ((claimerUnclaimed > 0)) | |
262 | + | then true | |
263 | + | else throwErr("nothing to claim") | |
264 | + | if ((checkCanClaim == checkCanClaim)) | |
265 | + | then { | |
266 | + | let newClaimerClaimed = (claimerClaimed + claimerUnclaimed) | |
267 | + | let newClaimedTotal = (claimedTotal + claimerUnclaimed) | |
268 | + | let balanceBefore = value(assetBalance(this, rewardAssetId)) | |
269 | + | if ((balanceBefore == balanceBefore)) | |
270 | + | then { | |
271 | + | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
272 | + | if ((res == res)) | |
273 | + | then { | |
274 | + | let balanceAfter = value(assetBalance(this, rewardAssetId)) | |
275 | + | if ((balanceAfter == balanceAfter)) | |
276 | + | then { | |
277 | + | let balanceDiff = (balanceAfter - balanceBefore) | |
278 | + | if ((balanceDiff == balanceDiff)) | |
279 | + | then { | |
280 | + | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
281 | + | then true | |
282 | + | else throwErr("insufficient balance on referral contract") | |
283 | + | if ((checkBalance == checkBalance)) | |
284 | + | then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed, 0), ScriptTransfer(addressFromStringValue(userAddressStr), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed) | |
285 | + | else throw("Strict value is not equal to itself.") | |
286 | + | } | |
287 | + | else throw("Strict value is not equal to itself.") | |
288 | + | } | |
289 | + | else throw("Strict value is not equal to itself.") | |
290 | + | } | |
291 | + | else throw("Strict value is not equal to itself.") | |
292 | + | } | |
293 | + | else throw("Strict value is not equal to itself.") | |
294 | + | } | |
295 | + | else throw("Strict value is not equal to itself.") | |
296 | + | } | |
517 | 297 | } | |
518 | 298 | else throw("Strict value is not equal to itself.") | |
519 | 299 | } | |
520 | 300 | ||
521 | 301 | ||
522 | 302 | ||
523 | 303 | @Callable(i) | |
524 | 304 | func claimREADONLY (programName,userAddress) = { | |
525 | 305 | let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0) | |
526 | 306 | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0) | |
527 | 307 | $Tuple2(nil, [claimerUnclaimed, claimerClaimed]) | |
528 | - | } | |
529 | - | ||
530 | - | ||
531 | - | ||
532 | - | @Callable(i) | |
533 | - | func claimBulkREADONLY (claimer) = { | |
534 | - | let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimer)), 0) | |
535 | - | let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimer)), 0) | |
536 | - | $Tuple2(nil, [unclaimedTotalAddress, claimedTotalAddress]) | |
537 | - | } | |
538 | - | ||
539 | - | ||
540 | - | ||
541 | - | @Callable(i) | |
542 | - | func setTotalKeys (programName,address) = { | |
543 | - | let claimedReferrer = valueOrElse(getInteger(keyClaimedReferrer(programName, address)), 0) | |
544 | - | let claimedReferral = valueOrElse(getInteger(keyClaimedReferral(programName, address)), 0) | |
545 | - | let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, address)), 0) | |
546 | - | let unclaimedReferral = valueOrElse(getInteger(keyUnclaimedReferral(programName, address)), 0) | |
547 | - | let claimedTotalAddress = (claimedReferrer + claimedReferral) | |
548 | - | let unclaimedTotalAddress = (unclaimedReferrer + unclaimedReferral) | |
549 | - | $Tuple2([IntegerEntry(keyClaimedTotalAddress(address), claimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(address), unclaimedTotalAddress)], unit) | |
550 | 308 | } | |
551 | 309 | ||
552 | 310 | ||
553 | 311 | ||
554 | 312 | @Callable(i) | |
555 | 313 | func setManager (pendingManagerPublicKey) = { | |
556 | 314 | let checkCaller = mustManager(i) | |
557 | 315 | if ((checkCaller == checkCaller)) | |
558 | 316 | then { | |
559 | 317 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
560 | 318 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
561 | 319 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
562 | 320 | else throw("Strict value is not equal to itself.") | |
563 | 321 | } | |
564 | 322 | else throw("Strict value is not equal to itself.") | |
565 | 323 | } | |
566 | 324 | ||
567 | 325 | ||
568 | 326 | ||
569 | 327 | @Callable(i) | |
570 | 328 | func confirmManager () = { | |
571 | 329 | let pm = pendingManagerPublicKeyOrUnit() | |
572 | 330 | let hasPM = if (isDefined(pm)) | |
573 | 331 | then true | |
574 | 332 | else throwErr("no pending manager") | |
575 | 333 | if ((hasPM == hasPM)) | |
576 | 334 | then { | |
577 | 335 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
578 | 336 | then true | |
579 | 337 | else throwErr("you are not pending manager") | |
580 | 338 | if ((checkPM == checkPM)) | |
581 | 339 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
582 | 340 | else throw("Strict value is not equal to itself.") | |
583 | 341 | } | |
584 | 342 | else throw("Strict value is not equal to itself.") | |
585 | 343 | } | |
586 | 344 | ||
587 | 345 | ||
588 | 346 | @Verifier(tx) | |
589 | 347 | func verify () = { | |
590 | 348 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
591 | 349 | case pk: ByteVector => | |
592 | 350 | pk | |
593 | 351 | case _: Unit => | |
594 | 352 | tx.senderPublicKey | |
595 | 353 | case _ => | |
596 | 354 | throw("Match error") | |
597 | 355 | } | |
598 | 356 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
599 | 357 | } | |
600 | 358 |
github/deemru/w8io/169f3d6 65.20 ms ◑