@@ -30,8 +30,8 @@ pub type AuthToken = String;
3030) ]
3131#[ serde( tag = "type" , rename_all = "SCREAMING_SNAKE_CASE" ) ]
3232pub enum IAWError {
33- #[ error( "API error: {0 }" ) ]
34- ApiError ( String ) ,
33+ #[ error( "API error: {message }" ) ]
34+ ApiError { message : String } ,
3535 #[ error( "Serialization error: {message}" ) ]
3636 SerializationError { message : String } ,
3737 #[ error( "Network error: {error}" ) ]
@@ -197,14 +197,16 @@ impl IAWClient {
197197 . await ?;
198198
199199 if !response. status ( ) . is_success ( ) {
200- return Err ( IAWError :: ApiError ( format ! (
201- "Failed to sign message - {} {}" ,
202- response. status( ) ,
203- response
204- . status( )
205- . canonical_reason( )
206- . unwrap_or( "Unknown error" )
207- ) ) ) ;
200+ return Err ( IAWError :: ApiError {
201+ message : format ! (
202+ "Failed to sign message - {} {}" ,
203+ response. status( ) ,
204+ response
205+ . status( )
206+ . canonical_reason( )
207+ . unwrap_or( "Unknown error" )
208+ ) ,
209+ } ) ;
208210 }
209211
210212 // Parse the response
@@ -214,7 +216,9 @@ impl IAWClient {
214216 let signature = signed_response
215217 . get ( "signature" )
216218 . and_then ( |s| s. as_str ( ) )
217- . ok_or_else ( || IAWError :: ApiError ( "No signature in response" . to_string ( ) ) ) ?;
219+ . ok_or_else ( || IAWError :: ApiError {
220+ message : "No signature in response" . to_string ( ) ,
221+ } ) ?;
218222
219223 Ok ( SignMessageData {
220224 signature : signature. to_string ( ) ,
@@ -262,14 +266,16 @@ impl IAWClient {
262266 . await ?;
263267
264268 if !response. status ( ) . is_success ( ) {
265- return Err ( IAWError :: ApiError ( format ! (
266- "Failed to sign typed data - {} {}" ,
267- response. status( ) ,
268- response
269- . status( )
270- . canonical_reason( )
271- . unwrap_or( "Unknown error" )
272- ) ) ) ;
269+ return Err ( IAWError :: ApiError {
270+ message : format ! (
271+ "Failed to sign typed data - {} {}" ,
272+ response. status( ) ,
273+ response
274+ . status( )
275+ . canonical_reason( )
276+ . unwrap_or( "Unknown error" )
277+ ) ,
278+ } ) ;
273279 }
274280
275281 // Parse the response
@@ -279,7 +285,9 @@ impl IAWClient {
279285 let signature = signed_response
280286 . get ( "signature" )
281287 . and_then ( |s| s. as_str ( ) )
282- . ok_or_else ( || IAWError :: ApiError ( "No signature in response" . to_string ( ) ) ) ?;
288+ . ok_or_else ( || IAWError :: ApiError {
289+ message : "No signature in response" . to_string ( ) ,
290+ } ) ?;
283291
284292 Ok ( SignTypedDataData {
285293 signature : signature. to_string ( ) ,
@@ -328,14 +336,16 @@ impl IAWClient {
328336 . await ?;
329337
330338 if !response. status ( ) . is_success ( ) {
331- return Err ( IAWError :: ApiError ( format ! (
332- "Failed to sign transaction - {} {}" ,
333- response. status( ) ,
334- response
335- . status( )
336- . canonical_reason( )
337- . unwrap_or( "Unknown error" )
338- ) ) ) ;
339+ return Err ( IAWError :: ApiError {
340+ message : format ! (
341+ "Failed to sign transaction - {} {}" ,
342+ response. status( ) ,
343+ response
344+ . status( )
345+ . canonical_reason( )
346+ . unwrap_or( "Unknown error" )
347+ ) ,
348+ } ) ;
339349 }
340350
341351 // Parse the response
@@ -345,7 +355,9 @@ impl IAWClient {
345355 let signature = signed_response
346356 . get ( "signature" )
347357 . and_then ( |s| s. as_str ( ) )
348- . ok_or_else ( || IAWError :: ApiError ( "No signature in response" . to_string ( ) ) ) ?;
358+ . ok_or_else ( || IAWError :: ApiError {
359+ message : "No signature in response" . to_string ( ) ,
360+ } ) ?;
349361
350362 Ok ( SignTransactionData {
351363 signature : signature. to_string ( ) ,
@@ -397,14 +409,16 @@ impl IAWClient {
397409 . await ?;
398410
399411 if !response. status ( ) . is_success ( ) {
400- return Err ( IAWError :: ApiError ( format ! (
401- "Failed to sign authorization - {} {}" ,
402- response. status( ) ,
403- response
404- . status( )
405- . canonical_reason( )
406- . unwrap_or( "Unknown error" )
407- ) ) ) ;
412+ return Err ( IAWError :: ApiError {
413+ message : format ! (
414+ "Failed to sign authorization - {} {}" ,
415+ response. status( ) ,
416+ response
417+ . status( )
418+ . canonical_reason( )
419+ . unwrap_or( "Unknown error" )
420+ ) ,
421+ } ) ;
408422 }
409423
410424 // Parse the response
@@ -414,8 +428,8 @@ impl IAWClient {
414428 let signed_authorization: SignedAuthorization = serde_json:: from_value (
415429 signed_response
416430 . get ( "signedAuthorization" )
417- . ok_or_else ( || {
418- IAWError :: ApiError ( "No signedAuthorization in response" . to_string ( ) )
431+ . ok_or_else ( || IAWError :: ApiError {
432+ message : "No signedAuthorization in response" . to_string ( ) ,
419433 } ) ?
420434 . clone ( ) ,
421435 ) ?;
@@ -483,14 +497,16 @@ impl IAWClient {
483497 . await ?;
484498
485499 if !response. status ( ) . is_success ( ) {
486- return Err ( IAWError :: ApiError ( format ! (
487- "Failed to sign userop - {} {}" ,
488- response. status( ) ,
489- response
490- . status( )
491- . canonical_reason( )
492- . unwrap_or( "Unknown error" )
493- ) ) ) ;
500+ return Err ( IAWError :: ApiError {
501+ message : format ! (
502+ "Failed to sign userop - {} {}" ,
503+ response. status( ) ,
504+ response
505+ . status( )
506+ . canonical_reason( )
507+ . unwrap_or( "Unknown error" )
508+ ) ,
509+ } ) ;
494510 }
495511
496512 // Parse the response
@@ -500,7 +516,9 @@ impl IAWClient {
500516 let signature = signed_response
501517 . get ( "signature" )
502518 . and_then ( |s| s. as_str ( ) )
503- . ok_or_else ( || IAWError :: ApiError ( "No signature in response" . to_string ( ) ) ) ?;
519+ . ok_or_else ( || IAWError :: ApiError {
520+ message : "No signature in response" . to_string ( ) ,
521+ } ) ?;
504522
505523 Ok ( SignUserOpData {
506524 signature : signature. to_string ( ) ,
0 commit comments