Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
added from and to to Receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
ab320012 committed May 31, 2018
1 parent 00b209a commit 05cacdb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions rpc/src/v1/impls/light/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ impl<T: LightChainClient + 'static> Eth for EthClient<T> {
receipt.transaction_index = Some(index.into());
receipt.block_hash = Some(block_hash);
receipt.block_number = tx.block_number;
receipt.to = tx.to;
receipt.from = Some(tx.from);
receipt
})
.map(Some);
Expand Down
18 changes: 15 additions & 3 deletions rpc/src/v1/types/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ pub struct Receipt {
/// Block hash
#[serde(rename="blockHash")]
pub block_hash: Option<H256>,
/// Block number
/// Sender
pub from: Option<H160>,
/// Recipient
pub to: Option<H160>,
/// Block number
#[serde(rename="blockNumber")]
pub block_number: Option<U256>,
/// Cumulative gas used
Expand Down Expand Up @@ -73,7 +77,9 @@ impl Receipt {
impl From<LocalizedReceipt> for Receipt {
fn from(r: LocalizedReceipt) -> Self {
Receipt {
transaction_hash: Some(r.transaction_hash.into()),
from: None,
to: None,
transaction_hash: Some(r.transaction_hash.into()),
transaction_index: Some(r.transaction_index.into()),
block_hash: Some(r.block_hash.into()),
block_number: Some(r.block_number.into()),
Expand All @@ -91,6 +97,8 @@ impl From<LocalizedReceipt> for Receipt {
impl From<RichReceipt> for Receipt {
fn from(r: RichReceipt) -> Self {
Receipt {
from: None,
to: None,
transaction_hash: Some(r.transaction_hash.into()),
transaction_index: Some(r.transaction_index.into()),
block_hash: None,
Expand All @@ -109,7 +117,9 @@ impl From<RichReceipt> for Receipt {
impl From<EthReceipt> for Receipt {
fn from(r: EthReceipt) -> Self {
Receipt {
transaction_hash: None,
from: None,
to: None,
transaction_hash: None,
transaction_index: None,
block_hash: None,
block_number: None,
Expand All @@ -134,6 +144,8 @@ mod tests {
let s = r#"{"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","cumulativeGasUsed":"0x20","gasUsed":"0x10","contractAddress":null,"logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"data":"0x","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","logIndex":"0x1","transactionLogIndex":null,"type":"mined"}],"root":"0x000000000000000000000000000000000000000000000000000000000000000a","logsBloom":"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f","status":"0x1"}"#;

let receipt = Receipt {
from: None,
to: None,
transaction_hash: Some(0.into()),
transaction_index: Some(0.into()),
block_hash: Some("ed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5".parse().unwrap()),
Expand Down

0 comments on commit 05cacdb

Please sign in to comment.