1
1
use crate :: client:: schema:: contract:: ContractBalanceQueryArgs ;
2
2
use anyhow:: Context ;
3
- use cynic:: { http:: SurfExt , Id , MutationBuilder , Operation , QueryBuilder } ;
3
+ use cynic:: {
4
+ http:: SurfExt ,
5
+ Id ,
6
+ MutationBuilder ,
7
+ Operation ,
8
+ QueryBuilder ,
9
+ } ;
4
10
use fuel_vm:: prelude:: * ;
5
11
use itertools:: Itertools ;
6
12
use schema:: {
7
13
balance:: BalanceArgs ,
8
14
block:: BlockByIdArgs ,
9
- coin:: { Coin , CoinByIdArgs , SpendQueryElementInput } ,
10
- contract:: { Contract , ContractByIdArgs } ,
11
- tx:: { TxArg , TxIdArgs } ,
12
- Bytes , ContinueTx , ContinueTxArgs , ConversionError , HexString , IdArg , MemoryArgs , RegisterArgs ,
13
- RunResult , SetBreakpoint , SetBreakpointArgs , SetSingleStepping , SetSingleSteppingArgs , StartTx ,
14
- StartTxArgs , TransactionId , U64 ,
15
+ coin:: {
16
+ Coin ,
17
+ CoinByIdArgs ,
18
+ SpendQueryElementInput ,
19
+ } ,
20
+ contract:: {
21
+ Contract ,
22
+ ContractByIdArgs ,
23
+ } ,
24
+ tx:: {
25
+ TxArg ,
26
+ TxIdArgs ,
27
+ } ,
28
+ Bytes ,
29
+ ContinueTx ,
30
+ ContinueTxArgs ,
31
+ ConversionError ,
32
+ HexString ,
33
+ IdArg ,
34
+ MemoryArgs ,
35
+ RegisterArgs ,
36
+ RunResult ,
37
+ SetBreakpoint ,
38
+ SetBreakpointArgs ,
39
+ SetSingleStepping ,
40
+ SetSingleSteppingArgs ,
41
+ StartTx ,
42
+ StartTxArgs ,
43
+ TransactionId ,
44
+ U64 ,
15
45
} ;
16
46
use std:: {
17
47
convert:: TryInto ,
18
- io:: { self , ErrorKind } ,
48
+ io:: {
49
+ self ,
50
+ ErrorKind ,
51
+ } ,
19
52
net,
20
- str:: { self , FromStr } ,
53
+ str:: {
54
+ self ,
55
+ FromStr ,
56
+ } ,
57
+ } ;
58
+ use types:: {
59
+ TransactionResponse ,
60
+ TransactionStatus ,
21
61
} ;
22
- use types:: { TransactionResponse , TransactionStatus } ;
23
62
24
63
use crate :: client:: schema:: tx:: DryRunArg ;
25
- pub use schema:: { PageDirection , PaginatedResult , PaginationRequest } ;
64
+ pub use schema:: {
65
+ PageDirection ,
66
+ PaginatedResult ,
67
+ PaginationRequest ,
68
+ } ;
26
69
27
70
use self :: schema:: block:: ProduceBlockArgs ;
28
71
@@ -175,7 +218,12 @@ impl FuelClient {
175
218
Ok ( self . query ( query) . await ?. register . 0 as Word )
176
219
}
177
220
178
- pub async fn memory ( & self , id : & str , start : usize , size : usize ) -> io:: Result < Vec < u8 > > {
221
+ pub async fn memory (
222
+ & self ,
223
+ id : & str ,
224
+ start : usize ,
225
+ size : usize ,
226
+ ) -> io:: Result < Vec < u8 > > {
179
227
let query = schema:: Memory :: build ( & MemoryArgs {
180
228
id : id. into ( ) ,
181
229
start : start. into ( ) ,
@@ -209,7 +257,11 @@ impl FuelClient {
209
257
Ok ( ( ) )
210
258
}
211
259
212
- pub async fn set_single_stepping ( & self , session_id : & str , enable : bool ) -> io:: Result < ( ) > {
260
+ pub async fn set_single_stepping (
261
+ & self ,
262
+ session_id : & str ,
263
+ enable : bool ,
264
+ ) -> io:: Result < ( ) > {
213
265
let operation = SetSingleStepping :: build ( SetSingleSteppingArgs {
214
266
id : Id :: new ( session_id) ,
215
267
enable,
@@ -218,7 +270,11 @@ impl FuelClient {
218
270
Ok ( ( ) )
219
271
}
220
272
221
- pub async fn start_tx ( & self , session_id : & str , tx : & Transaction ) -> io:: Result < RunResult > {
273
+ pub async fn start_tx (
274
+ & self ,
275
+ session_id : & str ,
276
+ tx : & Transaction ,
277
+ ) -> io:: Result < RunResult > {
222
278
let operation = StartTx :: build ( StartTxArgs {
223
279
id : Id :: new ( session_id) ,
224
280
tx : serde_json:: to_string ( tx) . expect ( "Couldn't serialize tx to json" ) ,
@@ -314,7 +370,8 @@ impl FuelClient {
314
370
}
315
371
316
372
pub async fn block ( & self , id : & str ) -> io:: Result < Option < schema:: block:: Block > > {
317
- let query = schema:: block:: BlockByIdQuery :: build ( & BlockByIdArgs { id : id. parse ( ) ? } ) ;
373
+ let query =
374
+ schema:: block:: BlockByIdQuery :: build ( & BlockByIdArgs { id : id. parse ( ) ? } ) ;
318
375
319
376
let block = self . query ( query) . await ?. block ;
320
377
@@ -389,22 +446,28 @@ impl FuelClient {
389
446
}
390
447
391
448
pub async fn contract ( & self , id : & str ) -> io:: Result < Option < Contract > > {
392
- let query =
393
- schema:: contract:: ContractByIdQuery :: build ( ContractByIdArgs { id : id. parse ( ) ? } ) ;
449
+ let query = schema:: contract:: ContractByIdQuery :: build ( ContractByIdArgs {
450
+ id : id. parse ( ) ?,
451
+ } ) ;
394
452
let contract = self . query ( query) . await ?. contract ;
395
453
Ok ( contract)
396
454
}
397
455
398
- pub async fn contract_balance ( & self , id : & str , asset : Option < & str > ) -> io:: Result < u64 > {
456
+ pub async fn contract_balance (
457
+ & self ,
458
+ id : & str ,
459
+ asset : Option < & str > ,
460
+ ) -> io:: Result < u64 > {
399
461
let asset_id: schema:: AssetId = match asset {
400
462
Some ( asset) => asset. parse ( ) ?,
401
463
None => schema:: AssetId :: default ( ) ,
402
464
} ;
403
465
404
- let query = schema:: contract:: ContractBalanceQuery :: build ( ContractBalanceQueryArgs {
405
- id : id. parse ( ) ?,
406
- asset : asset_id,
407
- } ) ;
466
+ let query =
467
+ schema:: contract:: ContractBalanceQuery :: build ( ContractBalanceQueryArgs {
468
+ id : id. parse ( ) ?,
469
+ asset : asset_id,
470
+ } ) ;
408
471
409
472
let balance = self . query ( query) . await . unwrap ( ) . contract_balance . amount ;
410
473
Ok ( balance. into ( ) )
@@ -440,7 +503,9 @@ impl FuelClient {
440
503
request : PaginationRequest < String > ,
441
504
) -> io:: Result < PaginatedResult < schema:: contract:: ContractBalance , String > > {
442
505
let contract_id: schema:: ContractId = contract. parse ( ) ?;
443
- let query = schema:: contract:: ContractBalancesQuery :: build ( & ( contract_id, request) . into ( ) ) ;
506
+ let query = schema:: contract:: ContractBalancesQuery :: build (
507
+ & ( contract_id, request) . into ( ) ,
508
+ ) ;
444
509
445
510
let balances = self . query ( query) . await ?. contract_balances . into ( ) ;
446
511
@@ -452,7 +517,8 @@ impl FuelClient {
452
517
owner : Option < & str > ,
453
518
request : PaginationRequest < String > ,
454
519
) -> io:: Result < PaginatedResult < schema:: message:: Message , String > > {
455
- let owner: Option < schema:: Address > = owner. map ( |owner| owner. parse ( ) ) . transpose ( ) ?;
520
+ let owner: Option < schema:: Address > =
521
+ owner. map ( |owner| owner. parse ( ) ) . transpose ( ) ?;
456
522
let query = schema:: message:: OwnedMessageQuery :: build ( & ( owner, request) . into ( ) ) ;
457
523
458
524
let messages = self . query ( query) . await ?. messages . into ( ) ;
0 commit comments