Sergio Chouhy 50be74580b refactor!: move LEZ related crates to dedicated directory
BREAKING CHANGE: LEZ crates have been moved from top-level directories into
  a dedicated `lez/` subdirectory. The following crates were relocated:

    common          → lez/common
    indexer         → lez/indexer
    explorer_service→ lez/explorer_service
    keycard_wallet  → lez/keycard_wallet
    mempool         → lez/mempool
    sequencer       → lez/sequencer
    storage         → lez/storage
    testnet_initial_state → lez/testnet_initial_state
    wallet          → lez/wallet
    wallet-ffi      → lez/wallet-ffi

  Any external tooling, scripts, or paths referencing these crates at their
  previous top-level locations must be updated.
2026-06-02 14:17:59 -03:00

54 lines
1.5 KiB
Rust

use anyhow::Result;
use clap::Subcommand;
use common::HashType;
use sequencer_service_rpc::RpcClient as _;
use crate::{
WalletCore,
cli::{SubcommandReturnValue, WalletSubcommand},
};
/// Represents generic chain CLI subcommand.
#[derive(Subcommand, Debug, Clone)]
pub enum ChainSubcommand {
/// Get current block id from sequencer.
CurrentBlockId,
/// Get block at id from sequencer.
Block {
#[arg(short, long)]
id: u64,
},
/// Get transaction at hash from sequencer.
Transaction {
/// hash - valid 32 byte hex string.
#[arg(short = 't', long)]
hash: HashType,
},
}
impl WalletSubcommand for ChainSubcommand {
async fn handle_subcommand(
self,
wallet_core: &mut WalletCore,
) -> Result<SubcommandReturnValue> {
match self {
Self::CurrentBlockId => {
let latest_block_id = wallet_core.sequencer_client.get_last_block_id().await?;
println!("Last block id is {latest_block_id}");
}
Self::Block { id } => {
let block = wallet_core.sequencer_client.get_block(id).await?;
println!("Last block id is {block:#?}");
}
Self::Transaction { hash } => {
let tx = wallet_core.sequencer_client.get_transaction(hash).await?;
println!("Transaction is {tx:#?}");
}
}
Ok(SubcommandReturnValue::Empty)
}
}