Skip to content

Commit aad96d0

Browse files
committed
Enable drep image metadata
1 parent f262780 commit aad96d0

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module Cardano.DbSync.Era.Universal.Insert.GovAction (
2828
)
2929
where
3030

31-
import Cardano.BM.Trace (Trace, logInfo, logWarning)
31+
import Cardano.BM.Trace (Trace, logWarning)
3232
import qualified Cardano.Crypto as Crypto
3333
import Cardano.Db (DbWord64 (..))
3434
import qualified Cardano.Db as DB

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ fetchOffChainVoteData _tracer manager time oVoteWorkQ =
323323
, DB.offChainVoteDrepDataObjectives = Vote.textValue <$> Vote.objectives (Vote.body dt)
324324
, DB.offChainVoteDrepDataMotivations = Vote.textValue <$> Vote.motivations (Vote.body dt)
325325
, DB.offChainVoteDrepDataQualifications = Vote.textValue <$> Vote.qualifications (Vote.body dt)
326+
, DB.offChainVoteDrepDataImageUrl = Vote.textValue . Vote.contentUrl <$> Vote.image (Vote.body dt)
327+
, DB.offChainVoteDrepDataImageHash = Vote.textValue . Vote.sha256 <$> Vote.image (Vote.body dt)
326328
}
327329
_ -> Nothing
328330

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ getRationale = \case
5959
eitherDecodeOffChainVoteData :: LBS.ByteString -> DB.AnchorType -> Either String OffChainVoteData
6060
eitherDecodeOffChainVoteData lbs = \case
6161
DB.GovActionAnchor -> OffChainVoteDataGa <$> eitherDecode' lbs
62-
DB.DrepAnchor -> Left "unimplemented"
62+
DB.DrepAnchor -> OffChainVoteDataDr <$> eitherDecode' lbs
6363
DB.OtherAnchor -> OffChainVoteDataOther <$> eitherDecode' lbs
6464

6565
getAuthors :: OffChainVoteData -> [Author]
@@ -158,8 +158,8 @@ data DrepBody = DrepBody
158158
deriving (Show, Generic)
159159

160160
data Image = Image
161-
{ contentUrl :: Text
162-
, sha256 :: Text
161+
{ contentUrl :: TextValue
162+
, sha256 :: TextValue
163163
}
164164
deriving (Show, Generic, FromJSON)
165165

@@ -276,11 +276,11 @@ instance FromJSON DrepBody where
276276
DrepBody mBody
277277
<$> o .:? "paymentAddress"
278278
<*> parseTextLimit 80 "givenName" o
279-
<*> o .: "image"
279+
<*> o .:? "image"
280280
<*> parseTextLimitMaybe 1000 "objectives" o
281281
<*> parseTextLimitMaybe 1000 "motivations" o
282282
<*> parseTextLimitMaybe 1000 "qualifications" o
283-
<*> o .: "doNotList"
283+
<*> o .:? "doNotList"
284284
where
285285
withObjectV v' s p = withObject s p v'
286286

cardano-db/src/Cardano/Db/Schema.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ share
711711
objectives Text Maybe
712712
motivations Text Maybe
713713
qualifications Text Maybe
714+
imageUrl Text Maybe
715+
imageHash Text Maybe
714716

715717
OffChainVoteAuthor
716718
offChainVoteDataId OffChainVoteDataId noreference

0 commit comments

Comments
 (0)