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
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxMeta] -> ShowS
$cshowList :: [TxMeta] -> ShowS
show :: TxMeta -> String
$cshow :: TxMeta -> String
showsPrec :: Int -> TxMeta -> ShowS
$cshowsPrec :: Int -> TxMeta -> ShowS
Show, TxMeta -> TxMeta -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TxMeta -> TxMeta -> Bool
$c/= :: TxMeta -> TxMeta -> Bool
== :: TxMeta -> TxMeta -> Bool
$c== :: TxMeta -> TxMeta -> Bool
Eq, 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
$cto :: forall x. Rep TxMeta x -> TxMeta
$cfrom :: forall x. TxMeta -> Rep TxMeta x
Generic)
deriving (Maybe TxMeta
Value -> Parser [TxMeta]
Value -> Parser TxMeta
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe TxMeta
$comittedField :: Maybe TxMeta
parseJSONList :: Value -> Parser [TxMeta]
$cparseJSONList :: Value -> Parser [TxMeta]
parseJSON :: Value -> Parser TxMeta
$cparseJSON :: Value -> Parser TxMeta
FromJSON, [TxMeta] -> Encoding
[TxMeta] -> Value
TxMeta -> Bool
TxMeta -> Encoding
TxMeta -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: TxMeta -> Bool
$comitField :: TxMeta -> Bool
toEncodingList :: [TxMeta] -> Encoding
$ctoEncodingList :: [TxMeta] -> Encoding
toJSONList :: [TxMeta] -> Value
$ctoJSONList :: [TxMeta] -> Value
toEncoding :: TxMeta -> Encoding
$ctoEncoding :: TxMeta -> Encoding
toJSON :: TxMeta -> Value
$ctoJSON :: TxMeta -> Value
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_txMeta", CamelToSnake]] TxMeta
instance ToSample TxMeta where
toSamples :: Proxy TxMeta -> [(Text, TxMeta)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
[ Text -> Maybe Text -> Quantity -> TxMeta
TxMeta Text
"1990" forall a. Maybe a
Nothing Quantity
1
, Text -> Maybe Text -> Quantity -> TxMeta
TxMeta Text
"1967" (forall a. a -> Maybe a
Just Text
"nut.link metadata oracles registry") Quantity
3
, Text -> Maybe Text -> Quantity -> TxMeta
TxMeta Text
"1968" (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
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxMetaJSON] -> ShowS
$cshowList :: [TxMetaJSON] -> ShowS
show :: TxMetaJSON -> String
$cshow :: TxMetaJSON -> String
showsPrec :: Int -> TxMetaJSON -> ShowS
$cshowsPrec :: Int -> TxMetaJSON -> ShowS
Show, TxMetaJSON -> TxMetaJSON -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TxMetaJSON -> TxMetaJSON -> Bool
$c/= :: TxMetaJSON -> TxMetaJSON -> Bool
== :: TxMetaJSON -> TxMetaJSON -> Bool
$c== :: TxMetaJSON -> TxMetaJSON -> Bool
Eq, 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
$cto :: forall x. Rep TxMetaJSON x -> TxMetaJSON
$cfrom :: forall x. TxMetaJSON -> Rep TxMetaJSON x
Generic)
deriving (Maybe TxMetaJSON
Value -> Parser [TxMetaJSON]
Value -> Parser TxMetaJSON
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe TxMetaJSON
$comittedField :: Maybe TxMetaJSON
parseJSONList :: Value -> Parser [TxMetaJSON]
$cparseJSONList :: Value -> Parser [TxMetaJSON]
parseJSON :: Value -> Parser TxMetaJSON
$cparseJSON :: Value -> Parser TxMetaJSON
FromJSON, [TxMetaJSON] -> Encoding
[TxMetaJSON] -> Value
TxMetaJSON -> Bool
TxMetaJSON -> Encoding
TxMetaJSON -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: TxMetaJSON -> Bool
$comitField :: TxMetaJSON -> Bool
toEncodingList :: [TxMetaJSON] -> Encoding
$ctoEncodingList :: [TxMetaJSON] -> Encoding
toJSONList :: [TxMetaJSON] -> Value
$ctoJSONList :: [TxMetaJSON] -> Value
toEncoding :: TxMetaJSON -> Encoding
$ctoEncoding :: TxMetaJSON -> Encoding
toJSON :: TxMetaJSON -> Value
$ctoJSON :: TxMetaJSON -> Value
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" forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=
[ [Pair] -> Value
object [ Key
"value" forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
val :: Text)
, Key
"source" forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"ergoOracles" :: Text) ]
]
]
in forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
[ TxHash -> Maybe Value -> TxMetaJSON
TxMetaJSON
TxHash
"257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8"
(forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Text -> Value
oracleMeta Text
"0.10409800535729975")
, TxHash -> Maybe Value -> TxMetaJSON
TxMetaJSON
TxHash
"e865f2cc01ca7381cf98dcdc4de07a5e8674b8ea16e6a18e3ed60c186fde2b9c"
(forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Text -> Value
oracleMeta Text
"0.15409850555139935")
, TxHash -> Maybe Value -> TxMetaJSON
TxMetaJSON
TxHash
"4237501da3cfdd53ade91e8911e764bd0699d88fd43b12f44a1f459b89bc91be"
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
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxMetaCBOR] -> ShowS
$cshowList :: [TxMetaCBOR] -> ShowS
show :: TxMetaCBOR -> String
$cshow :: TxMetaCBOR -> String
showsPrec :: Int -> TxMetaCBOR -> ShowS
$cshowsPrec :: Int -> TxMetaCBOR -> ShowS
Show, TxMetaCBOR -> TxMetaCBOR -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TxMetaCBOR -> TxMetaCBOR -> Bool
$c/= :: TxMetaCBOR -> TxMetaCBOR -> Bool
== :: TxMetaCBOR -> TxMetaCBOR -> Bool
$c== :: TxMetaCBOR -> TxMetaCBOR -> Bool
Eq, 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
$cto :: forall x. Rep TxMetaCBOR x -> TxMetaCBOR
$cfrom :: forall x. TxMetaCBOR -> Rep TxMetaCBOR x
Generic)
deriving (Maybe TxMetaCBOR
Value -> Parser [TxMetaCBOR]
Value -> Parser TxMetaCBOR
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe TxMetaCBOR
$comittedField :: Maybe TxMetaCBOR
parseJSONList :: Value -> Parser [TxMetaCBOR]
$cparseJSONList :: Value -> Parser [TxMetaCBOR]
parseJSON :: Value -> Parser TxMetaCBOR
$cparseJSON :: Value -> Parser TxMetaCBOR
FromJSON, [TxMetaCBOR] -> Encoding
[TxMetaCBOR] -> Value
TxMetaCBOR -> Bool
TxMetaCBOR -> Encoding
TxMetaCBOR -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: TxMetaCBOR -> Bool
$comitField :: TxMetaCBOR -> Bool
toEncodingList :: [TxMetaCBOR] -> Encoding
$ctoEncodingList :: [TxMetaCBOR] -> Encoding
toJSONList :: [TxMetaCBOR] -> Value
$ctoJSONList :: [TxMetaCBOR] -> Value
toEncoding :: TxMetaCBOR -> Encoding
$ctoEncoding :: TxMetaCBOR -> Encoding
toJSON :: TxMetaCBOR -> Value
$ctoJSON :: TxMetaCBOR -> Value
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_txMetaCBOR", CamelToSnake]] TxMetaCBOR
instance ToSample TxMetaCBOR where
toSamples :: Proxy TxMetaCBOR -> [(Text, TxMetaCBOR)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
[ TxHash -> Maybe Text -> TxMetaCBOR
TxMetaCBOR
TxHash
"257d75c8ddb0434e9b63e29ebb6241add2b835a307aa33aedba2effe09ed4ec8"
forall a. Maybe a
Nothing
, TxHash -> Maybe Text -> TxMetaCBOR
TxMetaCBOR
TxHash
"e865f2cc01ca7381cf98dcdc4de07a5e8674b8ea16e6a18e3ed60c186fde2b9c"
forall a. Maybe a
Nothing
, TxHash -> Maybe Text -> TxMetaCBOR
TxMetaCBOR
TxHash
"4237501da3cfdd53ade91e8911e764bd0699d88fd43b12f44a1f459b89bc91be"
(forall a. a -> Maybe a
Just Text
"a100a16b436f6d62696e6174696f6e8601010101010c")
]