Skip to content

Commit

Permalink
feat: Implement legacy v1 mapper (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Mar 13, 2023
1 parent 3bd6d5d commit dc423a9
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 1,333 deletions.
10 changes: 7 additions & 3 deletions src/framework/legacy_v1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use std::fmt::Display;

use merge::Merge;
Expand Down Expand Up @@ -120,12 +119,13 @@ impl From<OutputAssetRecord> for EventData {
}
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct TxOutputRecord {
pub address: String,
pub amount: u64,
pub assets: Option<Vec<OutputAssetRecord>>,
pub datum_hash: Option<String>,
pub inline_datum: Option<PlutusDatumRecord>,
}

impl From<TxOutputRecord> for EventData {
Expand Down Expand Up @@ -161,6 +161,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 @@ -169,6 +171,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 Expand Up @@ -261,14 +265,14 @@ impl From<PlutusDatumRecord> for EventData {
EventData::PlutusDatum(x)
}
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct BlockRecord {
pub era: Era,
pub epoch: Option<u64>,
pub epoch_slot: Option<u64>,
pub body_size: usize,
pub issuer_vkey: String,
pub vrf_vkey: String,
pub tx_count: usize,
pub slot: u64,
pub hash: String,
Expand Down
14 changes: 13 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
use thiserror::Error;

pub mod filters;
pub mod framework;
pub mod mapper;
pub mod sinks;
pub mod sources;
pub mod utils;

pub type Error = Box<dyn std::error::Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("parse error {0}")]
Parse(String),
}

impl Error {
pub fn parse(error: impl ToString) -> Self {
Error::Parse(error)
}
}
Loading

0 comments on commit dc423a9

Please sign in to comment.