Skip to content

Commit 0c6474c

Browse files
committed
feat: extract blockfrost
1 parent 53f42ed commit 0c6474c

38 files changed

+316
-2746
lines changed

packages.dhall

Lines changed: 148 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,151 @@ let upstream =
22
-- https://github.com/mlabs-haskell/purescript-cardano-package-set
33
https://raw.githubusercontent.com/mlabs-haskell/purescript-cardano-package-set/v1.1.0/packages.dhall sha256:6197d808325030415858c597b61c83320344bf899107b83f7dfe366de4650aa6
44

5-
in upstream
5+
let additions =
6+
{ cardano-types =
7+
{ dependencies =
8+
[ "aeson"
9+
, "aff"
10+
, "arraybuffer-types"
11+
, "arrays"
12+
, "bifunctors"
13+
, "bytearrays"
14+
, "cardano-plutus-data-schema"
15+
, "cardano-serialization-lib"
16+
, "control"
17+
, "datetime"
18+
, "effect"
19+
, "either"
20+
, "encoding"
21+
, "exceptions"
22+
, "foldable-traversable"
23+
, "foreign-object"
24+
, "integers"
25+
, "js-bigints"
26+
, "lattice"
27+
, "lists"
28+
, "literals"
29+
, "maybe"
30+
, "monad-logger"
31+
, "mote"
32+
, "mote-testplan"
33+
, "newtype"
34+
, "nonempty"
35+
, "nullable"
36+
, "ordered-collections"
37+
, "partial"
38+
, "prelude"
39+
, "profunctor"
40+
, "profunctor-lenses"
41+
, "quickcheck"
42+
, "rationals"
43+
, "record"
44+
, "safe-coerce"
45+
, "spec"
46+
, "these"
47+
, "tuples"
48+
, "typelevel-prelude"
49+
, "uint"
50+
, "unfoldable"
51+
, "unsafe-coerce"
52+
]
53+
, repo = "https://github.com/mlabs-haskell/purescript-cardano-types.git"
54+
, version = "461c1972a122d2ca54320bd3c63a62e94a0085b5"
55+
}
56+
, cardano-provider =
57+
{ dependencies =
58+
[ "aeson"
59+
, "aff"
60+
, "affjax"
61+
, "argonaut-codecs"
62+
, "arraybuffer-types"
63+
, "arrays"
64+
, "bifunctors"
65+
, "bytearrays"
66+
, "cardano-plutus-data-schema"
67+
, "cardano-serialization-lib"
68+
, "cardano-types"
69+
, "console"
70+
, "control"
71+
, "datetime"
72+
, "effect"
73+
, "either"
74+
, "encoding"
75+
, "exceptions"
76+
, "foldable-traversable"
77+
, "foreign-object"
78+
, "integers"
79+
, "js-bigints"
80+
, "lattice"
81+
, "lists"
82+
, "literals"
83+
, "maybe"
84+
, "monad-logger"
85+
, "mote"
86+
, "mote-testplan"
87+
, "newtype"
88+
, "nonempty"
89+
, "nullable"
90+
, "ordered-collections"
91+
, "partial"
92+
, "prelude"
93+
, "profunctor"
94+
, "profunctor-lenses"
95+
, "quickcheck"
96+
, "rationals"
97+
, "record"
98+
, "safe-coerce"
99+
, "spec"
100+
, "these"
101+
, "tuples"
102+
, "typelevel-prelude"
103+
, "uint"
104+
, "unfoldable"
105+
, "unsafe-coerce"
106+
]
107+
, repo = "https://github.com/mlabs-haskell/purescript-cardano-provider"
108+
, version = "5c45f7def0a29b6653945e107be1b7c738d571d8"
109+
}
110+
, cardano-blockfrost-provider =
111+
{ dependencies =
112+
[ "aeson"
113+
, "aff"
114+
, "affjax"
115+
, "arrays"
116+
, "bifunctors"
117+
, "bignumber"
118+
, "bytearrays"
119+
, "cardano-provider"
120+
, "cardano-serialization-lib"
121+
, "cardano-types"
122+
, "control"
123+
, "datetime"
124+
, "effect"
125+
, "either"
126+
, "exceptions"
127+
, "foldable-traversable"
128+
, "foreign-object"
129+
, "heterogeneous"
130+
, "http-methods"
131+
, "js-bigints"
132+
, "js-date"
133+
, "lists"
134+
, "maybe"
135+
, "media-types"
136+
, "monad-logger"
137+
, "newtype"
138+
, "numbers"
139+
, "ordered-collections"
140+
, "parallel"
141+
, "prelude"
142+
, "strings"
143+
, "transformers"
144+
, "tuples"
145+
, "uint"
146+
]
147+
, repo = "https://github.com/mlabs-haskell/purescript-cardano-blockfrost-provider"
148+
, version = "b9bac36efc5ef1a491bee4324a6c2065f642b1ee"
149+
}
150+
}
151+
152+
in upstream // additions

spago-packages.nix

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spago.dhall

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
, "arrays"
1212
, "avar"
1313
, "bifunctors"
14-
, "bignumber"
1514
, "bytearrays"
1615
, "cardano-hd-wallet"
1716
, "cardano-key-wallet"
@@ -20,6 +19,7 @@
2019
, "cardano-serialization-lib"
2120
, "cardano-transaction-builder"
2221
, "cardano-types"
22+
, "cardano-blockfrost-provider"
2323
, "cardano-provider"
2424
, "checked-exceptions"
2525
, "cip30"
@@ -41,7 +41,6 @@
4141
, "foreign-object"
4242
, "formatters"
4343
, "functions"
44-
, "heterogeneous"
4544
, "http-methods"
4645
, "identity"
4746
, "integers"
@@ -84,7 +83,6 @@
8483
, "quickcheck"
8584
, "quickcheck-combinators"
8685
, "random"
87-
, "rationals"
8886
, "record"
8987
, "refs"
9088
, "safe-coerce"

src/Contract/Numeric/Rational.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Contract.Numeric.Rational
33
( module Rational
44
) where
55

6-
import Ctl.Internal.Types.Rational
6+
import Cardano.Types.Rational
77
( class RationalComponent
88
, Rational
99
, denominator

src/Contract/ProtocolParameters.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module Contract.ProtocolParameters
22
( getProtocolParameters
33
) where
44

5+
import Cardano.Types.ProtocolParameters (ProtocolParameters)
56
import Contract.Monad (Contract)
67
import Ctl.Internal.Contract (getProtocolParameters) as Contract
7-
import Ctl.Internal.Types.ProtocolParameters (ProtocolParameters)
88

99
-- | Returns the `ProtocolParameters` from the `Contract` environment.
1010
-- | Note that this is not necessarily the current value from the ledger.

src/Contract/Time.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import Cardano.Types.EraSummaries
3333
, SlotLength(SlotLength)
3434
) as ExportEraSummaries
3535
import Cardano.Types.EraSummaries (EraSummaries, EraSummary)
36+
import Cardano.Types.SystemStart (SystemStart)
37+
import Cardano.Types.SystemStart (SystemStart(SystemStart)) as ExportSystemStart
3638
import Contract.Chain (getTip) as Chain
3739
import Contract.Log (logInfo')
3840
import Contract.Monad (Contract, liftContractM, liftedE)
@@ -97,8 +99,6 @@ import Ctl.Internal.Types.Interval
9799
, toOnchainPosixTimeRange
98100
, upperBound
99101
) as Interval
100-
import Ctl.Internal.Types.SystemStart (SystemStart)
101-
import Ctl.Internal.Types.SystemStart (SystemStart(SystemStart)) as ExportSystemStart
102102
import Data.Array as Array
103103
import Data.Foldable (find)
104104
import Data.Maybe (Maybe(Just, Nothing))

src/Internal/BalanceTx/BalanceTx.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ import Cardano.Types.Address (Address)
4141
import Cardano.Types.BigNum as BigNum
4242
import Cardano.Types.Coin as Coin
4343
import Cardano.Types.OutputDatum (OutputDatum(OutputDatum))
44+
import Cardano.Types.ProtocolParameters
45+
( ProtocolParameters(ProtocolParameters)
46+
)
4447
import Cardano.Types.TransactionBody (_votingProposals)
4548
import Cardano.Types.TransactionInput (TransactionInput)
4649
import Cardano.Types.TransactionUnspentOutput as TransactionUnspentOutputs
@@ -117,9 +120,6 @@ import Ctl.Internal.Partition
117120
, equipartitionValueWithTokenQuantityUpperBound
118121
, partition
119122
)
120-
import Ctl.Internal.Types.ProtocolParameters
121-
( ProtocolParameters(ProtocolParameters)
122-
)
123123
import Ctl.Internal.Types.Val (Val(Val), pprintVal)
124124
import Ctl.Internal.Types.Val as Val
125125
import Data.Array as Array

src/Internal/Contract.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module Ctl.Internal.Contract (getChainTip, getProtocolParameters) where
33
import Prelude
44

55
import Cardano.Types.Chain (Tip)
6+
import Cardano.Types.ProtocolParameters (ProtocolParameters)
67
import Control.Monad.Reader.Class (asks)
78
import Ctl.Internal.Contract.Monad (Contract, getProvider)
8-
import Ctl.Internal.Types.ProtocolParameters (ProtocolParameters)
99
import Data.Either (either)
1010
import Effect.Aff.Class (liftAff)
1111
import Effect.Class (liftEffect)

src/Internal/Contract/Monad.purs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ module Ctl.Internal.Contract.Monad
2222

2323
import Prelude
2424

25+
import Cardano.Blockfrost.Service
26+
( BlockfrostServiceM
27+
, runBlockfrostServiceM
28+
)
29+
import Cardano.Blockfrost.Service as Blockfrost
2530
import Cardano.Provider.Error (ClientError)
2631
import Cardano.Provider.Type (Provider)
2732
import Cardano.Types (NetworkId(TestnetId, MainnetId), TransactionHash, UtxoMap)
33+
import Cardano.Types.ProtocolParameters (ProtocolParameters)
34+
import Cardano.Types.SystemStart (SystemStart)
2835
import Contract.Prelude (liftEither)
2936
import Control.Alt (class Alt)
3037
import Control.Alternative (class Alternative)
@@ -66,13 +73,6 @@ import Ctl.Internal.QueryM
6673
, underlyingWebSocket
6774
)
6875
import Ctl.Internal.QueryM.Kupo (isTxConfirmedAff)
69-
import Ctl.Internal.Service.Blockfrost
70-
( BlockfrostServiceM
71-
, runBlockfrostServiceM
72-
)
73-
import Ctl.Internal.Service.Blockfrost as Blockfrost
74-
import Ctl.Internal.Types.ProtocolParameters (ProtocolParameters)
75-
import Ctl.Internal.Types.SystemStart (SystemStart)
7676
import Ctl.Internal.Types.UsedTxOuts (UsedTxOuts, isTxOutRefUsed, newUsedTxOuts)
7777
import Ctl.Internal.Wallet (Wallet(GenericCip30))
7878
import Ctl.Internal.Wallet.Spec (WalletSpec, mkWalletBySpec)

src/Internal/Contract/Provider.purs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ module Ctl.Internal.Contract.Provider
77
import Prelude
88

99
import Cardano.AsCbor (encodeCbor)
10+
import Cardano.Blockfrost.BlockfrostBackend (BlockfrostBackend)
11+
import Cardano.Blockfrost.Service
12+
( BlockfrostServiceM
13+
, runBlockfrostServiceM
14+
)
15+
import Cardano.Blockfrost.Service as Blockfrost
1016
import Cardano.Provider.Error (ClientError(ClientOtherError))
1117
import Cardano.Provider.Type (Provider)
1218
import Cardano.Types.Transaction (hash) as Transaction
1319
import Contract.Log (logDebug')
1420
import Control.Monad.Error.Class (throwError)
1521
import Ctl.Internal.Contract.LogParams (LogParams)
16-
import Ctl.Internal.Contract.ProviderBackend (BlockfrostBackend, CtlBackend)
22+
import Ctl.Internal.Contract.ProviderBackend (CtlBackend)
1723
import Ctl.Internal.Helpers (logWithLevel)
1824
import Ctl.Internal.QueryM (QueryM)
1925
import Ctl.Internal.QueryM (evaluateTxOgmios, getChainTip, submitTxOgmios) as QueryM
@@ -34,11 +40,6 @@ import Ctl.Internal.QueryM.Pools
3440
, getPubKeyHashDelegationsAndRewards
3541
, getValidatorHashDelegationsAndRewards
3642
) as QueryM
37-
import Ctl.Internal.Service.Blockfrost
38-
( BlockfrostServiceM
39-
, runBlockfrostServiceM
40-
)
41-
import Ctl.Internal.Service.Blockfrost as Blockfrost
4243
import Data.Either (Either(Left, Right))
4344
import Data.Maybe (fromMaybe, isJust)
4445
import Data.Newtype (unwrap, wrap)
@@ -109,7 +110,7 @@ providerForBlockfrostBackend logParams backend =
109110
Left err -> throwError $ error $ show err
110111
, submitTx: runBlockfrostServiceM' <<< Blockfrost.submitTx
111112
, evaluateTx: \tx additionalUtxos ->
112-
runBlockfrostServiceM' $ Blockfrost.evaluateTx tx (wrap additionalUtxos)
113+
runBlockfrostServiceM' $ Blockfrost.evaluateTx tx additionalUtxos
113114
, getEraSummaries: runBlockfrostServiceM' Blockfrost.getEraSummaries
114115
, getPoolIds: runBlockfrostServiceM' Blockfrost.getPoolIds
115116
, getPubKeyHashDelegationsAndRewards: \networkId stakePubKeyHash ->

0 commit comments

Comments
 (0)