mirror of
https://github.com/FiloSpaTeam/plutus-pioneer-program.git
synced 2024-11-24 15:52:00 +01:00
updated code
This commit is contained in:
parent
9132d1b281
commit
fdd56c11c3
4 changed files with 11 additions and 7 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue