Skip to content

Commit

Permalink
chore: add sidecar url override
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit committed Oct 25, 2024
1 parent cc8db38 commit fa1cfd0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bolt-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ pub struct SendCommand {
/// The private key to sign the transaction with.
#[clap(long, env = "PRIVATE_KEY", hide_env_values = true)]
pub private_key: String,

/// The Bolt Sidecar URL to send requests to. If provided, this will override
/// the canonical bolt RPC URL and disregard any registration information.
///
/// This is useful for testing and development purposes.
#[clap(long, env = "OVERRIDE_BOLT_SIDECAR_URL")]
pub override_bolt_sidecar_url: Option<Url>,
}

/// The action to perform.
Expand Down
11 changes: 10 additions & 1 deletion bolt-cli/src/commands/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,20 @@ impl SendCommand {
};
let tx_hash = B256::from(keccak256(&raw_tx));

// Note: it's possible for users to override the target sidecar URL
// for testing and development purposes. In most cases, the sidecar will
// reject a request for a slot that it is not responsible for.
let target_url = if let Some(sidecar_url) = self.override_bolt_sidecar_url {
sidecar_url.clone()
} else {
self.bolt_rpc_url.clone()
};

send_rpc_request(
vec![hex::encode(&raw_tx)],
vec![tx_hash],
next_preconfirmer_slot,
self.bolt_rpc_url,
target_url,
&wallet,
)
.await?;
Expand Down
2 changes: 2 additions & 0 deletions bolt-cli/src/common/bolt_manager.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)] // TODO: rm this

use std::str::FromStr;

use alloy::{
Expand Down

0 comments on commit fa1cfd0

Please sign in to comment.