@@ -70,31 +70,34 @@ pub async fn create_campaign<A: Adapter>(
70
70
let error_response =
71
71
ResponseError :: BadRequest ( "err occurred; please try again later" . to_string ( ) ) ;
72
72
73
- let total_remaining =
74
- {
75
- let accounting_spent = get_accounting (
76
- app. pool . clone ( ) ,
77
- campaign. channel . id ( ) ,
78
- campaign. creator ,
79
- Side :: Spender ,
80
- )
81
- . await ?
82
- . map ( |accounting| accounting. amount )
83
- . unwrap_or_default ( ) ;
73
+ let total_remaining = {
74
+ let accounting_spent = get_accounting (
75
+ app. pool . clone ( ) ,
76
+ campaign. channel . id ( ) ,
77
+ campaign. creator ,
78
+ Side :: Spender ,
79
+ )
80
+ . await ?
81
+ . map ( |accounting| accounting. amount )
82
+ . unwrap_or_default ( ) ;
84
83
85
- let latest_spendable =
86
- fetch_spendable ( app. pool . clone ( ) , & campaign. creator , & campaign. channel . id ( ) )
87
- . await ?
88
- . ok_or_else ( || ResponseError :: BadRequest (
84
+ let latest_spendable =
85
+ fetch_spendable ( app. pool . clone ( ) , & campaign. creator , & campaign. channel . id ( ) )
86
+ . await ?
87
+ . ok_or_else ( || {
88
+ ResponseError :: BadRequest (
89
89
"No spendable amount found for the Campaign creator" . to_string ( ) ,
90
- ) ) ?;
91
- // Gets the latest Spendable for this (spender, channelId) pair
92
- let total_deposited = latest_spendable. deposit . total ;
93
-
94
- total_deposited. checked_sub ( & accounting_spent) . ok_or_else ( ||
95
- ResponseError :: FailedValidation ( "No more budget remaining" . to_string ( ) ) ,
96
- ) ?
97
- } ;
90
+ )
91
+ } ) ?;
92
+ // Gets the latest Spendable for this (spender, channelId) pair
93
+ let total_deposited = latest_spendable. deposit . total ;
94
+
95
+ total_deposited
96
+ . checked_sub ( & accounting_spent)
97
+ . ok_or_else ( || {
98
+ ResponseError :: FailedValidation ( "No more budget remaining" . to_string ( ) )
99
+ } ) ?
100
+ } ;
98
101
99
102
let channel_campaigns = get_campaigns_by_channel ( & app. pool , & campaign. channel . id ( ) )
100
103
. await ?
@@ -315,9 +318,7 @@ pub mod update_campaign {
315
318
. get_remaining_opt ( campaign. id )
316
319
. await ?
317
320
. map ( |remaining| UnifiedNum :: from ( max ( 0 , remaining) . unsigned_abs ( ) ) )
318
- . ok_or_else ( || Error :: FailedUpdate (
319
- "No remaining entry for campaign" . to_string ( ) ,
320
- ) ) ?;
321
+ . ok_or_else ( || Error :: FailedUpdate ( "No remaining entry for campaign" . to_string ( ) ) ) ?;
321
322
322
323
let campaign_spent = campaign
323
324
. budget
0 commit comments