tx · TjfgTYai7owBHDRzmi5Fh6KJtqCpDLEwZ99jF3e7oqR

3MqwMMLF42yF6Vz4oCJhUwUJ311vwpobAn8:  -0.00500000 Waves

2023.03.16 13:54 [2492487] smart account 3MqwMMLF42yF6Vz4oCJhUwUJ311vwpobAn8 > SELF 0.00000000 Waves

{ "type": 13, "id": "TjfgTYai7owBHDRzmi5Fh6KJtqCpDLEwZ99jF3e7oqR", "fee": 500000, "feeAssetId": null, "timestamp": 1678964164605, "version": 2, "chainId": 84, "sender": "3MqwMMLF42yF6Vz4oCJhUwUJ311vwpobAn8", "senderPublicKey": "dHg6is3pE1esJhncQ3dDmzhZXxdD1DgonKQzRPkTHUF", "proofs": [ "24Bst7PWzC2evB4MB55hGZvmg2jiVXowiRwtcUK3tR1bdZvqTEDaWfmcenFKYFp5vUofuiBwNG3TudXQp3NJfpkK" ], "script": null, "height": 2492487, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: hjPAYAzNxzALyxWTWUFECt5JhwWJqCeTcsp1wxcyqFg Next: HYVLE8qhbpmr7DUgqgmpPmfnNF8ViaKKbMs8xhNefSLs Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-let EMPTY = ""
7-
8-let statusVerified = 2
9-
10-let statusUnverified = 0
11-
12-let labelCommunityVerified = "COMMUNITY_VERIFIED"
13-
14-let labelPoolsLp = "POOLS_LP"
15-
16-let defaultLabels = [labelCommunityVerified, labelPoolsLp]
17-
18-func throwPD () = throw("Permission denied")
19-
20-
21-func throwNoAsset () = throw("Asset doesn't exists")
22-
23-
24-func keyManagerPublicKey () = "%s__managerPublicKey"
25-
26-
27-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
28-
29-
30-func keyAdminPubKeys () = "%s__adminPubKeys"
31-
32-
33-func keyUserPoolsContract () = "%s__userPoolsContract"
34-
35-
36-func keyFactoryContract () = "%s__factoryContract"
37-
38-
39-func keyCreated (assetId) = (("created_<" + assetId) + ">")
40-
41-
42-func keyLogo (assetId) = (("logo_<" + assetId) + ">")
43-
44-
45-func keyTicker (assetId) = (("ticker_<" + assetId) + ">")
46-
47-
48-func keyStatus (assetId) = (("status_<" + assetId) + ">")
49-
50-
51-func keyAssetPoolsNumber (assetId) = makeString(["%s%s", "pools", assetId], SEP)
52-
53-
54-func keyTickerToAssetId (ticker) = makeString(["%s%s", "ticker2assetId", ticker], SEP)
55-
56-
57-func keyAssetIdToTicker (assetId) = makeString(["%s%s", "assetId2ticker", assetId], SEP)
58-
59-
60-func keyAmountAndPriceAssetsToLpAsset (amountAsset,priceAsset) = makeString(["%s%s%s", "amountAndPriceAssetsToLpAsset", amountAsset, priceAsset], SEP)
61-
62-
63-func keyLpAssetToAmountAndPriceAssets (lpAsset) = makeString(["%s%s", "lpAssetToAmountAndPriceAssets", lpAsset], SEP)
64-
65-
66-func keyAssetLabels (assetId) = makeString(["%s%s", "labels", assetId], SEP)
67-
68-
69-func keyLabels () = makeString(["%s", "labels"], SEP)
70-
71-
72-func keyAssetName (assetId) = makeString(["%s%s", "assetName", assetId], SEP)
73-
74-
75-func keyAssetDescription (assetId) = makeString(["%s%s", "assetDescription", assetId], SEP)
76-
77-
78-func getValueOrFail (address,key,type) = {
79- let error = makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")
80- valueOrErrorMessage( match type {
81- case str: String =>
82- getString(address, key)
83- case int: Int =>
84- getInteger(address, key)
85- case _ =>
86- throw("invalid entry type")
87- }, error)
88- }
89-
90-
91-func getStrOrFail (address,key) = {
92- let @ = getValueOrFail(address, key, "")
93- if ($isInstanceOf(@, "String"))
94- then @
95- else throw("Couldn't cast Int|String to String")
96- }
97-
98-
99-func getIntOrFail (address,key) = {
100- let @ = getValueOrFail(address, key, 0)
101- if ($isInstanceOf(@, "Int"))
102- then @
103- else throw("Couldn't cast Int|String to Int")
104- }
105-
106-
107-func isVerified (assetId) = (valueOrElse(getInteger(keyStatus(assetId)), statusUnverified) == statusVerified)
108-
109-
110-func getLabels () = match getString(keyLabels()) {
111- case s: String =>
112- if ((size(s) == 0))
113- then nil
114- else split(s, SEP)
115- case _ =>
116- nil
117-}
118-
119-
120-func getAssetLabels (assetId) = match getString(keyAssetLabels(assetId)) {
121- case s: String =>
122- if ((size(s) == 0))
123- then nil
124- else split(s, SEP)
125- case _ =>
126- nil
127-}
128-
129-
130-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
131- case s: String =>
132- fromBase58String(s)
133- case _: Unit =>
134- unit
135- case _ =>
136- throw("Match error")
137-}
138-
139-
140-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
141- case s: String =>
142- fromBase58String(s)
143- case _: Unit =>
144- unit
145- case _ =>
146- throw("Match error")
147-}
148-
149-
150-func mustManager (i) = match managerPublicKeyOrUnit() {
151- case pk: ByteVector =>
152- if ((i.callerPublicKey == pk))
153- then true
154- else throwPD()
155- case _: Unit =>
156- if ((i.caller == this))
157- then true
158- else throwPD()
159- case _ =>
160- throw("Match error")
161-}
162-
163-
164-func mustAdmin (i) = {
165- let adminPKs = split(valueOrElse(getString(keyAdminPubKeys()), EMPTY), SEP)
166- if (containsElement(adminPKs, toBase58String(i.callerPublicKey)))
167- then true
168- else {
169- let isManager = mustManager(i)
170- if ((isManager == isManager))
171- then true
172- else throw("Strict value is not equal to itself.")
173- }
174- }
175-
176-
177-func isCreated (assetId) = valueOrElse(getBoolean(keyCreated(assetId)), false)
178-
179-
180-func verifiedToStatus (verified) = if (verified)
181- then statusVerified
182- else statusUnverified
183-
184-
185-func addLabelActions (assetId,label,throwOnError) = {
186- let labels = getLabels()
187- let assetLabels = getAssetLabels(assetId)
188- let checkLabel = if (containsElement(labels, label))
189- then true
190- else throw("Label doesn't exist")
191- if ((checkLabel == checkLabel))
192- then {
193- let newAssetLabels = if (containsElement(assetLabels, label))
194- then if (throwOnError)
195- then throw("Label has already been added")
196- else assetLabels
197- else (assetLabels :+ label)
198-[StringEntry(keyAssetLabels(assetId), makeString(newAssetLabels, SEP))]
199- }
200- else throw("Strict value is not equal to itself.")
201- }
202-
203-
204-func deleteLabelActions (assetId,label,throwOnError) = {
205- let assetLabels = getAssetLabels(assetId)
206- let newAssetLabels = if (containsElement(assetLabels, label))
207- then removeByIndex(assetLabels, value(indexOf(assetLabels, label)))
208- else if (throwOnError)
209- then throw("Label wasn't added")
210- else assetLabels
211-[StringEntry(keyAssetLabels(assetId), makeString(newAssetLabels, SEP))]
212- }
213-
214-
215-func setVerifiedActions (assetId,verified) = {
216- let labelCommunityVerifiedActions = if (verified)
217- then addLabelActions(assetId, labelCommunityVerified, false)
218- else deleteLabelActions(assetId, labelCommunityVerified, false)
219- ([IntegerEntry(keyStatus(assetId), verifiedToStatus(verified))] ++ labelCommunityVerifiedActions)
220- }
221-
222-
223-func updateTickerActions (assetId,ticker) = {
224- let checkTicker = {
225- let linkedAssetIdOrUnit = getString(keyTickerToAssetId(ticker))
226- let tickerIsValid = if ((ticker != ""))
227- then if ((linkedAssetIdOrUnit == unit))
228- then true
229- else (value(linkedAssetIdOrUnit) == assetId)
230- else false
231- if (tickerIsValid)
232- then true
233- else throw("Invalid ticker")
234- }
235- if ((checkTicker == checkTicker))
236- then [StringEntry(keyAssetIdToTicker(assetId), ticker), StringEntry(keyTickerToAssetId(ticker), assetId)]
237- else throw("Strict value is not equal to itself.")
238- }
239-
240-
241-@Callable(i)
242-func setAssetName (assetID,assetName) = {
243- let checkCaller = mustAdmin(i)
244- if ((checkCaller == checkCaller))
245- then [StringEntry(keyAssetName(assetID), assetName)]
246- else throw("Strict value is not equal to itself.")
247- }
248-
249-
250-
251-@Callable(i)
252-func setAssetDescription (assetID,assetDescription) = {
253- let checkCaller = mustAdmin(i)
254- if ((checkCaller == checkCaller))
255- then [StringEntry(keyAssetDescription(assetID), assetDescription)]
256- else throw("Strict value is not equal to itself.")
257- }
258-
259-
260-
261-@Callable(i)
262-func constructor (userPoolsContract,labels) = {
263- let checkCaller = mustManager(i)
264- if ((checkCaller == checkCaller))
265- then {
266- let checksAddress = valueOrErrorMessage(addressFromString(userPoolsContract), "Invalid address")
267- if ((checksAddress == checksAddress))
268- then [StringEntry(keyUserPoolsContract(), userPoolsContract), StringEntry(keyLabels(), makeString((defaultLabels ++ labels), SEP))]
269- else throw("Strict value is not equal to itself.")
270- }
271- else throw("Strict value is not equal to itself.")
272- }
273-
274-
275-
276-@Callable(i)
277-func constructorV2 (factoryContract) = {
278- let checkCaller = mustManager(i)
279- if ((checkCaller == checkCaller))
280- then {
281- let checkAddress = valueOrErrorMessage(addressFromString(factoryContract), "invalid factory contract address")
282- if ((checkAddress == checkAddress))
283- then [StringEntry(keyFactoryContract(), factoryContract)]
284- else throw("Strict value is not equal to itself.")
285- }
286- else throw("Strict value is not equal to itself.")
287- }
288-
289-
290-
291-@Callable(i)
292-func addAssetsLink (amountAsset,priceAsset,lpAsset) = {
293- let checkCaller = mustAdmin(i)
294- if ((checkCaller == checkCaller))
295- then [StringEntry(keyAmountAndPriceAssetsToLpAsset(amountAsset, priceAsset), lpAsset), StringEntry(keyLpAssetToAmountAndPriceAssets(lpAsset), makeString([amountAsset, priceAsset], SEP))]
296- else throw("Strict value is not equal to itself.")
297- }
298-
299-
300-
301-@Callable(i)
302-func increaseAssetPoolsNumber (assetId) = {
303- let checkCaller = mustAdmin(i)
304- if ((checkCaller == checkCaller))
305- then {
306- let assetPoolsNumberKey = keyAssetPoolsNumber(assetId)
307- let assetPoolsNumber = valueOrElse(getInteger(assetPoolsNumberKey), 0)
308-[IntegerEntry(assetPoolsNumberKey, (assetPoolsNumber + 1))]
309- }
310- else throw("Strict value is not equal to itself.")
311- }
312-
313-
314-
315-@Callable(i)
316-func createLabel (label) = {
317- let labels = getLabels()
318- let checkCaller = mustAdmin(i)
319- if ((checkCaller == checkCaller))
320- then {
321- let checkLabel = [if (!(contains(label, SEP)))
322- then true
323- else throw("Invalid label name"), if (!(containsElement(labels, label)))
324- then true
325- else throw("Label exists")]
326- if ((checkLabel == checkLabel))
327- then [StringEntry(keyLabels(), makeString((labels :+ label), SEP))]
328- else throw("Strict value is not equal to itself.")
329- }
330- else throw("Strict value is not equal to itself.")
331- }
332-
333-
334-
335-@Callable(i)
336-func dropLabel (label) = {
337- let labels = getLabels()
338- let checkCaller = mustManager(i)
339- if ((checkCaller == checkCaller))
340- then {
341- let checkLabel = if (containsElement(labels, label))
342- then true
343- else throw("Label doesn't exist")
344- if ((checkLabel == checkLabel))
345- then [StringEntry(keyLabels(), makeString(removeByIndex(labels, value(indexOf(labels, label))), SEP))]
346- else throw("Strict value is not equal to itself.")
347- }
348- else throw("Strict value is not equal to itself.")
349- }
350-
351-
352-
353-@Callable(i)
354-func addLabel (assetId,label) = {
355- let checkCaller = mustAdmin(i)
356- if ((checkCaller == checkCaller))
357- then addLabelActions(assetId, label, true)
358- else throw("Strict value is not equal to itself.")
359- }
360-
361-
362-
363-@Callable(i)
364-func deleteLabel (assetId,label) = {
365- let checkCaller = mustAdmin(i)
366- if ((checkCaller == checkCaller))
367- then deleteLabelActions(assetId, label, true)
368- else throw("Strict value is not equal to itself.")
369- }
370-
371-
372-
373-@Callable(i)
374-func updateTicker (assetId,ticker) = {
375- let checkCaller = mustAdmin(i)
376- if ((checkCaller == checkCaller))
377- then {
378- let checkAsset = if (isCreated(assetId))
379- then true
380- else throwNoAsset()
381- if ((checkAsset == checkAsset))
382- then updateTickerActions(assetId, ticker)
383- else throw("Strict value is not equal to itself.")
384- }
385- else throw("Strict value is not equal to itself.")
386- }
387-
388-
389-
390-@Callable(i)
391-func deleteTicker (assetId) = {
392- let checkCaller = mustAdmin(i)
393- if ((checkCaller == checkCaller))
394- then {
395- let ticker = valueOrErrorMessage(getString(keyAssetIdToTicker(assetId)), "Invalid asset")
396-[DeleteEntry(keyAssetIdToTicker(assetId)), DeleteEntry(keyTickerToAssetId(ticker))]
397- }
398- else throw("Strict value is not equal to itself.")
399- }
400-
401-
402-
403-@Callable(i)
404-func createOrUpdate (assetId,logo,verified) = {
405- let checkCaller = mustAdmin(i)
406- if ((checkCaller == checkCaller))
407- then {
408- let isCreatedNow = !(isCreated(assetId))
409- if ((isCreatedNow == isCreatedNow))
410- then {
411- let setLogoActions = if ((logo == ""))
412- then nil
413- else [StringEntry(keyLogo(assetId), logo)]
414- $Tuple2((([BooleanEntry(keyCreated(assetId), true)] ++ setLogoActions) ++ setVerifiedActions(assetId, verified)), isCreatedNow)
415- }
416- else throw("Strict value is not equal to itself.")
417- }
418- else throw("Strict value is not equal to itself.")
419- }
420-
421-
422-
423-@Callable(i)
424-func setLogo (assetId,logo) = {
425- let checks = [mustAdmin(i), if (isCreated(assetId))
426- then true
427- else throwNoAsset()]
428- if ((checks == checks))
429- then {
430- let action = if ((logo == ""))
431- then DeleteEntry(keyLogo(assetId))
432- else StringEntry(keyLogo(assetId), logo)
433-[action]
434- }
435- else throw("Strict value is not equal to itself.")
436- }
437-
438-
439-
440-@Callable(i)
441-func setVerified (assetId,verified) = {
442- let checks = [mustAdmin(i), if (isCreated(assetId))
443- then true
444- else throwNoAsset()]
445- if ((checks == checks))
446- then {
447- let onVerificationLossInv = if (!(verified))
448- then {
449- let factoryContract = valueOrErrorMessage(addressFromString(getStrOrFail(this, keyFactoryContract())), "invalid factory contract address")
450- invoke(factoryContract, "onVerificationLoss", [assetId], nil)
451- }
452- else unit
453- if ((onVerificationLossInv == onVerificationLossInv))
454- then $Tuple2(setVerifiedActions(assetId, verified), unit)
455- else throw("Strict value is not equal to itself.")
456- }
457- else throw("Strict value is not equal to itself.")
458- }
459-
460-
461-
462-@Callable(i)
463-func onEliminate (assetId) = {
464- let poolsNumber = valueOrElse(getInteger(keyAssetPoolsNumber(assetId)), 0)
465- let actions = if ((poolsNumber > 0))
466- then nil
467- else [DeleteEntry(keyLogo(assetId))]
468- $Tuple2(actions, unit)
469- }
470-
471-
472-
473-@Callable(i)
474-func setAdmins (adminPubKeys) = {
475- let checkCaller = mustManager(i)
476- if ((checkCaller == checkCaller))
477- then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))]
478- else throw("Strict value is not equal to itself.")
479- }
480-
481-
482-
483-@Callable(i)
484-func setManager (pendingManagerPublicKey) = {
485- let checkCaller = mustManager(i)
486- if ((checkCaller == checkCaller))
487- then {
488- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
489- if ((checkManagerPublicKey == checkManagerPublicKey))
490- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
491- else throw("Strict value is not equal to itself.")
492- }
493- else throw("Strict value is not equal to itself.")
494- }
495-
496-
497-
498-@Callable(i)
499-func confirmManager () = {
500- let pm = pendingManagerPublicKeyOrUnit()
501- let hasPM = if (isDefined(pm))
502- then true
503- else throw("No pending manager")
504- if ((hasPM == hasPM))
505- then {
506- let checkPM = if ((i.callerPublicKey == value(pm)))
507- then true
508- else throw("You are not pending manager")
509- if ((checkPM == checkPM))
510- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
511- else throw("Strict value is not equal to itself.")
512- }
513- else throw("Strict value is not equal to itself.")
514- }
515-
516-
517-
518-@Callable(i)
519-func isVerifiedREADONLY (assetId) = $Tuple2(nil, isVerified(assetId))
520-
521-
522-@Verifier(tx)
523-func verify () = {
524- let targetPublicKey = match managerPublicKeyOrUnit() {
525- case pk: ByteVector =>
526- pk
527- case _: Unit =>
528- tx.senderPublicKey
529- case _ =>
530- throw("Match error")
531- }
532- sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
533- }
534-
1+# no script

github/deemru/w8io/026f985 
36.36 ms