1
1
#![ allow( dead_code) ]
2
2
#![ cfg_attr( not( feature = "std" ) , no_std) ]
3
3
#![ cfg_attr( not( feature = "std" ) , feature( alloc_error_handler) ) ]
4
- #![ cfg_attr( feature = "log" , feature( panic_info_message) ) ]
5
4
5
+ pub mod account_ids;
6
6
pub mod blake2;
7
7
pub mod bn128;
8
8
pub mod hash;
@@ -15,6 +15,7 @@ pub mod secp256k1;
15
15
#[ cfg( test) ]
16
16
mod utils;
17
17
18
+ use crate :: account_ids:: { CurrentAccount , PredecessorAccount } ;
18
19
use crate :: blake2:: Blake2F ;
19
20
use crate :: bn128:: { Bn128Add , Bn128Mul , Bn128Pair } ;
20
21
use crate :: hash:: { RIPEMD160 , SHA256 } ;
@@ -125,6 +126,7 @@ impl executor::stack::PrecompileSet for Precompiles {
125
126
pub struct PrecompileConstructorContext {
126
127
pub current_account_id : AccountId ,
127
128
pub random_seed : H256 ,
129
+ pub predecessor_account_id : AccountId ,
128
130
}
129
131
130
132
impl Precompiles {
@@ -137,14 +139,18 @@ impl Precompiles {
137
139
ExitToNear :: ADDRESS ,
138
140
ExitToEthereum :: ADDRESS ,
139
141
RandomSeed :: ADDRESS ,
142
+ CurrentAccount :: ADDRESS ,
143
+ PredecessorAccount :: ADDRESS ,
140
144
] ;
141
145
let fun: prelude:: Vec < Box < dyn Precompile > > = vec ! [
142
146
Box :: new( ECRecover ) ,
143
147
Box :: new( SHA256 ) ,
144
148
Box :: new( RIPEMD160 ) ,
145
149
Box :: new( ExitToNear :: new( ctx. current_account_id. clone( ) ) ) ,
146
- Box :: new( ExitToEthereum :: new( ctx. current_account_id) ) ,
150
+ Box :: new( ExitToEthereum :: new( ctx. current_account_id. clone ( ) ) ) ,
147
151
Box :: new( RandomSeed :: new( ctx. random_seed) ) ,
152
+ Box :: new( CurrentAccount :: new( ctx. current_account_id) ) ,
153
+ Box :: new( PredecessorAccount :: new( ctx. predecessor_account_id) ) ,
148
154
] ;
149
155
let map: BTreeMap < Address , Box < dyn Precompile > > = addresses. into_iter ( ) . zip ( fun) . collect ( ) ;
150
156
@@ -165,6 +171,8 @@ impl Precompiles {
165
171
ExitToNear :: ADDRESS ,
166
172
ExitToEthereum :: ADDRESS ,
167
173
RandomSeed :: ADDRESS ,
174
+ CurrentAccount :: ADDRESS ,
175
+ PredecessorAccount :: ADDRESS ,
168
176
] ;
169
177
let fun: prelude:: Vec < Box < dyn Precompile > > = vec ! [
170
178
Box :: new( ECRecover ) ,
@@ -176,8 +184,10 @@ impl Precompiles {
176
184
Box :: new( Bn128Mul :: <Byzantium >:: new( ) ) ,
177
185
Box :: new( Bn128Pair :: <Byzantium >:: new( ) ) ,
178
186
Box :: new( ExitToNear :: new( ctx. current_account_id. clone( ) ) ) ,
179
- Box :: new( ExitToEthereum :: new( ctx. current_account_id) ) ,
187
+ Box :: new( ExitToEthereum :: new( ctx. current_account_id. clone ( ) ) ) ,
180
188
Box :: new( RandomSeed :: new( ctx. random_seed) ) ,
189
+ Box :: new( CurrentAccount :: new( ctx. current_account_id) ) ,
190
+ Box :: new( PredecessorAccount :: new( ctx. predecessor_account_id) ) ,
181
191
] ;
182
192
let map: BTreeMap < Address , Box < dyn Precompile > > = addresses. into_iter ( ) . zip ( fun) . collect ( ) ;
183
193
@@ -198,6 +208,8 @@ impl Precompiles {
198
208
ExitToNear :: ADDRESS ,
199
209
ExitToEthereum :: ADDRESS ,
200
210
RandomSeed :: ADDRESS ,
211
+ CurrentAccount :: ADDRESS ,
212
+ PredecessorAccount :: ADDRESS ,
201
213
] ;
202
214
let fun: prelude:: Vec < Box < dyn Precompile > > = vec ! [
203
215
Box :: new( ECRecover ) ,
@@ -210,8 +222,10 @@ impl Precompiles {
210
222
Box :: new( Bn128Pair :: <Istanbul >:: new( ) ) ,
211
223
Box :: new( Blake2F ) ,
212
224
Box :: new( ExitToNear :: new( ctx. current_account_id. clone( ) ) ) ,
213
- Box :: new( ExitToEthereum :: new( ctx. current_account_id) ) ,
225
+ Box :: new( ExitToEthereum :: new( ctx. current_account_id. clone ( ) ) ) ,
214
226
Box :: new( RandomSeed :: new( ctx. random_seed) ) ,
227
+ Box :: new( CurrentAccount :: new( ctx. current_account_id) ) ,
228
+ Box :: new( PredecessorAccount :: new( ctx. predecessor_account_id) ) ,
215
229
] ;
216
230
let map: BTreeMap < Address , Box < dyn Precompile > > = addresses. into_iter ( ) . zip ( fun) . collect ( ) ;
217
231
@@ -232,6 +246,8 @@ impl Precompiles {
232
246
ExitToNear :: ADDRESS ,
233
247
ExitToEthereum :: ADDRESS ,
234
248
RandomSeed :: ADDRESS ,
249
+ CurrentAccount :: ADDRESS ,
250
+ PredecessorAccount :: ADDRESS ,
235
251
] ;
236
252
let fun: prelude:: Vec < Box < dyn Precompile > > = vec ! [
237
253
Box :: new( ECRecover ) ,
@@ -244,8 +260,10 @@ impl Precompiles {
244
260
Box :: new( Bn128Pair :: <Istanbul >:: new( ) ) ,
245
261
Box :: new( Blake2F ) ,
246
262
Box :: new( ExitToNear :: new( ctx. current_account_id. clone( ) ) ) ,
247
- Box :: new( ExitToEthereum :: new( ctx. current_account_id) ) ,
263
+ Box :: new( ExitToEthereum :: new( ctx. current_account_id. clone ( ) ) ) ,
248
264
Box :: new( RandomSeed :: new( ctx. random_seed) ) ,
265
+ Box :: new( CurrentAccount :: new( ctx. current_account_id) ) ,
266
+ Box :: new( PredecessorAccount :: new( ctx. predecessor_account_id) ) ,
249
267
] ;
250
268
let map: BTreeMap < Address , Box < dyn Precompile > > = addresses. into_iter ( ) . zip ( fun) . collect ( ) ;
251
269
0 commit comments