No instance for ‘PlutusTx.Eq.Eq ScriptPurpose’ arising from a use of ‘lookup’
Summary
Сan you tell me where I'm wrong in my wishes?
I want to do lookup (Rewarding sc) (txInfoRedeemers $ scriptContextTxInfo ctx), but in pr 6173 delete instance for PlutusTx.Eq.Eq ScriptPurpose
Steps to reproduce the behavior
add line to plutuscript lookup (Rewarding $ ScriptCredential $ ScriptHash hash) (txInfoRedeemers $ scriptContextTxInfo ctx)
Actual Result
error
Expected Result
no errors
Describe the approach you would take to fix this
Bring back the behavior that was there before?
System info
os: Ubuntu 22.04.3 plutus-core: 1.30
@ana-pantilie you're probably equipped best to answer this one.
ScriptPurpose doesn't have an Eq instance anymore because in the case of Proposing scripts we would need to be able to compare Maps, which we decided we cannot do efficiently. @zlonast can you use Foldable.find instead?
Do I understand correctly that you are suggesting something like that? @ana-pantilie
{-# INLINABLE eqCredential #-}
eqCredential :: Credential -> ScriptPurpose -> Bool
eqCredential a (Rewarding b) = a PlutusTx.== b
eqCredential _ _ = Haskell.False
find (eqCredential sc) (keys $ txInfoRedeemers $ scriptContextTxInfo ctx)
@zlonast yes that's what I was thinking of.
Sounds like there's a reasonable workaround and we aren't going to do anything about the issue otherwise, hence I'm closing it. Do feel free to reopen if you feel otherwise.
instance PlutusTx.Eq.Eq ScriptPurpose where
(==) a b = PlutusTx.toBuiltinData a == PlutusTx.toBuiltinData b