Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix evm logs addr check #204

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added evm_route.did
Empty file.
9 changes: 5 additions & 4 deletions route/bitfinity/src/evm_scan.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::str::FromStr;
use anyhow::anyhow;
use did::{TransactionReceipt, transaction::TransactionReceiptLog, H160};
use did::{TransactionReceipt, transaction::TransactionReceiptLog};
use ethers_core::abi::RawLog;
use ethers_core::utils::hex::ToHexExt;
use ic_canister_log::log;
use ic_stable_structures::Storable;
use itertools::Itertools;

use omnity_types::{ChainState, Directive, Ticket, ChainId, Memo};
Expand All @@ -17,7 +15,6 @@ use crate::contract_types::{
TokenBurned, TokenMinted, TokenTransportRequested,
};
use crate::convert::{ticket_from_burn_event, ticket_from_runes_mint_event, ticket_from_transport_event};
use crate::eth_common::EvmAddress;
use crate::state::{mutate_state, read_state, bitfinity_get_redeem_fee};

pub fn scan_evm_task() {
Expand Down Expand Up @@ -86,7 +83,11 @@ pub fn scan_evm_task() {
}

pub async fn handle_port_events(logs: Vec<TransactionReceiptLog>) -> anyhow::Result<()> {
let port = read_state(|s|s.omnity_port_contract.clone());
for l in logs {
if l.address.to_hex_str() != port.to_hex() {
continue;
}
if l.removed {
return Err(anyhow!("log is removed"));
}
Expand Down
13 changes: 9 additions & 4 deletions route/evm/src/evm_scan.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::anyhow;
use cketh_common::address::Address;
use cketh_common::eth_rpc::Hash;
use cketh_common::eth_rpc::LogEntry;
use ethers_core::abi::RawLog;
Expand Down Expand Up @@ -84,7 +85,11 @@ pub async fn sync_mint_status(hash: String) {
}

pub async fn handle_port_events(logs: Vec<LogEntry>) -> anyhow::Result<()> {
let port = read_state(|s| s.omnity_port_contract.clone());
for l in logs {
if l.address.to_string() != port.to_hex() {
continue;
}
if l.removed {
return Err(anyhow!("log is removed"));
}
Expand Down Expand Up @@ -301,8 +306,8 @@ pub fn get_memo(memo: Option<String>, dst_chain: ChainId) -> Option<String> {
memo,
bridge_fee: fee.unwrap_or_default() as u128,
}
.convert_to_memo_json()
.unwrap_or_default();
.convert_to_memo_json()
.unwrap_or_default();
Some(memo_json)
}

Expand All @@ -317,8 +322,8 @@ mod evm_route_test {
memo,
bridge_fee: 999_u128,
}
.convert_to_memo_json()
.unwrap_or_default();
.convert_to_memo_json()
.unwrap_or_default();
Some(memo_json)
}

Expand Down