Skip to content

Commit

Permalink
Fix plutus-playground-server
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed Jun 12, 2021
1 parent 70ab1f0 commit 59054fb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
5 changes: 2 additions & 3 deletions plutus-playground-server/usecases/ErrorHandling.hs
Expand Up @@ -17,8 +17,7 @@ import Data.Text (Text)
import qualified Data.Text as T

import Playground.Contract
import Plutus.Contract (AsContractError (_ContractError), ContractError, HasAwaitSlot, logInfo,
mapError, select)
import Plutus.Contract (AsContractError (_ContractError), ContractError, logInfo, mapError, select)
import Prelude (Maybe (..), const, show, ($), (.), (<>), (>>), (>>=))

-- Demonstrates how to deal with errors in Plutus contracts. We define a custom
Expand Down Expand Up @@ -69,7 +68,7 @@ throwAndCatch e =

-- | Handle an error from 'awaitSlot' by wrapping it in the 'AContractError'
-- constructor
catchContractError :: (AsMyError e, HasAwaitSlot s) => Contract () s e ()
catchContractError :: (AsMyError e) => Contract () s e ()
catchContractError =
catching _AContractError
(void $ mapError (review _AContractError) $ awaitSlot 10)
Expand Down
15 changes: 13 additions & 2 deletions plutus-playground-server/usecases/HelloWorld.hs
@@ -1,14 +1,19 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# options_ghc -fno-warn-unused-imports #-}

module HelloWorld where

-- TRIM TO HERE
import qualified Data.Text as T
import Playground.Contract
import Plutus.Contract hiding (when)
import Plutus.Contract
import PlutusTx.Prelude
import qualified Prelude as Haskell

Expand All @@ -19,6 +24,12 @@ hello = logInfo @Haskell.String "Hello, world"
endpoints :: Contract () EmptySchema T.Text ()
endpoints = hello

mkSchemaDefinitions ''EmptySchema
-- 'mkSchemaDefinitions' doesn't work with 'EmptySchema'
-- (that is, with 0 endpoints) so we define a
-- dummy schema type with 1 endpoint to make it compile.
-- TODO: Repair 'mkSchemaDefinitions'
type DummySchema = Endpoint "dummy" ()

mkSchemaDefinitions ''DummySchema

$(mkKnownCurrencies [])
22 changes: 11 additions & 11 deletions plutus-playground-server/usecases/SimulationUtils.hs
Expand Up @@ -2,17 +2,17 @@

module SimulationUtils where

import Ledger.Scripts (ValidatorHash (ValidatorHash))
import Ledger.Value (CurrencySymbol (CurrencySymbol), TokenName, Value)
import qualified Ledger.Value as Value
import Playground.Types (ContractCall (CallEndpoint), FunctionSchema (FunctionSchema),
KnownCurrency (KnownCurrency), SimulatorAction,
SimulatorWallet (SimulatorWallet), argument, argumentValues,
caller, endpointDescription, hash, knownTokens,
simulatorWalletBalance, simulatorWalletWallet)
import Plutus.Contract.Effects.ExposeEndpoint (EndpointDescription)
import Schema (ToArgument, toArgument)
import Wallet.Emulator.Types (Wallet)
import Ledger.Scripts (ValidatorHash (ValidatorHash))
import Ledger.Value (CurrencySymbol (CurrencySymbol), TokenName, Value)
import qualified Ledger.Value as Value
import Playground.Types (ContractCall (CallEndpoint), FunctionSchema (FunctionSchema),
KnownCurrency (KnownCurrency), SimulatorAction,
SimulatorWallet (SimulatorWallet), argument, argumentValues, caller,
endpointDescription, hash, knownTokens, simulatorWalletBalance,
simulatorWalletWallet)
import Schema (ToArgument, toArgument)
import Wallet.Emulator.Types (Wallet)
import Wallet.Types (EndpointDescription)

callEndpoint :: ToArgument a => Wallet -> EndpointDescription -> a -> SimulatorAction
callEndpoint caller endpointDescription param =
Expand Down
12 changes: 3 additions & 9 deletions plutus-playground-server/usecases/Vesting.hs
Expand Up @@ -32,7 +32,7 @@ import qualified Ledger.Typed.Scripts as Scripts
import Ledger.Value (Value)
import qualified Ledger.Value as Value
import Playground.Contract
import Plutus.Contract hiding (when)
import Plutus.Contract
import qualified Plutus.Contract.Typed.Tx as Typed
import qualified PlutusTx
import PlutusTx.Prelude hiding (Semigroup (..), fold)
Expand Down Expand Up @@ -160,9 +160,7 @@ payIntoContract :: Value -> TxConstraints () ()
payIntoContract = mustPayToTheScript ()

vestFundsC
:: ( HasWriteTx s
)
=> VestingParams
:: VestingParams
-> Contract () s T.Text ()
vestFundsC vesting = do
let tx = payIntoContract (totalAmount vesting)
Expand All @@ -171,11 +169,7 @@ vestFundsC vesting = do
data Liveness = Alive | Dead

retrieveFundsC
:: ( HasAwaitSlot s
, HasUtxoAt s
, HasWriteTx s
)
=> VestingParams
:: VestingParams
-> Value
-> Contract () s T.Text Liveness
retrieveFundsC vesting payment = do
Expand Down

0 comments on commit 59054fb

Please sign in to comment.