Correct parsing of memos
This commit is contained in:
parent
63d372c2d5
commit
cce6811df2
1 changed files with 7 additions and 4 deletions
11
src/ZGoTx.hs
11
src/ZGoTx.hs
|
@ -106,7 +106,7 @@ data ZGoMemo =
|
||||||
, m_address :: Maybe T.Text
|
, m_address :: Maybe T.Text
|
||||||
, m_payment :: Bool
|
, m_payment :: Bool
|
||||||
}
|
}
|
||||||
deriving (Eq)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data MemoToken
|
data MemoToken
|
||||||
= Login !U.UUID
|
= Login !U.UUID
|
||||||
|
@ -174,21 +174,24 @@ pZGoMemo = do
|
||||||
tks <- some pMemo
|
tks <- some pMemo
|
||||||
pure $ ZGoMemo (isSession tks) (isAddress tks) (isPayment tks)
|
pure $ ZGoMemo (isSession tks) (isAddress tks) (isPayment tks)
|
||||||
where
|
where
|
||||||
|
isPayment [] = False
|
||||||
isPayment tks =
|
isPayment tks =
|
||||||
not (null tks) &&
|
not (null tks) &&
|
||||||
case head tks of
|
case head tks of
|
||||||
PayMsg x -> True
|
PayMsg x -> True
|
||||||
_ -> False
|
_ -> isPayment $ tail tks
|
||||||
|
isAddress [] = Nothing
|
||||||
isAddress tks =
|
isAddress tks =
|
||||||
if not (null tks)
|
if not (null tks)
|
||||||
then case head tks of
|
then case head tks of
|
||||||
Address x -> Just x
|
Address x -> Just x
|
||||||
_ -> Nothing
|
_ -> isAddress $ tail tks
|
||||||
else Nothing
|
else Nothing
|
||||||
|
isSession [] = Nothing
|
||||||
isSession tks =
|
isSession tks =
|
||||||
if not (null tks)
|
if not (null tks)
|
||||||
then case head tks of
|
then case head tks of
|
||||||
Login x -> Just x
|
Login x -> Just x
|
||||||
PayMsg y -> Just y
|
PayMsg y -> Just y
|
||||||
_ -> Nothing
|
_ -> isSession $ tail tks
|
||||||
else Nothing
|
else Nothing
|
||||||
|
|
Loading…
Reference in a new issue