Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzejkop committed Dec 14, 2023
1 parent 0b59d19 commit 4c3ffcf
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ tokio = { version = "1.17", features = [
] }
tracing = "0.1"
tracing-futures = "0.2"
tx-sitter-client = { path = "crates/tx-sitter-client" }
url = { version = "2.2", features = ["serde"] }
# `ethers-rs` requires an older version of primitive-types.
# But `ruint` supports the latest version. So we need to override it.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "tx-sitter"
name = "tx-sitter-client"
version = "0.1.0"
edition = "2021"
publish = false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion src/ethereum/write_oz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tracing::{info, warn};
use self::inner::Inner;
use self::openzeppelin::OzRelay;
use self::options::ParsedOptions;
use self::tx_sitter::TxSitter;
use super::write::TransactionId;
use super::{ReadProvider, TxError};

Expand Down Expand Up @@ -44,7 +45,9 @@ impl WriteProvider {

let inner: Arc<dyn Inner> = match options {
ParsedOptions::Oz(oz_options) => Arc::new(OzRelay::new(&oz_options).await?),
ParsedOptions::TxSitter(tx_sitter_options) => todo!(),
ParsedOptions::TxSitter(tx_sitter_options) => {
Arc::new(TxSitter::new(&tx_sitter_options.tx_sitter_url))
}
};

Ok(Self {
Expand Down
22 changes: 21 additions & 1 deletion src/ethereum/write_oz/tx_sitter.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
use anyhow::Context;
use async_trait::async_trait;
use ethers::types::transaction::eip2718::TypedTransaction;
use tx_sitter_client::data::SendTxRequest;
use tx_sitter_client::TxSitterClient;

use super::inner::{Inner, TransactionResult};
use crate::ethereum::write::TransactionId;
use crate::ethereum::TxError;

pub struct TxSitter {
url: String,
client: TxSitterClient,
}

impl TxSitter {
pub fn new(url: impl ToString) -> Self {
Self {
client: TxSitterClient::new(url),
}
}
}

#[async_trait]
Expand All @@ -16,6 +27,15 @@ impl Inner for TxSitter {
tx: TypedTransaction,
only_once: bool,
) -> Result<TransactionId, TxError> {
let x = self.client.send_tx(&SendTxRequest {
to: *tx.to_addr().context("Tx receiver must be an address")?,
value: *tx.value().context("Missing tx value")?,
data: todo!(),
gas_limit: todo!(),
priority: todo!(),
tx_id: todo!(),
}).await.unwrap();

todo!()
}

Expand Down

0 comments on commit 4c3ffcf

Please sign in to comment.