IntersectMBO / plutus-apps

The Plutus application platform
Apache License 2.0
305 stars 213 forks source link

Cant assign `mempty` to a `ScriptLookups` #440

Open DrXano opened 2 years ago

DrXano commented 2 years ago

Summary

I wanted to initialise a State machine with runInitialiseWith with a certain Constraint. The first argument of the function is a ScriptLookups and i wanted to assign mempty since i don't want to pass any Lookup. But the playground is telling me this:

    * No instance for (Monoid
                         (Constraints.ScriptLookups
                            (SM.StateMachine CounterTriggerState CounterTriggerInput)))
        arising from a use of `mempty'

I find this weird cause i can start a state machine with runInitialise and the function's source code is this:

runInitialise ::
    forall w e state schema input.
    ( PlutusTx.FromData state
    , PlutusTx.ToData state
    , PlutusTx.ToData input
    , AsSMContractError e
    )
    => StateMachineClient state input
    -- ^ The state machine
    -> state
    -- ^ The initial state
    -> Value
    -- ^ The value locked by the contract at the beginning
    -> Contract w schema e state
runInitialise = runInitialiseWith mempty mempty

Steps to reproduce the behavior

Set some variable of the type ScriptLookups a to mempty in the online Playground.

Actual Result

It tells me there is no Monoid instance for ScriptLookups a.

Expected Result

It should accept mempty.

Describe the approach you would take to fix this

No response

System info

The online Playground

koslambrou commented 2 years ago

ScriptLookups IS a Monoid instance (see module Ledger.Constraints.OffChain in plutus-ledger-constraints.

What's the code giving you this error?

DrXano commented 2 years ago

I am literally just putting mempty in a ScriptLookups variable.

sjoerdvisscher commented 2 years ago

Were you using the mempty from PlutusTx.Prelude perhaps?