tx · 9WA53dYhMo8abNYSBSwUrCkdBbMjbk8LkVPrdeeGrnYK 3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh: -0.01800000 Waves 2022.10.27 10:23 [2290524] smart account 3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh > SELF 0.00000000 Waves
{ "type": 13, "id": "9WA53dYhMo8abNYSBSwUrCkdBbMjbk8LkVPrdeeGrnYK", "fee": 1800000, "feeAssetId": null, "timestamp": 1666855364820, "version": 1, "sender": "3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh", "senderPublicKey": "33fpjdpM9FMu87RZKePniPardKqQXM96sm7VhAk3JEVQ", "proofs": [ "5dD13guaNhsEL58Ahtm7bqqWrVkvwJqrSSLN61FVMZGpdYo8b5Xrvprr1ugwGidEbR2tcbDUxtfoL5hU7hsgCYdV" ], "script": "base64:BgLnEwgCEgUKAwgIBBIFCgMIGAESBwoFEQgYAQESBgoECAgICBIGCgQICAgCEgUKAwgIBBIGCgQICAEBEgQKAggYEgMKAQgSABIECgIICBIDCgEIEgQKAggIEgMKAQgSACIJc2VwYXJhdG9yIgxrZXlXeEFzc2V0SWQiE2tleUJhY2tlbmRQdWJsaWNLZXkiG2tleUV4aXN0c1JlZmVycmVyVG9SZWZlcnJhbCILcHJvZ3JhbU5hbWUiD3JlZmVycmVyQWRkcmVzcyIPcmVmZXJyYWxBZGRyZXNzIhJrZXlDbGFpbWVkUmVmZXJyZXIiDmNsYWltZXJBZGRyZXNzIhJrZXlDbGFpbWVkUmVmZXJyYWwiFGtleVVuY2xhaW1lZFJlZmVycmVyIhRrZXlVbmNsYWltZWRSZWZlcnJhbCILa2V5UmVmZXJyZXIiDmtleVByb2dyYW1OYW1lIhVrZXlUb3RhbFJlZmVycmFsQ291bnQiFmtleUFjdGl2ZVJlZmVycmFsQ291bnQiE2tleUlzUmVmZXJyYWxBY3RpdmUiFmtleUNsYWltZWRUb3RhbEFkZHJlc3MiB2FkZHJlc3MiGGtleV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UAkA2QQBBQJiTwMJAAACBQJiUAUCYlAJAMwIAgkBC1N0cmluZ0VudHJ5AgkBAUMABQJiTwUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAVEBDmNvbmZpcm1NYW5hZ2VyAAQCYlEJAQFPAAQCYlIDCQEJaXNEZWZpbmVkAQUCYlEGCQEBSgECEm5vIHBlbmRpbmcgbWFuYWdlcgMJAAACBQJiUgUCYlIEAmJTAwkAAAIIBQFRD2NhbGxlclB1YmxpY0tleQkBBXZhbHVlAQUCYlEGCQEBSgECG3lvdSBhcmUgbm90IHBlbmRpbmcgbWFuYWdlcgMJAAACBQJiUwUCYlMJAMwIAgkBC1N0cmluZ0VudHJ5AgkBAUIACQDYBAEJAQV2YWx1ZQEFAmJRCQDMCAIJAQtEZWxldGVFbnRyeQEJAQFDAAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJiVAECYlUABAJiVgQBTQkBAUwAAwkAAQIFAU0CCkJ5dGVWZWN0b3IEAVMFAU0FAVMDCQABAgUBTQIEVW5pdAgFAmJUD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJiVAlib2R5Qnl0ZXMJAJEDAggFAmJUBnByb29mcwAABQJiVpTNQYA=", "chainId": 84, "height": 2290524, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: F85abB5RAhaDewZHwtxKQE7YZRptbphgTcgBMJcqZbKX Next: EPiqXdrakwq5NydtB98s9ydE91rgp4i8zkvyUeRVvp8v 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 | + | ||
5 | 8 | ||
6 | 9 | let keyBackendPublicKey = makeString(["%s", "backendPublicKey"], separator) | |
7 | 10 | ||
8 | 11 | func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator) | |
9 | 12 | ||
10 | 13 | ||
11 | - | func keyClaimedReferrer (programName,claimerAddress) = makeString([" | |
14 | + | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
12 | 15 | ||
13 | 16 | ||
14 | - | func keyClaimedReferral (programName,claimerAddress) = makeString([" | |
17 | + | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
15 | 18 | ||
16 | 19 | ||
17 | - | func keyUnclaimedReferrer (programName,claimerAddress) = makeString([" | |
20 | + | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
18 | 21 | ||
19 | 22 | ||
20 | - | func keyUnclaimedReferral (programName,claimerAddress) = makeString([" | |
23 | + | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
21 | 24 | ||
22 | 25 | ||
23 | 26 | func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator) | |
35 | 38 | func keyIsReferralActive (programName,referralAddress) = makeString(["%s%s%s", "activeReferral", programName, referralAddress], separator) | |
36 | 39 | ||
37 | 40 | ||
41 | + | func keyClaimedTotalAddress (address) = makeString(["%s%s", "claimedTotalAddress", address], separator) | |
42 | + | ||
43 | + | ||
44 | + | func keyUnclaimedTotalAddress (address) = makeString(["%s%s", "unclaimedTotalAddress", address], separator) | |
45 | + | ||
46 | + | ||
38 | 47 | func keyClaimedTotal (programName) = makeString(["%s%s", "claimedTotal", programName], separator) | |
39 | 48 | ||
40 | 49 | ||
48 | 57 | ||
49 | 58 | ||
50 | 59 | 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) | |
51 | 66 | ||
52 | 67 | ||
53 | 68 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
100 | 115 | throw("Match error") | |
101 | 116 | } | |
102 | 117 | } | |
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 | + | ||
103 | 268 | ||
104 | 269 | ||
105 | 270 | @Callable(i) | |
162 | 327 | then { | |
163 | 328 | let totalReferralCount = valueOrElse(getInteger(keyTotalReferralCount(programName, referrerAddress)), 0) | |
164 | 329 | let newTotalReferralCount = (totalReferralCount + 1) | |
165 | - | $Tuple2([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)], unit) | |
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) | |
166 | 333 | } | |
167 | 334 | else throw("Strict value is not equal to itself.") | |
168 | 335 | } | |
209 | 376 | @Callable(i) | |
210 | 377 | func incUnclaimed (programName,referralAddress,referrerReward,referralReward) = { | |
211 | 378 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
379 | + | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
212 | 380 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
213 | 381 | then true | |
214 | 382 | else throwErr("permission denied") | |
215 | 383 | if ((checkCaller == checkCaller)) | |
216 | 384 | then { | |
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) | |
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.") | |
224 | 476 | } | |
225 | 477 | else throw("Strict value is not equal to itself.") | |
226 | 478 | } | |
235 | 487 | if ((checkProgramExists == checkProgramExists)) | |
236 | 488 | then { | |
237 | 489 | let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName)))) | |
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 | - | } | |
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.") | |
297 | 517 | } | |
298 | 518 | else throw("Strict value is not equal to itself.") | |
299 | 519 | } | |
305 | 525 | let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0) | |
306 | 526 | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0) | |
307 | 527 | $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) | |
308 | 550 | } | |
309 | 551 | ||
310 | 552 |
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 | + | ||
5 | 8 | ||
6 | 9 | let keyBackendPublicKey = makeString(["%s", "backendPublicKey"], separator) | |
7 | 10 | ||
8 | 11 | func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator) | |
9 | 12 | ||
10 | 13 | ||
11 | - | func keyClaimedReferrer (programName,claimerAddress) = makeString([" | |
14 | + | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
12 | 15 | ||
13 | 16 | ||
14 | - | func keyClaimedReferral (programName,claimerAddress) = makeString([" | |
17 | + | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
15 | 18 | ||
16 | 19 | ||
17 | - | func keyUnclaimedReferrer (programName,claimerAddress) = makeString([" | |
20 | + | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
18 | 21 | ||
19 | 22 | ||
20 | - | func keyUnclaimedReferral (programName,claimerAddress) = makeString([" | |
23 | + | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
21 | 24 | ||
22 | 25 | ||
23 | 26 | func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator) | |
24 | 27 | ||
25 | 28 | ||
26 | 29 | func keyProgramName (programName) = makeString(["%s%s", "programName", programName], separator) | |
27 | 30 | ||
28 | 31 | ||
29 | 32 | func keyTotalReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "totalReferralCount", programName, referrerAddress], separator) | |
30 | 33 | ||
31 | 34 | ||
32 | 35 | func keyActiveReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "activeReferralCount", programName, referrerAddress], separator) | |
33 | 36 | ||
34 | 37 | ||
35 | 38 | func keyIsReferralActive (programName,referralAddress) = makeString(["%s%s%s", "activeReferral", programName, referralAddress], separator) | |
36 | 39 | ||
37 | 40 | ||
41 | + | func keyClaimedTotalAddress (address) = makeString(["%s%s", "claimedTotalAddress", address], separator) | |
42 | + | ||
43 | + | ||
44 | + | func keyUnclaimedTotalAddress (address) = makeString(["%s%s", "unclaimedTotalAddress", address], separator) | |
45 | + | ||
46 | + | ||
38 | 47 | func keyClaimedTotal (programName) = makeString(["%s%s", "claimedTotal", programName], separator) | |
39 | 48 | ||
40 | 49 | ||
41 | 50 | func keyRewardsTotal (programName) = makeString(["%s%s", "rewardsTotal", programName], separator) | |
42 | 51 | ||
43 | 52 | ||
44 | 53 | func keyRewardAssetId (programName) = makeString(["%s%s", "rewardAssetId", programName], separator) | |
45 | 54 | ||
46 | 55 | ||
47 | 56 | func keyTreasuryContract (programName) = makeString(["%s%s", "treasuryContract", programName], separator) | |
48 | 57 | ||
49 | 58 | ||
50 | 59 | 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) | |
51 | 66 | ||
52 | 67 | ||
53 | 68 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
54 | 69 | ||
55 | 70 | ||
56 | 71 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
57 | 72 | ||
58 | 73 | ||
59 | 74 | func keyClaimHistory (programName,userAddress,transactionId,type) = makeString(["%s%s%s%s%s", "history", type, programName, userAddress, transactionId], separator) | |
60 | 75 | ||
61 | 76 | ||
62 | 77 | func formatClaimHistory (amount) = makeString(["%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], separator) | |
63 | 78 | ||
64 | 79 | ||
65 | 80 | func throwErr (msg) = throw(makeString(["referral.ride:", msg], " ")) | |
66 | 81 | ||
67 | 82 | ||
68 | 83 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
69 | 84 | case s: String => | |
70 | 85 | fromBase58String(s) | |
71 | 86 | case _: Unit => | |
72 | 87 | unit | |
73 | 88 | case _ => | |
74 | 89 | throw("Match error") | |
75 | 90 | } | |
76 | 91 | ||
77 | 92 | ||
78 | 93 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
79 | 94 | case s: String => | |
80 | 95 | fromBase58String(s) | |
81 | 96 | case _: Unit => | |
82 | 97 | unit | |
83 | 98 | case _ => | |
84 | 99 | throw("Match error") | |
85 | 100 | } | |
86 | 101 | ||
87 | 102 | ||
88 | 103 | func mustManager (i) = { | |
89 | 104 | let pd = throwErr("permission denied") | |
90 | 105 | match managerPublicKeyOrUnit() { | |
91 | 106 | case pk: ByteVector => | |
92 | 107 | if ((i.callerPublicKey == pk)) | |
93 | 108 | then true | |
94 | 109 | else pd | |
95 | 110 | case _: Unit => | |
96 | 111 | if ((i.caller == this)) | |
97 | 112 | then true | |
98 | 113 | else pd | |
99 | 114 | case _ => | |
100 | 115 | throw("Match error") | |
101 | 116 | } | |
102 | 117 | } | |
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 | + | ||
103 | 268 | ||
104 | 269 | ||
105 | 270 | @Callable(i) | |
106 | 271 | func createReferralProgram (programName,treasuryContract,implementationContract,rewardAssetId) = { | |
107 | 272 | let checkCaller = mustManager(i) | |
108 | 273 | if ((checkCaller == checkCaller)) | |
109 | 274 | then { | |
110 | 275 | let checkProgramName = if ((getBoolean(keyProgramName(programName)) == unit)) | |
111 | 276 | then true | |
112 | 277 | else throwErr("program name already exists") | |
113 | 278 | if ((checkProgramName == checkProgramName)) | |
114 | 279 | then { | |
115 | 280 | let programNameIsValid = if (!(contains(programName, separator))) | |
116 | 281 | then !(contains(programName, " ")) | |
117 | 282 | else false | |
118 | 283 | let checkProgramExists = if (programNameIsValid) | |
119 | 284 | then true | |
120 | 285 | else throwErr("invalid program name") | |
121 | 286 | if ((checkProgramExists == checkProgramExists)) | |
122 | 287 | then { | |
123 | 288 | let checkRewardAsset = if ((assetInfo(fromBase58String(rewardAssetId)) != unit)) | |
124 | 289 | then true | |
125 | 290 | else throwErr("invalid reward asset id") | |
126 | 291 | if ((checkRewardAsset == checkRewardAsset)) | |
127 | 292 | then $Tuple2([BooleanEntry(keyProgramName(programName), true), StringEntry(keyTreasuryContract(programName), treasuryContract), StringEntry(keyImplementationContract(programName), implementationContract), StringEntry(keyRewardAssetId(programName), rewardAssetId), IntegerEntry(keyRewardsTotal(programName), 0)], unit) | |
128 | 293 | else throw("Strict value is not equal to itself.") | |
129 | 294 | } | |
130 | 295 | else throw("Strict value is not equal to itself.") | |
131 | 296 | } | |
132 | 297 | else throw("Strict value is not equal to itself.") | |
133 | 298 | } | |
134 | 299 | else throw("Strict value is not equal to itself.") | |
135 | 300 | } | |
136 | 301 | ||
137 | 302 | ||
138 | 303 | ||
139 | 304 | @Callable(i) | |
140 | 305 | func createPair (programName,referrerAddress,referralAddress,signature) = { | |
141 | 306 | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
142 | 307 | then true | |
143 | 308 | else throwErr("program does not exist") | |
144 | 309 | if ((checkProgramExists == checkProgramExists)) | |
145 | 310 | then { | |
146 | 311 | let pairReferrerToReferralExistCheck = if ((getBoolean(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress)) == unit)) | |
147 | 312 | then true | |
148 | 313 | else throwErr("pair already exists") | |
149 | 314 | if ((pairReferrerToReferralExistCheck == pairReferrerToReferralExistCheck)) | |
150 | 315 | then { | |
151 | 316 | let noRefSelf = if ((referrerAddress != referralAddress)) | |
152 | 317 | then true | |
153 | 318 | else throwErr("cannot refer to self") | |
154 | 319 | if ((noRefSelf == noRefSelf)) | |
155 | 320 | then { | |
156 | 321 | let pair = toBytes(makeString([programName, referrerAddress, referralAddress], ":")) | |
157 | 322 | let backendPublicKey = fromBase58String(value(getString(keyBackendPublicKey))) | |
158 | 323 | let validateSignature = if (sigVerify(pair, signature, backendPublicKey)) | |
159 | 324 | then true | |
160 | 325 | else throwErr("bad signature") | |
161 | 326 | if ((validateSignature == validateSignature)) | |
162 | 327 | then { | |
163 | 328 | let totalReferralCount = valueOrElse(getInteger(keyTotalReferralCount(programName, referrerAddress)), 0) | |
164 | 329 | let newTotalReferralCount = (totalReferralCount + 1) | |
165 | - | $Tuple2([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)], unit) | |
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) | |
166 | 333 | } | |
167 | 334 | else throw("Strict value is not equal to itself.") | |
168 | 335 | } | |
169 | 336 | else throw("Strict value is not equal to itself.") | |
170 | 337 | } | |
171 | 338 | else throw("Strict value is not equal to itself.") | |
172 | 339 | } | |
173 | 340 | else throw("Strict value is not equal to itself.") | |
174 | 341 | } | |
175 | 342 | ||
176 | 343 | ||
177 | 344 | ||
178 | 345 | @Callable(i) | |
179 | 346 | func updateReferralActivity (programName,referralAddress,isActive) = { | |
180 | 347 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
181 | 348 | let isReferralActive = (getBoolean(keyIsReferralActive(programName, referralAddress)) != unit) | |
182 | 349 | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
183 | 350 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
184 | 351 | then true | |
185 | 352 | else throwErr("permission denied") | |
186 | 353 | if ((checkCaller == checkCaller)) | |
187 | 354 | then { | |
188 | 355 | let update = if ((isReferralActive == isActive)) | |
189 | 356 | then $Tuple2(nil, unit) | |
190 | 357 | else { | |
191 | 358 | let update = if ((isActive == true)) | |
192 | 359 | then { | |
193 | 360 | let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) + 1) | |
194 | 361 | $Tuple2([BooleanEntry(keyIsReferralActive(programName, referralAddress), true), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit) | |
195 | 362 | } | |
196 | 363 | else { | |
197 | 364 | let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) - 1) | |
198 | 365 | $Tuple2([DeleteEntry(keyIsReferralActive(programName, referralAddress)), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit) | |
199 | 366 | } | |
200 | 367 | update | |
201 | 368 | } | |
202 | 369 | update | |
203 | 370 | } | |
204 | 371 | else throw("Strict value is not equal to itself.") | |
205 | 372 | } | |
206 | 373 | ||
207 | 374 | ||
208 | 375 | ||
209 | 376 | @Callable(i) | |
210 | 377 | func incUnclaimed (programName,referralAddress,referrerReward,referralReward) = { | |
211 | 378 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
379 | + | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
212 | 380 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
213 | 381 | then true | |
214 | 382 | else throwErr("permission denied") | |
215 | 383 | if ((checkCaller == checkCaller)) | |
216 | 384 | then { | |
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) | |
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.") | |
224 | 476 | } | |
225 | 477 | else throw("Strict value is not equal to itself.") | |
226 | 478 | } | |
227 | 479 | ||
228 | 480 | ||
229 | 481 | ||
230 | 482 | @Callable(i) | |
231 | 483 | func claim (programName) = { | |
232 | 484 | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
233 | 485 | then true | |
234 | 486 | else throwErr("program does not exist") | |
235 | 487 | if ((checkProgramExists == checkProgramExists)) | |
236 | 488 | then { | |
237 | 489 | let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName)))) | |
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 | - | } | |
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.") | |
297 | 517 | } | |
298 | 518 | else throw("Strict value is not equal to itself.") | |
299 | 519 | } | |
300 | 520 | ||
301 | 521 | ||
302 | 522 | ||
303 | 523 | @Callable(i) | |
304 | 524 | func claimREADONLY (programName,userAddress) = { | |
305 | 525 | let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0) | |
306 | 526 | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0) | |
307 | 527 | $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) | |
308 | 550 | } | |
309 | 551 | ||
310 | 552 | ||
311 | 553 | ||
312 | 554 | @Callable(i) | |
313 | 555 | func setManager (pendingManagerPublicKey) = { | |
314 | 556 | let checkCaller = mustManager(i) | |
315 | 557 | if ((checkCaller == checkCaller)) | |
316 | 558 | then { | |
317 | 559 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
318 | 560 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
319 | 561 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
320 | 562 | else throw("Strict value is not equal to itself.") | |
321 | 563 | } | |
322 | 564 | else throw("Strict value is not equal to itself.") | |
323 | 565 | } | |
324 | 566 | ||
325 | 567 | ||
326 | 568 | ||
327 | 569 | @Callable(i) | |
328 | 570 | func confirmManager () = { | |
329 | 571 | let pm = pendingManagerPublicKeyOrUnit() | |
330 | 572 | let hasPM = if (isDefined(pm)) | |
331 | 573 | then true | |
332 | 574 | else throwErr("no pending manager") | |
333 | 575 | if ((hasPM == hasPM)) | |
334 | 576 | then { | |
335 | 577 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
336 | 578 | then true | |
337 | 579 | else throwErr("you are not pending manager") | |
338 | 580 | if ((checkPM == checkPM)) | |
339 | 581 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
340 | 582 | else throw("Strict value is not equal to itself.") | |
341 | 583 | } | |
342 | 584 | else throw("Strict value is not equal to itself.") | |
343 | 585 | } | |
344 | 586 | ||
345 | 587 | ||
346 | 588 | @Verifier(tx) | |
347 | 589 | func verify () = { | |
348 | 590 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
349 | 591 | case pk: ByteVector => | |
350 | 592 | pk | |
351 | 593 | case _: Unit => | |
352 | 594 | tx.senderPublicKey | |
353 | 595 | case _ => | |
354 | 596 | throw("Match error") | |
355 | 597 | } | |
356 | 598 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
357 | 599 | } | |
358 | 600 |
github/deemru/w8io/026f985 74.01 ms ◑