@@ -128,10 +128,11 @@ where
128
128
return Ok ( None )
129
129
}
130
130
let block_id = block_number. map ( BlockId :: from) . unwrap_or ( BlockId :: Latest ) ;
131
- Ok ( self . client . get_text ( transaction_hash, block_id) . map_err ( errors:: transaction_state) ?. map ( |text| {
132
- let parent_block_id = block_number. map ( |n| ( n - 1 ) . into ( ) ) . unwrap_or ( BlockId :: ParentOfLatest ) ;
133
- Text :: from_core ( text, self . client . common_params ( parent_block_id) . unwrap ( ) . network_id ( ) )
134
- } ) )
131
+ Ok ( self
132
+ . client
133
+ . get_text ( transaction_hash, block_id)
134
+ . map_err ( errors:: transaction_state) ?
135
+ . map ( |text| Text :: from_core ( text, self . client . network_id ( ) ) ) )
135
136
}
136
137
137
138
fn get_asset (
@@ -178,8 +179,7 @@ where
178
179
fn get_regular_key_owner ( & self , public : Public , block_number : Option < u64 > ) -> Result < Option < PlatformAddress > > {
179
180
let block_id = block_number. map ( BlockId :: Number ) . unwrap_or ( BlockId :: Latest ) ;
180
181
Ok ( self . client . regular_key_owner ( & public_to_address ( & public) , block_id. into ( ) ) . and_then ( |address| {
181
- let parent_block_id = block_number. map ( |n| ( n - 1 ) . into ( ) ) . unwrap_or ( BlockId :: ParentOfLatest ) ;
182
- let network_id = self . client . common_params ( parent_block_id) . unwrap ( ) . network_id ( ) ;
182
+ let network_id = self . client . network_id ( ) ;
183
183
Some ( PlatformAddress :: new_v1 ( network_id, address) )
184
184
} ) )
185
185
}
@@ -206,17 +206,15 @@ where
206
206
fn get_shard_owners ( & self , shard_id : ShardId , block_number : Option < u64 > ) -> Result < Option < Vec < PlatformAddress > > > {
207
207
let block_id = block_number. map ( BlockId :: Number ) . unwrap_or ( BlockId :: Latest ) ;
208
208
Ok ( self . client . shard_owners ( shard_id, block_id. into ( ) ) . map ( |owners| {
209
- let parent_block_id = block_number. map ( |n| ( n - 1 ) . into ( ) ) . unwrap_or ( BlockId :: ParentOfLatest ) ;
210
- let network_id = self . client . common_params ( parent_block_id) . unwrap ( ) . network_id ( ) ;
209
+ let network_id = self . client . network_id ( ) ;
211
210
owners. into_iter ( ) . map ( |owner| PlatformAddress :: new_v1 ( network_id, owner) ) . collect ( )
212
211
} ) )
213
212
}
214
213
215
214
fn get_shard_users ( & self , shard_id : ShardId , block_number : Option < u64 > ) -> Result < Option < Vec < PlatformAddress > > > {
216
215
let block_id = block_number. map ( BlockId :: Number ) . unwrap_or ( BlockId :: Latest ) ;
217
216
Ok ( self . client . shard_users ( shard_id, block_id. into ( ) ) . map ( |users| {
218
- let parent_block_id = block_number. map ( |n| ( n - 1 ) . into ( ) ) . unwrap_or ( BlockId :: ParentOfLatest ) ;
219
- let network_id = self . client . common_params ( parent_block_id) . unwrap ( ) . network_id ( ) ;
217
+ let network_id = self . client . network_id ( ) ;
220
218
users. into_iter ( ) . map ( |user| PlatformAddress :: new_v1 ( network_id, user) ) . collect ( )
221
219
} ) )
222
220
}
@@ -239,26 +237,14 @@ where
239
237
240
238
fn get_block_by_number ( & self , block_number : u64 ) -> Result < Option < Block > > {
241
239
let id = BlockId :: Number ( block_number) ;
242
- Ok ( self . client . block ( & id) . map ( |block| {
243
- let block_id_to_read_params = if block_number == 0 {
244
- 0 . into ( )
245
- } else {
246
- ( block_number - 1 ) . into ( )
247
- } ;
248
- Block :: from_core ( block. decode ( ) , self . client . common_params ( block_id_to_read_params) . unwrap ( ) . network_id ( ) )
249
- } ) )
240
+ Ok ( self . client . block ( & id) . map ( |block| Block :: from_core ( block. decode ( ) , self . client . network_id ( ) ) ) )
250
241
}
251
242
252
243
fn get_block_by_hash ( & self , block_hash : BlockHash ) -> Result < Option < Block > > {
253
244
let id = BlockId :: Hash ( block_hash) ;
254
245
Ok ( self . client . block ( & id) . map ( |block| {
255
246
let block = block. decode ( ) ;
256
- let block_id_to_read_params = if block. header . number ( ) == 0 {
257
- 0 . into ( )
258
- } else {
259
- ( * block. header . parent_hash ( ) ) . into ( )
260
- } ;
261
- Block :: from_core ( block, self . client . common_params ( block_id_to_read_params) . unwrap ( ) . network_id ( ) )
247
+ Block :: from_core ( block, self . client . network_id ( ) )
262
248
} ) )
263
249
}
264
250
@@ -301,7 +287,7 @@ where
301
287
}
302
288
303
289
fn get_network_id ( & self ) -> Result < NetworkId > {
304
- Ok ( self . client . common_params ( BlockId :: Latest ) . unwrap ( ) . network_id ( ) )
290
+ Ok ( self . client . network_id ( ) )
305
291
}
306
292
307
293
fn get_common_params ( & self , block_number : Option < u64 > ) -> Result < Option < Params > > {
0 commit comments