module Blockfrost.Client.Cardano.Utils
( deriveShelleyAddress
, txEvaluate
, txEvaluateUTXOs
) where
import Data.Text (Text)
import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.Types
utilsClient :: MonadBlockfrost m => Project -> UtilsAPI (AsClientT m)
utilsClient :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> UtilsAPI (AsClientT m)
utilsClient = ((Text -> Integer -> Integer -> m DerivedAddress)
:<|> ((CBORString -> m TxEval) :<|> (TxEvalInput -> m TxEval)))
-> UtilsAPI (AsClientT m)
ToServant UtilsAPI (AsClientT m) -> UtilsAPI (AsClientT m)
forall {k} (routes :: k -> *) (mode :: k).
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant (((Text -> Integer -> Integer -> m DerivedAddress)
:<|> ((CBORString -> m TxEval) :<|> (TxEvalInput -> m TxEval)))
-> UtilsAPI (AsClientT m))
-> (Project
-> (Text -> Integer -> Integer -> m DerivedAddress)
:<|> ((CBORString -> m TxEval) :<|> (TxEvalInput -> m TxEval)))
-> Project
-> UtilsAPI (AsClientT m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoAPI (AsClientT m)
-> (Text -> Integer -> Integer -> m DerivedAddress)
:<|> ((CBORString -> m TxEval) :<|> (TxEvalInput -> m TxEval))
CardanoAPI (AsClientT m)
-> AsClientT m
:- ("utils"
:> (Tag "Cardano \187 Utilities" :> ToServantApi UtilsAPI))
forall route.
CardanoAPI route
-> route
:- ("utils"
:> (Tag "Cardano \187 Utilities" :> ToServantApi UtilsAPI))
_utils (CardanoAPI (AsClientT m)
-> (Text -> Integer -> Integer -> m DerivedAddress)
:<|> ((CBORString -> m TxEval) :<|> (TxEvalInput -> m TxEval)))
-> (Project -> CardanoAPI (AsClientT m))
-> Project
-> (Text -> Integer -> Integer -> m DerivedAddress)
:<|> ((CBORString -> m TxEval) :<|> (TxEvalInput -> m TxEval))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> CardanoAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CardanoAPI (AsClientT m)
cardanoClient
deriveShelleyAddress_
:: MonadBlockfrost m
=> Project
-> Text
-> Integer
-> Integer
-> m DerivedAddress
deriveShelleyAddress_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Text -> Integer -> Integer -> m DerivedAddress
deriveShelleyAddress_ = UtilsAPI (AsClientT m)
-> AsClientT m
:- (Summary "Derive an address"
:> (Description "Derive Shelley address from an xpub."
:> ("addresses"
:> ("xpub"
:> (Capture "xpub" Text
:> (Capture "role" Integer
:> (Capture "index" Integer :> Get '[JSON] DerivedAddress)))))))
UtilsAPI (AsClientT m)
-> Text -> Integer -> Integer -> m DerivedAddress
forall route.
UtilsAPI route
-> route
:- (Summary "Derive an address"
:> (Description "Derive Shelley address from an xpub."
:> ("addresses"
:> ("xpub"
:> (Capture "xpub" Text
:> (Capture "role" Integer
:> (Capture "index" Integer :> Get '[JSON] DerivedAddress)))))))
_deriveAddr (UtilsAPI (AsClientT m)
-> Text -> Integer -> Integer -> m DerivedAddress)
-> (Project -> UtilsAPI (AsClientT m))
-> Project
-> Text
-> Integer
-> Integer
-> m DerivedAddress
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> UtilsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> UtilsAPI (AsClientT m)
utilsClient
deriveShelleyAddress
:: MonadBlockfrost m
=> Text
-> Integer
-> Integer
-> m DerivedAddress
deriveShelleyAddress :: forall (m :: * -> *).
MonadBlockfrost m =>
Text -> Integer -> Integer -> m DerivedAddress
deriveShelleyAddress Text
xpub Integer
role Integer
index = (Project -> m DerivedAddress) -> m DerivedAddress
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (\Project
p -> Project -> Text -> Integer -> Integer -> m DerivedAddress
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> Text -> Integer -> Integer -> m DerivedAddress
deriveShelleyAddress_ Project
p Text
xpub Integer
role Integer
index)
txEvaluate_
:: MonadBlockfrost m
=> Project
-> CBORString
-> m TxEval
txEvaluate_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CBORString -> m TxEval
txEvaluate_ = UtilsAPI (AsClientT m)
-> AsClientT m
:- (Summary "Submit a transaction for execution units evaluation"
:> (Description
"Submit an already serialized transaction to evaluate how much execution units it requires."
:> ("txs"
:> ("evaluate"
:> (ReqBody '[CBOR] CBORString :> Post '[JSON] TxEval)))))
UtilsAPI (AsClientT m) -> CBORString -> m TxEval
forall route.
UtilsAPI route
-> route
:- (Summary "Submit a transaction for execution units evaluation"
:> (Description
"Submit an already serialized transaction to evaluate how much execution units it requires."
:> ("txs"
:> ("evaluate"
:> (ReqBody '[CBOR] CBORString :> Post '[JSON] TxEval)))))
_txEvaluate (UtilsAPI (AsClientT m) -> CBORString -> m TxEval)
-> (Project -> UtilsAPI (AsClientT m))
-> Project
-> CBORString
-> m TxEval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> UtilsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> UtilsAPI (AsClientT m)
utilsClient
txEvaluate
:: MonadBlockfrost m
=> CBORString
-> m TxEval
txEvaluate :: forall (m :: * -> *). MonadBlockfrost m => CBORString -> m TxEval
txEvaluate CBORString
txCbor = (Project -> m TxEval) -> m TxEval
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (Project -> CBORString -> m TxEval
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CBORString -> m TxEval
`txEvaluate_` CBORString
txCbor)
txEvaluateUTXOs_
:: MonadBlockfrost m
=> Project
-> TxEvalInput
-> m TxEval
txEvaluateUTXOs_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> TxEvalInput -> m TxEval
txEvaluateUTXOs_ = UtilsAPI (AsClientT m)
-> AsClientT m
:- (Summary
"Submit a transaction for execution units evaluation (additional UTXO set)"
:> (Description
"Submit a JSON payload with transaction CBOR and additional UTXO set to evaluate how much execution units it requires."
:> ("txs"
:> ("evaluate"
:> ("utxos"
:> (ReqBody '[JSON] TxEvalInput :> Post '[JSON] TxEval))))))
UtilsAPI (AsClientT m) -> TxEvalInput -> m TxEval
forall route.
UtilsAPI route
-> route
:- (Summary
"Submit a transaction for execution units evaluation (additional UTXO set)"
:> (Description
"Submit a JSON payload with transaction CBOR and additional UTXO set to evaluate how much execution units it requires."
:> ("txs"
:> ("evaluate"
:> ("utxos"
:> (ReqBody '[JSON] TxEvalInput :> Post '[JSON] TxEval))))))
_txEvaluateUTXOs (UtilsAPI (AsClientT m) -> TxEvalInput -> m TxEval)
-> (Project -> UtilsAPI (AsClientT m))
-> Project
-> TxEvalInput
-> m TxEval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> UtilsAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> UtilsAPI (AsClientT m)
utilsClient
txEvaluateUTXOs
:: MonadBlockfrost m
=> TxEvalInput
-> m TxEval
txEvaluateUTXOs :: forall (m :: * -> *). MonadBlockfrost m => TxEvalInput -> m TxEval
txEvaluateUTXOs TxEvalInput
txei = (Project -> m TxEval) -> m TxEval
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go (Project -> TxEvalInput -> m TxEval
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> TxEvalInput -> m TxEval
`txEvaluateUTXOs_` TxEvalInput
txei)