tx · UQJEXbxEbJXbdoms3w5UfAE6BWPZZTQH1n8eeUaVjcC

3Mq63KhXVgGGwRKzuA5Bvw4mNRVxeS7aMqp:  -0.01400000 Waves

2020.12.09 07:45 [1300664] smart account 3Mq63KhXVgGGwRKzuA5Bvw4mNRVxeS7aMqp > SELF 0.00000000 Waves

{ "type": 13, "id": "UQJEXbxEbJXbdoms3w5UfAE6BWPZZTQH1n8eeUaVjcC", "fee": 1400000, "feeAssetId": null, "timestamp": 1607489250744, "version": 2, "chainId": 84, "sender": "3Mq63KhXVgGGwRKzuA5Bvw4mNRVxeS7aMqp", "senderPublicKey": "ArjHVMk2ga51ShWPgoLAhEkdZavYYmUAqJJ1ihuCoD3b", "proofs": [ "BHcifZA2vEKbHKXCAUyMwHJbZqgKu6MjuPyWt9sUk96crVyuV5SDiuYmTXMiuXcy3wnsKhVmxMEy1gwoEUafY5X" ], "script": "base64:AAIEAAAAAAAAAAIIAgAAAAAAAAAAAAAAALqqDqs=", "height": 1300664, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BWBFnhMsHoAGH8F83hFeyVd9hXv7bKhA2F7CgHVRkpiy Next: 3p59RtZH2k1K9wQhPoekTUn3hCWwcZGtVpV6tBTAs98a Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let dappRunningKey = "conf_dapp_is_running"
54
6-let maintenanceMSGKey = "conf_maintenance_msg"
7-
8-let whitelistedonlyKey = "conf_whitelisted_only"
9-
10-let dappRunning = match getBoolean(this, dappRunningKey) {
11- case a: Boolean =>
12- a
13- case _ =>
14- true
15-}
16-
17-let maintenanceMSG = match getString(this, maintenanceMSGKey) {
18- case a: String =>
19- a
20- case _ =>
21- ""
22-}
23-
24-let whitelistedonly = match getBoolean(this, whitelistedonlyKey) {
25- case a: Boolean =>
26- a
27- case _ =>
28- true
29-}
30-
31-let signAssetId = base58'Gf9t8FA4H3ssoZPCwrg3KwUFCci8zuUFP9ssRsUY3s6a'
32-
33-let chris = "3MsG6jPNCrVJUtYB7XJBxS7utWsXAf4n9Vp"
34-
35-let joep = "3Mzm4VLwsN9uZwbTMzPj3XuxV6kEfAR8UDN"
36-
37-let userAllowed = "ALLOWED"
38-
39-let userRegistered = "REGISTERED"
40-
41-let userVerified = "VERIFIED"
42-
43-let userSuspended = "SUSPENDED"
44-
45-let userRemoved = "REMOVED"
46-
47-let userChangeRequired = "CHANGE_REQUIRED"
48-
49-let userUnregistered = "UNREGISTERED"
50-
51-let userReset = "RESET"
52-
53-func getStringByKey (key) = match getString(this, key) {
54- case a: String =>
55- a
56- case _ =>
57- ""
58-}
59-
60-
61-func getBooleanByKey (key) = match getBoolean(this, key) {
62- case a: Boolean =>
63- a
64- case _ =>
65- false
66-}
67-
68-
69-func getIntegerByKey (key) = match getInteger(this, key) {
70- case i: Int =>
71- i
72- case _ =>
73- 0
74-}
75-
76-
77-func validateCID (cid) = if (if ((75 > size(cid)))
78- then (60 > size(split(cid, "/")[0]))
79- else false)
80- then (16 > size(split(cid, "/")[1]))
81- else false
82-
83-
84-func keyUserAddr (caller) = ("user_" + caller)
85-
86-
87-func keyUserName (caller) = ("user_name_" + caller)
88-
89-
90-func keyUserDesc (caller) = ("user_desc_" + caller)
91-
92-
93-func keyUserSocial (caller) = ("user_social_" + caller)
94-
95-
96-func keyUserThumb (caller) = ("user_thumb_" + caller)
97-
98-
99-func keyUserStatus (caller) = ("user_status_" + caller)
100-
101-
102-func keyUserDate (caller) = ("user_date_" + caller)
103-
104-
105-@Callable(i)
106-func appRunning (isLive,message) = {
107- let caller = toString(addressFromPublicKey(i.callerPublicKey))
108- let id = toBase58String(i.transactionId)
109- if (containsElement([chris, joep, toString(this)], caller))
110- then [BooleanEntry(dappRunningKey, isLive), StringEntry(maintenanceMSGKey, message)]
111- else throw("You are not allowed to change this")
112- }
113-
114-
115-
116-@Callable(i)
117-func registrationMode (WLonly) = {
118- let caller = toString(addressFromPublicKey(i.callerPublicKey))
119- let id = toBase58String(i.transactionId)
120- if (containsElement([chris, joep, toString(this)], caller))
121- then [BooleanEntry(whitelistedonlyKey, WLonly)]
122- else throw("You are not allowed to change this")
123- }
124-
125-
126-
127-@Callable(i)
128-func registerUser (name,description,thumb,social) = if (!(dappRunning))
129- then throw(maintenanceMSG)
130- else {
131- let caller = toString(addressFromPublicKey(i.callerPublicKey))
132- let canRegister = getStringByKey(keyUserStatus(caller))
133- let id = toBase58String(i.transactionId)
134- let timestamp = lastBlock.timestamp
135- if (if ((canRegister == userSuspended))
136- then true
137- else (canRegister == userRemoved))
138- then throw("Account suspended/ removed.")
139- else if ((canRegister == userRegistered))
140- then throw("Already registered")
141- else if (if ((canRegister == ""))
142- then whitelistedonly
143- else false)
144- then throw("Can't register, get approved first.")
145- else if (if ((name == ""))
146- then true
147- else (description == ""))
148- then throw("Name and description cannot be empty")
149- else if ((size(description) > 600))
150- then throw("600 Char. max description")
151- else if ((size(name) > 45))
152- then throw("45 Char. max name")
153- else [IntegerEntry(keyUserDate(caller), timestamp), StringEntry(keyUserAddr(caller), ((id + "_") + toString(timestamp))), StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(keyUserStatus(caller), userRegistered)]
154- }
155-
156-
157-
158-@Callable(i)
159-func updateUser (name,description,thumb,social) = if (!(dappRunning))
160- then throw(maintenanceMSG)
161- else {
162- let caller = toString(addressFromPublicKey(i.callerPublicKey))
163- let id = toBase58String(i.transactionId)
164- let canUpdate = getStringByKey(keyUserStatus(caller))
165- if (if ((canUpdate == userSuspended))
166- then true
167- else (canUpdate == userRemoved))
168- then throw("Account suspended/ removed.")
169- else if (if ((canUpdate == ""))
170- then true
171- else (canUpdate == userAllowed))
172- then throw("Register first")
173- else if (if ((name == ""))
174- then true
175- else (description == ""))
176- then throw("Name & description cannot be empty")
177- else if ((size(description) > 600))
178- then throw("600 Char. max for description")
179- else if ((size(name) > 45))
180- then throw("45 Char. max name")
181- else [StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb)]
182- }
183-
184-
185-
186-@Callable(i)
187-func changeUserStatus (address,status) = if (!(dappRunning))
188- then throw(maintenanceMSG)
189- else {
190- let caller = toString(addressFromPublicKey(i.callerPublicKey))
191- let id = toBase58String(i.transactionId)
192- let currentStatus = getStringByKey(keyUserStatus(address))
193- let statusToSet = if ((status == userVerified))
194- then userVerified
195- else if ((status == userRegistered))
196- then userRegistered
197- else if ((status == userSuspended))
198- then userSuspended
199- else if ((status == userRemoved))
200- then userRemoved
201- else if ((status == userAllowed))
202- then userAllowed
203- else if ((status == userChangeRequired))
204- then userChangeRequired
205- else if (if ((status == userReset))
206- then (currentStatus == userAllowed)
207- else false)
208- then ""
209- else throw("Unknown status")
210- let userIsRegistered = getIntegerByKey(keyUserDate(address))
211- if (if ((userIsRegistered == 0))
212- then (status != userAllowed)
213- else false)
214- then throw("You cant set this status, user is not registered.")
215- else if (if ((currentStatus == userAllowed))
216- then (status == userAllowed)
217- else false)
218- then throw("User already allowed")
219- else if (if ((currentStatus == userRegistered))
220- then (status == userAllowed)
221- else false)
222- then throw("User already allowed & registered")
223- else if (if ((currentStatus == userVerified))
224- then (status == userAllowed)
225- else false)
226- then throw("User already allowed & verified")
227- else if (containsElement([chris, joep, toString(this)], caller))
228- then [StringEntry(keyUserStatus(address), statusToSet)]
229- else throw("Not allowed to change user status")
230- }
231-
232-
233-
234-@Callable(i)
235-func creditUser (address) = {
236- let caller = toString(addressFromPublicKey(i.callerPublicKey))
237- let id = toBase58String(i.transactionId)
238- if (containsElement([chris, joep], caller))
239- then [ScriptTransfer(Address(fromBase58String(address)), 30000000000, signAssetId)]
240- else throw("Not allowed")
241- }
242-
243-
244-
245-@Callable(i)
246-func deleteUser (address) = {
247- let caller = toString(addressFromPublicKey(i.callerPublicKey))
248- let id = toBase58String(i.transactionId)
249- if (containsElement([chris, joep, toString(this)], caller))
250- then [DeleteEntry(keyUserDate(address)), DeleteEntry(keyUserAddr(address)), DeleteEntry(keyUserName(address)), DeleteEntry(keyUserDesc(address)), DeleteEntry(keyUserSocial(address)), DeleteEntry(keyUserThumb(address)), StringEntry(keyUserStatus(address), userRemoved)]
251- else throw("Not allowed")
252- }
253-
254-
255-
256-@Callable(i)
257-func deleteEntry (entry) = {
258- let caller = toString(addressFromPublicKey(i.callerPublicKey))
259- if ((caller == chris))
260- then [DeleteEntry(entry)]
261- else throw("no")
262- }
2635
2646

github/deemru/w8io/169f3d6 
92.07 ms