tx · 8bP27cBvTuTg9QpT89hwg1XT8wCrn9f3rau2sSm1eDiQ

3Mz7AZHqAeMecF7aaE9HVsK94XVQKf1QCKg:  -0.01400000 Waves

2022.03.11 17:01 [1959379] smart account 3Mz7AZHqAeMecF7aaE9HVsK94XVQKf1QCKg > SELF 0.00000000 Waves

{ "type": 13, "id": "8bP27cBvTuTg9QpT89hwg1XT8wCrn9f3rau2sSm1eDiQ", "fee": 1400000, "feeAssetId": null, "timestamp": 1647007342122, "version": 1, "sender": "3Mz7AZHqAeMecF7aaE9HVsK94XVQKf1QCKg", "senderPublicKey": "9o6mYaNcbcTi647J8XhDQg2VsHJCv5Jon1QFPCbFPoFh", "proofs": [ "53xgWo7yFbP97gM7nsyfcSMKR9B1Ci4iwCAL919LgHS4WRuanUD1Ay5JGyqEdm9Na1BxmHvkRvU9EKooRMTWsRKq" ], "script": "base64:AAIFAAAAAAAAABcIAhIFCgMBAQgSABIDCgEIEgMKAQgSAAAAABIBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABQlc19fbWFuYWdlclB1YmxpY0tleQEAAAAaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAAAACXNlcGFyYXRvcgIAAAACX18BAAAAD2dldFN0cmluZ09yRmFpbAAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAKbWFuZGF0b3J5IAkABCUAAAABBQAAAAdhZGRyZXNzAgAAAAEuBQAAAANrZXkCAAAADyBpcyBub3QgZGVmaW5lZAAAAAAIa2V5U3RhcnQJAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAAAVzdGFydAUAAAADbmlsBQAAAAlzZXBhcmF0b3IAA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m1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAJwawUAAAAHJG1hdGNoMAUAAAACcGsDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA90YXJnZXRQdWJsaWNLZXmx4s+t", "chainId": 84, "height": 1959379, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FJpctF1YcHbZMrtBTDWsD1Bw9rzggSVn4Z6BST5erE9k Next: BftZoJ9A1HJVoXugiK3WneSojGCKKXCpRGr318jUfmY6 Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+func keyManagerPublicKey () = "%s__managerPublicKey"
5+
6+
7+func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
8+
9+
410 let separator = "__"
511
612 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
4955 }
5056
5157
58+func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
59+ case s: String =>
60+ fromBase58String(s)
61+ case _: Unit =>
62+ unit
63+ case _ =>
64+ throw("Match error")
65+}
66+
67+
68+func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
69+ case s: String =>
70+ fromBase58String(s)
71+ case _: Unit =>
72+ unit
73+ case _ =>
74+ throw("Match error")
75+}
76+
77+
78+func mustManager (i) = {
79+ let pd = throw("Permission denied")
80+ match managerPublicKeyOrUnit() {
81+ case pk: ByteVector =>
82+ if ((i.callerPublicKey == pk))
83+ then true
84+ else pd
85+ case _: Unit =>
86+ if ((i.caller == this))
87+ then true
88+ else pd
89+ case _ =>
90+ throw("Match error")
91+ }
92+ }
93+
94+
5295 @Callable(i)
5396 func constructor (start,duration,assetId) = {
54- let checks = [if ((i.caller == this))
55- then true
56- else throw("Access denied")]
57- if ((checks == checks))
97+ let checkCaller = mustManager(i)
98+ if ((checkCaller == checkCaller))
5899 then [IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), StringEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)]
59100 else throw("Strict value is not equal to itself.")
60101 }
63104
64105 @Callable(i)
65106 func claim () = {
66- let $t024322491 = getUserRewards(i.caller)
67- let total = $t024322491._1
68- let claimed = $t024322491._2
69- let available = $t024322491._3
107+ let $t030183077 = getUserRewards(i.caller)
108+ let total = $t030183077._1
109+ let claimed = $t030183077._2
110+ let available = $t030183077._3
70111 let asset = fromBase58String(getStringOrFail(this, keyAsset))
71112 let balance = assetBalance(this, asset)
72113 let checks = [checkIfDataIsReady(), if ((available > 0))
86127 let checks = [checkIfDataIsReady()]
87128 if ((checks == checks))
88129 then {
89- let $t031703253 = getUserRewards(addressFromStringValue(address))
90- let total = $t031703253._1
91- let claimed = $t031703253._2
92- let available = $t031703253._3
130+ let $t037563839 = getUserRewards(addressFromStringValue(address))
131+ let total = $t037563839._1
132+ let claimed = $t037563839._2
133+ let available = $t037563839._3
93134 $Tuple2(nil, makeString(["%d%d%d", toString(total), toString(claimed), toString(available)], separator))
94135 }
95136 else throw("Strict value is not equal to itself.")
96137 }
97138
98139
140+
141+@Callable(i)
142+func setManager (pendingManagerPublicKey) = {
143+ let checkCaller = mustManager(i)
144+ if ((checkCaller == checkCaller))
145+ then {
146+ let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
147+ if ((checkManagerPublicKey == checkManagerPublicKey))
148+ then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
149+ else throw("Strict value is not equal to itself.")
150+ }
151+ else throw("Strict value is not equal to itself.")
152+ }
153+
154+
155+
156+@Callable(i)
157+func confirmManager () = {
158+ let pm = pendingManagerPublicKeyOrUnit()
159+ let hasPM = if (isDefined(pm))
160+ then true
161+ else throw("No pending manager")
162+ if ((hasPM == hasPM))
163+ then {
164+ let checkPM = if ((i.callerPublicKey == value(pm)))
165+ then true
166+ else throw("You are not pending manager")
167+ if ((checkPM == checkPM))
168+ then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
169+ else throw("Strict value is not equal to itself.")
170+ }
171+ else throw("Strict value is not equal to itself.")
172+ }
173+
174+
175+@Verifier(tx)
176+func verify () = {
177+ let targetPublicKey = match managerPublicKeyOrUnit() {
178+ case pk: ByteVector =>
179+ pk
180+ case _: Unit =>
181+ tx.senderPublicKey
182+ case _ =>
183+ throw("Match error")
184+ }
185+ sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
186+ }
187+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+func keyManagerPublicKey () = "%s__managerPublicKey"
5+
6+
7+func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
8+
9+
410 let separator = "__"
511
612 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
713
814
915 let keyStart = makeString(["%s", "start"], separator)
1016
1117 let keyDuration = makeString(["%s", "duration"], separator)
1218
1319 let keyAsset = makeString(["%s", "asset"], separator)
1420
1521 let keyIsDataReady = makeString(["%s", "isDataReady"], separator)
1622
1723 func keyUserRewardInfo (address) = makeString(["%s%s", "userRewardInfo", toString(address)], separator)
1824
1925
2026 func keyClaimHistoryRecord (address,txId) = makeString(["%s%s%s", "claimHistoryRecord", toString(address), toBase58String(txId)], separator)
2127
2228
2329 func formatHistoryRecord (amount) = makeString(["%d%d%d", toString(height), toString(lastBlock.timestamp), toString(amount)], separator)
2430
2531
2632 func dataUserRewardInfo (totalAmt,claimedAmt) = makeString(["%d%d", toString(totalAmt), toString(claimedAmt)], separator)
2733
2834
2935 func readUserRewardInfo (userAddr) = split(getStringOrFail(this, keyUserRewardInfo(userAddr)), separator)
3036
3137
3238 func checkIfDataIsReady () = {
3339 let isDataReady = valueOrElse(getBoolean(this, keyIsDataReady), false)
3440 if (isDataReady)
3541 then true
3642 else throw("Data is not ready")
3743 }
3844
3945
4046 func getUserRewards (address) = {
4147 let start = valueOrErrorMessage(getInteger(this, keyStart), "Start block is not specified")
4248 let duration = valueOrErrorMessage(getInteger(this, keyDuration), "Duration is not specified")
4349 let userRewardInfo = readUserRewardInfo(address)
4450 let total = parseIntValue(userRewardInfo[1])
4551 let claimed = parseIntValue(userRewardInfo[2])
4652 let availableTotal = fraction(total, min([duration, max([0, (height - start)])]), duration)
4753 let available = max([0, (availableTotal - claimed)])
4854 $Tuple3(total, claimed, available)
4955 }
5056
5157
58+func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
59+ case s: String =>
60+ fromBase58String(s)
61+ case _: Unit =>
62+ unit
63+ case _ =>
64+ throw("Match error")
65+}
66+
67+
68+func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
69+ case s: String =>
70+ fromBase58String(s)
71+ case _: Unit =>
72+ unit
73+ case _ =>
74+ throw("Match error")
75+}
76+
77+
78+func mustManager (i) = {
79+ let pd = throw("Permission denied")
80+ match managerPublicKeyOrUnit() {
81+ case pk: ByteVector =>
82+ if ((i.callerPublicKey == pk))
83+ then true
84+ else pd
85+ case _: Unit =>
86+ if ((i.caller == this))
87+ then true
88+ else pd
89+ case _ =>
90+ throw("Match error")
91+ }
92+ }
93+
94+
5295 @Callable(i)
5396 func constructor (start,duration,assetId) = {
54- let checks = [if ((i.caller == this))
55- then true
56- else throw("Access denied")]
57- if ((checks == checks))
97+ let checkCaller = mustManager(i)
98+ if ((checkCaller == checkCaller))
5899 then [IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), StringEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)]
59100 else throw("Strict value is not equal to itself.")
60101 }
61102
62103
63104
64105 @Callable(i)
65106 func claim () = {
66- let $t024322491 = getUserRewards(i.caller)
67- let total = $t024322491._1
68- let claimed = $t024322491._2
69- let available = $t024322491._3
107+ let $t030183077 = getUserRewards(i.caller)
108+ let total = $t030183077._1
109+ let claimed = $t030183077._2
110+ let available = $t030183077._3
70111 let asset = fromBase58String(getStringOrFail(this, keyAsset))
71112 let balance = assetBalance(this, asset)
72113 let checks = [checkIfDataIsReady(), if ((available > 0))
73114 then true
74115 else throw("No reward available"), if ((balance >= available))
75116 then true
76117 else throw("Insufficient funds. Contact support")]
77118 if ((checks == checks))
78119 then [ScriptTransfer(i.caller, available, asset), StringEntry(keyUserRewardInfo(i.caller), dataUserRewardInfo(total, (claimed + available))), StringEntry(keyClaimHistoryRecord(i.caller, i.transactionId), formatHistoryRecord(available))]
79120 else throw("Strict value is not equal to itself.")
80121 }
81122
82123
83124
84125 @Callable(i)
85126 func getUserRewardsREADONLY (address) = {
86127 let checks = [checkIfDataIsReady()]
87128 if ((checks == checks))
88129 then {
89- let $t031703253 = getUserRewards(addressFromStringValue(address))
90- let total = $t031703253._1
91- let claimed = $t031703253._2
92- let available = $t031703253._3
130+ let $t037563839 = getUserRewards(addressFromStringValue(address))
131+ let total = $t037563839._1
132+ let claimed = $t037563839._2
133+ let available = $t037563839._3
93134 $Tuple2(nil, makeString(["%d%d%d", toString(total), toString(claimed), toString(available)], separator))
94135 }
95136 else throw("Strict value is not equal to itself.")
96137 }
97138
98139
140+
141+@Callable(i)
142+func setManager (pendingManagerPublicKey) = {
143+ let checkCaller = mustManager(i)
144+ if ((checkCaller == checkCaller))
145+ then {
146+ let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
147+ if ((checkManagerPublicKey == checkManagerPublicKey))
148+ then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
149+ else throw("Strict value is not equal to itself.")
150+ }
151+ else throw("Strict value is not equal to itself.")
152+ }
153+
154+
155+
156+@Callable(i)
157+func confirmManager () = {
158+ let pm = pendingManagerPublicKeyOrUnit()
159+ let hasPM = if (isDefined(pm))
160+ then true
161+ else throw("No pending manager")
162+ if ((hasPM == hasPM))
163+ then {
164+ let checkPM = if ((i.callerPublicKey == value(pm)))
165+ then true
166+ else throw("You are not pending manager")
167+ if ((checkPM == checkPM))
168+ then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
169+ else throw("Strict value is not equal to itself.")
170+ }
171+ else throw("Strict value is not equal to itself.")
172+ }
173+
174+
175+@Verifier(tx)
176+func verify () = {
177+ let targetPublicKey = match managerPublicKeyOrUnit() {
178+ case pk: ByteVector =>
179+ pk
180+ case _: Unit =>
181+ tx.senderPublicKey
182+ case _ =>
183+ throw("Match error")
184+ }
185+ sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
186+ }
187+

github/deemru/w8io/169f3d6 
37.88 ms