tx · DG5AQhg63em22Z8YhnbC5YSiNHmdqcoz4hN3GJaWhzgi

3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM:  -0.02000000 Waves

2020.07.03 18:19 [1071074] smart account 3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM > SELF 0.00000000 Waves

{ "type": 13, "id": "DG5AQhg63em22Z8YhnbC5YSiNHmdqcoz4hN3GJaWhzgi", "fee": 2000000, "feeAssetId": null, "timestamp": 1593789589789, "version": 1, "sender": "3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM", "senderPublicKey": "FmnQ1LwTnauTS2BSrZivE1nSF1A9MY9hyYB72pyh5hw9", "proofs": [ "4TXhP5tpUQtCzzN6LqJYKhFk7FgRc47Yki8FE9Vt91YwxQe5VNM8sYMCgLKL897ARY1uGb6VrTnZMP6XnhRCtP4Y" ], "script": "base64:AAIDAAAAAAAAAAcIARIDCgEIAAAAAQEAAAAQZ2V0QnJpZGdlQWRkcmVzcwAAAAAEAAAAByRtYXRjaDAJAQAAABFhZGRyZXNzRnJvbVN0cmluZwAAAAECAAAAIzNONTRlS1c1WnVjRGFSYUdWVWZ6WDh4Ulh2NlZlOE03MXRNAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAdBZGRyZXNzBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhCQAAAgAAAAECAAAAGmZhaWwgdG8gZ2V0IGJyaWRnZSBhZGRyZXNzAAAAAQAAAAFpAQAAAA5yZWFkRnJvbUJyaWRnZQAAAAEAAAAGc3ltYm9sAwMDCQEAAAACIT0AAAACBQAAAAZzeW1ib2wCAAAAA0JUQwkBAAAAAiE9AAAAAgUAAAAGc3ltYm9sAgAAAAVXQVZFUwcJAQAAAAIhPQAAAAIFAAAABnN5bWJvbAIAAAADRVRIBwkAAAIAAAABAgAAAA5JbnZhbGlkIHN5bWJvbAQAAAAFcHJpY2UJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIJAQAAABBnZXRCcmlkZ2VBZGRyZXNzAAAAAAkAASwAAAACBQAAAAZzeW1ib2wCAAAABi92YWx1ZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZzeW1ib2wCAAAABi9wcmljZQUAAAAFcHJpY2UFAAAAA25pbAAAAABKqeWt", "chainId": 84, "height": 1071074, "spentComplexity": 0 } View: original | compacted Prev: EDjWQnzhvgh4neYao5rqTNbgrmzcPJ9WCmyutUCgCdgK Next: 4mVj717ockX3b3rFjFBemYQbycF29ki2tzc6ScAo2on7 Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-func decodeInt8 (data,offset) = if ((1 > size(data)))
5- then throw("decode u8 error, data must be at least 1 byte")
6- else if ((offset > size(data)))
7- then throw("decode u8 error, decoding is finish")
8- else {
9- let x0 = take(drop(data, offset), 1)
10- let x1 = toInt((base58'1111111' + x0), 0)
11-[toInt((base58'1111111' + x0), 0), (offset + 1)]
12- }
13-
14-
15-func decodeInt16 (data,offset) = if ((2 > size(data)))
16- then throw("decode u16 error, data must be at least 2 bytes")
17- else if ((offset > size(data)))
18- then throw("decode u16 error, decoding is finish")
19- else {
20- let x0 = drop(data, offset)
21- let x1 = take(x0, 2)
22-[toInt((base58'111111' + x1), 0), (offset + 2)]
23- }
24-
25-
26-func decodeInt32 (data,offset) = if ((4 > size(data)))
27- then throw("decode u32 error, data must be at least 4 bytes")
28- else if ((offset > size(data)))
29- then throw("decode u32 error, decoding is finish")
30- else {
31- let x0 = drop(data, offset)
32- let x1 = take(x0, 4)
33-[toInt((base58'1111' + x1), 0), (offset + 4)]
34- }
35-
36-
37-func decodeInt64 (data,offset) = if ((8 > size(data)))
38- then throw("decode u32 error, data must be at least 8 bytes")
39- else if ((offset > size(data)))
40- then throw("decode u32 error, decoding is finish")
41- else {
42- let x0 = drop(data, offset)
43- let x1 = take(x0, 8)
44-[toInt(x1, 0), (offset + 8)]
45- }
46-
47-
48-func decodeBool (data,offset) = {
49- let decoded1 = decodeInt8(data, offset)
50-[DataEntry("bool", (decoded1[0] != 0)), DataEntry("int", decoded1[1])]
51- }
52-
53-
54-func decodeBytes32 (data,offset) = if ((32 > size(data)))
55- then throw("decode bytes32 error, data must be at least 32 bytes")
56- else [DataEntry("byte_vector", take(drop(data, offset), 32)), DataEntry("int", (offset + 32))]
57-
58-
59-func decodeBytes64 (data,offset) = if ((64 > size(data)))
60- then throw("decode bytes64 error, data must be at least 64 bytes")
61- else [DataEntry("byte_vector", take(drop(data, offset), 64)), DataEntry("int", (offset + 64))]
62-
63-
64-func decodeBytes65 (data,offset) = if ((65 > size(data)))
65- then throw("decode bytes65 error, data must be at least 65 bytes")
66- else [DataEntry("byte_vector", take(drop(data, offset), 65)), DataEntry("int", (offset + 65))]
67-
68-
69-func decodeBytes (data,offset) = {
70- let decoded1 = decodeInt32(data, offset)
71- let bytesSize = decoded1[0]
72- let nextOffset = decoded1[1]
73-[DataEntry("byte_vector", take(drop(data, nextOffset), bytesSize)), DataEntry("int", (nextOffset + bytesSize))]
74- }
75-
76-
77-func decodeString (data,offset) = {
78- let decoded1 = decodeInt32(data, offset)
79- let bytesSize = decoded1[0]
80- let nextOffset = decoded1[1]
81-[DataEntry("string", toUtf8String(take(drop(data, nextOffset), bytesSize))), DataEntry("int", (nextOffset + bytesSize))]
82- }
83-
84-
85-func getAsBool (tuple) = match tuple[0].value {
86- case b: Boolean =>
87- b
4+func getBridgeAddress () = match addressFromString("3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM") {
5+ case a: Address =>
6+ a
887 case _ =>
89- throw("not a Boolean")
8+ throw("fail to get bridge address")
909 }
9110
9211
93-func getAsByteVector (tuple) = match tuple[0].value {
94- case bv: ByteVector =>
95- bv
96- case _ =>
97- throw("not a ByteVector")
98-}
99-
100-
101-func getAsString (tuple) = match tuple[0].value {
102- case s: String =>
103- s
104- case _ =>
105- throw("not a String")
106-}
107-
108-
109-func getOffset (tuple) = match tuple[1].value {
110- case i: Int =>
111- i
112- case _ =>
113- throw("not a Int")
114-}
115-
116-
117-func getLatestUpdateTimeOfSymbol (symbol) = match getInteger(this, (symbol + "/latest_update")) {
118- case i: Int =>
119- i
120- case _ =>
121- 0
122-}
123-
124-
125-@Callable(contextObj)
126-func relayAndVerify (data) = if ((contextObj.caller != this))
127- then throw("Unauthorized caller")
12+@Callable(i)
13+func readFromBridge (symbol) = if (if (if ((symbol != "BTC"))
14+ then (symbol != "WAVES")
15+ else false)
16+ then (symbol != "ETH")
17+ else false)
18+ then throw("Invalid symbol")
12819 else {
129- let req1 = decodeString(data, 0)
130- let req2 = decodeInt64(data, getOffset(req1))
131- let req3 = decodeBytes(data, req2[1])
132- let req4 = decodeInt64(data, getOffset(req3))
133- let req5 = decodeInt64(data, req4[1])
134- let res1 = decodeString(data, req5[1])
135- let res2 = decodeInt64(data, getOffset(res1))
136- let res3 = decodeInt64(data, res2[1])
137- let res4 = decodeInt64(data, res3[1])
138- let res5 = decodeInt64(data, res4[1])
139- let res6 = decodeInt8(data, res5[1])
140- let res7 = decodeBytes(data, res6[1])
141- let calldata = getAsByteVector(req3)
142- let c1 = decodeString(calldata, 0)
143- let c2 = decodeInt64(calldata, getOffset(c1))
144- let symbol = getAsString(c1)
145- let multiplier = c2[0]
146- if ((req2[0] != 1))
147- then throw("Invalid oracle script")
148- else if (if (if ((symbol != "BTC"))
149- then (symbol != "WAVES")
150- else false)
151- then (symbol != "ETH")
152- else false)
153- then throw("Invalid symbol")
154- else if ((multiplier != 1000000))
155- then throw("Invalid multiplier")
156- else if ((getLatestUpdateTimeOfSymbol(symbol) >= res5[0]))
157- then throw("Not newer than the latest")
158- else if ((res6[0] != 1))
159- then throw("Invalid resolve status")
160- else {
161- let response = getAsByteVector(res7)
162- let price = decodeInt64(response, 0)
163- WriteSet([DataEntry((symbol + "/latest_update_time"), res5[0]), DataEntry((symbol + "/value"), price[0]), DataEntry((symbol + "/latest_block"), height)])
164- }
20+ let price = getIntegerValue(getBridgeAddress(), (symbol + "/value"))
21+ WriteSet([DataEntry((symbol + "/price"), price)])
16522 }
16623
16724

github/deemru/w8io/873ac7e 
31.59 ms