Skip to content

Commit 5f019d4

Browse files
committed
working-without-voting-power
1 parent f25e2b5 commit 5f019d4

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

govtool/backend/src/VVA/API/SyncAiResponseType.hs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
module VVA.API.SyncAiResponseType where
88

9+
import Data.Maybe (fromMaybe)
910
import GHC.Generics (Generic)
1011
import Data.Text (Text)
1112
import qualified Data.Text (stripPrefix)
@@ -60,7 +61,7 @@ data DRepData = DRepData
6061
-- Missing:
6162
-- , dataHash :: Maybe Text
6263
-- , deposit :: Integer
63-
, votingPower :: Double -- We might need to multiply this by 1e6 to get the actual voting power + Int
64+
-- , votingPower :: Double -- We might need to multiply this by 1e6 to get the actual voting power + Int
6465
, status :: Text
6566
-- Missing:
6667
-- , type :: DRepType
@@ -81,26 +82,23 @@ data DRepData = DRepData
8182
instance FromJSON DRepData where
8283
parseJSON = withObject "DRepData" $ \v -> do
8384
-- dRep data:
84-
-- drepId <- v .: "drepId"
8585
motivations <- v .: "motivations"
8686
givenName <- v .: "name"
8787
objectives <- v .: "objectives"
8888
status <- v .: "status"
8989
url <- v .:? "url"
90-
votingPower <- (v .: "votingPower" <|> (v .: "metrics" >>= (.: "votingPower")))
90+
-- votingPower <- (v .: "votingPower" <|> (v .: "metrics" >>= (.: "votingPower")))
9191

9292
--
9393
mMeta <- v .:? "metadata"
9494
mJsonMeta <- mMeta .::? "json_metadata"
9595
mBody <- mJsonMeta .::? "body"
9696

97-
drepId <- v .:? "drepId" >>= \did ->
98-
case did of
99-
Just _ -> pure did
100-
Nothing -> do
101-
m <- v .:? "metadata"
102-
m1 <- m .::? "hex"
103-
traverse parseJSON m1
97+
drepId <- do
98+
m <- v .:? "metadata"
99+
m1 <- m .::? "hex"
100+
mt <- traverse parseJSON m1
101+
pure (fromMaybe "" mt)
104102

105103
imageUrl <- do
106104
m <- v .:? "metadata"
@@ -147,7 +145,7 @@ instance FromJSON DRepData where
147145
)
148146

149147
pure $ DRepData
150-
drepId motivations givenName objectives status url votingPower
148+
drepId motivations givenName objectives status url -- votingPower
151149
imageUrl imageHash paymentAddress qualifications linkRefs identityRefs
152150

153151
data Reference = Reference

0 commit comments

Comments
 (0)