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:AAIEAAAAAAAAACcIAhIGCgQICAgIEgYKBAgICAgSBAoCCAgSAwoBCBIDCgEIEgMKAQgAAAAYAAAAAAtzaWduQXNzZXRJZAEAAAAg6KVqvMp3QvJwYTI1Sk9Fg7m5HuWZZxfDcerZC6EEresAAAAABWNocmlzAgAAACMzTXNHNmpQTkNyVkpVdFlCN1hKQnhTN3V0V3NYQWY0bjlWcAAAAAAEam9lcAIAAAAjM016bTRWTHdzTjl1WndiVE16UGozWHV4VjZrRWZBUjhVRE4AAAAAD1dISVRFTElTVEVET05MWQYAAAAAC2RhcHBSdW5uaW5nBgAAAAAObWFpbnRlbmFuY2VNU0cCAAAAHVNJR04gQXJ0IGlzIHVuZGVyIG1haW50ZW5hbmNlAAAAAAt1c2VyQWxsb3dlZAIAAAAHQUxMT1dFRAAAAAAOdXNlclJlZ2lzdGVyZWQCAAAAClJFR0lTVEVSRUQAAAAADHVzZXJWZXJpZmllZAIAAAAIVkVSSUZJRUQAAAAADXVzZXJTdXNwZW5kZWQCAAAACVNVU1BFTkRFRAAAAAALdXNlclJlbW92ZWQCAAAAB1JFTU9WRUQA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AAAANuaWwJAAACAAAAAQIAAAACbm8AAAAAJLSm6A==", "height": 1293750, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4s9SjGRTTqLRo6uHyYTJpsmUYUgPiQkyaRcKAEzPRkpT Next: 2fJifczpEwhKC8xoHRFLcuqgqGwNFNovRiXGAgLzAQUb Diff:
Old | New | Differences | |
---|---|---|---|
34 | 34 | a | |
35 | 35 | case _ => | |
36 | 36 | "" | |
37 | + | } | |
38 | + | ||
39 | + | ||
40 | + | func getIntegerByKey (key) = match getInteger(this, key) { | |
41 | + | case i: Int => | |
42 | + | i | |
43 | + | case _ => | |
44 | + | 0 | |
37 | 45 | } | |
38 | 46 | ||
39 | 47 | ||
148 | 156 | else false) | |
149 | 157 | then "" | |
150 | 158 | 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) | |
153 | 162 | else false) | |
154 | - | then throw(" | |
155 | - | else if (if ((currentStatus == | |
163 | + | then throw("You cant set this status, user is not registered.") | |
164 | + | else if (if ((currentStatus == userAllowed)) | |
156 | 165 | then (status == userAllowed) | |
157 | 166 | else false) | |
158 | - | then throw("User already allowed | |
159 | - | else if (if ((currentStatus == | |
167 | + | then throw("User already allowed") | |
168 | + | else if (if ((currentStatus == userRegistered)) | |
160 | 169 | then (status == userAllowed) | |
161 | 170 | 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)) | |
166 | 179 | } | |
167 | 180 | ||
168 | 181 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let signAssetId = base58'Gf9t8FA4H3ssoZPCwrg3KwUFCci8zuUFP9ssRsUY3s6a' | |
5 | 5 | ||
6 | 6 | let chris = "3MsG6jPNCrVJUtYB7XJBxS7utWsXAf4n9Vp" | |
7 | 7 | ||
8 | 8 | let joep = "3Mzm4VLwsN9uZwbTMzPj3XuxV6kEfAR8UDN" | |
9 | 9 | ||
10 | 10 | let WHITELISTEDONLY = true | |
11 | 11 | ||
12 | 12 | let dappRunning = true | |
13 | 13 | ||
14 | 14 | let maintenanceMSG = "SIGN Art is under maintenance" | |
15 | 15 | ||
16 | 16 | let userAllowed = "ALLOWED" | |
17 | 17 | ||
18 | 18 | let userRegistered = "REGISTERED" | |
19 | 19 | ||
20 | 20 | let userVerified = "VERIFIED" | |
21 | 21 | ||
22 | 22 | let userSuspended = "SUSPENDED" | |
23 | 23 | ||
24 | 24 | let userRemoved = "REMOVED" | |
25 | 25 | ||
26 | 26 | let userChangeRequired = "CHANGE_REQUIRED" | |
27 | 27 | ||
28 | 28 | let userUnregistered = "UNREGISTERED" | |
29 | 29 | ||
30 | 30 | let userReset = "RESET" | |
31 | 31 | ||
32 | 32 | func getStringByKey (key) = match getString(this, key) { | |
33 | 33 | case a: String => | |
34 | 34 | a | |
35 | 35 | case _ => | |
36 | 36 | "" | |
37 | + | } | |
38 | + | ||
39 | + | ||
40 | + | func getIntegerByKey (key) = match getInteger(this, key) { | |
41 | + | case i: Int => | |
42 | + | i | |
43 | + | case _ => | |
44 | + | 0 | |
37 | 45 | } | |
38 | 46 | ||
39 | 47 | ||
40 | 48 | func validateCID (cid) = if (if ((75 > size(cid))) | |
41 | 49 | then (60 > size(split(cid, "/")[0])) | |
42 | 50 | else false) | |
43 | 51 | then (16 > size(split(cid, "/")[1])) | |
44 | 52 | else false | |
45 | 53 | ||
46 | 54 | ||
47 | 55 | func keyUserAddr (caller) = ("user_" + caller) | |
48 | 56 | ||
49 | 57 | ||
50 | 58 | func keyUserName (caller) = ("user_name_" + caller) | |
51 | 59 | ||
52 | 60 | ||
53 | 61 | func keyUserDesc (caller) = ("user_desc_" + caller) | |
54 | 62 | ||
55 | 63 | ||
56 | 64 | func keyUserSocial (caller) = ("user_social_" + caller) | |
57 | 65 | ||
58 | 66 | ||
59 | 67 | func keyUserThumb (caller) = ("user_thumb_" + caller) | |
60 | 68 | ||
61 | 69 | ||
62 | 70 | func keyUserStatus (caller) = ("user_status_" + caller) | |
63 | 71 | ||
64 | 72 | ||
65 | 73 | func keyUserDate (caller) = ("user_date_" + caller) | |
66 | 74 | ||
67 | 75 | ||
68 | 76 | @Callable(i) | |
69 | 77 | func registerUser (name,description,thumb,social) = if (!(dappRunning)) | |
70 | 78 | then throw(maintenanceMSG) | |
71 | 79 | else { | |
72 | 80 | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
73 | 81 | let canRegister = getStringByKey(keyUserStatus(caller)) | |
74 | 82 | let id = toBase58String(i.transactionId) | |
75 | 83 | let timestamp = lastBlock.timestamp | |
76 | 84 | if (if ((canRegister == userSuspended)) | |
77 | 85 | then true | |
78 | 86 | else (canRegister == userRemoved)) | |
79 | 87 | then throw("Account suspended/ removed.") | |
80 | 88 | else if ((canRegister == userRegistered)) | |
81 | 89 | then throw("Already registered") | |
82 | 90 | else if (if ((canRegister == "")) | |
83 | 91 | then WHITELISTEDONLY | |
84 | 92 | else false) | |
85 | 93 | then throw("Can't register, get approved first.") | |
86 | 94 | else if (if ((name == "")) | |
87 | 95 | then true | |
88 | 96 | else (description == "")) | |
89 | 97 | then throw("Name and description cannot be empty") | |
90 | 98 | else if ((size(description) > 600)) | |
91 | 99 | then throw("600 Char. max description") | |
92 | 100 | else if ((size(name) > 45)) | |
93 | 101 | then throw("45 Char. max name") | |
94 | 102 | 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)] | |
95 | 103 | } | |
96 | 104 | ||
97 | 105 | ||
98 | 106 | ||
99 | 107 | @Callable(i) | |
100 | 108 | func updateUser (name,description,thumb,social) = if (!(dappRunning)) | |
101 | 109 | then throw(maintenanceMSG) | |
102 | 110 | else { | |
103 | 111 | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
104 | 112 | let id = toBase58String(i.transactionId) | |
105 | 113 | let canUpdate = getStringByKey(keyUserStatus(caller)) | |
106 | 114 | if (if ((canUpdate == userSuspended)) | |
107 | 115 | then true | |
108 | 116 | else (canUpdate == userRemoved)) | |
109 | 117 | then throw("Account suspended/ removed.") | |
110 | 118 | else if (if ((canUpdate == "")) | |
111 | 119 | then true | |
112 | 120 | else (canUpdate == userAllowed)) | |
113 | 121 | then throw("Register first") | |
114 | 122 | else if (if ((name == "")) | |
115 | 123 | then true | |
116 | 124 | else (description == "")) | |
117 | 125 | then throw("Name & description cannot be empty") | |
118 | 126 | else if ((size(description) > 600)) | |
119 | 127 | then throw("600 Char. max for description") | |
120 | 128 | else if ((size(name) > 45)) | |
121 | 129 | then throw("45 Char. max name") | |
122 | 130 | else [StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb)] | |
123 | 131 | } | |
124 | 132 | ||
125 | 133 | ||
126 | 134 | ||
127 | 135 | @Callable(i) | |
128 | 136 | func changeUserStatus (address,status) = if (!(dappRunning)) | |
129 | 137 | then throw(maintenanceMSG) | |
130 | 138 | else { | |
131 | 139 | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
132 | 140 | let id = toBase58String(i.transactionId) | |
133 | 141 | let currentStatus = getStringByKey(keyUserStatus(address)) | |
134 | 142 | let statusToSet = if ((status == userVerified)) | |
135 | 143 | then userVerified | |
136 | 144 | else if ((status == userRegistered)) | |
137 | 145 | then userRegistered | |
138 | 146 | else if ((status == userSuspended)) | |
139 | 147 | then userSuspended | |
140 | 148 | else if ((status == userRemoved)) | |
141 | 149 | then userRemoved | |
142 | 150 | else if ((status == userAllowed)) | |
143 | 151 | then userAllowed | |
144 | 152 | else if ((status == userChangeRequired)) | |
145 | 153 | then userChangeRequired | |
146 | 154 | else if (if ((status == userReset)) | |
147 | 155 | then (currentStatus == userAllowed) | |
148 | 156 | else false) | |
149 | 157 | then "" | |
150 | 158 | 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) | |
153 | 162 | else false) | |
154 | - | then throw(" | |
155 | - | else if (if ((currentStatus == | |
163 | + | then throw("You cant set this status, user is not registered.") | |
164 | + | else if (if ((currentStatus == userAllowed)) | |
156 | 165 | then (status == userAllowed) | |
157 | 166 | else false) | |
158 | - | then throw("User already allowed | |
159 | - | else if (if ((currentStatus == | |
167 | + | then throw("User already allowed") | |
168 | + | else if (if ((currentStatus == userRegistered)) | |
160 | 169 | then (status == userAllowed) | |
161 | 170 | 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)) | |
166 | 179 | } | |
167 | 180 | ||
168 | 181 | ||
169 | 182 | ||
170 | 183 | @Callable(i) | |
171 | 184 | func creditUser (address) = { | |
172 | 185 | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
173 | 186 | let id = toBase58String(i.transactionId) | |
174 | 187 | if (containsElement([chris, joep], caller)) | |
175 | 188 | then [ScriptTransfer(Address(fromBase58String(address)), 30000000000, signAssetId)] | |
176 | 189 | else throw("Not allowed") | |
177 | 190 | } | |
178 | 191 | ||
179 | 192 | ||
180 | 193 | ||
181 | 194 | @Callable(i) | |
182 | 195 | func deleteUser (address) = { | |
183 | 196 | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
184 | 197 | let id = toBase58String(i.transactionId) | |
185 | 198 | if (containsElement([chris, joep], caller)) | |
186 | 199 | then [DeleteEntry(keyUserDate(address)), DeleteEntry(keyUserAddr(address)), DeleteEntry(keyUserName(address)), DeleteEntry(keyUserDesc(address)), DeleteEntry(keyUserSocial(address)), DeleteEntry(keyUserThumb(address)), StringEntry(keyUserStatus(address), userRemoved)] | |
187 | 200 | else throw("Not allowed") | |
188 | 201 | } | |
189 | 202 | ||
190 | 203 | ||
191 | 204 | ||
192 | 205 | @Callable(i) | |
193 | 206 | func deleteEntry (entry) = { | |
194 | 207 | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
195 | 208 | if ((caller == chris)) | |
196 | 209 | then [DeleteEntry(entry)] | |
197 | 210 | else throw("no") | |
198 | 211 | } | |
199 | 212 | ||
200 | 213 |
github/deemru/w8io/026f985 35.99 ms ◑