module Blockfrost.Types.NutLink
( NutlinkAddress (..)
, NutlinkAddressTicker (..)
, NutlinkTicker (..)
) where
import Blockfrost.Types.Shared
import Data.Aeson
import Data.Text (Text)
import Deriving.Aeson
import Servant.Docs (ToSample (..), samples, singleSample)
data NutlinkAddress = NutlinkAddress
{ NutlinkAddress -> Address
_nutlinkAddressAddress :: Address
, NutlinkAddress -> Text
_nutlinkAddressMetadataUrl :: Text
, NutlinkAddress -> Text
_nutlinkAddressMetadataHash :: Text
, NutlinkAddress -> Maybe Value
_nutlinkAddressMetadata :: Maybe Value
}
deriving stock (Int -> NutlinkAddress -> ShowS
[NutlinkAddress] -> ShowS
NutlinkAddress -> String
(Int -> NutlinkAddress -> ShowS)
-> (NutlinkAddress -> String)
-> ([NutlinkAddress] -> ShowS)
-> Show NutlinkAddress
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NutlinkAddress -> ShowS
showsPrec :: Int -> NutlinkAddress -> ShowS
$cshow :: NutlinkAddress -> String
show :: NutlinkAddress -> String
$cshowList :: [NutlinkAddress] -> ShowS
showList :: [NutlinkAddress] -> ShowS
Show, NutlinkAddress -> NutlinkAddress -> Bool
(NutlinkAddress -> NutlinkAddress -> Bool)
-> (NutlinkAddress -> NutlinkAddress -> Bool) -> Eq NutlinkAddress
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NutlinkAddress -> NutlinkAddress -> Bool
== :: NutlinkAddress -> NutlinkAddress -> Bool
$c/= :: NutlinkAddress -> NutlinkAddress -> Bool
/= :: NutlinkAddress -> NutlinkAddress -> Bool
Eq, (forall x. NutlinkAddress -> Rep NutlinkAddress x)
-> (forall x. Rep NutlinkAddress x -> NutlinkAddress)
-> Generic NutlinkAddress
forall x. Rep NutlinkAddress x -> NutlinkAddress
forall x. NutlinkAddress -> Rep NutlinkAddress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NutlinkAddress -> Rep NutlinkAddress x
from :: forall x. NutlinkAddress -> Rep NutlinkAddress x
$cto :: forall x. Rep NutlinkAddress x -> NutlinkAddress
to :: forall x. Rep NutlinkAddress x -> NutlinkAddress
Generic)
deriving (Maybe NutlinkAddress
Value -> Parser [NutlinkAddress]
Value -> Parser NutlinkAddress
(Value -> Parser NutlinkAddress)
-> (Value -> Parser [NutlinkAddress])
-> Maybe NutlinkAddress
-> FromJSON NutlinkAddress
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser NutlinkAddress
parseJSON :: Value -> Parser NutlinkAddress
$cparseJSONList :: Value -> Parser [NutlinkAddress]
parseJSONList :: Value -> Parser [NutlinkAddress]
$comittedField :: Maybe NutlinkAddress
omittedField :: Maybe NutlinkAddress
FromJSON, [NutlinkAddress] -> Value
[NutlinkAddress] -> Encoding
NutlinkAddress -> Bool
NutlinkAddress -> Value
NutlinkAddress -> Encoding
(NutlinkAddress -> Value)
-> (NutlinkAddress -> Encoding)
-> ([NutlinkAddress] -> Value)
-> ([NutlinkAddress] -> Encoding)
-> (NutlinkAddress -> Bool)
-> ToJSON NutlinkAddress
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: NutlinkAddress -> Value
toJSON :: NutlinkAddress -> Value
$ctoEncoding :: NutlinkAddress -> Encoding
toEncoding :: NutlinkAddress -> Encoding
$ctoJSONList :: [NutlinkAddress] -> Value
toJSONList :: [NutlinkAddress] -> Value
$ctoEncodingList :: [NutlinkAddress] -> Encoding
toEncodingList :: [NutlinkAddress] -> Encoding
$comitField :: NutlinkAddress -> Bool
omitField :: NutlinkAddress -> Bool
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_nutlinkAddress", CamelToSnake]] NutlinkAddress
instance ToSample NutlinkAddress where
toSamples :: Proxy NutlinkAddress -> [(Text, NutlinkAddress)]
toSamples = [(Text, NutlinkAddress)]
-> Proxy NutlinkAddress -> [(Text, NutlinkAddress)]
forall a. a -> Proxy NutlinkAddress -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, NutlinkAddress)]
-> Proxy NutlinkAddress -> [(Text, NutlinkAddress)])
-> [(Text, NutlinkAddress)]
-> Proxy NutlinkAddress
-> [(Text, NutlinkAddress)]
forall a b. (a -> b) -> a -> b
$ NutlinkAddress -> [(Text, NutlinkAddress)]
forall a. a -> [(Text, a)]
singleSample (NutlinkAddress -> [(Text, NutlinkAddress)])
-> NutlinkAddress -> [(Text, NutlinkAddress)]
forall a b. (a -> b) -> a -> b
$
NutlinkAddress
{ $sel:_nutlinkAddressAddress:NutlinkAddress :: Address
_nutlinkAddressAddress = Address
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz"
, $sel:_nutlinkAddressMetadataUrl:NutlinkAddress :: Text
_nutlinkAddressMetadataUrl = Text
"https://nut.link/metadata.json"
, $sel:_nutlinkAddressMetadataHash:NutlinkAddress :: Text
_nutlinkAddressMetadataHash = Text
"6bf124f217d0e5a0a8adb1dbd8540e1334280d49ab861127868339f43b3948af"
, $sel:_nutlinkAddressMetadata:NutlinkAddress :: Maybe Value
_nutlinkAddressMetadata = Value -> Maybe Value
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ [Pair] -> Value
object []
}
data NutlinkAddressTicker = NutlinkAddressTicker
{ NutlinkAddressTicker -> Text
_nutlinkAddressTickerName :: Text
, NutlinkAddressTicker -> Integer
_nutlinkAddressTickerCount :: Integer
, NutlinkAddressTicker -> Integer
_nutlinkAddressTickerLatestBlock :: Integer
}
deriving stock (Int -> NutlinkAddressTicker -> ShowS
[NutlinkAddressTicker] -> ShowS
NutlinkAddressTicker -> String
(Int -> NutlinkAddressTicker -> ShowS)
-> (NutlinkAddressTicker -> String)
-> ([NutlinkAddressTicker] -> ShowS)
-> Show NutlinkAddressTicker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NutlinkAddressTicker -> ShowS
showsPrec :: Int -> NutlinkAddressTicker -> ShowS
$cshow :: NutlinkAddressTicker -> String
show :: NutlinkAddressTicker -> String
$cshowList :: [NutlinkAddressTicker] -> ShowS
showList :: [NutlinkAddressTicker] -> ShowS
Show, NutlinkAddressTicker -> NutlinkAddressTicker -> Bool
(NutlinkAddressTicker -> NutlinkAddressTicker -> Bool)
-> (NutlinkAddressTicker -> NutlinkAddressTicker -> Bool)
-> Eq NutlinkAddressTicker
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NutlinkAddressTicker -> NutlinkAddressTicker -> Bool
== :: NutlinkAddressTicker -> NutlinkAddressTicker -> Bool
$c/= :: NutlinkAddressTicker -> NutlinkAddressTicker -> Bool
/= :: NutlinkAddressTicker -> NutlinkAddressTicker -> Bool
Eq, (forall x. NutlinkAddressTicker -> Rep NutlinkAddressTicker x)
-> (forall x. Rep NutlinkAddressTicker x -> NutlinkAddressTicker)
-> Generic NutlinkAddressTicker
forall x. Rep NutlinkAddressTicker x -> NutlinkAddressTicker
forall x. NutlinkAddressTicker -> Rep NutlinkAddressTicker x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NutlinkAddressTicker -> Rep NutlinkAddressTicker x
from :: forall x. NutlinkAddressTicker -> Rep NutlinkAddressTicker x
$cto :: forall x. Rep NutlinkAddressTicker x -> NutlinkAddressTicker
to :: forall x. Rep NutlinkAddressTicker x -> NutlinkAddressTicker
Generic)
deriving (Maybe NutlinkAddressTicker
Value -> Parser [NutlinkAddressTicker]
Value -> Parser NutlinkAddressTicker
(Value -> Parser NutlinkAddressTicker)
-> (Value -> Parser [NutlinkAddressTicker])
-> Maybe NutlinkAddressTicker
-> FromJSON NutlinkAddressTicker
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser NutlinkAddressTicker
parseJSON :: Value -> Parser NutlinkAddressTicker
$cparseJSONList :: Value -> Parser [NutlinkAddressTicker]
parseJSONList :: Value -> Parser [NutlinkAddressTicker]
$comittedField :: Maybe NutlinkAddressTicker
omittedField :: Maybe NutlinkAddressTicker
FromJSON, [NutlinkAddressTicker] -> Value
[NutlinkAddressTicker] -> Encoding
NutlinkAddressTicker -> Bool
NutlinkAddressTicker -> Value
NutlinkAddressTicker -> Encoding
(NutlinkAddressTicker -> Value)
-> (NutlinkAddressTicker -> Encoding)
-> ([NutlinkAddressTicker] -> Value)
-> ([NutlinkAddressTicker] -> Encoding)
-> (NutlinkAddressTicker -> Bool)
-> ToJSON NutlinkAddressTicker
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: NutlinkAddressTicker -> Value
toJSON :: NutlinkAddressTicker -> Value
$ctoEncoding :: NutlinkAddressTicker -> Encoding
toEncoding :: NutlinkAddressTicker -> Encoding
$ctoJSONList :: [NutlinkAddressTicker] -> Value
toJSONList :: [NutlinkAddressTicker] -> Value
$ctoEncodingList :: [NutlinkAddressTicker] -> Encoding
toEncodingList :: [NutlinkAddressTicker] -> Encoding
$comitField :: NutlinkAddressTicker -> Bool
omitField :: NutlinkAddressTicker -> Bool
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_nutlinkAddressTicker", CamelToSnake]] NutlinkAddressTicker
instance ToSample NutlinkAddressTicker where
toSamples :: Proxy NutlinkAddressTicker -> [(Text, NutlinkAddressTicker)]
toSamples = [(Text, NutlinkAddressTicker)]
-> Proxy NutlinkAddressTicker -> [(Text, NutlinkAddressTicker)]
forall a. a -> Proxy NutlinkAddressTicker -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, NutlinkAddressTicker)]
-> Proxy NutlinkAddressTicker -> [(Text, NutlinkAddressTicker)])
-> [(Text, NutlinkAddressTicker)]
-> Proxy NutlinkAddressTicker
-> [(Text, NutlinkAddressTicker)]
forall a b. (a -> b) -> a -> b
$ [NutlinkAddressTicker] -> [(Text, NutlinkAddressTicker)]
forall a. [a] -> [(Text, a)]
samples ([NutlinkAddressTicker] -> [(Text, NutlinkAddressTicker)])
-> [NutlinkAddressTicker] -> [(Text, NutlinkAddressTicker)]
forall a b. (a -> b) -> a -> b
$
[ NutlinkAddressTicker
{ $sel:_nutlinkAddressTickerName:NutlinkAddressTicker :: Text
_nutlinkAddressTickerName = Text
"ADAUSD"
, $sel:_nutlinkAddressTickerCount:NutlinkAddressTicker :: Integer
_nutlinkAddressTickerCount = Integer
1980038
, $sel:_nutlinkAddressTickerLatestBlock:NutlinkAddressTicker :: Integer
_nutlinkAddressTickerLatestBlock = Integer
2657092
}
, NutlinkAddressTicker
{ $sel:_nutlinkAddressTickerName:NutlinkAddressTicker :: Text
_nutlinkAddressTickerName = Text
"ADAEUR"
, $sel:_nutlinkAddressTickerCount:NutlinkAddressTicker :: Integer
_nutlinkAddressTickerCount = Integer
1980038
, $sel:_nutlinkAddressTickerLatestBlock:NutlinkAddressTicker :: Integer
_nutlinkAddressTickerLatestBlock = Integer
2657092
}
, NutlinkAddressTicker
{ $sel:_nutlinkAddressTickerName:NutlinkAddressTicker :: Text
_nutlinkAddressTickerName = Text
"ADABTC"
, $sel:_nutlinkAddressTickerCount:NutlinkAddressTicker :: Integer
_nutlinkAddressTickerCount = Integer
1980038
, $sel:_nutlinkAddressTickerLatestBlock:NutlinkAddressTicker :: Integer
_nutlinkAddressTickerLatestBlock = Integer
2657092
}
]
data NutlinkTicker = NutlinkTicker
{ NutlinkTicker -> TxHash
_nutlinkTickerTxHash :: TxHash
, NutlinkTicker -> Integer
_nutlinkTickerBlockHeight :: Integer
, NutlinkTicker -> Integer
_nutlinkTickerTxIndex :: Integer
, NutlinkTicker -> Value
_nutlinkTickerPayload :: Value
}
deriving stock (Int -> NutlinkTicker -> ShowS
[NutlinkTicker] -> ShowS
NutlinkTicker -> String
(Int -> NutlinkTicker -> ShowS)
-> (NutlinkTicker -> String)
-> ([NutlinkTicker] -> ShowS)
-> Show NutlinkTicker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NutlinkTicker -> ShowS
showsPrec :: Int -> NutlinkTicker -> ShowS
$cshow :: NutlinkTicker -> String
show :: NutlinkTicker -> String
$cshowList :: [NutlinkTicker] -> ShowS
showList :: [NutlinkTicker] -> ShowS
Show, NutlinkTicker -> NutlinkTicker -> Bool
(NutlinkTicker -> NutlinkTicker -> Bool)
-> (NutlinkTicker -> NutlinkTicker -> Bool) -> Eq NutlinkTicker
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NutlinkTicker -> NutlinkTicker -> Bool
== :: NutlinkTicker -> NutlinkTicker -> Bool
$c/= :: NutlinkTicker -> NutlinkTicker -> Bool
/= :: NutlinkTicker -> NutlinkTicker -> Bool
Eq, (forall x. NutlinkTicker -> Rep NutlinkTicker x)
-> (forall x. Rep NutlinkTicker x -> NutlinkTicker)
-> Generic NutlinkTicker
forall x. Rep NutlinkTicker x -> NutlinkTicker
forall x. NutlinkTicker -> Rep NutlinkTicker x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NutlinkTicker -> Rep NutlinkTicker x
from :: forall x. NutlinkTicker -> Rep NutlinkTicker x
$cto :: forall x. Rep NutlinkTicker x -> NutlinkTicker
to :: forall x. Rep NutlinkTicker x -> NutlinkTicker
Generic)
deriving (Maybe NutlinkTicker
Value -> Parser [NutlinkTicker]
Value -> Parser NutlinkTicker
(Value -> Parser NutlinkTicker)
-> (Value -> Parser [NutlinkTicker])
-> Maybe NutlinkTicker
-> FromJSON NutlinkTicker
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser NutlinkTicker
parseJSON :: Value -> Parser NutlinkTicker
$cparseJSONList :: Value -> Parser [NutlinkTicker]
parseJSONList :: Value -> Parser [NutlinkTicker]
$comittedField :: Maybe NutlinkTicker
omittedField :: Maybe NutlinkTicker
FromJSON, [NutlinkTicker] -> Value
[NutlinkTicker] -> Encoding
NutlinkTicker -> Bool
NutlinkTicker -> Value
NutlinkTicker -> Encoding
(NutlinkTicker -> Value)
-> (NutlinkTicker -> Encoding)
-> ([NutlinkTicker] -> Value)
-> ([NutlinkTicker] -> Encoding)
-> (NutlinkTicker -> Bool)
-> ToJSON NutlinkTicker
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: NutlinkTicker -> Value
toJSON :: NutlinkTicker -> Value
$ctoEncoding :: NutlinkTicker -> Encoding
toEncoding :: NutlinkTicker -> Encoding
$ctoJSONList :: [NutlinkTicker] -> Value
toJSONList :: [NutlinkTicker] -> Value
$ctoEncodingList :: [NutlinkTicker] -> Encoding
toEncodingList :: [NutlinkTicker] -> Encoding
$comitField :: NutlinkTicker -> Bool
omitField :: NutlinkTicker -> Bool
ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_nutlinkTicker", CamelToSnake]] NutlinkTicker
instance ToSample NutlinkTicker where
toSamples :: Proxy NutlinkTicker -> [(Text, NutlinkTicker)]
toSamples = [(Text, NutlinkTicker)]
-> Proxy NutlinkTicker -> [(Text, NutlinkTicker)]
forall a. a -> Proxy NutlinkTicker -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, NutlinkTicker)]
-> Proxy NutlinkTicker -> [(Text, NutlinkTicker)])
-> [(Text, NutlinkTicker)]
-> Proxy NutlinkTicker
-> [(Text, NutlinkTicker)]
forall a b. (a -> b) -> a -> b
$ NutlinkTicker -> [(Text, NutlinkTicker)]
forall a. a -> [(Text, a)]
singleSample (NutlinkTicker -> [(Text, NutlinkTicker)])
-> NutlinkTicker -> [(Text, NutlinkTicker)]
forall a b. (a -> b) -> a -> b
$
NutlinkTicker
{ $sel:_nutlinkTickerTxHash:NutlinkTicker :: TxHash
_nutlinkTickerTxHash = TxHash
"e8073fd5318ff43eca18a852527166aa8008bee9ee9e891f585612b7e4ba700b"
, $sel:_nutlinkTickerBlockHeight:NutlinkTicker :: Integer
_nutlinkTickerBlockHeight = Integer
2657092
, $sel:_nutlinkTickerTxIndex:NutlinkTicker :: Integer
_nutlinkTickerTxIndex = Integer
8
, $sel:_nutlinkTickerPayload:NutlinkTicker :: Value
_nutlinkTickerPayload = [Pair] -> Value
object []
}
instance {-# OVERLAPS #-} ToJSON (Address, NutlinkTicker) where
toJSON :: (Address, NutlinkTicker) -> Value
toJSON (Address
addr, NutlinkTicker
nt) = case NutlinkTicker -> Value
forall a. ToJSON a => a -> Value
toJSON NutlinkTicker
nt of
(Object Object
o) -> Object -> Value
Object (Object
o Object -> Object -> Object
forall a. Semigroup a => a -> a -> a
<> (Key
"address" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Address -> Value
forall a. ToJSON a => a -> Value
toJSON Address
addr)))
Value
_ -> String -> Value
forall a. HasCallStack => String -> a
error String
"Absurd"
instance {-# OVERLAPS #-} FromJSON (Address, NutlinkTicker) where
parseJSON :: Value -> Parser (Address, NutlinkTicker)
parseJSON v :: Value
v@(Object Object
o) = do
Address
addr <- Object
o Object -> Key -> Parser Address
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
NutlinkTicker
ticker <- Value -> Parser NutlinkTicker
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
(Address, NutlinkTicker) -> Parser (Address, NutlinkTicker)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Address
addr, NutlinkTicker
ticker)
parseJSON Value
_ = String -> Parser (Address, NutlinkTicker)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Unexpected type for (Address, NutlinkTicker)"