Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 1c2ae37

Browse files
author
Ben Ford
committed
[DEVOPS-834] withdrawl -> withdrawal
1 parent 7cabdb9 commit 1c2ae37

File tree

6 files changed

+55
-55
lines changed

6 files changed

+55
-55
lines changed

faucet/src/Cardano/Faucet.hs

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import qualified Cardano.WalletClient as Client
3838

3939
-- | Top level type of the faucet API
4040
type FaucetAPI = "withdraw" :> Summary "Requests ADA from the faucet"
41-
:> ReqBody '[FormUrlEncoded, JSON] WithdrawlRequest
42-
:> Post '[JSON] WithdrawlResult
41+
:> ReqBody '[FormUrlEncoded, JSON] WithdrawalRequest
42+
:> Post '[JSON] WithdrawalResult
4343
:<|> "return-address" :> Summary "Get the address to return ADA to"
4444
:> Get '[JSON] (V1 Address)
4545
:<|> Raw
@@ -48,8 +48,8 @@ type FaucetAPI = "withdraw" :> Summary "Requests ADA from the faucet"
4848
faucetServerAPI :: Proxy FaucetAPI
4949
faucetServerAPI = Proxy
5050

51-
-- | Handler for the withdrawl of ADA from the faucet
52-
withdraw :: (MonadFaucet c m) => WithdrawlRequest -> m WithdrawlResult
51+
-- | Handler for the withdrawal of ADA from the faucet
52+
withdraw :: (MonadFaucet c m) => WithdrawalRequest -> m WithdrawalResult
5353
withdraw wr = withSublogger (LoggerName "withdraw") $ do
5454
logInfo "Attempting to send ADA"
5555
mCaptchaSecret <- view (feFaucetConfig . fcRecaptchaSecret)
@@ -64,15 +64,15 @@ withdraw wr = withSublogger (LoggerName "withdraw") $ do
6464
resp <- Client.withdraw (wr ^. wAddress)
6565
case resp of
6666
Left _ -> do
67-
logError "Withdrawl queue is full"
68-
throwError $ err503 { errBody = "Withdrawl queue is full" }
67+
logError "Withdrawal queue is full"
68+
throwError $ err503 { errBody = "Withdrawal queue is full" }
6969
Right wdResp -> do
70-
for_ (wdResp ^? _WithdrawlSuccess) $ \txn -> do
70+
for_ (wdResp ^? _WithdrawalSuccess) $ \txn -> do
7171
let amount = unV1 $ txAmount txn
7272
logInfo ((txn ^. to show . packed) <> " withdrew: "
7373
<> (amount ^. to show . packed))
7474
incWithDrawn amount
75-
for_ (wdResp ^? _WithdrawlError) $ \err -> do
75+
for_ (wdResp ^? _WithdrawalError) $ \err -> do
7676
logError ("Error from wallet: " <> err)
7777
throwError $ err503 { errBody = (fromStrict err) ^. re utf8 }
7878
return wdResp

faucet/src/Cardano/Faucet/Init.hs

+9-9
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ makeInitializedWallet fc client = withSublogger "makeInitializedWallet" $ do
300300
left = return . Left
301301

302302
--------------------------------------------------------------------------------
303-
-- | Process withdrawls requested from the 'feWithdrawlQ'
303+
-- | Process withdrawals requested from the 'feWithdrawalQ'
304304
--
305305
-- On receiving a 'ProcessorPayload' 'postTransaction' is used to send the
306-
-- 'Payment' and the resulting 'Transaction' is wrapped in a 'WithdrawlResult'
306+
-- 'Payment' and the resulting 'Transaction' is wrapped in a 'WithdrawalResult'
307307
-- and put into the provided 'TMVar'
308-
processWithdrawls :: FaucetEnv -> LoggerNameBox IO ()
309-
processWithdrawls fEnv = withSublogger "processWithdrawls" $ forever $ do
308+
processWithdrawals :: FaucetEnv -> LoggerNameBox IO ()
309+
processWithdrawals fEnv = withSublogger "processWithdrawals" $ forever $ do
310310
let wc = fEnv ^. feWalletClient
311-
pmtQ = fEnv ^. feWithdrawlQ
311+
pmtQ = fEnv ^. feWithdrawalQ
312312
logInfo "Waiting for next payment"
313313
(ProcessorPayload pmt tVarResult)<- liftIOA $ TBQ.readTBQueue pmtQ
314314
logInfo "Processing payment"
@@ -319,14 +319,14 @@ processWithdrawls fEnv = withSublogger "processWithdrawls" $ forever $ do
319319
logError ("Error sending to " <> (showPmt pmt)
320320
<> " error: "
321321
<> txtErr)
322-
liftIOA $ putTMVar tVarResult (WithdrawlError txtErr)
322+
liftIOA $ putTMVar tVarResult (WithdrawalError txtErr)
323323
Right withDrawResp -> do
324324
let txn = wrData withDrawResp
325325
amount = unV1 $ txAmount txn
326326
logInfo ((withDrawResp ^. to (show . wrStatus) . packed)
327327
<> " withdrew: "
328328
<> (amount ^. to show . packed))
329-
liftIOA $ putTMVar tVarResult (WithdrawlSuccess txn)
329+
liftIOA $ putTMVar tVarResult (WithdrawalSuccess txn)
330330
where
331331
liftIOA = liftIO . atomically
332332
showPmt = toStrict . encodeToLazyText . pdAddress . NonEmpty.head . pmtDestinations
@@ -339,9 +339,9 @@ initEnv fc store = do
339339
withSublogger "initEnv" $ logInfo "Initializing environment"
340340
env <- createEnv
341341
withSublogger "initEnv" $ logInfo "Created environment"
342-
wdTId <- liftLogIO forkIO $ processWithdrawls env
342+
wdTId <- liftLogIO forkIO $ processWithdrawals env
343343
withSublogger "initEnv"
344-
$ logInfo ( "Forked thread for processing withdrawls:"
344+
$ logInfo ( "Forked thread for processing withdrawals:"
345345
<> show wdTId ^. packed)
346346
monTId <- liftLogIO forkIO $ monitorWalletBalance env
347347
withSublogger "initEnv"

faucet/src/Cardano/Faucet/Metrics.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import Cardano.Faucet.Types
2828
import Pos.Core (Coin (..))
2929

3030
--------------------------------------------------------------------------------
31-
-- | Record a withdrawl
31+
-- | Record a withdrawal
3232
--
3333
-- * Adds to 'feWithDrawn' 'Counter'
3434
-- * Increments 'feNumWithDrawn' 'Counter'

faucet/src/Cardano/Faucet/Types/API.hs

+27-27
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
{-# LANGUAGE TypeFamilies #-}
1212
{-# OPTIONS_GHC -Wall #-}
1313
module Cardano.Faucet.Types.API (
14-
WithdrawlRequest(..), wAddress, gRecaptchaResponse
15-
, WithdrawlResult(..), _WithdrawlError, _WithdrawlSuccess
14+
WithdrawalRequest(..), wAddress, gRecaptchaResponse
15+
, WithdrawalResult(..), _WithdrawalError, _WithdrawalSuccess
1616
, DepositRequest(..), dWalletId, dAmount
1717
, DepositResult(..)
1818
, GCaptchaResponse(..)
19-
, WithdrawlQFull(..)
19+
, WithdrawalQFull(..)
2020
) where
2121

2222
import Control.Exception
@@ -48,80 +48,80 @@ instance IsString GCaptchaResponse where
4848

4949
--------------------------------------------------------------------------------
5050
-- | A request to withdraw ADA from the faucet wallet
51-
data WithdrawlRequest = WithdrawlRequest {
51+
data WithdrawalRequest = WithdrawalRequest {
5252
-- | The address to send the ADA to
5353
_wAddress :: !(V1 Address)
5454
-- | The "g-recaptcha-response" field sent by the form
5555
, _gRecaptchaResponse :: !GCaptchaResponse
5656
} deriving (Show, Typeable, Generic)
5757

58-
makeLenses ''WithdrawlRequest
58+
makeLenses ''WithdrawalRequest
5959

60-
instance FromJSON WithdrawlRequest where
61-
parseJSON = withObject "WithdrawlRequest" $ \v -> WithdrawlRequest
60+
instance FromJSON WithdrawalRequest where
61+
parseJSON = withObject "WithdrawalRequest" $ \v -> WithdrawalRequest
6262
<$> v .: "address"
6363
<*> (GCaptchaResponse <$> v .: "g-recaptcha-response")
6464

65-
instance FromForm WithdrawlRequest where
66-
fromForm f = WithdrawlRequest
65+
instance FromForm WithdrawalRequest where
66+
fromForm f = WithdrawalRequest
6767
<$> parseUnique "address" f
6868
<*> (GCaptchaResponse <$> parseUnique "g-recaptcha-response" f)
6969

70-
instance ToSchema WithdrawlRequest where
70+
instance ToSchema WithdrawalRequest where
7171
declareNamedSchema _ = do
7272
addrSchema <- declareSchemaRef (Proxy :: Proxy (V1 Address))
7373
recaptchaSchema <- declareSchemaRef (Proxy :: Proxy Text)
74-
return $ NamedSchema (Just "WithdrawlRequest") $ mempty
74+
return $ NamedSchema (Just "WithdrawalRequest") $ mempty
7575
& type_ .~ SwaggerObject
7676
& properties .~ (mempty & at "address" ?~ addrSchema
7777
& at "g-recaptcha-response" ?~ recaptchaSchema)
7878
& required .~ ["address", "g-recaptcha-response"]
7979

80-
instance ToJSON WithdrawlRequest where
81-
toJSON (WithdrawlRequest w g) =
80+
instance ToJSON WithdrawalRequest where
81+
toJSON (WithdrawalRequest w g) =
8282
object [ "address" .= w
8383
, "g-recaptcha-response" .= (g ^. _Wrapped)]
8484

8585

8686
--------------------------------------------------------------------------------
87-
data WithdrawlQFull = WithdrawlQFull deriving (Show, Generic, Exception)
87+
data WithdrawalQFull = WithdrawalQFull deriving (Show, Generic, Exception)
8888

89-
instance ToJSON WithdrawlQFull where
89+
instance ToJSON WithdrawalQFull where
9090
toJSON _ =
91-
object [ "error" .= ("Withdrawl queue is full" :: Text)
91+
object [ "error" .= ("Withdrawal queue is full" :: Text)
9292
, "status" .= ("error" :: Text) ]
9393

94-
instance ToSchema WithdrawlQFull where
94+
instance ToSchema WithdrawalQFull where
9595
declareNamedSchema _ = do
9696
strSchema <- declareSchemaRef (Proxy :: Proxy Text)
97-
return $ NamedSchema (Just "WithdrawlQFull") $ mempty
97+
return $ NamedSchema (Just "WithdrawalQFull") $ mempty
9898
& type_ .~ SwaggerObject
9999
& properties .~ (mempty
100100
& at "status" ?~ strSchema
101101
& at "error" ?~ strSchema)
102102
& required .~ ["status"]
103103

104104
--------------------------------------------------------------------------------
105-
data WithdrawlResult =
106-
WithdrawlError Text -- ^ Error with http client error
107-
| WithdrawlSuccess Transaction -- ^ Success with transaction details
105+
data WithdrawalResult =
106+
WithdrawalError Text -- ^ Error with http client error
107+
| WithdrawalSuccess Transaction -- ^ Success with transaction details
108108
deriving (Show, Typeable, Generic)
109109

110-
makePrisms ''WithdrawlResult
110+
makePrisms ''WithdrawalResult
111111

112-
instance ToJSON WithdrawlResult where
113-
toJSON (WithdrawlSuccess txn) =
112+
instance ToJSON WithdrawalResult where
113+
toJSON (WithdrawalSuccess txn) =
114114
object ["success" .= txn]
115-
toJSON (WithdrawlError err) =
115+
toJSON (WithdrawalError err) =
116116
object ["error" .= err]
117117

118118
wdDesc :: Text
119119
wdDesc = "An object with either a success field containing the transaction or "
120120
<> "an error field containing the ClientError from the wallet as a string"
121121

122-
instance ToSchema WithdrawlResult where
122+
instance ToSchema WithdrawalResult where
123123
declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
124-
{ constructorTagModifier = map Char.toLower . drop (length ("Withdrawl" :: String)) }
124+
{ constructorTagModifier = map Char.toLower . drop (length ("Withdrawal" :: String)) }
125125
& mapped.mapped.schema.description ?~ wdDesc
126126

127127
--------------------------------------------------------------------------------

faucet/src/Cardano/Faucet/Types/Config.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ data FaucetConfig = FaucetConfig {
151151
, _fcWalletApiPort :: !Int
152152
-- | Port to serve the faucet on
153153
, _fcPort :: !Int
154-
-- | Distribution for withdrawls (default to 1000 and 500)
154+
-- | Distribution for withdrawals (default to 1000 and 500)
155155
, _fcPaymentDistribution :: !PaymentDistribution
156156
-- | Statsd server details
157157
, _fcStatsdOpts :: !FaucetStatsdOpts
@@ -235,7 +235,7 @@ instance Exception InitFaucetError
235235
--------------------------------------------------------------------------------
236236
data ProcessorPayload = ProcessorPayload {
237237
_ppQueue :: !Payment
238-
, _ppResult :: !(TMVar WithdrawlResult)
238+
, _ppResult :: !(TMVar WithdrawalResult)
239239
}
240240

241241
makeLenses ''ProcessorPayload
@@ -244,7 +244,7 @@ makeLenses ''ProcessorPayload
244244
data FaucetEnv = FaucetEnv {
245245
-- | Counter for total amount withdawn from a wallet while faucet is running
246246
_feWithdrawn :: !Counter
247-
-- | Counter for number of withdrawls made
247+
-- | Counter for number of withdrawals made
248248
, _feNumWithdrawn :: !Counter
249249
-- | Gauge for wallet balance
250250
, _feWalletBalance :: !Gauge
@@ -258,8 +258,8 @@ data FaucetEnv = FaucetEnv {
258258
, _feFaucetConfig :: !FaucetConfig
259259
-- | Client for communicating with wallet API
260260
, _feWalletClient :: !(WalletClient IO)
261-
-- | Lock to ensure only one withdrawl at a time
262-
, _feWithdrawlQ :: !(TBQueue ProcessorPayload)
261+
-- | Lock to ensure only one withdrawal at a time
262+
, _feWithdrawalQ :: !(TBQueue ProcessorPayload)
263263
}
264264

265265
makeClassy ''FaucetEnv

faucet/src/Cardano/WalletClient.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ randomAmount (PaymentDistribution (getCoin -> amt) (getCoin -> var))= do
3939
--
4040
-- Simply sends a 'randomAmount' of ADA (units in lovelace )to the supplied
4141
-- 'Address'
42-
withdraw :: (MonadFaucet c m) => V1 Address -> m (Either WithdrawlQFull WithdrawlResult)
42+
withdraw :: (MonadFaucet c m) => V1 Address -> m (Either WithdrawalQFull WithdrawalResult)
4343
withdraw addr = withSublogger "WalletClient.withdraw" $ do
4444
paymentSource <- view (feSourceWallet . to cfgToPaymentSource)
4545
spendingPassword <- view (feSourceWallet . srcSpendingPassword)
4646
coin <- randomAmount =<< view (feFaucetConfig . fcPaymentDistribution)
47-
q <- view feWithdrawlQ
47+
q <- view feWithdrawalQ
4848
let paymentDist = (V1.PaymentDistribution addr coin :| [])
4949
sp = spendingPassword <&> view (re utf8 . to hashPwd . to V1)
5050
payment = Payment paymentSource paymentDist Nothing sp
@@ -60,15 +60,15 @@ withdraw addr = withSublogger "WalletClient.withdraw" $ do
6060
-- | Sends the 'Payment' to the processor queue
6161
--
6262
-- Returns a 'TMVar' to wait on for the response from the node
63-
-- See 'Cardano.Faucet.Init.processWithdrawls'
63+
-- See 'Cardano.Faucet.Init.processWithdrawals'
6464
sendToQueue
6565
:: TBQ.TBQueue ProcessorPayload
6666
-> Payment
67-
-> IO (Either WithdrawlQFull (TMVar WithdrawlResult))
67+
-> IO (Either WithdrawalQFull (TMVar WithdrawalResult))
6868
sendToQueue q payment = atomically $ do
6969
isFull <- TBQ.isFullTBQueue q
7070
if isFull
71-
then return $ Left WithdrawlQFull
71+
then return $ Left WithdrawalQFull
7272
else do
7373
resTMVar <- newEmptyTMVar
7474
TBQ.writeTBQueue q (ProcessorPayload payment resTMVar)

0 commit comments

Comments
 (0)