@@ -21,7 +21,11 @@ import {
2121 isInvalidContinuationError ,
2222 isNotFoundError ,
2323} from '@/background/services/openPayments' ;
24- import { createTabIfNotExists } from '@/background/utils' ;
24+ import {
25+ createTabIfNotExists ,
26+ WalletStatusCancelError ,
27+ WalletStatusFailureError ,
28+ } from '@/background/utils' ;
2529
2630interface InteractionParams {
2731 interactRef : string ;
@@ -284,7 +288,7 @@ export class OutgoingPaymentGrantService {
284288 if ( tabId !== tabID ) return ;
285289
286290 removeListeners ( ) ;
287- reject ( new ErrorWithKey ( 'connectWallet_error_tabClosed ') ) ;
291+ reject ( new WalletStatusCancelError ( 'tab_closed ') ) ;
288292 } ;
289293
290294 const getInteractionInfo : TabUpdateCallback = async ( tabId , changeInfo ) => {
@@ -306,9 +310,9 @@ export class OutgoingPaymentGrantService {
306310 if ( interactRef && hash ) {
307311 resolve ( { interactRef, hash, tabId } ) ;
308312 } else if ( result === 'grant_rejected' ) {
309- reject ( new ErrorWithKey ( 'connectWallet_error_grantRejected ') ) ;
313+ reject ( new WalletStatusCancelError ( 'grant_rejected ') ) ;
310314 } else if ( result === 'grant_invalid' ) {
311- reject ( new ErrorWithKey ( 'connectWallet_error_grantInvalid ') ) ;
315+ reject ( new WalletStatusFailureError ( 'grant_invalid ') ) ;
312316 }
313317 } catch {
314318 /* do nothing */
@@ -337,7 +341,7 @@ export class OutgoingPaymentGrantService {
337341 'verifyInteractionHash failed with authServer without trailing slash' ,
338342 ) ;
339343 if ( hash === ( await computeHash ( ensureEnd ( authServer , '/' ) ) ) ) return ;
340- throw new ErrorWithKey ( 'connectWallet_error_hashFailed ') ;
344+ throw new WalletStatusFailureError ( 'grant_hash_failed ') ;
341345 }
342346
343347 private computeHash = async (
@@ -365,10 +369,11 @@ export class OutgoingPaymentGrantService {
365369
366370 return continuation ;
367371 } catch ( error ) {
368- this . logger . error ( 'connectWallet_error_continuationFailed ', {
369- cause : error ,
372+ const err = new WalletStatusFailureError ( 'grant_continuation_failed ', {
373+ details : error ,
370374 } ) ;
371- throw new ErrorWithKey ( 'connectWallet_error_continuationFailed' ) ;
375+ this . logger . error ( err ) ;
376+ throw err ;
372377 }
373378 }
374379
0 commit comments