diff --git a/tools/compiler/src/processor.rs b/tools/compiler/src/processor.rs index 2f47c06..8bd585a 100644 --- a/tools/compiler/src/processor.rs +++ b/tools/compiler/src/processor.rs @@ -1,6 +1,5 @@ use anyhow::anyhow; use std::collections::BTreeMap; -use std::collections::HashMap; use std::fs; use std::path::Path; use tracing::instrument; @@ -103,7 +102,6 @@ pub fn generate_registry() -> AppResult<()> { pub fn transport_metadata_along_channel( ibc_data: &IbcInput, source_asset: Metadata, - priority_scores_by_base: &HashMap, ) -> AppResult { // The `Metadata` structure doesn't allow modifying the internals, so drop to raw proto data let mut pb_metadata: pb::Metadata = source_asset.into(); @@ -126,11 +124,6 @@ pub fn transport_metadata_along_channel( // Without this, decoding will fail because the asset ID won't match. pb_metadata.penumbra_asset_id = None; - // Add priority score if available - if let Some(score) = priority_scores_by_base.get(&pb_metadata.base) { - pb_metadata.priority_score = *score; - } - tracing::trace!(?pb_metadata, "new"); Ok(Metadata::try_from(pb_metadata)?) } @@ -152,14 +145,6 @@ fn process_chain_config(chain_config: ChainConfig) -> AppResult { all_metadata.extend(generate_metadata_from_validators(&chain_config.validators)?); all_metadata.extend(chain_config.native_assets.clone()); - for metadata in &mut all_metadata { - if let Some(score) = chain_config.priority_scores_by_base.get(&metadata.base_denom().denom) { - let mut pb_metadata: pb::Metadata = metadata.clone().into(); - pb_metadata.priority_score = *score; - *metadata = Metadata::try_from(pb_metadata)?; - } - } - // For each ibc connection, grab all metadata of native assets from the cosmos registry for ibc_input in &chain_config.ibc_connections { let assetlist_path = Path::new(LOCAL_COSMOS_REGISTRY_DIR) @@ -182,12 +167,20 @@ fn process_chain_config(chain_config: ChainConfig) -> AppResult { let transferred_asset = transport_metadata_along_channel( ibc_input, source_asset_metadata, - &chain_config.priority_scores_by_base, )?; all_metadata.push(transferred_asset); } } + // add priority score if available + for metadata in &mut all_metadata { + if let Some(score) = chain_config.priority_scores_by_base.get(&metadata.base_denom().denom) { + let mut pb_metadata: pb::Metadata = metadata.clone().into(); + pb_metadata.priority_score = *score; + *metadata = Metadata::try_from(pb_metadata)?; + } + } + Ok(Registry { chain_id: chain_config.chain_id, ibc_connections: chain_config