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