-- | Responses for Cardano address queries

module Blockfrost.Types.Cardano.Addresses
  ( AddressInfo (..)
  , AddressInfoExtended (..)
  , AddressType (..)
  , AddressDetails (..)
  , AddressUtxo (..)
  , AddressTransaction (..)
  ) where

import Deriving.Aeson
import qualified Money
import Servant.Docs (ToSample (..), samples, singleSample)

import Blockfrost.Types.Cardano.Scripts (InlineDatum (..))
import Blockfrost.Types.Shared

-- | Information about Cardano address
data AddressInfo = AddressInfo
  { AddressInfo -> Address
_addressInfoAddress      :: Address -- ^ Bech32 encoded addresses
  , AddressInfo -> [Amount]
_addressInfoAmount       :: [Amount] -- ^ Lovelaces or tokens stored on this address
  , AddressInfo -> Maybe Address
_addressInfoStakeAddress :: Maybe Address -- ^ Stake address that controls the key
  , AddressInfo -> AddressType
_addressInfoType         :: AddressType -- ^ Address era
  , AddressInfo -> Bool
_addressInfoScript       :: Bool -- ^ True if this is a script address
  } deriving stock (Int -> AddressInfo -> ShowS
[AddressInfo] -> ShowS
AddressInfo -> String
(Int -> AddressInfo -> ShowS)
-> (AddressInfo -> String)
-> ([AddressInfo] -> ShowS)
-> Show AddressInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddressInfo -> ShowS
showsPrec :: Int -> AddressInfo -> ShowS
$cshow :: AddressInfo -> String
show :: AddressInfo -> String
$cshowList :: [AddressInfo] -> ShowS
showList :: [AddressInfo] -> ShowS
Show, AddressInfo -> AddressInfo -> Bool
(AddressInfo -> AddressInfo -> Bool)
-> (AddressInfo -> AddressInfo -> Bool) -> Eq AddressInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddressInfo -> AddressInfo -> Bool
== :: AddressInfo -> AddressInfo -> Bool
$c/= :: AddressInfo -> AddressInfo -> Bool
/= :: AddressInfo -> AddressInfo -> Bool
Eq, (forall x. AddressInfo -> Rep AddressInfo x)
-> (forall x. Rep AddressInfo x -> AddressInfo)
-> Generic AddressInfo
forall x. Rep AddressInfo x -> AddressInfo
forall x. AddressInfo -> Rep AddressInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddressInfo -> Rep AddressInfo x
from :: forall x. AddressInfo -> Rep AddressInfo x
$cto :: forall x. Rep AddressInfo x -> AddressInfo
to :: forall x. Rep AddressInfo x -> AddressInfo
Generic)
  deriving (Maybe AddressInfo
Value -> Parser [AddressInfo]
Value -> Parser AddressInfo
(Value -> Parser AddressInfo)
-> (Value -> Parser [AddressInfo])
-> Maybe AddressInfo
-> FromJSON AddressInfo
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AddressInfo
parseJSON :: Value -> Parser AddressInfo
$cparseJSONList :: Value -> Parser [AddressInfo]
parseJSONList :: Value -> Parser [AddressInfo]
$comittedField :: Maybe AddressInfo
omittedField :: Maybe AddressInfo
FromJSON, [AddressInfo] -> Value
[AddressInfo] -> Encoding
AddressInfo -> Bool
AddressInfo -> Value
AddressInfo -> Encoding
(AddressInfo -> Value)
-> (AddressInfo -> Encoding)
-> ([AddressInfo] -> Value)
-> ([AddressInfo] -> Encoding)
-> (AddressInfo -> Bool)
-> ToJSON AddressInfo
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AddressInfo -> Value
toJSON :: AddressInfo -> Value
$ctoEncoding :: AddressInfo -> Encoding
toEncoding :: AddressInfo -> Encoding
$ctoJSONList :: [AddressInfo] -> Value
toJSONList :: [AddressInfo] -> Value
$ctoEncodingList :: [AddressInfo] -> Encoding
toEncodingList :: [AddressInfo] -> Encoding
$comitField :: AddressInfo -> Bool
omitField :: AddressInfo -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressInfo", CamelToSnake]] AddressInfo

instance ToSample AddressInfo where
  toSamples :: Proxy AddressInfo -> [(Text, AddressInfo)]
toSamples = [(Text, AddressInfo)] -> Proxy AddressInfo -> [(Text, AddressInfo)]
forall a. a -> Proxy AddressInfo -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, AddressInfo)]
 -> Proxy AddressInfo -> [(Text, AddressInfo)])
-> [(Text, AddressInfo)]
-> Proxy AddressInfo
-> [(Text, AddressInfo)]
forall a b. (a -> b) -> a -> b
$ AddressInfo -> [(Text, AddressInfo)]
forall a. a -> [(Text, a)]
singleSample
    AddressInfo
      { $sel:_addressInfoAddress:AddressInfo :: Address
_addressInfoAddress = Address
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz"
      , $sel:_addressInfoAmount:AddressInfo :: [Amount]
_addressInfoAmount =
        [ Lovelaces -> Amount
AdaAmount Discrete' "ADA" '(1000000, 1)
Lovelaces
42000000
        , SomeDiscrete -> Amount
AssetAmount
            (SomeDiscrete -> Amount) -> SomeDiscrete -> Amount
forall a b. (a -> b) -> a -> b
$ Text -> Scale -> Integer -> SomeDiscrete
Money.mkSomeDiscrete
                Text
"b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
                Scale
unitScale
                Integer
12
        ]
      , $sel:_addressInfoStakeAddress:AddressInfo :: Maybe Address
_addressInfoStakeAddress = Address -> Maybe Address
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Address
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7"
      , $sel:_addressInfoType:AddressInfo :: AddressType
_addressInfoType = AddressType
Shelley
      , $sel:_addressInfoScript:AddressInfo :: Bool
_addressInfoScript = Bool
False
      }

-- | Information about Cardano address
data AddressInfoExtended = AddressInfoExtended
  { AddressInfoExtended -> Address
_addressInfoExtendedAddress      :: Address -- ^ Bech32 encoded addresses
  , AddressInfoExtended -> [AmountExtended]
_addressInfoExtendedAmount       :: [AmountExtended] -- ^ Lovelaces or tokens stored on this address
  , AddressInfoExtended -> Maybe Address
_addressInfoExtendedStakeAddress :: Maybe Address -- ^ Stake address that controls the key
  , AddressInfoExtended -> AddressType
_addressInfoExtendedType         :: AddressType -- ^ Address era
  , AddressInfoExtended -> Bool
_addressInfoExtendedScript       :: Bool -- ^ True if this is a script address
  } deriving stock (Int -> AddressInfoExtended -> ShowS
[AddressInfoExtended] -> ShowS
AddressInfoExtended -> String
(Int -> AddressInfoExtended -> ShowS)
-> (AddressInfoExtended -> String)
-> ([AddressInfoExtended] -> ShowS)
-> Show AddressInfoExtended
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddressInfoExtended -> ShowS
showsPrec :: Int -> AddressInfoExtended -> ShowS
$cshow :: AddressInfoExtended -> String
show :: AddressInfoExtended -> String
$cshowList :: [AddressInfoExtended] -> ShowS
showList :: [AddressInfoExtended] -> ShowS
Show, AddressInfoExtended -> AddressInfoExtended -> Bool
(AddressInfoExtended -> AddressInfoExtended -> Bool)
-> (AddressInfoExtended -> AddressInfoExtended -> Bool)
-> Eq AddressInfoExtended
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddressInfoExtended -> AddressInfoExtended -> Bool
== :: AddressInfoExtended -> AddressInfoExtended -> Bool
$c/= :: AddressInfoExtended -> AddressInfoExtended -> Bool
/= :: AddressInfoExtended -> AddressInfoExtended -> Bool
Eq, (forall x. AddressInfoExtended -> Rep AddressInfoExtended x)
-> (forall x. Rep AddressInfoExtended x -> AddressInfoExtended)
-> Generic AddressInfoExtended
forall x. Rep AddressInfoExtended x -> AddressInfoExtended
forall x. AddressInfoExtended -> Rep AddressInfoExtended x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddressInfoExtended -> Rep AddressInfoExtended x
from :: forall x. AddressInfoExtended -> Rep AddressInfoExtended x
$cto :: forall x. Rep AddressInfoExtended x -> AddressInfoExtended
to :: forall x. Rep AddressInfoExtended x -> AddressInfoExtended
Generic)
  deriving (Maybe AddressInfoExtended
Value -> Parser [AddressInfoExtended]
Value -> Parser AddressInfoExtended
(Value -> Parser AddressInfoExtended)
-> (Value -> Parser [AddressInfoExtended])
-> Maybe AddressInfoExtended
-> FromJSON AddressInfoExtended
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AddressInfoExtended
parseJSON :: Value -> Parser AddressInfoExtended
$cparseJSONList :: Value -> Parser [AddressInfoExtended]
parseJSONList :: Value -> Parser [AddressInfoExtended]
$comittedField :: Maybe AddressInfoExtended
omittedField :: Maybe AddressInfoExtended
FromJSON, [AddressInfoExtended] -> Value
[AddressInfoExtended] -> Encoding
AddressInfoExtended -> Bool
AddressInfoExtended -> Value
AddressInfoExtended -> Encoding
(AddressInfoExtended -> Value)
-> (AddressInfoExtended -> Encoding)
-> ([AddressInfoExtended] -> Value)
-> ([AddressInfoExtended] -> Encoding)
-> (AddressInfoExtended -> Bool)
-> ToJSON AddressInfoExtended
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AddressInfoExtended -> Value
toJSON :: AddressInfoExtended -> Value
$ctoEncoding :: AddressInfoExtended -> Encoding
toEncoding :: AddressInfoExtended -> Encoding
$ctoJSONList :: [AddressInfoExtended] -> Value
toJSONList :: [AddressInfoExtended] -> Value
$ctoEncodingList :: [AddressInfoExtended] -> Encoding
toEncodingList :: [AddressInfoExtended] -> Encoding
$comitField :: AddressInfoExtended -> Bool
omitField :: AddressInfoExtended -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressInfoExtended", CamelToSnake]] AddressInfoExtended

instance ToSample AddressInfoExtended where
  toSamples :: Proxy AddressInfoExtended -> [(Text, AddressInfoExtended)]
toSamples = [(Text, AddressInfoExtended)]
-> Proxy AddressInfoExtended -> [(Text, AddressInfoExtended)]
forall a. a -> Proxy AddressInfoExtended -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, AddressInfoExtended)]
 -> Proxy AddressInfoExtended -> [(Text, AddressInfoExtended)])
-> [(Text, AddressInfoExtended)]
-> Proxy AddressInfoExtended
-> [(Text, AddressInfoExtended)]
forall a b. (a -> b) -> a -> b
$ AddressInfoExtended -> [(Text, AddressInfoExtended)]
forall a. a -> [(Text, a)]
singleSample
    AddressInfoExtended
      { $sel:_addressInfoExtendedAddress:AddressInfoExtended :: Address
_addressInfoExtendedAddress = Address
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz"
      , $sel:_addressInfoExtendedAmount:AddressInfoExtended :: [AmountExtended]
_addressInfoExtendedAmount =
        [ Lovelaces -> AmountExtended
AdaAmountExtended Discrete' "ADA" '(1000000, 1)
Lovelaces
42000000
        , AssetAmountExtended
            { $sel:assetAmountExtendedDecimals:AdaAmountExtended :: Maybe Int
assetAmountExtendedDecimals              = Maybe Int
forall a. Maybe a
Nothing
            , $sel:assetAmountExtendedHasNftOnchainMetadata:AdaAmountExtended :: Bool
assetAmountExtendedHasNftOnchainMetadata = Bool
True
            , $sel:assetAmountExtendedValue:AdaAmountExtended :: SomeDiscrete
assetAmountExtendedValue =
                Discrete'
  "b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
  '(1, 1)
-> SomeDiscrete
forall (currency :: Symbol) (scale :: (Natural, Natural)).
(KnownSymbol currency, GoodScale scale) =>
Discrete' currency scale -> SomeDiscrete
Money.toSomeDiscrete
                (Discrete'
  "b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
  '(1, 1)
12 :: Money.Discrete'
                          "b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
                          '(1,1))
            }
        ]
      , $sel:_addressInfoExtendedStakeAddress:AddressInfoExtended :: Maybe Address
_addressInfoExtendedStakeAddress = Address -> Maybe Address
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Address
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7"
      , $sel:_addressInfoExtendedType:AddressInfoExtended :: AddressType
_addressInfoExtendedType = AddressType
Shelley
      , $sel:_addressInfoExtendedScript:AddressInfoExtended :: Bool
_addressInfoExtendedScript = Bool
False
      }

-- | Type (era) of an address
data AddressType = Byron | Shelley
  deriving stock (Int -> AddressType -> ShowS
[AddressType] -> ShowS
AddressType -> String
(Int -> AddressType -> ShowS)
-> (AddressType -> String)
-> ([AddressType] -> ShowS)
-> Show AddressType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddressType -> ShowS
showsPrec :: Int -> AddressType -> ShowS
$cshow :: AddressType -> String
show :: AddressType -> String
$cshowList :: [AddressType] -> ShowS
showList :: [AddressType] -> ShowS
Show, AddressType -> AddressType -> Bool
(AddressType -> AddressType -> Bool)
-> (AddressType -> AddressType -> Bool) -> Eq AddressType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddressType -> AddressType -> Bool
== :: AddressType -> AddressType -> Bool
$c/= :: AddressType -> AddressType -> Bool
/= :: AddressType -> AddressType -> Bool
Eq, (forall x. AddressType -> Rep AddressType x)
-> (forall x. Rep AddressType x -> AddressType)
-> Generic AddressType
forall x. Rep AddressType x -> AddressType
forall x. AddressType -> Rep AddressType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddressType -> Rep AddressType x
from :: forall x. AddressType -> Rep AddressType x
$cto :: forall x. Rep AddressType x -> AddressType
to :: forall x. Rep AddressType x -> AddressType
Generic)
  deriving (Maybe AddressType
Value -> Parser [AddressType]
Value -> Parser AddressType
(Value -> Parser AddressType)
-> (Value -> Parser [AddressType])
-> Maybe AddressType
-> FromJSON AddressType
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AddressType
parseJSON :: Value -> Parser AddressType
$cparseJSONList :: Value -> Parser [AddressType]
parseJSONList :: Value -> Parser [AddressType]
$comittedField :: Maybe AddressType
omittedField :: Maybe AddressType
FromJSON, [AddressType] -> Value
[AddressType] -> Encoding
AddressType -> Bool
AddressType -> Value
AddressType -> Encoding
(AddressType -> Value)
-> (AddressType -> Encoding)
-> ([AddressType] -> Value)
-> ([AddressType] -> Encoding)
-> (AddressType -> Bool)
-> ToJSON AddressType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AddressType -> Value
toJSON :: AddressType -> Value
$ctoEncoding :: AddressType -> Encoding
toEncoding :: AddressType -> Encoding
$ctoJSONList :: [AddressType] -> Value
toJSONList :: [AddressType] -> Value
$ctoEncodingList :: [AddressType] -> Encoding
toEncodingList :: [AddressType] -> Encoding
$comitField :: AddressType -> Bool
omitField :: AddressType -> Bool
ToJSON)
  via CustomJSON '[ConstructorTagModifier '[ToLower]] AddressType

instance ToSample AddressType where
  toSamples :: Proxy AddressType -> [(Text, AddressType)]
toSamples = [(Text, AddressType)] -> Proxy AddressType -> [(Text, AddressType)]
forall a. a -> Proxy AddressType -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, AddressType)]
 -> Proxy AddressType -> [(Text, AddressType)])
-> [(Text, AddressType)]
-> Proxy AddressType
-> [(Text, AddressType)]
forall a b. (a -> b) -> a -> b
$ [AddressType] -> [(Text, AddressType)]
forall a. [a] -> [(Text, a)]
samples [ AddressType
Byron, AddressType
Shelley ]

-- | Details about Cardano address
data AddressDetails = AddressDetails
  { AddressDetails -> Address
_addressDetailsAddress     :: Address -- ^ Bech32 encoded address
  , AddressDetails -> [Amount]
_addressDetailsReceivedSum :: [Amount] -- ^ Total Lovelaces or tokens received by this address
  , AddressDetails -> [Amount]
_addressDetailsSentSum     :: [Amount] -- ^ Total Lovelaces or tokens sent by this address
  , AddressDetails -> Integer
_addressDetailsTxCount     :: Integer -- ^ Count of all transactions on the address
  } deriving stock (Int -> AddressDetails -> ShowS
[AddressDetails] -> ShowS
AddressDetails -> String
(Int -> AddressDetails -> ShowS)
-> (AddressDetails -> String)
-> ([AddressDetails] -> ShowS)
-> Show AddressDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddressDetails -> ShowS
showsPrec :: Int -> AddressDetails -> ShowS
$cshow :: AddressDetails -> String
show :: AddressDetails -> String
$cshowList :: [AddressDetails] -> ShowS
showList :: [AddressDetails] -> ShowS
Show, AddressDetails -> AddressDetails -> Bool
(AddressDetails -> AddressDetails -> Bool)
-> (AddressDetails -> AddressDetails -> Bool) -> Eq AddressDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddressDetails -> AddressDetails -> Bool
== :: AddressDetails -> AddressDetails -> Bool
$c/= :: AddressDetails -> AddressDetails -> Bool
/= :: AddressDetails -> AddressDetails -> Bool
Eq, (forall x. AddressDetails -> Rep AddressDetails x)
-> (forall x. Rep AddressDetails x -> AddressDetails)
-> Generic AddressDetails
forall x. Rep AddressDetails x -> AddressDetails
forall x. AddressDetails -> Rep AddressDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddressDetails -> Rep AddressDetails x
from :: forall x. AddressDetails -> Rep AddressDetails x
$cto :: forall x. Rep AddressDetails x -> AddressDetails
to :: forall x. Rep AddressDetails x -> AddressDetails
Generic)
  deriving (Maybe AddressDetails
Value -> Parser [AddressDetails]
Value -> Parser AddressDetails
(Value -> Parser AddressDetails)
-> (Value -> Parser [AddressDetails])
-> Maybe AddressDetails
-> FromJSON AddressDetails
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AddressDetails
parseJSON :: Value -> Parser AddressDetails
$cparseJSONList :: Value -> Parser [AddressDetails]
parseJSONList :: Value -> Parser [AddressDetails]
$comittedField :: Maybe AddressDetails
omittedField :: Maybe AddressDetails
FromJSON, [AddressDetails] -> Value
[AddressDetails] -> Encoding
AddressDetails -> Bool
AddressDetails -> Value
AddressDetails -> Encoding
(AddressDetails -> Value)
-> (AddressDetails -> Encoding)
-> ([AddressDetails] -> Value)
-> ([AddressDetails] -> Encoding)
-> (AddressDetails -> Bool)
-> ToJSON AddressDetails
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AddressDetails -> Value
toJSON :: AddressDetails -> Value
$ctoEncoding :: AddressDetails -> Encoding
toEncoding :: AddressDetails -> Encoding
$ctoJSONList :: [AddressDetails] -> Value
toJSONList :: [AddressDetails] -> Value
$ctoEncodingList :: [AddressDetails] -> Encoding
toEncodingList :: [AddressDetails] -> Encoding
$comitField :: AddressDetails -> Bool
omitField :: AddressDetails -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressDetails", CamelToSnake]] AddressDetails

instance ToSample AddressDetails where
  toSamples :: Proxy AddressDetails -> [(Text, AddressDetails)]
toSamples = [(Text, AddressDetails)]
-> Proxy AddressDetails -> [(Text, AddressDetails)]
forall a. a -> Proxy AddressDetails -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, AddressDetails)]
 -> Proxy AddressDetails -> [(Text, AddressDetails)])
-> [(Text, AddressDetails)]
-> Proxy AddressDetails
-> [(Text, AddressDetails)]
forall a b. (a -> b) -> a -> b
$ AddressDetails -> [(Text, AddressDetails)]
forall a. a -> [(Text, a)]
singleSample
    AddressDetails
      { $sel:_addressDetailsAddress:AddressDetails :: Address
_addressDetailsAddress = Address
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz"
      , $sel:_addressDetailsReceivedSum:AddressDetails :: [Amount]
_addressDetailsReceivedSum = [Amount]
amounts
      , $sel:_addressDetailsSentSum:AddressDetails :: [Amount]
_addressDetailsSentSum = [Amount]
amounts
      , $sel:_addressDetailsTxCount:AddressDetails :: Integer
_addressDetailsTxCount = Integer
12
      }
    where amounts :: [Amount]
amounts =
            [ Lovelaces -> Amount
AdaAmount Discrete' "ADA" '(1000000, 1)
Lovelaces
42000000
            , SomeDiscrete -> Amount
AssetAmount
                (SomeDiscrete -> Amount) -> SomeDiscrete -> Amount
forall a b. (a -> b) -> a -> b
$ Text -> Scale -> Integer -> SomeDiscrete
Money.mkSomeDiscrete
                        Text
"b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
                        Scale
unitScale
                        Integer
12
            ]

-- | UTxOs of the address
data AddressUtxo = AddressUtxo
  { AddressUtxo -> Address
_addressUtxoAddress             :: Address  -- ^ Address in the UTxO. Useful when querying by payment credential.
  , AddressUtxo -> TxHash
_addressUtxoTxHash              :: TxHash -- ^ Transaction hash of the UTXO
  , AddressUtxo -> Integer
_addressUtxoOutputIndex         :: Integer -- ^ UTXO index in the transaction
  , AddressUtxo -> [Amount]
_addressUtxoAmount              :: [Amount] -- ^ Amounts of Lovelaces or tokens
  , AddressUtxo -> BlockHash
_addressUtxoBlock               :: BlockHash -- ^ Block hash of the UTXO
  , AddressUtxo -> Maybe DatumHash
_addressUtxoDataHash            :: Maybe DatumHash -- ^ The hash of the transaction output datum
  , AddressUtxo -> Maybe InlineDatum
_addressUtxoInlineDatum         :: Maybe InlineDatum -- ^ CBOR encoded inline datum
  , AddressUtxo -> Maybe ScriptHash
_addressUtxoReferenceScriptHash :: Maybe ScriptHash -- ^ The hash of the reference script of the output
  } deriving stock (Int -> AddressUtxo -> ShowS
[AddressUtxo] -> ShowS
AddressUtxo -> String
(Int -> AddressUtxo -> ShowS)
-> (AddressUtxo -> String)
-> ([AddressUtxo] -> ShowS)
-> Show AddressUtxo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddressUtxo -> ShowS
showsPrec :: Int -> AddressUtxo -> ShowS
$cshow :: AddressUtxo -> String
show :: AddressUtxo -> String
$cshowList :: [AddressUtxo] -> ShowS
showList :: [AddressUtxo] -> ShowS
Show, AddressUtxo -> AddressUtxo -> Bool
(AddressUtxo -> AddressUtxo -> Bool)
-> (AddressUtxo -> AddressUtxo -> Bool) -> Eq AddressUtxo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddressUtxo -> AddressUtxo -> Bool
== :: AddressUtxo -> AddressUtxo -> Bool
$c/= :: AddressUtxo -> AddressUtxo -> Bool
/= :: AddressUtxo -> AddressUtxo -> Bool
Eq, (forall x. AddressUtxo -> Rep AddressUtxo x)
-> (forall x. Rep AddressUtxo x -> AddressUtxo)
-> Generic AddressUtxo
forall x. Rep AddressUtxo x -> AddressUtxo
forall x. AddressUtxo -> Rep AddressUtxo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddressUtxo -> Rep AddressUtxo x
from :: forall x. AddressUtxo -> Rep AddressUtxo x
$cto :: forall x. Rep AddressUtxo x -> AddressUtxo
to :: forall x. Rep AddressUtxo x -> AddressUtxo
Generic)
  deriving (Maybe AddressUtxo
Value -> Parser [AddressUtxo]
Value -> Parser AddressUtxo
(Value -> Parser AddressUtxo)
-> (Value -> Parser [AddressUtxo])
-> Maybe AddressUtxo
-> FromJSON AddressUtxo
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AddressUtxo
parseJSON :: Value -> Parser AddressUtxo
$cparseJSONList :: Value -> Parser [AddressUtxo]
parseJSONList :: Value -> Parser [AddressUtxo]
$comittedField :: Maybe AddressUtxo
omittedField :: Maybe AddressUtxo
FromJSON, [AddressUtxo] -> Value
[AddressUtxo] -> Encoding
AddressUtxo -> Bool
AddressUtxo -> Value
AddressUtxo -> Encoding
(AddressUtxo -> Value)
-> (AddressUtxo -> Encoding)
-> ([AddressUtxo] -> Value)
-> ([AddressUtxo] -> Encoding)
-> (AddressUtxo -> Bool)
-> ToJSON AddressUtxo
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AddressUtxo -> Value
toJSON :: AddressUtxo -> Value
$ctoEncoding :: AddressUtxo -> Encoding
toEncoding :: AddressUtxo -> Encoding
$ctoJSONList :: [AddressUtxo] -> Value
toJSONList :: [AddressUtxo] -> Value
$ctoEncodingList :: [AddressUtxo] -> Encoding
toEncodingList :: [AddressUtxo] -> Encoding
$comitField :: AddressUtxo -> Bool
omitField :: AddressUtxo -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressUtxo", CamelToSnake]] AddressUtxo

instance ToSample AddressUtxo where
  toSamples :: Proxy AddressUtxo -> [(Text, AddressUtxo)]
toSamples = [(Text, AddressUtxo)] -> Proxy AddressUtxo -> [(Text, AddressUtxo)]
forall a. a -> Proxy AddressUtxo -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, AddressUtxo)]
 -> Proxy AddressUtxo -> [(Text, AddressUtxo)])
-> [(Text, AddressUtxo)]
-> Proxy AddressUtxo
-> [(Text, AddressUtxo)]
forall a b. (a -> b) -> a -> b
$ [AddressUtxo] -> [(Text, AddressUtxo)]
forall a. [a] -> [(Text, a)]
samples
    [ AddressUtxo
      { $sel:_addressUtxoAddress:AddressUtxo :: Address
_addressUtxoAddress = Address
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz"
      , $sel:_addressUtxoTxHash:AddressUtxo :: TxHash
_addressUtxoTxHash = TxHash
"39a7a284c2a0948189dc45dec670211cd4d72f7b66c5726c08d9b3df11e44d58"
      , $sel:_addressUtxoOutputIndex:AddressUtxo :: Integer
_addressUtxoOutputIndex = Integer
0
      , $sel:_addressUtxoAmount:AddressUtxo :: [Amount]
_addressUtxoAmount = [ Lovelaces -> Amount
AdaAmount Discrete' "ADA" '(1000000, 1)
Lovelaces
42000000 ]
      , $sel:_addressUtxoBlock:AddressUtxo :: BlockHash
_addressUtxoBlock = BlockHash
"7eb8e27d18686c7db9a18f8bbcfe34e3fed6e047afaa2d969904d15e934847e6"
      , $sel:_addressUtxoDataHash:AddressUtxo :: Maybe DatumHash
_addressUtxoDataHash = DatumHash -> Maybe DatumHash
forall a. a -> Maybe a
Just DatumHash
"9e478573ab81ea7a8e31891ce0648b81229f408d596a3483e6f4f9b92d3cf710"
      , $sel:_addressUtxoInlineDatum:AddressUtxo :: Maybe InlineDatum
_addressUtxoInlineDatum = Maybe InlineDatum
forall a. Maybe a
Nothing
      , $sel:_addressUtxoReferenceScriptHash:AddressUtxo :: Maybe ScriptHash
_addressUtxoReferenceScriptHash = Maybe ScriptHash
forall a. Maybe a
Nothing
      }
    , AddressUtxo
      { $sel:_addressUtxoAddress:AddressUtxo :: Address
_addressUtxoAddress = Address
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz"
      , $sel:_addressUtxoTxHash:AddressUtxo :: TxHash
_addressUtxoTxHash = TxHash
"4c4e67bafa15e742c13c592b65c8f74c769cd7d9af04c848099672d1ba391b49"
      , $sel:_addressUtxoOutputIndex:AddressUtxo :: Integer
_addressUtxoOutputIndex = Integer
0
      , $sel:_addressUtxoAmount:AddressUtxo :: [Amount]
_addressUtxoAmount = [ Lovelaces -> Amount
AdaAmount Discrete' "ADA" '(1000000, 1)
Lovelaces
729235000 ]
      , $sel:_addressUtxoBlock:AddressUtxo :: BlockHash
_addressUtxoBlock = BlockHash
"953f1b80eb7c11a7ffcd67cbd4fde66e824a451aca5a4065725e5174b81685b7"
      , $sel:_addressUtxoDataHash:AddressUtxo :: Maybe DatumHash
_addressUtxoDataHash = Maybe DatumHash
forall a. Maybe a
Nothing
      , $sel:_addressUtxoInlineDatum:AddressUtxo :: Maybe InlineDatum
_addressUtxoInlineDatum = Maybe InlineDatum
forall a. Maybe a
Nothing
      , $sel:_addressUtxoReferenceScriptHash:AddressUtxo :: Maybe ScriptHash
_addressUtxoReferenceScriptHash = Maybe ScriptHash
forall a. Maybe a
Nothing
      }
    , AddressUtxo
      { $sel:_addressUtxoAddress:AddressUtxo :: Address
_addressUtxoAddress = Address
"addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz"
      , $sel:_addressUtxoTxHash:AddressUtxo :: TxHash
_addressUtxoTxHash = TxHash
"768c63e27a1c816a83dc7b07e78af673b2400de8849ea7e7b734ae1333d100d2"
      , $sel:_addressUtxoOutputIndex:AddressUtxo :: Integer
_addressUtxoOutputIndex = Integer
1
      , $sel:_addressUtxoAmount:AddressUtxo :: [Amount]
_addressUtxoAmount =
          [ Lovelaces -> Amount
AdaAmount Discrete' "ADA" '(1000000, 1)
Lovelaces
42000000
          , SomeDiscrete -> Amount
AssetAmount
              (SomeDiscrete -> Amount) -> SomeDiscrete -> Amount
forall a b. (a -> b) -> a -> b
$ Text -> Scale -> Integer -> SomeDiscrete
Money.mkSomeDiscrete
                  Text
"b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
                   Scale
unitScale
                   Integer
12
          ]
      , $sel:_addressUtxoBlock:AddressUtxo :: BlockHash
_addressUtxoBlock = BlockHash
"5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7"
      , $sel:_addressUtxoDataHash:AddressUtxo :: Maybe DatumHash
_addressUtxoDataHash = Maybe DatumHash
forall a. Maybe a
Nothing
      , $sel:_addressUtxoInlineDatum:AddressUtxo :: Maybe InlineDatum
_addressUtxoInlineDatum = Maybe InlineDatum
forall a. Maybe a
Nothing
      , $sel:_addressUtxoReferenceScriptHash:AddressUtxo :: Maybe ScriptHash
_addressUtxoReferenceScriptHash = Maybe ScriptHash
forall a. Maybe a
Nothing
      }
    ]

-- | Transactions on the address
data AddressTransaction = AddressTransaction {
    AddressTransaction -> TxHash
_addressTransactionTxHash      :: TxHash -- ^ Hash of the transaction
  , AddressTransaction -> Integer
_addressTransactionTxIndex     :: Integer -- ^ Transaction index within the block
  , AddressTransaction -> Integer
_addressTransactionBlockHeight :: Integer -- ^ Block height
  , AddressTransaction -> POSIXTime
_addressTransactionBlockTime   :: POSIXTime -- ^ Block creation time in UNIX time
  } deriving stock (Int -> AddressTransaction -> ShowS
[AddressTransaction] -> ShowS
AddressTransaction -> String
(Int -> AddressTransaction -> ShowS)
-> (AddressTransaction -> String)
-> ([AddressTransaction] -> ShowS)
-> Show AddressTransaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddressTransaction -> ShowS
showsPrec :: Int -> AddressTransaction -> ShowS
$cshow :: AddressTransaction -> String
show :: AddressTransaction -> String
$cshowList :: [AddressTransaction] -> ShowS
showList :: [AddressTransaction] -> ShowS
Show, AddressTransaction -> AddressTransaction -> Bool
(AddressTransaction -> AddressTransaction -> Bool)
-> (AddressTransaction -> AddressTransaction -> Bool)
-> Eq AddressTransaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddressTransaction -> AddressTransaction -> Bool
== :: AddressTransaction -> AddressTransaction -> Bool
$c/= :: AddressTransaction -> AddressTransaction -> Bool
/= :: AddressTransaction -> AddressTransaction -> Bool
Eq, (forall x. AddressTransaction -> Rep AddressTransaction x)
-> (forall x. Rep AddressTransaction x -> AddressTransaction)
-> Generic AddressTransaction
forall x. Rep AddressTransaction x -> AddressTransaction
forall x. AddressTransaction -> Rep AddressTransaction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddressTransaction -> Rep AddressTransaction x
from :: forall x. AddressTransaction -> Rep AddressTransaction x
$cto :: forall x. Rep AddressTransaction x -> AddressTransaction
to :: forall x. Rep AddressTransaction x -> AddressTransaction
Generic)
  deriving (Maybe AddressTransaction
Value -> Parser [AddressTransaction]
Value -> Parser AddressTransaction
(Value -> Parser AddressTransaction)
-> (Value -> Parser [AddressTransaction])
-> Maybe AddressTransaction
-> FromJSON AddressTransaction
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser AddressTransaction
parseJSON :: Value -> Parser AddressTransaction
$cparseJSONList :: Value -> Parser [AddressTransaction]
parseJSONList :: Value -> Parser [AddressTransaction]
$comittedField :: Maybe AddressTransaction
omittedField :: Maybe AddressTransaction
FromJSON, [AddressTransaction] -> Value
[AddressTransaction] -> Encoding
AddressTransaction -> Bool
AddressTransaction -> Value
AddressTransaction -> Encoding
(AddressTransaction -> Value)
-> (AddressTransaction -> Encoding)
-> ([AddressTransaction] -> Value)
-> ([AddressTransaction] -> Encoding)
-> (AddressTransaction -> Bool)
-> ToJSON AddressTransaction
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: AddressTransaction -> Value
toJSON :: AddressTransaction -> Value
$ctoEncoding :: AddressTransaction -> Encoding
toEncoding :: AddressTransaction -> Encoding
$ctoJSONList :: [AddressTransaction] -> Value
toJSONList :: [AddressTransaction] -> Value
$ctoEncodingList :: [AddressTransaction] -> Encoding
toEncodingList :: [AddressTransaction] -> Encoding
$comitField :: AddressTransaction -> Bool
omitField :: AddressTransaction -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressTransaction", CamelToSnake]] AddressTransaction

instance ToSample AddressTransaction where
  toSamples :: Proxy AddressTransaction -> [(Text, AddressTransaction)]
toSamples = [(Text, AddressTransaction)]
-> Proxy AddressTransaction -> [(Text, AddressTransaction)]
forall a. a -> Proxy AddressTransaction -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, AddressTransaction)]
 -> Proxy AddressTransaction -> [(Text, AddressTransaction)])
-> [(Text, AddressTransaction)]
-> Proxy AddressTransaction
-> [(Text, AddressTransaction)]
forall a b. (a -> b) -> a -> b
$ [AddressTransaction] -> [(Text, AddressTransaction)]
forall a. [a] -> [(Text, a)]
samples
    [ AddressTransaction
      { $sel:_addressTransactionTxHash:AddressTransaction :: TxHash
_addressTransactionTxHash = TxHash
"8788591983aa73981fc92d6cddbbe643959f5a784e84b8bee0db15823f575a5b"
      , $sel:_addressTransactionTxIndex:AddressTransaction :: Integer
_addressTransactionTxIndex = Integer
6
      , $sel:_addressTransactionBlockHeight:AddressTransaction :: Integer
_addressTransactionBlockHeight = Integer
69
      , $sel:_addressTransactionBlockTime:AddressTransaction :: POSIXTime
_addressTransactionBlockTime = POSIXTime
1635505891
      }
    , AddressTransaction
      { $sel:_addressTransactionTxHash:AddressTransaction :: TxHash
_addressTransactionTxHash = TxHash
"52e748c4dec58b687b90b0b40d383b9fe1f24c1a833b7395cdf07dd67859f46f"
      , $sel:_addressTransactionTxIndex:AddressTransaction :: Integer
_addressTransactionTxIndex = Integer
9
      , $sel:_addressTransactionBlockHeight:AddressTransaction :: Integer
_addressTransactionBlockHeight = Integer
4547
      , $sel:_addressTransactionBlockTime:AddressTransaction :: POSIXTime
_addressTransactionBlockTime = POSIXTime
1635505987
      }
    , AddressTransaction
      { $sel:_addressTransactionTxHash:AddressTransaction :: TxHash
_addressTransactionTxHash = TxHash
"e8073fd5318ff43eca18a852527166aa8008bee9ee9e891f585612b7e4ba700b"
      , $sel:_addressTransactionTxIndex:AddressTransaction :: Integer
_addressTransactionTxIndex = Integer
0
      , $sel:_addressTransactionBlockHeight:AddressTransaction :: Integer
_addressTransactionBlockHeight = Integer
564654
      , $sel:_addressTransactionBlockTime:AddressTransaction :: POSIXTime
_addressTransactionBlockTime = POSIXTime
1834505492
      }
    ]