tx · 4yzfD4RdLap4KYBtrPptUSzhAA2VqorJXnTqvPr4FQoY

3NBCBtA1F4m6tBir7JX2dUtDNt4ujmHH5NA:  -0.02000000 Waves

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

{ "type": 13, "id": "4yzfD4RdLap4KYBtrPptUSzhAA2VqorJXnTqvPr4FQoY", "fee": 2000000, "feeAssetId": null, "timestamp": 1593789640778, "version": 1, "sender": "3NBCBtA1F4m6tBir7JX2dUtDNt4ujmHH5NA", "senderPublicKey": "Aj2RvtYHTSnDfcwYBCD5ZEwG3V483xJe2L1n13KPsi3a", "proofs": [ "5tKS1ejFXVhEC7cJiYac4rEXbKhZYSfN8SvrnUPMLRqmBGEoxWRt21SkeP38jyfnK7t8ViqdGuYUhUtYnQhvuRuh" ], "script": "base64:AAIDAAAAAAAAAAcIARIDCgEIAAAAAQEAAAAQZ2V0QnJpZGdlQWRkcmVzcwAAAAAEAAAAByRtYXRjaDAJAQAAABFhZGRyZXNzRnJvbVN0cmluZwAAAAECAAAAIzNONTRlS1c1WnVjRGFSYUdWVWZ6WDh4Ulh2NlZlOE03MXRNAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAdBZGRyZXNzBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhCQAAAgAAAAECAAAAGmZhaWwgdG8gZ2V0IGJyaWRnZSBhZGRyZXNzAAAAAQAAAAFpAQAAAA5yZWFkRnJvbUJyaWRnZQAAAAEAAAAGc3ltYm9sAwMDCQEAAAACIT0AAAACBQAAAAZzeW1ib2wCAAAAA0JUQwkBAAAAAiE9AAAAAgUAAAAGc3ltYm9sAgAAAAVXQVZFUwcJAQAAAAIhPQAAAAIFAAAABnN5bWJvbAIAAAADRVRIBwkAAAIAAAABAgAAAA5JbnZhbGlkIHN5bWJvbAQAAAAFcHJpY2UJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIJAQAAABBnZXRCcmlkZ2VBZGRyZXNzAAAAAAkAASwAAAACBQAAAAZzeW1ib2wCAAAABi92YWx1ZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZzeW1ib2wCAAAABi9wcmljZQUAAAAFcHJpY2UFAAAAA25pbAAAAABKqeWt", "chainId": 84, "height": 1071074, "spentComplexity": 0 } View: original | compacted Prev: ZxzEwzbtKA58cJPyxgun6Bmka5zPafWvuSMHx6G9fLd Next: none 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- if ((128 > x1))
12- then [x1, (offset + 1)]
13- else [toInt((base58'Ahg1opVcGW' + x0), 0), (offset + 1)]
14- }
15-
16-
17-func decodeInt16 (data,offset) = if ((2 > size(data)))
18- then throw("decode u16 error, data must be at least 2 bytes")
19- else if ((offset > size(data)))
20- then throw("decode u16 error, decoding is finish")
21- else {
22- let x0 = drop(data, offset)
23- let x1 = take(x0, 1)
24- let x2 = take(drop(x0, 1), 1)
25- if ((decodeInt8(x2, 0)[0] >= 0))
26- then [toInt(((base58'111111' + x2) + x1), 0), (offset + 2)]
27- else [toInt(((base58'3CUsUpv9t' + x2) + x1), 0), (offset + 2)]
28- }
29-
30-
31-func decodeInt32 (data,offset) = if ((4 > size(data)))
32- then throw("decode u32 error, data must be at least 4 bytes")
33- else if ((offset > size(data)))
34- then throw("decode u32 error, decoding is finish")
35- else {
36- let x0 = drop(data, offset)
37- let x1 = take(x0, 1)
38- let x2 = take(drop(x0, 1), 1)
39- let x3 = take(drop(x0, 2), 1)
40- let x4 = take(drop(x0, 3), 1)
41- if ((decodeInt8(x4, 0)[0] >= 0))
42- then [toInt(((((base58'1111' + x4) + x3) + x2) + x1), 0), (offset + 4)]
43- else [toInt(((((base58'7YXq9G' + x4) + x3) + x2) + x1), 0), (offset + 4)]
44- }
45-
46-
47-func decodeInt64 (data,offset) = if ((8 > size(data)))
48- then throw("decode u32 error, data must be at least 8 bytes")
49- else if ((offset > size(data)))
50- then throw("decode u32 error, decoding is finish")
51- else {
52- let x0 = drop(data, offset)
53- let x1 = take(x0, 1)
54- let x2 = take(drop(x0, 1), 1)
55- let x3 = take(drop(x0, 2), 1)
56- let x4 = take(drop(x0, 3), 1)
57- let x5 = take(drop(x0, 4), 1)
58- let x6 = take(drop(x0, 5), 1)
59- let x7 = take(drop(x0, 6), 1)
60- let x8 = take(drop(x0, 7), 1)
61-[toInt((((((((x8 + x7) + x6) + x5) + x4) + x3) + x2) + x1), 0), (offset + 8)]
62- }
63-
64-
65-func decodeString (data,offset) = {
66- let decoded1 = decodeInt32(data, offset)
67- let bytesSize = decoded1[0]
68- let nextOffset = decoded1[1]
69-[DataEntry("string", toUtf8String(take(drop(data, nextOffset), bytesSize))), DataEntry("int", (nextOffset + bytesSize))]
70- }
71-
72-
73-func getAsString (tuple) = match tuple[0].value {
74- case s: String =>
75- s
4+func getBridgeAddress () = match addressFromString("3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM") {
5+ case a: Address =>
6+ a
767 case _ =>
77- throw("not a String")
8+ throw("fail to get bridge address")
789 }
7910
8011
81-func getOffset (tuple) = match tuple[1].value {
82- case i: Int =>
83- i
84- case _ =>
85- throw("not a Int")
86-}
87-
88-
89-@Callable(contextObj)
90-func init (bridgeAddress) = if ((contextObj.caller != this))
91- then throw("permission denied")
92- else match getInteger(this, "latestRequestId") {
93- case latestRequestId: Int =>
94- throw("already init")
95- case _ =>
96- match getInteger(this, "latestWavesPrice") {
97- case latestWavesPrice: Int =>
98- throw("already init")
99- case _ =>
100- WriteSet([DataEntry("oracleScriptId", 1), DataEntry("symbol", "WAVES"), DataEntry("multiplier", 100), DataEntry("latestRequestId", 0), DataEntry("latestWavesPrice", 0)])
101- }
102- }
103-
104-
105-
106-@Callable(contextObj)
107-func setBridge (bridgeAddress) = if ((contextObj.caller != this))
108- then throw("permission denied")
109- else WriteSet([DataEntry("bridge", bridgeAddress)])
110-
111-
112-
113-@Callable(contextObj)
114-func setLatestWavesPrice (requestId) = {
115- let bridge = Address(getBinaryValue(this, "bridge"))
116- if ((getIntegerValue(bridge, (toString(requestId) + "/oracleScriptId")) != getIntegerValue(this, "oracleScriptId")))
117- then throw("incorrect oracleScriptId")
118- else {
119- let calldata = getBinaryValue(bridge, (toString(requestId) + "/calldata"))
120- let tuple1 = decodeString(calldata, 0)
121- let tuple2 = decodeInt64(calldata, getOffset(tuple1))
122- let symbol = getAsString(tuple1)
123- let multiplier = tuple2[0]
124- if ((symbol != getStringValue(this, "symbol")))
125- then throw("wrong symbol")
126- else if ((multiplier != getIntegerValue(this, "multiplier")))
127- then throw("wrong multiplier")
128- else if ((getIntegerValue(this, "latestRequestId") >= requestId))
129- then throw("requestId is not new")
130- else {
131- let result = getBinaryValue(bridge, (toString(requestId) + "/result"))
132- let price = decodeInt64(result, 0)[0]
133- WriteSet([DataEntry("latestWavesPrice", price), DataEntry("latestRequestId", requestId)])
134- }
135- }
136- }
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")
19+ else {
20+ let price = getIntegerValue(getBridgeAddress(), (symbol + "/value"))
21+ WriteSet([DataEntry((symbol + "/price"), price)])
22+ }
13723
13824

github/deemru/w8io/3ef1775 
48.86 ms