From a46d1482aa952b27cb6152c9c401b0058385db01 Mon Sep 17 00:00:00 2001 From: Joseph Livesey Date: Thu, 22 Aug 2024 14:31:11 -0400 Subject: [PATCH] refactor: use sf-protos type conversions --- Cargo.lock | 3 ++- src/transactions/tx_type.rs | 23 +---------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95a3673..c6e6fea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4165,7 +4165,7 @@ dependencies = [ [[package]] name = "sf-protos" version = "0.1.0" -source = "git+https://github.com/semiotic-ai/sf-protos.git?branch=main#15062016c30ad0fc3f77c29aa2a1cb6016ece4d7" +source = "git+https://github.com/semiotic-ai/sf-protos.git?branch=main#ed8887e1631ea882c448b3d9cfa9cd7bac85d6a3" dependencies = [ "alloy-primitives", "ethportal-api", @@ -4174,6 +4174,7 @@ dependencies = [ "prost-wkt", "prost-wkt-build", "prost-wkt-types", + "reth-primitives", "serde", "thiserror", ] diff --git a/src/transactions/tx_type.rs b/src/transactions/tx_type.rs index 9cbf664..022b848 100644 --- a/src/transactions/tx_type.rs +++ b/src/transactions/tx_type.rs @@ -8,28 +8,7 @@ pub enum TransactionTypeError { Missing, } -fn tx_to_reth_tx(tx_type: Type) -> TxType { - use TxType::*; - use Type::*; - - match tx_type { - TrxTypeLegacy => Legacy, - TrxTypeAccessList => Eip2930, - TrxTypeDynamicFee => Eip1559, - TrxTypeBlob => todo!(), - TrxTypeArbitrumDeposit => unimplemented!(), - TrxTypeArbitrumUnsigned => unimplemented!(), - TrxTypeArbitrumContract => unimplemented!(), - TrxTypeArbitrumRetry => unimplemented!(), - TrxTypeArbitrumSubmitRetryable => unimplemented!(), - TrxTypeArbitrumInternal => unimplemented!(), - TrxTypeArbitrumLegacy => unimplemented!(), - TrxTypeOptimismDeposit => unimplemented!(), - } -} - pub fn map_tx_type(tx_type: &i32) -> Result { let tx_type = Type::try_from(*tx_type).map_err(|_| TransactionTypeError::Missing)?; // 1 - let tx_type = tx_to_reth_tx(tx_type); - Ok(tx_type) + Ok(TxType::from(tx_type)) }