Skip to content

Commit

Permalink
feat(faucet): new faucet (#479)
Browse files Browse the repository at this point in the history
* feat(faucet): new faucet

This version of the Faucet does not have any limitations per user, only
limitations are daily token supply

* fix: minor css changes for mobile

* fix(faucet): add daily refresh and token refresh job

* fix(faucet): fix bugs and ci

* fix(faucet): remove unnessary go.mod files, replace dockerfile faucet-v2

* chore(faucet): remove unnessary variables and modify types

this will modify the types of DailyLimit and Batchinterval to remove
unnessary conversions and remove Cooldown and BatchInterval

* fix(faucet): acquire a lock when setting the new supply

* fix(faucet): removed locking where it's not needed

other enhancements as well, the loading and setting context to correct
place

* fix(faucet): converted background to much smaller image

* feat(faucet): make the run out of daily nicer

* feat(faucet): add new style

* feat(faucet): add check that same address cannot be multiple time in one batch

* feat(faucet): add metrics

* fix(faucet): Dockerfile libwasmvm was missing access rights

* feat(faucet): add pre input option to address form

---------

Co-authored-by: Jon Heywood <94459819+jjheywood@users.noreply.github.com>
  • Loading branch information
2 people authored and mn13 committed Sep 3, 2024
1 parent 57198d0 commit 63815ae
Show file tree
Hide file tree
Showing 20 changed files with 949 additions and 358 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/wardend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
- main
paths:
- "cmd/faucet/**"
- "cmd/faucet-v2/**"
- "cmd/wardend/**"
- "warden/**"
tags:
Expand All @@ -16,12 +15,11 @@ on:
pull_request:
paths:
- "cmd/faucet/**"
- "cmd/faucet-v2/**"
- "cmd/wardend/**"
- "warden/**"

env:
modules: "./warden/... ./cmd/wardend/... ./cmd/faucet/... ./cmd/faucet-v2/..."
modules: "./warden/... ./cmd/wardend/... ./cmd/faucet/..."

jobs:
lint:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* (x/warden) Rename `UpdateKeyRequest` to `FulfilKeyRequest`
* (x/warden) Rename `SignatureRequest` to `SignRequest`
* (x/oracle) Integrate Slinky
* (faucet) New version of the web based Faucet

### Features

Expand Down
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN --mount=type=bind,source=.,target=.,readonly\
RUN --mount=type=bind,source=.,target=.,readonly\
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
just output_dir=/build build faucet-v2
just output_dir=/build build faucet

FROM debian:bookworm-slim AS wardend
RUN apt update && \
Expand All @@ -47,14 +47,21 @@ RUN apt-get update && apt-get install -y \
useradd -M -u 1000 -U -s /bin/sh -d /data warden && \
install -o 1000 -g 1000 -d /data


COPY --from=wardend-build --chown=warden:warden /build/wardend /usr/bin/wardend
COPY --from=wardend-build --chown=warden:warden /build/faucet-v2 /usr/bin/faucet-v2
ADD --chown=warden:warden --checksum=sha256:015bdae5e70304f1e487981f90e3956754718fe7bdac4446aab0838fcb8b33e0 https://github.com/CosmWasm/wasmvm/releases/download/v2.1.2/libwasmvm.x86_64.so /lib/libwasmvm.x86_64.so
COPY --from=wardend-build --chown=warden:warden /build/faucet /usr/bin/faucet
ADD --checksum=sha256:015bdae5e70304f1e487981f90e3956754718fe7bdac4446aab0838fcb8b33e0 https://github.com/CosmWasm/wasmvm/releases/download/v2.1.2/libwasmvm.x86_64.so /lib/libwasmvm.x86_64.so
RUN chmod 444 /lib/libwasmvm.x86_64.so

EXPOSE 8000
USER warden
CMD ["/usr/bin/faucet-v2"]

COPY cmd/faucet/assets/ /assets
COPY cmd/faucet/css/ /css
COPY cmd/faucet/js/ /js
COPY cmd/faucet/templates/ /templates

EXPOSE 8081
CMD ["/usr/bin/faucet"]

## wardenkms
FROM build-env AS wardenkms-build
Expand Down
11 changes: 11 additions & 0 deletions cmd/faucet/assets/background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
238 changes: 238 additions & 0 deletions cmd/faucet/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
body {
background: linear-gradient(45deg, #140901, #1c1c0c);
color: #e4e6e0;
font-family: Syne, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}

.red-cross {
color: #caff94;
font-size: 150px;
text-align: center;
line-height: 1;
position: relative;
display: flex;
justify-content: center;
align-items: center;
height: 100px;
width: 100px;
margin: 50px auto;
border-radius: 50%;
animation: pulse 1s infinite;
}

@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}

.container {
text-align: center;
background-image: url("/assets/background.svg");
background-color: #140901;
background-repeat: no-repeat;
background-size: 50%;
background-position: top 2% center;
padding: 3rem;
border-radius: 16px;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
width: 23vw;
min-width: 400px;
height: 43vh;
min-height: 450px;
display: flex;
justify-content: center;
align-items: center;
}

@media screen and (max-width: 768px) {
.container {
width: 90vw;
margin: 0 16px;
min-width: 300px;
height: 90vh;
min-height: 300px;
}
}

.content {
padding: 0.1rem 2rem;
border-radius: 10px;
width: 100%;
max-height: 100%;
overflow-y: auto;
}

.tokens {
color: #caff94;
}

h1 {
color: #caff94;
margin-bottom: 1rem;
font-size: 2.5em;
}

form {
margin-bottom: 1rem;
}

input[type="text"] {
padding: 0.5rem;
margin: 0.5rem 0;
border-radius: 5px;
border: none;
width: 100%;
box-sizing: border-box;
background-color: rgba(255, 255, 255, 0.1);
color: white;
}

input[type="submit"] {
background-color: #caff94;
border: none;
color: black;
padding: 10px 20px;
text-align: center;
display: inline-block;
font-size: 16px;
cursor: pointer;
width: 100%;
border-radius: 5px;
transition: all 0.3s ease;
}

input[type="submit"]:hover {
opacity: 0.5;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

input[type="submit"]:active {
transform: translateY(2px);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

::placeholder {
color: rgba(255, 255, 255, 0.5);
}

.token-circle {
width: 200px;
height: 200px;
margin: 0 auto;
}

.token-circle svg {
transform: rotate(-90deg);
max-width: 200px;
}

#progressCircle {
transition: stroke-dashoffset 0.5s ease-out;
}

.htmx-indicator {
display: none;
}

.htmx-request .htmx-indicator {
display: inline-block;
}

.htmx-request.htmx-indicator {
display: inline-block;
}

.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(20, 9, 1, 255);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
z-index: 1000;
}

.spinner {
border: 8px solid #140901;
border-top: 8px solid #caff94;
border-radius: 50%;
opacity: 0.8;
width: 80px;
height: 80px;
animation: spin 1s linear infinite;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}

.spinner-text {
margin-top: 20px;
font-size: 18px;
text-align: center;
}

.error-message {
background-color: #ef5350;
color: #140901;
border: 1px solid #ef5350;
border-radius: 4px;
padding: 10px;
margin: 10px 0;
}

.tx-result {
border: 1px solid #ccc;
padding: 15px;
margin: 10px 0;
max-width: 100%;
box-sizing: border-box;
}

.tx-result p {
margin: 0 0 10px 0;
word-wrap: break-word;
overflow-wrap: break-word;
}

.tx-hash {
color: #caff94;
font-family: Syne, sans-serif;
}

.tx-result input[type="submit"] {
background-color: #4caf50;
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 4px;
}
Loading

0 comments on commit 63815ae

Please sign in to comment.