From ce1fb2fbf7ac46132e64fe187e6038ff42c8e1c9 Mon Sep 17 00:00:00 2001 From: elizabeth Date: Tue, 2 Apr 2024 22:22:26 -0400 Subject: [PATCH] remove proto abci codes --- .../src/generated/astria.sequencer.v1.rs | 38 ------------------- crates/astria-core/src/sequencer/v1/abci.rs | 20 +--------- .../astria/sequencer/v1/abci.proto | 12 ------ 3 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 proto/sequencerapis/astria/sequencer/v1/abci.proto diff --git a/crates/astria-core/src/generated/astria.sequencer.v1.rs b/crates/astria-core/src/generated/astria.sequencer.v1.rs index cb0193a7b5..80221d0449 100644 --- a/crates/astria-core/src/generated/astria.sequencer.v1.rs +++ b/crates/astria-core/src/generated/astria.sequencer.v1.rs @@ -173,44 +173,6 @@ pub mod rollup_data { Deposit(super::Deposit), } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum AbciErrorCode { - Unspecified = 0, - UnknownPath = 1, - InvalidParameter = 2, - InternalError = 3, - InvalidNonce = 4, - TransactionTooLarge = 5, -} -impl AbciErrorCode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - AbciErrorCode::Unspecified => "ABCI_ERROR_CODE_UNSPECIFIED", - AbciErrorCode::UnknownPath => "ABCI_ERROR_CODE_UNKNOWN_PATH", - AbciErrorCode::InvalidParameter => "ABCI_ERROR_CODE_INVALID_PARAMETER", - AbciErrorCode::InternalError => "ABCI_ERROR_CODE_INTERNAL_ERROR", - AbciErrorCode::InvalidNonce => "ABCI_ERROR_CODE_INVALID_NONCE", - AbciErrorCode::TransactionTooLarge => "ABCI_ERROR_CODE_TRANSACTION_TOO_LARGE", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "ABCI_ERROR_CODE_UNSPECIFIED" => Some(Self::Unspecified), - "ABCI_ERROR_CODE_UNKNOWN_PATH" => Some(Self::UnknownPath), - "ABCI_ERROR_CODE_INVALID_PARAMETER" => Some(Self::InvalidParameter), - "ABCI_ERROR_CODE_INTERNAL_ERROR" => Some(Self::InternalError), - "ABCI_ERROR_CODE_INVALID_NONCE" => Some(Self::InvalidNonce), - "ABCI_ERROR_CODE_TRANSACTION_TOO_LARGE" => Some(Self::TransactionTooLarge), - _ => None, - } - } -} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct AssetBalance { diff --git a/crates/astria-core/src/sequencer/v1/abci.rs b/crates/astria-core/src/sequencer/v1/abci.rs index fb5dffb0fe..f01358c982 100644 --- a/crates/astria-core/src/sequencer/v1/abci.rs +++ b/crates/astria-core/src/sequencer/v1/abci.rs @@ -3,8 +3,6 @@ use std::{ num::NonZeroU32, }; -use super::raw; - #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[allow(clippy::module_name_repetitions)] pub struct AbciErrorCode(u32); @@ -34,23 +32,6 @@ impl AbciErrorCode { other => format!("unknown non-zero abci error code: {other}").into(), } } - - /// Converts from the rust representation of the abci error code. - /// - /// Note that by convention unknown protobuf enum variants are mapped to - /// the default enum variant with value 0. - #[must_use] - pub fn from_raw(raw: raw::AbciErrorCode) -> Option { - let code = match raw { - raw::AbciErrorCode::Unspecified => Self::UNSPECIFIED, - raw::AbciErrorCode::UnknownPath => Self::UNKNOWN_PATH, - raw::AbciErrorCode::InvalidParameter => Self::INVALID_PARAMETER, - raw::AbciErrorCode::InternalError => Self::INTERNAL_ERROR, - raw::AbciErrorCode::InvalidNonce => Self::INVALID_NONCE, - raw::AbciErrorCode::TransactionTooLarge => Self::TRANSACTION_TOO_LARGE, - }; - Some(code) - } } impl std::fmt::Display for AbciErrorCode { @@ -73,6 +54,7 @@ impl From for AbciErrorCode { 3 => Self::INTERNAL_ERROR, 4 => Self::INVALID_NONCE, 5 => Self::TRANSACTION_TOO_LARGE, + 6 => Self::INSUFFICIENT_FUNDS, other => Self(other), } } diff --git a/proto/sequencerapis/astria/sequencer/v1/abci.proto b/proto/sequencerapis/astria/sequencer/v1/abci.proto deleted file mode 100644 index 848d401afe..0000000000 --- a/proto/sequencerapis/astria/sequencer/v1/abci.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package astria.sequencer.v1; - -enum AbciErrorCode { - ABCI_ERROR_CODE_UNSPECIFIED = 0; - ABCI_ERROR_CODE_UNKNOWN_PATH = 1; - ABCI_ERROR_CODE_INVALID_PARAMETER = 2; - ABCI_ERROR_CODE_INTERNAL_ERROR = 3; - ABCI_ERROR_CODE_INVALID_NONCE = 4; - ABCI_ERROR_CODE_TRANSACTION_TOO_LARGE = 5; -}