Skip to content

Commit

Permalink
Implement Aeson instances for API TxOut
Browse files Browse the repository at this point in the history
  • Loading branch information
intricate committed Sep 23, 2020
1 parent c6eea9f commit 9aa683e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cardano-api/src/Cardano/Api/Typed.hs
Expand Up @@ -935,8 +935,23 @@ deriving instance Eq (TxOut Shelley)
deriving instance Show (TxOut Byron)
deriving instance Show (TxOut Shelley)

instance SerialiseAddress (Address era) => ToJSON (TxOut era) where
toJSON (TxOut addr amount) =
Aeson.object
[ "address" .= toJSON addr
, "amount" .= toJSON amount
]

instance FromJSON (Address era) => FromJSON (TxOut era) where
parseJSON =
Aeson.withObject "TxOut" $ \v ->
TxOut
<$> v .: "address"
<*> v .: "amount"

newtype Lovelace = Lovelace Integer
deriving (Eq, Ord, Enum, Show)
deriving newtype (ToJSON, FromJSON)


toByronTxIn :: TxIn -> Byron.TxIn
Expand Down

0 comments on commit 9aa683e

Please sign in to comment.