Skip to content

Commit

Permalink
feat: Use latest pallas (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
alegadea authored Dec 6, 2024
1 parent b4ea439 commit 1e8b05e
Show file tree
Hide file tree
Showing 11 changed files with 2,850 additions and 2,435 deletions.
2 changes: 1 addition & 1 deletion napi-pallas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hex = "0.4.3"
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4"] }
napi-derive = "2.12.2"
pallas = { git = "https://github.com/txpipe/pallas.git", rev = "ba342ab", features = ["unstable"] }
pallas = { git = "https://github.com/txpipe/pallas.git", features = ["applying"] }

[build-dependencies]
napi-build = "2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion napi-pallas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Section {
self
}

fn build_child<F>(mut self, func: F) -> Self
fn build_child<F>(self, func: F) -> Self
where
F: FnOnce() -> Section,
{
Expand Down
14 changes: 10 additions & 4 deletions napi-pallas/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn tx_output_section(o: &MultiEraOutput) -> Section {
.with_topic("output")
.with_bytes(&o.encode())
.with_attr("tx_output_address", o.address().unwrap())
.with_attr("tx_output_lovelace", o.lovelace_amount())
.with_attr("tx_output_lovelace", o.value().coin())
.maybe_push_child(o.datum().map(|x| {
match x {
pallas::ledger::primitives::conway::PseudoDatumOption::Hash(x) => Section::new()
Expand All @@ -71,7 +71,7 @@ fn tx_output_section(o: &MultiEraOutput) -> Section {
.build_child(|| {
Section::new()
.with_topic("tx_output_assets")
.collect_children(o.non_ada_assets().into_iter().map(|x| {
.collect_children(o.value().assets().into_iter().map(|x| {
Section::new()
.with_topic("tx_output_asset_policy")
.with_attr("tx_output_asset_policy_id", x.policy())
Expand All @@ -81,8 +81,14 @@ fn tx_output_section(o: &MultiEraOutput) -> Section {
.collect_children(x.assets().iter().map(|asset| {
Section::new()
.with_topic("tx_output_asset_policy_asset")
.with_attr("tx_output_asset_policy_asset_name", hex::encode(asset.name()))
.with_maybe_attr("tx_output_asset_policy_asset_name_ascii", asset.to_ascii_name())
.with_attr(
"tx_output_asset_policy_asset_name",
hex::encode(asset.name()),
)
.with_maybe_attr(
"tx_output_asset_policy_asset_name_ascii",
asset.to_ascii_name(),
)
.with_maybe_attr("tx_output_asset_policy_asset_count", asset.output_coin())
}))
})
Expand Down
2 changes: 1 addition & 1 deletion napi-pallas/src/validations/alonzo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pallas::ledger::primitives::alonzo::MintedTx;

use crate::Validations;

pub fn validate_alonzo(mtx_a: &MintedTx) -> Validations {
pub fn validate_alonzo(_mtx_a: &MintedTx) -> Validations {
let out = Validations::new();
out
}
23 changes: 4 additions & 19 deletions napi-pallas/src/validations/babbage.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
use crate::{Validation, Validations};
use pallas::{
applying::babbage::check_ins_not_empty,
ledger::primitives::babbage::{MintedTransactionBody, MintedTx as BabbageMintedTx},
};
use crate::Validations;
use pallas::ledger::primitives::babbage::MintedTx as BabbageMintedTx;

use super::validate::set_description;

fn validate_babbage_ins_not_empty(mtx: &BabbageMintedTx) -> Validation {
let tx_body: &MintedTransactionBody = &mtx.transaction_body.clone();
let res = check_ins_not_empty(tx_body);
let description = set_description(&res, "Inputs are not empty".to_string());
return Validation::new()
.with_name("Non empty inputs".to_string())
.with_value(res.is_ok())
.with_description(description);
}

pub fn validate_babbage(mtx_b: &BabbageMintedTx) -> Validations {
let out = Validations::new().add_new_validation(validate_babbage_ins_not_empty(&mtx_b));
pub fn validate_babbage(_mtx_b: &BabbageMintedTx) -> Validations {
let out = Validations::new();
out
}
2 changes: 1 addition & 1 deletion napi-pallas/src/validations/byron.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::Validations;
use pallas::ledger::primitives::byron::MintedTxPayload;
pub fn validate_byron(mtxp: &MintedTxPayload) -> Validations {
pub fn validate_byron(_mtxp: &MintedTxPayload) -> Validations {
let out = Validations::new();
out
}
2 changes: 1 addition & 1 deletion napi-pallas/src/validations/conway.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pallas::ledger::primitives::conway::MintedTx;

use crate::Validations;
pub fn validate_conway(mtx_c: &MintedTx) -> Validations {
pub fn validate_conway(_mtx_c: &MintedTx) -> Validations {
let out = Validations::new();
out
}
2 changes: 1 addition & 1 deletion napi-pallas/src/validations/shelley_ma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pallas::ledger::primitives::alonzo::MintedTx;

use crate::Validations;

pub fn validate_shelley_ma(mtx_sma: &MintedTx) -> Validations {
pub fn validate_shelley_ma(_mtx_sma: &MintedTx) -> Validations {
let out = Validations::new();
out
}
Loading

0 comments on commit 1e8b05e

Please sign in to comment.