File tree Expand file tree Collapse file tree
packages/wallet/src/guardian Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,16 +111,19 @@ describe('GuardianClient.evaluateEVMTransaction — 422 handling', () => {
111111 } ) ;
112112
113113 describe ( 'when Guardian returns 422 and crossSdkBridgeEnabled is false (web SDK)' , ( ) => {
114- it ( 'returns confirmationRequired: true instead of throwing ' , async ( ) => {
114+ it ( 'throws INTERNAL_ERROR; TRANSACTION_REVERTED is only used for native clients ' , async ( ) => {
115115 mockEvaluateTransaction . mockRejectedValue (
116116 makeAxiosError ( 422 , { message : 'execution reverted' } ) ,
117117 ) ;
118118
119119 const client = makeClient ( false ) ;
120120
121- const result = await ( client as any ) . evaluateEVMTransaction ( evalParams ) ;
122-
123- expect ( result ) . toEqual ( { confirmationRequired : true } ) ;
121+ await expect (
122+ ( client as any ) . evaluateEVMTransaction ( evalParams ) ,
123+ ) . rejects . toMatchObject ( {
124+ code : RpcErrorCode . INTERNAL_ERROR ,
125+ message : expect . stringContaining ( 'Transaction failed to validate with error:' ) ,
126+ } ) ;
124127 } ) ;
125128 } ) ;
126129
Original file line number Diff line number Diff line change @@ -173,16 +173,14 @@ export default class GuardianClient {
173173 throw new WalletError ( 'Service unavailable' , WalletErrorType . SERVICE_UNAVAILABLE_ERROR ) ;
174174 }
175175
176- if ( isAxiosError ( error ) && error . response ?. status === 422 ) {
177- if ( this . crossSdkBridgeEnabled ) {
178- const revertReason = ( error . response ?. data as any ) ?. message ?? 'A transaction simulation reverted' ;
179- throw new JsonRpcError (
180- RpcErrorCode . TRANSACTION_REVERTED ,
181- `Transaction will revert: ${ revertReason } ` ,
182- ) ;
183- }
184-
185- return { confirmationRequired : true } ;
176+ // For native clients, throw a TRANSACTION_REVERTED error if the guardian service
177+ // responds with a 422.
178+ if ( isAxiosError ( error ) && error . response ?. status === 422 && this . crossSdkBridgeEnabled ) {
179+ const revertReason = ( error . response ?. data as any ) ?. message ?? 'A transaction simulation reverted' ;
180+ throw new JsonRpcError (
181+ RpcErrorCode . TRANSACTION_REVERTED ,
182+ `Transaction will revert: ${ revertReason } ` ,
183+ ) ;
186184 }
187185
188186 const errorMessage = error instanceof Error ? error . message : String ( error ) ;
You can’t perform that action at this time.
0 commit comments