-
Notifications
You must be signed in to change notification settings - Fork 12
EOA Production Readiness #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cc4ff1d
wip
d4mr 81d56cc
refactor eoa store
d4mr 67a7ab7
add event notification integration points
d4mr 1c72974
wip
d4mr 0925946
typo
d4mr 1862517
Add transaction context creation from Redis pipeline
d4mr d233439
Add thirdweb-core dependency and enhance transaction processing
d4mr 1518cd8
Refactor signer and transaction handling for improved efficiency
d4mr 6b70ab5
remove dbg, fix underflow
d4mr 9a29963
fix event
d4mr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| use std::fmt::Display; | ||
|
|
||
| use engine_core::error::EngineError; | ||
| use serde::{Deserialize, Serialize}; | ||
| use twmq::job::RequeuePosition; | ||
|
|
||
| use crate::{ | ||
| eoa::{ | ||
| store::{SubmittedTransaction, TransactionData}, | ||
| worker::ConfirmedTransactionWithRichReceipt, | ||
| }, | ||
| webhook::envelope::{ | ||
| BareWebhookNotificationEnvelope, SerializableNackData, SerializableSuccessData, StageEvent, | ||
| }, | ||
| }; | ||
|
|
||
| pub struct EoaExecutorEvent { | ||
| pub transaction_data: TransactionData, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||
| pub struct EoaSendAttemptNackData { | ||
| pub nonce: u64, | ||
| pub error: EngineError, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
| pub enum EoaExecutorStage { | ||
| SendAttempt, | ||
| SendAttemptNack, | ||
| TransactionReplaced, | ||
| TransactionConfirmed, | ||
| } | ||
|
|
||
| impl Display for EoaExecutorStage { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| match self { | ||
| EoaExecutorStage::SendAttempt => write!(f, "send_attempt"), | ||
| EoaExecutorStage::SendAttemptNack => write!(f, "send_attempt_nack"), | ||
| EoaExecutorStage::TransactionReplaced => write!(f, "transaction_replaced"), | ||
| EoaExecutorStage::TransactionConfirmed => write!(f, "transaction_confirmed"), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const EXECUTOR_NAME: &str = "eoa"; | ||
|
|
||
| impl EoaExecutorEvent { | ||
| pub fn send_attempt_success_envelopes( | ||
| &self, | ||
| submitted_transaction: SubmittedTransaction, | ||
| ) -> BareWebhookNotificationEnvelope<SerializableSuccessData<SubmittedTransaction>> { | ||
| BareWebhookNotificationEnvelope { | ||
| transaction_id: self.transaction_data.transaction_id.clone(), | ||
| executor_name: EXECUTOR_NAME.to_string(), | ||
| stage_name: EoaExecutorStage::SendAttempt.to_string(), | ||
| event_type: StageEvent::Success, | ||
| payload: SerializableSuccessData { | ||
| result: submitted_transaction.clone(), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| pub fn send_attempt_nack_envelopes( | ||
| &self, | ||
| nonce: u64, | ||
| error: EngineError, | ||
| attempt_number: u32, | ||
| ) -> BareWebhookNotificationEnvelope<SerializableNackData<EoaSendAttemptNackData>> { | ||
| BareWebhookNotificationEnvelope { | ||
| transaction_id: self.transaction_data.transaction_id.clone(), | ||
| executor_name: EXECUTOR_NAME.to_string(), | ||
| stage_name: EoaExecutorStage::SendAttemptNack.to_string(), | ||
| event_type: StageEvent::Nack, | ||
| payload: SerializableNackData { | ||
| error: EoaSendAttemptNackData { | ||
| nonce, | ||
| error: error.clone(), | ||
| }, | ||
| delay_ms: None, | ||
| position: RequeuePosition::Last, | ||
| attempt_number, | ||
| max_attempts: None, | ||
| next_retry_at: None, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| pub fn transaction_replaced_envelopes( | ||
| &self, | ||
| replaced_transaction: SubmittedTransaction, | ||
| ) -> BareWebhookNotificationEnvelope<SerializableSuccessData<SubmittedTransaction>> { | ||
| BareWebhookNotificationEnvelope { | ||
| transaction_id: self.transaction_data.transaction_id.clone(), | ||
| executor_name: EXECUTOR_NAME.to_string(), | ||
| stage_name: EoaExecutorStage::TransactionReplaced.to_string(), | ||
| event_type: StageEvent::Success, | ||
| payload: SerializableSuccessData { | ||
| result: replaced_transaction.clone(), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| pub fn transaction_confirmed_envelopes( | ||
| &self, | ||
| confirmed_transaction: ConfirmedTransactionWithRichReceipt, | ||
| ) -> BareWebhookNotificationEnvelope<SerializableSuccessData<ConfirmedTransactionWithRichReceipt>> | ||
| { | ||
| BareWebhookNotificationEnvelope { | ||
| transaction_id: self.transaction_data.transaction_id.clone(), | ||
| executor_name: EXECUTOR_NAME.to_string(), | ||
| stage_name: EoaExecutorStage::TransactionConfirmed.to_string(), | ||
| event_type: StageEvent::Success, | ||
| payload: SerializableSuccessData { | ||
| result: confirmed_transaction.clone(), | ||
| }, | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| pub mod error_classifier; | ||
| pub mod events; | ||
| pub mod store; | ||
| pub mod worker; | ||
|
|
||
| pub use error_classifier::{EoaErrorMapper, EoaExecutionError, RecoveryStrategy}; | ||
| pub use store::{EoaExecutorStore, EoaTransactionRequest}; | ||
| pub use worker::{EoaExecutorWorker, EoaExecutorWorkerJobData}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.