Skip to content

Commit

Permalink
SCP-2345: Delete ContractCLI and ContractExe, and replaced them with …
Browse files Browse the repository at this point in the history
…'Builtin' contracts.

Co-authored-by: Noon van der Silk <noonsilk+-noonsilk@gmail.com>
Co-authored-by: Jann Mueller <jann.mueller@iohk.io>
  • Loading branch information
3 people committed Jul 20, 2021
1 parent db4cf45 commit 36a9e46
Show file tree
Hide file tree
Showing 87 changed files with 1,842 additions and 2,487 deletions.
17 changes: 5 additions & 12 deletions default.nix
Expand Up @@ -43,11 +43,6 @@ rec {
plutus-atomic-swap
plutus-pay-to-wallet;

inherit (haskell.packages.marlowe.components.exes)
marlowe-app
marlowe-companion-app
marlowe-follow-app;

webCommon = pkgs.callPackage ./web-common { inherit (plutus.lib) gitignore-nix; };
webCommonPlutus = pkgs.callPackage ./web-common-plutus { inherit (plutus.lib) gitignore-nix; };
webCommonMarlowe = pkgs.callPackage ./web-common-marlowe { inherit (plutus.lib) gitignore-nix; };
Expand All @@ -71,15 +66,15 @@ rec {

marlowe-dashboard = pkgs.recurseIntoAttrs rec {
inherit (pkgs.callPackage ./marlowe-dashboard-client {
inherit plutus-pab marlowe-app marlowe-companion-app marlowe-follow-app;
inherit haskell plutus-pab;
inherit (plutus.lib) buildPursPackage buildNodeModules filterNpm gitignore-nix;
inherit webCommon webCommonMarlowe;
}) client server-invoker generated-purescript generate-purescript contractsJSON install-marlowe-contracts;
}) client server-setup-invoker marlowe-invoker generated-purescript generate-purescript;
};

marlowe-dashboard-fake-pab = pkgs.recurseIntoAttrs rec {
inherit (pkgs.callPackage ./fake-pab {
inherit plutus-pab marlowe-app marlowe-companion-app marlowe-follow-app;
inherit marlowe-dashboard;
inherit (plutus.lib) buildPursPackage buildNodeModules filterNpm gitignore-nix;
inherit haskell webCommon webCommonMarlowe;
}) client fake-pab-exe fake-pab-generated-purescript;
Expand All @@ -104,17 +99,15 @@ rec {
inherit (plutus.lib) gitignore-nix;
inherit (plutus) fixStylishHaskell fixPurty fixPngOptimization;
inherit (pkgs) terraform;
inherit plutus-playground marlowe-playground marlowe-dashboard web-ghc plutus-pab
marlowe-app marlowe-companion-app marlowe-follow-app;
inherit plutus-playground marlowe-playground marlowe-dashboard web-ghc plutus-pab;
src = ./.;
};

docs = import ./nix/docs.nix { inherit pkgs plutus; };

deployment = pkgs.recurseIntoAttrs (pkgs.callPackage ./deployment/morph {
plutus = {
inherit plutus-pab marlowe-app marlowe-companion-app marlowe-follow-app
marlowe-dashboard marlowe-playground plutus-playground web-ghc docs marlowe-web;
inherit plutus-pab marlowe-dashboard marlowe-playground plutus-playground web-ghc docs marlowe-web;
};
});

Expand Down
8 changes: 2 additions & 6 deletions deployment/morph/machines/marlowe-dash.nix
Expand Up @@ -11,12 +11,8 @@

services.pab = {
enable = true;
pab-package = pkgs.plutus-pab.pab-exes.plutus-pab;
contracts = [
"${pkgs.marlowe-app}/bin/marlowe-app"
"${pkgs.marlowe-companion-app}/bin/marlowe-companion-app"
"${pkgs.marlowe-follow-app}/bin/marlowe-follow-app"
];
pab-setup = pkgs.plutus-pab.pab-exes.plutus-pab-setup;
pab-package = pkgs.plutus-pab.pab-exes.plutus-pab-examples;
staticContent = pkgs.marlowe-dashboard.client;
dbFile = "/var/lib/pab/pab-core.db";
defaultWallet = 1;
Expand Down
3 changes: 0 additions & 3 deletions deployment/morph/mk-machine.nix
Expand Up @@ -25,9 +25,6 @@
overlays = [
(self: super: {
plutus-pab = plutus.plutus-pab;
marlowe-app = plutus.marlowe-app;
marlowe-companion-app = plutus.marlowe-companion-app;
marlowe-follow-app = plutus.marlowe-follow-app;
marlowe-dashboard = plutus.marlowe-dashboard;
marlowe-playground = plutus.marlowe-playground;
marlowe-web = plutus.marlowe-web;
Expand Down
11 changes: 2 additions & 9 deletions fake-pab/default.nix
@@ -1,4 +1,4 @@
{ pkgs, gitignore-nix, haskell, webCommon, webCommonMarlowe, buildPursPackage, buildNodeModules, filterNpm, plutus-pab, marlowe-app, marlowe-companion-app, marlowe-follow-app }:
{ pkgs, gitignore-nix, haskell, webCommon, webCommonMarlowe, buildPursPackage, buildNodeModules, filterNpm, marlowe-dashboard }:
let
cleanSrc = gitignore-nix.gitignoreSource ../marlowe-dashboard-client/.;

Expand All @@ -17,12 +17,6 @@ let
githubSourceHashMap = { };
};

contractsJSON = pkgs.writeTextDir "contracts.json" (builtins.toJSON {
marlowe = "${marlowe-app}/bin/marlowe-app";
walletCompanion = "${marlowe-companion-app}/bin/marlowe-companion-app";
walletFollower = "${marlowe-follow-app}/bin/marlowe-follow-app";
});

client = buildPursPackage {
inherit pkgs nodeModules;
src = cleanSrc;
Expand All @@ -33,9 +27,8 @@ let
extraSrcs = {
web-common = webCommon;
web-common-marlowe = webCommonMarlowe;
generated = plutus-pab.generated-purescript;
generated = marlowe-dashboard.generated-purescript;
fake-pab-generated = fake-pab-generated-purescript;
contracts = contractsJSON;
};
packages = pkgs.callPackage ../marlowe-dashboard-client/packages.nix { };
spagoPackages = pkgs.callPackage ../marlowe-dashboard-client/spago-packages.nix { };
Expand Down
41 changes: 24 additions & 17 deletions marlowe-dashboard-client/default.nix
@@ -1,5 +1,25 @@
{ pkgs, gitignore-nix, webCommon, webCommonMarlowe, buildPursPackage, buildNodeModules, filterNpm, plutus-pab, marlowe-app, marlowe-companion-app, marlowe-follow-app }:
{ pkgs, gitignore-nix, haskell, webCommon, webCommonMarlowe, buildPursPackage, buildNodeModules, filterNpm, plutus-pab }:
let
marlowe-invoker = haskell.packages.marlowe.components.exes.marlowe-pab;

generated-purescript = pkgs.runCommand "marlowe-pab-purescript" { } ''
mkdir $out
ln -s ${haskell.packages.plutus-pab.src}/plutus-pab.yaml.sample plutus-pab.yaml
${plutus-pab.server-setup-invoker}/bin/plutus-pab-setup psgenerator $out
${plutus-pab.test-generator}/bin/plutus-pab-test-psgenerator $out
${marlowe-invoker}/bin/marlowe-pab --config plutus-pab.yaml psapigenerator $out
'';

generate-purescript = pkgs.writeShellScriptBin "marlowe-pab-generate-purs" ''
generatedDir=./generated
rm -rf $generatedDir
# There might be local modifications so only copy when missing
! test -f ./plutus-pab.yaml && cp ../plutus-pab/plutus-pab.yaml.sample plutus-pab.yaml
$(nix-build ../default.nix --quiet --no-build-output -A plutus-pab.server-setup-invoker)/bin/plutus-pab-setup psgenerator $generatedDir
$(nix-build ../default.nix --quiet --no-build-output -A plutus-pab.test-generator)/bin/plutus-pab-test-psgenerator $generatedDir
$(nix-build ../default.nix --quiet --no-build-output -A marlowe-dashboard.marlowe-invoker)/bin/marlowe-pab --config plutus-pab.yaml psapigenerator $generatedDir
'';

cleanSrc = gitignore-nix.gitignoreSource ./.;

nodeModules = buildNodeModules {
Expand All @@ -9,12 +29,6 @@ let
githubSourceHashMap = { };
};

contractsJSON = pkgs.writeTextDir "contracts.json" (builtins.toJSON {
marlowe = "${marlowe-app}/bin/marlowe-app";
walletCompanion = "${marlowe-companion-app}/bin/marlowe-companion-app";
walletFollower = "${marlowe-follow-app}/bin/marlowe-follow-app";
});

client = buildPursPackage {
inherit pkgs nodeModules;
src = cleanSrc;
Expand All @@ -25,20 +39,13 @@ let
extraSrcs = {
web-common = webCommon;
web-common-marlowe = webCommonMarlowe;
generated = plutus-pab.generated-purescript;
contracts = contractsJSON;
generated = generated-purescript;
};
packages = pkgs.callPackage ./packages.nix { };
spagoPackages = pkgs.callPackage ./spago-packages.nix { };
};

install-marlowe-contracts = pkgs.writeShellScriptBin "install-marlowe-contracts" ''
${plutus-pab.server-invoker}/bin/plutus-pab contracts install --path ${marlowe-app}/bin/marlowe-app
${plutus-pab.server-invoker}/bin/plutus-pab contracts install --path ${marlowe-companion-app}/bin/marlowe-companion-app
${plutus-pab.server-invoker}/bin/plutus-pab contracts install --path ${marlowe-follow-app}/bin/marlowe-follow-app
'';
in
{
inherit (plutus-pab) server-invoker generated-purescript generate-purescript start-backend;
inherit client contractsJSON install-marlowe-contracts;
inherit (plutus-pab) server-setup-invoker start-backend;
inherit client marlowe-invoker generate-purescript generated-purescript;
}
5 changes: 1 addition & 4 deletions marlowe-dashboard-client/package.json
Expand Up @@ -10,10 +10,7 @@
"test:watch": "spago test --no-psa --watch",
"docs": "spago docs",
"repl": "spago repl",
"start": "npm install && plutus-pab-generate-purs && npm run purs:compile && npm run webpack:server",
"link-contracts": "nix-build ../default.nix -A marlowe-dashboard.contractsJSON -o contracts",
"install-contracts": "nix-build ../default.nix -A marlowe-dashboard.install-marlowe-contracts",
"setup-contracts": "npm run install-contracts && npm run link-contracts"
"start": "npm install && marlowe-pab-generate-purs && npm run purs:compile && npm run webpack:server"
},
"resolutions": {},
"license": "Apache-2.0",
Expand Down
21 changes: 10 additions & 11 deletions marlowe-dashboard-client/plutus-pab.yaml
@@ -1,25 +1,24 @@
# This file is provided here for development purposes only. In deployment,
# settings are taken from `deployment/morph/machines/marlowe-dash.nix` (which
# also determines which contracts are available). In most cases we use the
# default settings - the main thing to watch out for is that the
# `scZeroSlotTime` here coincides with the frontend code's assumptions about
# the time of slot 0 (in `web-common-marlowe/src/Marlowe/Slot.purs`).
# settings are taken from `deployment/morph/machines/marlowe-dash.nix` . In
# most cases we use the default settings - the main thing to watch out for is
# that the `scSlotZeroTime` here coincides with the frontend code's assumptions
# about the time of slot 0 (in `web-common-marlowe/src/Marlowe/Slot.purs`).
dbConfig:
dbConfigFile: pab-core.db
dbConfigPoolSize: 20

pabWebserverConfig:
baseUrl: http://localhost:8080
baseUrl: http://localhost:9080
staticDir: plutus-pab-client/dist
permissiveCorsPolicy: False

walletServerConfig:
baseUrl: http://localhost:8081
baseUrl: http://localhost:9081
wallet:
getWallet: 1

nodeServerConfig:
mscBaseUrl: http://localhost:8082
mscBaseUrl: http://localhost:9082
mscSocketPath: ./node-server.sock
mscKeptBlocks: 100
mscNetworkId: "1"
Expand All @@ -37,19 +36,19 @@ nodeServerConfig:
- getWallet: 3

chainIndexConfig:
ciBaseUrl: http://localhost:8083
ciBaseUrl: http://localhost:9083
ciWatchedAddresses: []

requestProcessingConfig:
requestProcessingInterval: 1

signingProcessConfig:
spBaseUrl: http://localhost:8084
spBaseUrl: http://localhost:9084
spWallet:
getWallet: 1

metadataServerConfig:
mdBaseUrl: http://localhost:8085
mdBaseUrl: http://localhost:9085

# Optional timeout (in seconds) for calls to endpoints that are not currently
# available. If this is not set, calls to unavailable endpoints fail
Expand Down
11 changes: 1 addition & 10 deletions marlowe-dashboard-client/src/API/Contract.purs
Expand Up @@ -22,7 +22,7 @@ import API.Url (toUrlPiece)
import Control.Monad.Error.Class (class MonadError)
import Effect.Aff.Class (class MonadAff)
import Foreign.Generic (class Decode, class Encode)
import Plutus.PAB.Effects.Contract.ContractExe (ContractExe)
import Plutus.PAB.Effects.Contract.Builtin (Builtin)
import Plutus.PAB.Webserver.Types (ContractActivationArgs, ContractInstanceClientState, ContractSignatureResponse)
import Servant.PureScript.Ajax (AjaxError)
import Wallet.Emulator.Wallet (Wallet)
Expand All @@ -47,15 +47,6 @@ class
getAllContractInstances :: forall m. MonadError AjaxError m => MonadAff m => a -> m (Array (ContractInstanceClientState a))
getContractDefinitions :: forall m. MonadError AjaxError m => MonadAff m => a -> m (Array (ContractSignatureResponse a))

instance contractExeContractActivationId :: ContractActivationId ContractExe where
activateContract = defaultActivateContract
deactivateContract = defaultDeactivateContract
getContractInstanceClientState = defaultGetContractInstanceClientState
invokeEndpoint = defaultInvokeEndpoint
getWalletContractInstances = defaultGetWalletContractInstances
getAllContractInstances = defaultGetAllContractInstances
getContractDefinitions = defaultGetContractDefinitions

defaultActivateContract ::
forall a m.
ContractActivationId a =>
Expand Down

0 comments on commit 36a9e46

Please sign in to comment.