@@ -20,6 +20,9 @@ module Cardano.Api.Internal.Experimental.Plutus.IndexedPlutusScriptWitness
2020 , createIndexedPlutusScriptWitnesses
2121 , getAnyWitnessRedeemerPointerMap
2222 , obtainAlonzoScriptPurposeConstraints
23+
24+ -- * Exposed for testing
25+ , constructRedeeemerPointerMap
2326 )
2427where
2528
@@ -48,17 +51,22 @@ import GHC.Exts
4851-- and the index of the thing it is witnessing.
4952data IndexedPlutusScriptWitness witnessable (lang :: L. Language ) (purpose :: PlutusScriptPurpose ) era where
5053 IndexedPlutusScriptWitness
51- :: Witnessable witnessable era
54+ :: L. AlonzoEraScript era
55+ => Witnessable witnessable era
5256 -> (L. PlutusPurpose L. AsIx era )
5357 -> (PlutusScriptWitness lang purpose era )
5458 -> IndexedPlutusScriptWitness witnessable lang purpose era
5559
60+ deriving instance Show (IndexedPlutusScriptWitness witnessable lang purpose era )
61+
5662data AnyIndexedPlutusScriptWitness era where
5763 AnyIndexedPlutusScriptWitness
5864 :: GetPlutusScriptPurpose era
5965 => IndexedPlutusScriptWitness witnessable lang purpose era
6066 -> AnyIndexedPlutusScriptWitness era
6167
68+ deriving instance Show (AnyIndexedPlutusScriptWitness era )
69+
6270-- | These are all of the "things" a plutus script can witness. We include the relevant
6371-- type class constraint to avoid boilerplate when creating the 'PlutusPurpose' in
6472-- the 'GetPlutusScriptPurpose' instances.
@@ -141,7 +149,8 @@ instance GetPlutusScriptPurpose era where
141149 toPlutusScriptPurpose index WitProposal {} = L. mkProposingPurpose (L. AsIx index)
142150
143151createIndexedPlutusScriptWitness
144- :: Word32
152+ :: L. AlonzoEraScript era
153+ => Word32
145154 -> Witnessable witnessable era
146155 -> PlutusScriptWitness lang purpose era
147156 -> IndexedPlutusScriptWitness witnessable lang purpose era
@@ -151,7 +160,8 @@ createIndexedPlutusScriptWitness index witnessable =
151160-- | Create a list of indexed plutus script witnesses from anything witnessable that has been
152161-- witnesseed by a plutus script.
153162createIndexedPlutusScriptWitnesses
154- :: [(Witnessable witnessable era , AnyWitness era )]
163+ :: L. AlonzoEraScript era
164+ => [(Witnessable witnessable era , AnyWitness era )]
155165 -> [AnyIndexedPlutusScriptWitness era ]
156166createIndexedPlutusScriptWitnesses witnessableThings =
157167 [ AnyIndexedPlutusScriptWitness $ createIndexedPlutusScriptWitness index thing sWit
@@ -162,16 +172,15 @@ createIndexedPlutusScriptWitnesses witnessableThings =
162172
163173-- | The transaction's redeemer pointer map allows the ledger to connect a redeemer and execution unit pairing to the relevant
164174-- script. The ledger basically reconstructs the indicies (redeemer pointers) of this map can then look up the relevant
165- -- execution units/redeemer pairing. NB the redeemer pointer has been renamed to 'PlutusPurpose AsIndex' in the ledger.
175+ -- execution units/redeemer pairing. NB: the redeemer pointer has been renamed to 'PlutusPurpose AsIndex' in the ledger.
166176getAnyWitnessRedeemerPointerMap
167177 :: AlonzoEraOnwards era
168- -> (Witnessable witnessable (ShelleyLedgerEra era ), AnyWitness (ShelleyLedgerEra era ))
178+ -> [ (Witnessable witnessable (ShelleyLedgerEra era ), AnyWitness (ShelleyLedgerEra era ))]
169179 -> L. Redeemers (ShelleyLedgerEra era )
170- getAnyWitnessRedeemerPointerMap eon (_, AnyKeyWitnessPlaceholder ) = alonzoEraOnwardsConstraints eon mempty
171- getAnyWitnessRedeemerPointerMap eon (_, AnySimpleScriptWitness {}) = alonzoEraOnwardsConstraints eon mempty
172180getAnyWitnessRedeemerPointerMap eon anyWit =
173181 constructRedeeemerPointerMap eon $
174- createIndexedPlutusScriptWitnesses [anyWit]
182+ alonzoEraOnwardsConstraints eon $
183+ createIndexedPlutusScriptWitnesses anyWit
175184
176185-- | An 'IndexedPlutusScriptWitness' contains everything we need to construct a single
177186-- entry in the redeemer pointer map.
0 commit comments