tx · jinqcGU91uPabKhh38aVaz2ot9iS1wn427iX2Y1EeX2

3N9vabWFoy1tnEwQgiR547qrvbubRopDv2T:  -0.00500000 Waves

2023.03.16 11:34 [2492340] smart account 3N9vabWFoy1tnEwQgiR547qrvbubRopDv2T > SELF 0.00000000 Waves

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

github/deemru/w8io/169f3d6 
46.55 ms