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

Commit 711ac13

Browse files
author
Ben Ford
committed
[DEVOPS-834] Faucet component (squashed to single commit on top of develop
[DEVOPS-834] Add a process that checks the wallet balance periodically [DEVOPS-834] Uncomment type sig as suggested [DEVOPS-834] Fix copyright in license [DEVOPS-834] Split queue logic from withdrawl function Also document the processWithdrawls function [DEVOPS-834] Remove faucet shell.nix, default.nix and .projectile [DEVOPS-834] Remove commented code [DEVOPS-834] withdrawl -> withdrawal [DEVOPS-834] Get test suite running [DEVOPS-834] Apply stack2nix patch from buildkite And stylish.diff from hydra [DEVOPS-834] Change executable name to cardano-faucet [DEVOPS-834] Switch to optparse-applicative for command line Add the --ekg-server commandline option [DEVOPS-834] Use a file to read the recaptcha secret from a file * Config parameter has changed to "recaptcha-secret-file" * The actual secret is now a field in FaucetEnv [DEVOPS-834] Change logging of wallet balance to DEBUG [DEVOPS-834] Handle newlines in recaptcha secret file Also adds a couple of tests for readCaptchaSecret [DEVOPS-834] Apply stylish.diff [DEVOPS-834] Add demo frontend to faucet [DEVOPS-834] Fix faucet static serving [DEVOPS-834] Apply stylish haskell fixes [DEVOPS-834] Add universium and fix indentation/sorting of deps [DEVOPS-834] Switch to universum [DEVOPS-834] Switch to safe-exceptions [DEVOPS-834] Fix for upstream API changes [DEVOPS-834] Apply stack2nix patch [DEVOPS-834] Apply stylish.diff from hydra [DEVOPS-834] Remove existing wallet json file [DEVOP-834] Add -Wall everywhere [DEVOPS-834] Use a pattern match instead of whenJust [DEVOPS-834] Remove unused decrWithdrawn function [DEVOPS-834] Remove unused DepositRequest and DepositResult [DEVOPS-834] Remove -Wall from the modules [DEVOPS-834] Fix some warnings
1 parent 5659d4f commit 711ac13

29 files changed

+2048
-3
lines changed

.gitignore

+11-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GTAGS
4343
GRTAGS
4444
GPATH
4545
TAGS
46+
.projectile
4647

4748
# Vim
4849
tags*
@@ -104,7 +105,6 @@ result*
104105
# remove when done debugging
105106
1.1.1-1-w/
106107

107-
108108
# Created by https://www.gitignore.io/api/python
109109

110110
### Python ###
@@ -216,3 +216,13 @@ venv.bak/
216216
/docs/on-the-wire/binary.fls
217217
/docs/on-the-wire/binary.fdb_latexmk
218218
/docs/on-the-wire/binary.dvi
219+
220+
# Don't include config files with sensitive data or tls certs
221+
/faucet/test-config.json
222+
/faucet/tls/*
223+
/faucet/wallet-source.json
224+
/faucet/existing-wallet-details.json
225+
/faucet/generated-wallet-details.json
226+
/faucet/default.nix
227+
/faucet/shell.nix
228+
/faucet/recaptcha-secret.txt

default.nix

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ let
5858
cardano-sl-client = addRealTimeTestLogs super.cardano-sl-client;
5959
cardano-sl-generator = addRealTimeTestLogs super.cardano-sl-generator;
6060
cardano-sl-auxx = justStaticExecutablesGitRev super.cardano-sl-auxx;
61-
cardano-sl-wallet-new = justStaticExecutablesGitRev super.cardano-sl-wallet-new;
61+
cardano-sl-wallet-new-static = justStaticExecutablesGitRev self.cardano-sl-wallet-new;
6262
cardano-sl-node-static = justStaticExecutablesGitRev self.cardano-sl-node;
6363
cardano-sl-explorer-static = justStaticExecutablesGitRev self.cardano-sl-explorer;
6464
cardano-report-server-static = justStaticExecutablesGitRev self.cardano-report-server;
65+
cardano-sl-faucet-static = justStaticExecutablesGitRev self.cardano-sl-faucet;
6566
cardano-sl-tools = justStaticExecutablesGitRev (overrideCabal super.cardano-sl-tools (drv: {
6667
# waiting on load-command size fix in dyld
6768
doCheck = ! pkgs.stdenv.isDarwin;
@@ -166,6 +167,8 @@ let
166167
inherit system config gitrev pkgs;
167168
cardano-sl-explorer = cardanoPkgs.cardano-sl-explorer-static;
168169
});
170+
makeFaucetFrontend = pkgs.callPackage ./faucet/frontend;
171+
169172
all-cardano-sl = pkgs.buildEnv {
170173
name = "all-cardano-sl";
171174
paths = attrValues (filterAttrs (name: drv: localLib.isCardanoSL name) cardanoPkgs);

faucet/LICENSE

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright IOHK (c) 2018
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Ben Ford nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

faucet/Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

faucet/cardano-sl-faucet.cabal

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
-- This file has been generated from package.yaml by hpack version 0.18.1.
2+
--
3+
-- see: https://github.com/sol/hpack
4+
5+
name: cardano-sl-faucet
6+
version: 0.1.0.0
7+
description: Cardano SL - faucet
8+
license: MIT
9+
author: Ben Ford
10+
maintainer: [email protected]
11+
copyright: 2018 IOHK
12+
build-type: Simple
13+
cabal-version: >= 1.10
14+
15+
library
16+
hs-source-dirs:
17+
src
18+
build-depends:
19+
base
20+
, QuickCheck
21+
, aeson
22+
, aeson-pretty
23+
, base16-bytestring
24+
, bytestring
25+
, cardano-sl-core
26+
, cardano-sl-crypto
27+
, cardano-sl-chain
28+
, cardano-sl-util
29+
, cardano-sl-wallet
30+
, cardano-sl-wallet-new
31+
, connection
32+
, cryptonite
33+
, data-default
34+
, directory
35+
, ekg-core
36+
, ekg-statsd
37+
, exceptions
38+
, filepath
39+
, generic-arbitrary
40+
, http-api-data
41+
, http-client
42+
, http-client-tls
43+
, http-types
44+
, lens
45+
, log-warper
46+
, memory
47+
, mmorph
48+
, mtl
49+
, neat-interpolation
50+
, random
51+
, safe-exceptions
52+
, serokell-util
53+
, servant
54+
, servant-client
55+
, servant-client-core
56+
, servant-server
57+
, servant-swagger
58+
, servant-swagger-ui
59+
, stm
60+
, swagger2
61+
, tagged
62+
, text
63+
, text-format
64+
, time
65+
, tls
66+
, universum
67+
, wai
68+
, wai-app-static
69+
, wreq
70+
exposed-modules:
71+
Cardano.Faucet
72+
, Cardano.Faucet.Endpoints
73+
, Cardano.Faucet.Swagger
74+
, Cardano.Faucet.Types.Config
75+
, Cardano.Faucet.Types.API
76+
, Cardano.Faucet.Types.Recaptcha
77+
, Cardano.Faucet.Types
78+
, Cardano.Faucet.Metrics
79+
, Cardano.Faucet.Init
80+
, Cardano.WalletClient
81+
default-language: Haskell2010
82+
default-extensions: NoImplicitPrelude
83+
ghc-options: -Wall
84+
85+
executable cardano-faucet
86+
main-is: Main.hs
87+
hs-source-dirs:
88+
server
89+
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
90+
build-depends:
91+
base
92+
, aeson
93+
, bytestring
94+
, cardano-sl-core
95+
, cardano-sl-faucet
96+
, cardano-sl-infra
97+
, cardano-sl-chain
98+
, cardano-sl-util
99+
, cardano-sl-wallet
100+
, cardano-sl-wallet-new
101+
, ekg
102+
, ekg-core
103+
, ekg-statsd
104+
, exceptions
105+
, lens
106+
, log-warper
107+
, mmorph
108+
, mtl
109+
, optparse-applicative
110+
, safe-exceptions
111+
, servant
112+
, servant-client
113+
, servant-server
114+
, text
115+
, universum
116+
, wai
117+
, wai-cors
118+
, wai-extra
119+
, warp
120+
default-language: Haskell2010
121+
default-extensions: NoImplicitPrelude
122+
123+
test-suite faucet-test
124+
type: exitcode-stdio-1.0
125+
main-is: Spec.hs
126+
hs-source-dirs:
127+
test
128+
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
129+
build-depends:
130+
base
131+
, QuickCheck
132+
, aeson
133+
, bytestring
134+
, cardano-sl-core
135+
, cardano-sl-faucet
136+
, cardano-sl-wallet
137+
, cardano-sl-wallet-new
138+
, hspec
139+
, mtl
140+
, time
141+
, universum
142+
default-language: Haskell2010
143+
default-extensions: NoImplicitPrelude

faucet/frontend/default.nix

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This is a demo frontend for faucet for testing purposes.
2+
3+
{ lib, runCommand, gnused
4+
, apiBaseURL ? ""
5+
, explorerURL ? "http://cardano-explorer/"
6+
, recaptchaSiteKey ? null
7+
}:
8+
9+
let
10+
template = ./index.html;
11+
replaceAPIBaseURL = "-e 's|apiBaseURL:.*|apiBaseURL: \"${apiBaseURL}\",|g'";
12+
replaceExplorerURL = "-e 's|explorerURL:.*|explorerURL: \"${explorerURL}\",|g'";
13+
replaceSiteKey = if recaptchaSiteKey != null
14+
then "-e 's|recaptchaSiteKey:.*|recaptchaSiteKey: \"${recaptchaSiteKey}\",|g'"
15+
else "";
16+
17+
in
18+
runCommand "cardano-sl-faucet-frontend" {} ''
19+
mkdir -p $out
20+
${gnused}/bin/sed \
21+
${replaceAPIBaseURL} \
22+
${replaceExplorerURL} \
23+
${replaceSiteKey} \
24+
${template} > $out/index.html
25+
''

0 commit comments

Comments
 (0)