tx · EA9aVssxceuKp9iM8pCov7Uhgut9XbQQhbXm9mfpr8h

3MsH95R1SdYUEkUTVjHvR8gLD8rXtgQ21Vj:  -0.01400000 Waves

2021.04.14 18:07 [1482278] smart account 3MsH95R1SdYUEkUTVjHvR8gLD8rXtgQ21Vj > SELF 0.00000000 Waves

{ "type": 13, "id": "EA9aVssxceuKp9iM8pCov7Uhgut9XbQQhbXm9mfpr8h", "fee": 1400000, "feeAssetId": null, "timestamp": 1618412833721, "version": 2, "chainId": 84, "sender": "3MsH95R1SdYUEkUTVjHvR8gLD8rXtgQ21Vj", "senderPublicKey": "GYeGBXmJUHrtkkJuLVJKCHtaCbkvj9nS4aVLqzdrbpZx", "proofs": [ "YPTaj1XYXBCBxPvCgeHiSb1JRDWpSpgF6vreJ2cqtkEPwHnnbm1Q9S2zV8rVerR7DUmihkzEcLVPYexUih1hny5" ], "script": "base64:AAIEAAAAAAAAAAQIAhIAAAAAAAAAAAEAAAABaQEAAAAEY2FsbAAAAAAEAAAABWFzc2V0CQAEQwAAAAcCAAAABUFzc2V0AgAAAAAAAAAAAAAAAAEAAAAAAAAAAAAGBQAAAAR1bml0AAAAAAAAAAAABAAAAAdhc3NldElkCQAEOAAAAAEFAAAABWFzc2V0CQAETAAAAAIJAQAAAAtCaW5hcnlFbnRyeQAAAAICAAAAA2JpbgEAAAAACQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAAARib29sBgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAADaW50AAAAAAAAAAABCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAAA3N0cgIAAAAACQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAECAAAAA3N0cgkABEwAAAACBQAAAAVhc3NldAkABEwAAAACCQEAAAAHUmVpc3N1ZQAAAAMFAAAAB2Fzc2V0SWQAAAAAAAAAAAEHCQAETAAAAAIJAQAAAARCdXJuAAAAAgUAAAAHYXNzZXRJZAAAAAAAAAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEFAAAAB2Fzc2V0SWQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5KOU8bg==", "height": 1482278, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HsVeavFmxFpycd1hNTWKiDxra4ZcFenEKdtP2EcnwX9w Next: 13VzYAup8V4dL7vgMb1tWLCUMtMcwGrGnc1SibFqzSvD Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let version = 1
5-
6-let separator = "___"
7-
8-let decimals = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]
9-
10-let maxInt = 9223372036854775807
11-
12-let addrPrivileges = addressFromStringValue("3Myojf1j7W2S5XSKemGaqErcSYghqCgQ1gp")
13-
14-let addrVault = addressFromStringValue("3MutTVXh7Z2m9Cfzx982D4nm7h9Yzr3Ra9a")
15-
16-let nibelAsset = base58'8c6SCeWJj6M1VFBaFEg2LWxYS77ZHkmiMeAs6MMSDi1v'
17-
18-let nibelAmountPerBlocks = 1000000000000
19-
20-let nibelGenesisBlock = 0
21-
22-let nibelHavlingDelay = 100000
23-
24-let sharedKeyMainOperator = "MAIN_OPERATOR"
25-
26-let sharedKeyPrivilege = "PRIVILEGE"
27-
28-let sharedReceiptTag = "R"
29-
30-let keyForgesTotalWeight = "FORGES_TOTAL_WEIGHT"
31-
32-let keyForgeSettingsEnabled = "FS_ENABLED_"
33-
34-let keyForgeSettingsSupplies = "FS_SUPPLIES_"
35-
36-let keyForgeSettingsWeight = "FS_WEIGHT_"
37-
38-func isSafeString (stringToTest) = if ((contains(stringToTest, separator) == false))
39- then (contains(stringToTest, " ") == false)
40- else false
414
425
43-func isSafeInteger (integerToTest) = match integerToTest {
44- case isString: String =>
45- match parseInt(isString) {
46- case isInteger: Int =>
47- if ((isInteger >= 0))
48- then (maxInt >= isInteger)
49- else false
50- case _ =>
51- false
52- }
53- case isInteger: Int =>
54- if ((isInteger >= 0))
55- then (maxInt >= isInteger)
56- else false
57- case _ =>
58- false
59-}
60-
61-
62-func toSafeInteger (stringToConvert) = {
63- let parsedInteger = valueOrErrorMessage(parseInt(stringToConvert), "Not a string int")
64- if ((isSafeInteger(parsedInteger) != true))
65- then throw("Not safe")
66- else parsedInteger
6+@Callable(i)
7+func call () = {
8+ let asset = Issue("Asset", "", 1, 0, true, unit, 0)
9+ let assetId = calculateAssetId(asset)
10+[BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)]
6711 }
6812
6913
70-func isAsset (assetToTest) = match assetToTest {
71- case isString: String =>
72- isDefined(assetInfo(fromBase58String(isString)))
73- case isByteVector: ByteVector =>
74- isDefined(assetInfo(isByteVector))
75- case _ =>
76- false
77-}
78-
79-
80-func getForgeAssetState (assetToCheck) = match getBoolean(this, (keyForgeSettingsEnabled + assetToCheck)) {
81- case isBoolean: Boolean =>
82- if ((isBoolean == true))
83- then "enabled"
84- else "disabled"
85- case _ =>
86- "notWhitelisted"
87-}
88-
89-
90-func hasPrivilege (callerAddress,privilegeName) = if ((addressFromStringValue(getStringValue(addrPrivileges, sharedKeyMainOperator)) == callerAddress))
91- then true
92- else match getInteger(addrPrivileges, (((((sharedKeyPrivilege + separator) + toBase58String(callerAddress.bytes)) + separator) + toBase58String(this.bytes)) + privilegeName)) {
93- case isInteger: Int =>
94- true
95- case _ =>
96- false
97- }
98-
99-
100-func calcForgeWeight (forgeSupplies) = (maxInt / forgeSupplies)
101-
102-
103-@Callable(i)
104-func addAssetToWhitelist (assetToAdd,assetTotalSupplies) = if ((hasPrivilege(i.caller, "addAssetToWhitelist") != true))
105- then throw("Access denied")
106- else if (if ((isAsset(assetToAdd) != true))
107- then true
108- else (isSafeInteger(assetTotalSupplies) != true))
109- then throw("Data validation")
110- else if ((getForgeAssetState(assetToAdd) != "notWhitelisted"))
111- then throw("Asset already whitelisted")
112- else {
113- let forgeWeight = calcForgeWeight(assetTotalSupplies)
114- let newForgesTotalWeight = (getIntegerValue(this, keyForgesTotalWeight) + forgeWeight)
115-[BooleanEntry((keyForgeSettingsEnabled + assetToAdd), true), IntegerEntry((keyForgeSettingsSupplies + assetToAdd), assetTotalSupplies), IntegerEntry((keyForgeSettingsWeight + assetToAdd), forgeWeight), IntegerEntry(keyForgesTotalWeight, newForgesTotalWeight)]
116- }
117-
118-
119-
120-@Callable(i)
121-func removeAssetFromWhitelist (assetToRemove) = if ((hasPrivilege(i.caller, "removeAssetFromWhitelist") != true))
122- then throw("Access denied")
123- else if ((isAsset(assetToRemove) != true))
124- then throw("Data validation")
125- else {
126- let forgeAssetState = getForgeAssetState(assetToRemove)
127- if ((forgeAssetState == "notWhitelisted"))
128- then throw("Asset not whitelisted")
129- else {
130- let actions = [DeleteEntry((keyForgeSettingsEnabled + assetToRemove)), DeleteEntry((keyForgeSettingsSupplies + assetToRemove)), DeleteEntry((keyForgeSettingsWeight + assetToRemove))]
131- if ((forgeAssetState == "disabled"))
132- then actions
133- else IntegerEntry(keyForgesTotalWeight, (getIntegerValue(this, keyForgesTotalWeight) - getIntegerValue(this, (keyForgeSettingsWeight + assetToRemove)))) :: actions
134- }
135- }
136-
137-
138-
139-@Callable(i)
140-func enableDisableForge (assetToToggle) = if ((hasPrivilege(i.caller, "enableDisableForge") != true))
141- then throw("Access denied")
142- else if ((isAsset(assetToToggle) != true))
143- then throw("Data validation")
144- else {
145- let forgeAssetState = getForgeAssetState(assetToToggle)
146- if ((forgeAssetState == "notWhitelisted"))
147- then throw("Asset not whitelisted")
148- else {
149- let forgeWeight = getIntegerValue(this, keyForgeSettingsWeight)
150- let forgesTotalWeight = getIntegerValue(this, keyForgesTotalWeight)
151- if ((forgeAssetState == "disabled"))
152- then [IntegerEntry(keyForgesTotalWeight, (forgesTotalWeight + forgeWeight)), BooleanEntry((keyForgeSettingsEnabled + assetToToggle), true)]
153- else [IntegerEntry(keyForgesTotalWeight, (forgesTotalWeight - forgeWeight)), BooleanEntry((keyForgeSettingsEnabled + assetToToggle), false)]
154- }
155- }
156-
157-
158-
159-@Callable(i)
160-func updateForgeAssetSupplies (assetToUpdate,newSuppliesValue) = if ((hasPrivilege(i.caller, "updateForgeAssetSupplies") != true))
161- then throw("Access denied")
162- else if (if ((isAsset(assetToUpdate) != true))
163- then true
164- else (isSafeInteger(newSuppliesValue) != true))
165- then throw("Data validation")
166- else {
167- let forgeAssetState = getForgeAssetState(assetToUpdate)
168- if ((forgeAssetState == "notWhitelisted"))
169- then throw("Asset not whitelisted")
170- else {
171- let currentForgeWeight = getIntegerValue(this, (keyForgeSettingsWeight + assetToUpdate))
172- let newForgeWeight = calcForgeWeight(newSuppliesValue)
173- let actions = [IntegerEntry((keyForgeSettingsWeight + assetToUpdate), newForgeWeight), IntegerEntry((keyForgeSettingsSupplies + assetToUpdate), newSuppliesValue)]
174- if ((forgeAssetState == "disabled"))
175- then actions
176- else IntegerEntry(keyForgesTotalWeight, ((getIntegerValue(this, keyForgesTotalWeight) + newForgeWeight) - currentForgeWeight)) :: actions
177- }
178- }
179-
180-
181-
182-@Callable(i)
183-func claim () = if ((this == i.caller))
184- then throw("Self-invoke forbidden")
185- else if (if ((size(i.payments) != 1))
186- then true
187- else (i.payments[0].amount != 1))
188- then throw("Payment issue")
189- else {
190- let receiptInfo = valueOrErrorMessage(assetInfo(valueOrErrorMessage(i.payments[0].assetId, "Wrong asset type")), "Unknown asset")
191- if ((receiptInfo.issuer != addrVault))
192- then throw("Unknown issuer")
193- else {
194- let receiptFields = split(receiptInfo.description, separator)
195- if (if ((size(receiptFields) != 8))
196- then true
197- else (receiptFields[0] != sharedReceiptTag))
198- then throw("Not a receipt")
199- else {
200- let forgeAssetState = getForgeAssetState(receiptFields[3])
201- if ((forgeAssetState != "enabled"))
202- then throw("Not whitelisted/enabled")
203- else {
204- let assetQuantity = toSafeInteger(receiptFields[4])
205- let eligibleBlocks = (toSafeInteger(receiptFields[5]) - toSafeInteger(receiptFields[1]))
206- if ((1 > eligibleBlocks))
207- then throw("No eligible blocks")
208- else {
209- let forgeWeight = getIntegerValue(this, (keyForgeSettingsWeight + receiptFields[3]))
210- let forgeSupplies = getIntegerValue(this, (keyForgeSettingsSupplies + receiptFields[3]))
211- let forgesTotalWeight = getIntegerValue(this, keyForgesTotalWeight)
212- let amountToDeliverPerBlock = fraction(fraction(nibelAmountPerBlocks, forgeWeight, forgesTotalWeight), assetQuantity, forgeSupplies)
213- if ((1 > amountToDeliverPerBlock))
214- then throw("Below minimum required")
215- else {
216- let amountToDeliverTotal = (amountToDeliverPerBlock * eligibleBlocks)
217- if ((isSafeInteger(amountToDeliverTotal) != true))
218- then throw("System error")
219- else [Reissue(nibelAsset, amountToDeliverTotal, true), ScriptTransfer(i.caller, amountToDeliverTotal, nibelAsset), IntegerEntry("assetQuantity", assetQuantity), IntegerEntry("eligibleBlocks", eligibleBlocks), IntegerEntry("forgeWeight", forgeWeight), IntegerEntry("forgeSupplies", forgeSupplies), IntegerEntry("forgesTotalWeight", forgesTotalWeight), IntegerEntry("amountToDeliverPerBlock", amountToDeliverPerBlock), IntegerEntry("amountToDeliverTotal", amountToDeliverTotal)]
220- }
221- }
222- }
223- }
224- }
225- }
226-
14+@Verifier(tx)
15+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
22716

github/deemru/w8io/169f3d6 
45.95 ms