Skip to content

Commit

Permalink
chore: review fixes rollback to retain for asset filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Vovke committed Nov 8, 2024
1 parent 2ef24e9 commit 307fde6
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/chain/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,28 @@ impl ChainWatcher {
&chain.asset
);
// Remove unwanted assets
assets = assets
.into_iter()
.filter_map(|(asset_name, properties)| {
tracing::info!(
"chain {} has token {} with properties {:?}",
&chain.name,
&asset_name,
&properties
);
assets.retain(|asset_name, properties| {
tracing::info!(
"chain {} has token {} with properties {:?}",
&chain.name,
asset_name,
properties
);

if let Some(ref native_token) = chain.native_token {
(native_token.name == *asset_name) && (native_token.decimals == specs.decimals)
} else {
chain
.asset
.iter()
.find(|a| a.name == asset_name && Some(a.id) == properties.asset_id)
.map(|a| (a.name.clone(), properties))
})
.collect();
.any(|a| a.name == *asset_name && Some(a.id) == properties.asset_id)
}
});

if let Some(native_token) = chain.native_token.clone() {
if let Some(ref native_token) = chain.native_token {
if native_token.decimals == specs.decimals {
assets.insert(
native_token.name,
native_token.name.clone(),
CurrencyProperties {
chain_name: name.clone(),
kind: TokenKind::Native,
Expand Down Expand Up @@ -356,3 +356,4 @@ impl ChainWatcher {
Ok(chain)
}
}

0 comments on commit 307fde6

Please sign in to comment.