diff --git a/code/week04/cabal.project b/code/week04/cabal.project index 0ecddd9..3c020b7 100644 --- a/code/week04/cabal.project +++ b/code/week04/cabal.project @@ -25,7 +25,7 @@ source-repository-package prettyprinter-configurable quickcheck-dynamic word-array - tag: 72bafd845cb39cf08c24d063503b83e2ee5aa5cc + tag: 2fbb7abb22138a434bb6c4f663a81e9b9dc51e98 -- The following sections are copied from the 'plutus' repository cabal.project at the revision -- given above. diff --git a/code/week04/src/Week04/Contract.hs b/code/week04/src/Week04/Contract.hs index 5566b49..a729356 100644 --- a/code/week04/src/Week04/Contract.hs +++ b/code/week04/src/Week04/Contract.hs @@ -19,7 +19,7 @@ import Wallet.Emulator.Wallet myContract1 :: Contract () Empty Text () myContract1 = do void $ Contract.throwError "BOOM!" - Contract.logInfo @String "Hello from the contract!" + Contract.logInfo @String "hello from the contract" myTrace1 :: EmulatorTrace () myTrace1 = void $ activateContractWallet (Wallet 1) myContract1 @@ -29,7 +29,7 @@ test1 = runEmulatorTraceIO myTrace1 myContract2 :: Contract () Empty Void () myContract2 = Contract.handleError - (\err -> Contract.logError $ "Caught error: " ++ unpack err) + (\err -> Contract.logError $ "caught: " ++ unpack err) myContract1 myTrace2 :: EmulatorTrace () @@ -38,17 +38,20 @@ myTrace2 = void $ activateContractWallet (Wallet 1) myContract2 test2 :: IO () test2 = runEmulatorTraceIO myTrace2 -type MySchema = Endpoint "foo" Int +type MySchema = Endpoint "foo" Int .\/ Endpoint "bar" String myContract3 :: Contract () MySchema Text () myContract3 = do n <- endpoint @"foo" Contract.logInfo n + s <- endpoint @"bar" + Contract.logInfo s myTrace3 :: EmulatorTrace () myTrace3 = do h <- activateContractWallet (Wallet 1) myContract3 callEndpoint @"foo" h 42 + callEndpoint @"bar" h "Haskell" test3 :: IO () test3 = runEmulatorTraceIO myTrace3 diff --git a/code/week04/src/Week04/Solution.hs b/code/week04/src/Week04/Solution.hs index 5594401..7ba6f0d 100644 --- a/code/week04/src/Week04/Solution.hs +++ b/code/week04/src/Week04/Solution.hs @@ -35,13 +35,14 @@ payContract = do payTrace :: Integer -> Integer -> EmulatorTrace () payTrace x y = do h <- activateContractWallet (Wallet 1) payContract + let pkh = pubKeyHash $ walletPubKey $ Wallet 2 callEndpoint @"pay" h $ PayParams - { ppRecipient = pubKeyHash $ walletPubKey $ Wallet 2 + { ppRecipient = pkh , ppLovelace = x } void $ Emulator.waitNSlots 1 callEndpoint @"pay" h $ PayParams - { ppRecipient = pubKeyHash $ walletPubKey $ Wallet 2 + { ppRecipient = pkh , ppLovelace = y } void $ Emulator.waitNSlots 1 diff --git a/code/week04/src/Week04/Trace.hs b/code/week04/src/Week04/Trace.hs index 9179827..f4442ac 100644 --- a/code/week04/src/Week04/Trace.hs +++ b/code/week04/src/Week04/Trace.hs @@ -31,4 +31,4 @@ myTrace = do void $ waitUntilSlot 20 callEndpoint @"grab" h2 () s <- waitNSlots 1 - Extras.logInfo $ "reached slot " ++ show s + Extras.logInfo $ "reached " ++ show s