I'm writing emulator trace tests for the spacebudz contracts. Here is a minimum example:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExtendedDefaultRules #-}
module Test.EmulatorTrace where
import Control.Monad hiding ( fmap )
import Control.Monad.Freer.Extras as Extras
import Data.Default ( Default(..) )
import qualified Data.Map as Map
import Ledger
import Ledger.Ada as Ada
import Ledger.TimeSlot
import Ledger.Value
import Plutus.Contract.Trace
import Plutus.Trace.Emulator as Emulator
import PlutusTx.Prelude
import Prelude ( IO
, Show(..)
)
import Wallet.Emulator.Wallet
import Contract
test :: IO ()
test = do
test'
test' :: IO ()
test' = runEmulatorTraceIO' def def myTrace
myTrace :: EmulatorTrace ()
myTrace = do
h1 <- activateContractWallet (Wallet 1) endpoints
callEndpoint @"init" h1 ()
void $ Emulator.waitNSlots 10
However, when trying to activate the wallets for the emulator, I get this error:
src/Test/EmulatorTrace.hs:45:43: error:
• Ambiguous type variable ‘e0’ arising from a use of ‘endpoints’
prevents the constraint ‘(Wallet.Types.AsContractError
e0)’ from being solved.
Probable fix: use a type annotation to specify what ‘e0’ should be.
These potential instances exist:
two instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the second argument of ‘activateContractWallet’, namely
‘endpoints’
In a stmt of a 'do' block:
h1 <- activateContractWallet (Wallet 1) endpoints
In the expression:
do h1 <- activateContractWallet (Wallet 1) endpoints
callEndpoint @"init" h1 ()
void $ waitNSlots 10
|
45 | h1 <- activateContractWallet (Wallet 1) endpoints
How is it possible, when every contract example has the same code?