1 | | - | {-# STDLIB_VERSION 3 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "WAVES" |
---|
5 | | - | |
---|
6 | | - | let b = 0 |
---|
7 | | - | |
---|
8 | | - | let c = 1 |
---|
9 | | - | |
---|
10 | | - | let d = 2 |
---|
11 | | - | |
---|
12 | | - | func e (f) = { |
---|
13 | | - | let g = getInteger(this, f) |
---|
14 | | - | if ($isInstanceOf(g, "Int")) |
---|
15 | | - | then { |
---|
16 | | - | let h = g |
---|
17 | | - | h |
---|
18 | | - | } |
---|
19 | | - | else 0 |
---|
20 | | - | } |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | func i (f) = { |
---|
24 | | - | let g = getBinary(this, f) |
---|
25 | | - | if ($isInstanceOf(g, "ByteVector")) |
---|
26 | | - | then { |
---|
27 | | - | let h = g |
---|
28 | | - | h |
---|
29 | | - | } |
---|
30 | | - | else base58'2CsAf' |
---|
31 | | - | } |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | func j (f) = { |
---|
35 | | - | let g = getString(this, f) |
---|
36 | | - | if ($isInstanceOf(g, "String")) |
---|
37 | | - | then { |
---|
38 | | - | let h = g |
---|
39 | | - | h |
---|
40 | | - | } |
---|
41 | | - | else "" |
---|
42 | | - | } |
---|
43 | | - | |
---|
44 | | - | |
---|
45 | | - | func k (l,f) = { |
---|
46 | | - | let g = getString(l, f) |
---|
47 | | - | if ($isInstanceOf(g, "String")) |
---|
48 | | - | then { |
---|
49 | | - | let h = g |
---|
50 | | - | h |
---|
51 | | - | } |
---|
52 | | - | else "" |
---|
53 | | - | } |
---|
54 | | - | |
---|
55 | | - | |
---|
56 | | - | func m (l,f) = { |
---|
57 | | - | let g = getInteger(l, f) |
---|
58 | | - | if ($isInstanceOf(g, "Int")) |
---|
59 | | - | then { |
---|
60 | | - | let h = g |
---|
61 | | - | h |
---|
62 | | - | } |
---|
63 | | - | else 0 |
---|
64 | | - | } |
---|
65 | | - | |
---|
66 | | - | |
---|
67 | | - | let n = "oracles" |
---|
68 | | - | |
---|
69 | | - | let o = "subscriber_address" |
---|
70 | | - | |
---|
71 | | - | let p = "type" |
---|
72 | | - | |
---|
73 | | - | let q = "gravity_contract" |
---|
74 | | - | |
---|
75 | | - | let r = "bft_coefficient" |
---|
76 | | - | |
---|
77 | | - | let s = "last_height" |
---|
78 | | - | |
---|
79 | | - | let t = "last_round" |
---|
80 | | - | |
---|
81 | | - | let u = "last_pulse_id" |
---|
82 | | - | |
---|
83 | | - | func v (w) = ("data_hash_" + toString(w)) |
---|
84 | | - | |
---|
85 | | - | |
---|
86 | | - | func x (w) = ("height_" + toString(w)) |
---|
87 | | - | |
---|
88 | | - | |
---|
89 | | - | func y (z) = ("consuls_" + toString(z)) |
---|
90 | | - | |
---|
91 | | - | |
---|
92 | | - | let A = split(j(n), ",") |
---|
93 | | - | |
---|
94 | | - | let B = e(r) |
---|
95 | | - | |
---|
96 | | - | let C = addressFromStringValue(j(q)) |
---|
97 | | - | |
---|
98 | | - | let D = m(C, t) |
---|
99 | | - | |
---|
100 | | - | let E = split(k(C, y(D)), ",") |
---|
101 | | - | |
---|
102 | | - | let F = j(o) |
---|
103 | | - | |
---|
104 | | - | let G = e(p) |
---|
105 | | - | |
---|
106 | | - | let H = e(u) |
---|
107 | | - | |
---|
108 | | - | func I (w) = i(v(w)) |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | func J (w) = e(x(w)) |
---|
112 | | - | |
---|
113 | | - | |
---|
114 | | - | func K (L,M,N) = if ((M != "nil")) |
---|
115 | | - | then if (sigVerify(L, fromBase58String(M), fromBase58String(N))) |
---|
116 | | - | then 1 |
---|
117 | | - | else 0 |
---|
118 | | - | else 0 |
---|
119 | | - | |
---|
120 | | - | |
---|
121 | | - | @Callable(O) |
---|
122 | | - | func sendHashValue (L,P) = { |
---|
123 | | - | let Q = split(P, ",") |
---|
124 | | - | let R = ((((K(L, Q[0], A[0]) + K(L, Q[1], A[1])) + K(L, Q[2], A[2])) + K(L, Q[3], A[3])) + K(L, Q[4], A[4])) |
---|
125 | | - | if ((B > R)) |
---|
126 | | - | then throw("invalid bft count") |
---|
127 | | - | else { |
---|
128 | | - | let S = (H + 1) |
---|
129 | | - | WriteSet([DataEntry(v(S), L), DataEntry(x(S), height), DataEntry(s, height), DataEntry(u, S)]) |
---|
130 | | - | } |
---|
131 | | - | } |
---|
132 | | - | |
---|
133 | | - | |
---|
134 | | - | |
---|
135 | | - | @Callable(O) |
---|
136 | | - | func updateOracles (T,U,z) = { |
---|
137 | | - | let P = split(U, ",") |
---|
138 | | - | let R = ((((K(toBytes(T), P[0], E[0]) + K(toBytes(T), P[1], E[1])) + K(toBytes(T), P[2], E[2])) + K(toBytes(T), P[3], E[3])) + K(toBytes(T), P[4], E[4])) |
---|
139 | | - | if ((B > R)) |
---|
140 | | - | then throw("invalid bft count") |
---|
141 | | - | else WriteSet([DataEntry(n, T), DataEntry(((t + "_") + toString(z)), z)]) |
---|
142 | | - | } |
---|
143 | | - | |
---|
144 | | - | |
---|
145 | | - | @Verifier(O) |
---|
146 | | - | func V () = { |
---|
147 | | - | let g = O |
---|
148 | | - | if ($isInstanceOf(g, "InvokeScriptTransaction")) |
---|
149 | | - | then { |
---|
150 | | - | let W = g |
---|
151 | | - | let X = if ((G == b)) |
---|
152 | | - | then { |
---|
153 | | - | let h = { |
---|
154 | | - | let Y = W.args[0] |
---|
155 | | - | if ($isInstanceOf(Y, "Int")) |
---|
156 | | - | then { |
---|
157 | | - | let h = Y |
---|
158 | | - | h |
---|
159 | | - | } |
---|
160 | | - | else throw("invalid value type") |
---|
161 | | - | } |
---|
162 | | - | toBytes(h) |
---|
163 | | - | } |
---|
164 | | - | else if ((G == c)) |
---|
165 | | - | then { |
---|
166 | | - | let h = { |
---|
167 | | - | let Y = W.args[0] |
---|
168 | | - | if ($isInstanceOf(Y, "String")) |
---|
169 | | - | then { |
---|
170 | | - | let h = Y |
---|
171 | | - | h |
---|
172 | | - | } |
---|
173 | | - | else throw("invalid value type") |
---|
174 | | - | } |
---|
175 | | - | toBytes(h) |
---|
176 | | - | } |
---|
177 | | - | else if ((G == d)) |
---|
178 | | - | then { |
---|
179 | | - | let h = { |
---|
180 | | - | let Y = W.args[0] |
---|
181 | | - | if ($isInstanceOf(Y, "ByteVector")) |
---|
182 | | - | then { |
---|
183 | | - | let h = Y |
---|
184 | | - | h |
---|
185 | | - | } |
---|
186 | | - | else throw("invalid value type") |
---|
187 | | - | } |
---|
188 | | - | h |
---|
189 | | - | } |
---|
190 | | - | else throw("invalid value type") |
---|
191 | | - | let Z = { |
---|
192 | | - | let Y = W.args[1] |
---|
193 | | - | if ($isInstanceOf(Y, "Int")) |
---|
194 | | - | then { |
---|
195 | | - | let Z = Y |
---|
196 | | - | Z |
---|
197 | | - | } |
---|
198 | | - | else throw("invalid height type") |
---|
199 | | - | } |
---|
200 | | - | if ((W.function != "attachData")) |
---|
201 | | - | then throw("invalid function name") |
---|
202 | | - | else if ((size(W.args) != 2)) |
---|
203 | | - | then throw("invalid args size") |
---|
204 | | - | else if ((W.dApp != addressFromStringValue(F))) |
---|
205 | | - | then throw("invalid dapp address") |
---|
206 | | - | else if ((J(Z) != height)) |
---|
207 | | - | then throw("invalid height") |
---|
208 | | - | else if ((I(Z) == base58'2CsAf')) |
---|
209 | | - | then throw("invalid pulse id") |
---|
210 | | - | else if ((keccak256(X) != I(Z))) |
---|
211 | | - | then throw("invalid keccak256(value)") |
---|
212 | | - | else true |
---|
213 | | - | } |
---|
214 | | - | else sigVerify(O.bodyBytes, O.proofs[0], O.senderPublicKey) |
---|
215 | | - | } |
---|
216 | | - | |
---|
| 1 | + | {-# STDLIB_VERSION 4 #-} |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let publicKeyEth = base58'2sAQGNeFdzACYHGCvSVaxhgYKPes' |
---|
| 4 | + | (ecrecover(keccak256(tx.bodyBytes), tx.proofs[0]) == publicKeyEth) |
---|