Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MetaLamp/lending-pool/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fmt:
find pab src -type f -name \*.hs -exec \
stylish-haskell --inplace '{}' +
fix-stylish-haskell
fix-purty

2 changes: 1 addition & 1 deletion MetaLamp/lending-pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cabal build all
cabal run pab
```

This will then start up the server on port 8080.
This will then start up the server on port 9080.

4. To run test simulation do:

Expand Down
114 changes: 78 additions & 36 deletions MetaLamp/lending-pool/cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
index-state: 2021-04-13T00:00:00Z
index-state: 2021-08-14T00:00:00Z

packages: ./.

Expand All @@ -9,6 +9,7 @@ write-ghc-environment-files: never
tests: true
benchmarks: true

-- Plutus revision from 2021/08/16
source-repository-package
type: git
location: https://github.com/input-output-hk/plutus.git
Expand All @@ -17,6 +18,7 @@ source-repository-package
playground-common
plutus-core
plutus-contract
plutus-chain-index
plutus-ledger
plutus-ledger-api
plutus-tx
Expand All @@ -26,41 +28,66 @@ source-repository-package
prettyprinter-configurable
quickcheck-dynamic
word-array
tag: plutus-starter-devcontainer/v1.0.6
tag: plutus-starter-devcontainer/v1.0.8


-- The following sections are copied from the 'plutus' repository cabal.project at the revision
-- given above.
-- This is necessary because the 'plutus' libraries depend on a number of other libraries which are
-- not on Hackage, and so need to be pulled in as `source-repository-package`s themselves. Make sure to
-- re-update this section from the template when you do an upgrade.
package eventful-sql-common
ghc-options: -XDerivingStrategies -XStandaloneDeriving -XUndecidableInstances -XDataKinds -XFlexibleInstances

-- We never, ever, want this.
write-ghc-environment-files: never

-- Always build tests and benchmarks.
tests: true
benchmarks: true

-- The only sensible test display option
test-show-details: streaming

allow-newer:
-- Has a commit to allow newer aeson, not on Hackage yet
monoidal-containers:aeson
-- Pins to an old version of Template Haskell, unclear if/when it will be updated
, size-based:template-haskell

-- The following two dependencies are needed by plutus.
, eventful-sql-common:persistent
, eventful-sql-common:persistent-template
size-based:template-haskell
, ouroboros-consensus-byron:formatting
, beam-core:aeson
, beam-sqlite:aeson
, beam-sqlite:dlist
, beam-migrate:aeson

constraints:
-- aws-lambda-haskell-runtime-wai doesn't compile with newer versions
aws-lambda-haskell-runtime <= 3.0.3
-- big breaking change here, inline-r doens't have an upper bound
, singletons < 3.0
-- breaks eventful even more than it already was
, persistent-template < 2.12

singletons < 3.0
-- bizarre issue: in earlier versions they define their own 'GEq', in newer
-- ones they reuse the one from 'some', but there isn't e.g. a proper version
-- constraint from dependent-sum-template (which is the library we actually use).
, dependent-sum > 0.6.2.0

-- See the note on nix/pkgs/default.nix:agdaPackages for why this is here.
-- (NOTE this will change to ieee754 in newer versions of nixpkgs).
extra-packages: ieee, filemanip

-- Drops an instance breaking our code. Should be released to Hackage eventually.
-- These packages appear in our dependency tree and are very slow to build.
-- Empirically, turning off optimization shaves off ~50% build time.
-- It also mildly improves recompilation avoidance.
-- For deve work we don't care about performance so much, so this is okay.
package cardano-ledger-alonzo
optimization: False
package ouroboros-consensus-shelley
optimization: False
package ouroboros-consensus-cardano
optimization: False
package cardano-api
optimization: False

-- https://github.com/Quid2/flat/pull/22 fixes a potential exception
-- when decoding invalid (e.g. malicious) text literals.
source-repository-package
type: git
location: https://github.com/Quid2/flat.git
tag: 95e5d7488451e43062ca84d5376b3adcc465f1cd
-- location: https://github.com/Quid2/flat.git
location: https://github.com/michaelpj/flat.git
tag: ee59880f47ab835dbd73bea0847dab7869fc20d8

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

-- Needs a fix (https://github.com/wenkokke/unlit/pull/11) and a Hackage release
source-repository-package
type: git
location: https://github.com/michaelpj/unlit.git
tag: 9ca1112093c5ffd356fc99c7dafa080e686dd748
tag: 07397f0e50da97eaa0575d93bee7ac4b2b2576ec

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: a715c7f420770b70bbe95ca51d3dec83866cb1bd
tag: cb0f19c85e5bb5299839ad4ed66af6fa61322cc4
subdir:
base-deriving-via
binary
binary/test
slotting
cardano-crypto-class
cardano-crypto-praos
cardano-crypto-tests
measures
orphans-deriving-via
slotting
strict-containers

source-repository-package
Expand All @@ -108,8 +132,9 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: e50613562d6d4a0f933741fcf590b0f69a1eda67
tag: 877ce057ff6fb086474c8eaad53f2b7f0e0fce6b
subdir:
monoidal-synchronisation
typed-protocols
typed-protocols-examples
ouroboros-network
Expand All @@ -120,23 +145,27 @@ source-repository-package
ouroboros-consensus-cardano
ouroboros-consensus-shelley
io-sim
io-sim-classes
io-classes
network-mux

source-repository-package
type: git
location: https://github.com/input-output-hk/iohk-monitoring-framework
tag: 34abfb7f4f5610cabb45396e0496472446a0b2ca
tag: 808724ff8a19a33d0ed06f9ef59fbd900b08553c
subdir:
iohk-monitoring
tracer-transformers
contra-tracer
plugins/backend-aggregation
plugins/backend-ekg
plugins/backend-monitoring
plugins/backend-trace-forwarder
plugins/scribe-systemd

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: a3ef848542961079b7cd53d599e5385198a3035c
tag: d5b184a820853c7ba202efd615b8fadca1acb52c
subdir:
byron/chain/executable-spec
byron/crypto
Expand All @@ -159,21 +188,34 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-node.git
tag: b3cabae6b3bf30a0b1b4e78bc4b67282dabad0a6
tag: ed11e8b6429d4af1cb2539460e5cb2283a06b2dc
subdir:
cardano-api
cardano-node
cardano-cli
cardano-config

source-repository-package
type: git
location: https://github.com/input-output-hk/optparse-applicative
tag: 7497a29cb998721a9068d5725d49461f2bba0e7a

source-repository-package
type: git
location: https://github.com/input-output-hk/Win32-network
tag: 94153b676617f8f33abe8d8182c37377d2784bd1
tag: 3825d3abf75f83f406c1f7161883c438dac7277d

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

source-repository-package
type: git
location: https://github.com/input-output-hk/goblins
tag: cde90a2b27f79187ca8310b6549331e59595e7ba

source-repository-package
type: git
location: https://github.com/sordina/servant-options
tag: aa9338b1925e7bc5d65bad35f02aec8c20f8365b
5 changes: 0 additions & 5 deletions MetaLamp/lending-pool/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ npm start
```

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):

```
npm run start-chrome
```

## Troubleshooting

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 bd16cc29045ffc7eaa6beaabe3b985a56cb9292a # plutus-starter-devcontainer/v1.0.6
git pull origin cc7bc06c4344cee6cd59bc170063fd627da25ed3 # plutus-starter-devcontainer/v1.0.8
1 change: 0 additions & 1 deletion MetaLamp/lending-pool/client/scripts/start-chrome.sh

This file was deleted.

1 change: 1 addition & 0 deletions MetaLamp/lending-pool/client/spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can edit this file as you like.
, dependencies =
[ "aff"
, "affjax"
, "aff-promise"
, "argonaut-codecs"
, "avar"
, "bigints"
Expand Down
6 changes: 3 additions & 3 deletions MetaLamp/lending-pool/client/src/AppAff.purs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ post path body = do
runAjax $ ajax decode affReq

instance contractAppM :: Contract AppM where
getContracts = get "/api/new/contract/instances"
getContractStatus (ContractId cid) = get $ "/api/new/contract/instance/" <> cid <> "/status"
callEndpoint (Endpoint endpoint) (ContractId cid) params = post ("/api/new/contract/instance/" <> cid <> "/endpoint/" <> endpoint) (string <<< encodeJSON $ params)
getContracts = get "/api/contract/instances"
getContractStatus (ContractId cid) = get $ "/api/contract/instance/" <> cid <> "/status"
callEndpoint (Endpoint endpoint) (ContractId cid) params = post ("/api/contract/instance/" <> cid <> "/endpoint/" <> endpoint) (string <<< encodeJSON $ params)

instance pollContractAppM :: PollContract AppM where
pollDelay = liftAff <<< delay <<< Milliseconds $ 1000.0
Expand Down
2 changes: 1 addition & 1 deletion MetaLamp/lending-pool/client/src/Business/Aave.purs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ getAaveResponseWith endpoint pick cid param = pollEndpoint getNext endpoint para
(preview pick state)

getAaveContractId :: forall a. Prism' AaveContracts a -> ContractInstanceClientState AaveContracts -> Maybe ContractId
getAaveContractId pick (ContractInstanceClientState { cicContract, cicDefintion }) = (const $ toContractIdParam cicContract) <$> (preview pick cicDefintion)
getAaveContractId pick (ContractInstanceClientState st) = (const $ toContractIdParam st.cicContract) <$> (preview pick st.cicDefinition)

toContractIdParam :: ContractInstanceId -> ContractId
toContractIdParam (ContractInstanceId { unContractInstanceId: JsonUUID uuid }) = ContractId <<< UUID.toString $ uuid
25 changes: 13 additions & 12 deletions MetaLamp/lending-pool/client/src/Component/Contract.purs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ component =
(const <<< pure $ unit)
revokeCollateral
Nothing -> throwError "Asset name not found"

render :: State -> H.ComponentHTML Action Slots m
render state =
HH.div_
Expand All @@ -227,17 +227,18 @@ component =
Loading -> HH.div_ []
Failure e -> HH.h4_ [ HH.text e ]
Success _ -> HH.div_ []
, case state.submit of
Loading -> HH.div_ [ HH.text "Loading..." ]
_ -> HH.div_
$ mapWithIndex
( \index (Tuple title operation) ->
HH.h2_
[ HH.text title
, HH.slot _amountForm index AmountForm.component (reservesToAmounts state.reserves) (Just <<< (OnSubmitAmount operation))
]
)
[ Tuple "Deposit" SubmitDeposit, Tuple "Withdraw" SubmitWithdraw, Tuple "Borrow" SubmitBorrow, Tuple "Repay" SubmitRepay, Tuple "ProvideCollateral" SubmitProvideCollateral, Tuple "RevokeCollateral" SubmitRevokeCollateral ]
, case state.submit of
Loading -> HH.div_ [ HH.text "Loading..." ]
_ ->
HH.div_
$ mapWithIndex
( \index (Tuple title operation) ->
HH.h2_
[ HH.text title
, HH.slot _amountForm index AmountForm.component (reservesToAmounts state.reserves) (Just <<< (OnSubmitAmount operation))
]
)
[ Tuple "Deposit" SubmitDeposit, Tuple "Withdraw" SubmitWithdraw, Tuple "Borrow" SubmitBorrow, Tuple "Repay" SubmitRepay, Tuple "ProvideCollateral" SubmitProvideCollateral, Tuple "RevokeCollateral" SubmitRevokeCollateral ]
]

reservesToAmounts :: Array { amount :: BigInteger, asset :: AssetClass } -> Array AmountForm.AmountInfo
Expand Down
2 changes: 1 addition & 1 deletion MetaLamp/lending-pool/client/src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ main :: Effect Unit
main =
runHalogenAff do
let
rootComponent = H.hoist (runAppM { host: "localhost", port: 8080 }) App.component
rootComponent = H.hoist (runAppM { host: "localhost", port: 9080 }) App.component
body <- awaitBody
runUI rootComponent unit body

Expand Down
2 changes: 0 additions & 2 deletions MetaLamp/lending-pool/generate-purs/AaveTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import qualified Plutus.Contracts.LendingPool.OffChain.User as Aave
import qualified Plutus.Contracts.LendingPool.OnChain.Core as Aave
import qualified Plutus.Contracts.Service.Oracle as Oracle
import Plutus.PAB.Simulation (AaveContracts (..))
import Plutus.V1.Ledger.Value (AssetClass)

ratioBridge :: BridgePart
ratioBridge = do
Expand All @@ -56,7 +55,6 @@ aaveTypes = [ (equal <*> (genericShow <*> mkSumType)) (Proxy @AaveContracts)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @Oracle.Oracle)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @(ContractResponse E A))
, (equal <*> (genericShow <*> mkSumType)) (Proxy @Aave.CreateParams)
, (order <*> (equal <*> (genericShow <*> mkSumType))) (Proxy @AssetClass)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @Aave.UserContractState)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @Aave.InfoContractState)
, (equal <*> (genericShow <*> mkSumType)) (Proxy @Aave.Reserve)
Expand Down
Loading