1+ {-# LANGUAGE DataKinds #-}
12{-# LANGUAGE FlexibleInstances #-}
23{-# LANGUAGE GADTs #-}
34{-# LANGUAGE MultiParamTypeClasses #-}
4- {-# LANGUAGE OverloadedLabels #-}
55{-# LANGUAGE RankNTypes #-}
66{-# LANGUAGE ScopedTypeVariables #-}
77{-# LANGUAGE TypeApplications #-}
@@ -15,7 +15,7 @@ import Cardano.Api.Ledger qualified as L
1515import Cardano.Api.Pretty
1616import Cardano.Api.Serialise.Raw
1717import Cardano.Api.Tx
18- import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as UtxoRpc
18+ import Cardano.Rpc.Proto.Api.UtxoRpc.Query qualified as U5c
1919
2020import RIO hiding (toList )
2121
@@ -31,54 +31,56 @@ import Network.GRPC.Spec
3131
3232-- It's easier to use 'Proto a' wrappers for RPC types, because it makes lens automatically available.
3333
34- instance Inject (Proto UtxoRpc. RationalNumber ) Rational where
35- inject r = r ^. # numerator . to fromIntegral % r ^. # denominator . to fromIntegral
34+ -- x = U5c.numerator :: _
35+
36+ instance Inject (Proto U5c. RationalNumber ) Rational where
37+ inject r = r ^. U5c. numerator . to fromIntegral % r ^. U5c. denominator . to fromIntegral
3638
3739-- NB. this clips value in Integer -> Int64/Word64 conversion here
38- instance Inject Rational (Proto UtxoRpc . RationalNumber ) where
40+ instance Inject Rational (Proto U5c . RationalNumber ) where
3941 inject r =
4042 defMessage
41- & # numerator .~ fromIntegral (numerator r)
42- & # denominator .~ fromIntegral (denominator r)
43+ & U5c. numerator .~ fromIntegral (numerator r)
44+ & U5c. denominator .~ fromIntegral (denominator r)
4345
44- instance Inject (Proto UtxoRpc . ExUnits ) L. ExUnits where
46+ instance Inject (Proto U5c . ExUnits ) L. ExUnits where
4547 inject r =
4648 L. ExUnits
47- { L. exUnitsMem = r ^. # memory . to fromIntegral
48- , L. exUnitsSteps = r ^. # steps . to fromIntegral
49+ { L. exUnitsMem = r ^. U5c. memory . to fromIntegral
50+ , L. exUnitsSteps = r ^. U5c. steps . to fromIntegral
4951 }
5052
51- instance Inject L. ExUnits (Proto UtxoRpc . ExUnits ) where
53+ instance Inject L. ExUnits (Proto U5c . ExUnits ) where
5254 inject L. ExUnits {L. exUnitsMem = mem, L. exUnitsSteps = steps} =
5355 defMessage
54- & # memory .~ fromIntegral mem
55- & # steps .~ fromIntegral steps
56+ & U5c. memory .~ fromIntegral mem
57+ & U5c. steps .~ fromIntegral steps
5658
5759-- | Note that conversion is not total in the other direction
58- instance Inject TxIn (Proto UtxoRpc . TxoRef ) where
60+ instance Inject TxIn (Proto U5c . TxoRef ) where
5961 inject (TxIn txId' (TxIx txIx)) =
6062 defMessage
61- & # hash .~ serialiseToRawBytes txId'
62- & # index .~ fromIntegral txIx
63+ & U5c. hash .~ serialiseToRawBytes txId'
64+ & U5c. index .~ fromIntegral txIx
6365
6466instance Message a => Default (Proto a ) where
6567 def = defMessage
6668
67- instance Inject Integer (Proto UtxoRpc . BigInt ) where
69+ instance Inject Integer (Proto U5c . BigInt ) where
6870 inject int
6971 | int <= fromIntegral (maxBound @ Int64 )
7072 && int >= fromIntegral (minBound @ Int64 ) =
7173 inject @ Int64 $ fromIntegral int
7274 | int < 0 =
7375 -- https://www.rfc-editor.org/rfc/rfc8949.html#name-bignums see 3.4.3 for negative integers
74- defMessage & # bigNInt .~ serialiseToRawBytes (fromIntegral @ _ @ Natural (- 1 - int))
76+ defMessage & U5c. bigNInt .~ serialiseToRawBytes (fromIntegral @ _ @ Natural (- 1 - int))
7577 | otherwise =
76- defMessage & # bigUInt .~ serialiseToRawBytes (fromIntegral @ _ @ Natural int)
78+ defMessage & U5c. bigUInt .~ serialiseToRawBytes (fromIntegral @ _ @ Natural int)
7779
78- instance Inject Int64 (Proto UtxoRpc . BigInt ) where
79- inject int = defMessage & # int .~ int
80+ instance Inject Int64 (Proto U5c . BigInt ) where
81+ inject int = defMessage & U5c. int .~ int
8082
81- instance Inject L. Coin (Proto UtxoRpc . BigInt ) where
83+ instance Inject L. Coin (Proto U5c . BigInt ) where
8284 inject = inject . fromIntegral @ _ @ Integer
8385
8486-----------
0 commit comments