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