Skip to content

Commit

Permalink
Use Read.ChainPoint in Cardano.Wallet.Deposit.Read
Browse files Browse the repository at this point in the history
  • Loading branch information
HeinrichApfelmus committed Sep 12, 2024
1 parent 9e91ac5 commit 60ef40a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-|
Copyright: © 2024 Cardano Foundation
License: Apache-2.0
Expand Down Expand Up @@ -93,10 +94,19 @@ newNetworkEnvMock = do
}

genesis :: Read.ChainPoint
genesis = Read.Origin
genesis = Read.GenesisPoint

getBlockPoint :: Read.Block -> Read.ChainPoint
getBlockPoint = Read.At . Read.slotNo . Read.blockHeaderBody . Read.blockHeader
getBlockPoint block =
Read.BlockPoint
{ Read.slotNo = slot
, Read.headerHash =
Read.mockRawHeaderHash
$ fromIntegral $ fromEnum slot
}
where
bhBody = Read.blockHeaderBody $ Read.blockHeader block
slot = Read.slotNo bhBody

mkNextBlock :: Read.ChainPoint -> [Tx Conway] -> Read.Block
mkNextBlock tipOld txs =
Expand All @@ -114,5 +124,5 @@ mkNextBlock tipOld txs =
}
where
slotNext = case tipOld of
Read.Origin -> 1
Read.At n -> succ n
Read.GenesisPoint -> 1
Read.BlockPoint{slotNo = n} -> succ n
10 changes: 2 additions & 8 deletions lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
module Cardano.Wallet.Deposit.Read
( Network (..)
, Read.SlotNo
, toSlot
, fromSlot
, ChainPoint (..)
, Read.ChainPoint (..)

, Address
, KeyHash
Expand All @@ -34,6 +32,7 @@ module Cardano.Wallet.Deposit.Read
, BlockNo
, Block (..)
, BHeader (..)
, Read.mockRawHeaderHash
, BHBody (..)

, GenesisData
Expand Down Expand Up @@ -78,11 +77,6 @@ import qualified Data.ByteString.Short as SBS
------------------------------------------------------------------------------}
data Network = Testnet | Mainnet

data ChainPoint
= Origin
| At Read.SlotNo
deriving (Eq, Ord, Show)

-- | Synonym for readability.
-- The ledger specifications define @Addr@.
-- Byron addresses are represented by @Addr_bootstrap@.
Expand Down

0 comments on commit 60ef40a

Please sign in to comment.