Skip to content

Commit

Permalink
Remove async_trait redundancies
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurshsmith committed Apr 20, 2024
1 parent 30fd50a commit 73d5a14
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::states::Nft;

pub struct TransferHandler;

#[chaindexing::augmenting_std::async_trait::async_trait]
#[chaindexing::augmenting_std::async_trait]
impl EventHandler for TransferHandler {
fn abi(&self) -> &'static str {
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
Expand Down
4 changes: 2 additions & 2 deletions chaindexing-tests/src/factory/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub struct NftState;

pub struct TransferTestHandler;

#[chaindexing::augmenting_std::async_trait::async_trait]
#[chaindexing::augmenting_std::async_trait]
impl EventHandler for TransferTestHandler {
fn abi(&self) -> &'static str {
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
Expand All @@ -15,7 +15,7 @@ impl EventHandler for TransferTestHandler {

pub struct ApprovalForAllTestHandler;

#[chaindexing::augmenting_std::async_trait::async_trait]
#[chaindexing::augmenting_std::async_trait]
impl EventHandler for ApprovalForAllTestHandler {
fn abi(&self) -> &'static str {
"event ApprovalForAll(address indexed owner, address indexed operator, bool approved)"
Expand Down
8 changes: 4 additions & 4 deletions chaindexing-tests/src/factory/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rand::seq::SliceRandom;
pub fn empty_provider() -> impl IngesterProvider {
#[derive(Clone)]
struct Provider;
#[chaindexing::augmenting_std::async_trait::async_trait]
#[chaindexing::augmenting_std::async_trait]
impl IngesterProvider for Provider {
async fn get_block_number(&self) -> Result<U64, ProviderError> {
Ok(U64::from(0))
Expand Down Expand Up @@ -79,7 +79,7 @@ macro_rules! provider_with_logs {
struct Provider {
contract_address: String,
}
#[chaindexing::augmenting_std::async_trait::async_trait]
#[chaindexing::augmenting_std::async_trait]
impl IngesterProvider for Provider {
async fn get_block_number(&self) -> Result<U64, ProviderError> {
Ok(U64::from($current_block_number))
Expand Down Expand Up @@ -112,7 +112,7 @@ macro_rules! provider_with_filter_stubber {

#[derive(Clone)]
struct Provider;
#[chaindexing::augmenting_std::async_trait::async_trait]
#[chaindexing::augmenting_std::async_trait]
impl IngesterProvider for Provider {
async fn get_block_number(&self) -> Result<U64, ProviderError> {
Ok(U64::from(3))
Expand Down Expand Up @@ -147,7 +147,7 @@ macro_rules! provider_with_empty_logs {

#[derive(Clone)]
struct Provider;
#[chaindexing::augmenting_std::async_trait::async_trait]
#[chaindexing::augmenting_std::async_trait]
impl IngesterProvider for Provider {
async fn get_block_number(&self) -> Result<U64, ProviderError> {
Ok(U64::from(3))
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/augmenting_std.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[doc(hidden)]
pub use async_trait;
pub use async_trait::async_trait;

#[doc(hidden)]
pub use serde;
2 changes: 1 addition & 1 deletion chaindexing/src/handlers/pure_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::handler_context::HandlerContext;

/// Pure handlers do not contain any side effects. They are simple reducers
/// that derive or index states deterministically.
#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait PureHandler: Send + Sync {
/// The human-readable ABI of the event being handled.
/// For example, Uniswap's PoolCreated event's abi is:
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/handlers/side_effect_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::handler_context::HandlerContext;
/// that the side-effect handlers are called once immutably regardless of resets.
/// However, one can dangerously reset including side effects with the `reset_including_side_effects`
/// exposed in the Config API.
#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait SideEffectHandler: Send + Sync {
type SharedState: Send + Sync + Clone + Debug;

Expand Down
4 changes: 2 additions & 2 deletions chaindexing/src/ingester/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::filters::Filter;

pub type ProviderError = EthersProviderError;

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait Provider: Clone + Sync + Send {
async fn get_block_number(&self) -> Result<U64, ProviderError>;
async fn get_logs(&self, filter: &EthersFilter) -> Result<Vec<Log>, ProviderError>;
Expand Down Expand Up @@ -50,7 +50,7 @@ pub trait Provider: Clone + Sync + Send {
}
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
impl Provider for EthersProvider<Http> {
async fn get_block_number(&self) -> Result<U64, ProviderError> {
Middleware::get_block_number(&self).await
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn get_tasks_runner<S: Sync + Send + Debug + Clone + 'static>(
struct ChaindexingNodeTasksRunner<'a, S: Send + Sync + Clone + Debug + 'static> {
config: &'a Config<S>,
}
#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
impl<'a, S: Send + Sync + Clone + Debug + 'static> NodeTasksRunner
for ChaindexingNodeTasksRunner<'a, S>
{
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/nodes/node_tasks_runner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::node_task::NodeTask;

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait NodeTasksRunner {
async fn run(&self) -> Vec<NodeTask>;
}
2 changes: 1 addition & 1 deletion chaindexing/src/repos/postgres_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl PostgresRepo {
}
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
impl Repo for PostgresRepo {
type Conn<'a> = PgPooledConn<'a>;
type Pool = bb8::Pool<AsyncDieselConnectionManager<AsyncPgConnection>>;
Expand Down
6 changes: 3 additions & 3 deletions chaindexing/src/repos/postgres_repo/raw_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::de::DeserializeOwned;
pub type PostgresRepoClient = Client;
pub type PostgresRepoTxnClient<'a> = Transaction<'a>;

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
impl HasRawQueryClient for PostgresRepo {
type RawQueryClient = Client;
type RawQueryTxnClient<'a> = Transaction<'a>;
Expand All @@ -29,7 +29,7 @@ impl HasRawQueryClient for PostgresRepo {
}
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
impl ExecutesWithRawQuery for PostgresRepo {
async fn execute(client: &Self::RawQueryClient, query: &str) {
client.execute(query, &[] as &[&(dyn ToSql + Sync)]).await.unwrap();
Expand Down Expand Up @@ -206,7 +206,7 @@ impl ExecutesWithRawQuery for PostgresRepo {
}
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
impl LoadsDataWithRawQuery for PostgresRepo {
async fn create_and_load_new_node(client: &Self::RawQueryClient) -> Node {
Self::load_data(
Expand Down
10 changes: 5 additions & 5 deletions chaindexing/src/repos/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum RepoError {
Unknown(String),
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait Repo:
Sync + Send + Migratable + ExecutesWithRawQuery + LoadsDataWithRawQuery + Clone + Debug
{
Expand Down Expand Up @@ -69,7 +69,7 @@ pub trait Repo:
async fn keep_node_active<'a>(conn: &mut Self::Conn<'a>, node: &Node);
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait HasRawQueryClient {
type RawQueryClient: Send + Sync;
type RawQueryTxnClient<'a>: Send + Sync;
Expand All @@ -80,7 +80,7 @@ pub trait HasRawQueryClient {
) -> Self::RawQueryTxnClient<'a>;
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait ExecutesWithRawQuery: HasRawQueryClient {
async fn execute(client: &Self::RawQueryClient, query: &str);
async fn execute_in_txn<'a>(client: &Self::RawQueryTxnClient<'a>, query: &str);
Expand Down Expand Up @@ -127,7 +127,7 @@ pub trait ExecutesWithRawQuery: HasRawQueryClient {
async fn prune_root_states(client: &Self::RawQueryClient, retain_size: u64);
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait LoadsDataWithRawQuery: HasRawQueryClient {
async fn create_and_load_new_node(client: &Self::RawQueryClient) -> Node;
async fn load_last_root_state(client: &Self::RawQueryClient) -> Option<root::State>;
Expand Down Expand Up @@ -196,7 +196,7 @@ pub trait RepoMigrations: Migratable {
}
}

#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait Migratable: ExecutesWithRawQuery + Sync + Send {
async fn migrate(client: &Self::RawQueryClient, migrations: Vec<impl AsRef<str> + Send + Sync>)
where
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/states/chain_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::de::DeserializeOwned;
use serde::Serialize;

/// States derived from different contracts within a chain
#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait ChainState: DeserializeOwned + Serialize + Clone + Debug + Sync + Send + 'static {
/// Table of the state as specified in StateMigrations
fn table_name() -> &'static str;
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/states/contract_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::de::DeserializeOwned;
use serde::Serialize;

/// States derived from a contract
#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait ContractState:
DeserializeOwned + Serialize + Clone + Debug + Sync + Send + 'static
{
Expand Down
2 changes: 1 addition & 1 deletion chaindexing/src/states/multi_chain_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::Serialize;

/// States derived from different contracts across different chains
/// N/B: Indexing MultiChainStates must be Order-Agnostic
#[crate::augmenting_std::async_trait::async_trait]
#[crate::augmenting_std::async_trait]
pub trait MultiChainState:
DeserializeOwned + Serialize + Clone + Debug + Sync + Send + 'static
{
Expand Down

0 comments on commit 73d5a14

Please sign in to comment.