Skip to content

Commit

Permalink
Update dalek
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Aug 2, 2024
1 parent c2c8bf5 commit 8078903
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 133 deletions.
124 changes: 56 additions & 68 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ base64 = { default-features = false, features = ["alloc"], optional = true, vers
bincode = { default-features = false, optional = true, version = "1.0" }
bs58 = { default-features = false, features = ["alloc"], optional = true, version = "0.5" }
cl-aux = { default-features = false, features = ["alloc", "serde"], version = "5.0" }
ed25519-dalek = { default-features = false, features = ["u64_backend"], optional = true, version = "1.0" }
ed25519-dalek = { default-features = false, optional = true, version = "2.0" }
ethabi = { default-features = false, features = ["full-serde"], optional = true, version = "18.0" }
ethereum-types = { default-features = false, features = ["serialize"], optional = true, version = "0.14" }
hex = { default-features = false, optional = true, version = "0.4" }
Expand All @@ -28,7 +28,7 @@ base64 = ["dep:base64"]
bincode = ["dep:bincode"]
bs58 = ["dep:bs58"]
default = []
ed25519-dalek = ["dep:ed25519-dalek", "std"]
ed25519-dalek = ["dep:ed25519-dalek"]
ethabi = ["dep:ethabi"]
ethereum = ["ethabi", "ethereum-types", "hex", "primitive-types"]
ethereum-types = ["dep:ethereum-types"]
Expand Down
24 changes: 21 additions & 3 deletions src/blockchain/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
//! use wtx::client_api_framework::{dnsn::SerdeJson, network::HttpParams};
//! use wtx_apis::blockchain::ethereum::{Ethereum, PkgsAux};
//!
//! let mut pkgs_aux = PkgsAux::from_minimum(Ethereum, SerdeJson, HttpParams::from_uri("URL"));
//! let mut pkgs_aux =
//! PkgsAux::from_minimum(Ethereum::new(None), SerdeJson, HttpParams::from_uri("URL"));
//! let _ = pkgs_aux.eth_block_number().build();
//! # Ok(()) }
//! ```
Expand Down Expand Up @@ -44,13 +45,30 @@ pub use transaction::Transaction;
pub use transaction_condition::TransactionCondition;
pub use transaction_request::TransactionRequest;
pub use types::*;
use wtx::client_api_framework::Api;
use wtx::client_api_framework::{misc::RequestThrottling, Api};

#[derive(Debug)]
#[doc = _generic_api_doc!()]
#[wtx_macros::api_params(pkgs_aux(PkgsAux), transport(http, ws))]
pub struct Ethereum;
pub struct Ethereum {
/// If some, tells that each request must respect calling intervals.
pub rt: Option<RequestThrottling>,
}

impl Ethereum {
/// If desired, it is possible to instantiate directly instead of using this method.
pub const fn new(rt: Option<RequestThrottling>) -> Self {
Self { rt }
}
}

impl Api for Ethereum {
type Error = crate::Error;

async fn before_sending(&mut self) -> Result<(), Self::Error> {
if let Some(ref mut rt) = self.rt {
rt.rc.update_params(&rt.rl).await?;
}
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/blockchain/ethereum/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ mod tests {
trans: &mut Mock<str, HttpParams>,
) -> Contract<SerdeJson, &mut Mock<str, HttpParams>> {
let pair = Pair::new(
EthereumPkgsAux::from_minimum(Ethereum, SerdeJson, HttpParams::from_uri("")),
EthereumPkgsAux::from_minimum(Ethereum::new(None), SerdeJson, HttpParams::from_uri("")),
trans,
);
Contract::from_json(Address::from_low_u64_be(1), pair, include_bytes!("./resources/token.json"))
Expand Down
Loading

0 comments on commit 8078903

Please sign in to comment.