From 04bbd1b424e4f447dfd6d9e2ecab904e17116709 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Tue, 13 Jul 2021 14:13:12 +0300 Subject: [PATCH] fix: make event types thread safe (#341) --- ethers-contract/src/event.rs | 2 +- ethers-contract/src/log.rs | 2 +- ethers-contract/src/stream.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ethers-contract/src/event.rs b/ethers-contract/src/event.rs index e013b461..38d8bb3d 100644 --- a/ethers-contract/src/event.rs +++ b/ethers-contract/src/event.rs @@ -9,7 +9,7 @@ use std::borrow::Cow; use std::marker::PhantomData; /// A trait for implementing event bindings -pub trait EthEvent: Detokenize { +pub trait EthEvent: Detokenize + Send + Sync { /// The name of the event this type represents fn name() -> Cow<'static, str>; diff --git a/ethers-contract/src/log.rs b/ethers-contract/src/log.rs index bfc54d53..cb538649 100644 --- a/ethers-contract/src/log.rs +++ b/ethers-contract/src/log.rs @@ -3,7 +3,7 @@ use ethers_core::abi::Error; use ethers_core::abi::RawLog; /// A trait for types (events) that can be decoded from a `RawLog` -pub trait EthLogDecode { +pub trait EthLogDecode: Send + Sync { /// decode from a `RawLog` fn decode_log(log: &RawLog) -> Result where diff --git a/ethers-contract/src/stream.rs b/ethers-contract/src/stream.rs index c8671902..b0385b0a 100644 --- a/ethers-contract/src/stream.rs +++ b/ethers-contract/src/stream.rs @@ -4,7 +4,7 @@ use pin_project::pin_project; use std::pin::Pin; use std::task::{Context, Poll}; -type MapEvent<'a, R, E> = Box Result + 'a>; +type MapEvent<'a, R, E> = Box Result + 'a + Send + Sync>; #[pin_project] /// Generic wrapper around Log streams, mapping their content to a specific