Skip to content

Commit

Permalink
feat: add autoclose param
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio committed Jul 31, 2024
1 parent e16ec67 commit d5b3cbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ When integrating the faucet you can use the following query params to enhance th
| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| 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 |

Ex.: `http://localhost:3000/?address=fuel134ddh9pfsspar086htdldwxq2jsr3yvqtj5w456kkrz3s653la5q347kmc&redirectUrl=http://localhost:4000`
### Example - Redirect
- `http://localhost:3000/?address=fuel134ddh9pfsspar086htdldwxq2jsr3yvqtj5w456kkrz3s653la5q347kmc&redirectUrl=http://localhost:4000`

### Example - Auto Close
- `http://localhost:3000/?address=fuel134ddh9pfsspar086htdldwxq2jsr3yvqtj5w456kkrz3s653la5q347kmc&autoClose`
6 changes: 6 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ <h2 class="response-title">Test Ether sent to the wallet</h2>
let query = params = new URLSearchParams(document.location.search);
let address = query.get('address');
let redirectUrl = query.get('redirectUrl');
let autoClose = query.get('autoClose');
let buttonSubmit = form.querySelector("input[type=submit]");
let shouldAutoClose = (autoClose === "" || autoClose === "true");

if (address) {
let $address = document.getElementById('address');
Expand Down Expand Up @@ -342,6 +344,10 @@ <h2 class="response-title">Test Ether sent to the wallet</h2>
document.getElementById("form").hidden = true;
document.getElementById("response").style.display = "block";
link.href = `${blockExplorer}/tx/${tx_id}`;

if (shouldAutoClose) {
window.close();
}

if (redirectUrl) {
try {
Expand Down

0 comments on commit d5b3cbc

Please sign in to comment.