1212module Cardano.Rpc.Server.Internal.Orphans () where
1313
1414import Cardano.Api.Address
15+ import Cardano.Api.Block (SlotNo (.. ))
1516import Cardano.Api.Era
1617import Cardano.Api.Error
1718import Cardano.Api.Ledger qualified as L
1819import Cardano.Api.Plutus
1920import Cardano.Api.Pretty
20- import Cardano.Api.Serialise.Cbor
2121import Cardano.Api.Serialise.Raw
2222import Cardano.Api.Tx
2323import Cardano.Api.Value
@@ -79,8 +79,8 @@ instance Inject (ReferenceScript era) (Proto UtxoRpc.Script) where
7979 inject ReferenceScriptNone = defMessage
8080 inject (ReferenceScript _ (ScriptInAnyLang _ script)) =
8181 case script of
82- SimpleScript _ ->
83- defMessage & # native .~ serialiseToCBOR script
82+ SimpleScript ss ->
83+ defMessage & # native .~ inject ss
8484 PlutusScript PlutusScriptV1 ps ->
8585 defMessage & # plutusV1 .~ serialiseToRawBytes ps
8686 PlutusScript PlutusScriptV2 ps ->
@@ -90,6 +90,25 @@ instance Inject (ReferenceScript era) (Proto UtxoRpc.Script) where
9090 PlutusScript PlutusScriptV4 ps ->
9191 defMessage & # plutusV4 .~ serialiseToRawBytes ps
9292
93+ instance Inject SimpleScript (Proto UtxoRpc. NativeScript ) where
94+ inject = \ case
95+ RequireSignature paymentKeyHash ->
96+ defMessage & # scriptPubkey .~ serialiseToRawBytes paymentKeyHash
97+ RequireTimeBefore (SlotNo slotNo) ->
98+ defMessage & # invalidHereafter .~ slotNo
99+ RequireTimeAfter (SlotNo slotNo) ->
100+ defMessage & # invalidBefore .~ slotNo
101+ RequireAllOf scripts ->
102+ defMessage & # scriptAll . # items .~ map inject scripts
103+ RequireAnyOf scripts ->
104+ defMessage & # scriptAny . # items .~ map inject scripts
105+ RequireMOf k scripts -> do
106+ let nScriptsOf =
107+ defMessage
108+ & # k .~ fromIntegral k
109+ & # scripts .~ map inject scripts
110+ defMessage & # scriptNOfK .~ nScriptsOf
111+
93112instance Inject ScriptData (Proto UtxoRpc. PlutusData ) where
94113 inject = \ case
95114 ScriptDataBytes bs ->
@@ -122,7 +141,7 @@ instance IsCardanoEra era => Inject (UTxO era) [Proto UtxoRpc.AnyUtxoData] where
122141 toList policyAssets <&> \ (assetName, Quantity qty) -> do
123142 defMessage
124143 & # name .~ serialiseToRawBytes assetName
125- -- we don't have access to info it the coin was minted in the transaction,
144+ -- we don't have access to info if the coin was minted in the transaction,
126145 -- maybe we should add it later
127146 & # maybe'mintCoin .~ Nothing
128147 & # outputCoin .~ fromIntegral qty
0 commit comments