module Blockfrost.Types.Cardano.Metadata
( TxMeta (..)
, TxMetaJSON (..)
, TxMetaCBOR (..)
) where
import Data.Aeson (Value, object, (.=))
import Data.Text (Text)
import Deriving.Aeson
import Servant.Docs (ToSample (..), samples)
import Blockfrost.Types.Shared
data TxMeta = TxMeta
{ TxMeta -> Text
_txMetaLabel :: Text
, TxMeta -> Maybe Text
_txMetaCip10 :: Maybe Text
, TxMeta -> Quantity
_txMetaCount :: Quantity
}
deriving stock (Int -> TxMeta -> ShowS
[TxMeta] -> ShowS
TxMeta -> String
(Int -> TxMeta -> ShowS)
-> (TxMeta -> String) -> ([TxMeta] -> ShowS) -> Show TxMeta
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxMeta -> ShowS
showsPrec :: Int -> TxMeta -> ShowS
$cshow :: TxMeta -> String
show :: TxMeta -> String
$cshowList :: [TxMeta] -> ShowS
showList :: [TxMeta] -> ShowS
Show, TxMeta -> TxMeta -> Bool
(TxMeta -> TxMeta -> Bool)
-> (TxMeta -> TxMeta -> Bool) -> Eq TxMeta
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxMeta -> TxMeta -> Bool
== :: TxMeta -> TxMeta -> Bool
$c/= :: TxMeta -> TxMeta -> Bool
/= :: TxMeta -> TxMeta -> Bool
Eq, (forall x. TxMeta -> Rep TxMeta x)
-> (forall x. Rep TxMeta x -> TxMeta) -> Generic TxMeta
forall x. Rep TxMeta x -> TxMeta
forall x. TxMeta -> Rep TxMeta x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TxMeta -> Rep TxMeta x
from :: forall x. TxMeta -> Rep TxMeta x
$cto :: forall x. Rep TxMeta x -> TxMeta
to :: forall x. Rep TxMeta x -> TxMeta
Generic)
deriving (Maybe TxMeta
Value -> Parser [TxMeta]
Value -> Parser TxMeta
(Value -> Parser TxMeta)
-> (Value -> Parser [TxMeta]) -> Maybe TxMeta -> FromJSON TxMeta
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser TxMeta
parseJSON :: Value -> Parser TxMeta
$cparseJSONList :: Value -> Parser [TxMeta]
parseJSONList :: Value -> Parser [TxMeta]
$comittedField :: Maybe TxMeta
omittedField :: Maybe TxMeta
FromJSON, [TxMeta] -> Value
[TxMeta] -> Encoding
TxMeta -> Bool
TxMeta -> Value
TxMeta -> Encoding
(TxMeta -> Value)
-> (TxMeta -> Encoding)
-> ([TxMeta] -> Value)
-> ([TxMeta] -> Encoding)
-> (TxMeta -> Bool)
-> ToJSON TxMeta
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: TxMeta -> Value
toJSON :: TxMeta -> Value
$ctoEncoding :: TxMeta -> Encoding
toEncoding :: TxMeta -> Encoding
$ctoJSONList :: [TxMeta] -> Value
toJSONList :: [TxMeta] -> Value
$ctoEncodingList :: [TxMeta] -> Encoding
toEncodingList :: [TxMeta] -> Encoding
$comitField :: TxMeta -> Bool
omitField :: TxMeta -> Bool
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_txMeta", CamelToSnake]] TxMeta
instance ToSample TxMeta where
toSamples :: Proxy TxMeta -> [(Text, TxMeta)]
toSamples = [(Text, TxMeta)] -> Proxy TxMeta -> [(Text, TxMeta)]
forall a. a -> Proxy TxMeta -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, TxMeta)] -> Proxy TxMeta -> [(Text, TxMeta)])
-> [(Text, TxMeta)] -> Proxy TxMeta -> [(Text, TxMeta)]
forall a b. (a -> b) -> a -> b
$ [TxMeta] -> [(Text, TxMeta)]
forall a. [a] -> [(Text, a)]
samples
[ Text -> Maybe Text -> Quantity -> TxMeta
TxMeta Text
"1990" Maybe Text
forall a. Maybe a
Nothing Quantity
1
, Text -> Maybe Text -> Quantity -> TxMeta
TxMeta Text
"1967" (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"nut.link metadata oracles registry") Quantity
3
, Text -> Maybe Text -> Quantity -> TxMeta
TxMeta Text
"1968" (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"nut.link metadata oracles data points") Quantity
16321
]
data TxMetaJSON = TxMetaJSON
{ TxMetaJSON -> TxHash
_txMetaJSONTxHash :: TxHash
, TxMetaJSON -> Maybe Value
_txMetaJSONJSONMetadata :: Maybe Value
}
deriving stock (Int -> TxMetaJSON -> ShowS
[TxMetaJSON] -> ShowS
TxMetaJSON -> String
(Int -> TxMetaJSON -> ShowS)
-> (TxMetaJSON -> String)
-> ([TxMetaJSON] -> ShowS)
-> Show TxMetaJSON
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxMetaJSON -> ShowS
showsPrec :: Int -> TxMetaJSON -> ShowS
$cshow :: TxMetaJSON -> String
show :: TxMetaJSON -> String
$cshowList :: [TxMetaJSON] -> ShowS
showList :: [TxMetaJSON] -> ShowS
Show, TxMetaJSON -> TxMetaJSON -> Bool
(TxMetaJSON -> TxMetaJSON -> Bool)
-> (TxMetaJSON -> TxMetaJSON -> Bool) -> Eq TxMetaJSON
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxMetaJSON -> TxMetaJSON -> Bool
== :: TxMetaJSON -> TxMetaJSON -> Bool
$c/= :: TxMetaJSON -> TxMetaJSON -> Bool
/= :: TxMetaJSON -> TxMetaJSON -> Bool
Eq, (forall x. TxMetaJSON -> Rep TxMetaJSON x)
-> (forall x. Rep TxMetaJSON x -> TxMetaJSON) -> Generic TxMetaJSON
forall x. Rep TxMetaJSON x -> TxMetaJSON
forall x. TxMetaJSON -> Rep TxMetaJSON x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TxMetaJSON -> Rep TxMetaJSON x
from :: forall x. TxMetaJSON -> Rep TxMetaJSON x
$cto :: forall x. Rep TxMetaJSON x -> TxMetaJSON
to :: forall x. Rep TxMetaJSON x -> TxMetaJSON
Generic)
deriving (Maybe TxMetaJSON
Value -> Parser [TxMetaJSON]
Value -> Parser TxMetaJSON
(Value -> Parser TxMetaJSON)
-> (Value -> Parser [TxMetaJSON])
-> Maybe TxMetaJSON
-> FromJSON TxMetaJSON
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser TxMetaJSON
parseJSON :: Value -> Parser TxMetaJSON
$cparseJSONList :: Value -> Parser [TxMetaJSON]
parseJSONList :: Value -> Parser [TxMetaJSON]
$comittedField :: Maybe TxMetaJSON
omittedField :: Maybe TxMetaJSON
FromJSON, [TxMetaJSON] -> Value
[TxMetaJSON] -> Encoding
TxMetaJSON -> Bool
TxMetaJSON -> Value
TxMetaJSON -> Encoding
(TxMetaJSON -> Value)
-> (TxMetaJSON -> Encoding)
-> ([TxMetaJSON] -> Value)
-> ([TxMetaJSON] -> Encoding)
-> (TxMetaJSON -> Bool)
-> ToJSON TxMetaJSON
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: TxMetaJSON -> Value
toJSON :: TxMetaJSON -> Value
$ctoEncoding :: TxMetaJSON -> Encoding
toEncoding :: TxMetaJSON -> Encoding
$ctoJSONList :: [TxMetaJSON] -> Value
toJSONList :: [TxMetaJSON] -> Value
$ctoEncodingList :: [TxMetaJSON] -> Encoding
toEncodingList :: [TxMetaJSON] -> Encoding
$comitField :: TxMetaJSON -> Bool
omitField :: TxMetaJSON -> Bool
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_txMetaJSON", CamelToSnake]] TxMetaJSON
instance ToSample TxMetaJSON where
toSamples :: Proxy TxMetaJSON -> [(Text, TxMetaJSON)]
toSamples =
let oracleMeta :: Text -> Value
oracleMeta Text
val =
[Pair] -> Value
object [
Key
"ADAUSD" Key -> [Value] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=
[ [Pair] -> Value
object [ Key
"value" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
val :: Text)
, Key
"source" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"ergoOracles" :: Text) ]
]
]
in [(Text, TxMetaJSON)] -> Proxy TxMetaJSON -> [(Text, TxMetaJSON)]
forall a. a -> Proxy TxMetaJSON -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, TxMetaJSON)] -> Proxy TxMetaJSON -> [(Text, TxMetaJSON)])
-> [(Text, TxMetaJSON)] -> Proxy TxMetaJSON -> [(Text, TxMetaJSON)]
forall a b. (a -> b) -> a -> b
$ [TxMetaJSON] -> [(Text, TxMetaJSON)]
forall a. [a] -> [(Text, a)]
samples
[ TxHash -> Maybe Value -> TxMetaJSON
TxMetaJSON
TxHash
"257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8"
(Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Text -> Value
oracleMeta Text
"0.10409800535729975")
, TxHash -> Maybe Value -> TxMetaJSON
TxMetaJSON
TxHash
"e865f2cc01ca7381cf98dcdc4de07a5e8674b8ea16e6a18e3ed60c186fde2b9c"
(Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Text -> Value
oracleMeta Text
"0.15409850555139935")
, TxHash -> Maybe Value -> TxMetaJSON
TxMetaJSON
TxHash
"4237501da3cfdd53ade91e8911e764bd0699d88fd43b12f44a1f459b89bc91be"
Maybe Value
forall a. Maybe a
Nothing
]
data TxMetaCBOR = TxMetaCBOR
{ TxMetaCBOR -> TxHash
_txMetaCBORTxHash :: TxHash
, TxMetaCBOR -> Maybe Text
_txMetaCBORMetadata :: Maybe Text
}
deriving stock (Int -> TxMetaCBOR -> ShowS
[TxMetaCBOR] -> ShowS
TxMetaCBOR -> String
(Int -> TxMetaCBOR -> ShowS)
-> (TxMetaCBOR -> String)
-> ([TxMetaCBOR] -> ShowS)
-> Show TxMetaCBOR
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxMetaCBOR -> ShowS
showsPrec :: Int -> TxMetaCBOR -> ShowS
$cshow :: TxMetaCBOR -> String
show :: TxMetaCBOR -> String
$cshowList :: [TxMetaCBOR] -> ShowS
showList :: [TxMetaCBOR] -> ShowS
Show, TxMetaCBOR -> TxMetaCBOR -> Bool
(TxMetaCBOR -> TxMetaCBOR -> Bool)
-> (TxMetaCBOR -> TxMetaCBOR -> Bool) -> Eq TxMetaCBOR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxMetaCBOR -> TxMetaCBOR -> Bool
== :: TxMetaCBOR -> TxMetaCBOR -> Bool
$c/= :: TxMetaCBOR -> TxMetaCBOR -> Bool
/= :: TxMetaCBOR -> TxMetaCBOR -> Bool
Eq, (forall x. TxMetaCBOR -> Rep TxMetaCBOR x)
-> (forall x. Rep TxMetaCBOR x -> TxMetaCBOR) -> Generic TxMetaCBOR
forall x. Rep TxMetaCBOR x -> TxMetaCBOR
forall x. TxMetaCBOR -> Rep TxMetaCBOR x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TxMetaCBOR -> Rep TxMetaCBOR x
from :: forall x. TxMetaCBOR -> Rep TxMetaCBOR x
$cto :: forall x. Rep TxMetaCBOR x -> TxMetaCBOR
to :: forall x. Rep TxMetaCBOR x -> TxMetaCBOR
Generic)
deriving (Maybe TxMetaCBOR
Value -> Parser [TxMetaCBOR]
Value -> Parser TxMetaCBOR
(Value -> Parser TxMetaCBOR)
-> (Value -> Parser [TxMetaCBOR])
-> Maybe TxMetaCBOR
-> FromJSON TxMetaCBOR
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser TxMetaCBOR
parseJSON :: Value -> Parser TxMetaCBOR
$cparseJSONList :: Value -> Parser [TxMetaCBOR]
parseJSONList :: Value -> Parser [TxMetaCBOR]
$comittedField :: Maybe TxMetaCBOR
omittedField :: Maybe TxMetaCBOR
FromJSON, [TxMetaCBOR] -> Value
[TxMetaCBOR] -> Encoding
TxMetaCBOR -> Bool
TxMetaCBOR -> Value
TxMetaCBOR -> Encoding
(TxMetaCBOR -> Value)
-> (TxMetaCBOR -> Encoding)
-> ([TxMetaCBOR] -> Value)
-> ([TxMetaCBOR] -> Encoding)
-> (TxMetaCBOR -> Bool)
-> ToJSON TxMetaCBOR
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: TxMetaCBOR -> Value
toJSON :: TxMetaCBOR -> Value
$ctoEncoding :: TxMetaCBOR -> Encoding
toEncoding :: TxMetaCBOR -> Encoding
$ctoJSONList :: [TxMetaCBOR] -> Value
toJSONList :: [TxMetaCBOR] -> Value
$ctoEncodingList :: [TxMetaCBOR] -> Encoding
toEncodingList :: [TxMetaCBOR] -> Encoding
$comitField :: TxMetaCBOR -> Bool
omitField :: TxMetaCBOR -> Bool
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_txMetaCBOR", CamelToSnake]] TxMetaCBOR
instance ToSample TxMetaCBOR where
toSamples :: Proxy TxMetaCBOR -> [(Text, TxMetaCBOR)]
toSamples = [(Text, TxMetaCBOR)] -> Proxy TxMetaCBOR -> [(Text, TxMetaCBOR)]
forall a. a -> Proxy TxMetaCBOR -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, TxMetaCBOR)] -> Proxy TxMetaCBOR -> [(Text, TxMetaCBOR)])
-> [(Text, TxMetaCBOR)] -> Proxy TxMetaCBOR -> [(Text, TxMetaCBOR)]
forall a b. (a -> b) -> a -> b
$ [TxMetaCBOR] -> [(Text, TxMetaCBOR)]
forall a. [a] -> [(Text, a)]
samples
[ TxHash -> Maybe Text -> TxMetaCBOR
TxMetaCBOR
TxHash
"257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8"
Maybe Text
forall a. Maybe a
Nothing
, TxHash -> Maybe Text -> TxMetaCBOR
TxMetaCBOR
TxHash
"e865f2cc01ca7381cf98dcdc4de07a5e8674b8ea16e6a18e3ed60c186fde2b9c"
Maybe Text
forall a. Maybe a
Nothing
, TxHash -> Maybe Text -> TxMetaCBOR
TxMetaCBOR
TxHash
"4237501da3cfdd53ade91e8911e764bd0699d88fd43b12f44a1f459b89bc91be"
(Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"a100a16b436f6d62696e6174696f6e8601010101010c")
]