This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove `py_enum_name`, it was only used for `tx_type`. - Push down `tx_type` extraction into `py_tx`, it's only used there and is already included inside the `tx` argument. - Cast string `tx_type` into `TransactionType` as soon as possible. - Unify tx parsing logic under `py_tx` - Rename the arguments `py_tx` -> `tx` since `py_tx` shadows the function with the same name (also for consistency). - Add `From` to `Transaction`, for less verbose initialization. - Throw regular panic instead of `unimplemented!()` --- this was true in the past when we didn't implement all tx_types, but now that we do any value passed from Python that is not in the match is a bug. Co-Authored-By: Gilad Chase <[email protected]>
- Loading branch information
1 parent
9a69c3e
commit 94ee1a7
Showing
9 changed files
with
63 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
use std::str::FromStr; | ||
|
||
use serde::Deserialize; | ||
use strum_macros::EnumIter; | ||
|
||
use crate::transaction::errors::ParseError; | ||
|
||
#[derive(Clone, Copy, Debug, Deserialize, EnumIter, Eq, Hash, PartialEq)] | ||
pub enum TransactionType { | ||
Declare, | ||
DeployAccount, | ||
InvokeFunction, | ||
L1Handler, | ||
} | ||
|
||
impl FromStr for TransactionType { | ||
type Err = ParseError; | ||
|
||
fn from_str(tx_type: &str) -> Result<Self, Self::Err> { | ||
match tx_type { | ||
"Declare" | "DECLARE" => Ok(TransactionType::Declare), | ||
"DeployAccount" | "DEPLOY_ACCOUNT" => Ok(TransactionType::DeployAccount), | ||
"InvokeFunction" | "INVOKE_FUNCTION" => Ok(TransactionType::InvokeFunction), | ||
"L1Handler" | "L1_HANDLER" => Ok(TransactionType::L1Handler), | ||
unknown_tx_type => Err(ParseError::UnknownTransactionType(unknown_tx_type.to_string())), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters