Skip to content

Commit

Permalink
rollback to modular design
Browse files Browse the repository at this point in the history
0ex-d committed Jan 13, 2025
1 parent f5c94b6 commit 6342fb2
Showing 6 changed files with 432 additions and 213 deletions.
23 changes: 0 additions & 23 deletions bolt-cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ use crate::{
common::{keystore::DEFAULT_KEYSTORE_PASSWORD, parse_ether_value},
contracts::EigenLayerStrategy,
};
use tracing::info;

/// `bolt` is a CLI tool to interact with bolt Protocol ✨
#[derive(Parser, Debug, Clone)]
@@ -64,28 +63,6 @@ impl Cmd {
Self::PubkeyHash(cmd) => cmd.run(),
}
}

/// Asks whether the user wants to proceed further. If not, the process is exited.
#[allow(unreachable_code)]
pub fn request_confirmation() {
// Skip confirmation in tests
#[cfg(test)]
return;

inquire::Confirm::new("Do you want to continue? (yes/no):")
.prompt()
.map(|proceed| {
if proceed {
return;
}
info!("Aborting");
std::process::exit(0);
})
.unwrap_or_else(|err| {
info!("confirmation exited: {}", err);
std::process::exit(0);
})
}
}

/// Command for generating BLS delegation or revocation messages.
10 changes: 5 additions & 5 deletions bolt-cli/src/commands/operators/eigenlayer.rs
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ use eyre::Context;
use tracing::{info, warn};

use crate::{
cli::{Chain, Cmd, EigenLayerSubcommand},
common::{bolt_manager::BoltManagerContract, try_parse_contract_error},
cli::{Chain, EigenLayerSubcommand},
common::{bolt_manager::BoltManagerContract, request_confirmation, try_parse_contract_error},
contracts::{
bolt::{
BoltEigenLayerMiddleware::{self, BoltEigenLayerMiddlewareErrors},
@@ -62,7 +62,7 @@ impl EigenLayerSubcommand {

info!(%strategy, %token, amount = format_ether(amount), ?operator, "Depositing funds into EigenLayer strategy");

Cmd::request_confirmation();
request_confirmation();

let token_erc20 = IERC20Instance::new(token, provider);

@@ -106,7 +106,7 @@ impl EigenLayerSubcommand {

info!(operator = %signer.address(), rpc = %operator_rpc, ?chain, "Registering EigenLayer operator");

Cmd::request_confirmation();
request_confirmation();

let deployments = deployments_for_chain(chain);

@@ -186,7 +186,7 @@ impl EigenLayerSubcommand {

info!(operator = %address, ?chain, "Deregistering EigenLayer operator");

Cmd::request_confirmation();
request_confirmation();

let deployments = deployments_for_chain(chain);

8 changes: 4 additions & 4 deletions bolt-cli/src/commands/operators/symbiotic.rs
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ use eyre::Context;
use tracing::{info, warn};

use crate::{
cli::{Chain, Cmd, SymbioticSubcommand},
common::{bolt_manager::BoltManagerContract, try_parse_contract_error},
cli::{Chain, SymbioticSubcommand},
common::{bolt_manager::BoltManagerContract, request_confirmation, try_parse_contract_error},
contracts::{
bolt::BoltSymbioticMiddleware::{self, BoltSymbioticMiddlewareErrors},
deployments_for_chain,
@@ -37,7 +37,7 @@ impl SymbioticSubcommand {

info!(operator = %signer.address(), rpc = %operator_rpc, ?chain, "Registering Symbiotic operator");

Cmd::request_confirmation();
request_confirmation();

// Check if operator is opted in to the bolt network
if !IOptInService::new(
@@ -108,7 +108,7 @@ impl SymbioticSubcommand {

info!(operator = %address, ?chain, "Deregistering Symbiotic operator");

Cmd::request_confirmation();
request_confirmation();

let middleware =
BoltSymbioticMiddleware::new(deployments.bolt.symbiotic_middleware, provider);
6 changes: 3 additions & 3 deletions bolt-cli/src/commands/validators.rs
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ use eyre::Context;
use tracing::{info, warn};

use crate::{
cli::{Chain, Cmd, ValidatorsCommand, ValidatorsSubcommand},
common::{hash::compress_bls_pubkey, try_parse_contract_error},
cli::{Chain, ValidatorsCommand, ValidatorsSubcommand},
common::{hash::compress_bls_pubkey, request_confirmation, try_parse_contract_error},
contracts::{
bolt::BoltValidators::{self, BoltValidatorsErrors},
deployments_for_chain,
@@ -52,7 +52,7 @@ impl ValidatorsCommand {
let bolt_validators =
BoltValidators::new(bolt_validators_address, provider.clone());

Cmd::request_confirmation();
request_confirmation();

match bolt_validators
.batchRegisterValidatorsUnsafe(
23 changes: 23 additions & 0 deletions bolt-cli/src/common/mod.rs
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ use alloy::{
use ethereum_consensus::crypto::PublicKey as BlsPublicKey;
use eyre::{Context, ContextCompat, Result};
use serde::Serialize;
use tracing::info;

/// BoltManager contract bindings.
pub mod bolt_manager;
@@ -105,3 +106,25 @@ pub fn try_parse_contract_error<T: SolInterface>(error: ContractError) -> Result
_ => Err(error),
}
}

/// Asks whether the user wants to proceed further. If not, the process is exited.
#[allow(unreachable_code)]
pub fn request_confirmation() {
// Skip confirmation in tests
#[cfg(test)]
return;

inquire::Confirm::new("Do you want to continue? (yes/no):")
.prompt()
.map(|proceed| {
if proceed {
return;
}
info!("Aborting");
std::process::exit(0);
})
.unwrap_or_else(|err| {
info!("confirmation exited: {}", err);
std::process::exit(0);
})
}
575 changes: 397 additions & 178 deletions bolt-cli/src/pb/v1.rs

Large diffs are not rendered by default.

0 comments on commit 6342fb2

Please sign in to comment.