@@ -18,6 +18,7 @@ use crate::types::{
18
18
} ;
19
19
use crate :: { OnlineServerContext , SuiEnv } ;
20
20
use std:: time:: Duration ;
21
+ use sui_sdk:: error:: SuiRpcResult ;
21
22
use sui_types:: messages_checkpoint:: CheckpointSequenceNumber ;
22
23
23
24
/// Get an array of all AccountBalances for an AccountIdentifier and the BlockIdentifier
@@ -34,10 +35,10 @@ pub async fn balance(
34
35
let mut retry_attempts = 5 ;
35
36
while retry_attempts > 0 {
36
37
let balances_first = get_balances ( & ctx, & request, address, currencies. clone ( ) ) . await ?;
37
- let checkpoint1 = get_checkpoint ( & ctx) . await ;
38
- let mut checkpoint2 = get_checkpoint ( & ctx) . await ;
38
+ let checkpoint1 = get_checkpoint ( & ctx) . await . unwrap ( ) ;
39
+ let mut checkpoint2 = get_checkpoint ( & ctx) . await . unwrap ( ) ;
39
40
while checkpoint2 <= checkpoint1 {
40
- checkpoint2 = get_checkpoint ( & ctx) . await ;
41
+ checkpoint2 = get_checkpoint ( & ctx) . await . unwrap ( ) ;
41
42
tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
42
43
}
43
44
let balances_second = get_balances ( & ctx, & request, address, currencies. clone ( ) ) . await ?;
@@ -61,12 +62,11 @@ pub async fn balance(
61
62
Err ( Error :: RetryExhausted ( String :: from ( "retry" ) ) )
62
63
}
63
64
64
- async fn get_checkpoint ( ctx : & OnlineServerContext ) -> CheckpointSequenceNumber {
65
+ async fn get_checkpoint ( ctx : & OnlineServerContext ) -> SuiRpcResult < CheckpointSequenceNumber > {
65
66
ctx. client
66
67
. read_api ( )
67
68
. get_latest_checkpoint_sequence_number ( )
68
69
. await
69
- . unwrap ( )
70
70
}
71
71
72
72
async fn get_balances (
0 commit comments