From 39d76b03cfba37b7107a0761c86145c17541bfab Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Tue, 25 Jun 2024 13:36:29 +0200 Subject: [PATCH] fix(tap-core): implement serialize for failed state Signed-off-by: Lorenzo Delgado --- tap_core/src/receipt/received_receipt.rs | 3 ++- tap_core/src/receipt/state.rs | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tap_core/src/receipt/received_receipt.rs b/tap_core/src/receipt/received_receipt.rs index dc32ef1c..23d88a78 100644 --- a/tap_core/src/receipt/received_receipt.rs +++ b/tap_core/src/receipt/received_receipt.rs @@ -14,6 +14,7 @@ //! their progress through various checks and stages of inclusion in RAV requests and received RAVs. use alloy_sol_types::Eip712Domain; +use serde::{Deserialize, Serialize}; use super::{Receipt, ReceiptError, ReceiptResult, SignedReceipt}; use crate::receipt::state::{AwaitingReserve, Checking, Failed, ReceiptState, Reserved}; @@ -37,7 +38,7 @@ pub type ResultReceipt = std::result::Result, ReceiptWith /// awaiting escrow reservation. /// - The [ `Reserved` ] state is used to represent a receipt that has /// successfully reserved escrow. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct ReceiptWithState where S: ReceiptState, diff --git a/tap_core/src/receipt/state.rs b/tap_core/src/receipt/state.rs index 38e7e08b..c9583f73 100644 --- a/tap_core/src/receipt/state.rs +++ b/tap_core/src/receipt/state.rs @@ -8,13 +8,14 @@ //! The `ReceiptState` trait represents the different states a receipt can be in. use crate::receipt::ReceiptError; +use serde::{Deserialize, Serialize}; /// Checking state represents a receipt that is currently being checked. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Checking; /// Failed state represents a receipt that has failed a check or validation. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Failed { /// A list of checks to be completed for the receipt, along with their /// current result @@ -23,11 +24,11 @@ pub struct Failed { /// AwaitingReserve state represents a receipt that has passed all checks /// and is awaiting escrow reservation. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct AwaitingReserve; /// Reserved state represents a receipt that has successfully reserved escrow. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Reserved; /// Trait for the different states a receipt can be in.