diff --git a/app/Main.hs b/app/Main.hs index 0b6a6f0..3faa6eb 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -205,11 +205,12 @@ main = do config <- load ["$(HOME)/Zenith/zenith.cfg"] args <- getArgs dbFilePath <- require config "dbFilePath" - {-nodeUser <- require config "nodeUser"-} - {-nodePwd <- require config "nodePwd"-} + nodeUser <- require config "nodeUser" + nodePwd <- require config "nodePwd" zebraPort <- require config "zebraPort" zebraHost <- require config "zebraHost" - let myConfig = Config dbFilePath zebraHost zebraPort + nodePort <- require config "nodePort" + let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort if not (null args) then do case head args diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index b10b7e0..fe04a21 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -827,7 +827,13 @@ appEvent (BT.AppEvent t) = do _ <- liftIO $ syncWallet - (Config (s ^. dbPath) (s ^. zebraHost) (s ^. zebraPort)) + (Config + (s ^. dbPath) + (s ^. zebraHost) + (s ^. zebraPort) + "user" + "pwd" + 8080) selWallet BT.modify $ set displayBox BlankDisplay BT.modify $ set barValue 0.0 diff --git a/src/Zenith/Types.hs b/src/Zenith/Types.hs index 9868618..89a7b29 100644 --- a/src/Zenith/Types.hs +++ b/src/Zenith/Types.hs @@ -92,12 +92,16 @@ data Config = Config { c_dbPath :: !T.Text , c_zebraHost :: !T.Text , c_zebraPort :: !Int + , c_zenithUser :: !BS.ByteString + , c_zenithPwd :: !BS.ByteString + , c_zenithPort :: !Int } deriving (Eq, Prelude.Show) -- ** Zenith methods data ZenithMethod = GetInfo | Test + | UnknownMethod deriving (Eq, Prelude.Show) instance FromJSON ZenithMethod where @@ -105,10 +109,11 @@ instance FromJSON ZenithMethod where withText "ZenithMethod" $ \case "getinfo" -> pure GetInfo "test" -> pure Test - _ -> fail "Invalid method" + _ -> pure UnknownMethod data ZenithParams - = GetInfoParams + = BlankParams + | BadParams | TestParams !T.Text deriving (Eq, Prelude.Show) @@ -127,7 +132,12 @@ instance FromJSON RpcCall where i <- obj .: "id" m <- obj .: "method" case m of - GetInfo -> pure $ RpcCall v i GetInfo GetInfoParams + UnknownMethod -> pure $ RpcCall v i UnknownMethod BlankParams + GetInfo -> do + p <- obj .: "params" + if null (p :: [Value]) + then pure $ RpcCall v i GetInfo BlankParams + else pure $ RpcCall v i GetInfo BadParams Test -> do p <- obj .: "params" pure $ RpcCall v i Test (TestParams $ head p) diff --git a/zenith.cabal b/zenith.cabal index a849d74..57dcb43 100644 --- a/zenith.cabal +++ b/zenith.cabal @@ -47,6 +47,7 @@ library , base64-bytestring , brick , bytestring + , configurator , data-default , directory , filepath @@ -132,6 +133,7 @@ executable zenithserver app build-depends: base >=4.12 && <5 + , configurator , wai-extra , warp , servant-server