@@ -310,26 +310,20 @@ impl crate::ReaderDbManager for crate::PostgresDBManager {
310
310
let data_range_id = shard_id_pool. data_range_id ;
311
311
let sql_query = format ! (
312
312
"
313
- SELECT block_height, block_hash, data_value
313
+ SELECT data_value, block_height
314
314
FROM state_changes_account_{data_range_id}
315
315
WHERE account_id = $1
316
316
AND block_height <= $2
317
317
ORDER BY block_height DESC
318
318
LIMIT 1;
319
319
"
320
320
) ;
321
- let ( block_height, block_hash, data_value) : ( bigdecimal:: BigDecimal , String , Vec < u8 > ) =
322
- sqlx:: query_as ( & sql_query)
323
- . bind ( account_id. to_string ( ) )
324
- . bind ( bigdecimal:: BigDecimal :: from ( request_block_height) )
325
- . fetch_one ( shard_id_pool. pool )
326
- . await ?;
327
- let block = readnode_primitives:: BlockRecord :: try_from ( ( block_hash, block_height) ) ?;
328
- readnode_primitives:: QueryData :: < near_primitives:: account:: Account > :: try_from ( (
329
- data_value,
330
- block. height ,
331
- block. hash ,
332
- ) )
321
+ let result: ( Vec < u8 > , bigdecimal:: BigDecimal ) = sqlx:: query_as ( & sql_query)
322
+ . bind ( account_id. to_string ( ) )
323
+ . bind ( bigdecimal:: BigDecimal :: from ( request_block_height) )
324
+ . fetch_one ( shard_id_pool. pool )
325
+ . await ?;
326
+ readnode_primitives:: QueryData :: < near_primitives:: account:: Account > :: try_from ( result)
333
327
}
334
328
335
329
async fn get_contract_code (
@@ -351,26 +345,20 @@ impl crate::ReaderDbManager for crate::PostgresDBManager {
351
345
let data_range_id = shard_id_pool. data_range_id ;
352
346
let sql_query = format ! (
353
347
"
354
- SELECT block_height, block_hash, data_value
348
+ SELECT data_value, block_height
355
349
FROM state_changes_contract_{data_range_id}
356
350
WHERE account_id = $1
357
351
AND block_height <= $2
358
352
ORDER BY block_height DESC
359
353
LIMIT 1;
360
354
"
361
355
) ;
362
- let ( block_height, block_hash, contract_code) : ( bigdecimal:: BigDecimal , String , Vec < u8 > ) =
363
- sqlx:: query_as ( & sql_query)
364
- . bind ( account_id. to_string ( ) )
365
- . bind ( bigdecimal:: BigDecimal :: from ( request_block_height) )
366
- . fetch_one ( shard_id_pool. pool )
367
- . await ?;
368
- let block = readnode_primitives:: BlockRecord :: try_from ( ( block_hash, block_height) ) ?;
369
- Ok ( readnode_primitives:: QueryData {
370
- data : contract_code,
371
- block_height : block. height ,
372
- block_hash : block. hash ,
373
- } )
356
+ let result: ( Vec < u8 > , bigdecimal:: BigDecimal ) = sqlx:: query_as ( & sql_query)
357
+ . bind ( account_id. to_string ( ) )
358
+ . bind ( bigdecimal:: BigDecimal :: from ( request_block_height) )
359
+ . fetch_one ( shard_id_pool. pool )
360
+ . await ?;
361
+ readnode_primitives:: QueryData :: < Vec < u8 > > :: try_from ( result)
374
362
}
375
363
376
364
async fn get_access_key (
@@ -394,7 +382,7 @@ impl crate::ReaderDbManager for crate::PostgresDBManager {
394
382
let data_range_id = shard_id_pool. data_range_id ;
395
383
let sql_query = format ! (
396
384
"
397
- SELECT block_height, block_hash, data_value
385
+ SELECT data_value, block_height
398
386
FROM state_changes_access_key_{data_range_id}
399
387
WHERE account_id = $1
400
388
AND data_key = $2
@@ -403,19 +391,13 @@ impl crate::ReaderDbManager for crate::PostgresDBManager {
403
391
LIMIT 1;
404
392
"
405
393
) ;
406
- let ( block_height, block_hash, data_value) : ( bigdecimal:: BigDecimal , String , Vec < u8 > ) =
407
- sqlx:: query_as ( & sql_query)
408
- . bind ( account_id. to_string ( ) )
409
- . bind ( hex:: encode ( & key_data) . to_string ( ) )
410
- . bind ( bigdecimal:: BigDecimal :: from ( request_block_height) )
411
- . fetch_one ( shard_id_pool. pool )
412
- . await ?;
413
- let block = readnode_primitives:: BlockRecord :: try_from ( ( block_hash, block_height) ) ?;
414
- readnode_primitives:: QueryData :: < near_primitives:: account:: AccessKey > :: try_from ( (
415
- data_value,
416
- block. height ,
417
- block. hash ,
418
- ) )
394
+ let result: ( Vec < u8 > , bigdecimal:: BigDecimal ) = sqlx:: query_as ( & sql_query)
395
+ . bind ( account_id. to_string ( ) )
396
+ . bind ( hex:: encode ( & key_data) . to_string ( ) )
397
+ . bind ( bigdecimal:: BigDecimal :: from ( request_block_height) )
398
+ . fetch_one ( shard_id_pool. pool )
399
+ . await ?;
400
+ readnode_primitives:: QueryData :: < near_primitives:: account:: AccessKey > :: try_from ( result)
419
401
}
420
402
421
403
async fn get_account_access_keys (
0 commit comments