Skip to content

Commit

Permalink
make verifier proof field JSON for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
giantimi committed Apr 17, 2024
1 parent eb57e84 commit fc84dce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/Chainweb/Api/PactCommand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import Data.Text (Text)
import Chainweb.Api.ChainwebMeta
import Chainweb.Api.Payload
import Chainweb.Api.Signer
import Chainweb.Api.Verifier
------------------------------------------------------------------------------

data PactCommand = PactCommand
{ _pactCommand_payload :: Payload
, _pactCommand_signers :: [Signer]
, _pactCommand_verifiers :: Maybe [Verifier]
, _pactCommand_meta :: ChainwebMeta
, _pactCommand_nonce :: Text
, _pactCommand_network :: Maybe Text
Expand All @@ -24,6 +26,7 @@ instance ToJSON PactCommand where
toJSON PactCommand{..} = object
[ "payload" .= _pactCommand_payload
, "signers" .= _pactCommand_signers
, "verifiers" .= _pactCommand_verifiers
, "meta" .= _pactCommand_meta
, "nonce" .= _pactCommand_nonce
, "networkId" .= _pactCommand_network
Expand All @@ -33,6 +36,7 @@ instance FromJSON PactCommand where
parseJSON = withObject "PactCommand" $ \o -> PactCommand
<$> o .: "payload"
<*> o .: "signers"
<*> o .: "verifiers"
<*> o .: "meta"
<*> o .: "nonce"
<*> o .: "networkId"
1 change: 0 additions & 1 deletion lib/Chainweb/Api/Signer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Chainweb.Api.Signer where
import Chainweb.Api.SigCapability
import Data.Aeson
import Data.Maybe (fromMaybe, catMaybes)
import Data.Ord
import Data.Text (Text)
------------------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions lib/Chainweb/Api/Verifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Data.Text (Text)

data Verifier = Verifier
{ _verifier_name :: Maybe Text
, _verifier_proof :: Maybe Text
, _verifier_proof :: Value
, _verifier_capList :: [SigCapability]
} deriving (Eq, Show)

Expand All @@ -22,12 +22,12 @@ instance Ord Verifier where
instance ToJSON Verifier where
toJSON Verifier{..} = object $ catMaybes
[ fmap ("name" .=) _verifier_name
, fmap ("proof" .=) _verifier_proof
, Just $ "proof" .= _verifier_proof
, Just $ "clist" .= _verifier_capList
]

instance FromJSON Verifier where
parseJSON = withObject "Verifier" $ \o -> Verifier
<$> o .:? "name"
<*> o .:? "proof"
<*> o .: "proof"
<*> o .: "clist"

0 comments on commit fc84dce

Please sign in to comment.