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

Exposed Cbor Datum encoded in hex #505

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/mapper/byron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl EventWriter {
amount: source.amount,
assets: None,
datum_hash: None,
datum_cbor: None
})
}

Expand Down
13 changes: 11 additions & 2 deletions src/mapper/map.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::collections::HashMap;

use pallas::{
codec::{minicbor::bytes::ByteVec, utils::KeepRaw},
codec::{
minicbor::{bytes::ByteVec, to_vec},
utils::KeepRaw,
},
crypto::hash::Hash,
ledger::primitives::babbage::DatumOption,
};
Expand Down Expand Up @@ -178,6 +181,7 @@ impl EventWriter {
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()),
datum_cbor: None,
})
}

Expand All @@ -192,8 +196,13 @@ impl EventWriter {
.encode_address(output.address.as_slice())?,
amount: get_tx_output_coin_value(&output.value),
assets: self.collect_asset_records(&output.value).into(),
datum_hash: match output.datum_option {
datum_hash: match &output.datum_option {
Some(DatumOption::Hash(x)) => Some(x.to_string()),
Some(DatumOption::Data(x)) => Some(x.to_hash().to_string()),
_ => None,
},
datum_cbor: match &output.datum_option {
Some(DatumOption::Data(x)) => Some(to_vec(&x.0)?.to_hex()),
_ => None,
},
})
Expand Down
1 change: 1 addition & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub struct TxOutputRecord {
pub amount: u64,
pub assets: Option<Vec<OutputAssetRecord>>,
pub datum_hash: Option<String>,
pub datum_cbor: Option<String>,
}

impl From<TxOutputRecord> for EventData {
Expand Down