Skip to content

Commit a1c2f06

Browse files
committed
[cli] Remove anti oracle config get as covered by anti facts config
1 parent 55c8ec1 commit a1c2f06

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

cli/src/Oracle/Config/Cli.hs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ import Control.Monad.IO.Class (MonadIO)
88
import Control.Monad.Trans.Class (lift)
99
import Core.Context (WithContext, askMpfs, askSubmit)
1010
import Core.Types.Basic (TokenId)
11-
import Core.Types.Fact (Fact (..), parseFacts)
1211
import Core.Types.Tx (WithTxHash (..))
1312
import Core.Types.Wallet (Wallet)
1413
import Data.Functor (void)
14+
import Facts (FactsSelection (..), factsCmd)
1515
import MPFS.API
1616
import Oracle.Config.Types
1717
import Submitting (Submission (..))
1818
import Text.JSON.Canonical
1919

2020
data ConfigCmd a where
21-
GetConfig :: TokenId -> ConfigCmd (Maybe Config)
2221
SetConfig :: TokenId -> Wallet -> Config -> ConfigCmd (WithTxHash ())
2322

2423
deriving instance Show (ConfigCmd a)
@@ -29,15 +28,11 @@ configCmd
2928
configCmd (SetConfig tokenId wallet config) = do
3029
mpfs <- askMpfs
3130
Submission submit <- ($ wallet) <$> askSubmit
32-
present <- configCmd (GetConfig tokenId)
31+
present <- lift $ factsCmd mpfs tokenId ConfigFact
3332
jkey <- toJSON ConfigKey
3433
jvalue <- toJSON config
3534
case present of
36-
Nothing -> do
37-
lift $ fmap void $ submit $ \address ->
38-
mpfsRequestInsert mpfs address tokenId
39-
$ RequestInsertBody{key = jkey, value = jvalue}
40-
Just oldConfig -> do
35+
[oldConfig] -> do
4136
oldValue <- toJSON oldConfig
4237
lift $ fmap void $ submit $ \address ->
4338
mpfsRequestUpdate mpfs address tokenId
@@ -46,12 +41,7 @@ configCmd (SetConfig tokenId wallet config) = do
4641
, newValue = jvalue
4742
, oldValue
4843
}
49-
configCmd (GetConfig tokenId) = do
50-
mpfs <- askMpfs
51-
facts :: [Fact ConfigKey Config] <-
52-
fmap parseFacts
53-
$ lift
54-
$ mpfsGetTokenFacts mpfs tokenId
55-
pure $ case facts of
56-
[Fact _ c] -> Just c
57-
_ -> Nothing
44+
_ -> do
45+
lift $ fmap void $ submit $ \address ->
46+
mpfsRequestInsert mpfs address tokenId
47+
$ RequestInsertBody{key = jkey, value = jvalue}

cli/src/Oracle/Config/Options.hs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ configOption = do
5252
Owner
5353
<$> strOption
5454
[ long "agent-pkh"
55-
, metavar "AGENT_PUBLIC_KEY_HASH"
55+
, metavar "PUBLIC_KEY_HASH"
5656
, help "Public key hash of the agent that will run the tests"
5757
, option
5858
]
@@ -79,10 +79,4 @@ configCommandParser =
7979
<*> walletOption
8080
<*> configOption
8181
)
82-
, command
83-
"get"
84-
"Get the oracle configuration"
85-
( fmap Box GetConfig
86-
<$> tokenIdOption
87-
)
8882
]

0 commit comments

Comments
 (0)