Skip to content

Commit

Permalink
Add payments page to deposit wallet UI
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Dec 6, 2024
1 parent b83d6d4 commit bb8e1d7
Show file tree
Hide file tree
Showing 11 changed files with 1,855 additions and 3 deletions.
18 changes: 18 additions & 0 deletions lib/ui/cardano-wallet-ui.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ library
Cardano.Wallet.UI.Deposit.API.Addresses.Transactions
Cardano.Wallet.UI.Deposit.API.Common
Cardano.Wallet.UI.Deposit.API.Deposits.Deposits
Cardano.Wallet.UI.Deposit.API.Payments
Cardano.Wallet.UI.Deposit.Handlers.Addresses
Cardano.Wallet.UI.Deposit.Handlers.Addresses.Transactions
Cardano.Wallet.UI.Deposit.Handlers.Deposits.Customers
Cardano.Wallet.UI.Deposit.Handlers.Deposits.Times
Cardano.Wallet.UI.Deposit.Handlers.Deposits.TxIds
Cardano.Wallet.UI.Deposit.Handlers.Lib
Cardano.Wallet.UI.Deposit.Handlers.Payments.Balance
Cardano.Wallet.UI.Deposit.Handlers.Payments.Transaction
Cardano.Wallet.UI.Deposit.Handlers.Wallet
Cardano.Wallet.UI.Deposit.Html.Common
Cardano.Wallet.UI.Deposit.Html.Pages.About
Expand All @@ -79,6 +82,7 @@ library
Cardano.Wallet.UI.Deposit.Html.Pages.Deposits.Times
Cardano.Wallet.UI.Deposit.Html.Pages.Deposits.TxIds
Cardano.Wallet.UI.Deposit.Html.Pages.Page
Cardano.Wallet.UI.Deposit.Html.Pages.Payments.Page
Cardano.Wallet.UI.Deposit.Html.Pages.Wallet
Cardano.Wallet.UI.Deposit.Server
Cardano.Wallet.UI.Deposit.Server.Addresses
Expand All @@ -87,7 +91,9 @@ library
Cardano.Wallet.UI.Deposit.Server.Deposits.Times
Cardano.Wallet.UI.Deposit.Server.Deposits.TxIds
Cardano.Wallet.UI.Deposit.Server.Lib
Cardano.Wallet.UI.Deposit.Server.Payments.Page
Cardano.Wallet.UI.Deposit.Server.Wallet
Cardano.Wallet.UI.Deposit.Types.Payments
Cardano.Wallet.UI.Lib.Discretization
Cardano.Wallet.UI.Lib.ListOf
Cardano.Wallet.UI.Lib.Pagination.Map
Expand Down Expand Up @@ -117,6 +123,7 @@ library
, base16-bytestring
, bytestring
, cardano-addresses
, cardano-binary
, cardano-slotting
, cardano-wallet
, cardano-wallet-api
Expand Down Expand Up @@ -167,17 +174,28 @@ test-suite unit

build-depends:
, base
, base16-bytestring
, bytestring
, cardano-addresses
, cardano-crypto
, cardano-wallet-read
, cardano-wallet-ui
, contra-tracer
, containers
, hspec
, mtl
, QuickCheck
, text
, temporary
, time
, customer-deposit-wallet:rest
, customer-deposit-wallet:customer-deposit-wallet

build-tool-depends: hspec-discover:hspec-discover
type: exitcode-stdio-1.0
hs-source-dirs: test/unit
main-is: unit-test.hs
other-modules:
Cardano.Wallet.UI.Deposit.Html.Pages.Payments.PageSpec
Cardano.Wallet.UI.Lib.DiscretizationSpec
Cardano.Wallet.UI.Lib.Pagination.MapSpec
83 changes: 81 additions & 2 deletions lib/ui/src/Cardano/Wallet/UI/Deposit/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import Cardano.Wallet.Deposit.Pure
( Customer
)
import Cardano.Wallet.Deposit.Read
( TxId
( Address
, TxId
)
import Cardano.Wallet.Deposit.REST.Wallet.Create
( PostWalletViaMnemonic
Expand Down Expand Up @@ -42,9 +43,17 @@ import Cardano.Wallet.UI.Deposit.API.Common
import Cardano.Wallet.UI.Deposit.API.Deposits.Deposits
( DepositsParams
)
import Cardano.Wallet.UI.Deposit.API.Payments
( AddReceiverForm
, NewReceiverValidation
, SignatureForm
)
import Control.Lens
( makePrisms
)
import Data.Text
( Text
)
import Data.Time
( UTCTime
)
Expand All @@ -67,6 +76,7 @@ import Web.FormUrlEncoded
( FromForm (..)
)

import qualified Cardano.Wallet.UI.Deposit.API.Payments as Payment
import qualified Data.ByteString.Lazy as BL

instance FromForm PostWalletViaMnemonic
Expand All @@ -80,6 +90,7 @@ data Page
| Wallet
| Addresses
| Deposits
| Payments

makePrisms ''Page

Expand All @@ -90,6 +101,7 @@ instance ToHttpApiData Page where
toUrlPiece Wallet = "wallet"
toUrlPiece Addresses = "addresses"
toUrlPiece Deposits = "deposits"
toUrlPiece Payments = "payments"

instance FromHttpApiData Page where
parseUrlPiece "about" = Right About
Expand All @@ -98,6 +110,7 @@ instance FromHttpApiData Page where
parseUrlPiece "wallet" = Right Wallet
parseUrlPiece "addresses" = Right Addresses
parseUrlPiece "deposits" = Right Deposits
parseUrlPiece "payments" = Right Payments
parseUrlPiece _ = Left "Invalid page"

-- | Pages endpoints
Expand All @@ -108,6 +121,7 @@ type Pages =
:<|> "wallet" :> SessionedHtml Get
:<|> "addresses" :> SessionedHtml Get
:<|> "deposits" :> SessionedHtml Get
:<|> "payments" :> SessionedHtml Get

-- | Data endpoints
type Data =
Expand Down Expand Up @@ -187,6 +201,49 @@ type Data =
:> QueryParam "customer" Customer
:> QueryParam "tx-id" TxId
:> SessionedHtml Post
:<|> "payments" :> SessionedHtml Get
:<|> "payments"
:> "receiver"
:> ReqBody '[FormUrlEncoded] AddReceiverForm
:> SessionedHtml Post
:<|> "payments"
:> "receiver"
:> "delete"
:> ReqBody '[FormUrlEncoded] Payment.State
:> QueryParam "receiver-number" Address
:> SessionedHtml Post
:<|> "payments"
:> "balance"
:> "available"
:> SessionedHtml Get
:<|> "payments"
:> "receiver"
:> "address"
:> "validation"
:> ReqBody '[FormUrlEncoded] NewReceiverValidation
:> SessionedHtml Post
:<|> "payments"
:> "receiver"
:> "amount"
:> "validation"
:> ReqBody '[FormUrlEncoded] NewReceiverValidation
:> SessionedHtml Post
:<|> "modal"
:> "info"
:> QueryParam "title" Text
:> QueryParam "text" Text
:> SessionedHtml Get
:<|> "payments"
:> "sign"
:> ReqBody '[FormUrlEncoded] SignatureForm
:> SessionedHtml Post
:<|> "payments"
:> "submit"
:> ReqBody '[FormUrlEncoded] Payment.State
:> SessionedHtml Post
:<|> "payments"
:> "reset"
:> SessionedHtml Post

type Home = SessionedHtml Get

Expand All @@ -205,6 +262,7 @@ settingsPageLink :: Link
walletPageLink :: Link
addressesPageLink :: Link
depositPageLink :: Link
paymentsPageLink :: Link
networkInfoLink :: Link
settingsGetLink :: Link
settingsSseToggleLink :: Link
Expand Down Expand Up @@ -232,13 +290,24 @@ depositsTxIdsLink
:: Maybe (WithOrigin UTCTime) -> Maybe Customer -> Maybe Expand -> Link
depositsTxIdsPaginatingLink
:: Maybe (WithOrigin UTCTime) -> Maybe Customer -> Maybe TxId -> Link
paymentsLink :: Link
paymentsNewReceiverLink :: Link
paymentsDeleteReceiverLink :: Maybe Address -> Link
paymentsBalanceAvailableLink :: Link
paymentsReceiverAddressValidationLink :: Link
paymentsReceiverAmountValidationLink :: Link
modalLink :: Maybe Text -> Maybe Text -> Link
paymentsSignLink :: Link
paymentsSubmitLink :: Link
paymentsResetLink :: Link
homePageLink
:<|> aboutPageLink
:<|> networkPageLink
:<|> settingsPageLink
:<|> walletPageLink
:<|> addressesPageLink
:<|> depositPageLink
:<|> paymentsPageLink
:<|> networkInfoLink
:<|> settingsGetLink
:<|> settingsSseToggleLink
Expand All @@ -260,5 +329,15 @@ homePageLink
:<|> depositsCustomersLink
:<|> depositsCustomersPaginatingLink
:<|> depositsTxIdsLink
:<|> depositsTxIdsPaginatingLink =
:<|> depositsTxIdsPaginatingLink
:<|> paymentsLink
:<|> paymentsNewReceiverLink
:<|> paymentsDeleteReceiverLink
:<|> paymentsBalanceAvailableLink
:<|> paymentsReceiverAddressValidationLink
:<|> paymentsReceiverAmountValidationLink
:<|> modalLink
:<|> paymentsSignLink
:<|> paymentsSubmitLink
:<|> paymentsResetLink =
allLinks (Proxy @UI)
Loading

0 comments on commit bb8e1d7

Please sign in to comment.