diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2022-05-31 21:18:36 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2022-05-31 21:18:36 +0200 |
| commit | 7517ff3454a1d3c8811d1eb8d8be8cef23aba001 (patch) | |
| tree | ce673b61a89c06a5c26a0b980e27c3e53d3ce8aa /src/transaction/legacy.rs | |
| parent | c5d2ec6c93a40af460e35d9171dd7966e97a0c75 (diff) | |
Hash more types
Diffstat (limited to 'src/transaction/legacy.rs')
| -rw-r--r-- | src/transaction/legacy.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/transaction/legacy.rs b/src/transaction/legacy.rs index 9e0f9bc..231d9f8 100644 --- a/src/transaction/legacy.rs +++ b/src/transaction/legacy.rs @@ -1,10 +1,7 @@ //! Legacy Ethereum transaction type definition and RLP encoding. -use crate::{ - account::{Address, Signature}, - serialization, - transaction::rlp, -}; +use crate::{account::Signature, serialization, transaction::rlp}; +use ethaddr::Address; use ethnum::U256; use serde::Deserialize; @@ -12,25 +9,25 @@ use serde::Deserialize; #[derive(Clone, Debug, Deserialize, PartialEq)] pub struct LegacyTransaction { /// The nonce for the transaction. - #[serde(with = "serialization::u256")] + #[serde(with = "ethnum::serde::permissive")] pub nonce: U256, /// The gas price in Wei for the transaction. - #[serde(rename = "gasPrice", with = "serialization::u256")] + #[serde(rename = "gasPrice", with = "ethnum::serde::permissive")] pub gas_price: U256, /// The gas limit for the transaction. - #[serde(with = "serialization::u256")] + #[serde(with = "ethnum::serde::permissive")] pub gas: U256, /// The target address for the transaction. This can also be `None` to /// indicate a contract creation transaction. pub to: Option<Address>, /// The amount of Ether to send with the transaction. - #[serde(with = "serialization::u256")] + #[serde(with = "ethnum::serde::permissive")] pub value: U256, /// The calldata to use for the transaction. #[serde(with = "serialization::bytes")] pub data: Vec<u8>, /// Optional chain ID for the transaction. - #[serde(default, rename = "chainId", with = "serialization::u256::option")] + #[serde(default, rename = "chainId", with = "serialization::numopt")] pub chain_id: Option<U256>, } @@ -59,6 +56,7 @@ impl LegacyTransaction { #[cfg(test)] mod tests { use super::*; + use ethaddr::address; use ethnum::AsU256 as _; use hex_literal::hex; use serde_json::json; @@ -92,7 +90,7 @@ mod tests { .unwrap() .to .unwrap(), - Address(hex!("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef")), + address!("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF"), ); } @@ -104,7 +102,7 @@ mod tests { nonce: 66.as_u256(), gas_price: 42e9.as_u256(), gas: 30_000.as_u256(), - to: Some(Address(hex!("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"))), + to: Some(address!("0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF")), value: 13.37e18.as_u256(), data: vec![], } |
