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

Faucet rebased and squashed against develop #3541

Merged
merged 5 commits into from
Sep 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ GTAGS
GRTAGS
GPATH
TAGS
.projectile

# Vim
tags*
Expand Down Expand Up @@ -108,7 +109,6 @@ result*
# remove when done debugging
1.1.1-1-w/


# Created by https://www.gitignore.io/api/python

### Python ###
Expand Down Expand Up @@ -220,3 +220,13 @@ venv.bak/
/docs/on-the-wire/binary.fls
/docs/on-the-wire/binary.fdb_latexmk
/docs/on-the-wire/binary.dvi

# Don't include config files with sensitive data or tls certs
/faucet/test-config.json
/faucet/tls/*
/faucet/wallet-source.json
/faucet/existing-wallet-details.json
/faucet/generated-wallet-details.json
/faucet/default.nix
/faucet/shell.nix
/faucet/recaptcha-secret.txt
9 changes: 6 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ let
cardano-sl-wallet-static = justStaticExecutablesGitRev super.cardano-sl-wallet;
cardano-sl-client = addRealTimeTestLogs super.cardano-sl-client;
cardano-sl-generator = addRealTimeTestLogs super.cardano-sl-generator;
cardano-sl-auxx-static = justStaticExecutablesGitRev super.cardano-sl-auxx;
cardano-sl-wallet-new-static = justStaticExecutablesGitRev super.cardano-sl-wallet-new;
cardano-sl-auxx-static = justStaticExecutablesGitRev self.cardano-sl-auxx;
cardano-sl-wallet-new-static = justStaticExecutablesGitRev self.cardano-sl-wallet-new;
cardano-sl-node-static = justStaticExecutablesGitRev self.cardano-sl-node;
cardano-sl-explorer-static = justStaticExecutablesGitRev self.cardano-sl-explorer;
cardano-report-server-static = justStaticExecutablesGitRev self.cardano-report-server;
cardano-sl-tools-static = justStaticExecutablesGitRev (overrideCabal super.cardano-sl-tools (drv: {
cardano-sl-faucet-static = justStaticExecutablesGitRev self.cardano-sl-faucet;
cardano-sl-tools-static = justStaticExecutablesGitRev (overrideCabal self.cardano-sl-tools (drv: {
# waiting on load-command size fix in dyld
doCheck = ! pkgs.stdenv.isDarwin;
}));
Expand Down Expand Up @@ -176,6 +177,8 @@ let
inherit system config gitrev pkgs;
cardano-sl-explorer = cardanoPkgs.cardano-sl-explorer-static;
});
makeFaucetFrontend = pkgs.callPackage ./faucet/frontend;

all-cardano-sl = pkgs.buildEnv {
name = "all-cardano-sl";
paths = attrValues (filterAttrs (name: drv: localLib.isCardanoSL name) cardanoPkgs);
Expand Down
30 changes: 30 additions & 0 deletions faucet/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright IOHK (c) 2018

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of Ben Ford nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions faucet/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
143 changes: 143 additions & 0 deletions faucet/cardano-sl-faucet.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
-- This file has been generated from package.yaml by hpack version 0.18.1.
--
-- see: https://github.com/sol/hpack

name: cardano-sl-faucet
version: 0.1.0.0
description: Cardano SL - faucet
license: MIT
author: Ben Ford
maintainer: [email protected]
copyright: 2018 IOHK
build-type: Simple
cabal-version: >= 1.10

library
hs-source-dirs:
src
build-depends:
base
, QuickCheck
, aeson
, aeson-pretty
, base16-bytestring
, bytestring
, cardano-sl-core
, cardano-sl-crypto
, cardano-sl-chain
, cardano-sl-util
, cardano-sl-wallet
, cardano-sl-wallet-new
, connection
, cryptonite
, data-default
, directory
, ekg-core
, ekg-statsd
, exceptions
, filepath
, generic-arbitrary
, http-api-data
, http-client
, http-client-tls
, http-types
, lens
, log-warper
, memory
, mmorph
, mtl
, neat-interpolation
, random
, safe-exceptions
, serokell-util
, servant
, servant-client
, servant-client-core
, servant-server
, servant-swagger
, servant-swagger-ui
, stm
, swagger2
, tagged
, text
, text-format
, time
, tls
, universum
, wai
, wai-app-static
, wreq
exposed-modules:
Cardano.Faucet
, Cardano.Faucet.Endpoints
, Cardano.Faucet.Swagger
, Cardano.Faucet.Types.Config
, Cardano.Faucet.Types.API
, Cardano.Faucet.Types.Recaptcha
, Cardano.Faucet.Types
, Cardano.Faucet.Metrics
, Cardano.Faucet.Init
, Cardano.WalletClient
default-language: Haskell2010
default-extensions: NoImplicitPrelude
ghc-options: -Wall

executable cardano-faucet
main-is: Main.hs
hs-source-dirs:
server
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends:
base
, aeson
, bytestring
, cardano-sl-core
, cardano-sl-faucet
, cardano-sl-infra
, cardano-sl-chain
, cardano-sl-util
, cardano-sl-wallet
, cardano-sl-wallet-new
, ekg
, ekg-core
, ekg-statsd
, exceptions
, lens
, log-warper
, mmorph
, mtl
, optparse-applicative
, safe-exceptions
, servant
, servant-client
, servant-server
, text
, universum
, wai
, wai-cors
, wai-extra
, warp
default-language: Haskell2010
default-extensions: NoImplicitPrelude

test-suite faucet-test
type: exitcode-stdio-1.0
main-is: Spec.hs
hs-source-dirs:
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends:
base
, QuickCheck
, aeson
, bytestring
, cardano-sl-core
, cardano-sl-faucet
, cardano-sl-wallet
, cardano-sl-wallet-new
, hspec
, mtl
, time
, universum
default-language: Haskell2010
default-extensions: NoImplicitPrelude
25 changes: 25 additions & 0 deletions faucet/frontend/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This is a demo frontend for faucet for testing purposes.

{ lib, runCommand, gnused
, apiBaseURL ? ""
, explorerURL ? "http://cardano-explorer/"
, recaptchaSiteKey ? null
}:

let
template = ./index.html;
replaceAPIBaseURL = "-e 's|apiBaseURL:.*|apiBaseURL: \"${apiBaseURL}\",|g'";
replaceExplorerURL = "-e 's|explorerURL:.*|explorerURL: \"${explorerURL}\",|g'";
replaceSiteKey = if recaptchaSiteKey != null
then "-e 's|recaptchaSiteKey:.*|recaptchaSiteKey: \"${recaptchaSiteKey}\",|g'"
else "";

in
runCommand "cardano-sl-faucet-frontend" {} ''
mkdir -p $out
${gnused}/bin/sed \
${replaceAPIBaseURL} \
${replaceExplorerURL} \
${replaceSiteKey} \
${template} > $out/index.html
''
Loading