File tree Expand file tree Collapse file tree 2 files changed +17
-18
lines changed Expand file tree Collapse file tree 2 files changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,15 @@ export class StateGetBalanceResult {
101
101
balanceValue : CLValueUInt512 ;
102
102
103
103
public rawJSON : any ;
104
+
105
+ public toQueryBalanceResult ( ) {
106
+ const queryBalanceResult = new QueryBalanceResult ( ) ;
107
+
108
+ queryBalanceResult . apiVersion = this . apiVersion ;
109
+ queryBalanceResult . balance = this . balanceValue ;
110
+
111
+ return queryBalanceResult ;
112
+ }
104
113
}
105
114
106
115
@jsonObject
@@ -279,7 +288,7 @@ export class InfoGetDeployResult {
279
288
this . executionInfo . executionResult
280
289
) ;
281
290
} else if ( this ?. executionResultsV1 ?. length ) {
282
- executionInfo = ExecutionInfo . fromV1 ( this . executionResultsV1 )
291
+ executionInfo = ExecutionInfo . fromV1 ( this . executionResultsV1 ) ;
283
292
}
284
293
285
294
return new InfoGetTransactionResult (
Original file line number Diff line number Diff line change 5
5
PurseIdentifier ,
6
6
PutDeployResult ,
7
7
PutTransactionResult ,
8
- QueryBalanceResult ,
9
8
RpcClient
10
9
} from '../rpc' ;
11
10
import {
@@ -354,26 +353,17 @@ export class CasperNetwork {
354
353
return getDeployResult . toInfoGetTransactionResult ( ) ;
355
354
}
356
355
357
- public async queryLatestBalance (
358
- identifier : PurseIdentifier
359
- ) : Promise < QueryBalanceResult > {
356
+ public async queryLatestBalance ( identifier : PurseIdentifier ) {
360
357
if ( this . apiVersion === 2 ) {
361
358
return this . rpcClient . queryLatestBalance ( identifier ) ;
362
359
}
363
360
364
- const balanceResult = new QueryBalanceResult ( ) ;
361
+ const purseUref = identifier ?. purseUref ;
362
+ if ( ! purseUref ) return ;
365
363
366
- if ( identifier ?. purseUref ) {
367
- const stateBalanceResult = await this . rpcClient . getLatestBalance (
368
- identifier . purseUref . toPrefixedString ( )
369
- ) ;
370
-
371
- if ( stateBalanceResult ) {
372
- balanceResult . balance = stateBalanceResult . balanceValue ;
373
- balanceResult . apiVersion = stateBalanceResult . apiVersion ;
374
- }
375
- }
376
-
377
- return balanceResult ;
364
+ const balance = await this . rpcClient . getLatestBalance (
365
+ purseUref . toPrefixedString ( )
366
+ ) ;
367
+ return balance ?. toQueryBalanceResult ( ) ;
378
368
}
379
369
}
You can’t perform that action at this time.
0 commit comments