@@ -82,33 +82,39 @@ export async function cancelTransaction(fastify: FastifyInstance) {
82
82
83
83
const message = "Transaction successfully cancelled." ;
84
84
let cancelledTransaction : CancelledTransaction | null = null ;
85
- if ( ! transaction . isUserOp ) {
86
- if ( transaction . status === "queued" ) {
87
- // Remove all retries from the SEND_TRANSACTION queue.
88
- const config = await getConfig ( ) ;
89
- for (
90
- let resendCount = 0 ;
91
- resendCount < config . maxRetriesPerTx ;
92
- resendCount ++
93
- ) {
94
- await SendTransactionQueue . remove ( { queueId, resendCount } ) ;
95
- }
85
+ if ( transaction . status === "queued" ) {
86
+ // Remove all retries from the SEND_TRANSACTION queue.
87
+ const config = await getConfig ( ) ;
88
+ for (
89
+ let resendCount = 0 ;
90
+ resendCount < config . maxRetriesPerTx ;
91
+ resendCount ++
92
+ ) {
93
+ await SendTransactionQueue . remove ( { queueId, resendCount } ) ;
94
+ }
96
95
97
- cancelledTransaction = {
98
- ...transaction ,
99
- status : "cancelled" ,
100
- cancelledAt : new Date ( ) ,
96
+ cancelledTransaction = {
97
+ ...transaction ,
98
+ status : "cancelled" ,
99
+ cancelledAt : new Date ( ) ,
101
100
102
- // Dummy data since the transaction was never sent.
103
- sentAt : new Date ( ) ,
104
- sentAtBlock : await getBlockNumberish ( transaction . chainId ) ,
101
+ // Dummy data since the transaction was never sent.
102
+ sentAt : new Date ( ) ,
103
+ sentAtBlock : await getBlockNumberish ( transaction . chainId ) ,
105
104
106
- isUserOp : false ,
107
- gas : 0n ,
108
- nonce : - 1 ,
109
- sentTransactionHashes : [ ] ,
110
- } ;
111
- } else if ( transaction . status === "sent" ) {
105
+ // isUserOp: false,
106
+ gas : 0n ,
107
+ ...( transaction . isUserOp
108
+ ? {
109
+ userOpHash :
110
+ "0x0000000000000000000000000000000000000000000000000000000000000000" ,
111
+ nonce : "cancelled" ,
112
+ isUserOp : true ,
113
+ }
114
+ : { nonce : - 1 , sentTransactionHashes : [ ] , isUserOp : false } ) ,
115
+ } ;
116
+ } else if ( transaction . status === "sent" ) {
117
+ if ( ! transaction . isUserOp ) {
112
118
// Cancel a sent transaction with the same nonce.
113
119
const { chainId, from, nonce } = transaction ;
114
120
const transactionHash = await sendCancellationTransaction ( {
@@ -143,7 +149,10 @@ export async function cancelTransaction(fastify: FastifyInstance) {
143
149
queueId,
144
150
status : "success" ,
145
151
message,
146
- transactionHash : cancelledTransaction . sentTransactionHashes . at ( - 1 ) ,
152
+ transactionHash :
153
+ "sentTransactionHashes" in cancelledTransaction
154
+ ? cancelledTransaction . sentTransactionHashes . at ( - 1 )
155
+ : cancelledTransaction . userOpHash ,
147
156
} ,
148
157
} ) ;
149
158
} ,
0 commit comments