File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
packages/transaction-pay-controller/src/utils Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,32 @@ describe('Transaction Utils', () => {
157157 ) ;
158158 } ,
159159 ) ;
160+
161+ it ( 'removes state if transaction is deleted' , ( ) => {
162+ const removeTransactionDataMock = jest . fn ( ) ;
163+
164+ pollTransactionChanges ( messenger , noop , removeTransactionDataMock ) ;
165+
166+ publish (
167+ 'TransactionController:stateChange' ,
168+ {
169+ transactions : [ TRANSACTION_META_MOCK ] ,
170+ } as TransactionControllerState ,
171+ [ ] ,
172+ ) ;
173+
174+ publish (
175+ 'TransactionController:stateChange' ,
176+ {
177+ transactions : [ ] as TransactionMeta [ ] ,
178+ } as TransactionControllerState ,
179+ [ ] ,
180+ ) ;
181+
182+ expect ( removeTransactionDataMock ) . toHaveBeenCalledWith (
183+ TRANSACTION_ID_MOCK ,
184+ ) ;
185+ } ) ;
160186 } ) ;
161187
162188 describe ( 'updateTransaction' , ( ) => {
Original file line number Diff line number Diff line change @@ -85,7 +85,11 @@ export function pollTransactionChanges(
8585 ) ;
8686 } ) ;
8787
88- finalizedTransactions . forEach ( ( tx ) =>
88+ const deletedTransactions = ( previousTransactions ?? [ ] ) . filter (
89+ ( prevTx ) => ! transactions . find ( ( tx ) => tx . id === prevTx . id ) ,
90+ ) ;
91+
92+ [ ...finalizedTransactions , ...deletedTransactions ] . forEach ( ( tx ) =>
8993 onTransactionFinalized ( tx , removeTransactionData ) ,
9094 ) ;
9195
You can’t perform that action at this time.
0 commit comments