tx · 3bxkt9uVJ92kKFEPq6sbKpmyHkhRRxv8CUrVA1xVcmry 3NA9xYDGdvJqFhDhHXHLJGF2E6Bf5QecsYj: -0.00400000 Waves 2022.09.01 12:45 [2209904] smart account 3NA9xYDGdvJqFhDhHXHLJGF2E6Bf5QecsYj > SELF 0.00000000 Waves
{ "type": 13, "id": "3bxkt9uVJ92kKFEPq6sbKpmyHkhRRxv8CUrVA1xVcmry", "fee": 400000, "feeAssetId": null, "timestamp": 1662025549202, "version": 2, "chainId": 84, "sender": "3NA9xYDGdvJqFhDhHXHLJGF2E6Bf5QecsYj", "senderPublicKey": "Bu66gGmMgQxzUMY1KcrehvPCGi3akZhLZdVNzL4bdn99", "proofs": [ "tauDoHMk92yf9oSQg3pqbPsaPAyr4d93KFWEL6Wn2mVWYUVuSgMmPegqdwSjye6rvtkSKLqgpUdv15NVzhHTpok" ], "script": "base64:BgIdCAISAwoBCBIECgIIARIDCgEIEgQKAggBEgMKAQEQARR0cnlHZXRTdHJpbmdFeHRlcm5hbAIHYWRkcmVzcwNrZXkEByRtYXRjaDAJAJ0IAgUHYWRkcmVzcwUDa2V5AwkAAQIFByRtYXRjaDACBlN0cmluZwQBYQUHJG1hdGNoMAUBYQIAAQx0cnlHZXRTdHJpbmcBA2tleQkBFHRyeUdldFN0cmluZ0V4dGVybmFsAgUEdGhpcwUDa2V5AQ10cnlHZXRJbnRlZ2VyAQNrZXkEByRtYXRjaDAJAJoIAgUEdGhpcwUDa2V5AwkAAQIFByRtYXRjaDACA0ludAQBYgUHJG1hdGNoMAUBYgAAAQlnZXRPcmFjbGUACQEHQWRkcmVzcwEJANkEAQkBDHRyeUdldFN0cmluZwECFHN0YXRpY19vcmFjbGVBZGRyZXNzARFnZXRSZWJpcnRoQWRkcmVzcwAJAQdBZGRyZXNzAQkA2QQBCQEUdHJ5R2V0U3RyaW5nRXh0ZXJuYWwCCQEJZ2V0T3JhY2xlAAIVc3RhdGljX3JlYmlydGhBZGRyZXNzARNnZXRJbmN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NlcgQKdG90YWxTcGVuZAkAZAIJAQ10cnlHZXRJbnRlZ2VyAQUIa2V5U3BlbmQFCmFtb3VudFBhaWQJAJQKAgkAzAgCCQEMSW50ZWdlckVudHJ5AgUIa2V5U3BlbmQFCnRvdGFsU3BlbmQJAMwIAgkBDEludGVnZXJFbnRyeQIFBmtleU9sZAUQYXZhaWxhYmxlQ291cG9ucwkAzAgCCQEMSW50ZWdlckVudHJ5AgUJa2V5QWN0aXZlBRRhdmFpbGFibGVDb3Vwb25zTGVmdAUDbmlsBQphbW91bnRQYWlkAErpA08=", "height": 2209904, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | func tryGetStringExternal (address,key) = match getString(address, key) { | |
5 | + | case a: String => | |
6 | + | a | |
7 | + | case _ => | |
8 | + | "" | |
9 | + | } | |
10 | + | ||
11 | + | ||
12 | + | func tryGetString (key) = tryGetStringExternal(this, key) | |
13 | + | ||
14 | + | ||
15 | + | func tryGetInteger (key) = match getInteger(this, key) { | |
16 | + | case b: Int => | |
17 | + | b | |
18 | + | case _ => | |
19 | + | 0 | |
20 | + | } | |
21 | + | ||
22 | + | ||
23 | + | func getOracle () = Address(fromBase58String(tryGetString("static_oracleAddress"))) | |
24 | + | ||
25 | + | ||
26 | + | func getRebirthAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_rebirthAddress"))) | |
27 | + | ||
28 | + | ||
29 | + | func getIncubatorAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_incubatorAddress"))) | |
30 | + | ||
31 | + | ||
32 | + | func getFarmingAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_farmingAddress"))) | |
33 | + | ||
34 | + | ||
35 | + | func getGameDappAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_gameDappAddress"))) | |
36 | + | ||
37 | + | ||
38 | + | func getBurnAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_burnAddress"))) | |
39 | + | ||
40 | + | ||
41 | + | func getMasterAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_cfMasterAddress"))) | |
42 | + | ||
43 | + | ||
44 | + | let wAccPKey = fromBase58String(valueOrErrorMessage(getString(getOracle(), "static_warsPKey"), "static_warsPKey not defined")) | |
45 | + | ||
46 | + | let scCanUseCoupons = [getRebirthAddress(), getIncubatorAddress(), getFarmingAddress(), getGameDappAddress()] | |
47 | + | ||
48 | + | func couponsUserSpend (user) = (user + "_spend") | |
49 | + | ||
50 | + | ||
51 | + | func couponsUserActive (user) = (user + "_active") | |
52 | + | ||
53 | + | ||
54 | + | func couponsUserActiveOld (user) = (couponsUserActive(user) + "_old") | |
55 | + | ||
56 | + | ||
57 | + | func addCouponsInternal (user,amount) = { | |
58 | + | let keyOld = couponsUserActiveOld(user) | |
59 | + | let key = couponsUserActive(user) | |
60 | + | let couponsOld = tryGetInteger(key) | |
61 | + | let coupons = (couponsOld + amount) | |
62 | + | [IntegerEntry(keyOld, couponsOld), IntegerEntry(key, coupons)] | |
63 | + | } | |
64 | + | ||
65 | + | ||
66 | + | @Callable(i) | |
67 | + | func configureOracle (oracle) = if ((i.caller != this)) | |
68 | + | then throw("CCO: admin only") | |
69 | + | else [StringEntry("static_oracleAddress", oracle)] | |
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | @Callable(i) | |
74 | + | func addCoupons (user,amount) = if (if ((i.caller != this)) | |
75 | + | then (i.callerPublicKey != wAccPKey) | |
76 | + | else false) | |
77 | + | then throw("CAC: admin only") | |
78 | + | else addCouponsInternal(user, amount) | |
79 | + | ||
80 | + | ||
81 | + | ||
82 | + | @Callable(i) | |
83 | + | func addCouponsBatch (batch) = if (if ((i.caller != this)) | |
84 | + | then (i.callerPublicKey != wAccPKey) | |
85 | + | else false) | |
86 | + | then throw("CAC: admin only") | |
87 | + | else { | |
88 | + | let couponsList = split(batch, ";") | |
89 | + | func handleCoupon (acc,coupon) = { | |
90 | + | let splitArray = split(coupon, ":") | |
91 | + | let user = splitArray[0] | |
92 | + | let amount = parseIntValue(splitArray[1]) | |
93 | + | let burnCall = invoke(getBurnAddress(), "burnByInvoke", [amount], nil) | |
94 | + | if ((burnCall == burnCall)) | |
95 | + | then (acc ++ addCouponsInternal(user, amount)) | |
96 | + | else throw("Strict value is not equal to itself.") | |
97 | + | } | |
98 | + | ||
99 | + | let $l = couponsList | |
100 | + | let $s = size($l) | |
101 | + | let $acc0 = nil | |
102 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
103 | + | then $a | |
104 | + | else handleCoupon($a, $l[$i]) | |
105 | + | ||
106 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
107 | + | then $a | |
108 | + | else throw("List size exceeds 20") | |
109 | + | ||
110 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) | |
111 | + | } | |
112 | + | ||
113 | + | ||
114 | + | ||
115 | + | @Callable(i) | |
116 | + | func CFRefund (recipient,amount) = { | |
117 | + | let cfAddress = getStringValue(i.caller, "CF_ADDRESS") | |
118 | + | let key = (("f_" + cfAddress) + "_stake_address") | |
119 | + | let stakeAddress = getStringValue(getMasterAddress(), key) | |
120 | + | if ((stakeAddress != toString(i.caller))) | |
121 | + | then throw("CCR: This is something fishy going on!") | |
122 | + | else addCouponsInternal(recipient, amount) | |
123 | + | } | |
124 | + | ||
125 | + | ||
126 | + | ||
127 | + | @Callable(i) | |
128 | + | func useCoupons (amountTryingToPay) = { | |
129 | + | let invokingSc = i.caller | |
130 | + | if ((0 > amountTryingToPay)) | |
131 | + | then throw("CUC: Only positive amount of money can be paid!") | |
132 | + | else if (!(containsElement(scCanUseCoupons, invokingSc))) | |
133 | + | then throw("CUC: Only certain smart contracts can use this coupon module!") | |
134 | + | else { | |
135 | + | let user = toString(i.originCaller) | |
136 | + | let keyActive = couponsUserActive(user) | |
137 | + | let availableCoupons = tryGetInteger(keyActive) | |
138 | + | let leftToPay = if ((amountTryingToPay > availableCoupons)) | |
139 | + | then (amountTryingToPay - availableCoupons) | |
140 | + | else 0 | |
141 | + | let amountPaid = (amountTryingToPay - leftToPay) | |
142 | + | let availableCouponsLeft = (availableCoupons - amountPaid) | |
143 | + | let keySpend = couponsUserSpend(user) | |
144 | + | let keyOld = couponsUserActiveOld(user) | |
145 | + | let totalSpend = (tryGetInteger(keySpend) + amountPaid) | |
146 | + | $Tuple2([IntegerEntry(keySpend, totalSpend), IntegerEntry(keyOld, availableCoupons), IntegerEntry(keyActive, availableCouponsLeft)], amountPaid) | |
147 | + | } | |
148 | + | } | |
149 | + | ||
150 | + |
github/deemru/w8io/026f985 17.16 ms ◑