@@ -36,6 +36,7 @@ import { isUniswapX } from 'uniswap/src/features/transactions/swap/utils/routing
3636import  {  interruptTransactionFlow  }  from  'uniswap/src/utils/saga' 
3737import  {  isSameAddress  }  from  'utilities/src/addresses' 
3838import  {  percentFromFloat  }  from  'utilities/src/format/percent' 
39+ import  {  Sentry  }  from  'utilities/src/logger/Sentry' 
3940import  noop  from  'utilities/src/react/noop' 
4041import  {  currencyId  }  from  'utils/currencyId' 
4142import  {  signTypedData  }  from  'utils/signing' 
@@ -51,6 +52,15 @@ export function* handleSignatureStep({ setCurrentStep, step, ignoreInterrupt, ac
5152  // Add a watcher to check if the transaction flow is interrupted during this step 
5253  const  {  throwIfInterrupted }  =  yield *  watchForInterruption ( ignoreInterrupt ) 
5354
55+   addTransactionBreadcrumb ( { 
56+     step, 
57+     data : { 
58+       domain : JSON . stringify ( step . domain ) , 
59+       values : JSON . stringify ( step . values ) , 
60+       types : JSON . stringify ( step . types ) , 
61+     } , 
62+   } ) 
63+ 
5464  // Trigger UI prompting user to accept 
5565  setCurrentStep ( {  step,  accepted : false  } ) 
5666
@@ -59,6 +69,8 @@ export function* handleSignatureStep({ setCurrentStep, step, ignoreInterrupt, ac
5969  // If the transaction flow was interrupted, throw an error after the step has completed 
6070  yield *  call ( throwIfInterrupted ) 
6171
72+   addTransactionBreadcrumb ( {  step,  data : {  signature } ,  status : 'complete'  } ) 
73+ 
6274  return  signature 
6375} 
6476
@@ -81,12 +93,16 @@ export function* handleOnChainStep<T extends OnChainTransactionStep>(params: Han
8193  const  {  chainId }  =  step . txRequest 
8294  const  signer  =  yield *  call ( getSigner ,  account . address ) 
8395
96+   addTransactionBreadcrumb ( {  step,  data : {  ...info  }  } ) 
97+ 
8498  // Avoid sending prompting a transaction if the user already submitted an equivalent tx, e.g. by closing and reopening a transaction flow 
8599  const  duplicativeTx  =  yield *  findDuplicativeTx ( info ,  account ,  chainId ,  allowDuplicativeTx ) 
86100  if  ( duplicativeTx )  { 
87101    if  ( duplicativeTx . status  ===  TransactionStatus . Confirmed )  { 
102+       addTransactionBreadcrumb ( {  step,  data : {  duplicativeTx : true ,  hash : duplicativeTx . hash  } ,  status : 'complete'  } ) 
88103      return  duplicativeTx . hash 
89104    }  else  { 
105+       addTransactionBreadcrumb ( {  step,  data : {  duplicativeTx : true ,  hash : duplicativeTx . hash  } ,  status : 'in progress'  } ) 
90106      setCurrentStep ( {  step,  accepted : true  } ) 
91107      return  yield *  handleOnChainConfirmation ( params ,  duplicativeTx . hash ) 
92108    } 
@@ -139,6 +155,9 @@ function* handleOnChainConfirmation(params: HandleOnChainStepParams, hash: strin
139155  if  ( interrupt )  { 
140156    throw  new  HandledTransactionInterrupt ( 'Transaction flow was interrupted' ) 
141157  } 
158+ 
159+   addTransactionBreadcrumb ( {  step,  data : {  txHash : hash  } ,  status : 'complete'  } ) 
160+ 
142161  return  hash 
143162} 
144163
@@ -267,3 +286,22 @@ export function getSwapTransactionInfo(trade: ClassicTrade | UniswapXTrade): Swa
267286        } ) , 
268287  } 
269288} 
289+ 
290+ export  function  addTransactionBreadcrumb ( { 
291+   step, 
292+   data =  { } , 
293+   status =  'initiated' , 
294+ } : { 
295+   step : TransactionStep 
296+   data ?: { 
297+     [ key : string ] : string  |  number  |  boolean  |  undefined 
298+   } 
299+   status ?: 'initiated'  |  'complete'  |  'in progress'  |  'interrupted' 
300+ } )  { 
301+   Sentry . addBreadCrumb ( { 
302+     level : 'info' , 
303+     category : 'transaction' , 
304+     message : `${ step . type }   ${ status }  ` , 
305+     data, 
306+   } ) 
307+ } 
0 commit comments