-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: scaffold tx validation UI (#10)
- Loading branch information
Showing
15 changed files
with
451 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use pallas::ledger::primitives::alonzo::MintedTx; | ||
|
||
use crate::Validations; | ||
|
||
pub fn validate_alonzo(mtx_a: &MintedTx) -> Validations { | ||
let out = Validations::new(); | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::{Validation, Validations}; | ||
use pallas::{ | ||
applying::babbage::check_ins_not_empty, | ||
ledger::primitives::babbage::{MintedTransactionBody, 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)); | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::Validations; | ||
use pallas::ledger::primitives::byron::MintedTxPayload; | ||
pub fn validate_byron(mtxp: &MintedTxPayload) -> Validations { | ||
let out = Validations::new(); | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use pallas::ledger::primitives::conway::MintedTx; | ||
|
||
use crate::Validations; | ||
pub fn validate_conway(mtx_c: &MintedTx) -> Validations { | ||
let out = Validations::new(); | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod alonzo; | ||
pub mod babbage; | ||
pub mod byron; | ||
pub mod conway; | ||
pub mod shelley_ma; | ||
pub mod validate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use pallas::ledger::primitives::alonzo::MintedTx; | ||
|
||
use crate::Validations; | ||
|
||
pub fn validate_shelley_ma(mtx_sma: &MintedTx) -> Validations { | ||
let out = Validations::new(); | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::validations::babbage::validate_babbage; | ||
use crate::Validations; | ||
|
||
use pallas::applying::utils::ValidationError; | ||
use pallas::ledger::traverse::{Era, MultiEraTx}; | ||
|
||
use super::alonzo::validate_alonzo; | ||
use super::byron::validate_byron; | ||
use super::conway::validate_conway; | ||
use super::shelley_ma::validate_shelley_ma; | ||
|
||
pub fn set_description(res: &Result<(), ValidationError>, success: String) -> String { | ||
match res { | ||
Ok(_) => success, | ||
Err(e) => format!("Error {:?}", e), | ||
} | ||
} | ||
|
||
pub fn validate(mtx: &MultiEraTx<'_>) -> Validations { | ||
match &mtx { | ||
MultiEraTx::Byron(mtxp) => validate_byron(&mtxp), | ||
MultiEraTx::AlonzoCompatible(mtx_sma, Era::Shelley) | ||
| MultiEraTx::AlonzoCompatible(mtx_sma, Era::Allegra) | ||
| MultiEraTx::AlonzoCompatible(mtx_sma, Era::Mary) => validate_shelley_ma(&mtx_sma), | ||
MultiEraTx::AlonzoCompatible(mtx_a, Era::Alonzo) => validate_alonzo(&mtx_a), | ||
MultiEraTx::Babbage(mtx_b) => validate_babbage(&mtx_b), | ||
MultiEraTx::Conway(mtx_c) => validate_conway(&mtx_c), | ||
// This case is impossible. TODO: Handle error | ||
_ => Validations::new(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { type Section, safeParseTx } from "napi-pallas"; | ||
export { safeParseTx, type Section } from "napi-pallas"; |
Oops, something went wrong.