tx · Am3oFVqduApGqbqFD69xUD6qaeU5Zs5kNTZGWaAM971Y

3Mz1rmCZnkGe2yPbtNZ66VUTCDuT9zmPSJ7:  -0.00500000 Waves

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

{ "type": 13, "id": "Am3oFVqduApGqbqFD69xUD6qaeU5Zs5kNTZGWaAM971Y", "fee": 500000, "feeAssetId": null, "timestamp": 1678955713691, "version": 2, "chainId": 84, "sender": "3Mz1rmCZnkGe2yPbtNZ66VUTCDuT9zmPSJ7", "senderPublicKey": "5UpSa8WyDuRkZ5qCEUsadSLMBTDGRaFo1AKgUEfSFhUg", "proofs": [ "5S2rAFsv2kKUrbd1wCwYT6B3eGpJVrhs93jARBqXhHtKym94jVqSgg4Fo3BFaYzuhAkY6uLuuaCuDus11hYSWAfp" ], "script": null, "height": 2492340, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EahQEpZQQ7yUU7vQhuAU2QtA3cDezMP8LzEe3JssNrAB Next: 23yEVSSmBqsuH5bPdHLFC6rVfC3wifnVbZrB3hVkfkSA Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-let keyReferral = makeString(["%s", "referral"], SEP)
7-
8-let keyWxAssetId = makeString(["%s", "wxAssetId"], SEP)
9-
10-func keyManagerPublicKey () = "%s__managerPublicKey"
11-
12-
13-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
14-
15-
16-let IdxCfgClaimStartBlock = 1
17-
18-let IdxCfgClaimVestingPeriod = 2
19-
20-let IdxCfgClaimAssetId = 3
21-
22-let IdxCfgClaimAssetMult = 4
23-
24-let IdxCfgClaimAssetOwner = 5
25-
26-let IdxCfgClaimAssetTotalAmount = 6
27-
28-let IdxTotalsTotalClaimedAmount = 1
29-
30-let IdxTotalsRemainingAmount = 2
31-
32-let IdxTotalsLastClaimedHeight = 3
33-
34-func throwErr (msg) = throw(makeString(["marketing.ride:", msg], " "))
35-
36-
37-func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined"))
38-
39-
40-func formatConfigString (claimStartBlock,vestingPeriod,assetIdBase58,assetMult,assetOwner,assetTotalAmt) = makeString(["%d%d%s%d%s%d%", claimStartBlock, vestingPeriod, assetIdBase58, assetMult, assetOwner, assetTotalAmt], SEP)
41-
42-
43-func formatConfig (claimStartBlock,vestingPeriod,assetIdBase58,assetMult,claimAssetOwner,claimAssetTotalAmount) = formatConfigString(toString(claimStartBlock), toString(vestingPeriod), assetIdBase58, toString(assetMult), claimAssetOwner, toString(claimAssetTotalAmount))
44-
45-
46-func formatTotalsString (totalClaimedAmount,remainingAmountForClaim,lastClaimedHeight) = makeString(["%d%d%d", totalClaimedAmount, remainingAmountForClaim, lastClaimedHeight], SEP)
47-
48-
49-func formatHistoryRecord (claimedAssetAmount,claimingBlocks,firstCalulationBlock,lastCalulationBlock) = makeString(["%d%d%d%d%d%d", toString(height), toString(lastBlock.timestamp), toString(claimedAssetAmount), toString(claimingBlocks), toString(firstCalulationBlock), toString(lastCalulationBlock)], SEP)
50-
51-
52-func keyConfig () = "%s__config"
53-
54-
55-func keyTotals () = "%s__totals"
56-
57-
58-let keyAmountUnclaimed = makeString(["%s", "amountUnclaimed"], SEP)
59-
60-func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP)
61-
62-
63-func readConfigArray () = split(getStringOrFail(keyConfig()), SEP)
64-
65-
66-func readTotalsArray () = split(getStringOrFail(keyTotals()), SEP)
67-
68-
69-func TotalsEntry (key,origArray,claimedAmt,newLastClaimedHeight) = {
70- let totalClaimedAmount = parseIntValue(origArray[IdxTotalsTotalClaimedAmount])
71- let remainingAmount = parseIntValue(origArray[IdxTotalsRemainingAmount])
72- let lastClaimedHeight = parseIntValue(origArray[IdxTotalsLastClaimedHeight])
73- let newTotalClaimedAmount = (totalClaimedAmount + claimedAmt)
74- let newRemainingAmount = (remainingAmount - claimedAmt)
75- if ((0 > newRemainingAmount))
76- then throw("invalid math")
77- else StringEntry(key, formatTotalsString(toString(newTotalClaimedAmount), toString(newRemainingAmount), toString(newLastClaimedHeight)))
78- }
79-
80-
81-func ClaimOperationHistoryEntry (userAddress,claimedAssetAmount,claimingBlocks,firstCalculationBlock,lastCalculationBlock,txId) = StringEntry(keyOperationHistoryRecord("claim", userAddress, toBase58String(txId)), formatHistoryRecord(claimedAssetAmount, claimingBlocks, firstCalculationBlock, lastCalculationBlock))
82-
83-
84-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
85- case s: String =>
86- fromBase58String(s)
87- case _: Unit =>
88- unit
89- case _ =>
90- throw("Match error")
91-}
92-
93-
94-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
95- case s: String =>
96- fromBase58String(s)
97- case _: Unit =>
98- unit
99- case _ =>
100- throw("Match error")
101-}
102-
103-
104-func mustManager (i) = {
105- let pd = throwErr("permission denied")
106- match managerPublicKeyOrUnit() {
107- case pk: ByteVector =>
108- if ((i.callerPublicKey == pk))
109- then true
110- else pd
111- case _: Unit =>
112- if ((i.caller == this))
113- then true
114- else pd
115- case _ =>
116- throw("Match error")
117- }
118- }
119-
120-
121-func claimCommon (i,amount) = {
122- let cfgArray = readConfigArray()
123- let cfgClaimStartHeight = parseIntValue(cfgArray[IdxCfgClaimStartBlock])
124- let cfgClaimDuration = parseIntValue(cfgArray[IdxCfgClaimVestingPeriod])
125- let cfgClaimEnd = (cfgClaimStartHeight + cfgClaimDuration)
126- let cfgClaimAssetId = fromBase58String(cfgArray[IdxCfgClaimAssetId])
127- let cfgClaimAssetOwner = addressFromStringValue(cfgArray[IdxCfgClaimAssetOwner])
128- let cfgClaimAssetTotalAmount = parseIntValue(cfgArray[IdxCfgClaimAssetTotalAmount])
129- let origTotalsArray = readTotalsArray()
130- let totalClaimedAmount = parseIntValue(origTotalsArray[IdxTotalsTotalClaimedAmount])
131- let totalRemainingAmount = parseIntValue(origTotalsArray[IdxTotalsRemainingAmount])
132- let lastClaimedHeight = parseIntValue(origTotalsArray[IdxTotalsLastClaimedHeight])
133- if ((i.caller != cfgClaimAssetOwner))
134- then throw("permissions denied")
135- else if ((cfgClaimStartHeight > height))
136- then throw(("Wait claim start block: " + toString(cfgClaimStartHeight)))
137- else {
138- let lastCalulationBlock = if ((height > cfgClaimEnd))
139- then cfgClaimEnd
140- else height
141- let firstCalulationBlock = if ((lastClaimedHeight == 0))
142- then cfgClaimStartHeight
143- else lastClaimedHeight
144- let claimingBlocks = (lastCalulationBlock - firstCalulationBlock)
145- let amountAvailable = fraction(cfgClaimAssetTotalAmount, claimingBlocks, cfgClaimDuration)
146- let amountUnclaimed = valueOrElse(getInteger(this, keyAmountUnclaimed), 0)
147- let amountAvailableTotal = (amountAvailable + amountUnclaimed)
148- let amountToClaim = if (if ((0 >= amount))
149- then true
150- else (amount >= amountAvailableTotal))
151- then amountAvailableTotal
152- else amount
153- let amountUnclaimedNew = (amountAvailableTotal - amountToClaim)
154- $Tuple2([IntegerEntry(keyAmountUnclaimed, amountUnclaimedNew), ScriptTransfer(cfgClaimAssetOwner, amountToClaim, cfgClaimAssetId), TotalsEntry(keyTotals(), readTotalsArray(), amountToClaim, lastCalulationBlock), ClaimOperationHistoryEntry(toString(cfgClaimAssetOwner), amountToClaim, claimingBlocks, firstCalulationBlock, lastCalulationBlock, i.transactionId)], amountToClaim)
155- }
156- }
157-
158-
159-@Callable(i)
160-func constructor (claimStartBlock,vestingPeriodBlocks,beneficiaryAddress) = {
161- let vestingEnd = (claimStartBlock + vestingPeriodBlocks)
162- if (isDefined(getString(keyConfig())))
163- then throw("already initialized")
164- else if ((size(i.payments) != 1))
165- then throw("exactly 1 payment must be attached")
166- else if ((i.callerPublicKey != base58'2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq'))
167- then throw("not authorized")
168- else {
169- let beneficiaryAddressParsed = valueOrErrorMessage(addressFromString(beneficiaryAddress), "Invalid beneficiarAddress passed")
170- let pmt = value(i.payments[0])
171- let claimAssetId = value(pmt.assetId)
172- let claimAssetInfo = valueOrErrorMessage(assetInfo(claimAssetId), "fail to load ido asset info")
173- let claimAssetId58 = toBase58String(claimAssetId)
174- let claimAssetMult = pow(10, 0, claimAssetInfo.decimals, 0, 0, DOWN)
175- let claimAssetAmount = pmt.amount
176-[StringEntry(keyConfig(), formatConfig(claimStartBlock, vestingPeriodBlocks, claimAssetId58, claimAssetMult, toString(beneficiaryAddressParsed), claimAssetAmount)), StringEntry(keyTotals(), formatTotalsString("0", toString(claimAssetAmount), "0"))]
177- }
178- }
179-
180-
181-
182-@Callable(i)
183-func claimAmount (amount) = claimCommon(i, amount)
184-
185-
186-
187-@Callable(i)
188-func claim () = claimCommon(i, -1)
189-
190-
191-
192-@Callable(i)
193-func withdrawReferralReward (wxAmount) = {
194- let referralContractAddress = value(getString(keyReferral))
195- let mustReferral = if ((toString(i.caller) == referralContractAddress))
196- then true
197- else throwErr("permission denied")
198- if ((mustReferral == mustReferral))
199- then {
200- let wxAssetId = fromBase58String(value(getString(keyWxAssetId)))
201- $Tuple2([ScriptTransfer(i.caller, wxAmount, wxAssetId), ClaimOperationHistoryEntry(referralContractAddress, wxAmount, 0, 0, 0, i.transactionId)], unit)
202- }
203- else throw("Strict value is not equal to itself.")
204- }
205-
206-
207-
208-@Callable(i)
209-func setManager (pendingManagerPublicKey) = {
210- let checkCaller = mustManager(i)
211- if ((checkCaller == checkCaller))
212- then {
213- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
214- if ((checkManagerPublicKey == checkManagerPublicKey))
215- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
216- else throw("Strict value is not equal to itself.")
217- }
218- else throw("Strict value is not equal to itself.")
219- }
220-
221-
222-
223-@Callable(i)
224-func confirmManager () = {
225- let pm = pendingManagerPublicKeyOrUnit()
226- let hasPM = if (isDefined(pm))
227- then true
228- else throwErr("no pending manager")
229- if ((hasPM == hasPM))
230- then {
231- let checkPM = if ((i.callerPublicKey == value(pm)))
232- then true
233- else throwErr("you are not pending manager")
234- if ((checkPM == checkPM))
235- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
236- else throw("Strict value is not equal to itself.")
237- }
238- else throw("Strict value is not equal to itself.")
239- }
240-
241-
242-@Verifier(tx)
243-func verify () = {
244- let targetPublicKey = match managerPublicKeyOrUnit() {
245- case pk: ByteVector =>
246- pk
247- case _: Unit =>
248- tx.senderPublicKey
249- case _ =>
250- throw("Match error")
251- }
252- sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
253- }
254-
1+# no script

github/deemru/w8io/169f3d6 
35.72 ms