diff --git a/src/lib/Wst/Cli.hs b/src/lib/Wst/Cli.hs index 608342f..fe7ebde 100644 --- a/src/lib/Wst/Cli.hs +++ b/src/lib/Wst/Cli.hs @@ -2,12 +2,13 @@ {-# LANGUAGE OverloadedStrings #-} module Wst.Cli(runMain) where -import Blammo.Logging.Simple (Message ((:#)), MonadLogger, MonadLoggerIO, - WithLogger (..), logError, logInfo, logWarn, - runLoggerLoggingT) +import Blammo.Logging.Simple (MonadLogger, MonadLoggerIO, WithLogger (..), + logError, logInfo, runLoggerLoggingT) import Control.Monad.Except (ExceptT, MonadError, runExceptT) import Control.Monad.IO.Class (MonadIO (..)) -import Control.Monad.Reader (MonadReader, ReaderT, asks, runReaderT) +import Control.Monad.Reader (MonadReader, ReaderT, runReaderT) +import Convex.Wallet.Operator (OperatorConfigSigning) +import Convex.Wallet.Operator qualified as Operator import Data.String (IsString (..)) import Options.Applicative (customExecParser, disambiguate, helper, idm, info, prefs, showHelpOnEmpty, showHelpOnError) @@ -26,8 +27,12 @@ runCommand :: Command -> IO () runCommand com = do env <- RuntimeEnv.loadEnv result <- runWstApp env $ case com of - Deploy -> logInfo "Deploy" - Manage txIn com -> logInfo "Manage" + Deploy config -> deploy config + Manage _txIn _com -> + -- TODO: + -- * Implement status check (call the query endpoints and print out a summary of the results) + -- * Start the server + logInfo "Manage" case result of Left err -> runLoggerLoggingT env $ logError (fromString $ show err) Right a -> pure a @@ -43,3 +48,14 @@ newtype WstApp a = WstApp { unWstApp :: ReaderT RuntimeEnv (ExceptT AppError IO) runWstApp :: RuntimeEnv -> WstApp a -> IO (Either AppError a) runWstApp env WstApp{unWstApp} = runExceptT (runReaderT unWstApp env) + +deploy :: (MonadLogger m, MonadIO m) => OperatorConfigSigning -> m () +deploy config = do + logInfo "Loading operator files" + _operator <- liftIO (Operator.loadOperatorFiles config) + -- TODO: + -- Use blockfrost backend to run Wst.Offchain.Endpoints.Deployment with the operator's funds + -- Then use operator key to sign + -- Then submit transaction to blockfrost + -- Convex.Blockfrost.runBLockfrostT for the monadblockchain / monadutxoquery effects + pure () diff --git a/src/lib/Wst/Cli/Command.hs b/src/lib/Wst/Cli/Command.hs index 811862b..e1a0ed7 100644 --- a/src/lib/Wst/Cli/Command.hs +++ b/src/lib/Wst/Cli/Command.hs @@ -8,6 +8,8 @@ module Wst.Cli.Command( import Cardano.Api (TxIn (..), TxIx (..)) import Control.Monad (when) +import Convex.Wallet.Operator (OperatorConfigSigning, + parseOperatorConfigSigning) import Data.String (IsString (..)) import Options.Applicative (CommandFields, Mod, Parser, ReadM, argument, command, eitherReader, fullDesc, help, info, long, @@ -15,7 +17,6 @@ import Options.Applicative (CommandFields, Mod, Parser, ReadM, argument, strOption, subparser, (<|>)) import Text.Read (readMaybe) - parseCommand :: Parser Command parseCommand = subparser $ @@ -25,7 +26,7 @@ parseCommand = ] data Command = - Deploy + Deploy OperatorConfigSigning | Manage TxIn ManageCommand deriving Show @@ -38,7 +39,7 @@ data ManageCommand = parseDeploy :: Mod CommandFields Command parseDeploy = command "deploy" $ - info (pure Deploy) (fullDesc <> progDesc "Deploy the directory and global params") + info (Deploy <$> parseOperatorConfigSigning) (fullDesc <> progDesc "Deploy the directory and global params") parseManage :: Mod CommandFields Command parseManage =