Skip to content
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

[ADP-3443] Add a UI page to show deposits #4791

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9768e29
Fix field name in wallet creation form
paolino Oct 1, 2024
9b72531
Update deposit pure dependency
paolino Sep 28, 2024
b008f88
Add truncatable and copyable widget
paolino Sep 28, 2024
d12aff3
Add key of assocs column size control
paolino Sep 28, 2024
921d76a
Factor out onWalletPresentH html control
paolino Sep 28, 2024
c6d44a0
Add a time interpreter functionality to NetworkEnv
paolino Oct 1, 2024
85003fd
Add transactions history in the addresses page
paolino Oct 1, 2024
90794cc
Add spent and received filters to transaction view
paolino Oct 1, 2024
fd90fd9
Add title to navigation bar
paolino Oct 1, 2024
66ae121
CSS fixes for d-flex
paolino Oct 2, 2024
cb7cff9
Fix CSS for page padding
paolino Oct 2, 2024
3f00a90
Change network interpreter to handle origin correctly
paolino Oct 2, 2024
052040d
Add time sorting control to the transactions view
paolino Oct 2, 2024
fb9d284
Add start time control to the transactions view
paolino Oct 3, 2024
743fa31
Add headers into the addresses page
paolino Oct 3, 2024
85ecf98
Coolect value transfers in the REST interface
paolino Oct 3, 2024
dceebe0
Add a stub deposit page
paolino Oct 3, 2024
640b390
Restyle wallet page to use boxes
paolino Oct 4, 2024
a8e53c5
Enable fake data in the deposits tab
paolino Oct 4, 2024
aaf4459
Add deposit window UI element
paolino Oct 10, 2024
92fef5d
Add user to deposit window UI element
paolino Oct 10, 2024
bf35093
Bump deposit core dependency
paolino Oct 10, 2024
2c4d796
Implement a lossless getValueTransfer
paolino Oct 10, 2024
ffa4580
Fix copy address identifiers
paolino Oct 11, 2024
1274b1a
Simplify copy-button code
paolino Oct 11, 2024
268e601
Add spent toggle on deposits view
paolino Oct 11, 2024
be61c13
Use same table elements in transactions view
paolino Oct 11, 2024
d601546
Add a box around the deposit details
paolino Oct 11, 2024
d2d3412
Make the table configuration sticky
paolino Oct 11, 2024
b130a01
Add slot column to deposit details
paolino Oct 11, 2024
9b74901
Minimize interface state harvest by moving view-control id
paolino Oct 13, 2024
3f61387
Add constant HTML scrolling
paolino Oct 15, 2024
f9554de
Add constant HTML scrolling to the window details
paolino Oct 17, 2024
b7f0fee
Add a new API to TxHistory
paolino Oct 18, 2024
02a1f63
Use new TxHistory API in Deposits page
paolino Oct 18, 2024
1a8682e
Split deposits handlers code by table
paolino Oct 19, 2024
bf6f784
Rename quantize to discretize
paolino Oct 19, 2024
9a4d08e
Fix deposit customers naming
paolino Oct 19, 2024
6b33b9c
Fix pagination handlers naming
paolino Oct 19, 2024
29b5e4d
Remove use of deposits maps from html code
paolino Oct 21, 2024
25da0cb
Split deposits html page code by table
paolino Oct 21, 2024
02eba83
Add WithCopy control for truncatable text
paolino Oct 21, 2024
a4d997d
Add tx ids details of deposits customers details
paolino Oct 21, 2024
be7fa4e
Fix fake boot env to actually support mock network
paolino Oct 22, 2024
bb0060f
Fix copy button propagation issues
paolino Oct 22, 2024
7cd2174
Break out deposits code from server
paolino Oct 22, 2024
584835a
Standardize deposits serve function names
paolino Oct 22, 2024
8a352c9
Break out address code from server module
paolino Oct 22, 2024
9c12ba3
Break out wallet code from server module
paolino Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ package std-gen-seed
package wai-middleware-logging
tests: True

package cardano-wallet-ui
tests: True

-- Now disable all other tests with a global flag.
-- This is what they do in cardano-node/cabal.project.

Expand Down
7 changes: 6 additions & 1 deletion lib/customer-deposit-wallet/customer-deposit-wallet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ common language
default-extensions:
NoImplicitPrelude
OverloadedStrings
PackageImports

common opts-lib
ghc-options:
Expand Down Expand Up @@ -68,11 +69,12 @@ library
, delta-types
, io-classes
, microlens
, monoidal-containers
, mtl
, OddWord
, text
, time

reexported-modules: Cardano.Wallet.Address.BIP32
exposed-modules:
Cardano.Wallet.Deposit.IO
Cardano.Wallet.Deposit.IO.DB
Expand All @@ -81,7 +83,9 @@ library
Cardano.Wallet.Deposit.IO.Resource
Cardano.Wallet.Deposit.IO.Resource.Event
Cardano.Wallet.Deposit.Pure
Cardano.Wallet.Deposit.Pure.API.TxHistory
Cardano.Wallet.Deposit.Pure.Balance
Cardano.Wallet.Deposit.Map
Cardano.Wallet.Deposit.Pure.Submissions
Cardano.Wallet.Deposit.Pure.UTxO
Cardano.Wallet.Deposit.Read
Expand Down Expand Up @@ -153,6 +157,7 @@ library rest
, contra-tracer
, crypto-primitives
, customer-deposit-wallet
, customer-deposit-wallet-pure
, delta-store
, directory
, filepath
Expand Down
39 changes: 25 additions & 14 deletions lib/customer-deposit-wallet/rest/Cardano/Wallet/Deposit/REST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module Cardano.Wallet.Deposit.REST
, getWalletTip
, availableBalance
, getCustomerHistory
, getCustomerHistories
, getValueTransfers

-- ** Writing to the blockchain
, createPayment
Expand All @@ -47,6 +47,7 @@ module Cardano.Wallet.Deposit.REST
, deleteWallet
, deleteTheDepositWalletOnDisk
, customerAddress
, getValueTransfersWithTxIds
) where

import Prelude
Expand Down Expand Up @@ -110,6 +111,9 @@ import Data.ByteArray.Encoding
import Data.List
( isPrefixOf
)
import Data.Map.Strict
( Map
)
import Data.Store
( Store (..)
, newStore
Expand All @@ -129,7 +133,6 @@ import qualified Cardano.Wallet.Deposit.Read as Read
import qualified Cardano.Wallet.Deposit.Write as Write
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy as BL
import qualified Data.Map as Map

{-----------------------------------------------------------------------------
Types
Expand Down Expand Up @@ -290,10 +293,10 @@ loadWallet bootEnv dir = do
let action :: (WalletIO.WalletInstance -> IO b) -> IO (Either ErrDatabase b)
action f = findTheDepositWalletOnDisk dir $ \case
Right wallet ->
Right <$>
WalletIO.withWalletLoad
Right
<$> WalletIO.withWalletLoad
(WalletIO.WalletEnv bootEnv wallet)
f
f
Left e -> pure $ Left $ ErrLoadingDatabase e
resource <- ask
lift
Expand Down Expand Up @@ -323,9 +326,9 @@ initXPubWallet tr bootEnv dir xpub users = do
(WalletIO.WalletEnv bootEnv wallet)
xpub
users
$ \i -> do
ls <- WalletIO.listCustomers i
last ls `seq` f i
$ \i -> do
ls <- WalletIO.listCustomers i
last ls `seq` f i
Nothing ->
pure
$ Left
Expand Down Expand Up @@ -357,12 +360,12 @@ walletPublicIdentity = onWalletInstance WalletIO.walletPublicIdentity
{-----------------------------------------------------------------------------
Operations
------------------------------------------------------------------------------}

-- | List all tracked customers addresses.
listCustomers :: WalletResourceM [(Customer, Address)]
listCustomers = onWalletInstance WalletIO.listCustomers

-- | Retrieve the address for a customer if it's tracked by the wallet.

customerAddress :: Customer -> WalletResourceM (Maybe Address)
customerAddress = onWalletInstance . WalletIO.customerAddress

Expand All @@ -378,13 +381,21 @@ availableBalance = onWalletInstance WalletIO.availableBalance

getCustomerHistory
:: Customer
-> WalletResourceM [Wallet.TxSummary]
-> WalletResourceM (Map Read.TxId Wallet.TxSummary)
getCustomerHistory = onWalletInstance . WalletIO.getCustomerHistory

getCustomerHistories
:: (Read.ChainPoint, Read.ChainPoint)
-> WalletResourceM (Map.Map Customer Wallet.ValueTransfer)
getCustomerHistories = onWalletInstance . WalletIO.getCustomerHistories
getValueTransfers
:: WalletResourceM (Map Read.Slot (Map Address Wallet.ValueTransfer))
getValueTransfers = onWalletInstance WalletIO.getValueTransfers

getValueTransfersWithTxIds
:: WalletResourceM
( Map
Read.Slot
(Map Address (Map Read.TxId Wallet.ValueTransfer))
)
getValueTransfersWithTxIds =
onWalletInstance WalletIO.getValueTransfersWithTxIds

{-----------------------------------------------------------------------------
Operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ import Control.Monad.IO.Class
)
import Control.Tracer
( Tracer
, stdoutTracer
, traceWith
)
import Data.Functor.Contravariant
( (>$<)
)

import qualified Cardano.Wallet.Deposit.Read as Read

lg :: (MonadIO m, Show a) => Tracer IO String -> String -> a -> m ()
lg tr p x = liftIO $ traceWith tr $ p <> ": " <> show x
Expand All @@ -46,10 +52,10 @@ loadDepositWalletFromDisk tr dir env resource = do
Left e -> error $ show e
Right _ -> pure ()

fakeBootEnv :: WalletBootEnv m
fakeBootEnv :: MonadIO m => WalletBootEnv m
fakeBootEnv =
( WalletBootEnv
(error "Not defined")
(error "Not defined")
(error "Not defined")
(show >$< stdoutTracer)
Read.mockGenesisDataMainnet
(error "network env not defined")
)
84 changes: 50 additions & 34 deletions lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit/IO.hs
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE RecordWildCards #-}

module Cardano.Wallet.Deposit.IO
(
-- * Types
( -- * Types
WalletEnv (..)
, WalletBootEnv (..)
, WalletPublicIdentity (..)
, WalletInstance

-- * Operations
-- ** Initialization
-- * Operations

-- ** Initialization
, withWalletInit
, Word31
, withWalletLoad

-- ** Mapping between customers and addresses
-- ** Mapping between customers and addresses
, listCustomers
, customerAddress

-- ** Reading from the blockchain
-- ** Reading from the blockchain
, getWalletTip
, availableBalance
, getCustomerHistory
, getCustomerHistories
, getValueTransfers

-- ** Writing to the blockchain
-- ** Writing to the blockchain
, createPayment
, getBIP32PathsForOwnedInputs
, signTxBody
, WalletStore
, walletPublicIdentity
, getValueTransfersWithTxIds
) where

import Prelude
Expand All @@ -43,12 +45,15 @@ import Cardano.Wallet.Address.BIP32
)
import Cardano.Wallet.Deposit.Pure
( Customer
, TxSummary
, ValueTransfer
, WalletPublicIdentity (..)
, WalletState
, Word31
)
import Cardano.Wallet.Deposit.Read
( Address
, Slot
)
import Cardano.Wallet.Network.Checkpoints.Policy
( defaultPolicy
Expand All @@ -63,6 +68,9 @@ import Data.Bifunctor
import Data.List.NonEmpty
( NonEmpty
)
import Data.Map.Strict
( Map
)

import qualified Cardano.Wallet.Deposit.IO.Network.Type as Network
import qualified Cardano.Wallet.Deposit.Pure as Wallet
Expand All @@ -74,7 +82,6 @@ import qualified Data.Delta as Delta
( Replace (..)
)
import qualified Data.Delta.Update as Delta
import qualified Data.Map.Strict as Map
import qualified Data.Store as Store

{-----------------------------------------------------------------------------
Expand All @@ -84,25 +91,25 @@ import qualified Data.Store as Store
-- | The environment needed to initialize a wallet, before a database is
-- connected.
data WalletBootEnv m = WalletBootEnv
{ logger :: Tracer m WalletLog
-- ^ Logger for the wallet.
, genesisData :: Read.GenesisData
-- ^ Genesis data for the wallet.
, networkEnv :: Network.NetworkEnv m (Read.EraValue Read.Block)
-- ^ Network environment for the wallet.
{ logger :: Tracer m WalletLog
-- ^ Logger for the wallet.
, genesisData :: Read.GenesisData
-- ^ Genesis data for the wallet.
, networkEnv :: Network.NetworkEnv m (Read.EraValue Read.Block)
-- ^ Network environment for the wallet.
}

-- | The wallet store type.
type WalletStore = Store.UpdateStore IO Wallet.DeltaWalletState

-- | The full environment needed to run a wallet.
data WalletEnv m =
WalletEnv
{ bootEnv :: WalletBootEnv m
-- ^ The boot environment.
, store :: WalletStore
-- ^ The store for the wallet.
}
data WalletEnv m
= WalletEnv
{ bootEnv :: WalletBootEnv m
-- ^ The boot environment.
, store :: WalletStore
-- ^ The store for the wallet.
}

data WalletInstance = WalletInstance
{ env :: WalletEnv IO
Expand All @@ -112,14 +119,16 @@ data WalletInstance = WalletInstance
{-----------------------------------------------------------------------------
Helpers
------------------------------------------------------------------------------}

-- | Convenience to apply an 'Update' to the 'WalletState' via the 'DBLayer'.
onWalletState
:: WalletInstance
-> Delta.Update Wallet.DeltaWalletState r
-> IO r
onWalletState WalletInstance{walletState} =
Delta.onDBVar walletState
-- FIXME: Propagation of exceptions from Pure to IO.

-- FIXME: Propagation of exceptions from Pure to IO.

-- | Convenience to read the 'WalletState'.
--
Expand Down Expand Up @@ -202,10 +211,12 @@ customerAddress c w = Wallet.customerAddress c <$> readWalletState w
walletPublicIdentity :: WalletInstance -> IO WalletPublicIdentity
walletPublicIdentity w = do
state <- readWalletState w
pure $ WalletPublicIdentity
{ pubXpub = Wallet.walletXPub state
, pubNextUser = Wallet.trackedCustomers state
}
pure
$ WalletPublicIdentity
{ pubXpub = Wallet.walletXPub state
, pubNextUser = Wallet.trackedCustomers state
}

{-----------------------------------------------------------------------------
Operations
Reading from the blockchain
Expand All @@ -218,16 +229,20 @@ availableBalance :: WalletInstance -> IO Read.Value
availableBalance w =
Wallet.availableBalance <$> readWalletState w

getCustomerHistory :: Customer -> WalletInstance -> IO [Wallet.TxSummary]
getCustomerHistory :: Customer -> WalletInstance -> IO (Map Read.TxId TxSummary)
getCustomerHistory c w =
Wallet.getCustomerHistory c <$> readWalletState w

getCustomerHistories
:: (Read.ChainPoint, Read.ChainPoint)
-> WalletInstance
-> IO (Map.Map Customer Wallet.ValueTransfer)
getCustomerHistories a w =
Wallet.getCustomerHistories a <$> readWalletState w
getValueTransfers
:: WalletInstance
-> IO (Map Slot (Map Address ValueTransfer))
getValueTransfers w = Wallet.getValueTransfers <$> readWalletState w

getValueTransfersWithTxIds
:: WalletInstance
-> IO (Map Slot (Map Address (Map Read.TxId ValueTransfer)))
getValueTransfersWithTxIds w =
Wallet.getValueTransfersWithTxIds <$> readWalletState w

rollForward
:: WalletInstance -> NonEmpty (Read.EraValue Read.Block) -> tip -> IO ()
Expand Down Expand Up @@ -265,3 +280,4 @@ signTxBody txbody w = Wallet.signTxBody txbody <$> readWalletState w
------------------------------------------------------------------------------}
data WalletLog
= WalletLogDummy
deriving Show
Loading
Loading