diff --git a/Makefile b/Makefile index 21ab921e..d26aab2b 100644 --- a/Makefile +++ b/Makefile @@ -17,10 +17,10 @@ usage: @echo "Available commands:" @echo " hoogle -- Start local hoogle" @echo " build -- Run cabal v2-build" - @echo " watch -- Track files: mlabs-pab.cabal, src/* and run 'make build' on change" + @echo " watch -- Track files: bot-plutus-interface.cabal, src/* and run 'make build' on change" @echo " test -- Run cabal v2-test" @echo " accept_pirs -- Accept new PIR changes" - @echo " ghci -- Run cabal v2-repl mlabs-pab" + @echo " ghci -- Run cabal v2-repl bot-plutus-interface" @echo " format -- Apply source code formatting with fourmolu" @echo " format_check -- Check source code formatting without making changes" @echo " nixfmt -- Apply nix formatting with nixfmt" @@ -48,7 +48,7 @@ build: requires_nix_shell cabal v2-build $(GHC_FLAGS) watch: requires_nix_shell - while sleep 1; do find src mlabs-pab.cabal | entr -cd make build; done + while sleep 1; do find src bot-plutus-interface.cabal | entr -cd make build; done test: requires_nix_shell cabal v2-test @@ -57,7 +57,7 @@ accept_pirs: requires_nix_shell stack build --test $(STACK_FLAGS) $(GHC_FLAGS) --ta '-p MarketAction --accept' ghci: requires_nix_shell - cabal v2-repl $(GHC_FLAGS) mlabs-pab + cabal v2-repl $(GHC_FLAGS) bot-plutus-interface # Source dirs to run fourmolu on FORMAT_SOURCES := $(shell git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.hs' ) @@ -113,7 +113,7 @@ update_plutus: ################################################################################ # Geth -build_path = dist-newstyle/build/x86_64-linux/ghc-8.10.4.20210212/mlabs-pab-0.1 +build_path = dist-newstyle/build/x86_64-linux/ghc-8.10.4.20210212/bot-plutus-interface-0.1 clear_build: @[ ! -e $(build_path) ] || rm -rf $(build_path) diff --git a/README.md b/README.md index 980c1495..0ee317a7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MLabPAB (Plutus Fake PAB) +# Bot Plutus Interface (formerly MLabsPAB or Plutus Fake PAB) This is a custom implementation of the PAB as the official one is not ready yet. This PAB is not feature complete, and not fully tested with all use cases, so please use it with care! @@ -78,7 +78,7 @@ main = do , -- Protocol params file location relative to the cardano-cli working directory (needed for the cli) pcProtocolParamsFile = "./protocol.json" } - MLabsPAB.runPAB @MyContracts pabConf + BotPlutusInterface.runPAB @MyContracts pabConf ``` To run the fake PAB, you need to prepare a few more things: @@ -102,16 +102,16 @@ cardano-cli address key-hash --verification-key-file VERIFICATION_KEY.vkey The fake PAB consists of the following modules: -- **MLabsPAB** main entry point -- **MLabsPAB.Server** Servant server, handling http endpoint calls and websockets -- **MLabsPAB.Contract** handling contract effects by creating the necessary files and calling cardano-cli commands (a few effects are mocked) -- **MLabsPAB.PreBalance** doing some preparations so the cli can process the rest (non-ada asset balancing, addig tx inputs, adding minimum lovelaces, add signatories) -- **MLabsPAB.CardanoCLI** wrappers for cardano-cli commands +- **BotPlutusInterface** main entry point +- **BotPlutusInterface.Server** Servant server, handling http endpoint calls and websockets +- **BotPlutusInterface.Contract** handling contract effects by creating the necessary files and calling cardano-cli commands (a few effects are mocked) +- **BotPlutusInterface.PreBalance** doing some preparations so the cli can process the rest (non-ada asset balancing, addig tx inputs, adding minimum lovelaces, add signatories) +- **BotPlutusInterface.CardanoCLI** wrappers for cardano-cli commands - For development purposes, I created an ssh wrapper, so I can call relay these commands through an ssh connection. This is not nice, unsafe, and pretty slow, so I'm hoping to get rid of this pretty soon. -- **MLabsPAB.UtxoParser** parse the output of the `cardano-cli query utxo` command -- **MLabsPAB.Files** functions for handling script, datum and redeemer files -- **MLabsPAB.Types** configuration for the fake pab -- **MLabsPAB.PreBalance** prepare a transaction before sending to the cli for balancing. This includes: +- **BotPlutusInterface.UtxoParser** parse the output of the `cardano-cli query utxo` command +- **BotPlutusInterface.Files** functions for handling script, datum and redeemer files +- **BotPlutusInterface.Types** configuration for the fake pab +- **BotPlutusInterface.PreBalance** prepare a transaction before sending to the cli for balancing. This includes: - adding tx inputs to cover fees and outputs - adding collaterals, - modifying tx outs to contain the minimum amount of lovelaces diff --git a/mlabs-pab.cabal b/bot-plutus-interface.cabal similarity index 82% rename from mlabs-pab.cabal rename to bot-plutus-interface.cabal index 203de461..58baa101 100644 --- a/mlabs-pab.cabal +++ b/bot-plutus-interface.cabal @@ -1,12 +1,12 @@ cabal-version: 3.0 -name: mlabs-pab +name: bot-plutus-interface version: 0.1.0.0 synopsis: Unofficial PAB implementation description: Unofficial PAB imlementation, using the cardano-cli in the background to submit transactions -homepage: https://github.com/mlabs-haskell/mlabs-pab -bug-reports: https://github.com/mlabs-haskell/mlabs-pab +homepage: https://github.com/mlabs-haskell/bot-plutus-interface +bug-reports: https://github.com/mlabs-haskell/bot-plutus-interface license: license-file: author: MLabs @@ -18,7 +18,7 @@ extra-source-files: README.md source-repository head type: git - location: https://github.com/mlabs-haskell/mlabs-pab + location: https://github.com/mlabs-haskell/bot-plutus-interface -- Common sections @@ -75,17 +75,17 @@ common common-lang library import: common-lang exposed-modules: - MLabsPAB - MLabsPAB.CardanoCLI - MLabsPAB.ChainIndex - MLabsPAB.Contract - MLabsPAB.Effects - MLabsPAB.Files - MLabsPAB.PreBalance - MLabsPAB.Types - MLabsPAB.UtxoParser + BotPlutusInterface + BotPlutusInterface.CardanoCLI + BotPlutusInterface.ChainIndex + BotPlutusInterface.Contract + BotPlutusInterface.Effects + BotPlutusInterface.Files + BotPlutusInterface.PreBalance + BotPlutusInterface.Types + BotPlutusInterface.UtxoParser - other-modules: MLabsPAB.Server + other-modules: BotPlutusInterface.Server build-depends: , aeson ^>=1.5.0.0 , attoparsec >=0.13.2.2 @@ -135,15 +135,15 @@ library hs-source-dirs: src -test-suite mlabs-pab-test +test-suite bot-plutus-interface-test import: common-lang type: exitcode-stdio-1.0 main-is: Spec.hs ghc-options: -fplugin-opt PlutusTx.Plugin:defer-errors other-modules: - Spec.MLabsPAB.Contract - Spec.MLabsPAB.PreBalance - Spec.MLabsPAB.UtxoParser + Spec.BotPlutusInterface.Contract + Spec.BotPlutusInterface.PreBalance + Spec.BotPlutusInterface.UtxoParser Spec.MockContract build-depends: @@ -151,6 +151,7 @@ test-suite mlabs-pab-test , attoparsec , base , base-compat + , bot-plutus-interface , bytestring ^>=0.10.12.0 , cardano-api , cardano-crypto-class @@ -163,7 +164,6 @@ test-suite mlabs-pab-test , freer-simple , generic-arbitrary , lens - , mlabs-pab , neat-interpolation , plutus-chain-index , plutus-chain-index-core diff --git a/examples/plutus-game/app/Main.hs b/examples/plutus-game/app/Main.hs index d78fb336..074420bd 100644 --- a/examples/plutus-game/app/Main.hs +++ b/examples/plutus-game/app/Main.hs @@ -2,6 +2,15 @@ module Main (main) where +import BotPlutusInterface qualified +import BotPlutusInterface.Types ( + CLILocation (Local), + HasDefinitions (..), + LogLevel (Debug), + PABConfig (..), + SomeBuiltin (..), + endpointsToSchemas, + ) import Cardano.Api (NetworkId (Testnet), NetworkMagic (..)) import Cardano.PlutusExample.Game ( GameSchema, @@ -14,15 +23,6 @@ import Data.Aeson qualified as JSON import Data.Aeson.TH (defaultOptions, deriveJSON) import Data.ByteString.Lazy qualified as LazyByteString import Data.Maybe (fromMaybe) -import MLabsPAB qualified -import MLabsPAB.Types ( - CLILocation (Local), - HasDefinitions (..), - LogLevel (Debug), - PABConfig (..), - SomeBuiltin (..), - endpointsToSchemas, - ) import Playground.Types (FunctionSchema) import Schema (FormSchema) import Servant.Client.Core (BaseUrl (BaseUrl), Scheme (Http)) @@ -65,4 +65,4 @@ main = do , pcLogLevel = Debug , pcProtocolParamsFile = "./protocol.json" } - MLabsPAB.runPAB @GameContracts pabConf + BotPlutusInterface.runPAB @GameContracts pabConf diff --git a/examples/plutus-game/plutus-game.cabal b/examples/plutus-game/plutus-game.cabal index 05620afb..a04e4f52 100644 --- a/examples/plutus-game/plutus-game.cabal +++ b/examples/plutus-game/plutus-game.cabal @@ -3,8 +3,8 @@ name: plutus-game version: 0.1.0.0 synopsis: Game example description: Game example running on the fake pab -homepage: https://github.com/mlabs-haskell/mlabs-pab -bug-reports: https://github.com/mlabs-haskell/mlabs-pab +homepage: https://github.com/mlabs-haskell/bot-plutus-interface +bug-reports: https://github.com/mlabs-haskell/bot-plutus-interface license: license-file: author: MLabs @@ -16,7 +16,7 @@ extra-source-files: README.md source-repository head type: git - location: https://github.com/mlabs-haskell/mlabs-pab + location: https://github.com/mlabs-haskell/bot-plutus-interface -- Common sections @@ -125,10 +125,10 @@ library executable plutus-game-pab import: common-lang build-depends: - , aeson ^>=1.5.0.0 + , aeson ^>=1.5.0.0 + , bot-plutus-interface , bytestring , cardano-api - , mlabs-pab , playground-common , plutus-game , plutus-ledger diff --git a/examples/plutus-nft/app/Main.hs b/examples/plutus-nft/app/Main.hs index 8c6a88ee..783a5383 100644 --- a/examples/plutus-nft/app/Main.hs +++ b/examples/plutus-nft/app/Main.hs @@ -3,6 +3,15 @@ module Main (main) where +import BotPlutusInterface qualified +import BotPlutusInterface.Types ( + CLILocation (Local), + HasDefinitions (..), + LogLevel (Debug), + PABConfig (..), + SomeBuiltin (..), + endpointsToSchemas, + ) import Cardano.Api (NetworkId (Testnet), NetworkMagic (..)) import Cardano.PlutusExample.NFT ( NFTSchema, @@ -13,15 +22,6 @@ import Data.Aeson.TH (defaultOptions, deriveJSON) import Data.ByteString.Lazy qualified as LazyByteString import Data.Maybe (fromMaybe) import Ledger.Value (TokenName) -import MLabsPAB qualified -import MLabsPAB.Types ( - CLILocation (Local), - HasDefinitions (..), - LogLevel (Debug), - PABConfig (..), - SomeBuiltin (..), - endpointsToSchemas, - ) import Playground.Types (FunctionSchema) import Schema (FormSchema) import Servant.Client.Core (BaseUrl (BaseUrl), Scheme (Http)) @@ -65,4 +65,4 @@ main = do , pcLogLevel = Debug , pcProtocolParamsFile = "./protocol.json" } - MLabsPAB.runPAB @MintNFTContracts pabConf + BotPlutusInterface.runPAB @MintNFTContracts pabConf diff --git a/examples/plutus-nft/plutus-nft.cabal b/examples/plutus-nft/plutus-nft.cabal index 82b94a6a..e0354525 100644 --- a/examples/plutus-nft/plutus-nft.cabal +++ b/examples/plutus-nft/plutus-nft.cabal @@ -3,8 +3,8 @@ name: plutus-nft version: 0.1.0.0 synopsis: NFT example description: NFT example running on the fake pab -homepage: https://github.com/mlabs-haskell/mlabs-pab -bug-reports: https://github.com/mlabs-haskell/mlabs-pab +homepage: https://github.com/mlabs-haskell/bot-plutus-interface +bug-reports: https://github.com/mlabs-haskell/bot-plutus-interface license: license-file: author: MLabs @@ -16,7 +16,7 @@ extra-source-files: README.md source-repository head type: git - location: https://github.com/mlabs-haskell/mlabs-pab + location: https://github.com/mlabs-haskell/bot-plutus-interface -- Common sections @@ -125,10 +125,10 @@ library executable plutus-nft-pab import: common-lang build-depends: - , aeson ^>=1.5.0.0 + , aeson ^>=1.5.0.0 + , bot-plutus-interface , bytestring , cardano-api - , mlabs-pab , playground-common , plutus-ledger , plutus-nft diff --git a/flake.nix b/flake.nix index 5297a526..19c028ca 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "mlabs-pab"; + description = "bot-plutus-interface"; inputs.haskell-nix.url = "github:input-output-hk/haskell.nix"; inputs.nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; diff --git a/hie.yaml b/hie.yaml index e264486a..95862748 100644 --- a/hie.yaml +++ b/hie.yaml @@ -1,10 +1,10 @@ cradle: cabal: - path: "./src" - component: "lib:mlabs-pab" + component: "lib:bot-plutus-interface" - path: "./test" - component: "test:mlabs-pab-test" + component: "test:bot-plutus-interface-test" - path: "./examples/plutus-nft/src" component: "lib:plutus-nft" diff --git a/src/MLabsPAB.hs b/src/BotPlutusInterface.hs similarity index 67% rename from src/MLabsPAB.hs rename to src/BotPlutusInterface.hs index b86babdd..076c6723 100644 --- a/src/MLabsPAB.hs +++ b/src/BotPlutusInterface.hs @@ -1,18 +1,18 @@ {-# LANGUAGE AllowAmbiguousTypes #-} -module MLabsPAB (runPAB) where +module BotPlutusInterface (runPAB) where +import BotPlutusInterface.Server qualified as Server +import BotPlutusInterface.Types (PABConfig (..)) import Data.Aeson (FromJSON) import Data.Kind (Type) -import MLabsPAB.Server qualified as Server -import MLabsPAB.Types (PABConfig (..)) import Network.Wai.Handler.Warp (run) import Plutus.PAB.Effects.Contract.Builtin (HasDefinitions) import Prelude runPAB :: forall (t :: Type). (HasDefinitions t, FromJSON t) => PABConfig -> IO () runPAB pabConf = do - putStrLn "Starting MLabsPAB server" + putStrLn "Starting BotPlutusInterface server" state <- Server.initState run pabConf.pcPort (Server.app @t pabConf state) diff --git a/src/MLabsPAB/CardanoCLI.hs b/src/BotPlutusInterface/CardanoCLI.hs similarity index 98% rename from src/MLabsPAB/CardanoCLI.hs rename to src/BotPlutusInterface/CardanoCLI.hs index 6f697269..7bc879dd 100644 --- a/src/MLabsPAB/CardanoCLI.hs +++ b/src/BotPlutusInterface/CardanoCLI.hs @@ -1,7 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE NamedFieldPuns #-} -module MLabsPAB.CardanoCLI ( +module BotPlutusInterface.CardanoCLI ( BuildMode (..), submitTx, calculateMinUtxo, @@ -15,6 +15,17 @@ module MLabsPAB.CardanoCLI ( utxosAt, ) where +import BotPlutusInterface.Effects (PABEffect, ShellArgs (..), callCommand, uploadDir) +import BotPlutusInterface.Files ( + datumJsonFilePath, + policyScriptFilePath, + redeemerJsonFilePath, + signingKeyFilePath, + txFilePath, + validatorScriptFilePath, + ) +import BotPlutusInterface.Types (PABConfig) +import BotPlutusInterface.UtxoParser qualified as UtxoParser import Cardano.Api.Shelley (NetworkId (Mainnet, Testnet), NetworkMagic (..), serialiseAddress) import Codec.Serialise qualified as Codec import Control.Monad.Freer (Eff, Member) @@ -54,17 +65,6 @@ import Ledger.Tx ( import Ledger.TxId (TxId (..)) import Ledger.Value (Value) import Ledger.Value qualified as Value -import MLabsPAB.Effects (PABEffect, ShellArgs (..), callCommand, uploadDir) -import MLabsPAB.Files ( - datumJsonFilePath, - policyScriptFilePath, - redeemerJsonFilePath, - signingKeyFilePath, - txFilePath, - validatorScriptFilePath, - ) -import MLabsPAB.Types (PABConfig) -import MLabsPAB.UtxoParser qualified as UtxoParser import Plutus.Contract.CardanoAPI (toCardanoAddress) import Plutus.V1.Ledger.Api ( BuiltinData, diff --git a/src/MLabsPAB/ChainIndex.hs b/src/BotPlutusInterface/ChainIndex.hs similarity index 97% rename from src/MLabsPAB/ChainIndex.hs rename to src/BotPlutusInterface/ChainIndex.hs index a7a9e488..1904bcb0 100644 --- a/src/MLabsPAB/ChainIndex.hs +++ b/src/BotPlutusInterface/ChainIndex.hs @@ -1,9 +1,9 @@ {-# LANGUAGE NamedFieldPuns #-} -module MLabsPAB.ChainIndex (handleChainIndexReq) where +module BotPlutusInterface.ChainIndex (handleChainIndexReq) where +import BotPlutusInterface.Types (PABConfig) import Data.Kind (Type) -import MLabsPAB.Types (PABConfig) import Network.HTTP.Client (defaultManagerSettings, newManager) import Network.HTTP.Types (Status (statusCode)) import Plutus.ChainIndex.Api ( diff --git a/src/MLabsPAB/Contract.hs b/src/BotPlutusInterface/Contract.hs similarity index 95% rename from src/MLabsPAB/Contract.hs rename to src/BotPlutusInterface/Contract.hs index 5972bcdb..58e1430a 100644 --- a/src/MLabsPAB/Contract.hs +++ b/src/BotPlutusInterface/Contract.hs @@ -1,8 +1,20 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE RankNTypes #-} -module MLabsPAB.Contract (runContract, handleContract) where +module BotPlutusInterface.Contract (runContract, handleContract) where +import BotPlutusInterface.CardanoCLI qualified as CardanoCLI +import BotPlutusInterface.Effects ( + PABEffect, + createDirectoryIfMissing, + handlePABEffect, + logToContract, + printLog, + queryChainIndex, + ) +import BotPlutusInterface.Files qualified as Files +import BotPlutusInterface.PreBalance qualified as PreBalance +import BotPlutusInterface.Types (ContractEnvironment (..), LogLevel (Debug)) import Control.Lens ((^.)) import Control.Monad.Freer (Eff, Member, interpret, reinterpret, runM, subsume, type (~>)) import Control.Monad.Freer.Error (runError) @@ -18,18 +30,6 @@ import Ledger.Address (PaymentPubKeyHash (PaymentPubKeyHash)) import Ledger.Constraints.OffChain (UnbalancedTx (..)) import Ledger.Tx (CardanoTx) import Ledger.Tx qualified as Tx -import MLabsPAB.CardanoCLI qualified as CardanoCLI -import MLabsPAB.Effects ( - PABEffect, - createDirectoryIfMissing, - handlePABEffect, - logToContract, - printLog, - queryChainIndex, - ) -import MLabsPAB.Files qualified as Files -import MLabsPAB.PreBalance qualified as PreBalance -import MLabsPAB.Types (ContractEnvironment (..), LogLevel (Debug)) import Plutus.ChainIndex.Types (RollbackState (Committed), TxValidity (..)) import Plutus.Contract.Checkpoint (Checkpoint (..)) import Plutus.Contract.Effects ( diff --git a/src/MLabsPAB/Effects.hs b/src/BotPlutusInterface/Effects.hs similarity index 98% rename from src/MLabsPAB/Effects.hs rename to src/BotPlutusInterface/Effects.hs index 152c80b2..ed48c5a9 100644 --- a/src/MLabsPAB/Effects.hs +++ b/src/BotPlutusInterface/Effects.hs @@ -2,7 +2,7 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} -module MLabsPAB.Effects ( +module BotPlutusInterface.Effects ( PABEffect (..), ShellArgs (..), handlePABEffect, @@ -20,6 +20,13 @@ module MLabsPAB.Effects ( callCommand, ) where +import BotPlutusInterface.ChainIndex (handleChainIndexReq) +import BotPlutusInterface.Types ( + CLILocation (..), + ContractEnvironment, + ContractState (ContractState), + LogLevel (..), + ) import Cardano.Api (AsType, FileError, HasTextEnvelope, TextEnvelopeDescr, TextEnvelopeError) import Cardano.Api qualified import Control.Concurrent qualified as Concurrent @@ -31,13 +38,6 @@ import Data.Aeson qualified as JSON import Data.Kind (Type) import Data.Text (Text) import Data.Text qualified as Text -import MLabsPAB.ChainIndex (handleChainIndexReq) -import MLabsPAB.Types ( - CLILocation (..), - ContractEnvironment, - ContractState (ContractState), - LogLevel (..), - ) import Plutus.Contract.Effects (ChainIndexQuery, ChainIndexResponse) import Plutus.PAB.Core.ContractInstance.STM (Activity) import System.Directory qualified as Directory diff --git a/src/MLabsPAB/Files.hs b/src/BotPlutusInterface/Files.hs similarity index 98% rename from src/MLabsPAB/Files.hs rename to src/BotPlutusInterface/Files.hs index 29a93852..ebbdadda 100644 --- a/src/MLabsPAB/Files.hs +++ b/src/BotPlutusInterface/Files.hs @@ -1,6 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} -module MLabsPAB.Files ( +module BotPlutusInterface.Files ( policyScriptFilePath, validatorScriptFilePath, readPrivateKeys, @@ -17,6 +17,15 @@ module MLabsPAB.Files ( writeDatumJsonFile, ) where +import BotPlutusInterface.Effects ( + PABEffect, + createDirectoryIfMissing, + listDirectory, + readFileTextEnvelope, + writeFileJSON, + writeFileTextEnvelope, + ) +import BotPlutusInterface.Types (PABConfig) import Cardano.Api ( AsType (AsPaymentKey, AsSigningKey), FileError, @@ -54,15 +63,6 @@ import Ledger.Tx (Tx) import Ledger.Tx qualified as Tx import Ledger.TxId qualified as TxId import Ledger.Value qualified as Value -import MLabsPAB.Effects ( - PABEffect, - createDirectoryIfMissing, - listDirectory, - readFileTextEnvelope, - writeFileJSON, - writeFileTextEnvelope, - ) -import MLabsPAB.Types (PABConfig) import Plutus.V1.Ledger.Api ( CurrencySymbol, Datum (getDatum), diff --git a/src/MLabsPAB/PreBalance.hs b/src/BotPlutusInterface/PreBalance.hs similarity index 97% rename from src/MLabsPAB/PreBalance.hs rename to src/BotPlutusInterface/PreBalance.hs index 554dbba4..54de828d 100644 --- a/src/MLabsPAB/PreBalance.hs +++ b/src/BotPlutusInterface/PreBalance.hs @@ -1,10 +1,14 @@ {-# LANGUAGE AllowAmbiguousTypes #-} -module MLabsPAB.PreBalance ( +module BotPlutusInterface.PreBalance ( preBalanceTx, preBalanceTxIO, ) where +import BotPlutusInterface.CardanoCLI qualified as CardanoCLI +import BotPlutusInterface.Effects (PABEffect, createDirectoryIfMissing, printLog) +import BotPlutusInterface.Files qualified as Files +import BotPlutusInterface.Types (LogLevel (Debug), PABConfig) import Cardano.Api.Shelley (Lovelace (Lovelace), ProtocolParameters (protocolParamUTxOCostPerWord)) import Control.Monad (foldM, void, zipWithM) import Control.Monad.Freer (Eff, Member) @@ -36,10 +40,6 @@ import Ledger.Tx ( import Ledger.Tx qualified as Tx import Ledger.Value (Value (Value), getValue) import Ledger.Value qualified as Value -import MLabsPAB.CardanoCLI qualified as CardanoCLI -import MLabsPAB.Effects (PABEffect, createDirectoryIfMissing, printLog) -import MLabsPAB.Files qualified as Files -import MLabsPAB.Types (LogLevel (Debug), PABConfig) import Plutus.V1.Ledger.Api ( Credential (PubKeyCredential, ScriptCredential), CurrencySymbol (..), diff --git a/src/MLabsPAB/Server.hs b/src/BotPlutusInterface/Server.hs similarity index 98% rename from src/MLabsPAB/Server.hs rename to src/BotPlutusInterface/Server.hs index da2e6937..0f242ac5 100644 --- a/src/MLabsPAB/Server.hs +++ b/src/BotPlutusInterface/Server.hs @@ -1,7 +1,15 @@ {-# LANGUAGE AllowAmbiguousTypes #-} -module MLabsPAB.Server (app, initState) where +module BotPlutusInterface.Server (app, initState) where +import BotPlutusInterface.Contract (runContract) +import BotPlutusInterface.Types ( + AppState (AppState), + ContractEnvironment (..), + ContractState (ContractState, csActivity, csObservableState), + PABConfig, + SomeContractState (SomeContractState), + ) import Control.Concurrent (ThreadId, forkIO) import Control.Concurrent.STM (TVar, atomically, modifyTVar, newTVarIO, readTVar, readTVarIO, retry) import Control.Monad (forever, guard, unless, void) @@ -15,14 +23,6 @@ import Data.Maybe (catMaybes, fromMaybe) import Data.Proxy (Proxy (Proxy)) import Data.Row (Row) import Data.UUID.V4 qualified as UUID -import MLabsPAB.Contract (runContract) -import MLabsPAB.Types ( - AppState (AppState), - ContractEnvironment (..), - ContractState (ContractState, csActivity, csObservableState), - PABConfig, - SomeContractState (SomeContractState), - ) import Network.WebSockets ( Connection, PendingConnection, diff --git a/src/MLabsPAB/Types.hs b/src/BotPlutusInterface/Types.hs similarity index 98% rename from src/MLabsPAB/Types.hs rename to src/BotPlutusInterface/Types.hs index eb323bfa..ba4a970a 100644 --- a/src/MLabsPAB/Types.hs +++ b/src/BotPlutusInterface/Types.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RankNTypes #-} -module MLabsPAB.Types ( +module BotPlutusInterface.Types ( PABConfig (..), CLILocation (..), AppState (AppState), diff --git a/src/MLabsPAB/UtxoParser.hs b/src/BotPlutusInterface/UtxoParser.hs similarity index 98% rename from src/MLabsPAB/UtxoParser.hs rename to src/BotPlutusInterface/UtxoParser.hs index dde3e396..7d4fdcb8 100644 --- a/src/MLabsPAB/UtxoParser.hs +++ b/src/BotPlutusInterface/UtxoParser.hs @@ -1,4 +1,4 @@ -module MLabsPAB.UtxoParser ( +module BotPlutusInterface.UtxoParser ( chainIndexTxOutParser, feeParser, utxoParser, diff --git a/test/Spec.hs b/test/Spec.hs index 4a08b23a..866f076f 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,8 +1,8 @@ module Main (main) where -import Spec.MLabsPAB.Contract qualified -import Spec.MLabsPAB.PreBalance qualified -import Spec.MLabsPAB.UtxoParser qualified +import Spec.BotPlutusInterface.Contract qualified +import Spec.BotPlutusInterface.PreBalance qualified +import Spec.BotPlutusInterface.UtxoParser qualified import Test.Tasty (TestTree, defaultMain, testGroup) import Prelude @@ -17,8 +17,8 @@ main = defaultMain tests tests :: TestTree tests = testGroup - "MLabsPAB" - [ Spec.MLabsPAB.Contract.tests - , Spec.MLabsPAB.UtxoParser.tests - , Spec.MLabsPAB.PreBalance.tests + "BotPlutusInterface" + [ Spec.BotPlutusInterface.Contract.tests + , Spec.BotPlutusInterface.UtxoParser.tests + , Spec.BotPlutusInterface.PreBalance.tests ] diff --git a/test/Spec/MLabsPAB/Contract.hs b/test/Spec/BotPlutusInterface/Contract.hs similarity index 99% rename from test/Spec/MLabsPAB/Contract.hs rename to test/Spec/BotPlutusInterface/Contract.hs index 9d9c7992..d91cce5e 100644 --- a/test/Spec/MLabsPAB/Contract.hs +++ b/test/Spec/BotPlutusInterface/Contract.hs @@ -1,8 +1,9 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} -module Spec.MLabsPAB.Contract (tests) where +module Spec.BotPlutusInterface.Contract (tests) where +import BotPlutusInterface.CardanoCLI (unsafeSerialiseAddress) import Cardano.Api (NetworkId (Mainnet)) import Control.Lens (ix, (&), (.~), (^.), (^?)) import Data.Aeson (ToJSON) @@ -25,7 +26,6 @@ import Ledger.Tx (CardanoTx, TxOut (TxOut), TxOutRef (TxOutRef)) import Ledger.Tx qualified as Tx import Ledger.TxId qualified as TxId import Ledger.Value qualified as Value -import MLabsPAB.CardanoCLI (unsafeSerialiseAddress) import NeatInterpolation (text) import Plutus.Contract (Contract (..), Endpoint, submitTx, submitTxConstraintsWith, tell, utxosAt) import PlutusTx qualified @@ -57,7 +57,7 @@ import Prelude tests :: TestTree tests = testGroup - "MLabsPAB.Contracts" + "BotPlutusInterface.Contracts" [ testCase "Send ada to address" sendAda , testCase "Send ada to address+staking" sendAdaStaking , testCase "Support multiple signatories" multisigSupport diff --git a/test/Spec/MLabsPAB/PreBalance.hs b/test/Spec/BotPlutusInterface/PreBalance.hs similarity index 96% rename from test/Spec/MLabsPAB/PreBalance.hs rename to test/Spec/BotPlutusInterface/PreBalance.hs index b465749d..6cc9bb58 100644 --- a/test/Spec/MLabsPAB/PreBalance.hs +++ b/test/Spec/BotPlutusInterface/PreBalance.hs @@ -1,5 +1,6 @@ -module Spec.MLabsPAB.PreBalance (tests) where +module Spec.BotPlutusInterface.PreBalance (tests) where +import BotPlutusInterface.PreBalance qualified as PreBalance import Cardano.Api.Shelley (Lovelace (Lovelace), ProtocolParameters (protocolParamUTxOCostPerWord)) import Data.Default (def) import Data.Map qualified as Map @@ -12,7 +13,6 @@ import Ledger.CardanoWallet qualified as Wallet import Ledger.Crypto (PrivateKey, PubKeyHash) import Ledger.Tx (Tx (..), TxIn (..), TxInType (..), TxOut (..), TxOutRef (..)) import Ledger.Value qualified as Value -import MLabsPAB.PreBalance qualified as PreBalance import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (Assertion, testCase, (@?=)) import Prelude @@ -24,7 +24,7 @@ import Prelude tests :: TestTree tests = testGroup - "MLabsPAB.PreBalance" + "BotPlutusInterface.PreBalance" [ testCase "Add utxos to cover fees" addUtxosForFees , testCase "Add utxos to cover native tokens" addUtxosForNativeTokens , testCase "Add utxos to cover change min utxo" addUtxosForChange diff --git a/test/Spec/MLabsPAB/UtxoParser.hs b/test/Spec/BotPlutusInterface/UtxoParser.hs similarity index 97% rename from test/Spec/MLabsPAB/UtxoParser.hs rename to test/Spec/BotPlutusInterface/UtxoParser.hs index 4db802f7..5fcbc27f 100644 --- a/test/Spec/MLabsPAB/UtxoParser.hs +++ b/test/Spec/BotPlutusInterface/UtxoParser.hs @@ -2,8 +2,9 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} -module Spec.MLabsPAB.UtxoParser (tests) where +module Spec.BotPlutusInterface.UtxoParser (tests) where +import BotPlutusInterface.UtxoParser qualified as UtxoParser import Data.Attoparsec.Text (parseOnly) import Data.Text (Text) import Ledger qualified @@ -14,7 +15,6 @@ import Ledger.Tx ( TxOutRef (TxOutRef), ) import Ledger.Value qualified as Value -import MLabsPAB.UtxoParser qualified as UtxoParser import NeatInterpolation (text) import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (Assertion, testCase, (@?=)) @@ -30,7 +30,7 @@ pubKeyHashAddress pkh = Ledger.pubKeyHashAddress (Ledger.PaymentPubKeyHash pkh) tests :: TestTree tests = testGroup - "MLabsPAB.UtxoParser" + "BotPlutusInterface.UtxoParser" [ testCase "Without utxo" withoutUtxo , testCase "Single utxo, ada only" singleAdaOnly , testCase "Multiple utxos, ada only" multiAdaOnly diff --git a/test/Spec/MockContract.hs b/test/Spec/MockContract.hs index 67ee3397..2f6e22fa 100644 --- a/test/Spec/MockContract.hs +++ b/test/Spec/MockContract.hs @@ -38,6 +38,16 @@ module Spec.MockContract ( utxos, ) where +import BotPlutusInterface.CardanoCLI (unsafeSerialiseAddress) +import BotPlutusInterface.Contract (handleContract) +import BotPlutusInterface.Effects (PABEffect (..), ShellArgs (..)) +import BotPlutusInterface.Files qualified as Files +import BotPlutusInterface.Types ( + ContractEnvironment (..), + ContractState (ContractState, csActivity, csObservableState), + LogLevel (..), + PABConfig (..), + ) import Cardano.Api ( AsType, FileError (FileError, FileIOError), @@ -87,16 +97,6 @@ import Ledger.Tx (TxOut (TxOut), TxOutRef (TxOutRef)) import Ledger.Tx qualified as Tx import Ledger.TxId (TxId (TxId)) import Ledger.Value qualified as Value -import MLabsPAB.CardanoCLI (unsafeSerialiseAddress) -import MLabsPAB.Contract (handleContract) -import MLabsPAB.Effects (PABEffect (..), ShellArgs (..)) -import MLabsPAB.Files qualified as Files -import MLabsPAB.Types ( - ContractEnvironment (..), - ContractState (ContractState, csActivity, csObservableState), - LogLevel (..), - PABConfig (..), - ) import NeatInterpolation (text) import Plutus.ChainIndex.Api (UtxosResponse (..)) import Plutus.ChainIndex.Types (BlockId (..), Tip (..))