-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
779905d
commit decd69f
Showing
8 changed files
with
1,111 additions
and
221 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,4 +1,4 @@ | ||
[workspace] | ||
members = ["packages/relayer"] | ||
members = ["packages/relayer", "e2e"] | ||
exclude = ["node_modules/*", "packages/relayer/src/abis"] | ||
resolver = "2" |
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,26 @@ | ||
[package] | ||
name = "email-tx-builder-e2e-receiver" | ||
version = "1.0.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1.0.89" | ||
axum = "0.7.7" | ||
serde = { version = "1.0.210", features = ["derive"] } | ||
serde_json = "1.0.128" | ||
bigdecimal = "0.3.1" | ||
tokio = { version = "1.40.0", features = ["full"] } | ||
tower-http = { version = "0.6.1", features = ["cors"] } | ||
relayer-utils = { git = "https://github.com/zkemail/relayer-utils.git", branch = "main" } | ||
slog = { version = "2.7.0", features = [ | ||
"max_level_trace", | ||
"release_max_level_warn", | ||
] } | ||
uuid = { version = "1.10.0", features = ["serde", "v4"] } | ||
chrono = { version = "0.4.38", features = ["serde"] } | ||
reqwest = { version = "0.12.8", features = ["json"] } | ||
handlebars = "6.1.0" | ||
lazy_static = "1.5.0" | ||
relayer-imap = { version = "0.1.0", git = "https://github.com/zkemail/relayer-imap.git", branch = "feat/config_file" } | ||
relayer-smtp = { version = "0.1.0", git = "https://github.com/zkemail/relayer-smtp.git", branch = "feat/serde" } | ||
regex = "1.10.6" |
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,79 @@ | ||
use anyhow::Error; | ||
use relayer_imap::RelayerIMAPConfig; | ||
use relayer_smtp::RelayerSMTPConfig; | ||
use serde::Deserialize; | ||
use serde_json; | ||
use std::collections::HashMap; | ||
use std::env; | ||
use std::fs::File; | ||
use std::io::Read; | ||
|
||
// #[derive(Deserialize, Debug, Clone)] | ||
// #[serde(rename_all = "camelCase")] | ||
// pub struct ReceiverConfigs { | ||
// pub configs: Vec<ReceiverConfig>, | ||
// pub json_logger: bool, | ||
// // pub logs_path: String, | ||
// } | ||
|
||
// unsafe impl Send for ReceiverConfigs {} | ||
// unsafe impl Sync for ReceiverConfigs {} | ||
|
||
// impl ReceiverConfigs { | ||
// pub fn from_file(file_path: &str) -> Result<Self, Error> { | ||
// // Open the configuration file | ||
// let mut file = File::open(file_path) | ||
// .map_err(|e| anyhow::anyhow!("Failed to open config file: {}", e))?; | ||
|
||
// // Read the file's content into a string | ||
// let mut data = String::new(); | ||
// file.read_to_string(&mut data) | ||
// .map_err(|e| anyhow::anyhow!("Failed to read config file: {}", e))?; | ||
|
||
// // Deserialize the JSON content into a Config struct | ||
// let config: Self = serde_json::from_str(&data) | ||
// .map_err(|e| anyhow::anyhow!("Failed to parse config file: {}", e))?; | ||
|
||
// // Setting Logger ENV | ||
// if config.json_logger { | ||
// env::set_var("JSON_LOGGER", "true"); | ||
// } | ||
// Ok(config) | ||
// } | ||
// } | ||
|
||
#[derive(Deserialize, Debug, Clone)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ReceiverConfig { | ||
pub id: String, | ||
pub imap: RelayerIMAPConfig, | ||
pub smtp: RelayerSMTPConfig, | ||
pub json_logger: bool, | ||
// pub logs_path: String, | ||
} | ||
|
||
unsafe impl Send for ReceiverConfig {} | ||
unsafe impl Sync for ReceiverConfig {} | ||
|
||
impl ReceiverConfig { | ||
pub fn from_file(file_path: &str) -> Result<Self, Error> { | ||
// Open the configuration file | ||
let mut file = File::open(file_path) | ||
.map_err(|e| anyhow::anyhow!("Failed to open config file: {}", e))?; | ||
|
||
// Read the file's content into a string | ||
let mut data = String::new(); | ||
file.read_to_string(&mut data) | ||
.map_err(|e| anyhow::anyhow!("Failed to read config file: {}", e))?; | ||
|
||
// Deserialize the JSON content into a Config struct | ||
let config: Self = serde_json::from_str(&data) | ||
.map_err(|e| anyhow::anyhow!("Failed to parse config file: {}", e))?; | ||
|
||
// Setting Logger ENV | ||
if config.json_logger { | ||
env::set_var("JSON_LOGGER", "true"); | ||
} | ||
Ok(config) | ||
} | ||
} |
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,30 @@ | ||
use anyhow::{Error, Result}; | ||
use relayer_imap; | ||
use relayer_smtp; | ||
use std::sync::Arc; | ||
use tokio::sync::mpsc; | ||
use tokio::task; | ||
pub mod config; | ||
use config::*; | ||
use std::env; | ||
use std::path::Path; | ||
use std::process::Command; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Error> { | ||
let args: Vec<String> = env::args().collect(); | ||
match args.get(1).map(|s| s.as_str()) { | ||
Some("--run-smtp") => { | ||
let config = ReceiverConfig::from_file(&args[2])?; | ||
relayer_smtp::run(config.smtp).await?; | ||
} | ||
Some("--run-imap") => { | ||
let config = ReceiverConfig::from_file(&args[2])?; | ||
relayer_imap::run(config.imap).await?; | ||
} | ||
_ => { | ||
panic!("Invalid arguments"); | ||
} | ||
} | ||
Ok(()) | ||
} |
Empty file.
Empty file.
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