Skip to content

Commit a6da53e

Browse files
committed
Fallback to CIP-100 after CIP-119 or CIP-108 fails
Fixes #1779
1 parent 7a7ed1b commit a6da53e

File tree

1 file changed

+12
-2
lines changed
  • cardano-db-sync/src/Cardano/DbSync/OffChain/Vote

1 file changed

+12
-2
lines changed

cardano-db-sync/src/Cardano/DbSync/OffChain/Vote/Types.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,20 @@ getRationale = \case
5858

5959
eitherDecodeOffChainVoteData :: LBS.ByteString -> DB.AnchorType -> Either String OffChainVoteData
6060
eitherDecodeOffChainVoteData lbs = \case
61-
DB.GovActionAnchor -> OffChainVoteDataGa <$> eitherDecode' lbs
62-
DB.DrepAnchor -> OffChainVoteDataDr <$> eitherDecode' lbs
61+
DB.GovActionAnchor ->
62+
eitherDecodeAlternative (OffChainVoteDataGa <$> eitherDecode' lbs) (OffChainVoteDataOther <$> eitherDecode' lbs)
63+
DB.DrepAnchor ->
64+
eitherDecodeAlternative (OffChainVoteDataDr <$> eitherDecode' lbs) (OffChainVoteDataOther <$> eitherDecode' lbs)
6365
DB.OtherAnchor -> OffChainVoteDataOther <$> eitherDecode' lbs
6466

67+
eitherDecodeAlternative :: Either String OffChainVoteData -> Either String OffChainVoteData -> Either String OffChainVoteData
68+
eitherDecodeAlternative one two =
69+
case one of
70+
Right _ -> one
71+
Left err1 -> case two of
72+
Right _ -> two
73+
Left err2 -> Left $ err1 <> ", CIP-100:" <> err2
74+
6575
getAuthors :: OffChainVoteData -> [Author]
6676
getAuthors = \case
6777
OffChainVoteDataOther dt -> authors dt

0 commit comments

Comments
 (0)