Skip to content

Commit

Permalink
feat: extract blockfrost
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianBalaj committed Feb 19, 2025
1 parent 53f42ed commit 0c6474c
Show file tree
Hide file tree
Showing 38 changed files with 316 additions and 2,746 deletions.
149 changes: 148 additions & 1 deletion packages.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,151 @@ let upstream =
-- https://github.com/mlabs-haskell/purescript-cardano-package-set
https://raw.githubusercontent.com/mlabs-haskell/purescript-cardano-package-set/v1.1.0/packages.dhall sha256:6197d808325030415858c597b61c83320344bf899107b83f7dfe366de4650aa6

in upstream
let additions =
{ cardano-types =
{ dependencies =
[ "aeson"
, "aff"
, "arraybuffer-types"
, "arrays"
, "bifunctors"
, "bytearrays"
, "cardano-plutus-data-schema"
, "cardano-serialization-lib"
, "control"
, "datetime"
, "effect"
, "either"
, "encoding"
, "exceptions"
, "foldable-traversable"
, "foreign-object"
, "integers"
, "js-bigints"
, "lattice"
, "lists"
, "literals"
, "maybe"
, "monad-logger"
, "mote"
, "mote-testplan"
, "newtype"
, "nonempty"
, "nullable"
, "ordered-collections"
, "partial"
, "prelude"
, "profunctor"
, "profunctor-lenses"
, "quickcheck"
, "rationals"
, "record"
, "safe-coerce"
, "spec"
, "these"
, "tuples"
, "typelevel-prelude"
, "uint"
, "unfoldable"
, "unsafe-coerce"
]
, repo = "https://github.com/mlabs-haskell/purescript-cardano-types.git"
, version = "461c1972a122d2ca54320bd3c63a62e94a0085b5"
}
, cardano-provider =
{ dependencies =
[ "aeson"
, "aff"
, "affjax"
, "argonaut-codecs"
, "arraybuffer-types"
, "arrays"
, "bifunctors"
, "bytearrays"
, "cardano-plutus-data-schema"
, "cardano-serialization-lib"
, "cardano-types"
, "console"
, "control"
, "datetime"
, "effect"
, "either"
, "encoding"
, "exceptions"
, "foldable-traversable"
, "foreign-object"
, "integers"
, "js-bigints"
, "lattice"
, "lists"
, "literals"
, "maybe"
, "monad-logger"
, "mote"
, "mote-testplan"
, "newtype"
, "nonempty"
, "nullable"
, "ordered-collections"
, "partial"
, "prelude"
, "profunctor"
, "profunctor-lenses"
, "quickcheck"
, "rationals"
, "record"
, "safe-coerce"
, "spec"
, "these"
, "tuples"
, "typelevel-prelude"
, "uint"
, "unfoldable"
, "unsafe-coerce"
]
, repo = "https://github.com/mlabs-haskell/purescript-cardano-provider"
, version = "5c45f7def0a29b6653945e107be1b7c738d571d8"
}
, cardano-blockfrost-provider =
{ dependencies =
[ "aeson"
, "aff"
, "affjax"
, "arrays"
, "bifunctors"
, "bignumber"
, "bytearrays"
, "cardano-provider"
, "cardano-serialization-lib"
, "cardano-types"
, "control"
, "datetime"
, "effect"
, "either"
, "exceptions"
, "foldable-traversable"
, "foreign-object"
, "heterogeneous"
, "http-methods"
, "js-bigints"
, "js-date"
, "lists"
, "maybe"
, "media-types"
, "monad-logger"
, "newtype"
, "numbers"
, "ordered-collections"
, "parallel"
, "prelude"
, "strings"
, "transformers"
, "tuples"
, "uint"
]
, repo = "https://github.com/mlabs-haskell/purescript-cardano-blockfrost-provider"
, version = "b9bac36efc5ef1a491bee4324a6c2065f642b1ee"
}
}

in upstream // additions
24 changes: 18 additions & 6 deletions spago-packages.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
, "arrays"
, "avar"
, "bifunctors"
, "bignumber"
, "bytearrays"
, "cardano-hd-wallet"
, "cardano-key-wallet"
Expand All @@ -20,6 +19,7 @@
, "cardano-serialization-lib"
, "cardano-transaction-builder"
, "cardano-types"
, "cardano-blockfrost-provider"
, "cardano-provider"
, "checked-exceptions"
, "cip30"
Expand All @@ -41,7 +41,6 @@
, "foreign-object"
, "formatters"
, "functions"
, "heterogeneous"
, "http-methods"
, "identity"
, "integers"
Expand Down Expand Up @@ -84,7 +83,6 @@
, "quickcheck"
, "quickcheck-combinators"
, "random"
, "rationals"
, "record"
, "refs"
, "safe-coerce"
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Numeric/Rational.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Contract.Numeric.Rational
( module Rational
) where

import Ctl.Internal.Types.Rational
import Cardano.Types.Rational
( class RationalComponent
, Rational
, denominator
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/ProtocolParameters.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module Contract.ProtocolParameters
( getProtocolParameters
) where

import Cardano.Types.ProtocolParameters (ProtocolParameters)
import Contract.Monad (Contract)
import Ctl.Internal.Contract (getProtocolParameters) as Contract
import Ctl.Internal.Types.ProtocolParameters (ProtocolParameters)

-- | Returns the `ProtocolParameters` from the `Contract` environment.
-- | Note that this is not necessarily the current value from the ledger.
Expand Down
4 changes: 2 additions & 2 deletions src/Contract/Time.purs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import Cardano.Types.EraSummaries
, SlotLength(SlotLength)
) as ExportEraSummaries
import Cardano.Types.EraSummaries (EraSummaries, EraSummary)
import Cardano.Types.SystemStart (SystemStart)
import Cardano.Types.SystemStart (SystemStart(SystemStart)) as ExportSystemStart
import Contract.Chain (getTip) as Chain
import Contract.Log (logInfo')
import Contract.Monad (Contract, liftContractM, liftedE)
Expand Down Expand Up @@ -97,8 +99,6 @@ import Ctl.Internal.Types.Interval
, toOnchainPosixTimeRange
, upperBound
) as Interval
import Ctl.Internal.Types.SystemStart (SystemStart)
import Ctl.Internal.Types.SystemStart (SystemStart(SystemStart)) as ExportSystemStart
import Data.Array as Array
import Data.Foldable (find)
import Data.Maybe (Maybe(Just, Nothing))
Expand Down
6 changes: 3 additions & 3 deletions src/Internal/BalanceTx/BalanceTx.purs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import Cardano.Types.Address (Address)
import Cardano.Types.BigNum as BigNum
import Cardano.Types.Coin as Coin
import Cardano.Types.OutputDatum (OutputDatum(OutputDatum))
import Cardano.Types.ProtocolParameters
( ProtocolParameters(ProtocolParameters)
)
import Cardano.Types.TransactionBody (_votingProposals)
import Cardano.Types.TransactionInput (TransactionInput)
import Cardano.Types.TransactionUnspentOutput as TransactionUnspentOutputs
Expand Down Expand Up @@ -117,9 +120,6 @@ import Ctl.Internal.Partition
, equipartitionValueWithTokenQuantityUpperBound
, partition
)
import Ctl.Internal.Types.ProtocolParameters
( ProtocolParameters(ProtocolParameters)
)
import Ctl.Internal.Types.Val (Val(Val), pprintVal)
import Ctl.Internal.Types.Val as Val
import Data.Array as Array
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Contract.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module Ctl.Internal.Contract (getChainTip, getProtocolParameters) where
import Prelude

import Cardano.Types.Chain (Tip)
import Cardano.Types.ProtocolParameters (ProtocolParameters)
import Control.Monad.Reader.Class (asks)
import Ctl.Internal.Contract.Monad (Contract, getProvider)
import Ctl.Internal.Types.ProtocolParameters (ProtocolParameters)
import Data.Either (either)
import Effect.Aff.Class (liftAff)
import Effect.Class (liftEffect)
Expand Down
14 changes: 7 additions & 7 deletions src/Internal/Contract/Monad.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ module Ctl.Internal.Contract.Monad

import Prelude

import Cardano.Blockfrost.Service
( BlockfrostServiceM
, runBlockfrostServiceM
)
import Cardano.Blockfrost.Service as Blockfrost
import Cardano.Provider.Error (ClientError)
import Cardano.Provider.Type (Provider)
import Cardano.Types (NetworkId(TestnetId, MainnetId), TransactionHash, UtxoMap)
import Cardano.Types.ProtocolParameters (ProtocolParameters)
import Cardano.Types.SystemStart (SystemStart)
import Contract.Prelude (liftEither)
import Control.Alt (class Alt)
import Control.Alternative (class Alternative)
Expand Down Expand Up @@ -66,13 +73,6 @@ import Ctl.Internal.QueryM
, underlyingWebSocket
)
import Ctl.Internal.QueryM.Kupo (isTxConfirmedAff)
import Ctl.Internal.Service.Blockfrost
( BlockfrostServiceM
, runBlockfrostServiceM
)
import Ctl.Internal.Service.Blockfrost as Blockfrost
import Ctl.Internal.Types.ProtocolParameters (ProtocolParameters)
import Ctl.Internal.Types.SystemStart (SystemStart)
import Ctl.Internal.Types.UsedTxOuts (UsedTxOuts, isTxOutRefUsed, newUsedTxOuts)
import Ctl.Internal.Wallet (Wallet(GenericCip30))
import Ctl.Internal.Wallet.Spec (WalletSpec, mkWalletBySpec)
Expand Down
15 changes: 8 additions & 7 deletions src/Internal/Contract/Provider.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ module Ctl.Internal.Contract.Provider
import Prelude

import Cardano.AsCbor (encodeCbor)
import Cardano.Blockfrost.BlockfrostBackend (BlockfrostBackend)
import Cardano.Blockfrost.Service
( BlockfrostServiceM
, runBlockfrostServiceM
)
import Cardano.Blockfrost.Service as Blockfrost
import Cardano.Provider.Error (ClientError(ClientOtherError))
import Cardano.Provider.Type (Provider)
import Cardano.Types.Transaction (hash) as Transaction
import Contract.Log (logDebug')
import Control.Monad.Error.Class (throwError)
import Ctl.Internal.Contract.LogParams (LogParams)
import Ctl.Internal.Contract.ProviderBackend (BlockfrostBackend, CtlBackend)
import Ctl.Internal.Contract.ProviderBackend (CtlBackend)
import Ctl.Internal.Helpers (logWithLevel)
import Ctl.Internal.QueryM (QueryM)
import Ctl.Internal.QueryM (evaluateTxOgmios, getChainTip, submitTxOgmios) as QueryM
Expand All @@ -34,11 +40,6 @@ import Ctl.Internal.QueryM.Pools
, getPubKeyHashDelegationsAndRewards
, getValidatorHashDelegationsAndRewards
) as QueryM
import Ctl.Internal.Service.Blockfrost
( BlockfrostServiceM
, runBlockfrostServiceM
)
import Ctl.Internal.Service.Blockfrost as Blockfrost
import Data.Either (Either(Left, Right))
import Data.Maybe (fromMaybe, isJust)
import Data.Newtype (unwrap, wrap)
Expand Down Expand Up @@ -109,7 +110,7 @@ providerForBlockfrostBackend logParams backend =
Left err -> throwError $ error $ show err
, submitTx: runBlockfrostServiceM' <<< Blockfrost.submitTx
, evaluateTx: \tx additionalUtxos ->
runBlockfrostServiceM' $ Blockfrost.evaluateTx tx (wrap additionalUtxos)
runBlockfrostServiceM' $ Blockfrost.evaluateTx tx additionalUtxos
, getEraSummaries: runBlockfrostServiceM' Blockfrost.getEraSummaries
, getPoolIds: runBlockfrostServiceM' Blockfrost.getPoolIds
, getPubKeyHashDelegationsAndRewards: \networkId stakePubKeyHash ->
Expand Down
Loading

0 comments on commit 0c6474c

Please sign in to comment.