@@ -31,7 +31,7 @@ use primitives::{
31
31
} ,
32
32
spender:: { Spendable , Spender } ,
33
33
validator:: NewState ,
34
- Address , ChainOf , Channel , Deposit , UnifiedNum ,
34
+ Address , ChainOf , Channel , ChannelId , Deposit , UnifiedNum ,
35
35
} ;
36
36
use serde:: { Deserialize , Serialize } ;
37
37
use slog:: { error, Logger } ;
@@ -269,16 +269,13 @@ pub async fn get_spender_limits<C: Locked + 'static>(
269
269
}
270
270
271
271
pub async fn get_spender_limits_axum < C : Locked + ' static > (
272
- Path ( params) : Path < HashMap < String , String > > ,
272
+ Path ( params) : Path < ( ChannelId , Address ) > ,
273
273
Extension ( app) : Extension < Arc < Application < C > > > ,
274
274
Extension ( channel_context) : Extension < ChainOf < Channel > > ,
275
275
) -> Result < Json < SpenderResponse > , ResponseError > {
276
276
let channel = & channel_context. context ;
277
277
278
- let spender = params
279
- . get ( "addr" )
280
- . ok_or_else ( || ResponseError :: BadRequest ( "Invalid spender address" . to_string ( ) ) ) ?;
281
- let spender = Address :: from_str ( spender) ?;
278
+ let spender = params. 1 ;
282
279
283
280
let latest_spendable = fetch_spendable ( app. pool . clone ( ) , & spender, & channel. id ( ) ) . await ?;
284
281
@@ -313,14 +310,12 @@ pub async fn get_spender_limits_axum<C: Locked + 'static>(
313
310
. get ( & spender)
314
311
. map ( |spent| spent. to_owned ( ) ) ;
315
312
316
- // returned output
317
- let res = SpenderResponse {
313
+ Ok ( Json ( SpenderResponse {
318
314
spender : Spender {
319
315
total_deposited : latest_spendable. deposit . total ,
320
316
total_spent,
321
317
} ,
322
- } ;
323
- Ok ( Json ( res) )
318
+ } ) )
324
319
}
325
320
326
321
/// GET `/v5/channel/0xXXX.../spender/all` request.
@@ -422,12 +417,10 @@ pub async fn get_all_spender_limits_axum<C: Locked + 'static>(
422
417
all_spender_limits. insert ( spender, spender_info) ;
423
418
}
424
419
425
- let res = AllSpendersResponse {
420
+ Ok ( Json ( AllSpendersResponse {
426
421
spenders : all_spender_limits,
427
422
pagination,
428
- } ;
429
-
430
- Ok ( Json ( res) )
423
+ } ) )
431
424
}
432
425
433
426
/// POST `/v5/channel/0xXXX.../spender/0xXXX...` request
@@ -495,12 +488,9 @@ pub async fn add_spender_leaf<C: Locked + 'static>(
495
488
pub async fn add_spender_leaf_axum < C : Locked + ' static > (
496
489
Extension ( app) : Extension < Arc < Application < C > > > ,
497
490
Extension ( channel) : Extension < ChainOf < Channel > > ,
498
- Path ( params) : Path < HashMap < String , String > > ,
491
+ Path ( params) : Path < ( ChannelId , Address ) > ,
499
492
) -> Result < Json < SpenderResponse > , ResponseError > {
500
- let spender = params
501
- . get ( "addr" )
502
- . ok_or_else ( || ResponseError :: BadRequest ( "Invalid spender address" . to_string ( ) ) ) ?;
503
- let spender = Address :: from_str ( spender) ?;
493
+ let spender = params. 1 ;
504
494
505
495
update_accounting (
506
496
app. pool . clone ( ) ,
@@ -541,13 +531,12 @@ pub async fn add_spender_leaf_axum<C: Locked + 'static>(
541
531
. get ( & spender)
542
532
. map ( |spent| spent. to_owned ( ) ) ;
543
533
544
- let res = SpenderResponse {
534
+ Ok ( Json ( SpenderResponse {
545
535
spender : Spender {
546
536
total_deposited : latest_spendable. deposit . total ,
547
537
total_spent,
548
538
} ,
549
- } ;
550
- Ok ( Json ( res) )
539
+ } ) )
551
540
}
552
541
553
542
async fn get_corresponding_new_state (
0 commit comments