Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix byron address string representation #530

Merged
merged 2 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/mapper/babbage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,10 @@ impl EventWriter {
let record = self.to_post_alonzo_output_record(output)?;
self.append(record.into())?;

let address = pallas::ledger::addresses::Address::from_bytes(&output.address)?;

let child = &self.child_writer(EventContext {
output_address: self
.utils
.bech32
.encode_address(output.address.as_slice())?
.into(),
output_address: address.to_string().into(),
..EventContext::default()
});

Expand Down
14 changes: 6 additions & 8 deletions src/mapper/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ impl EventWriter {
&self,
output: &alonzo::TransactionOutput,
) -> Result<TxOutputRecord, Error> {
let address = pallas::ledger::addresses::Address::from_bytes(&output.address)?;

Ok(TxOutputRecord {
address: self
.utils
.bech32
.encode_address(output.address.as_slice())?,
address: address.to_string(),
amount: get_tx_output_coin_value(&output.amount),
assets: self.collect_asset_records(&output.amount).into(),
datum_hash: output.datum_hash.map(|hash| hash.to_string()),
Expand All @@ -183,11 +182,10 @@ impl EventWriter {
&self,
output: &babbage::PostAlonzoTransactionOutput,
) -> Result<TxOutputRecord, Error> {
let address = pallas::ledger::addresses::Address::from_bytes(&output.address)?;

Ok(TxOutputRecord {
address: self
.utils
.bech32
.encode_address(output.address.as_slice())?,
address: address.to_string(),
amount: get_tx_output_coin_value(&output.value),
assets: self.collect_asset_records(&output.value).into(),
datum_hash: match &output.datum_option {
Expand Down
8 changes: 3 additions & 5 deletions src/mapper/shelley.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,10 @@ impl EventWriter {
let record = self.to_legacy_output_record(output)?;
self.append(record.into())?;

let address = pallas::ledger::addresses::Address::from_bytes(&output.address)?;

let child = &self.child_writer(EventContext {
output_address: self
.utils
.bech32
.encode_address(output.address.as_slice())?
.into(),
output_address: address.to_string().into(),
..EventContext::default()
});

Expand Down
68 changes: 0 additions & 68 deletions src/utils/bech32.rs

This file was deleted.

11 changes: 1 addition & 10 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,14 @@ pub const PREVIEW_MAGIC: u64 = 2;

use serde::{Deserialize, Serialize};

use crate::{
model::Event,
utils::{
bech32::{Bech32Config, Bech32Provider},
time::NaiveProvider as NaiveTime,
},
};
use crate::{model::Event, utils::time::NaiveProvider as NaiveTime};

use crate::Error;

pub mod cursor;
pub mod metrics;
pub mod throttle;

pub(crate) mod bech32;
pub(crate) mod retry;
pub(crate) mod time;

Expand Down Expand Up @@ -174,7 +167,6 @@ impl Default for ChainWellKnownInfo {
pub struct Utils {
pub(crate) well_known: ChainWellKnownInfo,
pub(crate) time: Option<NaiveTime>,
pub(crate) bech32: Bech32Provider,
pub(crate) cursor: Option<cursor::Provider>,
pub(crate) metrics: Option<metrics::Provider>,
}
Expand All @@ -184,7 +176,6 @@ impl Utils {
pub fn new(well_known: ChainWellKnownInfo) -> Self {
Self {
time: NaiveTime::new(well_known.clone()).into(),
bech32: Bech32Provider::new(Bech32Config::from_well_known(&well_known)),
well_known,
cursor: None,
metrics: None,
Expand Down