-
Notifications
You must be signed in to change notification settings - Fork 10
Add UI Support for Faucet Endpoint #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arejula27
wants to merge
6
commits into
vulpemventures:master
Choose a base branch
from
arejula27:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Faucet</title> | ||
| <!-- Tailwind CDN --> | ||
| <script src="https://cdn.tailwindcss.com"></script> | ||
| </head> | ||
|
|
||
| <body class="bg-gray-100 flex items-center justify-center min-h-screen"> | ||
| <div class="bg-white shadow-lg rounded-2xl p-8 max-w-md w-full"> | ||
| <h1 class="text-3xl font-bold mb-2 text-center text-blue-600">Faucet</h1> | ||
| <p class="text-gray-600 text-center mb-6">Get your Bitcoin!</p> | ||
| <form id="faucet-form" class="space-y-4"> | ||
| <div> | ||
| <label for="address" class="block text-gray-700 font-medium">Wallet Address:</label> | ||
| <input type="text" id="address" name="address" required | ||
| class="mt-1 w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"> | ||
| </div> | ||
| <div> | ||
| <label for="amount" class="block text-gray-700 font-medium">Amount:</label> | ||
| <input type="number" id="amount" name="amount" min="1" required | ||
| class="mt-1 w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"> | ||
| </div> | ||
| <button type="submit" | ||
| class="w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded-lg transition"> | ||
| Claim Tokens | ||
| </button> | ||
| </form> | ||
| <div id="message" class="mt-4 text-center text-sm"></div> | ||
| </div> | ||
|
|
||
| <script> | ||
| document.getElementById("faucet-form").addEventListener("submit", async function (e) { | ||
| e.preventDefault(); | ||
|
|
||
| const address = document.getElementById("address").value; | ||
| const amount = document.getElementById("amount").value; | ||
| const messageDiv = document.getElementById("message"); | ||
| try { | ||
| const res = await fetch("/faucet", { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json" | ||
| }, | ||
| body: JSON.stringify({address, amount}) | ||
| }); | ||
|
|
||
| const data = await res.json(); | ||
|
|
||
| if (res.ok) { | ||
| let txId = data.txId; | ||
|
|
||
| messageDiv.textContent = txId | ||
| ? `✅ Tokens sent successfully! TxID: ${txId}` | ||
| : "✅ Tokens sent successfully!"; | ||
| messageDiv.className = "mt-4 text-green-600 text-center break-words"; | ||
| } else { | ||
| messageDiv.textContent = data.error || "❌ Something went wrong."; | ||
| messageDiv.className = "mt-4 text-red-600 text-center"; | ||
| } | ||
| } catch (error) { | ||
| messageDiv.textContent = "⚠️ Network error. Please try again."; | ||
| messageDiv.className = "mt-4 text-red-600 text-center"; | ||
| } | ||
|
|
||
|
|
||
| }); | ||
| </script> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded file path "pages/faucet.html" makes the code less maintainable and could fail if the file structure changes. Consider making this configurable or using a constant to define template paths.