@@ -50,28 +50,26 @@ pub async fn handle_single_account_blockfrost(
5050 |message| match message {
5151 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
5252 AccountsStateQueryResponse :: AccountInfo ( account) ,
53- ) ) => Ok ( account) ,
53+ ) ) => Ok ( Some ( account) ) ,
5454 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
5555 AccountsStateQueryResponse :: NotFound ,
56- ) ) => {
57- return Err ( anyhow:: anyhow!( "Account not found" ) ) ;
58- }
56+ ) ) => Ok ( None ) ,
5957 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
6058 AccountsStateQueryResponse :: Error ( e) ,
61- ) ) => {
62- return Err ( anyhow:: anyhow!(
63- "Internal server error while retrieving account info: {e}"
64- ) ) ;
65- }
66- _ => {
67- return Err ( anyhow:: anyhow!(
68- "Unexpected message type while retrieving account info"
69- ) )
70- }
59+ ) ) => Err ( anyhow:: anyhow!(
60+ "Internal server error while retrieving account info: {e}"
61+ ) ) ,
62+ _ => Err ( anyhow:: anyhow!(
63+ "Unexpected message type while retrieving account info"
64+ ) ) ,
7165 } ,
7266 )
7367 . await ?;
7468
69+ let Some ( account) = account else {
70+ return Ok ( RESTResponse :: with_text ( 404 , "Account not found" ) ) ;
71+ } ;
72+
7573 let delegated_spo = match & account. delegated_spo {
7674 Some ( spo) => match spo. to_bech32_with_hrp ( "pool" ) {
7775 Ok ( val) => Some ( val) ,
@@ -140,28 +138,26 @@ pub async fn handle_account_registrations_blockfrost(
140138 |message| match message {
141139 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
142140 AccountsStateQueryResponse :: AccountRegistrationHistory ( registrations) ,
143- ) ) => Ok ( registrations) ,
141+ ) ) => Ok ( Some ( registrations) ) ,
144142 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
145143 AccountsStateQueryResponse :: NotFound ,
146- ) ) => {
147- return Err ( anyhow:: anyhow!( "Account not found" ) ) ;
148- }
144+ ) ) => Ok ( None ) ,
149145 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
150146 AccountsStateQueryResponse :: Error ( e) ,
151- ) ) => {
152- return Err ( anyhow:: anyhow!(
153- "Internal server error while retrieving account info: {e}"
154- ) ) ;
155- }
156- _ => {
157- return Err ( anyhow:: anyhow!(
158- "Unexpected message type while retrieving account info"
159- ) )
160- }
147+ ) ) => Err ( anyhow:: anyhow!(
148+ "Internal server error while retrieving account info: {e}"
149+ ) ) ,
150+ _ => Err ( anyhow:: anyhow!(
151+ "Unexpected message type while retrieving account info"
152+ ) ) ,
161153 } ,
162154 )
163155 . await ?;
164156
157+ let Some ( registrations) = registrations else {
158+ return Ok ( RESTResponse :: with_text ( 404 , "Account not found" ) ) ;
159+ } ;
160+
165161 // Get TxHashes from TxIdentifiers
166162 let tx_ids: Vec < _ > = registrations. iter ( ) . map ( |r| r. tx_identifier . clone ( ) ) . collect ( ) ;
167163 let msg = Arc :: new ( Message :: StateQuery ( StateQuery :: Blocks (
@@ -238,28 +234,26 @@ pub async fn handle_account_delegations_blockfrost(
238234 |message| match message {
239235 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
240236 AccountsStateQueryResponse :: AccountDelegationHistory ( delegations) ,
241- ) ) => Ok ( delegations) ,
237+ ) ) => Ok ( Some ( delegations) ) ,
242238 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
243239 AccountsStateQueryResponse :: NotFound ,
244- ) ) => {
245- return Err ( anyhow:: anyhow!( "Account not found" ) ) ;
246- }
240+ ) ) => Ok ( None ) ,
247241 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
248242 AccountsStateQueryResponse :: Error ( e) ,
249- ) ) => {
250- return Err ( anyhow:: anyhow!(
251- "Internal server error while retrieving account info: {e}"
252- ) ) ;
253- }
254- _ => {
255- return Err ( anyhow:: anyhow!(
256- "Unexpected message type while retrieving account info"
257- ) )
258- }
243+ ) ) => Err ( anyhow:: anyhow!(
244+ "Internal server error while retrieving account info: {e}"
245+ ) ) ,
246+ _ => Err ( anyhow:: anyhow!(
247+ "Unexpected message type while retrieving account info"
248+ ) ) ,
259249 } ,
260250 )
261251 . await ?;
262252
253+ let Some ( delegations) = delegations else {
254+ return Ok ( RESTResponse :: with_text ( 404 , "Account not found" ) ) ;
255+ } ;
256+
263257 // Get TxHashes from TxIdentifiers
264258 let tx_ids: Vec < _ > = delegations. iter ( ) . map ( |r| r. tx_identifier . clone ( ) ) . collect ( ) ;
265259 let msg = Arc :: new ( Message :: StateQuery ( StateQuery :: Blocks (
@@ -346,28 +340,26 @@ pub async fn handle_account_mirs_blockfrost(
346340 |message| match message {
347341 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
348342 AccountsStateQueryResponse :: AccountMIRHistory ( mirs) ,
349- ) ) => Ok ( mirs) ,
343+ ) ) => Ok ( Some ( mirs) ) ,
350344 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
351345 AccountsStateQueryResponse :: NotFound ,
352- ) ) => {
353- return Err ( anyhow:: anyhow!( "Account not found" ) ) ;
354- }
346+ ) ) => Ok ( None ) ,
355347 Message :: StateQueryResponse ( StateQueryResponse :: Accounts (
356348 AccountsStateQueryResponse :: Error ( e) ,
357- ) ) => {
358- return Err ( anyhow:: anyhow!(
359- "Internal server error while retrieving account info: {e}"
360- ) ) ;
361- }
362- _ => {
363- return Err ( anyhow:: anyhow!(
364- "Unexpected message type while retrieving account info"
365- ) )
366- }
349+ ) ) => Err ( anyhow:: anyhow!(
350+ "Internal server error while retrieving account info: {e}"
351+ ) ) ,
352+ _ => Err ( anyhow:: anyhow!(
353+ "Unexpected message type while retrieving account info"
354+ ) ) ,
367355 } ,
368356 )
369357 . await ?;
370358
359+ let Some ( mirs) = mirs else {
360+ return Ok ( RESTResponse :: with_text ( 404 , "Account not found" ) ) ;
361+ } ;
362+
371363 // Get TxHashes from TxIdentifiers
372364 let tx_ids: Vec < _ > = mirs. iter ( ) . map ( |r| r. tx_identifier . clone ( ) ) . collect ( ) ;
373365 let msg = Arc :: new ( Message :: StateQuery ( StateQuery :: Blocks (
0 commit comments