Retrieve event ABI from Contract instance in process_events()

This commit is contained in:
silverpill 2022-01-26 23:16:38 +00:00
parent a3f20149cf
commit fd0c7edb59

View file

@ -6,7 +6,7 @@ use uuid::Uuid;
use web3::{ use web3::{
api::Web3, api::Web3,
contract::{Contract, Options}, contract::{Contract, Options},
ethabi::{Event, EventParam, ParamType, RawLog, token::Token}, ethabi::{RawLog, token::Token},
transports::Http, transports::Http,
types::{BlockNumber, FilterBuilder, H256}, types::{BlockNumber, FilterBuilder, H256},
}; };
@ -95,28 +95,7 @@ pub async fn process_events(
); );
// Search for Transfer events // Search for Transfer events
let event_abi_params = vec![ let event_abi = contract.abi().event("Transfer")?;
EventParam {
name: "from".to_string(),
kind: ParamType::Address,
indexed: true,
},
EventParam {
name: "to".to_string(),
kind: ParamType::Address,
indexed: true,
},
EventParam {
name: "tokenId".to_string(),
kind: ParamType::Uint(256),
indexed: true,
},
];
let event_abi = Event {
name: "Transfer".to_string(),
inputs: event_abi_params,
anonymous: false,
};
let filter = FilterBuilder::default() let filter = FilterBuilder::default()
.address(vec![contract.address()]) .address(vec![contract.address()])
.topics(Some(vec![event_abi.signature()]), None, None, None) .topics(Some(vec![event_abi.signature()]), None, None, None)