tx · GsS7t7aBcAqRaMLwTKj3TdyDCzqF3Suqix8h4bMpN1LZ 3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh: -0.01700000 Waves 2022.08.03 12:46 [2168143] smart account 3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh > SELF 0.00000000 Waves
{ "type": 13, "id": "GsS7t7aBcAqRaMLwTKj3TdyDCzqF3Suqix8h4bMpN1LZ", "fee": 1700000, "feeAssetId": null, "timestamp": 1659520018820, "version": 1, "sender": "3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh", "senderPublicKey": "33fpjdpM9FMu87RZKePniPardKqQXM96sm7VhAk3JEVQ", "proofs": [ "4TWGVrUGxfd2QPbdi7rxxTyrfaff5FkSWQREbrHRskCVoL9sPpM7J3Xg2rDD9Re2f2WPJchAMmutEd5m7F6hbmG1" ], "script": "base64:BgIzCAISBgoECAgICBIGCgQICAgCEgUKAwgIBBIGCgQICAEBEgMKAQgSBAoCCAgSAwoBCBIAGQAJc2VwYXJhdG9yAgJfXwATa2V5QmFja2VuZFB1YmxpY0tleQkAuQkCCQDMCAICAiVzCQDMCAICEGJhY2tlbmRQdWJsaWNLZXkFA25pbAUJc2VwYXJhdG9yARtrZXlFeGlzdHNSZWZlcnJlclRvUmVmZXJyYWwDC3Byb2dyYW1OYW1lD3JlZmVycmVyQWRkcmVzcw9yZWZlcnJhbEFkZHJlc3MJALkJAgkAzAgCAgglcyVzJXMlcwkAzAgCAhhleGlzdHNSZWZlcnJlclRvUmVmZXJyYWwJAMwIAgULcHJvZ3JhbU5hbWUJAMwIAgUPcmVmZXJyZXJBZGRyZXNzCQDMCAIFD3JlZmVycmFsQWRkcmVzcwUDbmlsBQlzZXBhcmF0b3IBEmtleUNsYWltZWRSZWZlcnJlcgILcHJvZ3JhbU5hbWUOY2xhaW1lckFkZHJlc3MJALkJAgkAzAgCAgglcyVzJXMlcwkAzAgCAg9jbGFpbWVkUmVmZXJyZXIJAMwIAgULcHJvZ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saWNLZXkJAQV2YWx1ZQEFAnBtBgkBCHRocm93RXJyAQIbeW91IGFyZSBub3QgcGVuZGluZyBtYW5hZ2VyAwkAAAIFB2NoZWNrUE0FB2NoZWNrUE0JAMwIAgkBC1N0cmluZ0VudHJ5AgkBE2tleU1hbmFnZXJQdWJsaWNLZXkACQDYBAEJAQV2YWx1ZQEFAnBtCQDMCAIJAQtEZWxldGVFbnRyeQEJARprZXlQZW5kaW5nTWFuYWdlclB1YmxpY0tleQAFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAED3RhcmdldFB1YmxpY0tleQQHJG1hdGNoMAkBFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAnBrBQckbWF0Y2gwBQJwawMJAAECBQckbWF0Y2gwAgRVbml0CAUCdHgPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleVt9SxI=", "chainId": 84, "height": 2168143, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3YzZr6vnD6D7LZ1t4ih11zb7Q8h7BMZRAea5C9Rs68PJ Next: 42MY5jDK7rB1bFkLEwFHS96wAWDxMhKMpqEfGZKLS7BT Diff:
Old | New | Differences | |
---|---|---|---|
8 | 8 | func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator) | |
9 | 9 | ||
10 | 10 | ||
11 | - | func | |
11 | + | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
12 | 12 | ||
13 | 13 | ||
14 | - | func keyUnclaimed (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimed", programName, claimerAddress], separator) | |
14 | + | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
15 | + | ||
16 | + | ||
17 | + | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
18 | + | ||
19 | + | ||
20 | + | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
15 | 21 | ||
16 | 22 | ||
17 | 23 | func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator) | |
209 | 215 | if ((checkCaller == checkCaller)) | |
210 | 216 | then { | |
211 | 217 | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
212 | - | let referrerUnclaimed = valueOrElse(getInteger( | |
213 | - | let referralUnclaimed = valueOrElse(getInteger( | |
218 | + | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
219 | + | let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0) | |
214 | 220 | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
215 | 221 | let newReferrerUnclaimed = (referrerUnclaimed + referrerReward) | |
216 | 222 | let newReferralUnclaimed = (referralUnclaimed + referralReward) | |
217 | - | $Tuple2([IntegerEntry( | |
223 | + | $Tuple2([IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit) | |
218 | 224 | } | |
219 | 225 | else throw("Strict value is not equal to itself.") | |
220 | 226 | } | |
228 | 234 | else throwErr("program does not exist") | |
229 | 235 | if ((checkProgramExists == checkProgramExists)) | |
230 | 236 | then { | |
231 | - | let userAddressStr = toString(i.caller) | |
237 | + | let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName)))) | |
238 | + | let $t084049132 = if (isImplementationContract) | |
239 | + | then { | |
240 | + | let user = toString(i.originCaller) | |
241 | + | $Tuple5(user, valueOrElse(getInteger(keyClaimedReferral(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user)) | |
242 | + | } | |
243 | + | else { | |
244 | + | let user = toString(i.caller) | |
245 | + | $Tuple5(user, valueOrElse(getInteger(keyClaimedReferrer(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user)) | |
246 | + | } | |
247 | + | let userAddressStr = $t084049132._1 | |
248 | + | let claimerClaimed = $t084049132._2 | |
249 | + | let claimerUnclaimed = $t084049132._3 | |
250 | + | let keyClaimed = $t084049132._4 | |
251 | + | let keyUnclaimed = $t084049132._5 | |
232 | 252 | let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0) | |
233 | - | let claimerClaimed = valueOrElse(getInteger(keyClaimed(programName, userAddressStr)), 0) | |
234 | - | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimed(programName, userAddressStr)), 0) | |
235 | 253 | let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName))))) | |
236 | 254 | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
237 | - | | |
238 | - | then | |
239 | - | else | |
240 | - | | |
241 | - | | |
242 | - | let | |
243 | - | | |
244 | - | | |
245 | - | if (( | |
255 | + | if (if (isImplementationContract) | |
256 | + | then (claimerUnclaimed == 0) | |
257 | + | else false) | |
258 | + | then $Tuple2(nil, 0) | |
259 | + | else { | |
260 | + | let checkCanClaim = if ((claimerUnclaimed > 0)) | |
261 | + | then true | |
262 | + | else throwErr("nothing to claim") | |
263 | + | if ((checkCanClaim == checkCanClaim)) | |
246 | 264 | then { | |
247 | - | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
248 | - | if ((res == res)) | |
265 | + | let newClaimerClaimed = (claimerClaimed + claimerUnclaimed) | |
266 | + | let newClaimedTotal = (claimedTotal + claimerUnclaimed) | |
267 | + | let balanceBefore = value(assetBalance(this, rewardAssetId)) | |
268 | + | if ((balanceBefore == balanceBefore)) | |
249 | 269 | then { | |
250 | - | let | |
251 | - | if (( | |
270 | + | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
271 | + | if ((res == res)) | |
252 | 272 | then { | |
253 | - | let | |
254 | - | if (( | |
273 | + | let balanceAfter = value(assetBalance(this, rewardAssetId)) | |
274 | + | if ((balanceAfter == balanceAfter)) | |
255 | 275 | then { | |
256 | - | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
257 | - | then true | |
258 | - | else throwErr("insufficient balance on referral contract") | |
259 | - | if ((checkBalance == checkBalance)) | |
260 | - | then $Tuple2([IntegerEntry(keyClaimed(programName, userAddressStr), newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed(programName, userAddressStr), 0), ScriptTransfer(i.caller, claimerUnclaimed, rewardAssetId), StringEntry(keyClaimHistory(programName, userAddressStr, toBase58String(i.transactionId)), formatClaimHistory(claimerUnclaimed))], unit) | |
276 | + | let balanceDiff = (balanceAfter - balanceBefore) | |
277 | + | if ((balanceDiff == balanceDiff)) | |
278 | + | then { | |
279 | + | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
280 | + | then true | |
281 | + | else throwErr("insufficient balance on referral contract") | |
282 | + | if ((checkBalance == checkBalance)) | |
283 | + | then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed, 0), ScriptTransfer(addressFromStringValue(userAddressStr), claimerUnclaimed, rewardAssetId), StringEntry(keyClaimHistory(programName, userAddressStr, toBase58String(i.transactionId)), formatClaimHistory(claimerUnclaimed))], claimerUnclaimed) | |
284 | + | else throw("Strict value is not equal to itself.") | |
285 | + | } | |
261 | 286 | else throw("Strict value is not equal to itself.") | |
262 | 287 | } | |
263 | 288 | else throw("Strict value is not equal to itself.") | |
268 | 293 | } | |
269 | 294 | else throw("Strict value is not equal to itself.") | |
270 | 295 | } | |
271 | - | else throw("Strict value is not equal to itself.") | |
272 | 296 | } | |
273 | 297 | else throw("Strict value is not equal to itself.") | |
274 | 298 | } | |
277 | 301 | ||
278 | 302 | @Callable(i) | |
279 | 303 | func claimREADONLY (programName,userAddress) = { | |
280 | - | let claimerClaimed = valueOrElse(getInteger( | |
281 | - | let claimerUnclaimed = valueOrElse(getInteger( | |
304 | + | let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0) | |
305 | + | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0) | |
282 | 306 | $Tuple2(nil, [claimerUnclaimed, claimerClaimed]) | |
283 | 307 | } | |
284 | 308 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | 5 | ||
6 | 6 | let keyBackendPublicKey = makeString(["%s", "backendPublicKey"], separator) | |
7 | 7 | ||
8 | 8 | func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator) | |
9 | 9 | ||
10 | 10 | ||
11 | - | func | |
11 | + | func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferrer", programName, claimerAddress], separator) | |
12 | 12 | ||
13 | 13 | ||
14 | - | func keyUnclaimed (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimed", programName, claimerAddress], separator) | |
14 | + | func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferral", programName, claimerAddress], separator) | |
15 | + | ||
16 | + | ||
17 | + | func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator) | |
18 | + | ||
19 | + | ||
20 | + | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferral", programName, claimerAddress], separator) | |
15 | 21 | ||
16 | 22 | ||
17 | 23 | func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator) | |
18 | 24 | ||
19 | 25 | ||
20 | 26 | func keyProgramName (programName) = makeString(["%s%s", "programName", programName], separator) | |
21 | 27 | ||
22 | 28 | ||
23 | 29 | func keyTotalReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "totalReferralCount", programName, referrerAddress], separator) | |
24 | 30 | ||
25 | 31 | ||
26 | 32 | func keyActiveReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "activeReferralCount", programName, referrerAddress], separator) | |
27 | 33 | ||
28 | 34 | ||
29 | 35 | func keyIsReferralActive (programName,referralAddress) = makeString(["%s%s%s", "activeReferral", programName, referralAddress], separator) | |
30 | 36 | ||
31 | 37 | ||
32 | 38 | func keyClaimedTotal (programName) = makeString(["%s%s", "claimedTotal", programName], separator) | |
33 | 39 | ||
34 | 40 | ||
35 | 41 | func keyRewardsTotal (programName) = makeString(["%s%s", "rewardsTotal", programName], separator) | |
36 | 42 | ||
37 | 43 | ||
38 | 44 | func keyRewardAssetId (programName) = makeString(["%s%s", "rewardAssetId", programName], separator) | |
39 | 45 | ||
40 | 46 | ||
41 | 47 | func keyTreasuryContract (programName) = makeString(["%s%s", "treasuryContract", programName], separator) | |
42 | 48 | ||
43 | 49 | ||
44 | 50 | func keyImplementationContract (programName) = makeString(["%s%s", "implementationContract", programName], separator) | |
45 | 51 | ||
46 | 52 | ||
47 | 53 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
48 | 54 | ||
49 | 55 | ||
50 | 56 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
51 | 57 | ||
52 | 58 | ||
53 | 59 | func keyClaimHistory (programName,userAddress,transactionId) = makeString(["%s%s%s%s%s", "history", "claim", programName, userAddress, transactionId], separator) | |
54 | 60 | ||
55 | 61 | ||
56 | 62 | func formatClaimHistory (amount) = makeString(["%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], separator) | |
57 | 63 | ||
58 | 64 | ||
59 | 65 | func throwErr (msg) = throw(makeString(["referral.ride:", msg], " ")) | |
60 | 66 | ||
61 | 67 | ||
62 | 68 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
63 | 69 | case s: String => | |
64 | 70 | fromBase58String(s) | |
65 | 71 | case _: Unit => | |
66 | 72 | unit | |
67 | 73 | case _ => | |
68 | 74 | throw("Match error") | |
69 | 75 | } | |
70 | 76 | ||
71 | 77 | ||
72 | 78 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
73 | 79 | case s: String => | |
74 | 80 | fromBase58String(s) | |
75 | 81 | case _: Unit => | |
76 | 82 | unit | |
77 | 83 | case _ => | |
78 | 84 | throw("Match error") | |
79 | 85 | } | |
80 | 86 | ||
81 | 87 | ||
82 | 88 | func mustManager (i) = { | |
83 | 89 | let pd = throwErr("permission denied") | |
84 | 90 | match managerPublicKeyOrUnit() { | |
85 | 91 | case pk: ByteVector => | |
86 | 92 | if ((i.callerPublicKey == pk)) | |
87 | 93 | then true | |
88 | 94 | else pd | |
89 | 95 | case _: Unit => | |
90 | 96 | if ((i.caller == this)) | |
91 | 97 | then true | |
92 | 98 | else pd | |
93 | 99 | case _ => | |
94 | 100 | throw("Match error") | |
95 | 101 | } | |
96 | 102 | } | |
97 | 103 | ||
98 | 104 | ||
99 | 105 | @Callable(i) | |
100 | 106 | func createReferralProgram (programName,treasuryContract,implementationContract,rewardAssetId) = { | |
101 | 107 | let checkCaller = mustManager(i) | |
102 | 108 | if ((checkCaller == checkCaller)) | |
103 | 109 | then { | |
104 | 110 | let checkProgramName = if ((getBoolean(keyProgramName(programName)) == unit)) | |
105 | 111 | then true | |
106 | 112 | else throwErr("program name already exists") | |
107 | 113 | if ((checkProgramName == checkProgramName)) | |
108 | 114 | then { | |
109 | 115 | let programNameIsValid = if (!(contains(programName, separator))) | |
110 | 116 | then !(contains(programName, " ")) | |
111 | 117 | else false | |
112 | 118 | let checkProgramExists = if (programNameIsValid) | |
113 | 119 | then true | |
114 | 120 | else throwErr("invalid program name") | |
115 | 121 | if ((checkProgramExists == checkProgramExists)) | |
116 | 122 | then { | |
117 | 123 | let checkRewardAsset = if ((assetInfo(fromBase58String(rewardAssetId)) != unit)) | |
118 | 124 | then true | |
119 | 125 | else throwErr("invalid reward asset id") | |
120 | 126 | if ((checkRewardAsset == checkRewardAsset)) | |
121 | 127 | then $Tuple2([BooleanEntry(keyProgramName(programName), true), StringEntry(keyTreasuryContract(programName), treasuryContract), StringEntry(keyImplementationContract(programName), implementationContract), StringEntry(keyRewardAssetId(programName), rewardAssetId), IntegerEntry(keyRewardsTotal(programName), 0)], unit) | |
122 | 128 | else throw("Strict value is not equal to itself.") | |
123 | 129 | } | |
124 | 130 | else throw("Strict value is not equal to itself.") | |
125 | 131 | } | |
126 | 132 | else throw("Strict value is not equal to itself.") | |
127 | 133 | } | |
128 | 134 | else throw("Strict value is not equal to itself.") | |
129 | 135 | } | |
130 | 136 | ||
131 | 137 | ||
132 | 138 | ||
133 | 139 | @Callable(i) | |
134 | 140 | func createPair (programName,referrerAddress,referralAddress,signature) = { | |
135 | 141 | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
136 | 142 | then true | |
137 | 143 | else throwErr("program does not exist") | |
138 | 144 | if ((checkProgramExists == checkProgramExists)) | |
139 | 145 | then { | |
140 | 146 | let pairReferrerToReferralExistCheck = if ((getBoolean(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress)) == unit)) | |
141 | 147 | then true | |
142 | 148 | else throwErr("pair already exists") | |
143 | 149 | if ((pairReferrerToReferralExistCheck == pairReferrerToReferralExistCheck)) | |
144 | 150 | then { | |
145 | 151 | let noRefSelf = if ((referrerAddress != referralAddress)) | |
146 | 152 | then true | |
147 | 153 | else throwErr("cannot refer to self") | |
148 | 154 | if ((noRefSelf == noRefSelf)) | |
149 | 155 | then { | |
150 | 156 | let pair = toBytes(makeString([programName, referrerAddress, referralAddress], ":")) | |
151 | 157 | let backendPublicKey = fromBase58String(value(getString(keyBackendPublicKey))) | |
152 | 158 | let validateSignature = if (sigVerify(pair, signature, backendPublicKey)) | |
153 | 159 | then true | |
154 | 160 | else throwErr("bad signature") | |
155 | 161 | if ((validateSignature == validateSignature)) | |
156 | 162 | then { | |
157 | 163 | let totalReferralCount = valueOrElse(getInteger(keyTotalReferralCount(programName, referrerAddress)), 0) | |
158 | 164 | let newTotalReferralCount = (totalReferralCount + 1) | |
159 | 165 | $Tuple2([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)], unit) | |
160 | 166 | } | |
161 | 167 | else throw("Strict value is not equal to itself.") | |
162 | 168 | } | |
163 | 169 | else throw("Strict value is not equal to itself.") | |
164 | 170 | } | |
165 | 171 | else throw("Strict value is not equal to itself.") | |
166 | 172 | } | |
167 | 173 | else throw("Strict value is not equal to itself.") | |
168 | 174 | } | |
169 | 175 | ||
170 | 176 | ||
171 | 177 | ||
172 | 178 | @Callable(i) | |
173 | 179 | func updateReferralActivity (programName,referralAddress,isActive) = { | |
174 | 180 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
175 | 181 | let isReferralActive = (getBoolean(keyIsReferralActive(programName, referralAddress)) != unit) | |
176 | 182 | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
177 | 183 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
178 | 184 | then true | |
179 | 185 | else throwErr("permission denied") | |
180 | 186 | if ((checkCaller == checkCaller)) | |
181 | 187 | then { | |
182 | 188 | let update = if ((isReferralActive == isActive)) | |
183 | 189 | then $Tuple2(nil, unit) | |
184 | 190 | else { | |
185 | 191 | let update = if ((isActive == true)) | |
186 | 192 | then { | |
187 | 193 | let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) + 1) | |
188 | 194 | $Tuple2([BooleanEntry(keyIsReferralActive(programName, referralAddress), true), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit) | |
189 | 195 | } | |
190 | 196 | else { | |
191 | 197 | let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) - 1) | |
192 | 198 | $Tuple2([DeleteEntry(keyIsReferralActive(programName, referralAddress)), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit) | |
193 | 199 | } | |
194 | 200 | update | |
195 | 201 | } | |
196 | 202 | update | |
197 | 203 | } | |
198 | 204 | else throw("Strict value is not equal to itself.") | |
199 | 205 | } | |
200 | 206 | ||
201 | 207 | ||
202 | 208 | ||
203 | 209 | @Callable(i) | |
204 | 210 | func incUnclaimed (programName,referralAddress,referrerReward,referralReward) = { | |
205 | 211 | let implementationContract = value(getString(keyImplementationContract(programName))) | |
206 | 212 | let checkCaller = if ((toString(i.caller) == implementationContract)) | |
207 | 213 | then true | |
208 | 214 | else throwErr("permission denied") | |
209 | 215 | if ((checkCaller == checkCaller)) | |
210 | 216 | then { | |
211 | 217 | let referrerAddress = value(getString(keyReferrer(programName, referralAddress))) | |
212 | - | let referrerUnclaimed = valueOrElse(getInteger( | |
213 | - | let referralUnclaimed = valueOrElse(getInteger( | |
218 | + | let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0) | |
219 | + | let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0) | |
214 | 220 | let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0) | |
215 | 221 | let newReferrerUnclaimed = (referrerUnclaimed + referrerReward) | |
216 | 222 | let newReferralUnclaimed = (referralUnclaimed + referralReward) | |
217 | - | $Tuple2([IntegerEntry( | |
223 | + | $Tuple2([IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit) | |
218 | 224 | } | |
219 | 225 | else throw("Strict value is not equal to itself.") | |
220 | 226 | } | |
221 | 227 | ||
222 | 228 | ||
223 | 229 | ||
224 | 230 | @Callable(i) | |
225 | 231 | func claim (programName) = { | |
226 | 232 | let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false)) | |
227 | 233 | then true | |
228 | 234 | else throwErr("program does not exist") | |
229 | 235 | if ((checkProgramExists == checkProgramExists)) | |
230 | 236 | then { | |
231 | - | let userAddressStr = toString(i.caller) | |
237 | + | let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName)))) | |
238 | + | let $t084049132 = if (isImplementationContract) | |
239 | + | then { | |
240 | + | let user = toString(i.originCaller) | |
241 | + | $Tuple5(user, valueOrElse(getInteger(keyClaimedReferral(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user)) | |
242 | + | } | |
243 | + | else { | |
244 | + | let user = toString(i.caller) | |
245 | + | $Tuple5(user, valueOrElse(getInteger(keyClaimedReferrer(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user)) | |
246 | + | } | |
247 | + | let userAddressStr = $t084049132._1 | |
248 | + | let claimerClaimed = $t084049132._2 | |
249 | + | let claimerUnclaimed = $t084049132._3 | |
250 | + | let keyClaimed = $t084049132._4 | |
251 | + | let keyUnclaimed = $t084049132._5 | |
232 | 252 | let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0) | |
233 | - | let claimerClaimed = valueOrElse(getInteger(keyClaimed(programName, userAddressStr)), 0) | |
234 | - | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimed(programName, userAddressStr)), 0) | |
235 | 253 | let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName))))) | |
236 | 254 | let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName)))) | |
237 | - | | |
238 | - | then | |
239 | - | else | |
240 | - | | |
241 | - | | |
242 | - | let | |
243 | - | | |
244 | - | | |
245 | - | if (( | |
255 | + | if (if (isImplementationContract) | |
256 | + | then (claimerUnclaimed == 0) | |
257 | + | else false) | |
258 | + | then $Tuple2(nil, 0) | |
259 | + | else { | |
260 | + | let checkCanClaim = if ((claimerUnclaimed > 0)) | |
261 | + | then true | |
262 | + | else throwErr("nothing to claim") | |
263 | + | if ((checkCanClaim == checkCanClaim)) | |
246 | 264 | then { | |
247 | - | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
248 | - | if ((res == res)) | |
265 | + | let newClaimerClaimed = (claimerClaimed + claimerUnclaimed) | |
266 | + | let newClaimedTotal = (claimedTotal + claimerUnclaimed) | |
267 | + | let balanceBefore = value(assetBalance(this, rewardAssetId)) | |
268 | + | if ((balanceBefore == balanceBefore)) | |
249 | 269 | then { | |
250 | - | let | |
251 | - | if (( | |
270 | + | let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil) | |
271 | + | if ((res == res)) | |
252 | 272 | then { | |
253 | - | let | |
254 | - | if (( | |
273 | + | let balanceAfter = value(assetBalance(this, rewardAssetId)) | |
274 | + | if ((balanceAfter == balanceAfter)) | |
255 | 275 | then { | |
256 | - | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
257 | - | then true | |
258 | - | else throwErr("insufficient balance on referral contract") | |
259 | - | if ((checkBalance == checkBalance)) | |
260 | - | then $Tuple2([IntegerEntry(keyClaimed(programName, userAddressStr), newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed(programName, userAddressStr), 0), ScriptTransfer(i.caller, claimerUnclaimed, rewardAssetId), StringEntry(keyClaimHistory(programName, userAddressStr, toBase58String(i.transactionId)), formatClaimHistory(claimerUnclaimed))], unit) | |
276 | + | let balanceDiff = (balanceAfter - balanceBefore) | |
277 | + | if ((balanceDiff == balanceDiff)) | |
278 | + | then { | |
279 | + | let checkBalance = if ((balanceDiff == claimerUnclaimed)) | |
280 | + | then true | |
281 | + | else throwErr("insufficient balance on referral contract") | |
282 | + | if ((checkBalance == checkBalance)) | |
283 | + | then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed, 0), ScriptTransfer(addressFromStringValue(userAddressStr), claimerUnclaimed, rewardAssetId), StringEntry(keyClaimHistory(programName, userAddressStr, toBase58String(i.transactionId)), formatClaimHistory(claimerUnclaimed))], claimerUnclaimed) | |
284 | + | else throw("Strict value is not equal to itself.") | |
285 | + | } | |
261 | 286 | else throw("Strict value is not equal to itself.") | |
262 | 287 | } | |
263 | 288 | else throw("Strict value is not equal to itself.") | |
264 | 289 | } | |
265 | 290 | else throw("Strict value is not equal to itself.") | |
266 | 291 | } | |
267 | 292 | else throw("Strict value is not equal to itself.") | |
268 | 293 | } | |
269 | 294 | else throw("Strict value is not equal to itself.") | |
270 | 295 | } | |
271 | - | else throw("Strict value is not equal to itself.") | |
272 | 296 | } | |
273 | 297 | else throw("Strict value is not equal to itself.") | |
274 | 298 | } | |
275 | 299 | ||
276 | 300 | ||
277 | 301 | ||
278 | 302 | @Callable(i) | |
279 | 303 | func claimREADONLY (programName,userAddress) = { | |
280 | - | let claimerClaimed = valueOrElse(getInteger( | |
281 | - | let claimerUnclaimed = valueOrElse(getInteger( | |
304 | + | let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0) | |
305 | + | let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0) | |
282 | 306 | $Tuple2(nil, [claimerUnclaimed, claimerClaimed]) | |
283 | 307 | } | |
284 | 308 | ||
285 | 309 | ||
286 | 310 | ||
287 | 311 | @Callable(i) | |
288 | 312 | func setManager (pendingManagerPublicKey) = { | |
289 | 313 | let checkCaller = mustManager(i) | |
290 | 314 | if ((checkCaller == checkCaller)) | |
291 | 315 | then { | |
292 | 316 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
293 | 317 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
294 | 318 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
295 | 319 | else throw("Strict value is not equal to itself.") | |
296 | 320 | } | |
297 | 321 | else throw("Strict value is not equal to itself.") | |
298 | 322 | } | |
299 | 323 | ||
300 | 324 | ||
301 | 325 | ||
302 | 326 | @Callable(i) | |
303 | 327 | func confirmManager () = { | |
304 | 328 | let pm = pendingManagerPublicKeyOrUnit() | |
305 | 329 | let hasPM = if (isDefined(pm)) | |
306 | 330 | then true | |
307 | 331 | else throwErr("no pending manager") | |
308 | 332 | if ((hasPM == hasPM)) | |
309 | 333 | then { | |
310 | 334 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
311 | 335 | then true | |
312 | 336 | else throwErr("you are not pending manager") | |
313 | 337 | if ((checkPM == checkPM)) | |
314 | 338 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
315 | 339 | else throw("Strict value is not equal to itself.") | |
316 | 340 | } | |
317 | 341 | else throw("Strict value is not equal to itself.") | |
318 | 342 | } | |
319 | 343 | ||
320 | 344 | ||
321 | 345 | @Verifier(tx) | |
322 | 346 | func verify () = { | |
323 | 347 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
324 | 348 | case pk: ByteVector => | |
325 | 349 | pk | |
326 | 350 | case _: Unit => | |
327 | 351 | tx.senderPublicKey | |
328 | 352 | case _ => | |
329 | 353 | throw("Match error") | |
330 | 354 | } | |
331 | 355 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
332 | 356 | } | |
333 | 357 |
github/deemru/w8io/169f3d6 76.56 ms ◑