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:AAIDAAAAAAAAAA8IARIECgICCBIFCgMICAEAAAAdAAAAAAVXQVZFUwIAAAAFV0FWRVMAAAAAB0ludFR5cGUAAAAAAAAAAAAAAAAAClN0cmluZ1R5cGUAAAAAAAAAAAEAAAAACUJ5dGVzVHlwZQAAAAAAAAAAAgEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABdgUAAAAHJG1hdGNoMAUAAAABdgAAAAAAAAAAAAEAAAANZ2V0Qnl0ZXNCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHAAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAKQnl0ZVZlY3RvcgQAAAABdgUAAAAHJG1hdGNoMAUAAAABdgEAAAAD0AAAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAA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aWdodAMJAAAAAAAAAgkBAAAAC2dldEhhc2hEYXRhAAAAAQUAAAAIdlB1bHNlSWQBAAAAA9AAAAkAAAIAAAABAgAAABBpbnZhbGlkIHB1bHNlIGlkAwkBAAAAAiE9AAAAAgkAAfUAAAABBQAAAAZ2Qnl0ZXMJAQAAAAtnZXRIYXNoRGF0YQAAAAEFAAAACHZQdWxzZUlkCQAAAgAAAAECAAAAGGludmFsaWQga2VjY2FrMjU2KHZhbHVlKQYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAGVNldEFzc2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAACHNjcmlwdFR4BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAhzY3JpcHRUeAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAACHNjcmlwdFR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAACHNjcmlwdFR4AAAAD3NlbmRlclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAZkYXRhVHgFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAABmRhdGFUeAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAABmRhdGFUeAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAZkYXRhVHgAAAAPc2VuZGVyUHVibGljS2V5B6YxY/o=", "chainId": 84, "height": 1170254, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FCdpLwjPTJggzk2kV7cacvM5f3tfLBNewUD2gS8HvzGX Next: none Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let WAVES = "WAVES"
5+
6+let IntType = 0
7+
8+let StringType = 1
9+
10+let BytesType = 2
511
612 func getNumberByKey (key) = match getInteger(this, key) {
713 case v: Int =>
4147
4248 let SubscriberAddressKey = "subscriber_address"
4349
50+let TypeKey = "type"
51+
4452 let GravityContractKey = "gravity_contract"
4553
4654 let BftCoefficientKey = "bft_coefficient"
4755
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+
4967
5068 let oracles = split(getStringByKey(OraclesKey), ",")
5169
5775
5876 let subscriberAddress = getStringByKey(SubscriberAddressKey)
5977
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+
6088 func validateSign (hash,sign,oracle) = if ((sign != "nil"))
6189 then if (sigVerify(hash, fromBase58String(sign), fromBase58String(oracle)))
6290 then 1
6593
6694
6795 @Callable(i)
68-func confirmData (hash,signs) = {
96+func sendHashValue (hash,signs) = {
6997 let signList = split(signs, ",")
7098 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 ((count > bftCoefficient))
99+ if ((bftCoefficient > count))
72100 then throw("invalid bft count")
73101 else if ((getBytesByKey(toString(height)) != base58'2CsAf'))
74102 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+ }
76107 }
77108
78109
79110
80111 @Callable(i)
81-func setSortedOracles (newSortedOracles,stringSigns,round) = {
112+func updateOracles (newSortedOracles,stringSigns,round) = {
82113 let signs = split(stringSigns, ",")
83114 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]))
84115 if ((count > bftCoefficient))
85116 then throw("invalid bft count")
86- else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry(((LasrRoundKey + "_") + toString(round)), round)])
117+ else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry(((LastRoundKey + "_") + toString(round)), round)])
87118 }
88119
89120
90121 @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
96158 case _ =>
97- throw("invalid args[0] type")
159+ throw("invalid height type")
98160 }
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)
112178 case _ =>
113- true
179+ false
114180 }
115181
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let WAVES = "WAVES"
5+
6+let IntType = 0
7+
8+let StringType = 1
9+
10+let BytesType = 2
511
612 func getNumberByKey (key) = match getInteger(this, key) {
713 case v: Int =>
814 v
915 case _ =>
1016 0
1117 }
1218
1319
1420 func getBytesByKey (key) = match getBinary(this, key) {
1521 case v: ByteVector =>
1622 v
1723 case _ =>
1824 base58'2CsAf'
1925 }
2026
2127
2228 func getStringByKey (key) = match getString(this, key) {
2329 case v: String =>
2430 v
2531 case _ =>
2632 ""
2733 }
2834
2935
3036 func getStringByAddressAndKey (address,key) = match getString(address, key) {
3137 case v: String =>
3238 v
3339 case _ =>
3440 ""
3541 }
3642
3743
3844 let OraclesKey = "oracles"
3945
4046 let ConsulsKey = "consuls"
4147
4248 let SubscriberAddressKey = "subscriber_address"
4349
50+let TypeKey = "type"
51+
4452 let GravityContractKey = "gravity_contract"
4553
4654 let BftCoefficientKey = "bft_coefficient"
4755
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+
4967
5068 let oracles = split(getStringByKey(OraclesKey), ",")
5169
5270 let bftCoefficient = getNumberByKey(BftCoefficientKey)
5371
5472 let gracityContract = addressFromStringValue(getStringByKey(GravityContractKey))
5573
5674 let consuls = split(getStringByAddressAndKey(gracityContract, ConsulsKey), ",")
5775
5876 let subscriberAddress = getStringByKey(SubscriberAddressKey)
5977
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+
6088 func validateSign (hash,sign,oracle) = if ((sign != "nil"))
6189 then if (sigVerify(hash, fromBase58String(sign), fromBase58String(oracle)))
6290 then 1
6391 else 0
6492 else 0
6593
6694
6795 @Callable(i)
68-func confirmData (hash,signs) = {
96+func sendHashValue (hash,signs) = {
6997 let signList = split(signs, ",")
7098 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 ((count > bftCoefficient))
99+ if ((bftCoefficient > count))
72100 then throw("invalid bft count")
73101 else if ((getBytesByKey(toString(height)) != base58'2CsAf'))
74102 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+ }
76107 }
77108
78109
79110
80111 @Callable(i)
81-func setSortedOracles (newSortedOracles,stringSigns,round) = {
112+func updateOracles (newSortedOracles,stringSigns,round) = {
82113 let signs = split(stringSigns, ",")
83114 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]))
84115 if ((count > bftCoefficient))
85116 then throw("invalid bft count")
86- else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry(((LasrRoundKey + "_") + toString(round)), round)])
117+ else WriteSet([DataEntry(OraclesKey, newSortedOracles), DataEntry(((LastRoundKey + "_") + toString(round)), round)])
87118 }
88119
89120
90121 @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
96158 case _ =>
97- throw("invalid args[0] type")
159+ throw("invalid height type")
98160 }
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)
112178 case _ =>
113- true
179+ false
114180 }
115181

github/deemru/w8io/026f985 
31.15 ms