Skip to content

Commit

Permalink
map fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lisicky committed Jan 31, 2024
1 parent 1ed53f9 commit 9303bd4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ authors = ["Santiago Carmuega <santiago@carmuega.me>"]


[dependencies]
pallas = { git = "https://github.com/lisicky/pallas", branch = "hotfix/v0.18" }
pallas = { git = "https://github.com/Emurgo/pallas", tag = "conway_2" }
# pallas = { git = "https://github.com/txpipe/pallas" }
# pallas = { path = "../pallas/pallas" }
# pallas = { path = "../../pallas/pallas" }
hex = "0.4.3"
net2 = "0.2.37"
bech32 = "0.9.1"
Expand Down
16 changes: 8 additions & 8 deletions src/mapper/babbage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl EventWriter {
}

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

Expand All @@ -92,7 +92,7 @@ impl EventWriter {
}

if let Some(req_signers) = &body.required_signers {
let req_signers = self.collect_required_signers_records(req_signers)?;
let req_signers = self.collect_required_signers_records(req_signers.into())?;
record.required_signers_count = req_signers.len();

if self.config.include_transaction_details {
Expand All @@ -110,7 +110,7 @@ impl EventWriter {

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

record.collateral_output = body.collateral_return.as_ref().map(|output| match output {
MintedTransactionOutput::Legacy(x) => self.to_legacy_output_record(x).unwrap(),
Expand All @@ -126,23 +126,23 @@ impl EventWriter {

if let Some(witnesses) = witness_set {
record.vkey_witnesses = self
.collect_vkey_witness_records(&witnesses.vkeywitness)?
.collect_vkey_witness_records_babbage(&witnesses.vkeywitness)?
.into();

record.native_witnesses = self
.collect_native_witness_records(&witnesses.native_script)?
.collect_native_witness_records_babbage(&witnesses.native_script)?
.into();

record.plutus_witnesses = self
.collect_plutus_v1_witness_records(&witnesses.plutus_v1_script)?
.collect_plutus_v1_witness_records_babbage(&witnesses.plutus_v1_script)?
.into();

record.plutus_redeemers = self
.collect_plutus_redeemer_records(&witnesses.redeemer)?
.into();

record.plutus_data = self
.collect_witness_plutus_datum_records(&witnesses.plutus_data)?
.collect_witness_plutus_datum_records_babbage(&witnesses.plutus_data)?
.into();
}

Expand Down Expand Up @@ -278,7 +278,7 @@ impl EventWriter {
}

if let Some(datums) = &witness_set.plutus_data {
for datum in datums.iter() {
for datum in datums {
self.append_from(self.to_plutus_datum_record(datum)?)?;
}
}
Expand Down
54 changes: 51 additions & 3 deletions src/mapper/collect.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use pallas::ledger::primitives::alonzo::{Certificate, RequiredSigners};
use std::option::IntoIter;

Check warning on line 1 in src/mapper/collect.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

unused import: `std::option::IntoIter`

Check warning on line 1 in src/mapper/collect.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `std::option::IntoIter`

Check warning on line 1 in src/mapper/collect.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

unused import: `std::option::IntoIter`
use pallas::ledger::primitives::alonzo::{AddrKeyhash, AddrKeyhashes, Certificates, RequiredSigners, TransactionInputs};

Check warning on line 2 in src/mapper/collect.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

unused imports: `AddrKeyhashes`, `Certificates`, `RequiredSigners`

Check warning on line 2 in src/mapper/collect.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused imports: `AddrKeyhashes`, `Certificates`, `RequiredSigners`

Check warning on line 2 in src/mapper/collect.rs

View workflow job for this annotation

GitHub Actions / Check (ubuntu-latest, stable)

unused imports: `AddrKeyhashes`, `Certificates`, `RequiredSigners`
use pallas::{
codec::utils::{KeepRaw, KeyValuePairs, MaybeIndefArray},
ledger::{
Expand All @@ -15,6 +16,7 @@ use pallas::{
traverse::OriginalHash,
},
};
use pallas::ledger::primitives::babbage::{KeepRawPlutusDatas, NativeScripts, PlutusV1Scripts, VKeyWitnesses};

use crate::model::{CertificateRecord, RequiredSignerRecord};
use crate::{
Expand All @@ -29,7 +31,7 @@ use crate::{
use super::{map::ToHex, EventWriter};

impl EventWriter {
pub fn collect_input_records(&self, source: &[TransactionInput]) -> Vec<TxInputRecord> {
pub fn collect_input_records(&self, source: &TransactionInputs) -> Vec<TxInputRecord> {
source
.iter()
.map(|i| self.to_transaction_input_record(i))
Expand Down Expand Up @@ -148,6 +150,16 @@ impl EventWriter {
}
}

pub fn collect_vkey_witness_records_babbage(
&self,
witness_set: &Option<VKeyWitnesses>,
) -> Result<Vec<VKeyWitnessRecord>, Error> {
match witness_set {
Some(all) => all.iter().map(|i| self.to_vkey_witness_record(i)).collect(),
None => Ok(vec![]),
}
}

pub fn collect_native_witness_records(
&self,
witness_set: &Option<Vec<NativeScript>>,
Expand All @@ -161,6 +173,19 @@ impl EventWriter {
}
}

pub fn collect_native_witness_records_babbage(
&self,
witness_set: &Option<NativeScripts>,
) -> Result<Vec<NativeWitnessRecord>, Error> {
match witness_set {
Some(all) => all
.iter()
.map(|i| self.to_native_witness_record(i))
.collect(),
None => Ok(vec![]),
}
}

pub fn collect_plutus_v1_witness_records(
&self,
witness_set: &Option<Vec<PlutusScript>>,
Expand All @@ -174,6 +199,19 @@ impl EventWriter {
}
}

pub fn collect_plutus_v1_witness_records_babbage(
&self,
witness_set: &Option<PlutusV1Scripts>,
) -> Result<Vec<PlutusWitnessRecord>, Error> {
match &witness_set {
Some(all) => all
.iter()
.map(|i| self.to_plutus_v1_witness_record(i))
.collect(),
None => Ok(vec![]),
}
}

pub fn collect_plutus_v2_witness_records(
&self,
witness_set: &Option<MaybeIndefArray<PlutusV2Script>>,
Expand Down Expand Up @@ -210,6 +248,16 @@ impl EventWriter {
}
}

pub fn collect_witness_plutus_datum_records_babbage(
&self,
witness_set: &Option<KeepRawPlutusDatas>,
) -> Result<Vec<PlutusDatumRecord>, Error> {
match &witness_set {
Some(all) => all.into_iter().map(|i| self.to_plutus_datum_record(i)).collect(),
None => Ok(vec![]),
}
}

pub fn collect_shelley_tx_records(
&self,
block: &MintedBlock,
Expand All @@ -236,7 +284,7 @@ impl EventWriter {

pub fn collect_required_signers_records(
&self,
req_signers: &RequiredSigners,
req_signers: &Vec<AddrKeyhash>,
) -> Result<Vec<RequiredSignerRecord>, Error> {
let mut signers = vec![];
for req_sign in req_signers {
Expand Down

0 comments on commit 9303bd4

Please sign in to comment.