From 03ec0dd1aef56d80c3af0840d3ae88958f83d5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Est=C3=A1cio=20=7C=20stacio=2Eeth?= Date: Wed, 7 Aug 2024 14:03:20 -0300 Subject: [PATCH] feat: add redirect and autoClose features (#73) --- README.md | 42 +++++++++++++++++++++--------- static/index.html | 65 +++++++++++++++++++++++++++++++++++++++++------ tests/dispense.rs | 1 - 3 files changed, 87 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 6c9f724..a297284 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Faucet App -=== +# Faucet App + [![build](https://github.com/FuelLabs/faucet/actions/workflows/ci.yml/badge.svg)](https://github.com/FuelLabs/faucet/actions/workflows/ci.yml) [![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe) @@ -7,19 +7,21 @@ A simple faucet app for dispensing tokens on a fuel network. It uses Google capt without requiring any social media based identification. ## Configuration + The faucet makes use of environment variables for configuration. -| Environment Variable | Description | -|----------------------|-------------------------------------------------------------------------| -| RUST_LOG | EnvFilter configuration for adjusting logging granularity. | -| HUMAN_LOGGING | If false, logs will be output as machine readable JSON. | -| CAPTCHA_SECRET | The secret key used for enabling Google captcha authentication. | -| CAPTCHA_KEY | The website key used for enabling Google captcha authentication. | -| WALLET_SECRET_KEY | A hex formatted string of the wallet private key that owns some tokens. | -| FUEL_NODE_URL | The GraphQL endpoint for connecting to fuel-core. | +| Environment Variable | Description | +| -------------------- | ----------------------------------------------------------------------------------------------- | +| RUST_LOG | EnvFilter configuration for adjusting logging granularity. | +| HUMAN_LOGGING | If false, logs will be output as machine readable JSON. | +| CAPTCHA_SECRET | The secret key used for enabling Google captcha authentication. | +| CAPTCHA_KEY | The website key used for enabling Google captcha authentication. | +| WALLET_SECRET_KEY | A hex formatted string of the wallet private key that owns some tokens. | +| FUEL_NODE_URL | The GraphQL endpoint for connecting to fuel-core. | | PUBLIC_FUEL_NODE_URL | The public GraphQL endpoint for connecting to fuel-core. Ex.: https://node.fuel.network/graphql | -| SERVICE_PORT | The port the service will listen for http connections on. | -| DISPENSE_AMOUNT | Dispense amount on each faucet | +| SERVICE_PORT | The port the service will listen for http connections on. | +| DISPENSE_AMOUNT | Dispense amount on each faucet | +| MIN_GAS_PRICE | The minimum gas price to use in each transfer | ## Build and Run @@ -28,3 +30,19 @@ To run locally, assuming environment variables have already been set: ```sh cargo run ``` + +## Query Params + +When integrating the faucet you can use the following query params to enhance the user experience: + +| Name | Type | Description | +| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| address | Address | Auto-fill the address field using the provided value | +| redirectUrl | String | If provided with a valid url, once the faucet is complete, the user will be redirected back to the url with tx_id as a query param | +| autoClose | String | If provided empty or true will close automatically the window after the transaction is finished | + +### Example - Redirect +- `http://localhost:3000/?address=fuel134ddh9pfsspar086htdldwxq2jsr3yvqtj5w456kkrz3s653la5q347kmc&redirectUrl=http://localhost:4000` + +### Example - Auto Close +- `http://localhost:3000/?address=fuel134ddh9pfsspar086htdldwxq2jsr3yvqtj5w456kkrz3s653la5q347kmc&autoClose` diff --git a/static/index.html b/static/index.html index 5e7f087..8447edd 100644 --- a/static/index.html +++ b/static/index.html @@ -138,6 +138,11 @@ color: #949494; } + .provider-url a { + color: #949494; + text-decoration: underline; + } + .agreements { text-align: left; margin-top: 25px; @@ -146,7 +151,7 @@ font-size: 14px; } - .queued { + .queued, .redirect-container { display: flex; flex-direction: column; align-items: center; @@ -183,6 +188,10 @@ .hidden { display: none; } + + .footer { + z-index: 9; + } @@ -241,15 +250,27 @@

Test Ether sent to the wallet

+ See on Fuel Explorer
-
Node url: {{ public_node_url }}
+