@@ -9,6 +9,7 @@ module BotPlutusInterface.Server (
99) where
1010
1111import BotPlutusInterface.Contract (runContract )
12+ import BotPlutusInterface.Files (txFileName )
1213import BotPlutusInterface.Types (
1314 AppState (AppState ),
1415 ContractEnvironment (.. ),
@@ -59,7 +60,7 @@ import Servant.API (Capture, Get, JSON, Post, ReqBody, (:<|>) (..), (:>))
5960import Servant.API.WebSocket (WebSocketPending )
6061import Servant.Server (Application , Handler , Server , err404 , serve )
6162import System.Directory (canonicalizePath , doesFileExist , makeAbsolute )
62- import System.FilePath (replaceExtension , takeDirectory , (</>) )
63+ import System.FilePath (takeDirectory , (</>) )
6364import Wallet.Types (ContractInstanceId (.. ))
6465import Prelude
6566
@@ -83,8 +84,8 @@ type ActivateContractEndpoint a =
8384 :> Post '[JSON ] ContractInstanceId -- Start a new instance.
8485
8586type RawTxEndpoint =
86- " rawTx "
87- :> Capture " hash " Text
87+ " raw-tx "
88+ :> Capture " txId " Text
8889 :> Get '[JSON ] RawTx
8990
9091server :: HasDefinitions t => PABConfig -> AppState -> Server (API t )
@@ -234,15 +235,15 @@ handleContract pabConf state@(AppState st) contract = liftIO $ do
234235
235236-- | This handler will allow to retrieve raw transactions from the pcTxFileDir if pcEnableTxEndpoint is True
236237rawTxHandler :: PABConfig -> Text -> Handler RawTx
237- rawTxHandler config hash = do
238+ rawTxHandler config txId = do
238239 -- Check that endpoint is enabled
239240 assert config. pcEnableTxEndpoint
240241 -- Absolute path to pcTxFileDir that is specified in the config
241242 txFolderPath <- liftIO $ makeAbsolute (unpack config. pcTxFileDir)
242243
243244 -- Add/Set .raw extension on path
244245 let suppliedPath :: FilePath
245- suppliedPath = replaceExtension ( txFolderPath </> " tx- " <> unpack hash) " .raw"
246+ suppliedPath = txFolderPath </> unpack (txFileName txId " .raw" )
246247 -- Resolve path indirections
247248 path <- liftIO $ canonicalizePath suppliedPath
248249 -- ensure it does not try to escape txFolderPath
0 commit comments