tx · B54YdMfGDWnR6kuqDQohKzjNtYWw6TapBw7VQejkmWct

3N3QGoxpTairHzyavoHpRPyTVMyLdX46MwJ:  -0.01400000 Waves

2021.02.10 15:56 [1392116] smart account 3N3QGoxpTairHzyavoHpRPyTVMyLdX46MwJ > SELF 0.00000000 Waves

{ "type": 13, "id": "B54YdMfGDWnR6kuqDQohKzjNtYWw6TapBw7VQejkmWct", "fee": 1400000, "feeAssetId": null, "timestamp": 1612961849426, "version": 2, "chainId": 84, "sender": "3N3QGoxpTairHzyavoHpRPyTVMyLdX46MwJ", "senderPublicKey": "84ye9pvBU1ixETjmeNbvvD5czb8ZEjsSJuNyFGkYFmwd", "proofs": [ "49f3TCW18MEWWb9txA2So6GK7wEK4yzGVpkQAQjrujwp3Z8tyvkf8piwJxqHWcVipYwcS5Tj7ELPHNxijQbcMMkg" ], "script": "base64:AAIEAAAAAAAAAB0IAhIDCgEIEgMKAQgSAwoBCBIECgIIARIECgIICAAAACIAAAAABE5PTkUCAAAABG5vbmUAAAAABkJBTk5FRAIAAAAGYmFubmVkAAAAAAZBQ1RJVkUCAAAABmFjdGl2ZQAAAAAFQ0xPU0UCAAAABWNsb3NlAAAAAARPUEVOAgAAAARvcGVuAAAAAAhhc3NldEtleQIAAAAFYXNzZXQAAAAAC2tleVByaWNlS2V5AgAAAAlrZXlfcHJpY2UAAAAACG93bmVyS2V5AgAAAAVvd25lcgAAAAAQcmVjaGFyZ2VMaW1pdEtleQIAAAAOcmVjaGFyZ2VfbGltaXQAAAAAB2FjdGlvbnMJAARMAAAAAgUAAAAET1BFTgkABEwAAAACBQAAAAVDTE9TRQUAAAADbmlsAAAAABRkZXZpY2VJbml0aWFsQ291bnRlcgAAAAAAAAAAAAAAAAAJa2V5RGV2aWNlAAAAAAAAAAAAAAAAAA1rZXlWYWxpZFVudGlsAAAAAAAAAAABAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXM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GV2aWNlBQAAAAVrZXlJRAkAAAIAAAABAgAAABNLZXkgbm90IHdoaXRlbGlzdGVkAwkBAAAAFm5vdEFsbG93ZWREZXZpY2VBY3Rpb24AAAABBQAAAAZhY3Rpb24JAAACAAAAAQIAAAAVQWN0aW9uIGlzIG5vdCBhbGxvd2VkAwkBAAAAE2tleVRpbWVzdGFtcEludmFsaWQAAAABBQAAAAdrZXlJbmZvCQAAAgAAAAECAAAAC0tleSBleHBpcmVkBAAAAAdjaGFuZ2VzCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAA9kZXZpY2VBY3Rpb25LZXkAAAABBQAAAAlkZXZpY2VTdHIFAAAABmFjdGlvbgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAFmRldmljZUFjdGlvbkNvdW50ZXJLZXkAAAABBQAAAAlkZXZpY2VTdHIJAABkAAAAAgkBAAAAGGRldmljZUFjdGlvbkNvdW50ZXJWYWx1ZQAAAAEFAAAACWRldmljZVN0cgAAAAAAAAAAAQUAAAADbmlsAwMJAABmAAAAAgUAAAAIcmVjaGFyZ2UICQAD7wAAAAEIBQAAAAFpAAAABmNhbGxlcgAAAAdyZWd1bGFyCQEAAAACIT0AAAACBQAAAAhyZWNoYXJnZQAAAAAAAAAAAAcJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAhyZWNoYXJnZQUAAAAEdW5pdAUAAAAHY2hhbmdlcwUAAAAHY2hhbmdlcwAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5leiI/w==", "height": 1392116, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CwJVvzCg4MZ6x5kksHPBJfDiuJddPJmSi1uNrE8hvYwk Next: CPdej6XfX7qNC3TdHVaHrA9HjiEY2UbhUvWQad9YTaQ2 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 notAllowedDeviceAction (action) = match indexOf(actions, action) {
154154 case a: Int =>
155155 false
156156 case _ =>
157157 true
158158 }
159159
160160
161161 @Callable(i)
162162 func addDevice (deviceAddr) = if ((i.caller != this))
163163 then throw("Not permitted")
164164 else if ((deviceActionValue(deviceAddr) != NONE))
165165 then throw("Device already added")
166166 else [StringEntry(deviceActionKey(deviceAddr), CLOSE), IntegerEntry(deviceActionCounterKey(deviceAddr), deviceInitialCounter)]
167167
168168
169169
170170 @Callable(i)
171171 func addUser (deviceAddr) = if ((i.caller != this))
172172 then throw("Not permitted")
173173 else [StringEntry(userStatusKey(deviceAddr), ACTIVE)]
174174
175175
176176
177177 @Callable(i)
178178 func removeUser (deviceAddr) = if ((i.caller != this))
179179 then throw("Not permitted")
180180 else [DeleteEntry(userStatusKey(deviceAddr))]
181181
182182
183183
184184 @Callable(i)
185185 func requestKey (deviceAddr,duration) = {
186186 let issuedAt = lastBlock.timestamp
187187 let validUntil = (issuedAt + duration)
188188 let deviceOwner = ownerFromDevice(addressFromStringValue(deviceAddr))
189189 let keyPrice = keyPriceFromDevice(addressFromStringValue(deviceAddr))
190190 let assetId = getAssetId()
191191 if ((toBase58String(i.caller.bytes) != deviceOwner))
192192 then throw("Not permitted")
193193 else if ((deviceActionKey(deviceAddr) == NONE))
194194 then throw("No such device")
195195 else if (priceIsWrong(i, assetId, keyPrice))
196196 then throw("wrong price")
197197 else {
198198 let issue = Issue("DeviceKeyGen", ((deviceAddr + "_") + toString(validUntil)), 1, 0, false)
199199 let newAssetId = calculateAssetId(issue)
200200 [issue, ScriptTransfer(i.caller, 1, newAssetId)]
201201 }
202202 }
203203
204204
205205
206206 @Callable(i)
207207 func deviceAction (keyID,action) = {
208208 let hasNoKey = (1 > assetBalance(i.caller, fromBase58String(keyID)))
209209 let keyInfo = getAssetInfo(fromBase58String(keyID))
210210 let device = deviceFromKey(keyInfo)
211211 let deviceStr = toBase58String(device.bytes)
212212 let recharge = getExtNumberByKey(rechargeLimitKey)
213213 if (hasNoKey)
214214 then throw("Key not owned")
215215 else if ((deviceActionKey(deviceStr) == NONE))
216216 then throw("No such device")
217217 else if (deviceNotWhitelistedKey(device, keyID))
218218 then throw("Key not whitelisted")
219219 else if (notAllowedDeviceAction(action))
220220 then throw("Action is not allowed")
221221 else if (keyTimestampInvalid(keyInfo))
222222 then throw("Key expired")
223223 else {
224224 let changes = [StringEntry(deviceActionKey(deviceStr), action), IntegerEntry(deviceActionCounterKey(deviceStr), (deviceActionCounterValue(deviceStr) + 1))]
225225 if (if ((recharge > wavesBalance(i.caller).regular))
226226 then (recharge != 0)
227227 else false)
228228 then ScriptTransfer(i.caller, recharge, unit) :: changes
229229 else changes
230230 }
231231 }
232232
233233
234234 @Verifier(tx)
235235 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
236236

github/deemru/w8io/026f985 
52.55 ms