Skip to content

Commit

Permalink
(fix): remove the rpc_url dependencies from eth-spout start (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauromedda authored May 30, 2024
1 parent a6ca0a7 commit 2a16bac
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions products/eth-spout/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@ async fn request(State(state): State<Arc<AppState>>, Form(request): Form<Request
}

let value = parse_ether(&state.config.eth_amount).unwrap_or(WEI_IN_ETHER);
let tx = TransactionRequest::pay(address, value);
let chain_id = match state.provider.get_chainid().await {
Ok(c) => c,
Err(e) => {
eprintln!("{e:?}");
return home_inner(State(state.clone()), Some(RequestStatus::SendErr(e))).await;
}
};
let tx = TransactionRequest::pay(address, value).chain_id(chain_id.low_u64());
let status = match state.provider.send_transaction(tx, None).await {
Ok(t) => RequestStatus::Sent(t.tx_hash()),
Err(e) => {
Expand Down Expand Up @@ -221,7 +228,7 @@ async fn main() -> Result<()> {

let provider = Provider::try_from(&config.rpc_url)?;
let wallet: LocalWallet = config.private_key.parse()?;
let provider = SignerMiddleware::new_with_provider_chain(provider, wallet).await?;
let provider = SignerMiddleware::new(provider, wallet);

let addr = ("0.0.0.0".parse::<IpAddr>()?, config.http_port);
let state = Arc::new(AppState {
Expand Down

0 comments on commit 2a16bac

Please sign in to comment.