-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events-collector: events-collector-api: add routes & request types
- Loading branch information
Showing
8 changed files
with
110 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
//! Constants for the events collector API | ||
|
||
pub mod routes; |
10 changes: 10 additions & 0 deletions
10
events-collector/events-collector-api/src/constants/routes.rs
This file contains 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,10 @@ | ||
//! Events collector API routes | ||
|
||
/// The ping route | ||
pub const PING_ROUTE: &str = "ping"; | ||
|
||
/// The event submission route | ||
pub const EVENT_SUBMISSION_ROUTE: &str = "events"; | ||
|
||
/// The wallet annotation route | ||
pub const WALLET_ANNOTATION_ROUTE: &str = "wallet-annotations"; |
This file contains 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
This file contains 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
This file contains 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,3 +1,5 @@ | ||
//! API types for the events collector | ||
|
||
pub mod events; | ||
pub mod requests; | ||
pub mod wallet_annotations; |
49 changes: 49 additions & 0 deletions
49
events-collector/events-collector-api/src/types/requests.rs
This file contains 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,49 @@ | ||
//! API request types for the events collector | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use uuid::Uuid; | ||
|
||
use super::{ | ||
events::{ | ||
Deposit, FeeCollection, FeePayment, Match, OrderCancellation, OrderPlacement, | ||
WalletCreation, Withdrawal, | ||
}, | ||
wallet_annotations::WalletType, | ||
}; | ||
|
||
/// A single enum wrapping all possible event payloads | ||
#[derive(Serialize, Deserialize)] | ||
pub enum EventPayload { | ||
/// A wallet creation event payload | ||
WalletCreation(WalletCreation), | ||
/// A deposit event payload | ||
Deposit(Deposit), | ||
/// A withdrawal event payload | ||
Withdrawal(Withdrawal), | ||
/// An order placement event payload | ||
OrderPlacement(OrderPlacement), | ||
/// An order cancellation event payload | ||
OrderCancellation(OrderCancellation), | ||
/// A match event payload | ||
Match(Match), | ||
/// A fee payment event payload | ||
FeePayment(FeePayment), | ||
/// A fee collection event payload | ||
FeeCollection(FeeCollection), | ||
} | ||
|
||
/// A request to submit an event | ||
#[derive(Serialize, Deserialize)] | ||
pub struct EventSubmissionRequest { | ||
/// The event to submit | ||
pub event: EventPayload, | ||
} | ||
|
||
/// A request to annotate a wallet | ||
#[derive(Serialize, Deserialize)] | ||
pub struct WalletAnnotationRequest { | ||
/// The wallet to annotate | ||
pub wallet_id: Uuid, | ||
/// The type with which to annotate the wallet | ||
pub wallet_type: WalletType, | ||
} |
16 changes: 16 additions & 0 deletions
16
events-collector/events-collector-api/src/types/wallet_annotations.rs
This file contains 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,16 @@ | ||
//! Wallet annotation types for the events collector | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// The type of a wallet | ||
#[derive(Serialize, Deserialize)] | ||
pub enum WalletType { | ||
/// A user wallet | ||
User, | ||
/// A relayer wallet | ||
Relayer, | ||
/// A protocol wallet | ||
Protocol, | ||
/// A quoter wallet | ||
Quoter, | ||
} |
This file contains 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