11use std:: fmt:: Display ;
22
3- use engine_core:: error:: EngineError ;
43use serde:: { Deserialize , Serialize } ;
54use twmq:: job:: RequeuePosition ;
65
76use crate :: {
87 eoa:: {
98 store:: { SubmittedTransaction , TransactionData } ,
10- worker:: ConfirmedTransactionWithRichReceipt ,
9+ worker:: { ConfirmedTransactionWithRichReceipt , EoaExecutorWorkerError } ,
1110 } ,
1211 webhook:: envelope:: {
13- BareWebhookNotificationEnvelope , SerializableNackData , SerializableSuccessData , StageEvent ,
12+ BareWebhookNotificationEnvelope , SerializableFailData , SerializableNackData ,
13+ SerializableSuccessData , StageEvent ,
1414 } ,
1515} ;
1616
@@ -21,13 +21,12 @@ pub struct EoaExecutorEvent {
2121#[ derive( Debug , Clone , Serialize , Deserialize ) ]
2222pub struct EoaSendAttemptNackData {
2323 pub nonce : u64 ,
24- pub error : EngineError ,
24+ pub error : EoaExecutorWorkerError ,
2525}
2626
2727#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
2828pub enum EoaExecutorStage {
2929 SendAttempt ,
30- SendAttemptNack ,
3130 TransactionReplaced ,
3231 TransactionConfirmed ,
3332}
@@ -36,7 +35,6 @@ impl Display for EoaExecutorStage {
3635 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
3736 match self {
3837 EoaExecutorStage :: SendAttempt => write ! ( f, "send_attempt" ) ,
39- EoaExecutorStage :: SendAttemptNack => write ! ( f, "send_attempt_nack" ) ,
4038 EoaExecutorStage :: TransactionReplaced => write ! ( f, "transaction_replaced" ) ,
4139 EoaExecutorStage :: TransactionConfirmed => write ! ( f, "transaction_confirmed" ) ,
4240 }
@@ -46,7 +44,7 @@ impl Display for EoaExecutorStage {
4644const EXECUTOR_NAME : & str = "eoa" ;
4745
4846impl EoaExecutorEvent {
49- pub fn send_attempt_success_envelopes (
47+ pub fn send_attempt_success_envelope (
5048 & self ,
5149 submitted_transaction : SubmittedTransaction ,
5250 ) -> BareWebhookNotificationEnvelope < SerializableSuccessData < SubmittedTransaction > > {
@@ -61,16 +59,16 @@ impl EoaExecutorEvent {
6159 }
6260 }
6361
64- pub fn send_attempt_nack_envelopes (
62+ pub fn send_attempt_nack_envelope (
6563 & self ,
6664 nonce : u64 ,
67- error : EngineError ,
65+ error : EoaExecutorWorkerError ,
6866 attempt_number : u32 ,
6967 ) -> BareWebhookNotificationEnvelope < SerializableNackData < EoaSendAttemptNackData > > {
7068 BareWebhookNotificationEnvelope {
7169 transaction_id : self . transaction_data . transaction_id . clone ( ) ,
7270 executor_name : EXECUTOR_NAME . to_string ( ) ,
73- stage_name : EoaExecutorStage :: SendAttemptNack . to_string ( ) ,
71+ stage_name : EoaExecutorStage :: SendAttempt . to_string ( ) ,
7472 event_type : StageEvent :: Nack ,
7573 payload : SerializableNackData {
7674 error : EoaSendAttemptNackData {
@@ -86,7 +84,7 @@ impl EoaExecutorEvent {
8684 }
8785 }
8886
89- pub fn transaction_replaced_envelopes (
87+ pub fn transaction_replaced_envelope (
9088 & self ,
9189 replaced_transaction : SubmittedTransaction ,
9290 ) -> BareWebhookNotificationEnvelope < SerializableSuccessData < SubmittedTransaction > > {
@@ -101,7 +99,7 @@ impl EoaExecutorEvent {
10199 }
102100 }
103101
104- pub fn transaction_confirmed_envelopes (
102+ pub fn transaction_confirmed_envelope (
105103 & self ,
106104 confirmed_transaction : ConfirmedTransactionWithRichReceipt ,
107105 ) -> BareWebhookNotificationEnvelope < SerializableSuccessData < ConfirmedTransactionWithRichReceipt > >
@@ -116,4 +114,21 @@ impl EoaExecutorEvent {
116114 } ,
117115 }
118116 }
117+
118+ pub fn transaction_failed_envelope (
119+ & self ,
120+ error : EoaExecutorWorkerError ,
121+ final_attempt_number : u32 ,
122+ ) -> BareWebhookNotificationEnvelope < SerializableFailData < EoaExecutorWorkerError > > {
123+ BareWebhookNotificationEnvelope {
124+ transaction_id : self . transaction_data . transaction_id . clone ( ) ,
125+ executor_name : EXECUTOR_NAME . to_string ( ) ,
126+ stage_name : EoaExecutorStage :: SendAttempt . to_string ( ) ,
127+ event_type : StageEvent :: Failure ,
128+ payload : SerializableFailData {
129+ error : error. clone ( ) ,
130+ final_attempt_number,
131+ } ,
132+ }
133+ }
119134}
0 commit comments