tx · AvxzJqAZowY6NgV8LZQ4MpFymzsB5qiuJ2fF31rJZrFY 3NBPqqjDH2eYmoHeXNPnHhLvA7D4UDQXQcx: -0.01400000 Waves 2021.02.17 16:17 [1402196] smart account 3NBPqqjDH2eYmoHeXNPnHhLvA7D4UDQXQcx > SELF 0.00000000 Waves
{ "type": 13, "id": "AvxzJqAZowY6NgV8LZQ4MpFymzsB5qiuJ2fF31rJZrFY", "fee": 1400000, "feeAssetId": null, "timestamp": 1613567838959, "version": 2, "chainId": 84, "sender": "3NBPqqjDH2eYmoHeXNPnHhLvA7D4UDQXQcx", "senderPublicKey": "2VJESL5o2hqRwaKdJGDXpzJ7jNDcZz5y4C6qWEaUn4yY", "proofs": [ "EQVgVatNVx4VMRz8mEnvEXMcDkaazVYahhKENZWndxzu4Yc8a7uSipmT2KHUjoGGXfzaEeBye8KGvPi2wG5TBeJ" ], "script": "base64:AAIEAAAAAAAAABwIAhIDCgEIEgMKAQgSAwoBCBIECgIICBIDCgEIAAAAJQAAAAAETk9ORQIAAAAEbm9uZQAAAAAGQkFOTkVEAgAAAAZiYW5uZWQAAAAABkFDVElWRQIAAAAGYWN0aXZlAAAAAAVDTE9TRQIAAAAFY2xvc2UAAAAABE9QRU4CAAAABG9wZW4AAAAACGFzc2V0S2V5AgAAAAVhc3NldAAAAAALa2V5UHJpY2VLZXkCAAAACWtleV9wcmljZQAAAAAIb3duZXJLZXkCAAAABW93bmVyAAAAABByZWNoYXJnZUxpbWl0S2V5AgAAAA5yZWNoYXJnZV9saW1pdAAAAAAHYWN0aW9ucwkABEwAAAACBQAAAARPUEVOCQAETAAAAAIFAAAABUNMT1NFBQAAAANuaWwAAAAAFGRldmljZUluaXRpYWxDb3VudGVyAAAAAAAAAAAAAAAAAAlrZXlEZXZpY2UAAAAAAAAAAAAAAAAADWtleVZhbGlkVW50aWwAAAAAAAAAAAEBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUA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jaXBpZW50QWRkcgAAAAAAAAAAAQgFAAAAB2tleUluZm8AAAACaWQFAAAAA25pbAkBAAAAEHJlY2hhcmdlSWZOZWVkZWQAAAADBQAAAA1yZWNpcGllbnRBZGRyBQAAAAhyZWNoYXJnZQkBAAAAEHJlY2hhcmdlSWZOZWVkZWQAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAACHJlY2hhcmdlBQAAAAh0cmFuc2ZlcgAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5eKIhBQ==", "height": 1402196, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FkYMm28S3YpimcKZT6zDoTSbyQyVJZTJwAHVvmYDdQoR Next: DXEVxGLoaYFoc84bW44jq8cundW2CH3pX4BqJgctpQyX Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | let BANNED = "banned" | |
7 | 7 | ||
8 | 8 | let ACTIVE = "active" | |
9 | 9 | ||
10 | 10 | let CLOSE = "close" | |
11 | 11 | ||
12 | 12 | let OPEN = "open" | |
13 | 13 | ||
14 | 14 | let assetKey = "asset" | |
15 | 15 | ||
16 | 16 | let keyPriceKey = "key_price" | |
17 | 17 | ||
18 | 18 | let ownerKey = "owner" | |
19 | 19 | ||
20 | 20 | let rechargeLimitKey = "recharge_limit" | |
21 | 21 | ||
22 | 22 | let actions = [OPEN, CLOSE] | |
23 | 23 | ||
24 | 24 | let deviceInitialCounter = 0 | |
25 | 25 | ||
26 | 26 | let keyDevice = 0 | |
27 | 27 | ||
28 | 28 | let keyValidUntil = 1 | |
29 | 29 | ||
30 | 30 | func getNumberByKey (key) = match getInteger(this, key) { | |
31 | 31 | case a: Int => | |
32 | 32 | a | |
33 | 33 | case _ => | |
34 | 34 | 0 | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func getStrByKey (key) = match getString(this, key) { | |
39 | 39 | case a: String => | |
40 | 40 | a | |
41 | 41 | case _ => | |
42 | 42 | NONE | |
43 | 43 | } | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getExtNumberByKey (key) = match getInteger(this, key) { | |
47 | 47 | case a: Int => | |
48 | 48 | a | |
49 | 49 | case _ => | |
50 | 50 | 0 | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func getExtStrByKey (addr,key) = match getString(addr, key) { | |
55 | 55 | case a: String => | |
56 | 56 | a | |
57 | 57 | case _ => | |
58 | 58 | NONE | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func getAssetId () = fromBase58String(getStrByKey(assetKey)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func userStatusKey (addr) = ("user_" + addr) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func userStatusValue (addr) = match getString(this, userStatusKey(addr)) { | |
69 | 69 | case a: String => | |
70 | 70 | a | |
71 | 71 | case _ => | |
72 | 72 | NONE | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func deviceActionKey (addr) = ("device_" + addr) | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func deviceActionCounterKey (addr) = ("device_counter_" + addr) | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func deviceActionValue (addr) = getStrByKey(deviceActionKey(addr)) | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func deviceActionCounterValue (addr) = getNumberByKey(deviceActionCounterKey(addr)) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func nftKey (nft) = ("key_" + nft) | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func nftValue (nft) = getStrByKey(nftKey(nft)) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func deviceNotWhitelistedKey (device,key) = { | |
95 | 95 | let nftId = nftKey(key) | |
96 | 96 | let valInDevice = getExtStrByKey(device, nftId) | |
97 | 97 | if ((valInDevice != NONE)) | |
98 | 98 | then false | |
99 | 99 | else true | |
100 | 100 | } | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | func deviceFromKey (key) = { | |
104 | 104 | let device = split(key.description, "_")[keyDevice] | |
105 | 105 | match addressFromString(device) { | |
106 | 106 | case t: Address => | |
107 | 107 | t | |
108 | 108 | case _ => | |
109 | 109 | throw("Not a device key") | |
110 | 110 | } | |
111 | 111 | } | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func getAssetInfo (asset) = match assetInfo(asset) { | |
115 | 115 | case t: Asset => | |
116 | 116 | t | |
117 | 117 | case _ => | |
118 | 118 | throw("Not a key") | |
119 | 119 | } | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | func keyTimestampInvalid (key) = { | |
123 | 123 | let timestamp = parseIntValue(split(key.description, "_")[keyValidUntil]) | |
124 | 124 | (lastBlock.timestamp > timestamp) | |
125 | 125 | } | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | func keyPriceFromDevice (device) = match getInteger(device, keyPriceKey) { | |
129 | 129 | case t: Int => | |
130 | 130 | t | |
131 | 131 | case _ => | |
132 | 132 | throw("Price not specified in device") | |
133 | 133 | } | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func ownerFromDevice (device) = match getString(device, ownerKey) { | |
137 | 137 | case t: String => | |
138 | 138 | t | |
139 | 139 | case _ => | |
140 | 140 | throw("Owner not specified in device") | |
141 | 141 | } | |
142 | 142 | ||
143 | 143 | ||
144 | 144 | func priceIsWrong (i,assetId,price) = if ((1 > size(i.payments))) | |
145 | 145 | then throw("wrong payments count") | |
146 | 146 | else if ((i.payments[0].assetId != unit)) | |
147 | 147 | then throw("wrong asset, supported only wws") | |
148 | 148 | else if ((i.payments[0].amount != price)) | |
149 | 149 | then throw(("wrong payment value, expected " + toString(price))) | |
150 | 150 | else false | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | func getAssetIdFromAttachedPayment (p) = match p.assetId { | |
154 | 154 | case t: ByteVector => | |
155 | 155 | t | |
156 | 156 | case _ => | |
157 | 157 | throw("Wrong asset") | |
158 | 158 | } | |
159 | 159 | ||
160 | 160 | ||
161 | 161 | func getAssetInfoFromPayment (i) = if ((size(i.payments) != 1)) | |
162 | 162 | then throw("wrong assets count") | |
163 | 163 | else { | |
164 | 164 | let asset = getAssetInfo(getAssetIdFromAttachedPayment(i.payments[0])) | |
165 | 165 | if ((asset.issuer != this)) | |
166 | 166 | then throw("wrong asset issuer") | |
167 | 167 | else if (keyTimestampInvalid(asset)) | |
168 | 168 | then throw("key expired") | |
169 | 169 | else asset | |
170 | 170 | } | |
171 | 171 | ||
172 | 172 | ||
173 | 173 | func rechargeIfNeeded (account,rechargeLimit,txes) = if (if ((rechargeLimit > wavesBalance(account).regular)) | |
174 | 174 | then (rechargeLimit != 0) | |
175 | 175 | else false) | |
176 | 176 | then ScriptTransfer(account, rechargeLimit, unit) :: txes | |
177 | 177 | else txes | |
178 | 178 | ||
179 | 179 | ||
180 | 180 | func notAllowedDeviceAction (action) = match indexOf(actions, action) { | |
181 | 181 | case a: Int => | |
182 | 182 | false | |
183 | 183 | case _ => | |
184 | 184 | true | |
185 | 185 | } | |
186 | 186 | ||
187 | 187 | ||
188 | 188 | @Callable(i) | |
189 | 189 | func addDevice (deviceAddr) = if ((i.caller != this)) | |
190 | 190 | then throw("Not permitted") | |
191 | 191 | else if ((deviceActionValue(deviceAddr) != NONE)) | |
192 | 192 | then throw("Device already added") | |
193 | 193 | else [StringEntry(deviceActionKey(deviceAddr), CLOSE), IntegerEntry(deviceActionCounterKey(deviceAddr), deviceInitialCounter)] | |
194 | 194 | ||
195 | 195 | ||
196 | 196 | ||
197 | 197 | @Callable(i) | |
198 | 198 | func addUser (deviceAddr) = if ((i.caller != this)) | |
199 | 199 | then throw("Not permitted") | |
200 | 200 | else [StringEntry(userStatusKey(deviceAddr), ACTIVE)] | |
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | 204 | @Callable(i) | |
205 | 205 | func removeUser (deviceAddr) = if ((i.caller != this)) | |
206 | 206 | then throw("Not permitted") | |
207 | 207 | else [DeleteEntry(userStatusKey(deviceAddr))] | |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | 211 | @Callable(i) | |
212 | 212 | func deviceAction (keyID,action) = { | |
213 | 213 | let hasNoKey = (1 > assetBalance(i.caller, fromBase58String(keyID))) | |
214 | 214 | let keyInfo = getAssetInfo(fromBase58String(keyID)) | |
215 | 215 | let device = deviceFromKey(keyInfo) | |
216 | 216 | let deviceStr = toBase58String(device.bytes) | |
217 | 217 | let recharge = getExtNumberByKey(rechargeLimitKey) | |
218 | 218 | if (hasNoKey) | |
219 | 219 | then throw("Key not owned") | |
220 | 220 | else if ((deviceActionKey(deviceStr) == NONE)) | |
221 | 221 | then throw("No such device") | |
222 | 222 | else if (deviceNotWhitelistedKey(device, keyID)) | |
223 | 223 | then throw("Key not whitelisted") | |
224 | 224 | else if (notAllowedDeviceAction(action)) | |
225 | 225 | then throw("Action is not allowed") | |
226 | 226 | else if (keyTimestampInvalid(keyInfo)) | |
227 | 227 | then throw("Key expired") | |
228 | 228 | else { | |
229 | 229 | let changes = [StringEntry(deviceActionKey(deviceStr), action), IntegerEntry(deviceActionCounterKey(deviceStr), (deviceActionCounterValue(deviceStr) + 1))] | |
230 | 230 | if (if ((recharge > wavesBalance(i.caller).regular)) | |
231 | 231 | then (recharge != 0) | |
232 | 232 | else false) | |
233 | 233 | then ScriptTransfer(i.caller, recharge, unit) :: changes | |
234 | 234 | else changes | |
235 | 235 | } | |
236 | 236 | } | |
237 | 237 | ||
238 | 238 | ||
239 | 239 | ||
240 | 240 | @Callable(i) | |
241 | 241 | func transferKey (recipient) = { | |
242 | 242 | let keyInfo = getAssetInfoFromPayment(i) | |
243 | 243 | let recharge = getNumberByKey(rechargeLimitKey) | |
244 | 244 | let recipientAddr = addressFromStringValue(recipient) | |
245 | 245 | let transfer = [ScriptTransfer(recipientAddr, 1, keyInfo.id)] | |
246 | 246 | rechargeIfNeeded(recipientAddr, recharge, rechargeIfNeeded(i.caller, recharge, transfer)) | |
247 | 247 | } | |
248 | 248 | ||
249 | 249 | ||
250 | 250 | @Verifier(tx) | |
251 | 251 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
252 | 252 |
github/deemru/w8io/026f985 26.27 ms ◑