Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Fix the problem with pab-nami-demo psapigenerator #235
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgenii Akentev committed Jan 12, 2022
1 parent 7f53f18 commit 369f89d
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 5 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ rec {
inherit (pkgs.callPackage ./plutus-pab-executables/demo/pab-nami/client {
inherit pkgs haskell webCommon;
inherit (plutus-apps.lib) buildPursPackage buildNodeModules filterNpm gitignore-nix;
}) client pab-setup-invoker pab-nami-demo-invoker generate-purescript generated-purescript start-backend;
}) client pab-setup-invoker pab-nami-demo-invoker pab-nami-demo-generator generate-purescript generated-purescript start-backend;
};

plutus-use-cases = pkgs.recurseIntoAttrs (pkgs.callPackage ./plutus-use-cases {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nix/pkgs/haskell/materialized-darwin/default.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nix/pkgs/haskell/materialized-linux/default.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nix/pkgs/haskell/materialized-windows/default.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions plutus-pab-executables/demo/pab-nami/client/default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{ pkgs, gitignore-nix, haskell, webCommon, buildPursPackage, buildNodeModules, filterNpm }:
let
pab-nami-demo-invoker = haskell.packages.plutus-pab-executables.components.exes.plutus-pab-nami-demo;
pab-nami-demo-generator = haskell.packages.plutus-pab-executables.components.exes.plutus-pab-nami-demo-generator;

pab-setup-invoker = haskell.packages.plutus-pab-executables.components.exes.plutus-pab-setup;

# TODO: Use the PS generator in the demo app
generated-purescript = pkgs.runCommand "pab-nami-demo-purescript" { } ''
mkdir $out
${pab-setup-invoker}/bin/plutus-pab-setup psgenerator $out
ln -s ${../pab/plutus-pab.yaml} plutus-pab.yaml
${pab-nami-demo-invoker}/bin/plutus-pab-nami-demo --config ../pab/plutus-pab.yaml psapigenerator $out
${pab-nami-demo-generator}/bin/plutus-pab-nami-demo-generator --output-dir $out
'';

generate-purescript = pkgs.writeShellScriptBin "pab-nami-demo-generate-purs" ''
generatedDir=./generated
rm -rf $generatedDir
$(nix-build ../../../../default.nix -A pab-nami-demo.pab-setup-invoker)/bin/plutus-pab-setup psgenerator $generatedDir
$(nix-build ../../../../default.nix -A pab-nami-demo.pab-nami-demo-invoker)/bin/plutus-pab-nami-demo --config ../pab/plutus-pab.yaml psapigenerator $generatedDir
$(nix-build ../../../../default.nix -A pab-nami-demo.pab-nami-demo-generator)/bin/plutus-pab-nami-demo-generator --output-dir $generatedDir
'';

start-backend = pkgs.writeShellScriptBin "pab-nami-demo-server" ''
Expand Down Expand Up @@ -53,5 +53,5 @@ let
});
in
{
inherit client pab-nami-demo-invoker pab-setup-invoker generate-purescript generated-purescript start-backend;
inherit client pab-nami-demo-invoker pab-nami-demo-generator pab-setup-invoker generate-purescript generated-purescript start-backend;
}
28 changes: 28 additions & 0 deletions plutus-pab-executables/demo/pab-nami/pab/app/Generator.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Main
( main
) where

import Data.Proxy
import DemoContract (DemoContract)
import Options.Applicative
import Plutus.PAB.Run.PSGenerator qualified as PSGenerator

parseOptions :: IO FilePath
parseOptions = customExecParser
(prefs $ disambiguate <> showHelpOnEmpty <> showHelpOnError)
(info (helper <*> psGenOutputDirParser) idm)

psGenOutputDirParser :: Parser FilePath
psGenOutputDirParser = option str
(long "output-dir" <>
metavar "OUTPUT_DIR" <>
help "Output directory to write PureScript files to.")

main :: IO ()
main = do
psGenOutputDir <- parseOptions
PSGenerator.generateAPIModule (Proxy :: Proxy DemoContract) psGenOutputDir
PSGenerator.generateWith @DemoContract psGenOutputDir
31 changes: 31 additions & 0 deletions plutus-pab-executables/plutus-pab-executables.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,34 @@ executable plutus-pab-nami-demo
plutus-ledger-constraints -any,
row-types -any,
text -any,

executable plutus-pab-nami-demo-generator
import: lang
main-is: Generator.hs
hs-source-dirs: demo/pab-nami/pab/app
other-modules:
DemoContract
ghc-options:
-threaded
build-depends:
aeson -any,
async -any,
base >= 4.9 && < 5,
cardano-api -any,
data-default -any,
filepath -any,
freer-extras -any,
freer-simple -any,
openapi3 -any,
optparse-applicative -any,
plutus-chain-index -any,
plutus-contract -any,
plutus-pab -any,
plutus-pab-psgenerator -any,
playground-common -any,
prettyprinter -any,
purescript-bridge -any,
plutus-ledger -any,
plutus-ledger-constraints -any,
row-types -any,
text -any,

0 comments on commit 369f89d

Please sign in to comment.