Skip to content

Commit

Permalink
Fix: scanner error. (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssuangchen authored Oct 31, 2023
1 parent d272fa5 commit a23b9b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions scanner/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,18 @@ impl RPCCaller {
let hasher = sha2::Sha256::digest(&bytes);
let tx_hash = hex::encode(hasher);
let tx = self.rpc.load_transaction(&tx_hash).await?;
let result = serde_json::to_value(tx.tx_result.clone()).unwrap();
let mut result_tmp = tx.tx_result.clone();
if !result_tmp.log.is_empty() {
let mut trim_log: Vec<u8> = vec![];
let log_bytes = result_tmp.log.as_bytes();
for b in log_bytes {
if *b > 31 {
trim_log.push(*b);
}
}
result_tmp.log = String::from_utf8_lossy(&trim_log).parse().unwrap();
}
let result = serde_json::to_value(&result_tmp).unwrap();

match tx::try_tx_catalog(&bytes) {
tx::TxCatalog::EvmTx => {
Expand Down Expand Up @@ -269,7 +280,7 @@ impl RPCCaller {
ty_sub,
sender: sender.clone(),
receiver: receivers_val,
log: tx.tx_result.log,
log: result_tmp.log,
origin,
result,
value: v,
Expand Down Expand Up @@ -531,7 +542,7 @@ impl RPCCaller {
ty_sub,
sender: sender.clone(),
receiver: receivers_val,
log: tx.tx_result.log,
log: result_tmp.log,
origin,
result,
value,
Expand Down
2 changes: 1 addition & 1 deletion scanner/src/tx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{Error, Result};

pub const EVM_TX_TAG: [u8; 4] = [0x65, 0x76, 0x6d, 0x3a];
pub const EVM_TX_TAG: [u8; 4] = [0x65, 0x76, 0x6d, 0x3a]; // 101 118 109 58

pub fn unwrap(tx: &[u8]) -> Result<&[u8]> {
let len = EVM_TX_TAG.len();
Expand Down

0 comments on commit a23b9b1

Please sign in to comment.