[receipt]: add sender & receiver to RichReceipts (#11179)

* [receipts]: add `to` & `from` to `RichReceipts`

* [rpc]: add test for `pending_receipt`

* docs(common_types/receipt): add note Option field
This commit is contained in:
Niklas Adolfsson
2019-10-18 18:12:02 +02:00
committed by GitHub
parent 2d2513b35a
commit c8b4373e13
5 changed files with 50 additions and 7 deletions

View File

@@ -1236,6 +1236,11 @@ impl miner::MinerService for Miner {
let prev_gas = if index == 0 { Default::default() } else { receipts[index - 1].gas_used };
let receipt = &receipts[index];
RichReceipt {
from: tx.sender(),
to: match tx.action {
Action::Create => None,
Action::Call(ref address) => Some(*address),
},
transaction_hash: tx.hash(),
transaction_index: index,
cumulative_gas_used: receipt.gas_used,

View File

@@ -122,6 +122,7 @@ pub struct RichReceipt {
/// The gas used in the execution of the transaction. Note the difference of meaning to `Receipt::gas_used`.
pub gas_used: U256,
/// Contract address.
/// NOTE: It is an Option because only `Action::Create` transactions has a contract address
pub contract_address: Option<Address>,
/// Logs
pub logs: Vec<LogEntry>,
@@ -129,6 +130,11 @@ pub struct RichReceipt {
pub log_bloom: Bloom,
/// Transaction outcome.
pub outcome: TransactionOutcome,
/// Receiver address
/// NOTE: It is an Option because only `Action::Call` transactions has a receiver address
pub to: Option<H160>,
/// Sender
pub from: H160
}
/// Receipt with additional info.
@@ -147,6 +153,7 @@ pub struct LocalizedReceipt {
/// The gas used in the execution of the transaction. Note the difference of meaning to `Receipt::gas_used`.
pub gas_used: U256,
/// Contract address.
/// NOTE: It is an Option because only `Action::Create` transactions has a contract address
pub contract_address: Option<Address>,
/// Logs
pub logs: Vec<LocalizedLogEntry>,
@@ -155,6 +162,7 @@ pub struct LocalizedReceipt {
/// Transaction outcome.
pub outcome: TransactionOutcome,
/// Receiver address
/// NOTE: It is an Option because only `Action::Call` transactions has a receiver address
pub to: Option<H160>,
/// Sender
pub from: H160