tx · CXqKGxqiU5pe4NU3CDADZGP3E29QEWQKHhaxzL9SkNM9

3Mva1eWeuUN14KPKYbJWE4cC6i22mkYrvao:  -0.01400000 Waves

2021.03.02 16:02 [1420069] smart account 3Mva1eWeuUN14KPKYbJWE4cC6i22mkYrvao > SELF 0.00000000 Waves

{ "type": 13, "id": "CXqKGxqiU5pe4NU3CDADZGP3E29QEWQKHhaxzL9SkNM9", "fee": 1400000, "feeAssetId": null, "timestamp": 1614690207082, "version": 2, "chainId": 84, "sender": "3Mva1eWeuUN14KPKYbJWE4cC6i22mkYrvao", "senderPublicKey": "2fpynB2xzDZJf5GiBDvZuWfnmfUvuQMnV4U2rDnGUoPn", "proofs": [ "mvvUb6WSWqo5puriYMtkYj6pCXfVUiEK8ro3j2NkmKfK96G4E8Fs3MmRQyT4AX1EJywJu8nRoCFqC1eQTvR3M6j" ], "script": "base64:AAIEAAAAAAAAABwIAhIDCgEIEgMKAQgSAwoBCBIECgIICBIDCgEIAAAAJQAAAAAETk9ORQIAAAAEbm9uZQAAAAAGQkFOTkVEAgAAAAZiYW5uZWQAAAAABkFDVElWRQIAAAAGYWN0aXZlAAAAAAVDTE9TRQIAAAAFY2xvc2UAAAAABE9QRU4CAAAABG9wZW4AAAAACGFzc2V0S2V5AgAAAAVhc3NldAAAAAALa2V5UHJpY2VLZXkCAAAACWtleV9wcmljZQAAAAAIb3duZXJLZXkCAAAABW93bmVyAAAAABByZWNoYXJnZUxpbWl0S2V5AgAAAA5yZWNoYXJnZV9saW1pdAAAAAAHYWN0aW9ucwkABEwAAAACBQAAAARPUEVOCQAETAAAAAIFAAAABUNMT1NFBQAAAANuaWwAAAAAFGRldmljZUluaXRpYWxDb3VudGVyAAAAAAAAAAAAAAAAAAlrZXlEZXZpY2UAAAAAAAAAAAAAAAAADWtleVZhbGlkVW50aWwAAAAAAAAAAAEBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpc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WRkcgAAAAAAAAAAAQgFAAAAB2tleUluZm8AAAACaWQFAAAAA25pbAkBAAAAEHJlY2hhcmdlSWZOZWVkZWQAAAADBQAAAA1yZWNpcGllbnRBZGRyBQAAAAhyZWNoYXJnZQkBAAAAEHJlY2hhcmdlSWZOZWVkZWQAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAACHJlY2hhcmdlBQAAAAh0cmFuc2ZlcgAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5eKIhBQ==", "height": 1420069, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2LsszpRKrxEiT5K6QKrKVaFpqappj4YGZS5bNW3pKRox Next: AraCxGjdu7obuSBAU7YVznYgKv6NieDAyChECtieyKft Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 let BANNED = "banned"
77
88 let ACTIVE = "active"
99
1010 let CLOSE = "close"
1111
1212 let OPEN = "open"
1313
1414 let assetKey = "asset"
1515
1616 let keyPriceKey = "key_price"
1717
1818 let ownerKey = "owner"
1919
2020 let rechargeLimitKey = "recharge_limit"
2121
2222 let actions = [OPEN, CLOSE]
2323
2424 let deviceInitialCounter = 0
2525
2626 let keyDevice = 0
2727
2828 let keyValidUntil = 1
2929
3030 func getNumberByKey (key) = match getInteger(this, key) {
3131 case a: Int =>
3232 a
3333 case _ =>
3434 0
3535 }
3636
3737
3838 func getStrByKey (key) = match getString(this, key) {
3939 case a: String =>
4040 a
4141 case _ =>
4242 NONE
4343 }
4444
4545
4646 func getExtNumberByKey (key) = match getInteger(this, key) {
4747 case a: Int =>
4848 a
4949 case _ =>
5050 0
5151 }
5252
5353
5454 func getExtStrByKey (addr,key) = match getString(addr, key) {
5555 case a: String =>
5656 a
5757 case _ =>
5858 NONE
5959 }
6060
6161
6262 func getAssetId () = fromBase58String(getStrByKey(assetKey))
6363
6464
6565 func userStatusKey (addr) = ("user_" + addr)
6666
6767
6868 func userStatusValue (addr) = match getString(this, userStatusKey(addr)) {
6969 case a: String =>
7070 a
7171 case _ =>
7272 NONE
7373 }
7474
7575
7676 func deviceActionKey (addr) = ("device_" + addr)
7777
7878
7979 func deviceActionCounterKey (addr) = ("device_counter_" + addr)
8080
8181
8282 func deviceActionValue (addr) = getStrByKey(deviceActionKey(addr))
8383
8484
8585 func deviceActionCounterValue (addr) = getNumberByKey(deviceActionCounterKey(addr))
8686
8787
8888 func nftKey (nft) = ("key_" + nft)
8989
9090
9191 func nftValue (nft) = getStrByKey(nftKey(nft))
9292
9393
9494 func deviceNotWhitelistedKey (device,key) = {
9595 let nftId = nftKey(key)
9696 let valInDevice = getExtStrByKey(device, nftId)
9797 if ((valInDevice != NONE))
9898 then false
9999 else true
100100 }
101101
102102
103103 func deviceFromKey (key) = {
104104 let device = split(key.description, "_")[keyDevice]
105105 match addressFromString(device) {
106106 case t: Address =>
107107 t
108108 case _ =>
109109 throw("Not a device key")
110110 }
111111 }
112112
113113
114114 func getAssetInfo (asset) = match assetInfo(asset) {
115115 case t: Asset =>
116116 t
117117 case _ =>
118118 throw("Not a key")
119119 }
120120
121121
122122 func keyTimestampInvalid (key) = {
123123 let timestamp = parseIntValue(split(key.description, "_")[keyValidUntil])
124124 (lastBlock.timestamp > timestamp)
125125 }
126126
127127
128128 func keyPriceFromDevice (device) = match getInteger(device, keyPriceKey) {
129129 case t: Int =>
130130 t
131131 case _ =>
132132 throw("Price not specified in device")
133133 }
134134
135135
136136 func ownerFromDevice (device) = match getString(device, ownerKey) {
137137 case t: String =>
138138 t
139139 case _ =>
140140 throw("Owner not specified in device")
141141 }
142142
143143
144144 func priceIsWrong (i,assetId,price) = if ((1 > size(i.payments)))
145145 then throw("wrong payments count")
146146 else if ((i.payments[0].assetId != unit))
147147 then throw("wrong asset, supported only wws")
148148 else if ((i.payments[0].amount != price))
149149 then throw(("wrong payment value, expected " + toString(price)))
150150 else false
151151
152152
153153 func getAssetIdFromAttachedPayment (p) = match p.assetId {
154154 case t: ByteVector =>
155155 t
156156 case _ =>
157157 throw("Wrong asset")
158158 }
159159
160160
161161 func getAssetInfoFromPayment (i) = if ((size(i.payments) != 1))
162162 then throw("wrong assets count")
163163 else {
164164 let asset = getAssetInfo(getAssetIdFromAttachedPayment(i.payments[0]))
165165 if ((asset.issuer != this))
166166 then throw("wrong asset issuer")
167167 else if (keyTimestampInvalid(asset))
168168 then throw("key expired")
169169 else asset
170170 }
171171
172172
173173 func rechargeIfNeeded (account,rechargeLimit,txes) = if (if ((rechargeLimit > wavesBalance(account).regular))
174174 then (rechargeLimit != 0)
175175 else false)
176176 then ScriptTransfer(account, rechargeLimit, unit) :: txes
177177 else txes
178178
179179
180180 func notAllowedDeviceAction (action) = match indexOf(actions, action) {
181181 case a: Int =>
182182 false
183183 case _ =>
184184 true
185185 }
186186
187187
188188 @Callable(i)
189189 func addDevice (deviceAddr) = if ((i.caller != this))
190190 then throw("Not permitted")
191191 else if ((deviceActionValue(deviceAddr) != NONE))
192192 then throw("Device already added")
193193 else [StringEntry(deviceActionKey(deviceAddr), CLOSE), IntegerEntry(deviceActionCounterKey(deviceAddr), deviceInitialCounter)]
194194
195195
196196
197197 @Callable(i)
198198 func addUser (deviceAddr) = if ((i.caller != this))
199199 then throw("Not permitted")
200200 else [StringEntry(userStatusKey(deviceAddr), ACTIVE)]
201201
202202
203203
204204 @Callable(i)
205205 func removeUser (deviceAddr) = if ((i.caller != this))
206206 then throw("Not permitted")
207207 else [DeleteEntry(userStatusKey(deviceAddr))]
208208
209209
210210
211211 @Callable(i)
212212 func deviceAction (keyID,action) = {
213213 let hasNoKey = (1 > assetBalance(i.caller, fromBase58String(keyID)))
214214 let keyInfo = getAssetInfo(fromBase58String(keyID))
215215 let device = deviceFromKey(keyInfo)
216216 let deviceStr = toBase58String(device.bytes)
217217 let recharge = getExtNumberByKey(rechargeLimitKey)
218218 if (hasNoKey)
219219 then throw("Key not owned")
220220 else if ((deviceActionKey(deviceStr) == NONE))
221221 then throw("No such device")
222222 else if (deviceNotWhitelistedKey(device, keyID))
223223 then throw("Key not whitelisted")
224224 else if (notAllowedDeviceAction(action))
225225 then throw("Action is not allowed")
226226 else if (keyTimestampInvalid(keyInfo))
227227 then throw("Key expired")
228228 else {
229229 let changes = [StringEntry(deviceActionKey(deviceStr), action), IntegerEntry(deviceActionCounterKey(deviceStr), (deviceActionCounterValue(deviceStr) + 1))]
230230 if (if ((recharge > wavesBalance(i.caller).regular))
231231 then (recharge != 0)
232232 else false)
233233 then ScriptTransfer(i.caller, recharge, unit) :: changes
234234 else changes
235235 }
236236 }
237237
238238
239239
240240 @Callable(i)
241241 func transferKey (recipient) = {
242242 let keyInfo = getAssetInfoFromPayment(i)
243243 let recharge = getNumberByKey(rechargeLimitKey)
244244 let recipientAddr = addressFromStringValue(recipient)
245245 let transfer = [ScriptTransfer(recipientAddr, 1, keyInfo.id)]
246246 rechargeIfNeeded(recipientAddr, recharge, rechargeIfNeeded(i.caller, recharge, transfer))
247247 }
248248
249249
250250 @Verifier(tx)
251251 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
252252

github/deemru/w8io/026f985 
34.32 ms