tx · GxEkRJaegkHtUsFyxrFXFaEm4TWjqN3Ghw1e57rwGAzP

3Mx9KU2qWAgHfp1h3iyVsdiHiz3uuZFbBUG:  -0.01400000 Waves

2020.12.30 07:29 [1330951] smart account 3Mx9KU2qWAgHfp1h3iyVsdiHiz3uuZFbBUG > SELF 0.00000000 Waves

{ "type": 13, "id": "GxEkRJaegkHtUsFyxrFXFaEm4TWjqN3Ghw1e57rwGAzP", "fee": 1400000, "feeAssetId": null, "timestamp": 1609302634343, "version": 2, "chainId": 84, "sender": "3Mx9KU2qWAgHfp1h3iyVsdiHiz3uuZFbBUG", "senderPublicKey": "x1aRSsyD7D2CQzJbQGVnX4LjWQ2qX7B9QwBw4gz7FXU", "proofs": [ "3rNdHjGS9P53xApcsVJb2zC2oZGNGLXNnGsmSH5vK8ewCcef8FMsKFkUs5qhMDosMi3W6eqgSADuHFiQjgcsLZkB" ], "script": "base64:AAIEAAAAAAAAAAsIAhIHCgUICAgICAAAAAoBAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWECAAAAAAEAAAAPZ2V0Qm9vbGVhbkJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQbAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAdCb29sZWFuBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBwEAAAAPZ2V0SW50ZWdlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWkFAAAAByRtYXRjaDAFAAAAAWkAAAAAAAAAAAABAAAAC2tleVVzZXJBZGRyAAAAAQAA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HJpbmdFbnRyeQAAAAIJAQAAAAxrZXlVc2VyVGh1bWIAAAABBQAAAAZjYWxsZXIFAAAABXRodW1iCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAA1rZXlVc2VyU3RhdHVzAAAAAQUAAAAGY2FsbGVyBQAAAAZzdGF0dXMJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkAASwAAAACAgAAAAhBTExPV0VEXwUAAAAGY2FsbGVyCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAZzdGF0dXMCAAAAAV8FAAAABmNhbGxlcgUAAAAEanNvbgUAAAADbmlsAAAAANPUXU4=", "height": 1330951, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ENBputjoRXrV6GmDC8UGkeHZzmsMUsGKay2hJtR8BG1r Next: Duws2ua2zxZzaKc5Aet1mhCSrWupwJLRTxjsX887rp1 Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let signAssetId = base58'Gf9t8FA4H3ssoZPCwrg3KwUFCci8zuUFP9ssRsUY3s6a'
5-
6-let chris = "3MsG6jPNCrVJUtYB7XJBxS7utWsXAf4n9Vp"
7-
8-let joep = "3Mzm4VLwsN9uZwbTMzPj3XuxV6kEfAR8UDN"
9-
10-let dappRunningKey = "conf_dapp_is_running"
11-
12-let maintenanceMSGKey = "conf_maintenance_msg"
13-
14-let whitelistedonlyKey = "conf_whitelisted_only"
15-
16-let dappRunning = match getBoolean(this, dappRunningKey) {
17- case a: Boolean =>
18- a
19- case _ =>
20- true
21-}
22-
23-let maintenanceMSG = match getString(this, maintenanceMSGKey) {
24- case a: String =>
25- a
26- case _ =>
27- ""
28-}
29-
30-let whitelistedonly = match getBoolean(this, whitelistedonlyKey) {
31- case a: Boolean =>
32- a
33- case _ =>
34- true
35-}
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-
534 func getStringByKey (key) = match getString(this, key) {
545 case a: String =>
556 a
7425 }
7526
7627
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-
8428 func keyUserAddr (caller) = ("user_" + caller)
8529
8630
10347
10448
10549 @Callable(i)
106-func appRunning (isLive,message) = {
50+func registerUser (name,description,thumb,social,status) = {
10751 let caller = toString(addressFromPublicKey(i.callerPublicKey))
52+ let canRegister = getStringByKey(keyUserStatus(caller))
10853 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 {
154- let json = (((((("{\"user_name\": \"" + toBase64String(toBytes(name))) + "\", \"user_thumb\":\"") + toBase64String(toBytes(thumb))) + "\",\"user_date\":\"") + toString(timestamp)) + "\"}")
155-[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), DeleteEntry(("ALLOWED_" + caller)), StringEntry(((userRegistered + "_") + caller), json)]
156- }
157- }
158-
159-
160-
161-@Callable(i)
162-func updateUser (name,description,thumb,social) = if (!(dappRunning))
163- then throw(maintenanceMSG)
164- else {
165- let caller = toString(addressFromPublicKey(i.callerPublicKey))
166- let id = toBase58String(i.transactionId)
167- let canUpdate = getStringByKey(keyUserStatus(caller))
168- if (if ((canUpdate == userSuspended))
169- then true
170- else (canUpdate == userRemoved))
171- then throw("Account suspended/ removed.")
172- else if (if ((canUpdate == ""))
173- then true
174- else (canUpdate == userAllowed))
175- then throw("Register first")
176- else if (if ((name == ""))
177- then true
178- else (description == ""))
179- then throw("Name & description cannot be empty")
180- else if ((size(description) > 600))
181- then throw("600 Char. max for description")
182- else if ((size(name) > 45))
183- then throw("45 Char. max name")
184- else {
185- let date = getIntegerByKey(keyUserDate(caller))
186- let json = (((((("{\"user_name\": \"" + toBase64String(toBytes(name))) + "\", \"user_thumb\":\"") + toBase64String(toBytes(thumb))) + "\",\"user_date\":\"") + toString(date)) + "\"}")
187-[StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(((canUpdate + "_") + caller), json)]
188- }
189- }
190-
191-
192-
193-@Callable(i)
194-func changeUserStatus (address,status) = if (!(dappRunning))
195- then throw(maintenanceMSG)
196- else {
197- let caller = toString(addressFromPublicKey(i.callerPublicKey))
198- let id = toBase58String(i.transactionId)
199- let currentStatus = getStringByKey(keyUserStatus(address))
200- let statusToSet = if ((status == userVerified))
201- then userVerified
202- else if ((status == userRegistered))
203- then userRegistered
204- else if ((status == userSuspended))
205- then userSuspended
206- else if ((status == userRemoved))
207- then userRemoved
208- else if ((status == userAllowed))
209- then userAllowed
210- else if ((status == userChangeRequired))
211- then userChangeRequired
212- else if (if ((status == userReset))
213- then (currentStatus == userAllowed)
214- else false)
215- then ""
216- else throw("Unknown status")
217- let userIsRegistered = getIntegerByKey(keyUserDate(address))
218- if (if ((userIsRegistered == 0))
219- then (status != userAllowed)
220- else false)
221- then throw("You cant set this status, user is not registered.")
222- else if (if ((currentStatus == userAllowed))
223- then (status == userAllowed)
224- else false)
225- then throw("User already allowed")
226- else if (if ((currentStatus == userRegistered))
227- then (status == userAllowed)
228- else false)
229- then throw("User already allowed & registered")
230- else if (if ((currentStatus == userVerified))
231- then (status == userAllowed)
232- else false)
233- then throw("User already allowed & verified")
234- else {
235- let name = toBase64String(toBytes(getStringByKey(keyUserName(address))))
236- let thumb = toBase64String(toBytes(getStringByKey(keyUserThumb(address))))
237- let date = getIntegerByKey(keyUserDate(address))
238- let json = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + toString(date)) + "\"}")
239- if (containsElement([chris, joep, toString(this)], caller))
240- then [StringEntry(keyUserStatus(address), statusToSet), DeleteEntry(((currentStatus + "_") + address)), StringEntry(((statusToSet + "_") + address), json)]
241- else throw("Not allowed to change user status")
242- }
243- }
244-
245-
246-
247-@Callable(i)
248-func deleteUser (address) = {
249- let caller = toString(addressFromPublicKey(i.callerPublicKey))
250- let id = toBase58String(i.transactionId)
251- let currentStatus = getStringByKey(keyUserStatus(address))
252- if (containsElement([chris, toString(this)], caller))
253- then [DeleteEntry(keyUserDate(address)), DeleteEntry(keyUserAddr(address)), DeleteEntry(keyUserName(address)), DeleteEntry(keyUserDesc(address)), DeleteEntry(keyUserSocial(address)), DeleteEntry(keyUserThumb(address)), DeleteEntry(((currentStatus + "_") + address)), StringEntry(keyUserStatus(address), userRemoved)]
254- else throw("Not allowed")
54+ let timestamp = lastBlock.timestamp
55+ if (if ((name == ""))
56+ then true
57+ else (description == ""))
58+ then throw("Name and description cannot be empty")
59+ else if ((size(description) > 600))
60+ then throw("600 Char. max description")
61+ else if ((size(name) > 45))
62+ then throw("45 Char. max name")
63+ else {
64+ let json = (((((("{\"user_name\": \"" + toBase64String(toBytes(name))) + "\", \"user_thumb\":\"") + toBase64String(toBytes(thumb))) + "\",\"user_date\":\"") + toString(timestamp)) + "\"}")
65+[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), status), DeleteEntry(("ALLOWED_" + caller)), StringEntry(((status + "_") + caller), json)]
66+ }
25567 }
25668
25769
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let signAssetId = base58'Gf9t8FA4H3ssoZPCwrg3KwUFCci8zuUFP9ssRsUY3s6a'
5-
6-let chris = "3MsG6jPNCrVJUtYB7XJBxS7utWsXAf4n9Vp"
7-
8-let joep = "3Mzm4VLwsN9uZwbTMzPj3XuxV6kEfAR8UDN"
9-
10-let dappRunningKey = "conf_dapp_is_running"
11-
12-let maintenanceMSGKey = "conf_maintenance_msg"
13-
14-let whitelistedonlyKey = "conf_whitelisted_only"
15-
16-let dappRunning = match getBoolean(this, dappRunningKey) {
17- case a: Boolean =>
18- a
19- case _ =>
20- true
21-}
22-
23-let maintenanceMSG = match getString(this, maintenanceMSGKey) {
24- case a: String =>
25- a
26- case _ =>
27- ""
28-}
29-
30-let whitelistedonly = match getBoolean(this, whitelistedonlyKey) {
31- case a: Boolean =>
32- a
33- case _ =>
34- true
35-}
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-
534 func getStringByKey (key) = match getString(this, key) {
545 case a: String =>
556 a
567 case _ =>
578 ""
589 }
5910
6011
6112 func getBooleanByKey (key) = match getBoolean(this, key) {
6213 case a: Boolean =>
6314 a
6415 case _ =>
6516 false
6617 }
6718
6819
6920 func getIntegerByKey (key) = match getInteger(this, key) {
7021 case i: Int =>
7122 i
7223 case _ =>
7324 0
7425 }
7526
7627
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-
8428 func keyUserAddr (caller) = ("user_" + caller)
8529
8630
8731 func keyUserName (caller) = ("user_name_" + caller)
8832
8933
9034 func keyUserDesc (caller) = ("user_desc_" + caller)
9135
9236
9337 func keyUserSocial (caller) = ("user_social_" + caller)
9438
9539
9640 func keyUserThumb (caller) = ("user_thumb_" + caller)
9741
9842
9943 func keyUserStatus (caller) = ("user_status_" + caller)
10044
10145
10246 func keyUserDate (caller) = ("user_date_" + caller)
10347
10448
10549 @Callable(i)
106-func appRunning (isLive,message) = {
50+func registerUser (name,description,thumb,social,status) = {
10751 let caller = toString(addressFromPublicKey(i.callerPublicKey))
52+ let canRegister = getStringByKey(keyUserStatus(caller))
10853 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 {
154- let json = (((((("{\"user_name\": \"" + toBase64String(toBytes(name))) + "\", \"user_thumb\":\"") + toBase64String(toBytes(thumb))) + "\",\"user_date\":\"") + toString(timestamp)) + "\"}")
155-[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), DeleteEntry(("ALLOWED_" + caller)), StringEntry(((userRegistered + "_") + caller), json)]
156- }
157- }
158-
159-
160-
161-@Callable(i)
162-func updateUser (name,description,thumb,social) = if (!(dappRunning))
163- then throw(maintenanceMSG)
164- else {
165- let caller = toString(addressFromPublicKey(i.callerPublicKey))
166- let id = toBase58String(i.transactionId)
167- let canUpdate = getStringByKey(keyUserStatus(caller))
168- if (if ((canUpdate == userSuspended))
169- then true
170- else (canUpdate == userRemoved))
171- then throw("Account suspended/ removed.")
172- else if (if ((canUpdate == ""))
173- then true
174- else (canUpdate == userAllowed))
175- then throw("Register first")
176- else if (if ((name == ""))
177- then true
178- else (description == ""))
179- then throw("Name & description cannot be empty")
180- else if ((size(description) > 600))
181- then throw("600 Char. max for description")
182- else if ((size(name) > 45))
183- then throw("45 Char. max name")
184- else {
185- let date = getIntegerByKey(keyUserDate(caller))
186- let json = (((((("{\"user_name\": \"" + toBase64String(toBytes(name))) + "\", \"user_thumb\":\"") + toBase64String(toBytes(thumb))) + "\",\"user_date\":\"") + toString(date)) + "\"}")
187-[StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(((canUpdate + "_") + caller), json)]
188- }
189- }
190-
191-
192-
193-@Callable(i)
194-func changeUserStatus (address,status) = if (!(dappRunning))
195- then throw(maintenanceMSG)
196- else {
197- let caller = toString(addressFromPublicKey(i.callerPublicKey))
198- let id = toBase58String(i.transactionId)
199- let currentStatus = getStringByKey(keyUserStatus(address))
200- let statusToSet = if ((status == userVerified))
201- then userVerified
202- else if ((status == userRegistered))
203- then userRegistered
204- else if ((status == userSuspended))
205- then userSuspended
206- else if ((status == userRemoved))
207- then userRemoved
208- else if ((status == userAllowed))
209- then userAllowed
210- else if ((status == userChangeRequired))
211- then userChangeRequired
212- else if (if ((status == userReset))
213- then (currentStatus == userAllowed)
214- else false)
215- then ""
216- else throw("Unknown status")
217- let userIsRegistered = getIntegerByKey(keyUserDate(address))
218- if (if ((userIsRegistered == 0))
219- then (status != userAllowed)
220- else false)
221- then throw("You cant set this status, user is not registered.")
222- else if (if ((currentStatus == userAllowed))
223- then (status == userAllowed)
224- else false)
225- then throw("User already allowed")
226- else if (if ((currentStatus == userRegistered))
227- then (status == userAllowed)
228- else false)
229- then throw("User already allowed & registered")
230- else if (if ((currentStatus == userVerified))
231- then (status == userAllowed)
232- else false)
233- then throw("User already allowed & verified")
234- else {
235- let name = toBase64String(toBytes(getStringByKey(keyUserName(address))))
236- let thumb = toBase64String(toBytes(getStringByKey(keyUserThumb(address))))
237- let date = getIntegerByKey(keyUserDate(address))
238- let json = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + toString(date)) + "\"}")
239- if (containsElement([chris, joep, toString(this)], caller))
240- then [StringEntry(keyUserStatus(address), statusToSet), DeleteEntry(((currentStatus + "_") + address)), StringEntry(((statusToSet + "_") + address), json)]
241- else throw("Not allowed to change user status")
242- }
243- }
244-
245-
246-
247-@Callable(i)
248-func deleteUser (address) = {
249- let caller = toString(addressFromPublicKey(i.callerPublicKey))
250- let id = toBase58String(i.transactionId)
251- let currentStatus = getStringByKey(keyUserStatus(address))
252- if (containsElement([chris, toString(this)], caller))
253- then [DeleteEntry(keyUserDate(address)), DeleteEntry(keyUserAddr(address)), DeleteEntry(keyUserName(address)), DeleteEntry(keyUserDesc(address)), DeleteEntry(keyUserSocial(address)), DeleteEntry(keyUserThumb(address)), DeleteEntry(((currentStatus + "_") + address)), StringEntry(keyUserStatus(address), userRemoved)]
254- else throw("Not allowed")
54+ let timestamp = lastBlock.timestamp
55+ if (if ((name == ""))
56+ then true
57+ else (description == ""))
58+ then throw("Name and description cannot be empty")
59+ else if ((size(description) > 600))
60+ then throw("600 Char. max description")
61+ else if ((size(name) > 45))
62+ then throw("45 Char. max name")
63+ else {
64+ let json = (((((("{\"user_name\": \"" + toBase64String(toBytes(name))) + "\", \"user_thumb\":\"") + toBase64String(toBytes(thumb))) + "\",\"user_date\":\"") + toString(timestamp)) + "\"}")
65+[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), status), DeleteEntry(("ALLOWED_" + caller)), StringEntry(((status + "_") + caller), json)]
66+ }
25567 }
25668
25769

github/deemru/w8io/026f985 
31.45 ms