| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Chain.Blockfrost.Client
Synopsis
- data APIBlockfrostError
- data BlockfrostException
- = TimeoutOnUTxO TxId
- | NoUTxOFound (Address ShelleyAddr)
- | FailedToDecodeAddress Text
- | ByronAddressNotSupported
- | FailedUTxOForHash Text
- | FailedEraHistory
- | AssetNameMissing
- | DeserialiseError Text
- data BlockfrostConversion = BlockfrostConversion {
- a0 :: NonNegativeInterval
- rho :: UnitInterval
- tau :: UnitInterval
- priceMemory :: NonNegativeInterval
- priceSteps :: NonNegativeInterval
- pvtMotionNoConfidence :: UnitInterval
- pvtCommitteeNormal :: UnitInterval
- pvtCommitteeNoConfidence :: UnitInterval
- pvtHardForkInitiation :: UnitInterval
- pvtPPSecurityGroup :: UnitInterval
- dvtMotionNoConfidence :: UnitInterval
- dvtCommitteeNormal :: UnitInterval
- dvtCommitteeNoConfidence :: UnitInterval
- dvtUpdateToConstitution :: UnitInterval
- dvtHardForkInitiation :: UnitInterval
- dvtPPNetworkGroup :: UnitInterval
- dvtPPEconomicGroup :: UnitInterval
- dvtPPTechnicalGroup :: UnitInterval
- dvtPPGovGroup :: UnitInterval
- dvtTreasuryWithdrawal :: UnitInterval
- committeeMinSize :: Quantity
- committeeMaxTermLength :: Quantity
- govActionLifetime :: Quantity
- govActionDeposit :: Coin
- drepDeposit :: Integer
- drepActivity :: Quantity
- minFeeRefScriptCostPerByte :: NonNegativeInterval
- blockfrostRetryPolicy :: MonadIO m => RetryPolicyM m
- isRetryable :: APIBlockfrostError -> Bool
- submissionRetryPolicy :: MonadIO m => RetryPolicyM m
- queryGenesisParameters :: BlockfrostClientT IO Genesis
- queryScriptRegistry :: NetworkId -> [TxId] -> BlockfrostClientT IO ScriptRegistry
- queryEraHistory :: BlockfrostClientT IO EraHistory
- queryProtocolParameters :: MonadIO m => BlockfrostClientT m (PParams LedgerEra)
- queryStakePools :: BlockfrostClientT IO (Set PoolId)
- maxRetries :: Int
- awaitPolicy :: MonadIO m => RetryPolicyM m
- runBlockfrostMWith :: (MonadIO m, MonadThrow m) => RetryPolicyM m -> Project -> BlockfrostClientT IO a -> m a
- runBlockfrostM :: (MonadIO m, MonadThrow m) => Project -> BlockfrostClientT IO a -> m a
- queryUTxOByTxIn :: NetworkId -> [TxIn] -> BlockfrostClientT IO UTxO
- scriptTypeToPlutusVersion :: ScriptType -> Maybe Language
- toCardanoUTxO :: NetworkId -> TxIn -> Address -> Maybe ScriptHash -> Maybe DatumHash -> [Amount] -> Maybe InlineDatum -> BlockfrostClientT IO UTxO
- toCardanoValue :: [Amount] -> BlockfrostClientT IO Value
- queryScript :: Text -> BlockfrostClientT IO (Maybe PlutusScript)
- toCardanoTxOut :: NetworkId -> Text -> Value -> Maybe Text -> Maybe Text -> Maybe PlutusScript -> BlockfrostClientT IO (TxOut ctx)
- toCardanoPoolId :: PoolId -> Hash StakePoolKey
- toCardanoTxIn :: Text -> Integer -> TxIn
- toCardanoAddress :: Text -> Maybe AddressInEra
- toCardanoPolicyIdAndAssetName :: Text -> BlockfrostClientT IO (PolicyId, AssetName)
- toCardanoNetworkId :: Integer -> NetworkId
- toCardanoSystemStart :: Genesis -> SystemStart
- toCardanoGenesisParameters :: Genesis -> GenesisParameters ShelleyEra
- submitTransaction :: MonadIO m => Tx -> BlockfrostClientT m TxHash
- awaitOrThrow :: (a -> Maybe b) -> BlockfrostException -> BlockfrostClientT IO a -> BlockfrostClientT IO b
- queryUTxO :: NetworkId -> [Address ShelleyAddr] -> BlockfrostClientT IO UTxO
- queryUTxOFor :: NetworkId -> VerificationKey PaymentKey -> BlockfrostClientT IO UTxO
- queryTip :: BlockfrostClientT IO ChainPoint
- awaitTransaction :: NetworkId -> Tx -> VerificationKey PaymentKey -> BlockfrostClientT IO UTxO
- awaitUTxO :: NetworkId -> [Address ShelleyAddr] -> Tx -> BlockfrostClientT IO UTxO
- data Block = Block {
- _blockTime :: POSIXTime
- _blockHeight :: Maybe Integer
- _blockHash :: BlockHash
- _blockSlot :: Maybe Slot
- _blockEpoch :: Maybe Epoch
- _blockEpochSlot :: Maybe Integer
- _blockSlotLeader :: Text
- _blockSize :: Integer
- _blockTxCount :: Integer
- _blockOutput :: Maybe Lovelaces
- _blockFees :: Maybe Lovelaces
- _blockBlockVrf :: Maybe Text
- _blockOpCert :: Maybe Text
- _blockOpCertCounter :: Maybe Quantity
- _blockPreviousBlock :: Maybe BlockHash
- _blockNextBlock :: Maybe BlockHash
- _blockConfirmations :: Integer
- newtype Slot = Slot Integer
- newtype BlockHash = BlockHash Text
- data BlockfrostClientT (m :: Type -> Type) a
- data Genesis = Genesis {
- _genesisActiveSlotsCoefficient :: Rational
- _genesisUpdateQuorum :: Integer
- _genesisMaxLovelaceSupply :: Lovelaces
- _genesisNetworkMagic :: Integer
- _genesisEpochLength :: Integer
- _genesisSystemStart :: POSIXTime
- _genesisSlotsPerKesPeriod :: Integer
- _genesisSlotLength :: Integer
- _genesisMaxKesEvolutions :: Integer
- _genesisSecurityParam :: Integer
- data Project
- newtype TransactionCBOR = TransactionCBOR {
- _transactionCBORCbor :: Text
- newtype TxHash = TxHash {
- unTxHash :: Text
- newtype TxHashCBOR = TxHashCBOR {}
- tryError :: MonadError e m => m a -> m (Either e a)
- allPages :: Monad m => (Paged -> m [a]) -> m [a]
- def :: Default a => a
- getBlock :: MonadBlockfrost m => Either Integer BlockHash -> m Block
- getBlockTxsCBOR' :: MonadBlockfrost m => Either Integer BlockHash -> Paged -> SortOrder -> m [TxHashCBOR]
- getLedgerGenesis :: MonadBlockfrost m => m Genesis
- listPools :: MonadBlockfrost m => m [PoolId]
- projectFromFile :: FilePath -> IO Project
- runBlockfrost :: Project -> BlockfrostClientT IO a -> IO (Either BlockfrostError a)
- unBlockHash :: BlockHash -> Text
- unSlot :: Slot -> Integer
Documentation
data APIBlockfrostError Source #
Constructors
Instances
| Exception APIBlockfrostError Source # | |
Defined in Hydra.Chain.Blockfrost.Client Methods toException :: APIBlockfrostError -> SomeException Source # fromException :: SomeException -> Maybe APIBlockfrostError Source # | |
| Show APIBlockfrostError Source # | |
Defined in Hydra.Chain.Blockfrost.Client | |
data BlockfrostException Source #
Constructors
| TimeoutOnUTxO TxId | |
| NoUTxOFound (Address ShelleyAddr) | |
| FailedToDecodeAddress Text | |
| ByronAddressNotSupported | |
| FailedUTxOForHash Text | |
| FailedEraHistory | |
| AssetNameMissing | |
| DeserialiseError Text |
Instances
| Show BlockfrostException Source # | |
Defined in Hydra.Chain.Blockfrost.Client | |
data BlockfrostConversion Source #
Constructors
| BlockfrostConversion | |
Fields
| |
blockfrostRetryPolicy :: MonadIO m => RetryPolicyM m Source #
Retry policy for transient Blockfrost errors: full-jitter exponential
backoff with 1s base, capped at 60s, at most maxRetries retries.
isRetryable :: APIBlockfrostError -> Bool Source #
submissionRetryPolicy :: MonadIO m => RetryPolicyM m Source #
Rate-limit retry policy for transaction submission: like
blockfrostRetryPolicy, but gives up well before the upper validity bound
of close/contest transactions (now + min(contestationPeriod, maxGraceTime
= 200s), set at construction and not refreshed on retry). Retrying past
that point could only surface an expired-validity error instead of a timely
rate-limit failure the caller can react to. The cumulative delay limit only
kicks in once reached, so the worst case is ~120s plus one more (up to 60s)
delay, still below maxGraceTime.
queryGenesisParameters :: BlockfrostClientT IO Genesis Source #
Query the Blockfrost API for Genesis
queryScriptRegistry :: NetworkId -> [TxId] -> BlockfrostClientT IO ScriptRegistry Source #
Query for TxIns in the search for outputs containing all the reference
scripts of the ScriptRegistry.
This is implemented by repeated querying until we have all necessary reference scripts as we do only know the transaction id, not the indices.
Can throw at least NewScriptRegistryException on failure.
queryEraHistory :: BlockfrostClientT IO EraHistory Source #
queryProtocolParameters :: MonadIO m => BlockfrostClientT m (PParams LedgerEra) Source #
queryStakePools :: BlockfrostClientT IO (Set PoolId) Source #
maxRetries :: Int Source #
Maximum number of retries for transient Blockfrost errors.
awaitPolicy :: MonadIO m => RetryPolicyM m Source #
Policy for awaiting eventually-consistent query results (tx inclusion,
indexer catch-up): full-jitter backoff capped at 10s per attempt, giving up
once retries have accumulated ~5 minutes of waiting. Not to be confused
with blockfrostRetryPolicy, which handles HTTP 429 inside every request.
runBlockfrostMWith :: (MonadIO m, MonadThrow m) => RetryPolicyM m -> Project -> BlockfrostClientT IO a -> m a Source #
Like runBlockfrostM but with a custom rate-limit retry policy.
runBlockfrostM :: (MonadIO m, MonadThrow m) => Project -> BlockfrostClientT IO a -> m a Source #
Run a Blockfrost client action, retrying when rate limited (HTTP 429)
using blockfrostRetryPolicy. blockfrost-client does not expose the
Retry-After header, so the delay is blind. Gives up by throwing
BlockfrostRateLimited.
queryUTxOByTxIn :: NetworkId -> [TxIn] -> BlockfrostClientT IO UTxO Source #
Query the Blockfrost API to get the UTxO for TxIn and convert to cardano UTxO.
Awaits the tx being indexed by Blockfrost (eventual consistency), retrying
with awaitPolicy before giving up with FailedUTxOForHash.
scriptTypeToPlutusVersion :: ScriptType -> Maybe Language Source #
toCardanoUTxO :: NetworkId -> TxIn -> Address -> Maybe ScriptHash -> Maybe DatumHash -> [Amount] -> Maybe InlineDatum -> BlockfrostClientT IO UTxO Source #
toCardanoValue :: [Amount] -> BlockfrostClientT IO Value Source #
queryScript :: Text -> BlockfrostClientT IO (Maybe PlutusScript) Source #
toCardanoTxOut :: NetworkId -> Text -> Value -> Maybe Text -> Maybe Text -> Maybe PlutusScript -> BlockfrostClientT IO (TxOut ctx) Source #
toCardanoPoolId :: PoolId -> Hash StakePoolKey Source #
toCardanoTxIn :: Text -> Integer -> TxIn Source #
toCardanoAddress :: Text -> Maybe AddressInEra Source #
toCardanoPolicyIdAndAssetName :: Text -> BlockfrostClientT IO (PolicyId, AssetName) Source #
toCardanoNetworkId :: Integer -> NetworkId Source #
toCardanoSystemStart :: Genesis -> SystemStart Source #
toCardanoGenesisParameters :: Genesis -> GenesisParameters ShelleyEra Source #
submitTransaction :: MonadIO m => Tx -> BlockfrostClientT m TxHash Source #
awaitOrThrow :: (a -> Maybe b) -> BlockfrostException -> BlockfrostClientT IO a -> BlockfrostClientT IO b Source #
Run an action with awaitPolicy until the projection yields a result,
throwing the given BlockfrostException once retries are exhausted.
Blockfrost is eventually consistent, so queries can lag recently submitted
transactions.
queryUTxO :: NetworkId -> [Address ShelleyAddr] -> BlockfrostClientT IO UTxO Source #
Query the Blockfrost API for address UTxO and convert to cardano UTxO.
NOTE: We accept the address list here to be compatible with cardano-api but in
fact this is a single address query always.
queryUTxOFor :: NetworkId -> VerificationKey PaymentKey -> BlockfrostClientT IO UTxO Source #
queryTip :: BlockfrostClientT IO ChainPoint Source #
Query the Blockfrost API for Genesis and convert to cardano ChainPoint.
awaitTransaction :: NetworkId -> Tx -> VerificationKey PaymentKey -> BlockfrostClientT IO UTxO Source #
Arguments
| :: NetworkId | Network id |
| -> [Address ShelleyAddr] | Addresses we are interested in |
| -> Tx | Transaction to await |
| -> BlockfrostClientT IO UTxO |
Wait for the transaction to be included and return its outputs paying to the given addresses, awaiting until an address query reflects them. An empty result is not a failure: the tx pays nothing to those addresses, and only inclusion is awaited.
Constructors
| Block | |
Fields
| |
Instances
Instances
Constructors
| BlockHash Text |
Instances
data BlockfrostClientT (m :: Type -> Type) a #
Instances
Constructors
Instances
Instances
| IsString Project | |
Defined in Blockfrost.Auth Methods fromString :: String -> Project Source # | |
| Generic Project | |
| Show Project | |
| Eq Project | |
| type Rep Project | |
Defined in Blockfrost.Auth type Rep Project = D1 ('MetaData "Project" "Blockfrost.Auth" "blockfrost-api-0.15.0.0-HeNUgdZsDZyL8sVfNe2EH8" 'False) (C1 ('MetaCons "Project" 'PrefixI 'True) (S1 ('MetaSel ('Just "projectEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Env) :*: S1 ('MetaSel ('Just "projectId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) | |
newtype TransactionCBOR #
Constructors
| TransactionCBOR | |
Fields
| |
Instances
Instances
| FromJSON TxHash | |
Defined in Blockfrost.Types.Shared.TxHash | |
| ToJSON TxHash | |
Defined in Blockfrost.Types.Shared.TxHash Methods toEncoding :: TxHash -> Encoding toJSONList :: [TxHash] -> Value toEncodingList :: [TxHash] -> Encoding | |
| IsString TxHash | |
Defined in Blockfrost.Types.Shared.TxHash Methods fromString :: String -> TxHash Source # | |
| Generic TxHash | |
| Show TxHash | |
| Eq TxHash | |
| Ord TxHash | |
Defined in Blockfrost.Types.Shared.TxHash | |
| FromHttpApiData TxHash | |
Defined in Blockfrost.Types.Shared.TxHash Methods parseUrlPiece :: Text -> Either Text TxHash parseHeader :: ByteString -> Either Text TxHash parseQueryParam :: Text -> Either Text TxHash | |
| ToHttpApiData TxHash | |
Defined in Blockfrost.Types.Shared.TxHash Methods toUrlPiece :: TxHash -> Text toEncodedUrlPiece :: TxHash -> Builder toHeader :: TxHash -> ByteString toQueryParam :: TxHash -> Text toEncodedQueryParam :: TxHash -> Builder | |
| ToSample TxHash | |
Defined in Blockfrost.Types.Shared.TxHash | |
| HasHash TransactionUtxos TxHash | |
Defined in Blockfrost.Lens | |
| HasInitialMintTxHash AssetDetails TxHash | |
Defined in Blockfrost.Lens Methods initialMintTxHash :: Lens' AssetDetails TxHash | |
| HasTxHash AccountDelegation TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash AccountMir TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash AccountRegistration TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash AccountWithdrawal TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash AddressTransaction TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash AddressUtxo TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash AssetHistory TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash AssetTransaction TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash DRepUpdate TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash DRepVote TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash ParamProposal TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash ProposalInfo TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash ProposalMeta TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash ProposalVote TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash TxMetaCBOR TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash TxMetaJSON TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash PoolUpdate TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash UtxoInput TxHash | |
Defined in Blockfrost.Lens | |
| HasTxHash NutlinkTicker TxHash | |
Defined in Blockfrost.Lens | |
| ToCapture (Capture "hash" TxHash) | |
Defined in Blockfrost.Types.Shared.TxHash | |
| type Rep TxHash | |
Defined in Blockfrost.Types.Shared.TxHash | |
newtype TxHashCBOR #
Constructors
| TxHashCBOR | |
Fields | |
Instances
tryError :: MonadError e m => m a -> m (Either e a) Source #
MonadError analogue to the try function.
getBlockTxsCBOR' :: MonadBlockfrost m => Either Integer BlockHash -> Paged -> SortOrder -> m [TxHashCBOR] #
getLedgerGenesis :: MonadBlockfrost m => m Genesis #
projectFromFile :: FilePath -> IO Project #
runBlockfrost :: Project -> BlockfrostClientT IO a -> IO (Either BlockfrostError a) #
unBlockHash :: BlockHash -> Text #