@@ -62,48 +62,72 @@ instance HasDefinitions MyContracts where
6262 MyContract. contract params
6363```
6464
65- 3 . Write your main entrypoint for the application, with the preferred configurations
65+ 3 . Write your main entrypoint for the application and the configuration file
6666
6767``` haskell
68- import BotPlutusInterface.Types (CLILocation (Local ), LogLevel (Debug ), PABConfig (.. ))
69- import Cardano.Api (NetworkId (Testnet ), NetworkMagic (.. ))
70- import Data.Aeson qualified as JSON
71- import Data.ByteString.Lazy qualified as LazyByteString
72- import Data.Default (def )
73- import Servant.Client.Core (BaseUrl (BaseUrl ), Scheme (Http ))
68+ import BotPlutusInterface qualified
69+ import BotPlutusInterface.Config qualified as BotPlutusInterface
70+ import Prelude
7471
7572main :: IO ()
7673main = do
77- protocolParams <- JSON. decode <$> LazyByteString. readFile " protocol.json"
78- let pabConf =
79- PABConfig
80- { -- Calling the cli locally or through an ssh connection
81- pcCliLocation = Local
82- , pcNetwork = Testnet (NetworkMagic 42 )
83- , pcChainIndexUrl = BaseUrl Http " localhost" 9083 " "
84- , pcPort = 9080
85- , pcProtocolParams = protocolParams
86- , pcTipPollingInterval = 10_000_000
87- , pcOwnPubKeyHash = " 0f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f97546"
88- , pcOwnStakePubKeyHash = Nothing
89- , -- Directory name of the script and data files
90- pcScriptFileDir = " ./scripts"
91- , -- Directory for the signing key file(s)
92- pcSigningKeyFileDir = " ./signing-keys"
93- , -- Directory where the encoded transaction files will be saved
94- pcTxFileDir = " ./txs"
95- , -- Dry run mode will build the tx, but skip the submit step
96- pcDryRun = False
97- , pcLogLevel = Debug
98- , -- Protocol params file location relative to the cardano-cli working directory (needed for the cli)
99- , pcProtocolParamsFile = " ./protocol.json"
100- , pcEnableTxEndpoint = True
101- -- Save some stats during contract run (only transactions execution budgets supported atm)
102- , pcCollectStats = False
103- }
74+ pabConf <-
75+ either error id
76+ <$> BotPlutusInterface. loadPABConfig " ./pabConfig.value"
10477 BotPlutusInterface. runPAB @ MyContracts pabConf
10578```
10679
80+ Configuration format (example: <examples/plutus-game/pabConfig.value>):
81+
82+ ``` console
83+ $ cabal repl --disable-optimisation --repl-options -Wwarn
84+ ...
85+ BotPlutusInterface> :m Prelude
86+ ...
87+ Prelude> :l BotPlutusInterface.Config
88+ ...
89+ Prelude BotPlutusInterface.Config> putStrLn docPABConfig
90+ Top-level configuration file fields:
91+ cliLocation: `local` or destination text
92+ calling the cli through ssh when set to destination (default:
93+ local)
94+ chainIndexUrl: url text
95+ (default: "http://localhost:9083")
96+ networkId: case insensitive `mainnet` atom or 32-bit unsigned integral number
97+ (default: 42)
98+ scriptFileDir: path text
99+ Directory name of the script and data files (default:
100+ "./result-scripts")
101+ signingKeyFileDir: path text
102+ Directory name of the signing key files (default: "./signing-keys")
103+ txFileDir: path text
104+ Directory name of the transaction files (default: "./txs")
105+ metadataDir: path text
106+ Directory name of metadata files (default: "/metadata")
107+ protocolParamsFile: filepath text
108+ Protocol params file location relative to the cardano-cli working
109+ directory (needed for the cli) in JSON format. (default:
110+ "./protocol.json")
111+ dryRun: `true` or `false`
112+ Dry run mode will build the tx, but skip the submit step (default:
113+ true)
114+ logLevel: `error` or `warn` or `notice` or `info` or `debug`
115+ (default: info)
116+ ownPubKeyHash: PubKeyHash text
117+ (default: "")
118+ ownStakePubKeyHash: case insensitive `nothing` atom or StakePubKeyHash text
119+ (default: nothing)
120+ tipPollingInterval: non-negative integral number
121+ (default: 10000000)
122+ port: port non-negative integral number
123+ (default: 9080)
124+ enableTxEndpoint: `true` or `false`
125+ (default: false)
126+ collectStats: `true` or `false`
127+ Save some stats during contract run (only transactions execution
128+ budgets supported atm) (default: false)
129+ ```
130+
107131To run the fake PAB, you need to prepare a few more things:
108132
1091334 . Save the protocol params file to the root folder of your project using the cardano-cli
@@ -127,6 +151,7 @@ The fake PAB consists of the following modules:
127151
128152- ** BotPlutusInterface** main entry point
129153- ** BotPlutusInterface.Server** Servant server, handling http endpoint calls and websockets
154+ - ** BotPlutusInterface.Config** load/save PAB configuration file
130155- ** BotPlutusInterface.Contract** handling contract effects by creating the necessary files and calling cardano-cli commands (a few effects are mocked)
131156- ** BotPlutusInterface.Balance** doing some preparations so the cli can process the rest (non-ada asset balancing, addig tx inputs, adding minimum lovelaces, add signatories)
132157- ** BotPlutusInterface.CardanoCLI** wrappers for cardano-cli commands
0 commit comments