Fix deserialization issue when 'parameters' is missing.

Deserialize to an empty vector.
This commit is contained in:
KtorZ 2023-02-04 11:38:09 +01:00
parent 592d3d7a1c
commit ea269b14a2
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
3 changed files with 9 additions and 2 deletions

View File

@ -10,7 +10,7 @@ use std::fmt::{self, Debug, Display};
use validator::{Purpose, Validator};
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
pub struct Blueprint<T> {
pub struct Blueprint<T: Default> {
pub preamble: Preamble,
pub validators: Vec<Validator<T>>,
}
@ -55,7 +55,7 @@ impl Blueprint<Schema> {
impl<T> Blueprint<T>
where
T: Clone,
T: Clone + Default,
{
pub fn lookup(
&self,

View File

@ -302,6 +302,12 @@ impl Data {
}
}
impl Default for Schema {
fn default() -> Self {
Schema::Unit
}
}
impl Display for Schema {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let s = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?;

View File

@ -22,6 +22,7 @@ pub struct Validator<T> {
pub datum: Option<Annotated<T>>,
pub redeemer: Annotated<T>,
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
pub parameters: Vec<Annotated<T>>,
#[serde(flatten)]
pub program: Program<DeBruijn>,