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
showList :: [TxMeta] -> ShowS
$cshowList :: [TxMeta] -> ShowS
show :: TxMeta -> String
$cshow :: TxMeta -> String
showsPrec :: Int -> TxMeta -> ShowS
$cshowsPrec :: Int -> TxMeta -> ShowS
Show, TxMeta -> TxMeta -> Bool
(TxMeta -> TxMeta -> Bool)
-> (TxMeta -> TxMeta -> Bool) -> Eq TxMeta
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. 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
$cto :: forall x. Rep TxMeta x -> TxMeta
$cfrom :: forall x. TxMeta -> Rep TxMeta x
Generic)
deriving (Value -> Parser [TxMeta]
Value -> Parser TxMeta
(Value -> Parser TxMeta)
-> (Value -> Parser [TxMeta]) -> FromJSON TxMeta
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [TxMeta]
$cparseJSONList :: Value -> Parser [TxMeta]
parseJSON :: Value -> Parser TxMeta
$cparseJSON :: Value -> Parser TxMeta
FromJSON, [TxMeta] -> Encoding
[TxMeta] -> Value
TxMeta -> Encoding
TxMeta -> Value
(TxMeta -> Value)
-> (TxMeta -> Encoding)
-> ([TxMeta] -> Value)
-> ([TxMeta] -> Encoding)
-> ToJSON TxMeta
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
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 = [(Text, TxMeta)] -> Proxy TxMeta -> [(Text, TxMeta)]
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
showList :: [TxMetaJSON] -> ShowS
$cshowList :: [TxMetaJSON] -> ShowS
show :: TxMetaJSON -> String
$cshow :: TxMetaJSON -> String
showsPrec :: Int -> TxMetaJSON -> ShowS
$cshowsPrec :: Int -> TxMetaJSON -> ShowS
Show, TxMetaJSON -> TxMetaJSON -> Bool
(TxMetaJSON -> TxMetaJSON -> Bool)
-> (TxMetaJSON -> TxMetaJSON -> Bool) -> Eq TxMetaJSON
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. 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
$cto :: forall x. Rep TxMetaJSON x -> TxMetaJSON
$cfrom :: forall x. TxMetaJSON -> Rep TxMetaJSON x
Generic)
deriving (Value -> Parser [TxMetaJSON]
Value -> Parser TxMetaJSON
(Value -> Parser TxMetaJSON)
-> (Value -> Parser [TxMetaJSON]) -> FromJSON TxMetaJSON
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [TxMetaJSON]
$cparseJSONList :: Value -> Parser [TxMetaJSON]
parseJSON :: Value -> Parser TxMetaJSON
$cparseJSON :: Value -> Parser TxMetaJSON
FromJSON, [TxMetaJSON] -> Encoding
[TxMetaJSON] -> Value
TxMetaJSON -> Encoding
TxMetaJSON -> Value
(TxMetaJSON -> Value)
-> (TxMetaJSON -> Encoding)
-> ([TxMetaJSON] -> Value)
-> ([TxMetaJSON] -> Encoding)
-> ToJSON TxMetaJSON
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
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" Key -> [Value] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=
[ [Pair] -> Value
object [ Key
"value" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Text
val :: Text)
, Key
"source" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Text
"ergoOracles" :: Text) ]
]
]
in [(Text, TxMetaJSON)] -> Proxy TxMetaJSON -> [(Text, TxMetaJSON)]
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
showList :: [TxMetaCBOR] -> ShowS
$cshowList :: [TxMetaCBOR] -> ShowS
show :: TxMetaCBOR -> String
$cshow :: TxMetaCBOR -> String
showsPrec :: Int -> TxMetaCBOR -> ShowS
$cshowsPrec :: Int -> TxMetaCBOR -> ShowS
Show, TxMetaCBOR -> TxMetaCBOR -> Bool
(TxMetaCBOR -> TxMetaCBOR -> Bool)
-> (TxMetaCBOR -> TxMetaCBOR -> Bool) -> Eq TxMetaCBOR
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. 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
$cto :: forall x. Rep TxMetaCBOR x -> TxMetaCBOR
$cfrom :: forall x. TxMetaCBOR -> Rep TxMetaCBOR x
Generic)
deriving (Value -> Parser [TxMetaCBOR]
Value -> Parser TxMetaCBOR
(Value -> Parser TxMetaCBOR)
-> (Value -> Parser [TxMetaCBOR]) -> FromJSON TxMetaCBOR
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [TxMetaCBOR]
$cparseJSONList :: Value -> Parser [TxMetaCBOR]
parseJSON :: Value -> Parser TxMetaCBOR
$cparseJSON :: Value -> Parser TxMetaCBOR
FromJSON, [TxMetaCBOR] -> Encoding
[TxMetaCBOR] -> Value
TxMetaCBOR -> Encoding
TxMetaCBOR -> Value
(TxMetaCBOR -> Value)
-> (TxMetaCBOR -> Encoding)
-> ([TxMetaCBOR] -> Value)
-> ([TxMetaCBOR] -> Encoding)
-> ToJSON TxMetaCBOR
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
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 = [(Text, TxMetaCBOR)] -> Proxy TxMetaCBOR -> [(Text, TxMetaCBOR)]
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")
]