import { ExternalMethods , MESSAGE_SOURCE , TransactionResponseMessage , TxResult , } from '@shared/message-types' ; import { deleteTabForRequest , getTab , StorageKey } from '@shared/utils/storage' ; import { logger } from '@shared/logger' ; export const finalizeTxSignature = ( requestPayload , data ) => { try { const tabId = getTab ( StorageKey . transactionRequests , requestPayload ) ; const responseMessage = { source : MESSAGE_SOURCE , method : ExternalMethods . transactionResponse , payload : { transactionRequest : requestPayload , transactionResponse : data , } , } ; chrome . tabs . sendMessage ( tabId , responseMessage ) ; deleteTabForRequest ( StorageKey . transactionRequests , requestPayload ) ; if ( typeof data !== 'string' ) window . close ( ) ; } catch ( error ) { logger . debug ( 'Failed to get Tab ID for transaction request:' , requestPayload ) ; throw new Error ( 'Your transaction was broadcasted, but we lost communication with the app you started with.' ) ; } } ;