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

Commit 324fbc2

Browse files
authored
Merge pull request #2939 from input-output-hk/faucet
[DEVOPS-834] Cardano faucet package
2 parents 770c3c2 + ce421d8 commit 324fbc2

29 files changed

+2079
-3
lines changed

.gitignore

+11-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ GTAGS
4242
GRTAGS
4343
GPATH
4444
TAGS
45+
.projectile
4546

4647
# Vim
4748
tags*
@@ -103,7 +104,6 @@ result*
103104
# remove when done debugging
104105
1.1.1-1-w/
105106

106-
107107
# Created by https://www.gitignore.io/api/python
108108

109109
### Python ###
@@ -207,3 +207,13 @@ venv.bak/
207207
.mypy_cache/
208208

209209
# End of https://www.gitignore.io/api/python
210+
211+
# Don't include config files with sensitive data or tls certs
212+
/faucet/test-config.json
213+
/faucet/tls/*
214+
/faucet/wallet-source.json
215+
/faucet/existing-wallet-details.json
216+
/faucet/generated-wallet-details.json
217+
/faucet/default.nix
218+
/faucet/shell.nix
219+
/faucet/recaptcha-secret.txt

default.nix

+5-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ let
8686
# cardano-sl-auxx = addGitRev (justStaticExecutables super.cardano-sl-auxx);
8787
cardano-sl-auxx = addGitRev (justStaticExecutables super.cardano-sl-auxx);
8888
cardano-sl-node = addGitRev super.cardano-sl-node;
89-
cardano-sl-wallet-new = addGitRev (justStaticExecutables (buildWithBenchmarks super.cardano-sl-wallet-new));
89+
cardano-sl-wallet-new = addGitRev super.cardano-sl-wallet-new;
90+
cardano-sl-wallet-new-static = addGitRev (justStaticExecutables (buildWithBenchmarks super.cardano-sl-wallet-new));
9091
cardano-sl-tools = addGitRev (justStaticExecutables (overrideCabal super.cardano-sl-tools (drv: {
9192
# waiting on load-command size fix in dyld
9293
doCheck = ! pkgs.stdenv.isDarwin;
@@ -95,6 +96,7 @@ let
9596
cardano-sl-node-static = justStaticExecutables self.cardano-sl-node;
9697
cardano-sl-explorer-static = addGitRev (justStaticExecutables self.cardano-sl-explorer);
9798
cardano-report-server-static = justStaticExecutables self.cardano-report-server;
99+
cardano-sl-faucet-static = addGitRev (justStaticExecutables self.cardano-sl-faucet);
98100

99101
# Undo configuration-nix.nix change to hardcode security binary on darwin
100102
# This is needed for macOS binary not to fail during update system (using http-client-tls)
@@ -168,6 +170,8 @@ let
168170
inherit system config gitrev pkgs;
169171
cardano-sl-explorer = cardanoPkgs.cardano-sl-explorer-static;
170172
});
173+
makeFaucetFrontend = pkgs.callPackage ./faucet/frontend;
174+
171175
mkDocker = { environment, connectArgs ? {} }: import ./docker.nix { inherit environment connect gitrev pkgs connectArgs; };
172176
stack2nix = import (pkgs.fetchFromGitHub {
173177
owner = "avieth";

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-update
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-update
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)