From 05a9977e6fec95a8e8c8a355732f43e92aa71715 Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Fri, 30 Jan 2026 14:27:00 +0100 Subject: [PATCH 1/2] GHC 9.12 support --- .github/workflows/haskell.yml | 2 +- cabal.project | 29 +++++++++++++++++++++++++++++ cardano-api/cardano-api.cabal | 6 +++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 87850a7a86..e11abb4edf 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.6", "9.10"] + ghc: ["9.6", "9.10", "9.12"] cabal: ["3.14"] sys: - { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' } diff --git a/cabal.project b/cabal.project index cc71f29c10..ea21bab4d7 100644 --- a/cabal.project +++ b/cabal.project @@ -51,10 +51,14 @@ write-ghc-environment-files: always jobs: $ncpus semaphore: True + if impl (ghc >= 9.12) allow-newer: -- https://github.com/kapralVV/Unique/issues/11 , Unique:hashable + , proto-lens-arbitrary:QuickCheck + , io-classes + , typed-protocols -- WASM compilation specific @@ -160,6 +164,31 @@ if arch(wasm32) package digest flags: -pkg-config +-- GHC 9.12 support https://github.com/google/proto-lens/pull/519 +source-repository-package + type: git + location: https://github.com/tonyalaribe/proto-lens + tag: da3a3c7d8f43b7b22a3325a6706eb2aad98f41be + --sha256: sha256-Ac3hhsisXIyGyfscnM036tQF8ctru+22zfOlHYJecTs= + subdir: + discrimination-ieee754 + proto-lens-arbitrary + proto-lens-benchmarks + proto-lens-discrimination + proto-lens-optparse + proto-lens-protobuf-types + proto-lens-protoc + proto-lens-runtime + proto-lens-setup + proto-lens-tests-dep + proto-lens-tests + +-- unreleased master of https://github.com/google/ghc-source-gen +source-repository-package + type: git + location: https://github.com/google/ghc-source-gen.git + tag: 79ecc01213131da03a7198fc377606ce72ac037a + --sha256: sha256-TsPEK0I5c9FYqZp0lAzQNogqEv1LPMzdjFO9EtOm/Ls= -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index 8b994a8153..9ee7fbc9c3 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -38,7 +38,7 @@ common project-config -Wunused-packages common maybe-unix - if !(os(windows)|| arch(wasm32)) + if !(os(windows) || arch(wasm32)) build-depends: unix common maybe-Win32 @@ -46,7 +46,7 @@ common maybe-Win32 build-depends: Win32 common text - if os(osx)&& arch(aarch64) + if os(osx) && arch(aarch64) build-depends: text >=1.2.5.0 else build-depends: text >=2.0 @@ -193,7 +193,7 @@ library time, transformers, transformers-except ^>=0.1.3, - typed-protocols ^>=1.0, + typed-protocols >=1.0, validation, vector, yaml, From c87668091c3e68c6d4ec26247414e4ab49c9ae89 Mon Sep 17 00:00:00 2001 From: Mateusz Galazyn Date: Tue, 3 Feb 2026 23:43:29 +0100 Subject: [PATCH 2/2] Remove usage of overloaded labels --- .../src/Cardano/Rpc/Server/Internal/Node.hs | 5 +- .../Cardano/Rpc/Server/Internal/Orphans.hs | 29 +- .../Rpc/Server/Internal/UtxoRpc/Query.hs | 22 +- .../Rpc/Server/Internal/UtxoRpc/Submit.hs | 6 +- .../Rpc/Server/Internal/UtxoRpc/Type.hs | 311 +++++++++--------- 5 files changed, 192 insertions(+), 181 deletions(-) diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/Node.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/Node.hs index c20e29d337..b633d08314 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/Node.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/Node.hs @@ -3,7 +3,6 @@ {-# LANGUAGE DerivingVia #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} -{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -33,7 +32,7 @@ import Network.GRPC.Spec import Proto.Google.Protobuf.Empty getEraMethod :: MonadRpc e m => Proto Empty -> m (Proto Rpc.CurrentEra) -getEraMethod _ = pure . Proto $ defMessage & #era .~ Rpc.Conway +getEraMethod _ = pure . Proto $ defMessage & Rpc.era .~ Rpc.Conway getProtocolParamsJsonMethod :: MonadRpc e m => Proto Empty -> m (Proto Rpc.ProtocolParamsJson) getProtocolParamsJsonMethod _ = do @@ -52,4 +51,4 @@ getProtocolParamsJsonMethod _ = do pure $ def - & #json .~ BL.toStrict pparamsJson + & Rpc.json .~ BL.toStrict pparamsJson diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/Orphans.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/Orphans.hs index f7c907ac8b..51c63edf59 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/Orphans.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/Orphans.hs @@ -1,7 +1,7 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -15,6 +15,7 @@ import Cardano.Api.Ledger qualified as L import Cardano.Api.Pretty import Cardano.Api.Serialise.Raw import Cardano.Api.Tx +import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as U5c import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as UtxoRpc import RIO hiding (toList) @@ -31,35 +32,37 @@ import Network.GRPC.Spec -- It's easier to use 'Proto a' wrappers for RPC types, because it makes lens automatically available. +-- x = U5c.numerator :: _ + instance Inject (Proto UtxoRpc.RationalNumber) Rational where - inject r = r ^. #numerator . to fromIntegral % r ^. #denominator . to fromIntegral + inject r = r ^. U5c.numerator . to fromIntegral % r ^. UtxoRpc.denominator . to fromIntegral -- NB. this clips value in Integer -> Int64/Word64 conversion here instance Inject Rational (Proto UtxoRpc.RationalNumber) where inject r = defMessage - & #numerator .~ fromIntegral (numerator r) - & #denominator .~ fromIntegral (denominator r) + & U5c.numerator .~ fromIntegral (numerator r) + & U5c.denominator .~ fromIntegral (denominator r) instance Inject (Proto UtxoRpc.ExUnits) L.ExUnits where inject r = L.ExUnits - { L.exUnitsMem = r ^. #memory . to fromIntegral - , L.exUnitsSteps = r ^. #steps . to fromIntegral + { L.exUnitsMem = r ^. U5c.memory . to fromIntegral + , L.exUnitsSteps = r ^. U5c.steps . to fromIntegral } instance Inject L.ExUnits (Proto UtxoRpc.ExUnits) where inject L.ExUnits{L.exUnitsMem = mem, L.exUnitsSteps = steps} = defMessage - & #memory .~ fromIntegral mem - & #steps .~ fromIntegral steps + & U5c.memory .~ fromIntegral mem + & U5c.steps .~ fromIntegral steps -- | Note that conversion is not total in the other direction instance Inject TxIn (Proto UtxoRpc.TxoRef) where inject (TxIn txId' (TxIx txIx)) = defMessage - & #hash .~ serialiseToRawBytes txId' - & #index .~ fromIntegral txIx + & U5c.hash .~ serialiseToRawBytes txId' + & U5c.index .~ fromIntegral txIx instance Message a => Default (Proto a) where def = defMessage @@ -71,12 +74,12 @@ instance Inject Integer (Proto UtxoRpc.BigInt) where inject @Int64 $ fromIntegral int | int < 0 = -- https://www.rfc-editor.org/rfc/rfc8949.html#name-bignums see 3.4.3 for negative integers - defMessage & #bigNInt .~ serialiseToRawBytes (fromIntegral @_ @Natural (-1 - int)) + defMessage & U5c.bigNInt .~ serialiseToRawBytes (fromIntegral @_ @Natural (-1 - int)) | otherwise = - defMessage & #bigUInt .~ serialiseToRawBytes (fromIntegral @_ @Natural int) + defMessage & U5c.bigUInt .~ serialiseToRawBytes (fromIntegral @_ @Natural int) instance Inject Int64 (Proto UtxoRpc.BigInt) where - inject int = defMessage & #int .~ int + inject int = defMessage & U5c.int .~ int instance Inject L.Coin (Proto UtxoRpc.BigInt) where inject = inject . fromIntegral @_ @Integer diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs index b160e67bbb..96fce5ef35 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs @@ -3,7 +3,6 @@ {-# LANGUAGE DerivingVia #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} -{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -17,6 +16,7 @@ where import Cardano.Api import Cardano.Api.Experimental.Era +import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as U5c import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as UtxoRpc import Cardano.Rpc.Server.Internal.Error import Cardano.Rpc.Server.Internal.Monad @@ -52,8 +52,8 @@ readParamsMethod _req = do pure $ def - & #ledgerTip .~ mkChainPointMsg chainPoint blockNo - & #values . #cardano .~ obtainCommonConstraints eon (protocolParamsToUtxoRpcPParams eon pparams) + & U5c.ledgerTip .~ mkChainPointMsg chainPoint blockNo + & U5c.values . U5c.cardano .~ obtainCommonConstraints eon (protocolParamsToUtxoRpcPParams eon pparams) readUtxosMethod :: MonadRpc e m @@ -61,11 +61,11 @@ readUtxosMethod -> m (Proto UtxoRpc.ReadUtxosResponse) readUtxosMethod req = do utxoFilter <- - if not (null $ req ^. #keys) - then QueryUTxOByTxIn . fromList <$> mapM txoRefToTxIn (req ^. #keys) + if not (null $ req ^. U5c.keys) + then QueryUTxOByTxIn . fromList <$> mapM txoRefToTxIn (req ^. U5c.keys) -- TODO: reimplement this part as SearchUtxosRequest - -- \| Just addressesProto <- req ^. #maybe'cardanoAddresses -> - -- QueryUTxOByAddress . fromList <$> mapM readAddress (addressesProto ^. #items) + -- \| Just addressesProto <- req ^. U5c.maybe'cardanoAddresses -> + -- QueryUTxOByAddress . fromList <$> mapM readAddress (addressesProto ^. U5c.items) else pure QueryUTxOWhole nodeConnInfo <- grab @@ -81,13 +81,13 @@ readUtxosMethod req = do pure $ defMessage - & #ledgerTip .~ mkChainPointMsg chainPoint blockNo - & #items .~ obtainCommonConstraints eon (utxoToUtxoRpcAnyUtxoData utxo) + & U5c.ledgerTip .~ mkChainPointMsg chainPoint blockNo + & U5c.items .~ obtainCommonConstraints eon (utxoToUtxoRpcAnyUtxoData utxo) where txoRefToTxIn :: MonadRpc e m => Proto UtxoRpc.TxoRef -> m TxIn txoRefToTxIn r = do - txId' <- throwEither $ deserialiseFromRawBytes AsTxId $ r ^. #hash - pure $ TxIn txId' (TxIx . fromIntegral $ r ^. #index) + txId' <- throwEither $ deserialiseFromRawBytes AsTxId $ r ^. U5c.hash + pure $ TxIn txId' (TxIx . fromIntegral $ r ^. U5c.index) -- TODO: reimplement this part as SearchUtxosRequest -- readAddress :: MonadRpc e m => ByteString -> m AddressAny diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Submit.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Submit.hs index 05fd483599..ff8a807ab5 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Submit.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Submit.hs @@ -4,7 +4,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -16,6 +15,7 @@ where import Cardano.Api import Cardano.Api.Network.IPC qualified as Net.Tx +import Cardano.Rpc.Proto.Api.UtxoRpc.Submit qualified as U5c import Cardano.Rpc.Proto.Api.UtxoRpc.Submit qualified as UtxoRpc import Cardano.Rpc.Server.Internal.Error import Cardano.Rpc.Server.Internal.Monad @@ -42,11 +42,11 @@ submitTxMethod req = do putTraceThrowEither . first TraceRpcSubmitTxDecodingError . deserialiseTx eon - $ req ^. #tx . #raw + $ req ^. U5c.tx . U5c.raw txId' <- submitTx eon tx - pure $ def & #ref .~ serialiseToRawBytes txId' + pure $ def & U5c.ref .~ serialiseToRawBytes txId' where deserialiseTx :: ShelleyBasedEra era -> ByteString -> Either DecoderError (Tx era) deserialiseTx sbe = shelleyBasedEraConstraints sbe $ deserialiseFromCBOR asType diff --git a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs index d55b1cabf1..ba55a0ef73 100644 --- a/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs +++ b/cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs @@ -4,7 +4,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -36,6 +35,7 @@ import Cardano.Api.Serialise.Cbor import Cardano.Api.Serialise.Raw import Cardano.Api.Tx import Cardano.Api.Value +import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as U5c import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as UtxoRpc import Cardano.Rpc.Server.Internal.Orphans () @@ -71,36 +71,40 @@ protocolParamsToUtxoRpcPParams era pparams = obtainCommonConstraints era $ do drepVotingThresholds :: L.DRepVotingThresholds = pparams ^. L.ppDRepVotingThresholdsL def - & #coinsPerUtxoByte .~ pparams ^. L.ppCoinsPerUTxOByteL . to L.unCoinPerByte . to inject - & #maxTxSize .~ pparams ^. L.ppMaxTxSizeL . to fromIntegral - & #minFeeCoefficient .~ pparams ^. L.ppMinFeeBL . to inject - & #minFeeConstant .~ pparams ^. L.ppMinFeeAL . to inject - & #maxBlockBodySize .~ pparams ^. L.ppMaxBBSizeL . to fromIntegral - & #maxBlockHeaderSize .~ pparams ^. L.ppMaxBHSizeL . to fromIntegral - & #stakeKeyDeposit .~ pparams ^. L.ppKeyDepositL . to inject - & #poolDeposit .~ pparams ^. L.ppPoolDepositL . to inject - & #poolRetirementEpochBound .~ pparams ^. L.ppEMaxL . to L.unEpochInterval . to fromIntegral - & #desiredNumberOfPools .~ pparams ^. L.ppNOptL . to fromIntegral - & #poolInfluence .~ pparams ^. L.ppA0L . to L.unboundRational . to inject - & #monetaryExpansion .~ pparams ^. L.ppRhoL . to L.unboundRational . to inject - & #treasuryExpansion .~ pparams ^. L.ppTauL . to L.unboundRational . to inject - & #minPoolCost .~ pparams ^. L.ppMinPoolCostL . to inject - & #protocolVersion . #major .~ pparams ^. L.ppProtocolVersionL . to L.pvMajor . to L.getVersion - & #protocolVersion . #minor .~ pparams ^. L.ppProtocolVersionL . to L.pvMinor . to fromIntegral - & #maxValueSize .~ pparams ^. L.ppMaxValSizeL . to fromIntegral - & #collateralPercentage .~ pparams ^. L.ppCollateralPercentageL . to fromIntegral - & #maxCollateralInputs .~ pparams ^. L.ppMaxCollateralInputsL . to fromIntegral - & #costModels . #plutusV1 . #values .~ (join . maybeToList) (M.lookup L.PlutusV1 pparamsCostModels) - & #costModels . #plutusV2 . #values .~ (join . maybeToList) (M.lookup L.PlutusV2 pparamsCostModels) - & #costModels . #plutusV3 . #values .~ (join . maybeToList) (M.lookup L.PlutusV3 pparamsCostModels) - & #costModels . #plutusV4 . #values .~ (join . maybeToList) (M.lookup L.PlutusV4 pparamsCostModels) - & #prices . #steps .~ pparams ^. L.ppPricesL . to L.prSteps . to L.unboundRational . to inject - & #prices . #memory .~ pparams ^. L.ppPricesL . to L.prMem . to L.unboundRational . to inject - & #maxExecutionUnitsPerTransaction .~ pparams ^. L.ppMaxTxExUnitsL . to inject - & #maxExecutionUnitsPerBlock .~ pparams ^. L.ppMaxBlockExUnitsL . to inject - & #minFeeScriptRefCostPerByte + & U5c.coinsPerUtxoByte .~ pparams ^. L.ppCoinsPerUTxOByteL . to L.unCoinPerByte . to inject + & U5c.maxTxSize .~ pparams ^. L.ppMaxTxSizeL . to fromIntegral + & U5c.minFeeCoefficient .~ pparams ^. L.ppMinFeeBL . to inject + & U5c.minFeeConstant .~ pparams ^. L.ppMinFeeAL . to inject + & U5c.maxBlockBodySize .~ pparams ^. L.ppMaxBBSizeL . to fromIntegral + & U5c.maxBlockHeaderSize .~ pparams ^. L.ppMaxBHSizeL . to fromIntegral + & U5c.stakeKeyDeposit .~ pparams ^. L.ppKeyDepositL . to inject + & U5c.poolDeposit .~ pparams ^. L.ppPoolDepositL . to inject + & U5c.poolRetirementEpochBound .~ pparams ^. L.ppEMaxL . to L.unEpochInterval . to fromIntegral + & U5c.desiredNumberOfPools .~ pparams ^. L.ppNOptL . to fromIntegral + & U5c.poolInfluence .~ pparams ^. L.ppA0L . to L.unboundRational . to inject + & U5c.monetaryExpansion .~ pparams ^. L.ppRhoL . to L.unboundRational . to inject + & U5c.treasuryExpansion .~ pparams ^. L.ppTauL . to L.unboundRational . to inject + & U5c.minPoolCost .~ pparams ^. L.ppMinPoolCostL . to inject + & U5c.protocolVersion . U5c.major .~ pparams ^. L.ppProtocolVersionL . to L.pvMajor . to L.getVersion + & U5c.protocolVersion . U5c.minor .~ pparams ^. L.ppProtocolVersionL . to L.pvMinor . to fromIntegral + & U5c.maxValueSize .~ pparams ^. L.ppMaxValSizeL . to fromIntegral + & U5c.collateralPercentage .~ pparams ^. L.ppCollateralPercentageL . to fromIntegral + & U5c.maxCollateralInputs .~ pparams ^. L.ppMaxCollateralInputsL . to fromIntegral + & U5c.costModels . U5c.plutusV1 . U5c.values + .~ (join . maybeToList) (M.lookup L.PlutusV1 pparamsCostModels) + & U5c.costModels . U5c.plutusV2 . U5c.values + .~ (join . maybeToList) (M.lookup L.PlutusV2 pparamsCostModels) + & U5c.costModels . U5c.plutusV3 . U5c.values + .~ (join . maybeToList) (M.lookup L.PlutusV3 pparamsCostModels) + & U5c.costModels . U5c.plutusV4 . U5c.values + .~ (join . maybeToList) (M.lookup L.PlutusV4 pparamsCostModels) + & U5c.prices . U5c.steps .~ pparams ^. L.ppPricesL . to L.prSteps . to L.unboundRational . to inject + & U5c.prices . U5c.memory .~ pparams ^. L.ppPricesL . to L.prMem . to L.unboundRational . to inject + & U5c.maxExecutionUnitsPerTransaction .~ pparams ^. L.ppMaxTxExUnitsL . to inject + & U5c.maxExecutionUnitsPerBlock .~ pparams ^. L.ppMaxBlockExUnitsL . to inject + & U5c.minFeeScriptRefCostPerByte .~ pparams ^. L.ppMinFeeRefScriptCostPerByteL . to L.unboundRational . to inject - & #poolVotingThresholds . #thresholds + & U5c.poolVotingThresholds . U5c.thresholds .~ ( inject . L.unboundRational -- order taken from https://github.com/cardano-foundation/CIPs/blob/acb4b2348c968003dfc370cd3769615bfca1f159/CIP-1694/README.md#requirements <$> [ poolVotingThresholds ^. L.pvtMotionNoConfidenceL @@ -110,7 +114,7 @@ protocolParamsToUtxoRpcPParams era pparams = obtainCommonConstraints era $ do , poolVotingThresholds ^. L.pvtPPSecurityGroupL ] ) - & #drepVotingThresholds . #thresholds + & U5c.drepVotingThresholds . U5c.thresholds .~ ( inject . L.unboundRational -- order taken from https://github.com/cardano-foundation/CIPs/blob/acb4b2348c968003dfc370cd3769615bfca1f159/CIP-1694/README.md#requirements <$> [ drepVotingThresholds ^. L.dvtMotionNoConfidenceL @@ -125,14 +129,14 @@ protocolParamsToUtxoRpcPParams era pparams = obtainCommonConstraints era $ do , drepVotingThresholds ^. L.dvtTreasuryWithdrawalL ] ) - & #minCommitteeSize .~ pparams ^. L.ppCommitteeMinSizeL . to fromIntegral - & #committeeTermLimit + & U5c.minCommitteeSize .~ pparams ^. L.ppCommitteeMinSizeL . to fromIntegral + & U5c.committeeTermLimit .~ pparams ^. L.ppCommitteeMaxTermLengthL . to L.unEpochInterval . to fromIntegral - & #governanceActionValidityPeriod + & U5c.governanceActionValidityPeriod .~ pparams ^. L.ppGovActionLifetimeL . to L.unEpochInterval . to fromIntegral - & #governanceActionDeposit .~ pparams ^. L.ppGovActionDepositL . to inject - & #drepDeposit .~ pparams ^. L.ppDRepDepositL . to inject - & #drepInactivityPeriod .~ pparams ^. L.ppDRepActivityL . to L.unEpochInterval . to fromIntegral + & U5c.governanceActionDeposit .~ pparams ^. L.ppGovActionDepositL . to inject + & U5c.drepDeposit .~ pparams ^. L.ppDRepDepositL . to inject + & U5c.drepInactivityPeriod .~ pparams ^. L.ppDRepActivityL . to L.unEpochInterval . to fromIntegral utxoRpcPParamsToProtocolParams :: Era era @@ -143,51 +147,53 @@ utxoRpcPParamsToProtocolParams era pp = conwayEraOnwardsConstraints (convert era & appFuns [ \r -> do coinsPerUtxoByte <- - pp ^. #coinsPerUtxoByte . to utxoRpcBigIntToInteger ?! "Invalid coinsPerUtxoByte" + pp ^. U5c.coinsPerUtxoByte . to utxoRpcBigIntToInteger ?! "Invalid coinsPerUtxoByte" pure $ set L.ppCoinsPerUTxOByteL (L.CoinPerByte $ L.Coin coinsPerUtxoByte) r - , pure . (L.ppMaxTxSizeL .~ pp ^. #maxTxSize . to fromIntegral) + , pure . (L.ppMaxTxSizeL .~ pp ^. U5c.maxTxSize . to fromIntegral) , \r -> do - minFeeCoeff <- pp ^. #minFeeCoefficient . to utxoRpcBigIntToInteger ?! "Invalid minFeeCoefficient" + minFeeCoeff <- + pp ^. U5c.minFeeCoefficient . to utxoRpcBigIntToInteger ?! "Invalid minFeeCoefficient" pure $ set L.ppMinFeeBL (L.Coin minFeeCoeff) r , \r -> do - minFeeConst <- pp ^. #minFeeConstant . to utxoRpcBigIntToInteger ?! "Invalid minFeeConstant" + minFeeConst <- pp ^. U5c.minFeeConstant . to utxoRpcBigIntToInteger ?! "Invalid minFeeConstant" pure $ set L.ppMinFeeAL (L.Coin minFeeConst) r - , pure . (L.ppMaxBBSizeL .~ pp ^. #maxBlockBodySize . to fromIntegral) - , pure . (L.ppMaxBHSizeL .~ pp ^. #maxBlockHeaderSize . to fromIntegral) + , pure . (L.ppMaxBBSizeL .~ pp ^. U5c.maxBlockBodySize . to fromIntegral) + , pure . (L.ppMaxBHSizeL .~ pp ^. U5c.maxBlockHeaderSize . to fromIntegral) , \r -> do - stakeKeyDeposit <- pp ^. #stakeKeyDeposit . to utxoRpcBigIntToInteger ?! "Invalid stakeKeyDeposit" + stakeKeyDeposit <- + pp ^. U5c.stakeKeyDeposit . to utxoRpcBigIntToInteger ?! "Invalid stakeKeyDeposit" pure $ set L.ppKeyDepositL (L.Coin stakeKeyDeposit) r , \r -> do - poolDeposit <- pp ^. #poolDeposit . to utxoRpcBigIntToInteger ?! "Invalid poolDeposit" + poolDeposit <- pp ^. U5c.poolDeposit . to utxoRpcBigIntToInteger ?! "Invalid poolDeposit" pure $ set L.ppPoolDepositL (L.Coin poolDeposit) r - , pure . (L.ppEMaxL .~ pp ^. #poolRetirementEpochBound . to fromIntegral . to L.EpochInterval) - , pure . (L.ppNOptL .~ pp ^. #desiredNumberOfPools . to fromIntegral) + , pure . (L.ppEMaxL .~ pp ^. U5c.poolRetirementEpochBound . to fromIntegral . to L.EpochInterval) + , pure . (L.ppNOptL .~ pp ^. U5c.desiredNumberOfPools . to fromIntegral) , \r -> do - poolInfluence <- pp ^. #poolInfluence . to inject . to L.boundRational ?! "Invalid poolInfluence" + poolInfluence <- pp ^. U5c.poolInfluence . to inject . to L.boundRational ?! "Invalid poolInfluence" pure $ set L.ppA0L poolInfluence r , \r -> do monetaryExpansion <- - pp ^. #monetaryExpansion . to inject . to L.boundRational ?! "Invalid monetaryExpansion" + pp ^. U5c.monetaryExpansion . to inject . to L.boundRational ?! "Invalid monetaryExpansion" pure $ set L.ppRhoL monetaryExpansion r , \r -> do treasuryExpansion <- - pp ^. #treasuryExpansion . to inject . to L.boundRational ?! "Invalid treasuryExpansion" + pp ^. U5c.treasuryExpansion . to inject . to L.boundRational ?! "Invalid treasuryExpansion" pure $ set L.ppTauL treasuryExpansion r , \r -> do - minPoolCost <- pp ^. #minPoolCost . to utxoRpcBigIntToInteger ?! "Invalid minPoolCost" + minPoolCost <- pp ^. U5c.minPoolCost . to utxoRpcBigIntToInteger ?! "Invalid minPoolCost" pure $ set L.ppMinPoolCostL (L.Coin minPoolCost) r , \r -> do - major <- L.mkVersion64 $ pp ^. #protocolVersion . #major . to fromIntegral + major <- L.mkVersion64 $ pp ^. U5c.protocolVersion . U5c.major . to fromIntegral pure $ set (L.ppProtocolVersionL . pvMajorL) major r - , pure . (L.ppProtocolVersionL . pvMinorL .~ pp ^. #protocolVersion . #minor . to fromIntegral) - , pure . (L.ppMaxValSizeL .~ pp ^. #maxValueSize . to fromIntegral) - , pure . (L.ppCollateralPercentageL .~ pp ^. #collateralPercentage . to fromIntegral) - , pure . (L.ppMaxCollateralInputsL .~ pp ^. #maxCollateralInputs . to fromIntegral) + , pure . (L.ppProtocolVersionL . pvMinorL .~ pp ^. U5c.protocolVersion . U5c.minor . to fromIntegral) + , pure . (L.ppMaxValSizeL .~ pp ^. U5c.maxValueSize . to fromIntegral) + , pure . (L.ppCollateralPercentageL .~ pp ^. U5c.collateralPercentage . to fromIntegral) + , pure . (L.ppMaxCollateralInputsL .~ pp ^. U5c.maxCollateralInputs . to fromIntegral) , \r -> first show $ do - cm1 <- L.mkCostModel L.PlutusV1 $ pp ^. #costModels . #plutusV1 . #values - cm2 <- L.mkCostModel L.PlutusV2 $ pp ^. #costModels . #plutusV2 . #values - cm3 <- L.mkCostModel L.PlutusV3 $ pp ^. #costModels . #plutusV3 . #values - cm4 <- L.mkCostModel L.PlutusV4 $ pp ^. #costModels . #plutusV4 . #values + cm1 <- L.mkCostModel L.PlutusV1 $ pp ^. U5c.costModels . U5c.plutusV1 . U5c.values + cm2 <- L.mkCostModel L.PlutusV2 $ pp ^. U5c.costModels . U5c.plutusV2 . U5c.values + cm3 <- L.mkCostModel L.PlutusV3 $ pp ^. U5c.costModels . U5c.plutusV3 . U5c.values + cm4 <- L.mkCostModel L.PlutusV4 $ pp ^. U5c.costModels . U5c.plutusV4 . U5c.values -- do not add empty cost models let nonEmptyCostModels = fromList . flip mapMaybe [cm1, cm2, cm3, cm4] $ \cm -> @@ -197,21 +203,24 @@ utxoRpcPParamsToProtocolParams era pp = conwayEraOnwardsConstraints (convert era pure $ r & L.ppCostModelsL .~ L.mkCostModels nonEmptyCostModels , \r -> do - steps <- pp ^. #prices . #steps . to inject . to L.boundRational ?! "Invalid prices.steps" - mem <- pp ^. #prices . #memory . to inject . to L.boundRational ?! "Invalid prices.mem" + steps <- pp ^. U5c.prices . U5c.steps . to inject . to L.boundRational ?! "Invalid prices.steps" + mem <- pp ^. U5c.prices . U5c.memory . to inject . to L.boundRational ?! "Invalid prices.mem" pure $ r & L.ppPricesL . prStepsL .~ steps & L.ppPricesL . prMemL .~ mem - , pure . (L.ppMaxTxExUnitsL .~ pp ^. #maxExecutionUnitsPerTransaction . to inject) - , pure . (L.ppMaxBlockExUnitsL .~ pp ^. #maxExecutionUnitsPerBlock . to inject) + , pure . (L.ppMaxTxExUnitsL .~ pp ^. U5c.maxExecutionUnitsPerTransaction . to inject) + , pure . (L.ppMaxBlockExUnitsL .~ pp ^. U5c.maxExecutionUnitsPerBlock . to inject) , \r -> do minFeeScriptRefCostPerByte <- pp - ^. #minFeeScriptRefCostPerByte . to inject . to L.boundRational ?! "Invalid minFeeScriptRefCostPerByte" + ^. U5c.minFeeScriptRefCostPerByte + . to inject + . to L.boundRational + ?! "Invalid minFeeScriptRefCostPerByte" pure $ set L.ppMinFeeRefScriptCostPerByteL minFeeScriptRefCostPerByte r , \r -> do - let thresholds = pp ^. #poolVotingThresholds . #thresholds + let thresholds = pp ^. U5c.poolVotingThresholds . U5c.thresholds when (length thresholds /= 5) $ throwError $ "Invalid number of thresholds: " <> show (length thresholds) @@ -238,7 +247,7 @@ utxoRpcPParamsToProtocolParams era pp = conwayEraOnwardsConstraints (convert era & L.ppPoolVotingThresholdsL . L.pvtHardForkInitiationL .~ hardForkInitiation & L.ppPoolVotingThresholdsL . L.pvtPPSecurityGroupL .~ ppSecurityGroup , \r -> do - let thresholds = pp ^. #drepVotingThresholds . #thresholds + let thresholds = pp ^. U5c.drepVotingThresholds . U5c.thresholds when (length thresholds /= 10) $ throwError $ "Invalid number of thresholds: " <> show (length thresholds) @@ -279,21 +288,21 @@ utxoRpcPParamsToProtocolParams era pp = conwayEraOnwardsConstraints (convert era & L.ppDRepVotingThresholdsL . L.dvtPPTechnicalGroupL .~ ppTechnicalGroup & L.ppDRepVotingThresholdsL . L.dvtPPGovGroupL .~ ppGovGroup & L.ppDRepVotingThresholdsL . L.dvtTreasuryWithdrawalL .~ treasuryWithdrawal - , pure . (L.ppCommitteeMinSizeL .~ pp ^. #minCommitteeSize . to fromIntegral) + , pure . (L.ppCommitteeMinSizeL .~ pp ^. U5c.minCommitteeSize . to fromIntegral) , pure - . (L.ppCommitteeMaxTermLengthL .~ pp ^. #committeeTermLimit . to fromIntegral . to L.EpochInterval) + . (L.ppCommitteeMaxTermLengthL .~ pp ^. U5c.committeeTermLimit . to fromIntegral . to L.EpochInterval) , pure . ( L.ppGovActionLifetimeL - .~ pp ^. #governanceActionValidityPeriod . to fromIntegral . to L.EpochInterval + .~ pp ^. U5c.governanceActionValidityPeriod . to fromIntegral . to L.EpochInterval ) , \r -> do govActionDeposit <- - pp ^. #governanceActionDeposit . to utxoRpcBigIntToInteger ?! "Invalid governanceActionDeposit" + pp ^. U5c.governanceActionDeposit . to utxoRpcBigIntToInteger ?! "Invalid governanceActionDeposit" pure $ set L.ppGovActionDepositL (L.Coin govActionDeposit) r , \r -> do - drepDeposit <- pp ^. #drepDeposit . to utxoRpcBigIntToInteger ?! "Invalid drepDeposit" + drepDeposit <- pp ^. U5c.drepDeposit . to utxoRpcBigIntToInteger ?! "Invalid drepDeposit" pure $ set L.ppDRepDepositL (L.Coin drepDeposit) r - , pure . (L.ppDRepActivityL .~ pp ^. #drepInactivityPeriod . to fromIntegral . to L.EpochInterval) + , pure . (L.ppDRepActivityL .~ pp ^. U5c.drepInactivityPeriod . to fromIntegral . to L.EpochInterval) ] where -- Run a list of functions feeding the output of one to the next @@ -324,28 +333,28 @@ mkChainPointMsg chainPoint blockNo = do Origin -> 0 At (BlockNo h) -> h defMessage - & #slot .~ slotNo - & #hash .~ blockHash - & #height .~ blockHeight + & U5c.slot .~ slotNo + & U5c.hash .~ blockHash + & U5c.height .~ blockHeight simpleScriptToUtxoRpcNativeScript :: SimpleScript -> Proto UtxoRpc.NativeScript simpleScriptToUtxoRpcNativeScript = \case RequireSignature paymentKeyHash -> - defMessage & #scriptPubkeyHash .~ serialiseToRawBytes paymentKeyHash + defMessage & U5c.scriptPubkeyHash .~ serialiseToRawBytes paymentKeyHash RequireTimeBefore (SlotNo slotNo) -> - defMessage & #invalidHereafter .~ slotNo + defMessage & U5c.invalidHereafter .~ slotNo RequireTimeAfter (SlotNo slotNo) -> - defMessage & #invalidBefore .~ slotNo + defMessage & U5c.invalidBefore .~ slotNo RequireAllOf scripts -> - defMessage & #scriptAll . #items .~ map simpleScriptToUtxoRpcNativeScript scripts + defMessage & U5c.scriptAll . U5c.items .~ map simpleScriptToUtxoRpcNativeScript scripts RequireAnyOf scripts -> - defMessage & #scriptAny . #items .~ map simpleScriptToUtxoRpcNativeScript scripts + defMessage & U5c.scriptAny . U5c.items .~ map simpleScriptToUtxoRpcNativeScript scripts RequireMOf k scripts -> do let nScriptsOf = defMessage - & #k .~ fromIntegral k - & #scripts .~ map simpleScriptToUtxoRpcNativeScript scripts - defMessage & #scriptNOfK .~ nScriptsOf + & U5c.k .~ fromIntegral k + & U5c.scripts .~ map simpleScriptToUtxoRpcNativeScript scripts + defMessage & U5c.scriptNOfK .~ nScriptsOf utxoRpcNativeScriptToSimpleScript :: HasCallStack @@ -353,24 +362,24 @@ utxoRpcNativeScriptToSimpleScript => Proto UtxoRpc.NativeScript -> m SimpleScript utxoRpcNativeScriptToSimpleScript scriptRpc - | Just paymentKeyHash <- scriptRpc ^. #maybe'scriptPubkeyHash = + | Just paymentKeyHash <- scriptRpc ^. U5c.maybe'scriptPubkeyHash = RequireSignature <$> liftEitherError (deserialiseFromRawBytes asType paymentKeyHash) - | Just slotNo <- scriptRpc ^. #maybe'invalidHereafter = + | Just slotNo <- scriptRpc ^. U5c.maybe'invalidHereafter = pure . RequireTimeBefore $ SlotNo slotNo - | Just slotNo <- scriptRpc ^. #maybe'invalidBefore = + | Just slotNo <- scriptRpc ^. U5c.maybe'invalidBefore = pure . RequireTimeAfter $ SlotNo slotNo - | Just scriptsRpc <- scriptRpc ^. #maybe'scriptAll = do + | Just scriptsRpc <- scriptRpc ^. U5c.maybe'scriptAll = do fmap RequireAllOf $ mapM utxoRpcNativeScriptToSimpleScript $ - scriptsRpc ^. #items - | Just scriptsRpc <- scriptRpc ^. #maybe'scriptAny = do + scriptsRpc ^. U5c.items + | Just scriptsRpc <- scriptRpc ^. U5c.maybe'scriptAny = do fmap RequireAnyOf $ mapM utxoRpcNativeScriptToSimpleScript $ - scriptsRpc ^. #items - | Just scriptsRpc <- scriptRpc ^. #maybe'scriptNOfK = do - fmap (RequireMOf . fromIntegral $ scriptsRpc ^. #k) $ + scriptsRpc ^. U5c.items + | Just scriptsRpc <- scriptRpc ^. U5c.maybe'scriptNOfK = do + fmap (RequireMOf . fromIntegral $ scriptsRpc ^. U5c.k) $ mapM utxoRpcNativeScriptToSimpleScript $ - scriptsRpc ^. #scripts + scriptsRpc ^. U5c.scripts | otherwise = throwM . stringException $ "Cannot decode UTxORPC NativeScript" referenceScriptToUtxoRpcScript :: ReferenceScript era -> Proto UtxoRpc.Script @@ -378,15 +387,15 @@ referenceScriptToUtxoRpcScript ReferenceScriptNone = defMessage referenceScriptToUtxoRpcScript (ReferenceScript _ (ScriptInAnyLang _ script)) = case script of SimpleScript ss -> - defMessage & #native .~ simpleScriptToUtxoRpcNativeScript ss + defMessage & U5c.native .~ simpleScriptToUtxoRpcNativeScript ss PlutusScript PlutusScriptV1 ps -> - defMessage & #plutusV1 .~ serialiseToRawBytes ps + defMessage & U5c.plutusV1 .~ serialiseToRawBytes ps PlutusScript PlutusScriptV2 ps -> - defMessage & #plutusV2 .~ serialiseToRawBytes ps + defMessage & U5c.plutusV2 .~ serialiseToRawBytes ps PlutusScript PlutusScriptV3 ps -> - defMessage & #plutusV3 .~ serialiseToRawBytes ps + defMessage & U5c.plutusV3 .~ serialiseToRawBytes ps PlutusScript PlutusScriptV4 ps -> - defMessage & #plutusV4 .~ serialiseToRawBytes ps + defMessage & U5c.plutusV4 .~ serialiseToRawBytes ps utxoRpcScriptToReferenceScript :: forall era m @@ -396,19 +405,19 @@ utxoRpcScriptToReferenceScript => Proto UtxoRpc.Script -> m (ReferenceScript era) utxoRpcScriptToReferenceScript protoScript - | Just script <- protoScript ^. #maybe'native = + | Just script <- protoScript ^. U5c.maybe'native = ReferenceScript (convert $ useEra @era) . ScriptInAnyLang SimpleScriptLanguage . SimpleScript <$> utxoRpcNativeScriptToSimpleScript script - | Just script <- protoScript ^. #maybe'plutusV1 = + | Just script <- protoScript ^. U5c.maybe'plutusV1 = ReferenceScript (convert $ useEra @era) . ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV1) <$> liftEitherError (deserialiseFromCBOR asType script) - | Just script <- protoScript ^. #maybe'plutusV2 = + | Just script <- protoScript ^. U5c.maybe'plutusV2 = ReferenceScript (convert $ useEra @era) . ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2) <$> liftEitherError (deserialiseFromCBOR asType script) - | Just script <- protoScript ^. #maybe'plutusV3 = + | Just script <- protoScript ^. U5c.maybe'plutusV3 = ReferenceScript (convert $ useEra @era) . ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV3) <$> liftEitherError (deserialiseFromCBOR asType script) - | Just script <- protoScript ^. #maybe'plutusV4 = + | Just script <- protoScript ^. U5c.maybe'plutusV4 = ReferenceScript (convert $ useEra @era) . ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV4) <$> liftEitherError (deserialiseFromCBOR asType script) | otherwise = pure ReferenceScriptNone @@ -416,28 +425,28 @@ utxoRpcScriptToReferenceScript protoScript scriptDataToUtxoRpcPlutusData :: ScriptData -> Proto UtxoRpc.PlutusData scriptDataToUtxoRpcPlutusData = \case ScriptDataBytes bs -> - defMessage & #boundedBytes .~ bs - ScriptDataNumber int -> defMessage & #bigInt .~ inject int + defMessage & U5c.boundedBytes .~ bs + ScriptDataNumber int -> defMessage & U5c.bigInt .~ inject int ScriptDataList sds -> - defMessage & #array . #items .~ map scriptDataToUtxoRpcPlutusData sds + defMessage & U5c.array . U5c.items .~ map scriptDataToUtxoRpcPlutusData sds ScriptDataMap elements -> do let pairs = elements <&> \(k, v) -> defMessage - & #key .~ scriptDataToUtxoRpcPlutusData k - & #value .~ scriptDataToUtxoRpcPlutusData v - defMessage & #map . #pairs .~ pairs + & U5c.key .~ scriptDataToUtxoRpcPlutusData k + & U5c.value .~ scriptDataToUtxoRpcPlutusData v + defMessage & U5c.map . U5c.pairs .~ pairs ScriptDataConstructor tag args -> do -- Details of plutus tag serialisation: -- https://github.com/IntersectMBO/plutus/blob/fc78c36b545ee287ae8796a0c1a7d04cf31f4cee/plutus-core/plutus-core/src/PlutusCore/Data.hs#L72 let constr = defMessage & ( if tag <= fromIntegral (maxBound @Word32) - then #tag .~ fromIntegral tag - else (#tag .~ 102) . (#anyConstructor .~ fromIntegral @_ @Word64 tag) + then U5c.tag .~ fromIntegral tag + else (U5c.tag .~ 102) . (U5c.anyConstructor .~ fromIntegral @_ @Word64 tag) ) - & #fields .~ map scriptDataToUtxoRpcPlutusData args - defMessage & #constr .~ constr + & U5c.fields .~ map scriptDataToUtxoRpcPlutusData args + defMessage & U5c.constr .~ constr utxoToUtxoRpcAnyUtxoData :: forall era. IsEra era => UTxO era -> [Proto UtxoRpc.AnyUtxoData] utxoToUtxoRpcAnyUtxoData utxo = @@ -448,9 +457,9 @@ utxoToUtxoRpcAnyUtxoData utxo = CBOR.serialize' $ toShelleyTxOut (convert era) txOut defMessage - & #nativeBytes .~ txOutCbor - & #txoRef .~ inject txIn - & #cardano .~ txOutToUtxoRpcTxOutput txOut + & U5c.nativeBytes .~ txOutCbor + & U5c.txoRef .~ inject txIn + & U5c.cardano .~ txOutToUtxoRpcTxOutput txOut anyUtxoDataUtxoRpcToUtxo :: forall era m @@ -466,8 +475,8 @@ anyUtxoDataUtxoRpcToUtxo era = fmap fromList . foldM f mempty -> Proto UtxoRpc.AnyUtxoData -> m [(TxIn, TxOut CtxUTxO era)] f acc e = do - txOut <- obtainCommonConstraints era $ utxoRpcTxOutputToTxOut $ e ^. #cardano - txIn <- txoRefUtxoRpcToTxIn $ e ^. #txoRef + txOut <- obtainCommonConstraints era $ utxoRpcTxOutputToTxOut $ e ^. U5c.cardano + txIn <- txoRefUtxoRpcToTxIn $ e ^. U5c.txoRef pure $ (txIn, txOut) : acc txoRefUtxoRpcToTxIn @@ -480,8 +489,8 @@ txoRefUtxoRpcToTxIn txoRef = do txId' <- liftEitherError $ deserialiseFromRawBytes asType $ - txoRef ^. #hash - pure $ TxIn txId' (TxIx . fromIntegral $ txoRef ^. #index) + txoRef ^. U5c.hash + pure $ TxIn txId' (TxIx . fromIntegral $ txoRef ^. U5c.index) txOutToUtxoRpcTxOutput :: forall era @@ -495,36 +504,36 @@ txOutToUtxoRpcTxOutput (TxOut addressInEra txOutValue datum script) = do let assets = toList policyAssets <&> \(assetName, Quantity qty) -> do defMessage - & #name .~ serialiseToRawBytes assetName + & U5c.name .~ serialiseToRawBytes assetName -- we don't have access to info if the coin was minted in the transaction, -- maybe we should add it later - -- & #maybe'mintCoin .~ Nothing - & #quantity .~ inject qty + -- & U5c.maybe'mintCoin .~ Nothing + & U5c.quantity .~ inject qty defMessage - & #policyId .~ serialiseToRawBytes pId - & #assets .~ assets + & U5c.policyId .~ serialiseToRawBytes pId + & U5c.assets .~ assets datumRpc = case datum of TxOutDatumNone -> Nothing TxOutDatumHash _ scriptDataHash -> Just $ defMessage - & #hash .~ serialiseToRawBytes scriptDataHash - & #maybe'payload .~ Nothing -- we don't have it - & #maybe'originalCbor .~ Nothing + & U5c.hash .~ serialiseToRawBytes scriptDataHash + & U5c.maybe'payload .~ Nothing -- we don't have it + & U5c.maybe'originalCbor .~ Nothing TxOutDatumInline _ hashableScriptData -> Just $ defMessage - & #hash .~ serialiseToCBOR hashableScriptData - & #payload .~ scriptDataToUtxoRpcPlutusData (getScriptData hashableScriptData) - & #originalCbor .~ getOriginalScriptDataBytes hashableScriptData + & U5c.hash .~ serialiseToCBOR hashableScriptData + & U5c.payload .~ scriptDataToUtxoRpcPlutusData (getScriptData hashableScriptData) + & U5c.originalCbor .~ getOriginalScriptDataBytes hashableScriptData defMessage - & #address .~ T.encodeUtf8 (obtainCommonConstraints (useEra @era) $ serialiseAddress addressInEra) - & #coin .~ inject (L.unCoin (txOutValueToLovelace txOutValue)) - & #assets .~ multiAsset - & #maybe'datum .~ datumRpc - & #script .~ referenceScriptToUtxoRpcScript script + & U5c.address .~ T.encodeUtf8 (obtainCommonConstraints (useEra @era) $ serialiseAddress addressInEra) + & U5c.coin .~ inject (L.unCoin (txOutValueToLovelace txOutValue)) + & U5c.assets .~ multiAsset + & U5c.maybe'datum .~ datumRpc + & U5c.script .~ referenceScriptToUtxoRpcScript script utxoRpcTxOutputToTxOut :: forall era m @@ -535,15 +544,15 @@ utxoRpcTxOutputToTxOut -> m (TxOut CtxUTxO era) utxoRpcTxOutputToTxOut txOutput = do let era = useEra @era - addrUtf8 <- liftEitherError $ T.decodeUtf8' (txOutput ^. #address) + addrUtf8 <- liftEitherError $ T.decodeUtf8' (txOutput ^. U5c.address) address <- maybe (throwM . stringException $ "Cannot decode address: " <> T.unpack addrUtf8) pure $ obtainCommonConstraints era $ deserialiseAddress asType addrUtf8 datum <- - case txOutput ^. #maybe'datum of + case txOutput ^. U5c.maybe'datum of Just datumRpc -> - case datumRpc ^. #maybe'originalCbor of + case datumRpc ^. U5c.maybe'originalCbor of Just cbor -> liftEitherError $ TxOutDatumInline (convert era) @@ -551,18 +560,18 @@ utxoRpcTxOutputToTxOut txOutput = do Nothing -> liftEitherError $ TxOutDatumHash (convert era) - <$> deserialiseFromRawBytes asType (datumRpc ^. #hash) + <$> deserialiseFromRawBytes asType (datumRpc ^. U5c.hash) Nothing -> pure TxOutDatumNone - referenceScript <- utxoRpcScriptToReferenceScript (txOutput ^. #script) - coinValue <- lovelaceToValue . L.Coin <$> txOutput ^. #coin . to utxoRpcBigIntToInteger - multiAssetValue <- fmap (fromList @Value . join) . forM (txOutput ^. #assets) $ \policyAssets -> do + referenceScript <- utxoRpcScriptToReferenceScript (txOutput ^. U5c.script) + coinValue <- lovelaceToValue . L.Coin <$> txOutput ^. U5c.coin . to utxoRpcBigIntToInteger + multiAssetValue <- fmap (fromList @Value . join) . forM (txOutput ^. U5c.assets) $ \policyAssets -> do pId <- - liftEitherError $ deserialiseFromRawBytes AsPolicyId (policyAssets ^. #policyId) - forM (policyAssets ^. #assets) $ \asset -> do + liftEitherError $ deserialiseFromRawBytes AsPolicyId (policyAssets ^. U5c.policyId) + forM (policyAssets ^. U5c.assets) $ \asset -> do assetName <- liftEitherError $ - deserialiseFromRawBytes AsAssetName (asset ^. #name) - coin <- Quantity <$> asset ^. #quantity . to utxoRpcBigIntToInteger + deserialiseFromRawBytes AsAssetName (asset ^. U5c.name) + coin <- Quantity <$> asset ^. U5c.quantity . to utxoRpcBigIntToInteger pure (AssetId pId assetName, coin) pure $ TxOut @@ -580,10 +589,10 @@ utxoRpcBigIntToInteger => Proto UtxoRpc.BigInt -> m Integer utxoRpcBigIntToInteger bigInt - | Just int <- bigInt ^. #maybe'int = pure $ fromIntegral int - | Just bytes <- bigInt ^. #maybe'bigNInt = do + | Just int <- bigInt ^. U5c.maybe'int = pure $ fromIntegral int + | Just bytes <- bigInt ^. U5c.maybe'bigNInt = do n <- fmap fromIntegral . liftEitherError $ deserialiseFromRawBytes AsNatural bytes pure $ -n - 1 - | Just bytes <- bigInt ^. #maybe'bigUInt = + | Just bytes <- bigInt ^. U5c.maybe'bigUInt = fmap fromIntegral . liftEitherError $ deserialiseFromRawBytes AsNatural bytes | otherwise = pure 0 -- assume default value