tx · HvQcUZTTj3PXorsqk5LniFZcPa2tmQr1c9uTHkAHsq8u 3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM: -0.01400000 Waves 2020.06.25 10:05 [1058891] smart account 3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM > SELF 0.00000000 Waves
{ "type": 13, "id": "HvQcUZTTj3PXorsqk5LniFZcPa2tmQr1c9uTHkAHsq8u", "fee": 1400000, "feeAssetId": null, "timestamp": 1593068717309, "version": 1, "sender": "3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM", "senderPublicKey": "FmnQ1LwTnauTS2BSrZivE1nSF1A9MY9hyYB72pyh5hw9", "proofs": [ "2U7XxGEcfKRMZwJNsrk31SB2LJW7B5eFHgb4GbgvD7dwTu9QXffR9zuEZ9c5HgQTpRxBNhwUKnpjcNEyd7iUgHDb" ], "script": "base64:AAIDAAAAAAAAAAwIARIDCgEIEgMKAQIAAAAOAQAAAApkZWNvZGVJbnQ4AAAAAgAAAARkYXRhAAAABm9mZnNldAMJAABmAAAAAgAAAAAAAAAAAQkAAMgAAAABBQAAAARkYXRhCQAAAgAAAAECAAAALWRlY29kZSB1OCBlcnJvciwgZGF0YSBtdXN0IGJlIGF0IGxlYXN0IDEgYnl0ZQMJAABmAAAAAgUAAAAGb2Zmc2V0CQAAyAAAAAEFAAAABGRhdGEJAAACAAAAAQIAAAAjZGVjb2RlIHU4IGVycm9yLCBkZWNvZGluZyBpcyBmaW5pc2gEAAAAAngwCQAAyQAAAAIJAADKAAAAAgUAAAAEZGF0YQUAAAAGb2Zmc2V0AAAAAAAAAAABBAAAAAJ4MQkABLIAAAACCQAAywAAAAIBAAAABwAAAAAAAAAFAAAAAngwAAAAAAAAAAAACQAETAAAAAIJAASyAAAAAgkAAMsAAAACAQAAAAcAAAAAAAAABQAAAAJ4MAAAAAAAAAAAAAkABEwAAAACCQAAZAAAAAIFAAAABm9mZnNldAAAAAAAAAAAAQUAAAADbmlsAQAAAAtkZWNvZ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BQAAAARyZXM3AAAAAAAAAAAAAAAABXZhbHVlBQAAAANuaWwAAAAA+2jhjA==", "chainId": 84, "height": 1058891, "spentComplexity": 0 } View: original | compacted Prev: 3VNxqGa3MMfcQH7M3eoTGp1tf88fGMs2rPXiCB6fDbzT Next: CmmTBgbYZzDqbmKGNADMXjMvvNGcE4WEGSnGs4SpiwbW Diff:
Old | New | Differences | |
---|---|---|---|
120 | 120 | ||
121 | 121 | ||
122 | 122 | @Callable(contextObj) | |
123 | - | func relayAndVerify (data) = { | |
124 | - | let req1 = decodeString(data, 0) | |
125 | - | let req2 = decodeInt64(data, getOffset(req1)) | |
126 | - | let req3 = decodeBytes(data, req2[1]) | |
127 | - | let req4 = decodeInt64(data, getOffset(req3)) | |
128 | - | let req5 = decodeInt64(data, req4[1]) | |
129 | - | let res1 = decodeString(data, req5[1]) | |
130 | - | let res2 = decodeInt64(data, getOffset(res1)) | |
131 | - | let res3 = decodeInt64(data, res2[1]) | |
132 | - | let res4 = decodeInt64(data, res3[1]) | |
133 | - | let res5 = decodeInt64(data, res4[1]) | |
134 | - | let res6 = decodeInt8(data, res5[1]) | |
135 | - | let res7 = decodeBytes(data, res6[1]) | |
136 | - | let requestID = toString(res2[0]) | |
137 | - | WriteSet([DataEntry((requestID + "-clientId"), req1[0].value), DataEntry((requestID + "-oracleScriptId"), req2[0]), DataEntry((requestID + "-calldata"), req3[0].value), DataEntry((requestID + "-askCount"), req4[0]), DataEntry((requestID + "-minCount"), req5[0]), DataEntry((requestID + "-ansCount"), res3[0]), DataEntry((requestID + "-requestTime"), res4[0]), DataEntry((requestID + "-resolveTime"), res5[0]), DataEntry((requestID + "-resolveStatus"), res6[0]), DataEntry((requestID + "-result"), res7[0].value)]) | |
138 | - | } | |
123 | + | func relayAndVerify (data) = if ((contextObj.caller != addressFromString("3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM"))) | |
124 | + | then throw("Unauthorized caller") | |
125 | + | else { | |
126 | + | let req1 = decodeString(data, 0) | |
127 | + | let req2 = decodeInt64(data, getOffset(req1)) | |
128 | + | let req3 = decodeBytes(data, req2[1]) | |
129 | + | let req4 = decodeInt64(data, getOffset(req3)) | |
130 | + | let req5 = decodeInt64(data, req4[1]) | |
131 | + | let res1 = decodeString(data, req5[1]) | |
132 | + | let res2 = decodeInt64(data, getOffset(res1)) | |
133 | + | let res3 = decodeInt64(data, res2[1]) | |
134 | + | let res4 = decodeInt64(data, res3[1]) | |
135 | + | let res5 = decodeInt64(data, res4[1]) | |
136 | + | let res6 = decodeInt8(data, res5[1]) | |
137 | + | let res7 = decodeBytes(data, res6[1]) | |
138 | + | let requestID = toString(res2[0]) | |
139 | + | WriteSet([DataEntry((requestID + "-clientId"), req1[0].value), DataEntry((requestID + "-oracleScriptId"), req2[0]), DataEntry((requestID + "-calldata"), req3[0].value), DataEntry((requestID + "-askCount"), req4[0]), DataEntry((requestID + "-minCount"), req5[0]), DataEntry((requestID + "-ansCount"), res3[0]), DataEntry((requestID + "-requestTime"), res4[0]), DataEntry((requestID + "-resolveTime"), res5[0]), DataEntry((requestID + "-resolveStatus"), res6[0]), DataEntry((requestID + "-result"), res7[0].value)]) | |
140 | + | } | |
139 | 141 | ||
140 | 142 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func decodeInt8 (data,offset) = if ((1 > size(data))) | |
5 | 5 | then throw("decode u8 error, data must be at least 1 byte") | |
6 | 6 | else if ((offset > size(data))) | |
7 | 7 | then throw("decode u8 error, decoding is finish") | |
8 | 8 | else { | |
9 | 9 | let x0 = take(drop(data, offset), 1) | |
10 | 10 | let x1 = toInt((base58'1111111' + x0), 0) | |
11 | 11 | [toInt((base58'1111111' + x0), 0), (offset + 1)] | |
12 | 12 | } | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func decodeInt16 (data,offset) = if ((2 > size(data))) | |
16 | 16 | then throw("decode u16 error, data must be at least 2 bytes") | |
17 | 17 | else if ((offset > size(data))) | |
18 | 18 | then throw("decode u16 error, decoding is finish") | |
19 | 19 | else { | |
20 | 20 | let x0 = drop(data, offset) | |
21 | 21 | let x1 = take(x0, 2) | |
22 | 22 | [toInt((base58'111111' + x1), 0), (offset + 2)] | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func decodeInt32 (data,offset) = if ((4 > size(data))) | |
27 | 27 | then throw("decode u32 error, data must be at least 4 bytes") | |
28 | 28 | else if ((offset > size(data))) | |
29 | 29 | then throw("decode u32 error, decoding is finish") | |
30 | 30 | else { | |
31 | 31 | let x0 = drop(data, offset) | |
32 | 32 | let x1 = take(x0, 4) | |
33 | 33 | [toInt((base58'1111' + x1), 0), (offset + 4)] | |
34 | 34 | } | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func decodeInt64 (data,offset) = if ((8 > size(data))) | |
38 | 38 | then throw("decode u32 error, data must be at least 8 bytes") | |
39 | 39 | else if ((offset > size(data))) | |
40 | 40 | then throw("decode u32 error, decoding is finish") | |
41 | 41 | else { | |
42 | 42 | let x0 = drop(data, offset) | |
43 | 43 | let x1 = take(x0, 8) | |
44 | 44 | [toInt(x1, 0), (offset + 8)] | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func decodeBool (data,offset) = { | |
49 | 49 | let decoded1 = decodeInt8(data, offset) | |
50 | 50 | [DataEntry("bool", (decoded1[0] != 0)), DataEntry("int", decoded1[1])] | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func decodeBytes32 (data,offset) = if ((32 > size(data))) | |
55 | 55 | then throw("decode bytes32 error, data must be at least 32 bytes") | |
56 | 56 | else [DataEntry("byte_vector", take(drop(data, offset), 32)), DataEntry("int", (offset + 32))] | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func decodeBytes64 (data,offset) = if ((64 > size(data))) | |
60 | 60 | then throw("decode bytes64 error, data must be at least 64 bytes") | |
61 | 61 | else [DataEntry("byte_vector", take(drop(data, offset), 64)), DataEntry("int", (offset + 64))] | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func decodeBytes65 (data,offset) = if ((65 > size(data))) | |
65 | 65 | then throw("decode bytes65 error, data must be at least 65 bytes") | |
66 | 66 | else [DataEntry("byte_vector", take(drop(data, offset), 65)), DataEntry("int", (offset + 65))] | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func decodeBytes (data,offset) = { | |
70 | 70 | let decoded1 = decodeInt32(data, offset) | |
71 | 71 | let bytesSize = decoded1[0] | |
72 | 72 | let nextOffset = decoded1[1] | |
73 | 73 | [DataEntry("byte_vector", take(drop(data, nextOffset), bytesSize)), DataEntry("int", (nextOffset + bytesSize))] | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func decodeString (data,offset) = { | |
78 | 78 | let decoded1 = decodeInt32(data, offset) | |
79 | 79 | let bytesSize = decoded1[0] | |
80 | 80 | let nextOffset = decoded1[1] | |
81 | 81 | [DataEntry("string", toUtf8String(take(drop(data, nextOffset), bytesSize))), DataEntry("int", (nextOffset + bytesSize))] | |
82 | 82 | } | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func getAsBool (tuple) = match tuple[0].value { | |
86 | 86 | case b: Boolean => | |
87 | 87 | b | |
88 | 88 | case _ => | |
89 | 89 | throw("not a Boolean") | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func getAsByteVector (tuple) = match tuple[0].value { | |
94 | 94 | case bv: ByteVector => | |
95 | 95 | bv | |
96 | 96 | case _ => | |
97 | 97 | throw("not a ByteVector") | |
98 | 98 | } | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | func getAsString (tuple) = match tuple[0].value { | |
102 | 102 | case s: String => | |
103 | 103 | s | |
104 | 104 | case _ => | |
105 | 105 | throw("not a String") | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | func getOffset (tuple) = match tuple[1].value { | |
110 | 110 | case i: Int => | |
111 | 111 | i | |
112 | 112 | case _ => | |
113 | 113 | throw("not a Int") | |
114 | 114 | } | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | @Callable(contextObj) | |
118 | 118 | func testSaveString (data) = WriteSet([DataEntry("testSaveString", data)]) | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
122 | 122 | @Callable(contextObj) | |
123 | - | func relayAndVerify (data) = { | |
124 | - | let req1 = decodeString(data, 0) | |
125 | - | let req2 = decodeInt64(data, getOffset(req1)) | |
126 | - | let req3 = decodeBytes(data, req2[1]) | |
127 | - | let req4 = decodeInt64(data, getOffset(req3)) | |
128 | - | let req5 = decodeInt64(data, req4[1]) | |
129 | - | let res1 = decodeString(data, req5[1]) | |
130 | - | let res2 = decodeInt64(data, getOffset(res1)) | |
131 | - | let res3 = decodeInt64(data, res2[1]) | |
132 | - | let res4 = decodeInt64(data, res3[1]) | |
133 | - | let res5 = decodeInt64(data, res4[1]) | |
134 | - | let res6 = decodeInt8(data, res5[1]) | |
135 | - | let res7 = decodeBytes(data, res6[1]) | |
136 | - | let requestID = toString(res2[0]) | |
137 | - | WriteSet([DataEntry((requestID + "-clientId"), req1[0].value), DataEntry((requestID + "-oracleScriptId"), req2[0]), DataEntry((requestID + "-calldata"), req3[0].value), DataEntry((requestID + "-askCount"), req4[0]), DataEntry((requestID + "-minCount"), req5[0]), DataEntry((requestID + "-ansCount"), res3[0]), DataEntry((requestID + "-requestTime"), res4[0]), DataEntry((requestID + "-resolveTime"), res5[0]), DataEntry((requestID + "-resolveStatus"), res6[0]), DataEntry((requestID + "-result"), res7[0].value)]) | |
138 | - | } | |
123 | + | func relayAndVerify (data) = if ((contextObj.caller != addressFromString("3N54eKW5ZucDaRaGVUfzX8xRXv6Ve8M71tM"))) | |
124 | + | then throw("Unauthorized caller") | |
125 | + | else { | |
126 | + | let req1 = decodeString(data, 0) | |
127 | + | let req2 = decodeInt64(data, getOffset(req1)) | |
128 | + | let req3 = decodeBytes(data, req2[1]) | |
129 | + | let req4 = decodeInt64(data, getOffset(req3)) | |
130 | + | let req5 = decodeInt64(data, req4[1]) | |
131 | + | let res1 = decodeString(data, req5[1]) | |
132 | + | let res2 = decodeInt64(data, getOffset(res1)) | |
133 | + | let res3 = decodeInt64(data, res2[1]) | |
134 | + | let res4 = decodeInt64(data, res3[1]) | |
135 | + | let res5 = decodeInt64(data, res4[1]) | |
136 | + | let res6 = decodeInt8(data, res5[1]) | |
137 | + | let res7 = decodeBytes(data, res6[1]) | |
138 | + | let requestID = toString(res2[0]) | |
139 | + | WriteSet([DataEntry((requestID + "-clientId"), req1[0].value), DataEntry((requestID + "-oracleScriptId"), req2[0]), DataEntry((requestID + "-calldata"), req3[0].value), DataEntry((requestID + "-askCount"), req4[0]), DataEntry((requestID + "-minCount"), req5[0]), DataEntry((requestID + "-ansCount"), res3[0]), DataEntry((requestID + "-requestTime"), res4[0]), DataEntry((requestID + "-resolveTime"), res5[0]), DataEntry((requestID + "-resolveStatus"), res6[0]), DataEntry((requestID + "-result"), res7[0].value)]) | |
140 | + | } | |
139 | 141 | ||
140 | 142 |
github/deemru/w8io/026f985 39.74 ms ◑