From 1cdf73860ded83e44897c6b2c641f4d15b5509b7 Mon Sep 17 00:00:00 2001 From: Santiago Carmuega Date: Thu, 26 Jan 2023 20:27:29 +0100 Subject: [PATCH] fix: Adjust breaking changes from Pallas v0.17 (#123) --- src/reducers/address_by_asset.rs | 14 +++++++------- src/reducers/utxos_by_asset.rs | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/reducers/address_by_asset.rs b/src/reducers/address_by_asset.rs index 4a5bb03a..3eb7e017 100644 --- a/src/reducers/address_by_asset.rs +++ b/src/reducers/address_by_asset.rs @@ -21,13 +21,13 @@ pub struct Reducer { impl Reducer { fn to_string_output(&self, asset: Asset) -> Option { match asset.policy_hex() { - Some(policy_id) if policy_id.eq(&self.config.policy_id_hex) => { - if self.convert_to_ascii { - asset.ascii_name() - } else { - asset.name() - } - } + Some(policy_id) if policy_id.eq(&self.config.policy_id_hex) => match asset { + Asset::NativeAsset(_, name, _) => match self.convert_to_ascii { + true => String::from_utf8(name).ok(), + false => Some(hex::encode(name)), + }, + _ => None, + }, _ => None, } } diff --git a/src/reducers/utxos_by_asset.rs b/src/reducers/utxos_by_asset.rs index 25b70600..01f27a7a 100644 --- a/src/reducers/utxos_by_asset.rs +++ b/src/reducers/utxos_by_asset.rs @@ -1,3 +1,5 @@ +use std::str::FromStr; + use gasket::error::AsWorkError; use pallas::crypto::hash::Hash; use pallas::ledger::traverse::Asset; @@ -36,7 +38,7 @@ impl Reducer { output: &mut super::OutputPort, ) -> Result<(), gasket::error::Error> { if !self.is_policy_id_accepted(&policy) { - return (); + return Ok(()); } let tx_hash = tx.hash(); let prefix = self.config.key_prefix.as_deref();