| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Convex.TestingInterface.Trace.RedeemerTag
Description
Build a RedeemerTagger for the opt-in redeemer labels streamed by
--streaming-json (the redeemerKind / redeemerPayload fields on each
script input).
The RedeemerTagger is a method on the TestingInterface class with a no-op
default, so you only need one of the helpers below when you actually want
human-readable redeemer labels in the stream. The tagger is handed the redeemer
as Plutus Data, so it behaves the same for Plutus and Aiken validators
provided the Haskell side has a FromData instance for the redeemer type.
autoRedeemerTagdecodes the redeemer and labels it with itsshowoutput. That is enough for plain enumerations such asPing | Pong | Stop, where the constructor name is the label you want.labelRedeemerdecodes the redeemer and runs your own function over it, so you control both the label and an optional JSON payload. Reach for it whenshowis not a clean label (for example a single-constructor record) or when you want the redeemer's fields attached as payload.
If neither fits, build a RedeemerTagger straight from any
'Data -> Maybe RedeemerTag' function; AikenBankSpec shows this by matching on
Constr indices by hand.
The PingPongSpec is the simplest end-to-end example:
instance TestingInterface MyModel where redeemerTagger = autoRedeemerTag (Proxy @MyRedeemer)
Synopsis
- autoRedeemerTag :: forall r proxy. (FromData r, Show r) => proxy r -> RedeemerTagger
- labelRedeemer :: forall r proxy. FromData r => proxy r -> (r -> RedeemerTag) -> RedeemerTagger
Documentation
autoRedeemerTag :: forall r proxy. (FromData r, Show r) => proxy r -> RedeemerTagger Source #
labelRedeemer :: forall r proxy. FromData r => proxy r -> (r -> RedeemerTag) -> RedeemerTagger Source #
Decode the redeemer as r and turn it into a RedeemerTag with a
user-supplied function, giving full control over the label and an optional
JSON payload.
Returns Nothing when the Data does not decode as r.