refactor: Clean code and update cargo.lock

This commit is contained in:
Florian Pellissier
2024-07-12 15:42:55 +02:00
parent 10a36c0a9b
commit ec6e16f465
3 changed files with 5 additions and 12 deletions

4
substreams/Cargo.lock generated
View File

@@ -1097,10 +1097,12 @@ dependencies = [
[[package]]
name = "tycho-substreams"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"ethabi 18.0.0",
"hex",
"itertools 0.12.1",
"num-bigint",
"prost 0.11.9",
"substreams",
"substreams-ethereum",

View File

@@ -212,12 +212,7 @@ pub fn extract_balance_deltas_from_tx<F: Fn(&[u8], &[u8]) -> bool>(
let mut create_balance_delta = |transactor: &[u8], delta: BigInt| {
balance_deltas.push(BalanceDelta {
ord: log.ordinal,
tx: Some(Transaction {
to: tx.to.clone(),
from: tx.from.clone(),
hash: tx.hash.clone(),
index: tx.index.into(),
}),
tx: Some(tx.into()),
token: log.address.clone(),
delta: delta.to_signed_bytes_be(),
component_id: hex::encode(transactor).into(),

View File

@@ -117,11 +117,7 @@ pub fn map_relative_balances(
let pool_key = format!("pool:{}", hex::encode(transactor));
if let Some(tokens) = tokens_store.get_last(pool_key) {
let token_id = hex::encode(token);
tokens
.split(":")
.map(|token| token.to_owned())
.collect::<Vec<_>>()
.contains(&token_id)
tokens.split(':').any(|t| t == token_id)
} else {
false
}