tx · B72PPuUBuHQFvxsfyi61v3jTLEMN8HpXoH192CZKiVHr

3N8xXaYjE27Aa79d5hHrhHu9HaFoTBmhDEj:  -0.01400000 Waves

2020.12.04 12:42 [1293750] smart account 3N8xXaYjE27Aa79d5hHrhHu9HaFoTBmhDEj > SELF 0.00000000 Waves

{ "type": 13, "id": "B72PPuUBuHQFvxsfyi61v3jTLEMN8HpXoH192CZKiVHr", "fee": 1400000, "feeAssetId": null, "timestamp": 1607074956443, "version": 2, "chainId": 84, "sender": "3N8xXaYjE27Aa79d5hHrhHu9HaFoTBmhDEj", "senderPublicKey": "A2m227AHcq7gWfSU59Q3UJaqkEa7SccFYmJuWHbFrrKE", "proofs": [ "21vVECAw98bqD3TU8oMfUsSXUJERsMQ3BCbvk5Rd11CHjt8eZuE53SLzLcK1BE5cJ1eWH2no4j4RKMm99AjbGeSp" ], "script": "base64:AAIEAAAAAAAAACcIAhIGCgQICAgIEgYKBAgICAgSBAoCCAgSAwoBCBIDCgEIEgMKAQgAAAAYAAAAAAtzaWduQXNzZXRJZAEAAAAg6KVqvMp3QvJwYTI1Sk9Fg7m5HuWZZxfDcerZC6EEresAAAAABWNocmlzAgAAACMzTXNHNmpQTkNyVkpVdFlCN1hKQnhTN3V0V3NYQWY0bjlWcAAAAAAEam9lcAIAAAAjM016bTRWTHdzTjl1WndiVE16UGozWHV4VjZrRWZBUjhVRE4AAAAAD1dISVRFTElTVEVET05MWQYAAAAAC2RhcHBSdW5uaW5nBgAAAAAObWFpbnRlbmFuY2VNU0cCAAAAHVNJR04gQXJ0IGlzIHVuZGVyIG1haW50ZW5hbmNlAAAAAAt1c2VyQWxsb3dlZAIAAAAHQUxMT1dFRAAAAAAOdXNlclJlZ2lzdGVyZWQCAAAAClJFR0lTVEVSRUQAAAAADHVzZXJWZXJpZmllZAIAAAAIVkVSSUZJRUQAAAAADXVzZXJTdXNwZW5kZWQCAAAACVNVU1BFTkRFRAAAAAALdXNlclJlbW92ZWQCAAAAB1JFTU9WRUQ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QAAAANuaWwJAAACAAAAAQIAAAACbm8AAAAAJLSm6A==", "height": 1293750, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4s9SjGRTTqLRo6uHyYTJpsmUYUgPiQkyaRcKAEzPRkpT Next: 2fJifczpEwhKC8xoHRFLcuqgqGwNFNovRiXGAgLzAQUb Diff:
OldNewDifferences
3434 a
3535 case _ =>
3636 ""
37+}
38+
39+
40+func getIntegerByKey (key) = match getInteger(this, key) {
41+ case i: Int =>
42+ i
43+ case _ =>
44+ 0
3745 }
3846
3947
148156 else false)
149157 then ""
150158 else throw("Unknown status")
151- if (if ((currentStatus == userAllowed))
152- then (status == userAllowed)
159+ let userIsRegistered = getIntegerByKey(keyUserDate(address))
160+ if (if ((userIsRegistered == 0))
161+ then (status != userAllowed)
153162 else false)
154- then throw("User already allowed")
155- else if (if ((currentStatus == userRegistered))
163+ then throw("You cant set this status, user is not registered.")
164+ else if (if ((currentStatus == userAllowed))
156165 then (status == userAllowed)
157166 else false)
158- then throw("User already allowed & registered")
159- else if (if ((currentStatus == userVerified))
167+ then throw("User already allowed")
168+ else if (if ((currentStatus == userRegistered))
160169 then (status == userAllowed)
161170 else false)
162- then throw("User already allowed & verified")
163- else if (containsElement([chris, joep], caller))
164- then [StringEntry(keyUserStatus(address), statusToSet)]
165- else throw(((("Not allowed to change user status " + caller) + " / ") + chris))
171+ then throw("User already allowed & registered")
172+ else if (if ((currentStatus == userVerified))
173+ then (status == userAllowed)
174+ else false)
175+ then throw("User already allowed & verified")
176+ else if (containsElement([chris, joep], caller))
177+ then [StringEntry(keyUserStatus(address), statusToSet)]
178+ else throw(((("Not allowed to change user status " + caller) + " / ") + chris))
166179 }
167180
168181
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let signAssetId = base58'Gf9t8FA4H3ssoZPCwrg3KwUFCci8zuUFP9ssRsUY3s6a'
55
66 let chris = "3MsG6jPNCrVJUtYB7XJBxS7utWsXAf4n9Vp"
77
88 let joep = "3Mzm4VLwsN9uZwbTMzPj3XuxV6kEfAR8UDN"
99
1010 let WHITELISTEDONLY = true
1111
1212 let dappRunning = true
1313
1414 let maintenanceMSG = "SIGN Art is under maintenance"
1515
1616 let userAllowed = "ALLOWED"
1717
1818 let userRegistered = "REGISTERED"
1919
2020 let userVerified = "VERIFIED"
2121
2222 let userSuspended = "SUSPENDED"
2323
2424 let userRemoved = "REMOVED"
2525
2626 let userChangeRequired = "CHANGE_REQUIRED"
2727
2828 let userUnregistered = "UNREGISTERED"
2929
3030 let userReset = "RESET"
3131
3232 func getStringByKey (key) = match getString(this, key) {
3333 case a: String =>
3434 a
3535 case _ =>
3636 ""
37+}
38+
39+
40+func getIntegerByKey (key) = match getInteger(this, key) {
41+ case i: Int =>
42+ i
43+ case _ =>
44+ 0
3745 }
3846
3947
4048 func validateCID (cid) = if (if ((75 > size(cid)))
4149 then (60 > size(split(cid, "/")[0]))
4250 else false)
4351 then (16 > size(split(cid, "/")[1]))
4452 else false
4553
4654
4755 func keyUserAddr (caller) = ("user_" + caller)
4856
4957
5058 func keyUserName (caller) = ("user_name_" + caller)
5159
5260
5361 func keyUserDesc (caller) = ("user_desc_" + caller)
5462
5563
5664 func keyUserSocial (caller) = ("user_social_" + caller)
5765
5866
5967 func keyUserThumb (caller) = ("user_thumb_" + caller)
6068
6169
6270 func keyUserStatus (caller) = ("user_status_" + caller)
6371
6472
6573 func keyUserDate (caller) = ("user_date_" + caller)
6674
6775
6876 @Callable(i)
6977 func registerUser (name,description,thumb,social) = if (!(dappRunning))
7078 then throw(maintenanceMSG)
7179 else {
7280 let caller = toString(addressFromPublicKey(i.callerPublicKey))
7381 let canRegister = getStringByKey(keyUserStatus(caller))
7482 let id = toBase58String(i.transactionId)
7583 let timestamp = lastBlock.timestamp
7684 if (if ((canRegister == userSuspended))
7785 then true
7886 else (canRegister == userRemoved))
7987 then throw("Account suspended/ removed.")
8088 else if ((canRegister == userRegistered))
8189 then throw("Already registered")
8290 else if (if ((canRegister == ""))
8391 then WHITELISTEDONLY
8492 else false)
8593 then throw("Can't register, get approved first.")
8694 else if (if ((name == ""))
8795 then true
8896 else (description == ""))
8997 then throw("Name and description cannot be empty")
9098 else if ((size(description) > 600))
9199 then throw("600 Char. max description")
92100 else if ((size(name) > 45))
93101 then throw("45 Char. max name")
94102 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)]
95103 }
96104
97105
98106
99107 @Callable(i)
100108 func updateUser (name,description,thumb,social) = if (!(dappRunning))
101109 then throw(maintenanceMSG)
102110 else {
103111 let caller = toString(addressFromPublicKey(i.callerPublicKey))
104112 let id = toBase58String(i.transactionId)
105113 let canUpdate = getStringByKey(keyUserStatus(caller))
106114 if (if ((canUpdate == userSuspended))
107115 then true
108116 else (canUpdate == userRemoved))
109117 then throw("Account suspended/ removed.")
110118 else if (if ((canUpdate == ""))
111119 then true
112120 else (canUpdate == userAllowed))
113121 then throw("Register first")
114122 else if (if ((name == ""))
115123 then true
116124 else (description == ""))
117125 then throw("Name & description cannot be empty")
118126 else if ((size(description) > 600))
119127 then throw("600 Char. max for description")
120128 else if ((size(name) > 45))
121129 then throw("45 Char. max name")
122130 else [StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb)]
123131 }
124132
125133
126134
127135 @Callable(i)
128136 func changeUserStatus (address,status) = if (!(dappRunning))
129137 then throw(maintenanceMSG)
130138 else {
131139 let caller = toString(addressFromPublicKey(i.callerPublicKey))
132140 let id = toBase58String(i.transactionId)
133141 let currentStatus = getStringByKey(keyUserStatus(address))
134142 let statusToSet = if ((status == userVerified))
135143 then userVerified
136144 else if ((status == userRegistered))
137145 then userRegistered
138146 else if ((status == userSuspended))
139147 then userSuspended
140148 else if ((status == userRemoved))
141149 then userRemoved
142150 else if ((status == userAllowed))
143151 then userAllowed
144152 else if ((status == userChangeRequired))
145153 then userChangeRequired
146154 else if (if ((status == userReset))
147155 then (currentStatus == userAllowed)
148156 else false)
149157 then ""
150158 else throw("Unknown status")
151- if (if ((currentStatus == userAllowed))
152- then (status == userAllowed)
159+ let userIsRegistered = getIntegerByKey(keyUserDate(address))
160+ if (if ((userIsRegistered == 0))
161+ then (status != userAllowed)
153162 else false)
154- then throw("User already allowed")
155- else if (if ((currentStatus == userRegistered))
163+ then throw("You cant set this status, user is not registered.")
164+ else if (if ((currentStatus == userAllowed))
156165 then (status == userAllowed)
157166 else false)
158- then throw("User already allowed & registered")
159- else if (if ((currentStatus == userVerified))
167+ then throw("User already allowed")
168+ else if (if ((currentStatus == userRegistered))
160169 then (status == userAllowed)
161170 else false)
162- then throw("User already allowed & verified")
163- else if (containsElement([chris, joep], caller))
164- then [StringEntry(keyUserStatus(address), statusToSet)]
165- else throw(((("Not allowed to change user status " + caller) + " / ") + chris))
171+ then throw("User already allowed & registered")
172+ else if (if ((currentStatus == userVerified))
173+ then (status == userAllowed)
174+ else false)
175+ then throw("User already allowed & verified")
176+ else if (containsElement([chris, joep], caller))
177+ then [StringEntry(keyUserStatus(address), statusToSet)]
178+ else throw(((("Not allowed to change user status " + caller) + " / ") + chris))
166179 }
167180
168181
169182
170183 @Callable(i)
171184 func creditUser (address) = {
172185 let caller = toString(addressFromPublicKey(i.callerPublicKey))
173186 let id = toBase58String(i.transactionId)
174187 if (containsElement([chris, joep], caller))
175188 then [ScriptTransfer(Address(fromBase58String(address)), 30000000000, signAssetId)]
176189 else throw("Not allowed")
177190 }
178191
179192
180193
181194 @Callable(i)
182195 func deleteUser (address) = {
183196 let caller = toString(addressFromPublicKey(i.callerPublicKey))
184197 let id = toBase58String(i.transactionId)
185198 if (containsElement([chris, joep], caller))
186199 then [DeleteEntry(keyUserDate(address)), DeleteEntry(keyUserAddr(address)), DeleteEntry(keyUserName(address)), DeleteEntry(keyUserDesc(address)), DeleteEntry(keyUserSocial(address)), DeleteEntry(keyUserThumb(address)), StringEntry(keyUserStatus(address), userRemoved)]
187200 else throw("Not allowed")
188201 }
189202
190203
191204
192205 @Callable(i)
193206 func deleteEntry (entry) = {
194207 let caller = toString(addressFromPublicKey(i.callerPublicKey))
195208 if ((caller == chris))
196209 then [DeleteEntry(entry)]
197210 else throw("no")
198211 }
199212
200213

github/deemru/w8io/026f985 
44.06 ms