2025-04-16 16:17:53 +03:00
|
|
|
use merkle_tree_public::TreeHashType;
|
2025-02-05 12:24:09 +02:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
2025-04-16 16:17:53 +03:00
|
|
|
pub mod block;
|
|
|
|
|
pub mod commitment;
|
2025-07-24 16:05:27 +03:00
|
|
|
pub mod execution_input;
|
2025-04-16 16:17:53 +03:00
|
|
|
pub mod merkle_tree_public;
|
|
|
|
|
pub mod nullifier;
|
|
|
|
|
pub mod rpc_primitives;
|
|
|
|
|
pub mod transaction;
|
|
|
|
|
pub mod utxo_commitment;
|
|
|
|
|
|
2025-08-05 14:59:20 +03:00
|
|
|
//Module for tests utility functions
|
|
|
|
|
pub mod test_utils;
|
|
|
|
|
|
2025-04-16 16:17:53 +03:00
|
|
|
use rpc_primitives::errors::RpcError;
|
|
|
|
|
|
|
|
|
|
///Account id on blockchain
|
|
|
|
|
pub type AccountId = TreeHashType;
|
|
|
|
|
|
2025-02-05 12:24:09 +02:00
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
|
|
|
pub struct SequencerRpcError {
|
|
|
|
|
pub jsonrpc: String,
|
|
|
|
|
pub error: RpcError,
|
|
|
|
|
pub id: u64,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
|
|
|
pub enum SequencerClientError {
|
|
|
|
|
#[error("HTTP error")]
|
|
|
|
|
HTTPError(reqwest::Error),
|
|
|
|
|
#[error("Serde error")]
|
|
|
|
|
SerdeError(serde_json::Error),
|
|
|
|
|
#[error("Internal error")]
|
|
|
|
|
InternalError(SequencerRpcError),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<reqwest::Error> for SequencerClientError {
|
|
|
|
|
fn from(value: reqwest::Error) -> Self {
|
|
|
|
|
SequencerClientError::HTTPError(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<serde_json::Error> for SequencerClientError {
|
|
|
|
|
fn from(value: serde_json::Error) -> Self {
|
|
|
|
|
SequencerClientError::SerdeError(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<SequencerRpcError> for SequencerClientError {
|
|
|
|
|
fn from(value: SequencerRpcError) -> Self {
|
|
|
|
|
SequencerClientError::InternalError(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
|
|
|
pub enum ExecutionFailureKind {
|
|
|
|
|
#[error("Failed to write into builder err: {0:?}")]
|
|
|
|
|
WriteError(anyhow::Error),
|
2025-04-09 01:30:10 -04:00
|
|
|
#[error("Failed to interact with a db err: {0:?}")]
|
|
|
|
|
DBError(anyhow::Error),
|
2025-02-05 12:24:09 +02:00
|
|
|
#[error("Failed to build builder err: {0:?}")]
|
|
|
|
|
BuilderError(anyhow::Error),
|
|
|
|
|
#[error("Failed prove execution err: {0:?}")]
|
|
|
|
|
ProveError(anyhow::Error),
|
|
|
|
|
#[error("Failed to decode data from VM: {0:?}")]
|
|
|
|
|
DecodeError(#[from] risc0_zkvm::serde::Error),
|
|
|
|
|
#[error("Inputs amounts does not match outputs")]
|
|
|
|
|
AmountMismatchError,
|
|
|
|
|
#[error("Sequencer client error: {0:?}")]
|
|
|
|
|
SequencerClientError(#[from] SequencerClientError),
|
2025-02-28 12:32:54 +02:00
|
|
|
#[error("Insufficient gas for operation")]
|
|
|
|
|
InsufficientGasError,
|
|
|
|
|
#[error("Can not pay for operation")]
|
|
|
|
|
InsufficientFundsError,
|
2025-02-05 12:24:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ExecutionFailureKind {
|
|
|
|
|
pub fn write_error(err: anyhow::Error) -> Self {
|
|
|
|
|
Self::WriteError(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn builder_error(err: anyhow::Error) -> Self {
|
|
|
|
|
Self::BuilderError(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn prove_error(err: anyhow::Error) -> Self {
|
|
|
|
|
Self::ProveError(err)
|
|
|
|
|
}
|
2025-04-09 01:30:10 -04:00
|
|
|
|
|
|
|
|
pub fn db_error(err: anyhow::Error) -> Self {
|
|
|
|
|
Self::DBError(err)
|
|
|
|
|
}
|
2025-02-05 12:24:09 +02:00
|
|
|
}
|
2025-07-14 09:37:00 -03:00
|
|
|
|
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
|
|
|
pub enum TransactionSignatureError {
|
|
|
|
|
#[error("invalid signature for transaction body")]
|
|
|
|
|
InvalidSignature,
|
|
|
|
|
}
|