tx · 3UdY4SWHyjMfDVtx3fLzm1aSX3fFAQmTHL8JF854rZAK

3N3QGoxpTairHzyavoHpRPyTVMyLdX46MwJ:  -0.01400000 Waves

2021.02.01 15:25 [1379096] smart account 3N3QGoxpTairHzyavoHpRPyTVMyLdX46MwJ > SELF 0.00000000 Waves

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

github/deemru/w8io/169f3d6 
26.52 ms