Skip to content

Commit

Permalink
Merge branch 'MetaLamp/lending-pool/development' of https://github.co…
Browse files Browse the repository at this point in the history
…m/input-output-hk/plutus-use-cases into MetaLamp/lending-pool/incentivized-tokens
  • Loading branch information
performanceArtist committed Jul 20, 2021
2 parents c1f2c93 + 95a6742 commit bbfa664
Show file tree
Hide file tree
Showing 30 changed files with 773 additions and 124 deletions.
3 changes: 1 addition & 2 deletions MetaLamp/lending-pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ The smart contract protocol is based on [Aave](https://aave.com/), but does not
We have provided two PAB applications in `./pab` and `./pab-simulation`. The first one is made for real world usage and interaction through frontend [client](client/README.md), the second one is a big test scenario.
With the PAB we can serve and interact with contracts over a web API. You can read more about the PAB here: [PAB Architecture](https://github.com/input-output-hk/plutus/blob/master/plutus-pab/ARCHITECTURE.adoc).

1. Enter the nix shell (cd to the cloned Plutus repo):
1. Enter the nix shell (from `lending-pool` directory):

```
git checkout 5cdd2c3d708bf4c33514681dee096da6463273b7
nix-shell
```

Expand Down
55 changes: 42 additions & 13 deletions MetaLamp/lending-pool/cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
index-state: 2021-02-24T00:00:00Z
index-state: 2021-04-13T00:00:00Z

packages: ./.

Expand Down Expand Up @@ -26,7 +26,7 @@ source-repository-package
prettyprinter-configurable
quickcheck-dynamic
word-array
tag: 5cdd2c3d708bf4c33514681dee096da6463273b7
tag: plutus-starter-devcontainer/v1.0.6

-- The following sections are copied from the 'plutus' repository cabal.project at the revision
-- given above.
Expand Down Expand Up @@ -56,6 +56,12 @@ constraints:

extra-packages: ieee, filemanip

-- Drops an instance breaking our code. Should be released to Hackage eventually.
source-repository-package
type: git
location: https://github.com/Quid2/flat.git
tag: 95e5d7488451e43062ca84d5376b3adcc465f1cd

-- Needs some patches, but upstream seems to be fairly dead (no activity in > 1 year)
source-repository-package
type: git
Expand All @@ -70,7 +76,7 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-crypto.git
tag: f73079303f663e028288f9f4a9e08bcca39a923e
tag: ce8f1934e4b6252084710975bd9bbc0a4648ece4

-- Needs a fix (https://github.com/wenkokke/unlit/pull/11) and a Hackage release
source-repository-package
Expand All @@ -81,41 +87,46 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 4251c0bb6e4f443f00231d28f5f70d42876da055
tag: a715c7f420770b70bbe95ca51d3dec83866cb1bd
subdir:
binary
binary/test
slotting
cardano-crypto-class
cardano-crypto-praos
cardano-crypto-tests
strict-containers

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: ee4e7b547a991876e6b05ba542f4e62909f4a571
tag: fd773f7a58412131512b9f694ab95653ac430852
subdir:
cardano-prelude
cardano-prelude-test

source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 6cb9052bde39472a0555d19ade8a42da63d3e904
tag: e50613562d6d4a0f933741fcf590b0f69a1eda67
subdir:
typed-protocols
typed-protocols-examples
ouroboros-network
ouroboros-network-testing
ouroboros-network-framework
ouroboros-consensus
ouroboros-consensus-byron
ouroboros-consensus-cardano
ouroboros-consensus-shelley
io-sim
io-sim-classes
network-mux
Win32-network

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: a89c38ed5825ba17ca79fddb85651007753d699d
tag: 34abfb7f4f5610cabb45396e0496472446a0b2ca
subdir:
iohk-monitoring
tracer-transformers
Expand All @@ -125,7 +136,7 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: 097890495cbb0e8b62106bcd090a5721c3f4b36f
tag: a3ef848542961079b7cd53d599e5385198a3035c
subdir:
byron/chain/executable-spec
byron/crypto
Expand All @@ -137,14 +148,32 @@ source-repository-package
semantics/small-steps-test
shelley/chain-and-ledger/dependencies/non-integer
shelley/chain-and-ledger/executable-spec
shelley/chain-and-ledger/shelley-spec-ledger-test
shelley-ma/impl
cardano-ledger-core
alonzo/impl

-- A lot of plutus dependencies have to be synchronized with the dependencies of
-- cardano-node. If you update cardano-node, please make sure that all dependencies
-- of cardano-node are also updated.
source-repository-package
type: git
location: https://github.com/input-output-hk/goblins
tag: cde90a2b27f79187ca8310b6549331e59595e7ba
location: https://github.com/input-output-hk/cardano-node.git
tag: b3cabae6b3bf30a0b1b4e78bc4b67282dabad0a6
subdir:
cardano-api

source-repository-package
type: git
location: https://github.com/Quid2/flat.git
tag: 95e5d7488451e43062ca84d5376b3adcc465f1cd
location: https://github.com/input-output-hk/Win32-network
tag: 94153b676617f8f33abe8d8182c37377d2784bd1

source-repository-package
type: git
location: https://github.com/input-output-hk/hedgehog-extras
tag: 8bcd3c9dc22cc44f9fcfe161f4638a384fc7a187

source-repository-package
type: git
location: https://github.com/input-output-hk/goblins
tag: cde90a2b27f79187ca8310b6549331e59595e7ba
19 changes: 10 additions & 9 deletions MetaLamp/lending-pool/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@ The client application has a minimalistic interface to the PAB [server](/MetaLam

## Running the project

1. Install npm packages.
1. Enter the nix shell (from `lending-pool` directory):

```
npm install
nix-shell
```

2. Generate necessary PureScript code from Haskell source. This step runs an executable(`generate-purs`) from `lending-pool` directory, which requires a certain environment. The setup steps are described in `lending-pool/README`. Provided that you are able to build the backend, you can use the same approach to run purescript generation from `client` folder, i.e.
Cd to `./client` folder.


Enter the nix shell (cd to the cloned Plutus repo):
2. Install npm packages.

```
git checkout 5cdd2c3d708bf4c33514681dee096da6463273b7
nix-shell
npm install
```

cd to `lending-pool/client` folder and execute
3. Generate necessary PureScript code from Haskell source. This step runs an executable(`generate-purs`) from `lending-pool` directory, which requires a certain environment. The setup steps are described in `lending-pool/README`. Provided that you are able to build the backend, you can use the same approach to run purescript generation from `client` folder, i.e.


```
npm run generate-purs
```

3. Start the client:
4. Start the client:

```
npm start
```

4. Open browser to interact with the app at https://localhost:8009/.
5. Open browser to interact with the app at https://localhost:8009/.
CORS protection needs to be disabled. You can use this script to launch chromium (note that first you need to close chromium completely, otherwise security won't be disabled):

```
Expand Down
2 changes: 1 addition & 1 deletion MetaLamp/lending-pool/client/scripts/fetch-plutus-purs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ git remote add origin -f https://github.com/input-output-hk/plutus
git config core.sparseCheckout true
echo 'web-common-plutus/*' >> .git/info/sparse-checkout
echo 'web-common/*' >> .git/info/sparse-checkout
git pull origin 5cdd2c3d708bf4c33514681dee096da6463273b7
git pull origin bd16cc29045ffc7eaa6beaabe3b985a56cb9292a # plutus-starter-devcontainer/v1.0.6
35 changes: 35 additions & 0 deletions MetaLamp/lending-pool/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
########################################################################
# default.nix -- The top-level nix build file for plutus-starter.
#
# This file defines various attributes that are used for building and
# developing plutus-starter.
#
########################################################################

let
# Here a some of the various attributes for the variable 'packages':
#
# { pkgs
# plutus-starter: {
# haskell: {
# project # The Haskell project created by haskell-nix.project
# packages # All the packages defined by our project, including dependencies
# projectPackages # Just the packages in the project
# }
# hlint
# cabal-install
# stylish-haskell
# haskell-language-server
# }
# }

packages = import ./nix;

inherit (packages) pkgs plutus-starter;
project = plutus-starter.haskell.project;
in
{
inherit pkgs plutus-starter;

inherit project;
}
26 changes: 1 addition & 25 deletions MetaLamp/lending-pool/generate-purs/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,13 @@ import Language.PureScript.Bridge.CodeGenSwitches (ForeignOptions (For
genForeign,
unwrapSingleConstructors)
import Language.PureScript.Bridge.TypeParameters (A)
import Ledger.Constraints.OffChain (UnbalancedTx)
import qualified PSGenerator.Common
import Plutus.Contract.Checkpoint (CheckpointKey,
CheckpointStore,
CheckpointStoreItem)
import Plutus.Contract.Effects.AwaitSlot (WaitingForSlot)
import Plutus.Contract.Effects.AwaitTxConfirmed (TxConfirmed)
import Plutus.Contract.Effects.ExposeEndpoint (ActiveEndpoint,
EndpointValue)
import Plutus.Contract.Effects.Instance (OwnIdRequest)
import Plutus.Contract.Effects.OwnPubKey (OwnPubKeyRequest)
import Plutus.Contract.Effects.UtxoAt (UtxoAtAddress)
import Plutus.Contract.Effects.WriteTx (WriteTxResponse)
import Plutus.Contract.Effects (TxConfirmed)
import Plutus.Contract.Resumable (Responses)
import Plutus.PAB.Effects.Contract.ContractExe (ContractExe)
import Plutus.PAB.Events.Contract (ContractPABRequest,
ContractPABResponse)
import Plutus.PAB.Events.ContractInstanceState (PartiallyDecodedResponse)
import qualified Plutus.PAB.Webserver.API as API
import Plutus.PAB.Webserver.Types (ChainReport,
Expand All @@ -84,8 +74,6 @@ import Servant.PureScript (HasBridge,
writeAPIModuleWithSettings)
import System.Directory (doesDirectoryExist,
removeDirectoryRecursive)
import Wallet.Effects (AddressChangeRequest (..),
AddressChangeResponse (..))
import Wallet.Emulator.Wallet (Wallet (..))

myBridge :: BridgePart
Expand Down Expand Up @@ -133,25 +121,13 @@ myTypes =
, (equal <*> (genericShow <*> mkSumType))
(Proxy @(ContractSignatureResponse A))
, (equal <*> (genericShow <*> mkSumType)) (Proxy @(PartiallyDecodedResponse A))
, (equal <*> (genericShow <*> mkSumType)) (Proxy @ContractPABRequest)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @ContractPABResponse)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @UnbalancedTx)

-- Contract request / response types
, (equal <*> (genericShow <*> mkSumType)) (Proxy @ActiveEndpoint)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @(EndpointValue A))
, (equal <*> (genericShow <*> mkSumType)) (Proxy @OwnPubKeyRequest)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @TxConfirmed)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @UtxoAtAddress)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @WriteTxResponse)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @WaitingForSlot)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @CheckpointStore)
, (order <*> (genericShow <*> mkSumType)) (Proxy @CheckpointKey)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @(CheckpointStoreItem A))
, (equal <*> (genericShow <*> mkSumType)) (Proxy @(Responses A))
, (equal <*> (genericShow <*> mkSumType)) (Proxy @AddressChangeRequest)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @AddressChangeResponse)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @OwnIdRequest)

-- Logging types
, (equal <*> (genericShow <*> mkSumType)) (Proxy @(LogMessage A))
Expand Down
20 changes: 20 additions & 0 deletions MetaLamp/lending-pool/nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
let
# Pratically, the only needed dependency is the plutus repository.
sources = import ./sources.nix { inherit pkgs; };

# We're going to get everything from the main plutus repository. This ensures
# we're using the same version of multiple dependencies such as nipxkgs,
# haskell-nix, cabal-install, compiler-nix-name, etc.
plutus = import sources.plutus {};
pkgs = plutus.pkgs;

haskell-nix = pkgs.haskell-nix;

plutus-starter = import ./pkgs {
inherit pkgs haskell-nix sources plutus;
};

in
{
inherit pkgs plutus-starter;
}
Loading

0 comments on commit bbfa664

Please sign in to comment.