diff --git a/Cargo.toml b/Cargo.toml index 112c29ba9c3..e3afcaaad07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -136,6 +136,7 @@ serde = { version = "1.0", default-features = false, features = [ ] } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } serde_with = "3.3.0" +serde_repr = "0.1" ## misc-testing arbitrary = "1.3" diff --git a/crates/rpc-types-trace/Cargo.toml b/crates/rpc-types-trace/Cargo.toml index 7181ff4755f..96728037279 100644 --- a/crates/rpc-types-trace/Cargo.toml +++ b/crates/rpc-types-trace/Cargo.toml @@ -25,6 +25,7 @@ alloy-serde.workspace = true serde.workspace = true serde_json.workspace = true +serde_repr.workspace = true thiserror.workspace = true [dev-dependencies] diff --git a/crates/rpc-types-trace/src/otterscan.rs b/crates/rpc-types-trace/src/otterscan.rs index d756b833a40..f30456aa99a 100644 --- a/crates/rpc-types-trace/src/otterscan.rs +++ b/crates/rpc-types-trace/src/otterscan.rs @@ -6,9 +6,11 @@ use alloy_primitives::{Address, Bloom, Bytes, TxHash, B256, U256}; use alloy_rpc_types_eth::{Block, Header, Rich, Transaction, TransactionReceipt, Withdrawal}; use serde::{Deserialize, Serialize}; +use serde_repr::{Deserialize_repr, Serialize_repr}; /// Operation type enum for `InternalOperation` struct -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize_repr, Deserialize_repr)] +#[repr(u8)] pub enum OperationType { /// Operation Transfer OpTransfer = 0, @@ -237,4 +239,15 @@ mod tests { let _receipt: OtsTransactionReceipt = serde_json::from_str(s).unwrap(); } + + #[test] + fn test_otterscan_interal_operation() { + let s = r#"{ + "type": 0, + "from": "0xea593b730d745fb5fe01b6d20e6603915252c6bf", + "to": "0xcc3d455481967dc97346ef1771a112d7a14c8f12", + "value": "0xee846f9305c00" + }"#; + let _op: InternalOperation = serde_json::from_str(s).unwrap(); + } }