tx · Dt8coWdSc5QNzHdEka83612oEkAAhV21ufHbWyF4S9pi 3N3r2srkFiS6xvSDY9xVPgF2Yjz8djnd3cN: -0.01000000 Waves 2023.02.28 06:04 [2468985] smart account 3N3r2srkFiS6xvSDY9xVPgF2Yjz8djnd3cN > SELF 0.00000000 Waves
{ "type": 13, "id": "Dt8coWdSc5QNzHdEka83612oEkAAhV21ufHbWyF4S9pi", "fee": 1000000, "feeAssetId": null, "timestamp": 1677553485703, "version": 2, "chainId": 84, "sender": "3N3r2srkFiS6xvSDY9xVPgF2Yjz8djnd3cN", "senderPublicKey": "Ea9xszKCieHW2X9h4i9PEKXbMC4GDCkHwLoK3FY5T6nC", "proofs": [ "3nidNT4sxUXzsb9W93PoanyiFXaNEuobxXMo55J7xuCPzEYc3anvvMwZi7PdLAEt6Ca17p3AwavNAbzprrP1VkWE" ], "script": "base64:BgIsCAISBAoCCAgSBAoCBAgSBwoFCAgICAgSBwoFCAgICAgSBQoDCAgIEgMKAQgeAAdWRVJTSU9OAgExAQ5nZXRTdHJpbmdCeUtleQEDa2V5CQELdmFsdWVPckVsc2UCCQCdCAIFBHRoaXMFA2tleQIAAQ9nZXRCb29sZWFuQnlLZXkBA2tleQkBC3ZhbHVlT3JFbHNlAgkAmwgCBQR0aGlzBQNrZXkHAQ9nZXRJbnRlZ2VyQnlLZXkBA2tleQkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBQNrZXkAAAAFY2hyaXMJAQ5nZXRTdHJpbmdCeUtleQECDGNvbmZfYWRtaW5fMQAOZGFwcFJ1bm5pbmdLZXkCFGNvbmZfZGFwcF9pc19ydW5uaW5nABFtYWludGVuYW5jZU1TR0tleQIUY29uZl9tYWludGVuYW5jZV9tc2cAEndoaXRlbGlzdGVkb25seUtleQIVY29uZl93aGl0ZWxpc3RlZF9vbmx5AAtkYXBwUnVubmluZwkBC3ZhbHVlT3JFbHNlAgkAmwgCBQR0aGlzBQ5kYXBwUnVubmluZ0tleQYADm1haW50ZW5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CBhbGxvd2VkIHRvIGNoYW5nZSB1c2VyIHN0YXR1cwFpAQtkZWxldGVFbnRyeQEFZW50cnkEBmNhbGxlcgkApQgBCAUBaQZjYWxsZXIDCQAAAgUGY2FsbGVyBQVjaHJpcwkAzAgCCQELRGVsZXRlRW50cnkBBQVlbnRyeQUDbmlsCQACAQICbm8A+5oEtw==", "height": 2468985, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4H3AaSGtRRNRjWLJV3kqndyiy7NyFSdYHH39WvPCQits Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let VERSION = " | |
4 | + | let VERSION = "1" | |
5 | 5 | ||
6 | 6 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
7 | 7 | ||
133 | 133 | ||
134 | 134 | ||
135 | 135 | func validatePayment (i) = { | |
136 | - | let $ | |
137 | - | let payment = $ | |
138 | - | let amount = $ | |
136 | + | let $t039754011 = isPayment(i) | |
137 | + | let payment = $t039754011._1 | |
138 | + | let amount = $t039754011._2 | |
139 | 139 | let assetId = if (if (isDefined(payment.assetId)) | |
140 | 140 | then (payment.assetId == signAssetId) | |
141 | 141 | else false) | |
168 | 168 | ||
169 | 169 | ||
170 | 170 | @Callable(invoke) | |
171 | - | func registerUser (name,description,thumb,social) = if (!(dappRunning)) | |
171 | + | func registerUser (name,description,thumb,social,pubKey) = if (!(dappRunning)) | |
172 | 172 | then throw(maintenanceMSG) | |
173 | 173 | else { | |
174 | 174 | let caller = toString(invoke.caller) | |
175 | 175 | let id = toBase58String(invoke.transactionId) | |
176 | 176 | let timestamp = lastBlock.timestamp | |
177 | - | let $ | |
178 | - | let amount = $ | |
179 | - | let assetId = $ | |
177 | + | let $t055345581 = validatePayment(invoke) | |
178 | + | let amount = $t055345581._1 | |
179 | + | let assetId = $t055345581._2 | |
180 | 180 | if (!(isDefined(amount))) | |
181 | 181 | then throw("Something went wrong") | |
182 | 182 | else if (!(validUserData(caller, name, description, thumb, false))) | |
190 | 190 | ||
191 | 191 | ||
192 | 192 | @Callable(invoke) | |
193 | - | func updateUser (name,description,thumb,social) = if (!(dappRunning)) | |
193 | + | func updateUser (name,description,thumb,social,pubKey) = if (!(dappRunning)) | |
194 | 194 | then throw(maintenanceMSG) | |
195 | 195 | else { | |
196 | 196 | let caller = toString(invoke.caller) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let VERSION = " | |
4 | + | let VERSION = "1" | |
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 whitelistedonlyKey = "conf_whitelisted_only" | |
22 | 22 | ||
23 | 23 | let dappRunning = valueOrElse(getBoolean(this, dappRunningKey), true) | |
24 | 24 | ||
25 | 25 | let maintenanceMSG = valueOrElse(getString(this, maintenanceMSGKey), "") | |
26 | 26 | ||
27 | 27 | let userSuspended = "SUSPENDED" | |
28 | 28 | ||
29 | 29 | let userRegistered = "REGISTERED" | |
30 | 30 | ||
31 | 31 | func keyUserAddr (caller) = ("user_" + caller) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func keyUserName (caller) = ("user_name_" + caller) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func keyUserDesc (caller) = ("user_desc_" + caller) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func keyUserSocial (caller) = ("user_social_" + caller) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func keyUserThumb (caller) = ("user_thumb_" + caller) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func keyUserStatus (caller) = ("user_status_" + caller) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func keyUserDate (caller) = ("user_date_" + caller) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | let signAssetId = fromBase58String(getStringByKey("conf_accepted_asset_SIGN")) | |
53 | 53 | ||
54 | 54 | let oracleFeeAddress = value(addressFromString(getStringByKey("conf_oracle_fee_address"))) | |
55 | 55 | ||
56 | 56 | func getIntegerByKeyFromOracle (key) = valueOrErrorMessage(getInteger(oracleFeeAddress, key), "Integer undefine or 0 in oracle") | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | let currentCertificationPrice = (getIntegerByKeyFromOracle(("certification_fee_" + toBase58String(signAssetId))) * 2) | |
60 | 60 | ||
61 | 61 | let feeReceiver = getStringByKey("conf_fee_receiver") | |
62 | 62 | ||
63 | 63 | func validateCID (cid) = if (contains(cid, "/")) | |
64 | 64 | then if (if ((76 > size(cid))) | |
65 | 65 | then (size(split(cid, "/")[0]) == 59) | |
66 | 66 | else false) | |
67 | 67 | then (16 > size(split(cid, "/")[1])) | |
68 | 68 | else false | |
69 | 69 | else false | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func validUserData (caller,name,description,thumb,isAnUpdate) = { | |
73 | 73 | let validCID = if ((size(thumb) != 0)) | |
74 | 74 | then validateCID(thumb) | |
75 | 75 | else true | |
76 | 76 | if (!(validCID)) | |
77 | 77 | then throw("CID don't match requirement!") | |
78 | 78 | else if (if ((name == "")) | |
79 | 79 | then true | |
80 | 80 | else (description == "")) | |
81 | 81 | then throw("Name and description cannot be empty") | |
82 | 82 | else if ((size(description) > 600)) | |
83 | 83 | then throw("600 Char. max description") | |
84 | 84 | else if ((size(name) > 45)) | |
85 | 85 | then throw("45 Char. max name") | |
86 | 86 | else { | |
87 | 87 | let status = getStringByKey(keyUserStatus(caller)) | |
88 | 88 | if ((status == userSuspended)) | |
89 | 89 | then throw("Account suspended.") | |
90 | 90 | else if (if (!(isAnUpdate)) | |
91 | 91 | then (status == userRegistered) | |
92 | 92 | else false) | |
93 | 93 | then throw("Already registered") | |
94 | 94 | else if (if (isAnUpdate) | |
95 | 95 | then (status == "") | |
96 | 96 | else false) | |
97 | 97 | then throw("Register first") | |
98 | 98 | else true | |
99 | 99 | } | |
100 | 100 | } | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | func validateNewStatus (status,address,currentStatus) = { | |
104 | 104 | let allStatus = [userRegistered, userSuspended] | |
105 | 105 | let statusToSet = if (containsElement(allStatus, status)) | |
106 | 106 | then status | |
107 | 107 | else throw("Unknown status") | |
108 | 108 | let userIsRegistered = getIntegerByKey(keyUserDate(address)) | |
109 | 109 | if ((userIsRegistered == 0)) | |
110 | 110 | then throw("You cant set this status, user is not registered.") | |
111 | 111 | else if (if ((currentStatus == userRegistered)) | |
112 | 112 | then (statusToSet == userRegistered) | |
113 | 113 | else false) | |
114 | 114 | then throw("User already registered") | |
115 | 115 | else if (if ((currentStatus == userSuspended)) | |
116 | 116 | then (statusToSet == userSuspended) | |
117 | 117 | else false) | |
118 | 118 | then throw("User already suspended") | |
119 | 119 | else statusToSet | |
120 | 120 | } | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | func makeJSON (name,thumb,date) = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + date) + "\"}") | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | func isPayment (i) = if ((size(i.payments) == 0)) | |
127 | 127 | then throw("No payment attached") | |
128 | 128 | else { | |
129 | 129 | let payment = value(i.payments[0]) | |
130 | 130 | let amount = value(payment.amount) | |
131 | 131 | $Tuple2(payment, amount) | |
132 | 132 | } | |
133 | 133 | ||
134 | 134 | ||
135 | 135 | func validatePayment (i) = { | |
136 | - | let $ | |
137 | - | let payment = $ | |
138 | - | let amount = $ | |
136 | + | let $t039754011 = isPayment(i) | |
137 | + | let payment = $t039754011._1 | |
138 | + | let amount = $t039754011._2 | |
139 | 139 | let assetId = if (if (isDefined(payment.assetId)) | |
140 | 140 | then (payment.assetId == signAssetId) | |
141 | 141 | else false) | |
142 | 142 | then payment.assetId | |
143 | 143 | else throw("Only SIGN token accepted as transaction fee") | |
144 | 144 | if ((amount != currentCertificationPrice)) | |
145 | 145 | then throw(("Payment amount should be " + toString(currentCertificationPrice))) | |
146 | 146 | else $Tuple2(amount, assetId) | |
147 | 147 | } | |
148 | 148 | ||
149 | 149 | ||
150 | 150 | @Callable(invoke) | |
151 | 151 | func setConf (key,val) = { | |
152 | 152 | let caller = toString(invoke.caller) | |
153 | 153 | if (containsElement([chris, toString(this)], caller)) | |
154 | 154 | then [StringEntry(key, val)] | |
155 | 155 | else throw("You are not allowed to change this") | |
156 | 156 | } | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | ||
160 | 160 | @Callable(invoke) | |
161 | 161 | func appRunning (isLive,message) = { | |
162 | 162 | let caller = toString(invoke.caller) | |
163 | 163 | if (containsElement([chris, toString(this)], caller)) | |
164 | 164 | then [BooleanEntry(dappRunningKey, isLive), StringEntry(maintenanceMSGKey, message)] | |
165 | 165 | else throw("You are not allowed to change this") | |
166 | 166 | } | |
167 | 167 | ||
168 | 168 | ||
169 | 169 | ||
170 | 170 | @Callable(invoke) | |
171 | - | func registerUser (name,description,thumb,social) = if (!(dappRunning)) | |
171 | + | func registerUser (name,description,thumb,social,pubKey) = if (!(dappRunning)) | |
172 | 172 | then throw(maintenanceMSG) | |
173 | 173 | else { | |
174 | 174 | let caller = toString(invoke.caller) | |
175 | 175 | let id = toBase58String(invoke.transactionId) | |
176 | 176 | let timestamp = lastBlock.timestamp | |
177 | - | let $ | |
178 | - | let amount = $ | |
179 | - | let assetId = $ | |
177 | + | let $t055345581 = validatePayment(invoke) | |
178 | + | let amount = $t055345581._1 | |
179 | + | let assetId = $t055345581._2 | |
180 | 180 | if (!(isDefined(amount))) | |
181 | 181 | then throw("Something went wrong") | |
182 | 182 | else if (!(validUserData(caller, name, description, thumb, false))) | |
183 | 183 | then throw("Something went wrong") | |
184 | 184 | else { | |
185 | 185 | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(timestamp)) | |
186 | 186 | [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), ScriptTransfer(Address(fromBase58String(feeReceiver)), amount, assetId)] | |
187 | 187 | } | |
188 | 188 | } | |
189 | 189 | ||
190 | 190 | ||
191 | 191 | ||
192 | 192 | @Callable(invoke) | |
193 | - | func updateUser (name,description,thumb,social) = if (!(dappRunning)) | |
193 | + | func updateUser (name,description,thumb,social,pubKey) = if (!(dappRunning)) | |
194 | 194 | then throw(maintenanceMSG) | |
195 | 195 | else { | |
196 | 196 | let caller = toString(invoke.caller) | |
197 | 197 | let status = getStringByKey(keyUserStatus(caller)) | |
198 | 198 | if (!(validUserData(caller, name, description, thumb, true))) | |
199 | 199 | then throw("Something went wrong") | |
200 | 200 | else { | |
201 | 201 | let date = getIntegerByKey(keyUserDate(caller)) | |
202 | 202 | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(date)) | |
203 | 203 | [StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(((status + "_") + caller), json)] | |
204 | 204 | } | |
205 | 205 | } | |
206 | 206 | ||
207 | 207 | ||
208 | 208 | ||
209 | 209 | @Callable(invoke) | |
210 | 210 | func changeUserStatus (address,status,note) = { | |
211 | 211 | let caller = toString(invoke.caller) | |
212 | 212 | let currentStatus = getStringByKey(keyUserStatus(address)) | |
213 | 213 | let statusToSet = validateNewStatus(status, address, currentStatus) | |
214 | 214 | let name = toBase64String(toBytes(getStringByKey(keyUserName(address)))) | |
215 | 215 | let thumb = toBase64String(toBytes(getStringByKey(keyUserThumb(address)))) | |
216 | 216 | let date = getIntegerByKey(keyUserDate(address)) | |
217 | 217 | let json = makeJSON(name, thumb, toString(date)) | |
218 | 218 | if (containsElement([chris, toString(this)], caller)) | |
219 | 219 | then [StringEntry(keyUserStatus(address), statusToSet), DeleteEntry(((currentStatus + "_") + address)), StringEntry(((statusToSet + "_") + address), json), StringEntry(("user_note_" + address), note)] | |
220 | 220 | else throw("Not allowed to change user status") | |
221 | 221 | } | |
222 | 222 | ||
223 | 223 | ||
224 | 224 | ||
225 | 225 | @Callable(i) | |
226 | 226 | func deleteEntry (entry) = { | |
227 | 227 | let caller = toString(i.caller) | |
228 | 228 | if ((caller == chris)) | |
229 | 229 | then [DeleteEntry(entry)] | |
230 | 230 | else throw("no") | |
231 | 231 | } | |
232 | 232 | ||
233 | 233 |
github/deemru/w8io/026f985 47.03 ms ◑