tx · HW186RTVs18x4qX7wqseGHXFDZDPVGd6vE3Z6Zgo2S7L 3MvpFffWWo5or6sUZeRmSSxKSbiZkArx7En: -0.01400000 Waves 2022.10.22 09:46 [2283266] smart account 3MvpFffWWo5or6sUZeRmSSxKSbiZkArx7En > SELF 0.00000000 Waves
{ "type": 13, "id": "HW186RTVs18x4qX7wqseGHXFDZDPVGd6vE3Z6Zgo2S7L", "fee": 1400000, "feeAssetId": null, "timestamp": 1666421230152, "version": 2, "chainId": 84, "sender": "3MvpFffWWo5or6sUZeRmSSxKSbiZkArx7En", "senderPublicKey": "4pdv1bda9eVqVBp5VvxCh7vZWnTAYzoQuidCZhupq1Ak", "proofs": [ "3fLu5xoFcbgTQ94RHo2NU8WAZsMp5XGU2wJXbJa5dRoFEtW7masuSQXprnZKimSXbW4LbaCknsoQebK4yDdr2RJ" ], "script": "base64:BgIqCAISBAoCCAgSBAoCBAgSBgoECAgICBIGCgQICAgIEgUKAwgICBIDCgEIGAAHVkVSU0lPTgIDMS4wAQ5nZXRTdHJpbmdCeUtleQEDa2V5CQELdmFsdWVPckVsc2UCCQCdCAIFBHRoaXMFA2tleQIAAQ9nZXRCb29sZWFuQnlLZXkBA2tleQkBC3ZhbHVlT3JFbHNlAgkAmwgCBQR0aGlzBQNrZXkHAQ9nZXRJbnRlZ2VyQnlLZXkBA2tleQkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBQNrZXkAAAAFY2hyaXMJAQ5nZXRTdHJpbmdCeUtleQECDGNvbmZfYWRtaW5fMQAOZGFwcFJ1bm5pbmdLZXkCFGNvbmZfZGFwcF9pc19ydW5uaW5nABFtYWludGVuYW5jZU1TR0tleQIUY29uZl9tYWludGVuYW5jZV9tc2cAC2RhcHBSdW5uaW5nCQELdmFsdWVPckVsc2UCCQCbCAIFBHRoaXMFDmRhcHBSdW5uaW5nS2V5BgAObWFpbnRlbmFuY2VNU0cJAQt2YWx1ZU9yRWxzZQIJAJ0IAgUEdGhpcwURbWFpbnR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kBCQEMa2V5VXNlclRodW1iAQUHYWRkcmVzcwQLZGVzY3JpcHRpb24JANoEAQkAmwMBCQEOZ2V0U3RyaW5nQnlLZXkBCQELa2V5VXNlckRlc2MBBQdhZGRyZXNzBAZzb2NpYWwJANoEAQkAmwMBCQEOZ2V0U3RyaW5nQnlLZXkBCQENa2V5VXNlclNvY2lhbAEFB2FkZHJlc3MEBGRhdGUJAQ9nZXRJbnRlZ2VyQnlLZXkBCQELa2V5VXNlckRhdGUBBQdhZGRyZXNzBARqc29uCQEIbWFrZUpTT04FBQRuYW1lBQtkZXNjcmlwdGlvbgUGc29jaWFsBQV0aHVtYgkApAMBBQRkYXRlAwkBD2NvbnRhaW5zRWxlbWVudAIJAMwIAgUFY2hyaXMJAMwIAgkApQgBBQR0aGlzBQNuaWwFBmNhbGxlcgkAzAgCCQELU3RyaW5nRW50cnkCCQENa2V5VXNlclN0YXR1cwEFB2FkZHJlc3MFC3N0YXR1c1RvU2V0CQDMCAIJAQtEZWxldGVFbnRyeQEJAKwCAgkArAICBQ1jdXJyZW50U3RhdHVzAgFfBQdhZGRyZXNzCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICBQtzdGF0dXNUb1NldAIBXwUHYWRkcmVzcwUEanNvbgkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgICCnVzZXJfbm90ZV8FB2FkZHJlc3MFBG5vdGUFA25pbAkAAgECIU5vdCBhbGxvd2VkIHRvIGNoYW5nZSB1c2VyIHN0YXR1cwFpAQtkZWxldGVFbnRyeQEFZW50cnkEBmNhbGxlcgkApQgBCAUBaQZjYWxsZXIDCQAAAgUGY2FsbGVyBQVjaHJpcwkAzAgCCQELRGVsZXRlRW50cnkBBQVlbnRyeQUDbmlsCQACAQICbm8Af3kUVg==", "height": 2283266, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FJs5jKw9FTDMmMiQCXY2WjNFzM1Fr6m82pgXhe4ncLNz Next: 9DfxXRLS4AaXTEWzdA9ZSguZGE2W352uFHkhTJ5NKZHn Diff:
Old | New | Differences | |
---|---|---|---|
105 | 105 | } | |
106 | 106 | ||
107 | 107 | ||
108 | - | func makeJSON (name,thumb,date) = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + date) + "\"}") | |
108 | + | func makeJSON (name,description,social,thumb,date) = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + date) + "\"}") | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | @Callable(invoke) | |
138 | 138 | if (!(validUserData(caller, name, description, thumb, false))) | |
139 | 139 | then throw("Something went wrong") | |
140 | 140 | else { | |
141 | - | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(timestamp)) | |
141 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(description)), toBase64String(toBytes(social)), toBase64String(toBytes(thumb)), toString(timestamp)) | |
142 | 142 | [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), StringEntry(((userRegistered + "_") + caller), json)] | |
143 | 143 | } | |
144 | 144 | } | |
155 | 155 | then throw("Something went wrong") | |
156 | 156 | else { | |
157 | 157 | let date = getIntegerByKey(keyUserDate(caller)) | |
158 | - | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(date)) | |
158 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(description)), toBase64String(toBytes(social)), toBase64String(toBytes(thumb)), toString(date)) | |
159 | 159 | [StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(((status + "_") + caller), json)] | |
160 | 160 | } | |
161 | 161 | } | |
169 | 169 | let statusToSet = validateNewStatus(status, address, currentStatus) | |
170 | 170 | let name = toBase64String(toBytes(getStringByKey(keyUserName(address)))) | |
171 | 171 | let thumb = toBase64String(toBytes(getStringByKey(keyUserThumb(address)))) | |
172 | + | let description = toBase64String(toBytes(getStringByKey(keyUserDesc(address)))) | |
173 | + | let social = toBase64String(toBytes(getStringByKey(keyUserSocial(address)))) | |
172 | 174 | let date = getIntegerByKey(keyUserDate(address)) | |
173 | - | let json = makeJSON(name, thumb, toString(date)) | |
175 | + | let json = makeJSON(name, description, social, thumb, toString(date)) | |
174 | 176 | if (containsElement([chris, toString(this)], caller)) | |
175 | 177 | then [StringEntry(keyUserStatus(address), statusToSet), DeleteEntry(((currentStatus + "_") + address)), StringEntry(((statusToSet + "_") + address), json), StringEntry(("user_note_" + address), note)] | |
176 | 178 | else throw("Not allowed to change user status") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let VERSION = "1.0" | |
5 | 5 | ||
6 | 6 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func getBooleanByKey (key) = valueOrElse(getBoolean(this, key), false) | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func getIntegerByKey (key) = valueOrElse(getInteger(this, key), 0) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | let chris = getStringByKey("conf_admin_1") | |
16 | 16 | ||
17 | 17 | let dappRunningKey = "conf_dapp_is_running" | |
18 | 18 | ||
19 | 19 | let maintenanceMSGKey = "conf_maintenance_msg" | |
20 | 20 | ||
21 | 21 | let dappRunning = valueOrElse(getBoolean(this, dappRunningKey), true) | |
22 | 22 | ||
23 | 23 | let maintenanceMSG = valueOrElse(getString(this, maintenanceMSGKey), "") | |
24 | 24 | ||
25 | 25 | let userRegistered = "REGISTERED" | |
26 | 26 | ||
27 | 27 | let userVerified = "VERIFIED" | |
28 | 28 | ||
29 | 29 | let userSuspended = "SUSPENDED" | |
30 | 30 | ||
31 | 31 | let userChangeRequired = "CHANGE_REQUIRED" | |
32 | 32 | ||
33 | 33 | func keyUserAddr (caller) = ("user_" + caller) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func keyUserName (caller) = ("user_name_" + caller) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func keyUserDesc (caller) = ("user_desc_" + caller) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func keyUserSocial (caller) = ("user_social_" + caller) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func keyUserThumb (caller) = ("user_thumb_" + caller) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func keyUserStatus (caller) = ("user_status_" + caller) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func keyUserDate (caller) = ("user_date_" + caller) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func validateCID (cid) = if (contains(cid, "/")) | |
55 | 55 | then if (if ((76 > size(cid))) | |
56 | 56 | then (size(split(cid, "/")[0]) == 59) | |
57 | 57 | else false) | |
58 | 58 | then (16 > size(split(cid, "/")[1])) | |
59 | 59 | else false | |
60 | 60 | else false | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func validUserData (caller,name,description,thumb,isAnUpdate) = { | |
64 | 64 | let validCID = if ((size(thumb) != 0)) | |
65 | 65 | then validateCID(thumb) | |
66 | 66 | else true | |
67 | 67 | if (!(validCID)) | |
68 | 68 | then throw("CID don't match requirement!") | |
69 | 69 | else if (if ((name == "")) | |
70 | 70 | then true | |
71 | 71 | else (description == "")) | |
72 | 72 | then throw("Name and description cannot be empty") | |
73 | 73 | else if ((size(description) > 600)) | |
74 | 74 | then throw("600 Char. max description") | |
75 | 75 | else if ((size(name) > 100)) | |
76 | 76 | then throw("100 Char. max name") | |
77 | 77 | else { | |
78 | 78 | let status = getStringByKey(keyUserStatus(caller)) | |
79 | 79 | if ((status == userSuspended)) | |
80 | 80 | then throw("Account suspended.") | |
81 | 81 | else if (if (!(isAnUpdate)) | |
82 | 82 | then (status == userRegistered) | |
83 | 83 | else false) | |
84 | 84 | then throw("Already registered") | |
85 | 85 | else if (if (if (isAnUpdate) | |
86 | 86 | then (status == "") | |
87 | 87 | else false) | |
88 | 88 | then true | |
89 | 89 | else isAnUpdate) | |
90 | 90 | then throw("Register first") | |
91 | 91 | else true | |
92 | 92 | } | |
93 | 93 | } | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func validateNewStatus (status,address,currentStatus) = { | |
97 | 97 | let allStatus = [userVerified, userRegistered, userSuspended, userChangeRequired] | |
98 | 98 | let statusToSet = if (containsElement(allStatus, status)) | |
99 | 99 | then status | |
100 | 100 | else throw("Unknown status") | |
101 | 101 | let userIsRegistered = getIntegerByKey(keyUserDate(address)) | |
102 | 102 | if ((userIsRegistered == 0)) | |
103 | 103 | then throw("You cant set this status, user is not registered.") | |
104 | 104 | else statusToSet | |
105 | 105 | } | |
106 | 106 | ||
107 | 107 | ||
108 | - | func makeJSON (name,thumb,date) = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + date) + "\"}") | |
108 | + | func makeJSON (name,description,social,thumb,date) = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + date) + "\"}") | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | @Callable(invoke) | |
112 | 112 | func setConf (key,val) = { | |
113 | 113 | let caller = toString(invoke.caller) | |
114 | 114 | if (containsElement([chris, toString(this)], caller)) | |
115 | 115 | then [StringEntry(key, val)] | |
116 | 116 | else throw("You are not allowed to change this") | |
117 | 117 | } | |
118 | 118 | ||
119 | 119 | ||
120 | 120 | ||
121 | 121 | @Callable(invoke) | |
122 | 122 | func appRunning (isLive,message) = { | |
123 | 123 | let caller = toString(invoke.caller) | |
124 | 124 | if (containsElement([chris, toString(this)], caller)) | |
125 | 125 | then [BooleanEntry(dappRunningKey, isLive), StringEntry(maintenanceMSGKey, message)] | |
126 | 126 | else throw("You are not allowed to change this") | |
127 | 127 | } | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | ||
131 | 131 | @Callable(invoke) | |
132 | 132 | func registerUser (name,description,thumb,social) = if (!(dappRunning)) | |
133 | 133 | then throw(maintenanceMSG) | |
134 | 134 | else { | |
135 | 135 | let caller = toString(invoke.caller) | |
136 | 136 | let id = toBase58String(invoke.transactionId) | |
137 | 137 | let timestamp = lastBlock.timestamp | |
138 | 138 | if (!(validUserData(caller, name, description, thumb, false))) | |
139 | 139 | then throw("Something went wrong") | |
140 | 140 | else { | |
141 | - | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(timestamp)) | |
141 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(description)), toBase64String(toBytes(social)), toBase64String(toBytes(thumb)), toString(timestamp)) | |
142 | 142 | [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), StringEntry(((userRegistered + "_") + caller), json)] | |
143 | 143 | } | |
144 | 144 | } | |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | 148 | @Callable(invoke) | |
149 | 149 | func updateUser (name,description,thumb,social) = if (!(dappRunning)) | |
150 | 150 | then throw(maintenanceMSG) | |
151 | 151 | else { | |
152 | 152 | let caller = toString(invoke.caller) | |
153 | 153 | let status = getStringByKey(keyUserStatus(caller)) | |
154 | 154 | if (!(validUserData(caller, name, description, thumb, true))) | |
155 | 155 | then throw("Something went wrong") | |
156 | 156 | else { | |
157 | 157 | let date = getIntegerByKey(keyUserDate(caller)) | |
158 | - | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(date)) | |
158 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(description)), toBase64String(toBytes(social)), toBase64String(toBytes(thumb)), toString(date)) | |
159 | 159 | [StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(((status + "_") + caller), json)] | |
160 | 160 | } | |
161 | 161 | } | |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | 165 | @Callable(invoke) | |
166 | 166 | func changeUserStatus (address,status,note) = { | |
167 | 167 | let caller = toString(invoke.caller) | |
168 | 168 | let currentStatus = getStringByKey(keyUserStatus(address)) | |
169 | 169 | let statusToSet = validateNewStatus(status, address, currentStatus) | |
170 | 170 | let name = toBase64String(toBytes(getStringByKey(keyUserName(address)))) | |
171 | 171 | let thumb = toBase64String(toBytes(getStringByKey(keyUserThumb(address)))) | |
172 | + | let description = toBase64String(toBytes(getStringByKey(keyUserDesc(address)))) | |
173 | + | let social = toBase64String(toBytes(getStringByKey(keyUserSocial(address)))) | |
172 | 174 | let date = getIntegerByKey(keyUserDate(address)) | |
173 | - | let json = makeJSON(name, thumb, toString(date)) | |
175 | + | let json = makeJSON(name, description, social, thumb, toString(date)) | |
174 | 176 | if (containsElement([chris, toString(this)], caller)) | |
175 | 177 | then [StringEntry(keyUserStatus(address), statusToSet), DeleteEntry(((currentStatus + "_") + address)), StringEntry(((statusToSet + "_") + address), json), StringEntry(("user_note_" + address), note)] | |
176 | 178 | else throw("Not allowed to change user status") | |
177 | 179 | } | |
178 | 180 | ||
179 | 181 | ||
180 | 182 | ||
181 | 183 | @Callable(i) | |
182 | 184 | func deleteEntry (entry) = { | |
183 | 185 | let caller = toString(i.caller) | |
184 | 186 | if ((caller == chris)) | |
185 | 187 | then [DeleteEntry(entry)] | |
186 | 188 | else throw("no") | |
187 | 189 | } | |
188 | 190 | ||
189 | 191 |
github/deemru/w8io/026f985 50.19 ms ◑