-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
552 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE NumericUnderscores #-} | ||
|
||
module Cardano.Wallet.UI.Deposit.API.Payments | ||
( NewReceiver (..) | ||
, WithReceivers (..) | ||
) | ||
where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet.UI.Deposit.Types.Payments | ||
( Receiver (..) | ||
) | ||
import Web.FormUrlEncoded | ||
( FromForm (..) | ||
, parseAll | ||
, parseUnique | ||
) | ||
|
||
data WithReceivers a | ||
= WithReceivers | ||
{ receivers :: [Receiver] | ||
, what :: a | ||
} | ||
|
||
newtype NewReceiver = NewReceiver (WithReceivers Receiver) | ||
|
||
instance FromForm NewReceiver where | ||
fromForm form = do | ||
WithReceivers receivers () <- fromForm form | ||
address <- parseUnique "new-receiver-address" form | ||
amountDouble :: Double <- parseUnique "new-receiver-amount" form | ||
let amount = round $ amountDouble * 1_000_000 | ||
pure | ||
$ NewReceiver | ||
$ WithReceivers{receivers, what = Receiver{address, amount}} | ||
|
||
instance FromForm (WithReceivers ()) where | ||
fromForm form = do | ||
receivers <- parseAll "receiver-defined" form | ||
pure | ||
$ WithReceivers{receivers, what = ()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.