Fix deserialization issue when 'parameters' is missing.
Deserialize to an empty vector.
This commit is contained in:
		
							parent
							
								
									592d3d7a1c
								
							
						
					
					
						commit
						ea269b14a2
					
				|  | @ -10,7 +10,7 @@ use std::fmt::{self, Debug, Display}; | ||||||
| use validator::{Purpose, Validator}; | use validator::{Purpose, Validator}; | ||||||
| 
 | 
 | ||||||
| #[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)] | #[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)] | ||||||
| pub struct Blueprint<T> { | pub struct Blueprint<T: Default> { | ||||||
|     pub preamble: Preamble, |     pub preamble: Preamble, | ||||||
|     pub validators: Vec<Validator<T>>, |     pub validators: Vec<Validator<T>>, | ||||||
| } | } | ||||||
|  | @ -55,7 +55,7 @@ impl Blueprint<Schema> { | ||||||
| 
 | 
 | ||||||
| impl<T> Blueprint<T> | impl<T> Blueprint<T> | ||||||
| where | where | ||||||
|     T: Clone, |     T: Clone + Default, | ||||||
| { | { | ||||||
|     pub fn lookup( |     pub fn lookup( | ||||||
|         &self, |         &self, | ||||||
|  |  | ||||||
|  | @ -302,6 +302,12 @@ impl Data { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl Default for Schema { | ||||||
|  |     fn default() -> Self { | ||||||
|  |         Schema::Unit | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| impl Display for Schema { | impl Display for Schema { | ||||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|         let s = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?; |         let s = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?; | ||||||
|  |  | ||||||
|  | @ -22,6 +22,7 @@ pub struct Validator<T> { | ||||||
|     pub datum: Option<Annotated<T>>, |     pub datum: Option<Annotated<T>>, | ||||||
|     pub redeemer: Annotated<T>, |     pub redeemer: Annotated<T>, | ||||||
|     #[serde(skip_serializing_if = "Vec::is_empty")] |     #[serde(skip_serializing_if = "Vec::is_empty")] | ||||||
|  |     #[serde(default)] | ||||||
|     pub parameters: Vec<Annotated<T>>, |     pub parameters: Vec<Annotated<T>>, | ||||||
|     #[serde(flatten)] |     #[serde(flatten)] | ||||||
|     pub program: Program<DeBruijn>, |     pub program: Program<DeBruijn>, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 KtorZ
						KtorZ