-- | Responses for Cardano accounts queries

module Blockfrost.Types.Cardano.Accounts
  ( AccountInfo (..)
  , RewardType (..)
  , AccountReward (..)
  , AccountHistory (..)
  , AccountDelegation (..)
  , AccountRegistration (..)
  , AccountRegistrationAction (..)
  , AccountWithdrawal (..)
  , AccountMir (..)
  , AddressAssociated (..)
  ) where

import Blockfrost.Types.Shared
import Deriving.Aeson
import Servant.Docs (ToSample (..), samples, singleSample)

-- | Information about an account, identified by its stake address
data AccountInfo = AccountInfo
  { AccountInfo -> Address
_accountInfoStakeAddress       :: Address -- ^ Bech32 stake address
  , AccountInfo -> Bool
_accountInfoActive             :: Bool -- ^ Registration state of an account
  , AccountInfo -> Maybe Integer
_accountInfoActiveEpoch        :: Maybe Integer -- ^ Epoch of the most recent action - registration or deregistration
  , AccountInfo -> Lovelaces
_accountInfoControlledAmount   :: Lovelaces  -- ^ Balance of the account in Lovelaces
  , AccountInfo -> Lovelaces
_accountInfoRewardsSum         :: Lovelaces -- ^ Sum of all funds rewards for the account in the Lovelaces
  , AccountInfo -> Lovelaces
_accountInfoWithdrawalsSum     :: Lovelaces -- ^ Sum of all the withdrawals for the account in the Lovelaces
  , AccountInfo -> Lovelaces
_accountInfoReservesSum        :: Lovelaces -- ^ Sum of all funds from reserves for the account in the Lovelaces
  , AccountInfo -> Lovelaces
_accountInfoTreasurySum        :: Lovelaces -- ^ Sum of all funds from treasury for the account in the Lovelaces
  , AccountInfo -> Lovelaces
_accountInfoWithdrawableAmount :: Lovelaces -- ^ Sum of available rewards that haven't been withdrawn yet for the account in the Lovelaces
  , AccountInfo -> Maybe PoolId
_accountInfoPoolId             :: Maybe PoolId -- ^ Bech32 pool ID that owns the account
  }
  deriving stock (Int -> AccountInfo -> ShowS
[AccountInfo] -> ShowS
AccountInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountInfo] -> ShowS
$cshowList :: [AccountInfo] -> ShowS
show :: AccountInfo -> String
$cshow :: AccountInfo -> String
showsPrec :: Int -> AccountInfo -> ShowS
$cshowsPrec :: Int -> AccountInfo -> ShowS
Show, AccountInfo -> AccountInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountInfo -> AccountInfo -> Bool
$c/= :: AccountInfo -> AccountInfo -> Bool
== :: AccountInfo -> AccountInfo -> Bool
$c== :: AccountInfo -> AccountInfo -> Bool
Eq, forall x. Rep AccountInfo x -> AccountInfo
forall x. AccountInfo -> Rep AccountInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountInfo x -> AccountInfo
$cfrom :: forall x. AccountInfo -> Rep AccountInfo x
Generic)
  deriving (Value -> Parser [AccountInfo]
Value -> Parser AccountInfo
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountInfo]
$cparseJSONList :: Value -> Parser [AccountInfo]
parseJSON :: Value -> Parser AccountInfo
$cparseJSON :: Value -> Parser AccountInfo
FromJSON, [AccountInfo] -> Encoding
[AccountInfo] -> Value
AccountInfo -> Encoding
AccountInfo -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountInfo] -> Encoding
$ctoEncodingList :: [AccountInfo] -> Encoding
toJSONList :: [AccountInfo] -> Value
$ctoJSONList :: [AccountInfo] -> Value
toEncoding :: AccountInfo -> Encoding
$ctoEncoding :: AccountInfo -> Encoding
toJSON :: AccountInfo -> Value
$ctoJSON :: AccountInfo -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountInfo", CamelToSnake]] AccountInfo

instance ToSample AccountInfo where
  toSamples :: Proxy AccountInfo -> [(Text, AccountInfo)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. a -> [(Text, a)]
singleSample forall a b. (a -> b) -> a -> b
$ AccountInfo
    { _accountInfoStakeAddress :: Address
_accountInfoStakeAddress = Address
"stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7"
    , _accountInfoActive :: Bool
_accountInfoActive = Bool
True
    , _accountInfoActiveEpoch :: Maybe Integer
_accountInfoActiveEpoch = forall (f :: * -> *) a. Applicative f => a -> f a
pure Integer
412
    , _accountInfoControlledAmount :: Lovelaces
_accountInfoControlledAmount = Discrete' "ADA" '(1000000, 1)
619154618165
    , _accountInfoRewardsSum :: Lovelaces
_accountInfoRewardsSum = Discrete' "ADA" '(1000000, 1)
319154618165
    , _accountInfoWithdrawalsSum :: Lovelaces
_accountInfoWithdrawalsSum = Discrete' "ADA" '(1000000, 1)
12125369253
    , _accountInfoReservesSum :: Lovelaces
_accountInfoReservesSum = Discrete' "ADA" '(1000000, 1)
319154618165
    , _accountInfoTreasurySum :: Lovelaces
_accountInfoTreasurySum = Discrete' "ADA" '(1000000, 1)
12000000
    , _accountInfoWithdrawableAmount :: Lovelaces
_accountInfoWithdrawableAmount = Discrete' "ADA" '(1000000, 1)
319154618165
    , _accountInfoPoolId :: Maybe PoolId
_accountInfoPoolId = forall (f :: * -> *) a. Applicative f => a -> f a
pure PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
    }

-- | Reward type
data RewardType = Leader | Member | PoolDepositRefund
  deriving stock (Int -> RewardType -> ShowS
[RewardType] -> ShowS
RewardType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RewardType] -> ShowS
$cshowList :: [RewardType] -> ShowS
show :: RewardType -> String
$cshow :: RewardType -> String
showsPrec :: Int -> RewardType -> ShowS
$cshowsPrec :: Int -> RewardType -> ShowS
Show, RewardType -> RewardType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RewardType -> RewardType -> Bool
$c/= :: RewardType -> RewardType -> Bool
== :: RewardType -> RewardType -> Bool
$c== :: RewardType -> RewardType -> Bool
Eq, forall x. Rep RewardType x -> RewardType
forall x. RewardType -> Rep RewardType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RewardType x -> RewardType
$cfrom :: forall x. RewardType -> Rep RewardType x
Generic)
  deriving (Value -> Parser [RewardType]
Value -> Parser RewardType
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [RewardType]
$cparseJSONList :: Value -> Parser [RewardType]
parseJSON :: Value -> Parser RewardType
$cparseJSON :: Value -> Parser RewardType
FromJSON, [RewardType] -> Encoding
[RewardType] -> Value
RewardType -> Encoding
RewardType -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [RewardType] -> Encoding
$ctoEncodingList :: [RewardType] -> Encoding
toJSONList :: [RewardType] -> Value
$ctoJSONList :: [RewardType] -> Value
toEncoding :: RewardType -> Encoding
$ctoEncoding :: RewardType -> Encoding
toJSON :: RewardType -> Value
$ctoJSON :: RewardType -> Value
ToJSON)
  via CustomJSON '[ConstructorTagModifier '[CamelToKebab]] RewardType

instance ToSample RewardType where
  toSamples :: Proxy RewardType -> [(Text, RewardType)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples [ RewardType
Leader, RewardType
Member, RewardType
PoolDepositRefund ]

-- | Reward received by an account
data AccountReward = AccountReward
  { AccountReward -> Epoch
_accountRewardEpoch  :: Epoch -- ^ Epoch of the associated reward
  , AccountReward -> Lovelaces
_accountRewardAmount :: Lovelaces -- ^ Rewards for given epoch in Lovelaces
  , AccountReward -> PoolId
_accountRewardPoolId :: PoolId -- ^ Bech32 pool ID being delegated to
  , AccountReward -> RewardType
_accountRewardType   :: RewardType -- ^ Reward type
  }
  deriving stock (Int -> AccountReward -> ShowS
[AccountReward] -> ShowS
AccountReward -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountReward] -> ShowS
$cshowList :: [AccountReward] -> ShowS
show :: AccountReward -> String
$cshow :: AccountReward -> String
showsPrec :: Int -> AccountReward -> ShowS
$cshowsPrec :: Int -> AccountReward -> ShowS
Show, AccountReward -> AccountReward -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountReward -> AccountReward -> Bool
$c/= :: AccountReward -> AccountReward -> Bool
== :: AccountReward -> AccountReward -> Bool
$c== :: AccountReward -> AccountReward -> Bool
Eq, forall x. Rep AccountReward x -> AccountReward
forall x. AccountReward -> Rep AccountReward x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountReward x -> AccountReward
$cfrom :: forall x. AccountReward -> Rep AccountReward x
Generic)
  deriving (Value -> Parser [AccountReward]
Value -> Parser AccountReward
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountReward]
$cparseJSONList :: Value -> Parser [AccountReward]
parseJSON :: Value -> Parser AccountReward
$cparseJSON :: Value -> Parser AccountReward
FromJSON, [AccountReward] -> Encoding
[AccountReward] -> Value
AccountReward -> Encoding
AccountReward -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountReward] -> Encoding
$ctoEncodingList :: [AccountReward] -> Encoding
toJSONList :: [AccountReward] -> Value
$ctoJSONList :: [AccountReward] -> Value
toEncoding :: AccountReward -> Encoding
$ctoEncoding :: AccountReward -> Encoding
toJSON :: AccountReward -> Value
$ctoJSON :: AccountReward -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountReward", CamelToSnake]] AccountReward

instance ToSample AccountReward where
  toSamples :: Proxy AccountReward -> [(Text, AccountReward)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
    [ AccountReward
        { _accountRewardEpoch :: Epoch
_accountRewardEpoch = Epoch
214
        , _accountRewardAmount :: Lovelaces
_accountRewardAmount = Discrete' "ADA" '(1000000, 1)
1395265
        , _accountRewardPoolId :: PoolId
_accountRewardPoolId = PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
        , _accountRewardType :: RewardType
_accountRewardType = RewardType
Member
        }
    , AccountReward
        { _accountRewardEpoch :: Epoch
_accountRewardEpoch = Epoch
215
        , _accountRewardAmount :: Lovelaces
_accountRewardAmount = Discrete' "ADA" '(1000000, 1)
58632
        , _accountRewardPoolId :: PoolId
_accountRewardPoolId = PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
        , _accountRewardType :: RewardType
_accountRewardType = RewardType
Leader
        }
    , AccountReward
        { _accountRewardEpoch :: Epoch
_accountRewardEpoch = Epoch
216
        , _accountRewardAmount :: Lovelaces
_accountRewardAmount = Discrete' "ADA" '(1000000, 1)
0
        , _accountRewardPoolId :: PoolId
_accountRewardPoolId = PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
        , _accountRewardType :: RewardType
_accountRewardType = RewardType
Leader
        }
    , AccountReward
        { _accountRewardEpoch :: Epoch
_accountRewardEpoch = Epoch
217
        , _accountRewardAmount :: Lovelaces
_accountRewardAmount = Discrete' "ADA" '(1000000, 1)
1395265
        , _accountRewardPoolId :: PoolId
_accountRewardPoolId = PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
        , _accountRewardType :: RewardType
_accountRewardType = RewardType
PoolDepositRefund
        }
    ]

-- | History of accounts stake delegation
data AccountHistory = AccountHistory
  { AccountHistory -> Integer
_accountHistoryActiveEpoch :: Integer -- ^ Epoch in which the stake was active
  , AccountHistory -> Lovelaces
_accountHistoryAmount      :: Lovelaces -- ^ Stake amount in Lovelaces
  , AccountHistory -> PoolId
_accountHistoryPoolId      :: PoolId -- ^ Bech32 ID of pool being delegated to
  }
  deriving stock (Int -> AccountHistory -> ShowS
[AccountHistory] -> ShowS
AccountHistory -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountHistory] -> ShowS
$cshowList :: [AccountHistory] -> ShowS
show :: AccountHistory -> String
$cshow :: AccountHistory -> String
showsPrec :: Int -> AccountHistory -> ShowS
$cshowsPrec :: Int -> AccountHistory -> ShowS
Show, AccountHistory -> AccountHistory -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountHistory -> AccountHistory -> Bool
$c/= :: AccountHistory -> AccountHistory -> Bool
== :: AccountHistory -> AccountHistory -> Bool
$c== :: AccountHistory -> AccountHistory -> Bool
Eq, forall x. Rep AccountHistory x -> AccountHistory
forall x. AccountHistory -> Rep AccountHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountHistory x -> AccountHistory
$cfrom :: forall x. AccountHistory -> Rep AccountHistory x
Generic)
  deriving (Value -> Parser [AccountHistory]
Value -> Parser AccountHistory
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountHistory]
$cparseJSONList :: Value -> Parser [AccountHistory]
parseJSON :: Value -> Parser AccountHistory
$cparseJSON :: Value -> Parser AccountHistory
FromJSON, [AccountHistory] -> Encoding
[AccountHistory] -> Value
AccountHistory -> Encoding
AccountHistory -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountHistory] -> Encoding
$ctoEncodingList :: [AccountHistory] -> Encoding
toJSONList :: [AccountHistory] -> Value
$ctoJSONList :: [AccountHistory] -> Value
toEncoding :: AccountHistory -> Encoding
$ctoEncoding :: AccountHistory -> Encoding
toJSON :: AccountHistory -> Value
$ctoJSON :: AccountHistory -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountHistory", CamelToSnake]] AccountHistory

instance ToSample AccountHistory where
  toSamples :: Proxy AccountHistory -> [(Text, AccountHistory)]
toSamples  = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
    [ AccountHistory
        { _accountHistoryActiveEpoch :: Integer
_accountHistoryActiveEpoch = Integer
260
        , _accountHistoryAmount :: Lovelaces
_accountHistoryAmount = Discrete' "ADA" '(1000000, 1)
1395265
        , _accountHistoryPoolId :: PoolId
_accountHistoryPoolId = PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
        }
    , AccountHistory
        { _accountHistoryActiveEpoch :: Integer
_accountHistoryActiveEpoch = Integer
211
        , _accountHistoryAmount :: Lovelaces
_accountHistoryAmount = Discrete' "ADA" '(1000000, 1)
22695385
        , _accountHistoryPoolId :: PoolId
_accountHistoryPoolId = PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
        }
    ]

-- | Account delegations and associated transaction IDs
data AccountDelegation = AccountDelegation
  { AccountDelegation -> Epoch
_accountDelegationActiveEpoch :: Epoch -- ^ Epoch in which the delegation becomes active
  , AccountDelegation -> TxHash
_accountDelegationTxHash      :: TxHash -- ^ Hash of the transaction containing the delegation
  , AccountDelegation -> Lovelaces
_accountDelegationAmount      :: Lovelaces -- ^ Rewards for given epoch in Lovelaces
  , AccountDelegation -> PoolId
_accountDelegationPoolId      :: PoolId -- ^ Bech32 ID of pool being delegated to
  }
  deriving stock (Int -> AccountDelegation -> ShowS
[AccountDelegation] -> ShowS
AccountDelegation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountDelegation] -> ShowS
$cshowList :: [AccountDelegation] -> ShowS
show :: AccountDelegation -> String
$cshow :: AccountDelegation -> String
showsPrec :: Int -> AccountDelegation -> ShowS
$cshowsPrec :: Int -> AccountDelegation -> ShowS
Show, AccountDelegation -> AccountDelegation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountDelegation -> AccountDelegation -> Bool
$c/= :: AccountDelegation -> AccountDelegation -> Bool
== :: AccountDelegation -> AccountDelegation -> Bool
$c== :: AccountDelegation -> AccountDelegation -> Bool
Eq, forall x. Rep AccountDelegation x -> AccountDelegation
forall x. AccountDelegation -> Rep AccountDelegation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountDelegation x -> AccountDelegation
$cfrom :: forall x. AccountDelegation -> Rep AccountDelegation x
Generic)
  deriving (Value -> Parser [AccountDelegation]
Value -> Parser AccountDelegation
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountDelegation]
$cparseJSONList :: Value -> Parser [AccountDelegation]
parseJSON :: Value -> Parser AccountDelegation
$cparseJSON :: Value -> Parser AccountDelegation
FromJSON, [AccountDelegation] -> Encoding
[AccountDelegation] -> Value
AccountDelegation -> Encoding
AccountDelegation -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountDelegation] -> Encoding
$ctoEncodingList :: [AccountDelegation] -> Encoding
toJSONList :: [AccountDelegation] -> Value
$ctoJSONList :: [AccountDelegation] -> Value
toEncoding :: AccountDelegation -> Encoding
$ctoEncoding :: AccountDelegation -> Encoding
toJSON :: AccountDelegation -> Value
$ctoJSON :: AccountDelegation -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountDelegation", CamelToSnake]] AccountDelegation

instance ToSample AccountDelegation where
  toSamples :: Proxy AccountDelegation -> [(Text, AccountDelegation)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
    [ AccountDelegation
        { _accountDelegationActiveEpoch :: Epoch
_accountDelegationActiveEpoch = Epoch
210
        , _accountDelegationTxHash :: TxHash
_accountDelegationTxHash = TxHash
"2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531"
        , _accountDelegationAmount :: Lovelaces
_accountDelegationAmount = Discrete' "ADA" '(1000000, 1)
12695385
        , _accountDelegationPoolId :: PoolId
_accountDelegationPoolId = PoolId
"pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
        }
    , AccountDelegation
        { _accountDelegationActiveEpoch :: Epoch
_accountDelegationActiveEpoch = Epoch
242
        , _accountDelegationTxHash :: TxHash
_accountDelegationTxHash = TxHash
"1a0570af966fb355a7160e4f82d5a80b8681b7955f5d44bec0dde628516157f0"
        , _accountDelegationAmount :: Lovelaces
_accountDelegationAmount = Discrete' "ADA" '(1000000, 1)
12691385
        , _accountDelegationPoolId :: PoolId
_accountDelegationPoolId = PoolId
"pool1kchver88u3kygsak8wgll7htr8uxn5v35lfrsyy842nkscrzyvj"
        }
    ]

-- | Registration action
data AccountRegistrationAction = Registered | Deregistered
  deriving stock (Int -> AccountRegistrationAction -> ShowS
[AccountRegistrationAction] -> ShowS
AccountRegistrationAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountRegistrationAction] -> ShowS
$cshowList :: [AccountRegistrationAction] -> ShowS
show :: AccountRegistrationAction -> String
$cshow :: AccountRegistrationAction -> String
showsPrec :: Int -> AccountRegistrationAction -> ShowS
$cshowsPrec :: Int -> AccountRegistrationAction -> ShowS
Show, AccountRegistrationAction -> AccountRegistrationAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountRegistrationAction -> AccountRegistrationAction -> Bool
$c/= :: AccountRegistrationAction -> AccountRegistrationAction -> Bool
== :: AccountRegistrationAction -> AccountRegistrationAction -> Bool
$c== :: AccountRegistrationAction -> AccountRegistrationAction -> Bool
Eq, forall x.
Rep AccountRegistrationAction x -> AccountRegistrationAction
forall x.
AccountRegistrationAction -> Rep AccountRegistrationAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AccountRegistrationAction x -> AccountRegistrationAction
$cfrom :: forall x.
AccountRegistrationAction -> Rep AccountRegistrationAction x
Generic)
  deriving (Value -> Parser [AccountRegistrationAction]
Value -> Parser AccountRegistrationAction
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountRegistrationAction]
$cparseJSONList :: Value -> Parser [AccountRegistrationAction]
parseJSON :: Value -> Parser AccountRegistrationAction
$cparseJSON :: Value -> Parser AccountRegistrationAction
FromJSON, [AccountRegistrationAction] -> Encoding
[AccountRegistrationAction] -> Value
AccountRegistrationAction -> Encoding
AccountRegistrationAction -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountRegistrationAction] -> Encoding
$ctoEncodingList :: [AccountRegistrationAction] -> Encoding
toJSONList :: [AccountRegistrationAction] -> Value
$ctoJSONList :: [AccountRegistrationAction] -> Value
toEncoding :: AccountRegistrationAction -> Encoding
$ctoEncoding :: AccountRegistrationAction -> Encoding
toJSON :: AccountRegistrationAction -> Value
$ctoJSON :: AccountRegistrationAction -> Value
ToJSON)
  via CustomJSON '[ConstructorTagModifier '[ToLower]] AccountRegistrationAction

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

-- | Account (de)registration
data AccountRegistration = AccountRegistration
  { AccountRegistration -> AccountRegistrationAction
_accountRegistrationAction :: AccountRegistrationAction -- ^ Action in the certificate
  , AccountRegistration -> TxHash
_accountRegistrationTxHash :: TxHash -- ^ Hash of the transaction containing the (de)registration certificate
  }
  deriving stock (Int -> AccountRegistration -> ShowS
[AccountRegistration] -> ShowS
AccountRegistration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountRegistration] -> ShowS
$cshowList :: [AccountRegistration] -> ShowS
show :: AccountRegistration -> String
$cshow :: AccountRegistration -> String
showsPrec :: Int -> AccountRegistration -> ShowS
$cshowsPrec :: Int -> AccountRegistration -> ShowS
Show, AccountRegistration -> AccountRegistration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountRegistration -> AccountRegistration -> Bool
$c/= :: AccountRegistration -> AccountRegistration -> Bool
== :: AccountRegistration -> AccountRegistration -> Bool
$c== :: AccountRegistration -> AccountRegistration -> Bool
Eq, forall x. Rep AccountRegistration x -> AccountRegistration
forall x. AccountRegistration -> Rep AccountRegistration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountRegistration x -> AccountRegistration
$cfrom :: forall x. AccountRegistration -> Rep AccountRegistration x
Generic)
  deriving (Value -> Parser [AccountRegistration]
Value -> Parser AccountRegistration
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountRegistration]
$cparseJSONList :: Value -> Parser [AccountRegistration]
parseJSON :: Value -> Parser AccountRegistration
$cparseJSON :: Value -> Parser AccountRegistration
FromJSON, [AccountRegistration] -> Encoding
[AccountRegistration] -> Value
AccountRegistration -> Encoding
AccountRegistration -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountRegistration] -> Encoding
$ctoEncodingList :: [AccountRegistration] -> Encoding
toJSONList :: [AccountRegistration] -> Value
$ctoJSONList :: [AccountRegistration] -> Value
toEncoding :: AccountRegistration -> Encoding
$ctoEncoding :: AccountRegistration -> Encoding
toJSON :: AccountRegistration -> Value
$ctoJSON :: AccountRegistration -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountRegistration", CamelToSnake]] AccountRegistration

instance ToSample AccountRegistration where
  toSamples :: Proxy AccountRegistration -> [(Text, AccountRegistration)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
    [ AccountRegistration
        { _accountRegistrationAction :: AccountRegistrationAction
_accountRegistrationAction = AccountRegistrationAction
Registered
        , _accountRegistrationTxHash :: TxHash
_accountRegistrationTxHash = TxHash
"2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531"
        }
    , AccountRegistration
        { _accountRegistrationAction :: AccountRegistrationAction
_accountRegistrationAction = AccountRegistrationAction
Deregistered
        , _accountRegistrationTxHash :: TxHash
_accountRegistrationTxHash = TxHash
"1a0570af966fb355a7160e4f82d5a80b8681b7955f5d44bec0dde628516157f0"
        }
    ]

-- | Withdrawal from an account
data AccountWithdrawal = AccountWithdrawal
  { AccountWithdrawal -> Lovelaces
_accountWithdrawalAmount :: Lovelaces -- ^ Withdrawal amount in Lovelaces
  , AccountWithdrawal -> TxHash
_accountWithdrawalTxHash :: TxHash -- ^ Hash of the transaction containing the withdrawal
  }
  deriving stock (Int -> AccountWithdrawal -> ShowS
[AccountWithdrawal] -> ShowS
AccountWithdrawal -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountWithdrawal] -> ShowS
$cshowList :: [AccountWithdrawal] -> ShowS
show :: AccountWithdrawal -> String
$cshow :: AccountWithdrawal -> String
showsPrec :: Int -> AccountWithdrawal -> ShowS
$cshowsPrec :: Int -> AccountWithdrawal -> ShowS
Show, AccountWithdrawal -> AccountWithdrawal -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountWithdrawal -> AccountWithdrawal -> Bool
$c/= :: AccountWithdrawal -> AccountWithdrawal -> Bool
== :: AccountWithdrawal -> AccountWithdrawal -> Bool
$c== :: AccountWithdrawal -> AccountWithdrawal -> Bool
Eq, forall x. Rep AccountWithdrawal x -> AccountWithdrawal
forall x. AccountWithdrawal -> Rep AccountWithdrawal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountWithdrawal x -> AccountWithdrawal
$cfrom :: forall x. AccountWithdrawal -> Rep AccountWithdrawal x
Generic)
  deriving (Value -> Parser [AccountWithdrawal]
Value -> Parser AccountWithdrawal
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountWithdrawal]
$cparseJSONList :: Value -> Parser [AccountWithdrawal]
parseJSON :: Value -> Parser AccountWithdrawal
$cparseJSON :: Value -> Parser AccountWithdrawal
FromJSON, [AccountWithdrawal] -> Encoding
[AccountWithdrawal] -> Value
AccountWithdrawal -> Encoding
AccountWithdrawal -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountWithdrawal] -> Encoding
$ctoEncodingList :: [AccountWithdrawal] -> Encoding
toJSONList :: [AccountWithdrawal] -> Value
$ctoJSONList :: [AccountWithdrawal] -> Value
toEncoding :: AccountWithdrawal -> Encoding
$ctoEncoding :: AccountWithdrawal -> Encoding
toJSON :: AccountWithdrawal -> Value
$ctoJSON :: AccountWithdrawal -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountWithdrawal", CamelToSnake]] AccountWithdrawal

instance ToSample AccountWithdrawal where
  toSamples :: Proxy AccountWithdrawal -> [(Text, AccountWithdrawal)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
    [ AccountWithdrawal
        { _accountWithdrawalAmount :: Lovelaces
_accountWithdrawalAmount = Discrete' "ADA" '(1000000, 1)
454541212442
        , _accountWithdrawalTxHash :: TxHash
_accountWithdrawalTxHash = TxHash
"48a9625c841eea0dd2bb6cf551eabe6523b7290c9ce34be74eedef2dd8f7ecc5"
        }
    , AccountWithdrawal
        { _accountWithdrawalAmount :: Lovelaces
_accountWithdrawalAmount = Discrete' "ADA" '(1000000, 1)
97846969
        , _accountWithdrawalTxHash :: TxHash
_accountWithdrawalTxHash = TxHash
"4230b0cbccf6f449f0847d8ad1d634a7a49df60d8c142bb8cc2dbc8ca03d9e34"
        }
    ]

-- | Account MIR (Move Instantaneous Reward)
data AccountMir = AccountMir
  { AccountMir -> Lovelaces
_accountMirAmount :: Lovelaces -- ^ MIR amount in Lovelaces
  , AccountMir -> TxHash
_accountMirTxHash :: TxHash -- ^ Hash of the transaction containing the MIR
  }
  deriving stock (Int -> AccountMir -> ShowS
[AccountMir] -> ShowS
AccountMir -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountMir] -> ShowS
$cshowList :: [AccountMir] -> ShowS
show :: AccountMir -> String
$cshow :: AccountMir -> String
showsPrec :: Int -> AccountMir -> ShowS
$cshowsPrec :: Int -> AccountMir -> ShowS
Show, AccountMir -> AccountMir -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountMir -> AccountMir -> Bool
$c/= :: AccountMir -> AccountMir -> Bool
== :: AccountMir -> AccountMir -> Bool
$c== :: AccountMir -> AccountMir -> Bool
Eq, forall x. Rep AccountMir x -> AccountMir
forall x. AccountMir -> Rep AccountMir x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountMir x -> AccountMir
$cfrom :: forall x. AccountMir -> Rep AccountMir x
Generic)
  deriving (Value -> Parser [AccountMir]
Value -> Parser AccountMir
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AccountMir]
$cparseJSONList :: Value -> Parser [AccountMir]
parseJSON :: Value -> Parser AccountMir
$cparseJSON :: Value -> Parser AccountMir
FromJSON, [AccountMir] -> Encoding
[AccountMir] -> Value
AccountMir -> Encoding
AccountMir -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AccountMir] -> Encoding
$ctoEncodingList :: [AccountMir] -> Encoding
toJSONList :: [AccountMir] -> Value
$ctoJSONList :: [AccountMir] -> Value
toEncoding :: AccountMir -> Encoding
$ctoEncoding :: AccountMir -> Encoding
toJSON :: AccountMir -> Value
$ctoJSON :: AccountMir -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_accountMir", CamelToSnake]] AccountMir

instance ToSample AccountMir where
  toSamples :: Proxy AccountMir -> [(Text, AccountMir)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
    [ AccountMir
        { _accountMirAmount :: Lovelaces
_accountMirAmount = Discrete' "ADA" '(1000000, 1)
6202170
        , _accountMirTxHash :: TxHash
_accountMirTxHash = TxHash
"2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531"
        }
    , AccountMir
        { _accountMirAmount :: Lovelaces
_accountMirAmount = Discrete' "ADA" '(1000000, 1)
1202170
        , _accountMirTxHash :: TxHash
_accountMirTxHash = TxHash
"1dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531"
        }
    ]

-- | Address associated with an account address
newtype AddressAssociated = AddressAssociated {AddressAssociated -> Address
_addressAssociatedAddress :: Address}
  deriving stock (AddressAssociated -> AddressAssociated -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddressAssociated -> AddressAssociated -> Bool
$c/= :: AddressAssociated -> AddressAssociated -> Bool
== :: AddressAssociated -> AddressAssociated -> Bool
$c== :: AddressAssociated -> AddressAssociated -> Bool
Eq, Int -> AddressAssociated -> ShowS
[AddressAssociated] -> ShowS
AddressAssociated -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddressAssociated] -> ShowS
$cshowList :: [AddressAssociated] -> ShowS
show :: AddressAssociated -> String
$cshow :: AddressAssociated -> String
showsPrec :: Int -> AddressAssociated -> ShowS
$cshowsPrec :: Int -> AddressAssociated -> ShowS
Show, forall x. Rep AddressAssociated x -> AddressAssociated
forall x. AddressAssociated -> Rep AddressAssociated x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddressAssociated x -> AddressAssociated
$cfrom :: forall x. AddressAssociated -> Rep AddressAssociated x
Generic)
  deriving (Value -> Parser [AddressAssociated]
Value -> Parser AddressAssociated
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [AddressAssociated]
$cparseJSONList :: Value -> Parser [AddressAssociated]
parseJSON :: Value -> Parser AddressAssociated
$cparseJSON :: Value -> Parser AddressAssociated
FromJSON, [AddressAssociated] -> Encoding
[AddressAssociated] -> Value
AddressAssociated -> Encoding
AddressAssociated -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [AddressAssociated] -> Encoding
$ctoEncodingList :: [AddressAssociated] -> Encoding
toJSONList :: [AddressAssociated] -> Value
$ctoJSONList :: [AddressAssociated] -> Value
toEncoding :: AddressAssociated -> Encoding
$ctoEncoding :: AddressAssociated -> Encoding
toJSON :: AddressAssociated -> Value
$ctoJSON :: AddressAssociated -> Value
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressAssociated", CamelToSnake]] AddressAssociated

instance ToSample AddressAssociated where
  toSamples :: Proxy AddressAssociated -> [(Text, AddressAssociated)]
toSamples = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [(Text, a)]
samples
    [ Address -> AddressAssociated
AddressAssociated Address
"addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd"
    , Address -> AddressAssociated
AddressAssociated Address
"addr1q8j55h253zcvl326sk5qdt2n8z7eghzspe0ekxgncr796s2f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sjmd35m"
    ]