diff --git a/indexer/service/protocol/src/convert.rs b/indexer/service/protocol/src/convert.rs index dd01e28a..6114620f 100644 --- a/indexer/service/protocol/src/convert.rs +++ b/indexer/service/protocol/src/convert.rs @@ -402,7 +402,7 @@ impl TryFrom for nssa::privacy_preserving_transaction::witness_set:: signatures_and_public_keys, proof .map(Into::into) - .ok_or_else(|| nssa::error::NssaError::InvalidInput("Missing proof".to_string()))?, + .ok_or_else(|| nssa::error::NssaError::InvalidInput("Missing proof".to_owned()))?, )) } } diff --git a/integration_tests/src/lib.rs b/integration_tests/src/lib.rs index 016bde21..e6d31cf6 100644 --- a/integration_tests/src/lib.rs +++ b/integration_tests/src/lib.rs @@ -38,7 +38,7 @@ pub struct TestContext { indexer_client: IndexerClient, wallet: WalletCore, wallet_password: String, - /// Optional to move out value in Drop + /// Optional to move out value in Drop. sequencer_handle: Option, indexer_handle: IndexerHandle, bedrock_compose: DockerCompose, diff --git a/sequencer/core/src/lib.rs b/sequencer/core/src/lib.rs index f3e94614..cef66033 100644 --- a/sequencer/core/src/lib.rs +++ b/sequencer/core/src/lib.rs @@ -15,6 +15,7 @@ use logos_blockchain_key_management_system_service::keys::{ED25519_SECRET_KEY_SI use mempool::{MemPool, MemPoolHandle}; #[cfg(feature = "mock")] pub use mock::SequencerCoreWithMockClients; +pub use storage::error::DbError; use crate::{ block_settlement_client::{BlockSettlementClient, BlockSettlementClientTrait, MsgId}, @@ -27,8 +28,6 @@ pub mod block_store; pub mod config; pub mod indexer_client; -pub use storage::error::DbError; - #[cfg(feature = "mock")] pub mod mock; diff --git a/sequencer/service/src/lib.rs b/sequencer/service/src/lib.rs index 8ab997d9..bc9a4ef5 100644 --- a/sequencer/service/src/lib.rs +++ b/sequencer/service/src/lib.rs @@ -34,7 +34,7 @@ pub struct SequencerHandle { } impl SequencerHandle { - fn new( + const fn new( addr: SocketAddr, server_handle: ServerHandle, main_loop_handle: JoinHandle>, @@ -67,7 +67,7 @@ impl SequencerHandle { let server_handle = server_handle.take().expect("Server handle is set"); tokio::select! { - _ = server_handle.stopped() => { + () = server_handle.stopped() => { Err(anyhow!("RPC Server stopped")) } res = main_loop_handle => { diff --git a/sequencer/service/src/service.rs b/sequencer/service/src/service.rs index c8f17189..ab5459a7 100644 --- a/sequencer/service/src/service.rs +++ b/sequencer/service/src/service.rs @@ -23,6 +23,8 @@ use sequencer_core::{ }; use tokio::sync::Mutex; +const NOT_FOUND_ERROR_CODE: i32 = -31999; + pub struct SequencerService { sequencer: Arc>>, mempool_handle: MemPoolHandle, @@ -30,7 +32,7 @@ pub struct SequencerService SequencerService { - pub fn new( + pub const fn new( sequencer: Arc>>, mempool_handle: MemPoolHandle, max_block_size: u64, @@ -109,19 +111,17 @@ impl, - ) - }) - }) + .map_err(|err| internal_error(&err))?; + block.ok_or_else(|| { + ErrorObjectOwned::owned( + NOT_FOUND_ERROR_CODE, + format!("Block with id {block_id} not found"), + None::<()>, + ) + }) }) .collect::, _>>() } @@ -139,10 +139,10 @@ impl Result, ErrorObjectOwned> { let sequencer = self.sequencer.lock().await; - Ok(sequencer.block_store().get_transaction_by_hash(hash)) + Ok(sequencer.block_store().get_transaction_by_hash(tx_hash)) } async fn get_accounts_nonces( @@ -196,8 +196,6 @@ impl ErrorObjectOwned { ErrorObjectOwned::owned(ErrorCode::InternalError.code(), err.to_string(), None::<()>) } diff --git a/wallet/src/cli/account.rs b/wallet/src/cli/account.rs index 7e90b1bd..2a8ed2c7 100644 --- a/wallet/src/cli/account.rs +++ b/wallet/src/cli/account.rs @@ -3,7 +3,7 @@ use clap::Subcommand; use itertools::Itertools as _; use key_protocol::key_management::key_tree::chain_index::ChainIndex; use nssa::{Account, PublicKey, program::Program}; -use sequencer_service_rpc::RpcClient; +use sequencer_service_rpc::RpcClient as _; use token_core::{TokenDefinition, TokenHolding}; use crate::{ diff --git a/wallet/src/cli/mod.rs b/wallet/src/cli/mod.rs index 221f5539..85e792cc 100644 --- a/wallet/src/cli/mod.rs +++ b/wallet/src/cli/mod.rs @@ -3,7 +3,7 @@ use std::{io::Write as _, path::PathBuf}; use anyhow::{Context as _, Result}; use clap::{Parser, Subcommand}; use common::{HashType, transaction::NSSATransaction}; -use futures::TryFutureExt; +use futures::TryFutureExt as _; use nssa::{ProgramDeploymentTransaction, program::Program}; use sequencer_service_rpc::RpcClient as _; diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index e2bb6a8a..5ebbaf82 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -146,13 +146,12 @@ impl WalletCore { let mut builder = SequencerClientBuilder::default(); if let Some(basic_auth) = &config.basic_auth { builder = builder.set_headers( - [( + std::iter::once(( "Authorization".parse().expect("Header name is valid"), - format!("Basic {}", basic_auth) + format!("Basic {basic_auth}") .parse() .context("Invalid basic auth format")?, - )] - .into_iter() + )) .collect(), ); } @@ -341,11 +340,6 @@ impl WalletCore { Ok(()) } - // TODO: handle large Err-variant properly - #[expect( - clippy::result_large_err, - reason = "ExecutionFailureKind is large, tracked by TODO" - )] pub async fn send_privacy_preserving_tx( &self, accounts: Vec, diff --git a/wallet/src/program_facades/native_token_transfer/mod.rs b/wallet/src/program_facades/native_token_transfer/mod.rs index 72be949a..c771c735 100644 --- a/wallet/src/program_facades/native_token_transfer/mod.rs +++ b/wallet/src/program_facades/native_token_transfer/mod.rs @@ -14,11 +14,6 @@ pub mod shielded; )] pub struct NativeTokenTransfer<'wallet>(pub &'wallet WalletCore); -// TODO: handle large Err-variant properly -#[expect( - clippy::result_large_err, - reason = "ExecutionFailureKind is large, tracked by TODO" -)] fn auth_transfer_preparation( balance_to_move: u128, ) -> (