Skip to content

Commit 022df26

Browse files
authored
Add event source (#809)
1 parent dcbfbe5 commit 022df26

File tree

2 files changed

+7
-2
lines changed
  • ethcontract-mock/src/details
  • ethcontract/src/contract/event

2 files changed

+7
-2
lines changed

ethcontract-mock/src/details/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct MockTransportState {
6464
receipts: HashMap<H256, TransactionReceipt>,
6565
}
6666

67+
#[allow(clippy::type_complexity)]
6768
impl MockTransport {
6869
/// Creates a new transport.
6970
pub fn new(chain_id: u64) -> Self {
@@ -1007,7 +1008,7 @@ impl<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static> ExpectationApi
10071008
}
10081009
}
10091010

1010-
#[allow(clippy::enum_variant_names)]
1011+
#[allow(clippy::enum_variant_names, clippy::type_complexity)]
10111012
enum Predicate<P: Tokenize + Send + 'static> {
10121013
None,
10131014
Predicate(Box<dyn predicates::Predicate<P> + Send>),
@@ -1026,6 +1027,7 @@ impl<P: Tokenize + Send + 'static> Predicate<P> {
10261027
}
10271028
}
10281029

1030+
#[allow(clippy::type_complexity)]
10291031
enum Returns<P: Tokenize + Send + 'static, R: Tokenize + Send + 'static> {
10301032
Default,
10311033
Error(String),

ethcontract/src/contract/event/data.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Module contains code for parsing and manipulating event data.
22
use crate::{errors::ExecutionError, tokens::Tokenize};
33
use ethcontract_common::abi::{Event as AbiEvent, RawLog as AbiRawLog, Token};
4-
use web3::types::{Log, H256};
4+
use web3::types::{Log, H160, H256};
55

66
/// A contract event
77
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -125,6 +125,8 @@ impl<T> Event<EventStatus<T>> {
125125
/// Additional metadata from the log for the event.
126126
#[derive(Clone, Debug, Eq, PartialEq)]
127127
pub struct EventMetadata {
128+
/// From which this event originated from
129+
pub address: H160,
128130
/// The hash of the block where the log was produced.
129131
pub block_hash: H256,
130132
/// The number of the block where the log was produced.
@@ -146,6 +148,7 @@ pub struct EventMetadata {
146148
impl EventMetadata {
147149
fn from_log(log: &Log) -> Option<Self> {
148150
Some(EventMetadata {
151+
address: log.address,
149152
block_hash: log.block_hash?,
150153
block_number: log.block_number?.as_u64(),
151154
transaction_hash: log.transaction_hash?,

0 commit comments

Comments
 (0)