Skip to content

Commit

Permalink
SCP-5012 Removed commmands related to following contracts.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwbush committed Feb 8, 2023
1 parent e5acc8c commit be19e6e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 69 deletions.
6 changes: 1 addition & 5 deletions marlowe-apps/src/Language/Marlowe/Runtime/App.hs
Expand Up @@ -18,8 +18,7 @@ import Control.Exception (SomeException, catch)
import Data.Bifunctor (second)
import Data.Either (fromRight)
import Language.Marlowe.Runtime.App.Build (buildApplication, buildCreation, buildWithdrawal)
import Language.Marlowe.Runtime.App.List
(allContracts, followContract, followedContracts, getContract, unfollowContract)
import Language.Marlowe.Runtime.App.List (allContracts, getContract)
import Language.Marlowe.Runtime.App.Run (runClientWithConfig)
import Language.Marlowe.Runtime.App.Sign (sign)
import Language.Marlowe.Runtime.App.Submit (submit, waitForTx)
Expand All @@ -37,9 +36,6 @@ handle config request =
run =
case request of
List -> Right . Contracts <$> allContracts
Followed -> Right . Contracts <$> followedContracts
Follow{..} -> fmap FollowResult <$> followContract reqContractId
Unfollow{..} -> fmap FollowResult <$> unfollowContract reqContractId
Get{..} -> fmap (uncurry Info) <$> getContract reqContractId
Create{..} -> second (uncurry mkBody) <$> buildCreation MarloweV1 reqContract reqRoles reqMinUtxo reqMetadata reqAddresses reqChange reqCollateral
Apply{..} -> second (uncurry mkBody) <$> buildApplication MarloweV1 reqContractId reqInputs reqValidityLowerBound reqValidityUpperBound reqMetadata reqAddresses reqChange reqCollateral
Expand Down
34 changes: 2 additions & 32 deletions marlowe-apps/src/Language/Marlowe/Runtime/App/List.hs
Expand Up @@ -7,24 +7,18 @@

module Language.Marlowe.Runtime.App.List
( allContracts
, followContract
, followedContracts
, getContract
, unfollowContract
) where


import Data.Bifunctor (first)
import Data.Type.Equality ((:~:)(Refl))
import Data.Void (Void, absurd)
import Language.Marlowe.Runtime.App.Run (runJobClient, runMarloweSyncClient, runQueryClient)
import Language.Marlowe.Runtime.App.Run (runMarloweSyncClient, runQueryClient)
import Language.Marlowe.Runtime.App.Types (Client, Services(..))
import Language.Marlowe.Runtime.Core.Api (ContractId, IsMarloweVersion(..), MarloweVersion, assertVersionsEqual)
import Language.Marlowe.Runtime.Discovery.Api (ContractHeader(contractId), DiscoveryQuery(..))
import Language.Marlowe.Runtime.History.Api (ContractStep, CreateStep, HistoryCommand(..), HistoryQuery(..))
import Network.Protocol.Job.Client (liftCommand)
import Language.Marlowe.Runtime.History.Api (ContractStep, CreateStep)

import qualified Data.Map as M (keys)
import qualified Language.Marlowe.Protocol.Sync.Client as Sync
( ClientStFollow(ClientStFollow, recvMsgContractFound, recvMsgContractNotFound)
, ClientStIdle(SendMsgDone, SendMsgRequestNext)
Expand All @@ -46,10 +40,6 @@ allContracts :: Client [ContractId]
allContracts = listContracts GetContractHeaders runDiscoveryQueryClient $ fmap contractId


followedContracts :: Client [ContractId]
followedContracts = listContracts GetFollowedContracts runHistoryQueryClient M.keys


listContracts
:: Monoid a
=> query delimiter Void results
Expand Down Expand Up @@ -77,26 +67,6 @@ listContracts query run extract =
}


followContract :: ContractId -> Client (Either String Bool)
followContract = followCommand FollowContract


unfollowContract :: ContractId -> Client (Either String Bool)
unfollowContract = followCommand StopFollowingContract


followCommand
:: Show e
=> (ContractId -> HistoryCommand Void e Bool)
-> ContractId
-> Client (Either String Bool)
followCommand command =
fmap (first show)
. runJobClient runHistoryCommandClient
. liftCommand
. command


getContract
:: forall v
. IsMarloweVersion v
Expand Down
4 changes: 0 additions & 4 deletions marlowe-apps/src/Language/Marlowe/Runtime/App/Run.hs
Expand Up @@ -100,17 +100,13 @@ runClientWithConfig
runClientWithConfig Config{..} client = do
chainSeekCommandAddr <- resolve chainSeekHost chainSeekCommandPort
chainSeekSyncAddr <- resolve chainSeekHost chainSeekSyncPort
historyJobAddr <- resolve historyHost historyCommandPort
historyQueryAddr <- resolve historyHost historyQueryPort
historySyncAddr <- resolve historyHost historySyncPort
discoveryQueryAddr <- resolve discoveryHost discoveryQueryPort
discoverySyncAddr <- resolve discoveryHost discoverySyncPort
txJobAddr <- resolve txHost txCommandPort
runReaderT (runClient client) Services
{ runChainSeekCommandClient = runClientPeerOverSocket chainSeekCommandAddr codecJob jobClientPeer
, runChainSeekSyncClient = runClientPeerOverSocket chainSeekSyncAddr codecChainSeek (chainSeekClientPeer Genesis)
, runHistoryCommandClient = runClientPeerOverSocket historyJobAddr codecJob jobClientPeer
, runHistoryQueryClient = runClientPeerOverSocket historyQueryAddr codecQuery queryClientPeer
, runHistorySyncClient = runClientPeerOverSocket historySyncAddr codecMarloweSync marloweSyncClientPeer
, runTxCommandClient = runClientPeerOverSocket txJobAddr codecJob jobClientPeer
, runDiscoveryQueryClient = runClientPeerOverSocket discoveryQueryAddr codecQuery queryClientPeer
Expand Down
29 changes: 1 addition & 28 deletions marlowe-apps/src/Language/Marlowe/Runtime/App/Types.hs
Expand Up @@ -61,7 +61,7 @@ import Language.Marlowe.Runtime.Core.Api
)
import Language.Marlowe.Runtime.Discovery.Api (DiscoveryQuery)
import Language.Marlowe.Runtime.History.Api
(ContractStep(..), CreateStep(..), HistoryCommand, HistoryQuery, RedeemStep(RedeemStep, datum, redeemingTx, utxo))
(ContractStep(..), CreateStep(..), RedeemStep(RedeemStep, datum, redeemingTx, utxo))
import Language.Marlowe.Runtime.Transaction.Api (MarloweTxCommand)
import Network.Protocol.Job.Client (JobClient)
import Network.Protocol.Query.Client (QueryClient)
Expand Down Expand Up @@ -140,8 +140,6 @@ data Services m =
Services
{ runChainSeekCommandClient :: RunClient m (JobClient ChainSyncCommand)
, runChainSeekSyncClient :: RunClient m RuntimeChainSeekClient
, runHistoryCommandClient :: RunClient m (JobClient HistoryCommand)
, runHistoryQueryClient :: RunClient m (QueryClient HistoryQuery)
, runHistorySyncClient :: RunClient m MarloweSyncClient
, runDiscoveryQueryClient :: RunClient m (QueryClient DiscoveryQuery)
, runDiscoverySyncClient :: RunClient m MarloweHeaderSyncClient
Expand All @@ -160,13 +158,6 @@ type RunClient m client = forall a. client m a -> m a

data MarloweRequest v =
List
| Followed
| Follow
{ reqContractId :: ContractId
}
| Unfollow
{ reqContractId :: ContractId
}
| Get
{ reqContractId :: ContractId
}
Expand Down Expand Up @@ -218,13 +209,6 @@ instance A.FromJSON (MarloweRequest 'V1) where
(o A..: "request" :: A.Parser String)
>>= \case
"list" -> pure List
"followed" -> pure Followed
"follow" -> do
reqContractId <- fromString <$> o A..: "contractId"
pure Follow{..}
"unfollow" -> do
reqContractId <- fromString <$> o A..: "contractId"
pure Unfollow{..}
"get" -> do
reqContractId <- fromString <$> o A..: "contractId"
pure Get{..}
Expand Down Expand Up @@ -270,17 +254,6 @@ instance A.FromJSON (MarloweRequest 'V1) where

instance A.ToJSON (MarloweRequest 'V1) where
toJSON List = A.object ["request" A..= ("list" :: String)]
toJSON Followed = A.object ["request" A..= ("followed" :: String)]
toJSON Follow{..} =
A.object
[ "request" A..= ("follow" :: String)
, "contractId" A..= renderContractId reqContractId
]
toJSON Unfollow{..} =
A.object
[ "request" A..= ("unfollow" :: String)
, "contractId" A..= renderContractId reqContractId
]
toJSON Get{..} =
A.object
[ "request" A..= ("get" :: String)
Expand Down

0 comments on commit be19e6e

Please sign in to comment.