Skip to content

Commit bc3f67b

Browse files
committed
Use HTTP instead of websocket for Ogmios
1 parent eaf60dd commit bc3f67b

File tree

11 files changed

+1777
-328
lines changed

11 files changed

+1777
-328
lines changed

src/Internal/Contract/Monad.purs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,13 @@ import Ctl.Internal.Contract.QueryHandle
5353
)
5454
import Ctl.Internal.Contract.QueryHandle.Type (QueryHandle)
5555
import Ctl.Internal.Helpers (filterMapWithKeyM, liftM, logWithLevel)
56-
import Ctl.Internal.JsWebSocket (_wsClose, _wsFinalize)
5756
import Ctl.Internal.Logging (Logger, mkLogger, setupLogs)
5857
import Ctl.Internal.QueryM
5958
( QueryEnv
6059
, QueryM
61-
, WebSocket
6260
, getProtocolParametersAff
6361
, getSystemStartAff
64-
, mkOgmiosWebSocketAff
65-
, underlyingWebSocket
6662
)
67-
import Ctl.Internal.QueryM.Kupo (isTxConfirmedAff)
6863
import Ctl.Internal.Service.Blockfrost
6964
( BlockfrostServiceM
7065
, runBlockfrostServiceM
@@ -77,16 +72,15 @@ import Ctl.Internal.Types.UsedTxOuts (UsedTxOuts, isTxOutRefUsed, newUsedTxOuts)
7772
import Ctl.Internal.Wallet (Wallet(GenericCip30))
7873
import Ctl.Internal.Wallet.Spec (WalletSpec, mkWalletBySpec)
7974
import Data.Bifunctor (lmap)
80-
import Data.Either (Either(Left, Right), isRight)
75+
import Data.Either (Either(Right, Left))
8176
import Data.Log.Level (LogLevel)
8277
import Data.Log.Message (Message)
8378
import Data.Maybe (Maybe(Just, Nothing), fromMaybe)
8479
import Data.Newtype (class Newtype, unwrap)
8580
import Data.Set (Set)
8681
import Data.Set as Set
8782
import Data.Time.Duration (Milliseconds, Seconds)
88-
import Data.Traversable (for_, traverse, traverse_)
89-
import Effect (Effect)
83+
import Data.Traversable (for_, traverse)
9084
import Effect.Aff (Aff, ParAff, attempt, error, finally, supervise)
9185
import Effect.Aff.Class (class MonadAff, liftAff)
9286
import Effect.Class (class MonadEffect, liftEffect)
@@ -262,21 +256,16 @@ mkContractEnv params = do
262256
}
263257

264258
buildBackend :: Logger -> QueryBackendParams -> Aff QueryBackend
265-
buildBackend logger = case _ of
259+
buildBackend _ = case _ of
266260
CtlBackendParams ctlParams blockfrostParams ->
267261
flip CtlBackend blockfrostParams <$> buildCtlBackend ctlParams
268262
BlockfrostBackendParams blockfrostParams ctlParams ->
269263
BlockfrostBackend blockfrostParams <$> traverse buildCtlBackend ctlParams
270264
where
271265
buildCtlBackend :: CtlBackendParams -> Aff CtlBackend
272266
buildCtlBackend { ogmiosConfig, kupoConfig } = do
273-
let isTxConfirmed = map isRight <<< isTxConfirmedAff kupoConfig
274-
ogmiosWs <- mkOgmiosWebSocketAff isTxConfirmed logger ogmiosConfig
275267
pure
276-
{ ogmios:
277-
{ config: ogmiosConfig
278-
, ws: ogmiosWs
279-
}
268+
{ ogmiosConfig
280269
, kupoConfig
281270
}
282271

@@ -290,10 +279,10 @@ getLedgerConstants
290279
-> QueryBackend
291280
-> Aff LedgerConstants
292281
getLedgerConstants params = case _ of
293-
CtlBackend { ogmios: { ws } } _ ->
282+
CtlBackend _ _ ->
294283
{ pparams: _, systemStart: _ }
295-
<$> (unwrap <$> getProtocolParametersAff ws logger)
296-
<*> getSystemStartAff ws logger
284+
<$> (unwrap <$> getProtocolParametersAff logger)
285+
<*> getSystemStartAff logger
297286
BlockfrostBackend backend _ ->
298287
runBlockfrostServiceM blockfrostLogger backend $
299288
{ pparams: _, systemStart: _ }
@@ -341,16 +330,9 @@ walletNetworkCheck envNetworkId =
341330

342331
-- | Finalizes a `Contract` environment.
343332
-- | Closes the connections in `ContractEnv`, effectively making it unusable.
333+
-- TODO: remove
344334
stopContractEnv :: ContractEnv -> Aff Unit
345-
stopContractEnv { backend } =
346-
liftEffect $ traverse_ stopCtlRuntime (getCtlBackend backend)
347-
where
348-
stopCtlRuntime :: CtlBackend -> Effect Unit
349-
stopCtlRuntime { ogmios } =
350-
stopWebSocket ogmios.ws
351-
352-
stopWebSocket :: forall (a :: Type). WebSocket a -> Effect Unit
353-
stopWebSocket = ((*>) <$> _wsFinalize <*> _wsClose) <<< underlyingWebSocket
335+
stopContractEnv _ = pure unit
354336

355337
-- | Constructs and finalizes a contract environment that is usable inside a
356338
-- | bracket callback.
@@ -463,9 +445,6 @@ mkQueryEnv params ctlBackend =
463445
, customLogger: params.customLogger
464446
, suppressLogs: params.suppressLogs
465447
}
466-
, runtime:
467-
{ ogmiosWs: ctlBackend.ogmios.ws
468-
}
469448
}
470449

471450
--------------------------------------------------------------------------------

src/Internal/Contract/QueryBackend.purs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module Ctl.Internal.Contract.QueryBackend
1515

1616
import Prelude
1717

18-
import Ctl.Internal.QueryM (OgmiosWebSocket)
1918
import Ctl.Internal.ServerConfig (ServerConfig)
2019
import Data.Maybe (Maybe(Just, Nothing))
2120
import Data.Time.Duration (Seconds(Seconds))
@@ -29,10 +28,7 @@ data QueryBackend
2928
| BlockfrostBackend BlockfrostBackend (Maybe CtlBackend)
3029

3130
type CtlBackend =
32-
{ ogmios ::
33-
{ config :: ServerConfig
34-
, ws :: OgmiosWebSocket
35-
}
31+
{ ogmiosConfig :: ServerConfig
3632
, kupoConfig :: ServerConfig
3733
}
3834

0 commit comments

Comments
 (0)