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

Added code to expose collateral data #495

Merged
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
16 changes: 16 additions & 0 deletions src/mapper/babbage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ impl EventWriter {
}
}

// Add Collateral Stuff
let collateral_inputs = &body.collateral.as_deref();
record.collateral_input_count = collateral_inputs.iter().count();
record.has_collateral_output = body.collateral_return.is_some();

// TODO
// TransactionBodyComponent::ScriptDataHash(_)
// TransactionBodyComponent::RequiredSigners(_)
Expand All @@ -74,6 +79,17 @@ impl EventWriter {
record.outputs = outputs.into();
record.inputs = inputs.into();

// transaction_details collateral stuff
record.collateral_inputs =
collateral_inputs.map(|inputs| self.collect_input_records(inputs));

record.collateral_output = body.collateral_return.as_ref().map(|output| match output {
TransactionOutput::Legacy(x) => self.to_legacy_output_record(x).unwrap(),
TransactionOutput::PostAlonzo(x) => {
self.to_post_alonzo_output_record(x).unwrap()
}
});

record.metadata = match aux_data {
Some(aux_data) => self.collect_metadata_records(aux_data)?.into(),
None => None,
Expand Down
4 changes: 4 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ pub struct TransactionRecord {
pub validity_interval_start: Option<u64>,
pub network_id: Option<u32>,
pub input_count: usize,
pub collateral_input_count: usize,
pub has_collateral_output: bool,
pub output_count: usize,
pub mint_count: usize,
pub total_output: u64,
Expand All @@ -168,6 +170,8 @@ pub struct TransactionRecord {
pub metadata: Option<Vec<MetadataRecord>>,
pub inputs: Option<Vec<TxInputRecord>>,
pub outputs: Option<Vec<TxOutputRecord>>,
pub collateral_inputs: Option<Vec<TxInputRecord>>,
pub collateral_output: Option<TxOutputRecord>,
pub mint: Option<Vec<MintRecord>>,
pub vkey_witnesses: Option<Vec<VKeyWitnessRecord>>,
pub native_witnesses: Option<Vec<NativeWitnessRecord>>,
Expand Down