Skip to content

Commit

Permalink
Merge RawTransactionDetails into Transaction (tomusdrw#407)
Browse files Browse the repository at this point in the history
* Unify Transaction and RawTransactionDetails

* Fix test.

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
  • Loading branch information
3 people committed Feb 9, 2021
1 parent 9e80f89 commit 11277e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 54 deletions.
53 changes: 13 additions & 40 deletions src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ pub struct Transaction {
#[serde(rename = "transactionIndex")]
pub transaction_index: Option<Index>,
/// Sender
pub from: H160,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub from: Option<H160>,
/// Recipient (None when contract creation)
pub to: Option<H160>,
/// Transfered value
Expand All @@ -30,8 +31,17 @@ pub struct Transaction {
pub gas: U256,
/// Input data
pub input: Bytes,
/// ECDSA recovery id
#[serde(default, skip_serializing_if = "Option::is_none")]
pub v: Option<U64>,
/// ECDSA signature r, 32 bytes
#[serde(default, skip_serializing_if = "Option::is_none")]
pub r: Option<U256>,
/// ECDSA signature s, 32 bytes
#[serde(default, skip_serializing_if = "Option::is_none")]
pub s: Option<U256>,
/// Raw transaction data
#[serde(default)]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub raw: Option<Bytes>,
}

Expand Down Expand Up @@ -78,44 +88,7 @@ pub struct RawTransaction {
/// Signed transaction as raw bytes
pub raw: Bytes,
/// Transaction details
pub tx: RawTransactionDetails,
}

/// Details of a signed transaction
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
pub struct RawTransactionDetails {
/// Hash
pub hash: H256,
/// Nonce
pub nonce: U256,
/// Block hash. None when pending.
#[serde(rename = "blockHash")]
pub block_hash: Option<H256>,
/// Block number. None when pending.
#[serde(rename = "blockNumber")]
pub block_number: Option<U64>,
/// Transaction Index. None when pending.
#[serde(rename = "transactionIndex")]
pub transaction_index: Option<Index>,
/// Sender
pub from: Option<H160>,
/// Recipient (None when contract creation)
pub to: Option<H160>,
/// Transfered value
pub value: U256,
/// Gas Price
#[serde(rename = "gasPrice")]
pub gas_price: U256,
/// Gas amount
pub gas: U256,
/// Input data
pub input: Bytes,
/// ECDSA recovery id, set by Geth
pub v: Option<U64>,
/// ECDSA signature r, 32 bytes, set by Geth
pub r: Option<U256>,
/// ECDSA signature s, 32 bytes, set by Geth
pub s: Option<U256>,
pub tx: Transaction,
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 11277e0

Please sign in to comment.