@@ -27,8 +27,8 @@ use primitives::device::Device;
2727use primitives:: name:: NameRecord ;
2828use primitives:: rewards:: { RedemptionRequest , RedemptionResult , RewardRedemptionOption } ;
2929use primitives:: {
30- AddressName , AssetId , AuthNonce , ChainAddress , FiatAssets , FiatQuoteRequest , FiatQuoteType , FiatQuoteUrl , FiatQuotes , InAppNotification , MigrateDeviceIdRequest , NFTData ,
31- PortfolioAssets , PortfolioAssetsRequest , PriceAlerts , ReportNft , RewardEvent , Rewards , ScanTransaction , ScanTransactionPayload , Transaction , TransactionsResponse ,
30+ AddressName , AssetId , AuthNonce , ChainAddress , FiatAssets , FiatQuote , FiatQuoteRequest , FiatQuoteType , FiatQuoteUrl , FiatQuotes , InAppNotification , MigrateDeviceIdRequest ,
31+ NFTData , PortfolioAssets , PortfolioAssetsRequest , PriceAlerts , ReportNft , RewardEvent , Rewards , ScanTransaction , ScanTransactionPayload , Transaction , TransactionsResponse ,
3232 WalletSubscriptionChains ,
3333} ;
3434use rocket:: { State , delete, get, post, put, serde:: json:: Json , tokio:: sync:: Mutex } ;
@@ -218,15 +218,16 @@ pub async fn send_push_notification_device_v2(device: AuthenticatedDevice, clien
218218
219219#[ post( "/devices/nft/report" , format = "json" , data = "<request>" ) ]
220220pub async fn report_device_nft_v2 ( device : AuthenticatedDevice , request : Json < ReportNft > , client : & State < Mutex < NFTClient > > ) -> Result < ApiResponse < bool > , ApiError > {
221+ let asset_id = request
222+ . asset_id
223+ . as_deref ( )
224+ . map ( |asset_id| AssetId :: new ( asset_id) . ok_or_else ( || ApiError :: BadRequest ( format ! ( "Invalid asset_id: {asset_id}" ) ) ) )
225+ . transpose ( ) ?;
226+
221227 Ok ( client
222228 . lock ( )
223229 . await
224- . report_nft (
225- & device. device_row . device_id ,
226- request. collection_id . clone ( ) ,
227- request. asset_id . clone ( ) ,
228- request. reason . clone ( ) ,
229- ) ?
230+ . report_nft ( & device. device_row . device_id , request. collection_id . clone ( ) , asset_id, request. reason . clone ( ) ) ?
230231 . into ( ) )
231232}
232233
@@ -328,29 +329,12 @@ pub async fn delete_device_price_alerts_v2(
328329 Ok ( client. lock ( ) . await . delete_price_alerts ( & device. device_row . device_id , price_alerts. 0 ) . await ?. into ( ) )
329330}
330331
331- #[ get( "/devices/fiat/orders/<provider>/<order_id>" ) ]
332- pub async fn get_device_fiat_order_v2 (
333- _device : AuthenticatedDevice ,
334- provider : & str ,
335- order_id : & str ,
336- client : & State < Mutex < FiatQuotesClient > > ,
337- ) -> Result < ApiResponse < primitives:: FiatTransactionInfo > , ApiError > {
338- Ok ( fiat:: fiat_transaction_info ( client. lock ( ) . await . get_order_status ( provider, order_id) . await ?) . into ( ) )
339- }
340-
341332#[ get( "/devices/fiat/transactions" ) ]
342333pub async fn get_device_fiat_transactions_v2 (
343334 device : AuthenticatedDeviceWallet ,
344335 client : & State < Mutex < FiatQuotesClient > > ,
345336) -> Result < ApiResponse < Vec < primitives:: FiatTransactionInfo > > , ApiError > {
346- Ok ( client
347- . lock ( )
348- . await
349- . get_transactions_by_wallet_id ( device. device_row . id , device. wallet_id ) ?
350- . into_iter ( )
351- . map ( fiat:: fiat_transaction_info)
352- . collect :: < Vec < _ > > ( )
353- . into ( ) )
337+ Ok ( client. lock ( ) . await . get_transactions_by_wallet_id ( device. device_row . id , device. wallet_id ) ?. into ( ) )
354338}
355339
356340#[ get( "/devices/fiat/assets/<quote_type>" ) ]
@@ -385,14 +369,19 @@ pub async fn get_fiat_quotes_v2(
385369 quote_type : quote_type. 0 ,
386370 amount,
387371 currency : currency. as_string ( ) ,
388- provider_id : provider. map ( |p| p. 0 . id ( ) ) ,
372+ provider_id : provider. map ( |p| p. 0 . id ( ) . to_string ( ) ) ,
389373 ip_address : ip_address. map ( str:: to_string) . unwrap_or ( fallback_ip_address) ,
390374 } ;
391375 let quotes = client. lock ( ) . await . get_quotes ( quote_request) . await ?;
392376 fiat_metrics. record_quotes ( & quotes) ;
393377 Ok ( quotes. into ( ) )
394378}
395379
380+ #[ get( "/devices/fiat/quotes/<quote_id>" , rank = 2 ) ]
381+ pub async fn get_fiat_quote_v2 ( _device : AuthenticatedDevice , quote_id : & str , client : & State < Mutex < FiatQuotesClient > > ) -> Result < ApiResponse < FiatQuote > , ApiError > {
382+ Ok ( client. lock ( ) . await . get_quote ( quote_id) . await ?. into ( ) )
383+ }
384+
396385#[ get( "/fiat/quotes/<quote_type>?<asset_id>&<amount>&<currency>&<provider_id>&<ip_address>" ) ]
397386pub async fn get_fiat_quotes_v1 (
398387 quote_type : FiatQuoteTypeParam ,
@@ -411,7 +400,7 @@ pub async fn get_fiat_quotes_v1(
411400 quote_type : quote_type. 0 ,
412401 amount,
413402 currency : currency. as_string ( ) ,
414- provider_id : provider_id. map ( |p| p. 0 . id ( ) ) ,
403+ provider_id : provider_id. map ( |p| p. 0 . id ( ) . to_string ( ) ) ,
415404 ip_address : ip_address. map ( str:: to_string) . unwrap_or ( fallback_ip_address) ,
416405 } ;
417406 let quotes = client. lock ( ) . await . get_quotes ( quote_request) . await ?;
0 commit comments