IntersectMBO / plutus

The Plutus language implementation and tools
Apache License 2.0
1.55k stars 466 forks source link

Simple and efficient way of accessing the datum and redeemer #6264

Open effectfully opened 5 days ago

effectfully commented 5 days ago

In #6247 @Unisay showed us how to access the datum and redeemer efficiently, but not simply. We could consider adding a dedicated data type for doing this lazy decoding (data JustGiveMeDatumAndRedeemer = <...>), so that unsafeFromBuiltinData does the right thing for it, however we actually probably don't need to, because once @ana-pantilie's work on backing ScriptContext by Data is done we'll probably be able to use the fields of ScriptContext directly (implemented as pattern synonyms, I assume)? Accessing both the datum and redeemer via fields is going to be less efficient than using a dedicated type though, because we'd have to skip the tx info twice for each of them for example, so maybe having a dedicated type is worth it in the end.

This issue is for figuring what interface we should provide for accessing the datum and redeemer, as well as implementing that interface.