-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TxMeta type #114
Add TxMeta type #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
|
@@ -29,6 +30,7 @@ module Cardano.Wallet.Primitive.Types | |
, Tx(..) | ||
, TxIn(..) | ||
, TxOut(..) | ||
, TxMeta(..) | ||
, txIns | ||
, updatePending | ||
|
||
|
@@ -74,8 +76,12 @@ import Data.ByteString.Base58 | |
( bitcoinAlphabet, encodeBase58 ) | ||
import Data.Map.Strict | ||
( Map ) | ||
import Data.Quantity | ||
( Quantity (..) ) | ||
import Data.Set | ||
( Set ) | ||
import Data.Time | ||
( UTCTime ) | ||
import Data.Word | ||
( Word16, Word32, Word64 ) | ||
import Fmt | ||
|
@@ -93,6 +99,8 @@ import GHC.Generics | |
( Generic ) | ||
import GHC.TypeLits | ||
( Symbol ) | ||
import Numeric.Natural | ||
( Natural ) | ||
|
||
import qualified Data.Map.Strict as Map | ||
import qualified Data.Set as Set | ||
|
@@ -212,6 +220,29 @@ instance Buildable TxOut where | |
instance Buildable (TxIn, TxOut) where | ||
build (txin, txout) = build txin <> " ==> " <> build txout | ||
|
||
data TxMeta = TxMeta | ||
{ txId :: !(Hash "Tx") | ||
, depth :: !(Quantity "block" Natural) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to keep types in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimizations between If so, we should measure it first and have a baseline to compare with. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will leave it to |
||
, status :: !TxStatus | ||
, direction :: !Direction | ||
, timestamp :: !Timestamp | ||
, slotId :: !SlotId | ||
} deriving (Show, Eq, Generic) | ||
|
||
data TxStatus | ||
= Pending | ||
| InLedger | ||
| Invalidated | ||
deriving (Show, Eq, Generic) | ||
|
||
data Direction | ||
= Outgoing | ||
| Incoming | ||
deriving (Show, Eq, Generic) | ||
|
||
newtype Timestamp = Timestamp | ||
{ getTimestamp :: UTCTime | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the old wallet we used |
||
} deriving (Show, Generic, Eq, Ord) | ||
|
||
-- * Address | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as proposed by @KtorZ , we are going to try to use generic-lens and light lensing as described here https://hackage.haskell.org/package/generic-lens with as little as possible:
^.
.~
%~
This is experimental