tx · JD54pJXRS4ARoyPtyb2Chn16LUneawRHKqpzfxGPg1BS 3N666c9jMPp2LgthP7QpdaHbfcyCXp6pfk2: -0.01400000 Waves 2020.09.09 23:20 [1170254] smart account 3N666c9jMPp2LgthP7QpdaHbfcyCXp6pfk2 > SELF 0.00000000 Waves
{ "type": 13, "id": "JD54pJXRS4ARoyPtyb2Chn16LUneawRHKqpzfxGPg1BS", "fee": 1400000, "feeAssetId": null, "timestamp": 1599682814955, "version": 1, "sender": "3N666c9jMPp2LgthP7QpdaHbfcyCXp6pfk2", "senderPublicKey": "2K3zsM6XaqxaedbuC6dRB8cVX8TcnGRAXSkRyUmXiSAj", "proofs": [ "YBMhRNiLqn1qzm6mDHg4ADzcgJopCeYDgnBcpoK7usghPsKFZ5aqVQPvWKQMNtUZaaCxscjKmR5mFHvK8TZkWpL" ], "script": "base64:AAIDAAAAAAAAAA8IARIECgICCBIFCgMICAEAAAAdAAAAAAVXQVZFUwIAAAAFV0FWRVMAAAAAB0ludFR5cGUAAAAAAAAAAAAAAAAAClN0cmluZ1R5cGUAAAAAAAAAAAEAAAAACUJ5dGVzVHlwZQAAAAAAAAAAAgEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABdgUAAAAHJG1hdGNoMAUAAAABdgAAAAAAAAAAAAEAAAANZ2V0Qnl0ZXNCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHAAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAKQnl0ZVZlY3RvcgQAAAABdgUAAAAHJG1hdGNoMAUAAAABdgEAAAAD0AAAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAA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WdodAMJAAAAAAAAAgkBAAAAC2dldEhhc2hEYXRhAAAAAQUAAAAIdlB1bHNlSWQBAAAAA9AAAAkAAAIAAAABAgAAABBpbnZhbGlkIHB1bHNlIGlkAwkBAAAAAiE9AAAAAgkAAfUAAAABBQAAAAZ2Qnl0ZXMJAQAAAAtnZXRIYXNoRGF0YQAAAAEFAAAACHZQdWxzZUlkCQAAAgAAAAECAAAAGGludmFsaWQga2VjY2FrMjU2KHZhbHVlKQYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAGVNldEFzc2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAACHNjcmlwdFR4BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAhzY3JpcHRUeAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAACHNjcmlwdFR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAACHNjcmlwdFR4AAAAD3NlbmRlclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAZkYXRhVHgFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAABmRhdGFUeAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAABmRhdGFUeAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAZkYXRhVHgAAAAPc2VuZGVyUHVibGljS2V5B6YxY/o=", "chainId": 84, "height": 1170254, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FCdpLwjPTJggzk2kV7cacvM5f3tfLBNewUD2gS8HvzGX Next: none Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let WAVES = "WAVES" | |
5 | + | ||
6 | + | let IntType = 0 | |
7 | + | ||
8 | + | let StringType = 1 | |
9 | + | ||
10 | + | let BytesType = 2 | |
5 | 11 | ||
6 | 12 | func getNumberByKey (key) = match getInteger(this, key) { | |
7 | 13 | case v: Int => | |
41 | 47 | ||
42 | 48 | let SubscriberAddressKey = "subscriber_address" | |
43 | 49 | ||
50 | + | let TypeKey = "type" | |
51 | + | ||
44 | 52 | let GravityContractKey = "gravity_contract" | |
45 | 53 | ||
46 | 54 | let BftCoefficientKey = "bft_coefficient" | |
47 | 55 | ||
48 | - | let LasrRoundKey = "last_round" | |
56 | + | let LastHeightKey = "last_height" | |
57 | + | ||
58 | + | let LastRoundKey = "last_round" | |
59 | + | ||
60 | + | let LastPulseIdKey = "last_pulse_id" | |
61 | + | ||
62 | + | func getHashDataKey (pulseId) = ("data_hash_" + toString(pulseId)) | |
63 | + | ||
64 | + | ||
65 | + | func getHeightByPulseKey (pulseId) = ("height_" + toString(pulseId)) | |
66 | + | ||
49 | 67 | ||
50 | 68 | let oracles = split(getStringByKey(OraclesKey), ",") | |
51 | 69 | ||
57 | 75 | ||
58 | 76 | let subscriberAddress = getStringByKey(SubscriberAddressKey) | |
59 | 77 | ||
78 | + | let type = getNumberByKey(TypeKey) | |
79 | + | ||
80 | + | let lastPulseId = getNumberByKey(LastPulseIdKey) | |
81 | + | ||
82 | + | func getHashData (pulseId) = getBytesByKey(getHashDataKey(pulseId)) | |
83 | + | ||
84 | + | ||
85 | + | func getHeightByPulse (pulseId) = getNumberByKey(getHeightByPulseKey(pulseId)) | |
86 | + | ||
87 | + | ||
60 | 88 | func validateSign (hash,sign,oracle) = if ((sign != "nil")) | |
61 | 89 | then if (sigVerify(hash, fromBase58String(sign), fromBase58String(oracle))) | |
62 | 90 | then 1 | |
65 | 93 | ||
66 | 94 | ||
67 | 95 | @Callable(i) | |
68 | - | func | |
96 | + | func sendHashValue (hash,signs) = { | |
69 | 97 | let signList = split(signs, ",") | |
70 | 98 | let count = ((((validateSign(hash, signList[0], oracles[0]) + validateSign(hash, signList[1], oracles[1])) + validateSign(hash, signList[2], oracles[2])) + validateSign(hash, signList[3], oracles[3])) + validateSign(hash, signList[4], oracles[4])) | |
71 | - | if (( | |
99 | + | if ((bftCoefficient > count)) | |
72 | 100 | then throw("invalid bft count") | |
73 | 101 | else if ((getBytesByKey(toString(height)) != base58'2CsAf')) | |
74 | 102 | then throw("data is exist") | |
75 | - | else WriteSet([DataEntry(toString(height), hash)]) | |
103 | + | else { | |
104 | + | let pulseId = (lastPulseId + 1) | |
105 | + | WriteSet([DataEntry(getHashDataKey(pulseId), hash), DataEntry(getHeightByPulseKey(pulseId), height), DataEntry(LastHeightKey, height), DataEntry(LastPulseIdKey, pulseId)]) | |
106 | + | } | |
76 | 107 | } | |
77 | 108 | ||
78 | 109 | ||
79 | 110 | ||
80 | 111 | @Callable(i) | |
81 | - | func | |
112 | + | func updateOracles (newSortedOracles,stringSigns,round) = { | |
82 | 113 | let signs = split(stringSigns, ",") | |
83 | 114 | let count = ((((validateSign(toBytes(newSortedOracles), signs[0], consuls[0]) + validateSign(toBytes(newSortedOracles), signs[1], consuls[1])) + validateSign(toBytes(newSortedOracles), signs[2], consuls[2])) + validateSign(toBytes(newSortedOracles), signs[3], consuls[3])) + validateSign(toBytes(newSortedOracles), signs[4], consuls[4])) | |
84 | 115 | if ((count > bftCoefficient)) | |
85 | 116 | then throw("invalid bft count") | |
86 | - | else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry((( | |
117 | + | else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry(((LastRoundKey + "_") + toString(round)), round)]) | |
87 | 118 | } | |
88 | 119 | ||
89 | 120 | ||
90 | 121 | @Verifier(i) | |
91 | - | func sendData () = match i { | |
92 | - | case in: InvokeScriptTransaction => | |
93 | - | let v = match in.args[0] { | |
94 | - | case v: Int => | |
95 | - | v | |
122 | + | func sendValueToSub () = match i { | |
123 | + | case invokeTx: InvokeScriptTransaction => | |
124 | + | let vBytes = if ((type == IntType)) | |
125 | + | then { | |
126 | + | let v = match invokeTx.args[0] { | |
127 | + | case v: Int => | |
128 | + | v | |
129 | + | case _ => | |
130 | + | throw("invalid value type") | |
131 | + | } | |
132 | + | toBytes(v) | |
133 | + | } | |
134 | + | else if ((type == StringType)) | |
135 | + | then { | |
136 | + | let v = match invokeTx.args[0] { | |
137 | + | case v: String => | |
138 | + | v | |
139 | + | case _ => | |
140 | + | throw("invalid value type") | |
141 | + | } | |
142 | + | toBytes(v) | |
143 | + | } | |
144 | + | else if ((type == BytesType)) | |
145 | + | then { | |
146 | + | let v = match invokeTx.args[0] { | |
147 | + | case v: ByteVector => | |
148 | + | v | |
149 | + | case _ => | |
150 | + | throw("invalid value type") | |
151 | + | } | |
152 | + | v | |
153 | + | } | |
154 | + | else throw("invalid value type") | |
155 | + | let vPulseId = match invokeTx.args[1] { | |
156 | + | case vPulseId: Int => | |
157 | + | vPulseId | |
96 | 158 | case _ => | |
97 | - | throw("invalid | |
159 | + | throw("invalid height type") | |
98 | 160 | } | |
99 | - | let vHeight = match in.args[1] { | |
100 | - | case vHeight: Int => | |
101 | - | vHeight | |
102 | - | case _ => | |
103 | - | throw("invalid args[1] type") | |
104 | - | } | |
105 | - | if ((in.dApp != addressFromStringValue(subscriberAddress))) | |
106 | - | then throw("invalid dapp address") | |
107 | - | else if ((getStringByKey(toString(vHeight)) == "")) | |
108 | - | then throw("invalid height") | |
109 | - | else if ((keccak256(toBytes(v)) != fromBase58String(getStringByKey(toString(vHeight))))) | |
110 | - | then throw(("invalid keccak256(value) " + toString(v))) | |
111 | - | else true | |
161 | + | if ((invokeTx.function != "attachValue")) | |
162 | + | then throw("invalid function name") | |
163 | + | else if ((size(invokeTx.args) != 2)) | |
164 | + | then throw("invalid args size") | |
165 | + | else if ((invokeTx.dApp != addressFromStringValue(subscriberAddress))) | |
166 | + | then throw("invalid dapp address") | |
167 | + | else if ((getHeightByPulse(vPulseId) != height)) | |
168 | + | then throw("invalid height") | |
169 | + | else if ((getHashData(vPulseId) == base58'2CsAf')) | |
170 | + | then throw("invalid pulse id") | |
171 | + | else if ((keccak256(vBytes) != getHashData(vPulseId))) | |
172 | + | then throw("invalid keccak256(value)") | |
173 | + | else true | |
174 | + | case scriptTx: SetAssetScriptTransaction => | |
175 | + | sigVerify(scriptTx.bodyBytes, scriptTx.proofs[0], scriptTx.senderPublicKey) | |
176 | + | case dataTx: DataTransaction => | |
177 | + | sigVerify(dataTx.bodyBytes, dataTx.proofs[0], dataTx.senderPublicKey) | |
112 | 178 | case _ => | |
113 | - | | |
179 | + | false | |
114 | 180 | } | |
115 | 181 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let WAVES = "WAVES" | |
5 | + | ||
6 | + | let IntType = 0 | |
7 | + | ||
8 | + | let StringType = 1 | |
9 | + | ||
10 | + | let BytesType = 2 | |
5 | 11 | ||
6 | 12 | func getNumberByKey (key) = match getInteger(this, key) { | |
7 | 13 | case v: Int => | |
8 | 14 | v | |
9 | 15 | case _ => | |
10 | 16 | 0 | |
11 | 17 | } | |
12 | 18 | ||
13 | 19 | ||
14 | 20 | func getBytesByKey (key) = match getBinary(this, key) { | |
15 | 21 | case v: ByteVector => | |
16 | 22 | v | |
17 | 23 | case _ => | |
18 | 24 | base58'2CsAf' | |
19 | 25 | } | |
20 | 26 | ||
21 | 27 | ||
22 | 28 | func getStringByKey (key) = match getString(this, key) { | |
23 | 29 | case v: String => | |
24 | 30 | v | |
25 | 31 | case _ => | |
26 | 32 | "" | |
27 | 33 | } | |
28 | 34 | ||
29 | 35 | ||
30 | 36 | func getStringByAddressAndKey (address,key) = match getString(address, key) { | |
31 | 37 | case v: String => | |
32 | 38 | v | |
33 | 39 | case _ => | |
34 | 40 | "" | |
35 | 41 | } | |
36 | 42 | ||
37 | 43 | ||
38 | 44 | let OraclesKey = "oracles" | |
39 | 45 | ||
40 | 46 | let ConsulsKey = "consuls" | |
41 | 47 | ||
42 | 48 | let SubscriberAddressKey = "subscriber_address" | |
43 | 49 | ||
50 | + | let TypeKey = "type" | |
51 | + | ||
44 | 52 | let GravityContractKey = "gravity_contract" | |
45 | 53 | ||
46 | 54 | let BftCoefficientKey = "bft_coefficient" | |
47 | 55 | ||
48 | - | let LasrRoundKey = "last_round" | |
56 | + | let LastHeightKey = "last_height" | |
57 | + | ||
58 | + | let LastRoundKey = "last_round" | |
59 | + | ||
60 | + | let LastPulseIdKey = "last_pulse_id" | |
61 | + | ||
62 | + | func getHashDataKey (pulseId) = ("data_hash_" + toString(pulseId)) | |
63 | + | ||
64 | + | ||
65 | + | func getHeightByPulseKey (pulseId) = ("height_" + toString(pulseId)) | |
66 | + | ||
49 | 67 | ||
50 | 68 | let oracles = split(getStringByKey(OraclesKey), ",") | |
51 | 69 | ||
52 | 70 | let bftCoefficient = getNumberByKey(BftCoefficientKey) | |
53 | 71 | ||
54 | 72 | let gracityContract = addressFromStringValue(getStringByKey(GravityContractKey)) | |
55 | 73 | ||
56 | 74 | let consuls = split(getStringByAddressAndKey(gracityContract, ConsulsKey), ",") | |
57 | 75 | ||
58 | 76 | let subscriberAddress = getStringByKey(SubscriberAddressKey) | |
59 | 77 | ||
78 | + | let type = getNumberByKey(TypeKey) | |
79 | + | ||
80 | + | let lastPulseId = getNumberByKey(LastPulseIdKey) | |
81 | + | ||
82 | + | func getHashData (pulseId) = getBytesByKey(getHashDataKey(pulseId)) | |
83 | + | ||
84 | + | ||
85 | + | func getHeightByPulse (pulseId) = getNumberByKey(getHeightByPulseKey(pulseId)) | |
86 | + | ||
87 | + | ||
60 | 88 | func validateSign (hash,sign,oracle) = if ((sign != "nil")) | |
61 | 89 | then if (sigVerify(hash, fromBase58String(sign), fromBase58String(oracle))) | |
62 | 90 | then 1 | |
63 | 91 | else 0 | |
64 | 92 | else 0 | |
65 | 93 | ||
66 | 94 | ||
67 | 95 | @Callable(i) | |
68 | - | func | |
96 | + | func sendHashValue (hash,signs) = { | |
69 | 97 | let signList = split(signs, ",") | |
70 | 98 | let count = ((((validateSign(hash, signList[0], oracles[0]) + validateSign(hash, signList[1], oracles[1])) + validateSign(hash, signList[2], oracles[2])) + validateSign(hash, signList[3], oracles[3])) + validateSign(hash, signList[4], oracles[4])) | |
71 | - | if (( | |
99 | + | if ((bftCoefficient > count)) | |
72 | 100 | then throw("invalid bft count") | |
73 | 101 | else if ((getBytesByKey(toString(height)) != base58'2CsAf')) | |
74 | 102 | then throw("data is exist") | |
75 | - | else WriteSet([DataEntry(toString(height), hash)]) | |
103 | + | else { | |
104 | + | let pulseId = (lastPulseId + 1) | |
105 | + | WriteSet([DataEntry(getHashDataKey(pulseId), hash), DataEntry(getHeightByPulseKey(pulseId), height), DataEntry(LastHeightKey, height), DataEntry(LastPulseIdKey, pulseId)]) | |
106 | + | } | |
76 | 107 | } | |
77 | 108 | ||
78 | 109 | ||
79 | 110 | ||
80 | 111 | @Callable(i) | |
81 | - | func | |
112 | + | func updateOracles (newSortedOracles,stringSigns,round) = { | |
82 | 113 | let signs = split(stringSigns, ",") | |
83 | 114 | let count = ((((validateSign(toBytes(newSortedOracles), signs[0], consuls[0]) + validateSign(toBytes(newSortedOracles), signs[1], consuls[1])) + validateSign(toBytes(newSortedOracles), signs[2], consuls[2])) + validateSign(toBytes(newSortedOracles), signs[3], consuls[3])) + validateSign(toBytes(newSortedOracles), signs[4], consuls[4])) | |
84 | 115 | if ((count > bftCoefficient)) | |
85 | 116 | then throw("invalid bft count") | |
86 | - | else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry((( | |
117 | + | else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry(((LastRoundKey + "_") + toString(round)), round)]) | |
87 | 118 | } | |
88 | 119 | ||
89 | 120 | ||
90 | 121 | @Verifier(i) | |
91 | - | func sendData () = match i { | |
92 | - | case in: InvokeScriptTransaction => | |
93 | - | let v = match in.args[0] { | |
94 | - | case v: Int => | |
95 | - | v | |
122 | + | func sendValueToSub () = match i { | |
123 | + | case invokeTx: InvokeScriptTransaction => | |
124 | + | let vBytes = if ((type == IntType)) | |
125 | + | then { | |
126 | + | let v = match invokeTx.args[0] { | |
127 | + | case v: Int => | |
128 | + | v | |
129 | + | case _ => | |
130 | + | throw("invalid value type") | |
131 | + | } | |
132 | + | toBytes(v) | |
133 | + | } | |
134 | + | else if ((type == StringType)) | |
135 | + | then { | |
136 | + | let v = match invokeTx.args[0] { | |
137 | + | case v: String => | |
138 | + | v | |
139 | + | case _ => | |
140 | + | throw("invalid value type") | |
141 | + | } | |
142 | + | toBytes(v) | |
143 | + | } | |
144 | + | else if ((type == BytesType)) | |
145 | + | then { | |
146 | + | let v = match invokeTx.args[0] { | |
147 | + | case v: ByteVector => | |
148 | + | v | |
149 | + | case _ => | |
150 | + | throw("invalid value type") | |
151 | + | } | |
152 | + | v | |
153 | + | } | |
154 | + | else throw("invalid value type") | |
155 | + | let vPulseId = match invokeTx.args[1] { | |
156 | + | case vPulseId: Int => | |
157 | + | vPulseId | |
96 | 158 | case _ => | |
97 | - | throw("invalid | |
159 | + | throw("invalid height type") | |
98 | 160 | } | |
99 | - | let vHeight = match in.args[1] { | |
100 | - | case vHeight: Int => | |
101 | - | vHeight | |
102 | - | case _ => | |
103 | - | throw("invalid args[1] type") | |
104 | - | } | |
105 | - | if ((in.dApp != addressFromStringValue(subscriberAddress))) | |
106 | - | then throw("invalid dapp address") | |
107 | - | else if ((getStringByKey(toString(vHeight)) == "")) | |
108 | - | then throw("invalid height") | |
109 | - | else if ((keccak256(toBytes(v)) != fromBase58String(getStringByKey(toString(vHeight))))) | |
110 | - | then throw(("invalid keccak256(value) " + toString(v))) | |
111 | - | else true | |
161 | + | if ((invokeTx.function != "attachValue")) | |
162 | + | then throw("invalid function name") | |
163 | + | else if ((size(invokeTx.args) != 2)) | |
164 | + | then throw("invalid args size") | |
165 | + | else if ((invokeTx.dApp != addressFromStringValue(subscriberAddress))) | |
166 | + | then throw("invalid dapp address") | |
167 | + | else if ((getHeightByPulse(vPulseId) != height)) | |
168 | + | then throw("invalid height") | |
169 | + | else if ((getHashData(vPulseId) == base58'2CsAf')) | |
170 | + | then throw("invalid pulse id") | |
171 | + | else if ((keccak256(vBytes) != getHashData(vPulseId))) | |
172 | + | then throw("invalid keccak256(value)") | |
173 | + | else true | |
174 | + | case scriptTx: SetAssetScriptTransaction => | |
175 | + | sigVerify(scriptTx.bodyBytes, scriptTx.proofs[0], scriptTx.senderPublicKey) | |
176 | + | case dataTx: DataTransaction => | |
177 | + | sigVerify(dataTx.bodyBytes, dataTx.proofs[0], dataTx.senderPublicKey) | |
112 | 178 | case _ => | |
113 | - | | |
179 | + | false | |
114 | 180 | } | |
115 | 181 |
github/deemru/w8io/026f985 31.15 ms ◑