From cce6811df28af133aeae7dec27f4520c9e72f96b Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 14 Mar 2023 12:55:23 -0500 Subject: [PATCH] Correct parsing of memos --- src/ZGoTx.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ZGoTx.hs b/src/ZGoTx.hs index 4089c3a..95278f8 100644 --- a/src/ZGoTx.hs +++ b/src/ZGoTx.hs @@ -106,7 +106,7 @@ data ZGoMemo = , m_address :: Maybe T.Text , m_payment :: Bool } - deriving (Eq) + deriving (Eq, Show) data MemoToken = Login !U.UUID @@ -174,21 +174,24 @@ pZGoMemo = do tks <- some pMemo pure $ ZGoMemo (isSession tks) (isAddress tks) (isPayment tks) where + isPayment [] = False isPayment tks = not (null tks) && case head tks of PayMsg x -> True - _ -> False + _ -> isPayment $ tail tks + isAddress [] = Nothing isAddress tks = if not (null tks) then case head tks of Address x -> Just x - _ -> Nothing + _ -> isAddress $ tail tks else Nothing + isSession [] = Nothing isSession tks = if not (null tks) then case head tks of Login x -> Just x PayMsg y -> Just y - _ -> Nothing + _ -> isSession $ tail tks else Nothing