Skip to content

Commit

Permalink
Properly serde enum
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Oct 2, 2023
1 parent 1aef1a9 commit c787896
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/dojo-types/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ impl Ty {
}
}
Ty::Enum(e) => {
let option = e
.option
.map(|v| Ok(vec![FieldElement::from(v)]))
.unwrap_or(Err(PrimitiveError::MissingFieldElement))?;
felts.extend(option);

for (_, child) in &e.options {
serialize_inner(child, felts)?;
}
Expand Down Expand Up @@ -97,6 +103,8 @@ impl Ty {
}
}
Ty::Enum(e) => {
e.option =
Some(felts.remove(0).try_into().map_err(PrimitiveError::ValueOutOfRange)?);
for (_, child) in &mut e.options {
child.deserialize(felts)?;
}
Expand Down

0 comments on commit c787896

Please sign in to comment.