Skip to content

Commit

Permalink
Support ContractCall instead of ContractCallWithToken
Browse files Browse the repository at this point in the history
  • Loading branch information
themicp committed Jan 18, 2024
1 parent c09bb5e commit 1a6f1f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions relayer/src/consumers/ethers_consumer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::types::{ContractCallWithToken, EnrichedLog, OperatorshipTransferred};
use crate::types::{ContractCall, EnrichedLog, OperatorshipTransferred};
use async_trait::async_trait;
use eth::execution::{EthExecutionAPI, ExecutionRPC};
use ethers::{
Expand All @@ -24,7 +24,7 @@ impl EthersConsumer {

async fn get_logs(&self, from_block: u64, to_block: u64) -> Result<Vec<EnrichedLog>> {
let signatures = vec![
"ContractCallWithToken(address,string,string,bytes32,bytes,string,uint256)",
"ContractCall(address,string,string,bytes32,bytes)",
"OperatorshipTransferred(bytes)",
];

Expand All @@ -38,8 +38,8 @@ impl EthersConsumer {

let mut enriched_logs = vec![];
for log in &logs {
let event_name = if parse_log::<ContractCallWithToken>(log.clone()).is_ok() {
"ContractCallWithToken"
let event_name = if parse_log::<ContractCall>(log.clone()).is_ok() {
"ContractCall"
} else if parse_log::<OperatorshipTransferred>(log.clone()).is_ok() {
"OperatorshipTransferred"
} else {
Expand Down
8 changes: 4 additions & 4 deletions relayer/src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::types::{ContractCallWithToken, EnrichedLog, OperatorshipTransferred};
use crate::types::{ContractCall, EnrichedLog, OperatorshipTransferred};
use consensus_types::{
common::{ContentVariant, PrimaryKey, WorkerSetMessage},
proofs::{CrossChainId, Message},
Expand All @@ -14,16 +14,16 @@ use prover::prover::types::EnrichedContent;

/// The driver function for parsing an enriched log into an enriched content.
/// This is the only place where we need to know about the different enriched log variants.
/// Currenlty we support only ContractCallWithToken events.
/// Currenlty we support only ContractCall and OperatorshipTransferred events.
pub fn parse_enriched_log(
enriched_log: &EnrichedLog,
block_details: &FullBlockDetails,
delivery_tag: u64,
) -> Result<EnrichedContent> {
let log = &enriched_log.log;
match enriched_log.event_name.as_str() {
"ContractCallWithToken" => {
let event: ContractCallWithToken = EthEvent::decode_log(&RawLog::from(log.clone()))
"ContractCall" => {
let event: ContractCall = EthEvent::decode_log(&RawLog::from(log.clone()))
.map_err(|e| eyre!("Error decoding log {:?}", e))?;
let message = Message {
cc_id: CrossChainId {
Expand Down
4 changes: 1 addition & 3 deletions relayer/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,14 @@ impl From<Config> for EthConfig {

// Events
#[derive(Debug, Clone, EthEvent, PartialEq)]
pub struct ContractCallWithToken {
pub struct ContractCall {
#[ethevent(indexed)]
pub sender: Address,
pub destination_chain: String,
pub destination_contract_address: String,
#[ethevent(indexed)]
pub payload_hash: H256,
pub payload: Bytes,
pub symbol: String,
pub amount: U256,
}

#[derive(Debug, Clone, EthEvent, PartialEq)]
Expand Down

0 comments on commit 1a6f1f7

Please sign in to comment.