Skip to content

Commit

Permalink
Drop V0 support - traces of v0 in v1 files removed
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabhxyz committed Jul 27, 2023
1 parent 4cfdd3c commit d72a6e8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/Maestro/Client/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Control.Exception (Exception)
import Data.Aeson (decode)
import Data.Text (Text)
import Deriving.Aeson
import Maestro.Types.V0.Common (LowerFirst)
import Maestro.Types.Common (LowerFirst)
import Network.HTTP.Types
import Servant.Client

Expand Down
25 changes: 0 additions & 25 deletions src/Maestro/Types/V1/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ module Maestro.Types.V1.Common
NonAdaNativeToken (..),
AssetUnit (..),
Asset (..),
v1AssetToV0,
IsUtxo (..),
UtxoWithSlot (..),
v1UtxoWithSlotToV0,
PaginatedUtxoWithSlot (..),
module Maestro.Types.Common,
module Maestro.Types.V1.Common.Pagination,
Expand All @@ -28,8 +26,6 @@ import qualified Data.Text as T (splitAt)
import Deriving.Aeson
import GHC.TypeLits (Symbol)
import Maestro.Types.Common
import qualified Maestro.Types.V0 as V0 (Asset (..),
Utxo (..))
import Maestro.Types.V1.Common.Pagination
import Maestro.Types.V1.Common.Timestamped
import Servant.API (FromHttpApiData (..),
Expand Down Expand Up @@ -90,15 +86,6 @@ data Asset = Asset
(FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_asset", CamelToSnake]] Asset

-- | Convert @V1@ API version `Asset` type into corresponding @V0@ type.
v1AssetToV0 :: Asset -> V0.Asset
v1AssetToV0 Asset {..} = V0.Asset {
V0._assetQuantity = _assetAmount
, V0._assetUnit = case _assetUnit of
Lovelace -> "lovelace"
UserMintedToken (NonAdaNativeToken policyId tokenName) -> coerce policyId <> "#" <> coerce tokenName
}

-- | To get basic details from an UTxO.
class IsUtxo a where
getAddress :: a -> Bech32StringOf Address
Expand Down Expand Up @@ -140,18 +127,6 @@ instance IsUtxo UtxoWithSlot where
getIndex = _utxoWithSlotIndex
getReferenceScript = _utxoWithSlotReferenceScript

-- | Convert @V1@ API version UTxO (with slot) type into corresponding @V0@ type.
v1UtxoWithSlotToV0 :: UtxoWithSlot -> V0.Utxo
v1UtxoWithSlotToV0 UtxoWithSlot {..} = V0.Utxo {
V0._utxoAddress = _utxoWithSlotAddress
, V0._utxoAssets = map v1AssetToV0 _utxoWithSlotAssets
, V0._utxoDatum = _utxoWithSlotDatum
, V0._utxoIndex = coerce _utxoWithSlotIndex
, V0._utxoReferenceScript = _utxoWithSlotReferenceScript
, V0._utxoTxHash = coerce _utxoWithSlotTxHash
, V0._utxoTxoutCbor = _utxoWithSlotTxoutCbor
}

-- | A paginated response of transaction outputs.
data PaginatedUtxoWithSlot = PaginatedUtxoWithSlot
{ _paginatedUtxoWithSlotData :: ![UtxoWithSlot],
Expand Down
2 changes: 1 addition & 1 deletion src/Maestro/Types/V1/General.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import qualified Data.Text.Read as TxtRead
import Data.Time (LocalTime, NominalDiffTime)
import Data.Word (Word64)
import Deriving.Aeson
import Maestro.Types.V0.Common (BlockHash, EpochNo, EpochSize,
import Maestro.Types.Common (BlockHash, EpochNo, EpochSize,
LowerFirst, SlotNo)
import Maestro.Types.V1.Common (IsTimestamped (..), LastUpdated (..))
import Numeric.Natural (Natural)
Expand Down
15 changes: 0 additions & 15 deletions src/Maestro/Types/V1/Transactions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
module Maestro.Types.V1.Transactions
( OutputReference (..)
, UtxoWithBytes (..)
, v1UtxoToV0
, PaginatedUtxo (..)
) where

import Data.Aeson (ToJSON (..), Value (..))
import Data.Coerce (coerce)
import Deriving.Aeson
import Maestro.Types.Common
import qualified Maestro.Types.V0 as V0 (Utxo (..))
import Maestro.Types.V1.Common
import Servant.API (ToHttpApiData (..))

Expand Down Expand Up @@ -55,18 +52,6 @@ instance IsUtxo UtxoWithBytes where
getIndex = _utxoWithBytesIndex
getReferenceScript = _utxoWithBytesReferenceScript

-- | Convert @V1@ API version UTxO type into corresponding @V0@ type.
v1UtxoToV0 :: UtxoWithBytes -> V0.Utxo
v1UtxoToV0 UtxoWithBytes {..} = V0.Utxo {
V0._utxoAddress = _utxoWithBytesAddress
, V0._utxoAssets = map v1AssetToV0 _utxoWithBytesAssets
, V0._utxoDatum = _utxoWithBytesDatum
, V0._utxoIndex = coerce _utxoWithBytesIndex
, V0._utxoReferenceScript = _utxoWithBytesReferenceScript
, V0._utxoTxHash = coerce _utxoWithBytesTxHash
, V0._utxoTxoutCbor = _utxoWithBytesTxoutCbor
}

-- | A paginated response of transaction outputs.
data PaginatedUtxo = PaginatedUtxo
{ _paginatedUtxoData :: ![UtxoWithBytes],
Expand Down

0 comments on commit d72a6e8

Please sign in to comment.