@@ -57,8 +57,8 @@ pub struct TopupInfo {
57
57
pub exchange_fee_minor_units : u64 ,
58
58
pub exchange_rate : ExchangeRate ,
59
59
60
- pub expires_at : SystemTime ,
61
- pub lnurlw : String ,
60
+ pub expires_at : Option < SystemTime > ,
61
+ pub lnurlw : Option < String > ,
62
62
pub error : Option < TopupError > ,
63
63
}
64
64
@@ -148,7 +148,10 @@ fn to_topup_info(topup: ListUncompletedTopupsTopup) -> graphql::Result<TopupInfo
148
148
let exchange_fee_rate_permyriad = ( topup. exchange_fee_rate * 10_000_f64 ) . round ( ) as u16 ;
149
149
let exchange_fee_minor_units = ( topup. exchange_fee_user_currency * 100_f64 ) . round ( ) as u64 ;
150
150
let expires_at = topup. expires_at ;
151
- let expires_at = parse_from_rfc3339 ( & expires_at) ?;
151
+ let expires_at = match expires_at {
152
+ Some ( e) => Some ( parse_from_rfc3339 ( & e) ?) ,
153
+ None => None ,
154
+ } ;
152
155
let lnurlw = topup. lnurl ;
153
156
154
157
let status = match topup. status {
@@ -258,10 +261,10 @@ mod tests {
258
261
exchange_fee_rate : 0.014999999664723873 ,
259
262
exchange_fee_user_currency : 0.11999999731779099 ,
260
263
exchange_rate : 18507.0 ,
261
- expires_at : "2023-09-21T16:39:21.919+00:00" . to_string ( ) ,
264
+ expires_at : Some ( "2023-09-21T16:39:21.919+00:00" . to_string ( ) ) ,
262
265
id : "1707e09e-ebe1-4004-abd7-7a64604501b3" . to_string ( ) ,
263
266
lightning_fee_user_currency : 0.0 ,
264
- lnurl : LNURL . to_string ( ) ,
267
+ lnurl : Some ( LNURL . to_string ( ) ) ,
265
268
node_pub_key : "0233786a3f5c79d25508ed973e7a37506ddab49d41a07fcb3d341ab638000d69cf"
266
269
. to_string ( ) ,
267
270
status : topup_status_enum:: READY ,
@@ -286,11 +289,12 @@ mod tests {
286
289
287
290
let expires_at = topup_info
288
291
. expires_at
292
+ . unwrap ( )
289
293
. duration_since ( SystemTime :: UNIX_EPOCH )
290
294
. unwrap ( )
291
295
. as_secs ( ) ;
292
296
assert_eq ! ( expires_at, 1695314361 ) ;
293
- assert_eq ! ( topup_info. lnurlw, LNURL ) ;
297
+ assert_eq ! ( topup_info. lnurlw. unwrap ( ) , LNURL ) ;
294
298
295
299
assert_eq ! ( topup_info. status, TopupStatus :: READY ) ;
296
300
@@ -302,10 +306,10 @@ mod tests {
302
306
exchange_fee_rate : 0.014999999664723873 ,
303
307
exchange_fee_user_currency : 0.11999999731779099 ,
304
308
exchange_rate : 18507.0 ,
305
- expires_at : "2023-09-21T16:39:21.919+00:00" . to_string ( ) ,
309
+ expires_at : None ,
306
310
id : "1707e09e-ebe1-4004-abd7-7a64604501b3" . to_string ( ) ,
307
311
lightning_fee_user_currency : 0.0 ,
308
- lnurl : LNURL . to_string ( ) ,
312
+ lnurl : None ,
309
313
node_pub_key : "0233786a3f5c79d25508ed973e7a37506ddab49d41a07fcb3d341ab638000d69cf"
310
314
. to_string ( ) ,
311
315
status : topup_status_enum:: FAILED ,
@@ -320,6 +324,8 @@ mod tests {
320
324
code: TemporaryFailureCode :: NoRoute
321
325
} )
322
326
) ) ;
327
+ assert ! ( topup_info. expires_at. is_none( ) ) ;
328
+ assert ! ( topup_info. lnurlw. is_none( ) ) ;
323
329
324
330
let topup = ListUncompletedTopupsTopup {
325
331
additional_info : Some ( "customer_requested" . to_string ( ) ) ,
@@ -329,10 +335,10 @@ mod tests {
329
335
exchange_fee_rate : 0.014999999664723873 ,
330
336
exchange_fee_user_currency : 0.11999999731779099 ,
331
337
exchange_rate : 18507.0 ,
332
- expires_at : "2023-09-21T16:39:21.919+00:00" . to_string ( ) ,
338
+ expires_at : Some ( "2023-09-21T16:39:21.919+00:00" . to_string ( ) ) ,
333
339
id : "1707e09e-ebe1-4004-abd7-7a64604501b3" . to_string ( ) ,
334
340
lightning_fee_user_currency : 0.0 ,
335
- lnurl : LNURL . to_string ( ) ,
341
+ lnurl : None ,
336
342
node_pub_key : "0233786a3f5c79d25508ed973e7a37506ddab49d41a07fcb3d341ab638000d69cf"
337
343
. to_string ( ) ,
338
344
status : topup_status_enum:: REFUNDED ,
@@ -347,5 +353,7 @@ mod tests {
347
353
code: PermanentFailureCode :: CustomerRequested
348
354
} )
349
355
) ) ;
356
+ assert ! ( topup_info. expires_at. is_some( ) ) ;
357
+ assert ! ( topup_info. lnurlw. is_none( ) ) ;
350
358
}
351
359
}
0 commit comments