Skip to content

Commit

Permalink
Update sdk to 13.3.2 and some fixes (#24)
Browse files Browse the repository at this point in the history
* chore: update nodejs to 20

* chore: regenerate package-lock

* chore: use aescan instead old explorer

* chore: stop server on container stopping

* refactor: use `path.resolve` instead `import.meta.url`

* docs: address in url

* fix: don't duplicate AE suffix

* chore(deps): update backend
  • Loading branch information
davidyuk authored Apr 22, 2024
1 parent 22512e8 commit 35cf806
Show file tree
Hide file tree
Showing 10 changed files with 7,733 additions and 14,630 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.envrc
node_modules
test-account
.vscode
assets
templates
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# front-end build
FROM node:16 AS frontend
FROM node:20-alpine AS frontend

WORKDIR /app

COPY ./frontend/package*.json ./
RUN npm ci

COPY ./frontend ./
RUN npm run prod
RUN NODE_OPTIONS=--openssl-legacy-provider npm run prod

# actual build
FROM node:16
FROM node:20-alpine

# use app directory
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ISC License (ISC)
Copyright 2018 aeternity developers
Copyright 2024 aeternity developers

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Send Online Top-up. Instant Account Recharge

Recharge your account on the Aeternity Testnet

## Provide address in URL

If you navigate the user to the faucet from a wallet, it would be friendly to substitute the user's address into the form. Use `address` query parameter for that. For example,
```
https://faucet.aepps.com/?address=ak_21A27UVVt3hDkBE5J7rhhqnH5YNb4Y1dqo4PnSybrH85pnWo7E
```

## Configuration

Configuring Faucet application via environment variable:
Expand Down
15 changes: 7 additions & 8 deletions faucet.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { fileURLToPath } from 'url';
import path from 'path';
import express from 'express';
import mustache from 'mustache-express';
Expand All @@ -10,9 +9,6 @@ import {
} from '@aeternity/aepp-sdk';
import cors from 'cors';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const setRequiredVariable = (variableName) => {
if (process.env[variableName]) {
return process.env[variableName];
Expand All @@ -26,7 +22,7 @@ const TOPUP_AMOUNT = process.env.TOPUP_AMOUNT || '5';
const SPEND_TX_PAYLOAD = process.env.SPEND_TX_PAYLOAD || 'Faucet Tx';
// node, explorer & support
const NODE_URL = process.env.NODE_URL || 'https://testnet.aeternity.io';
const EXPLORER_URL = process.env.EXPLORER_URL || 'https://explorer.testnet.aeternity.io';
const EXPLORER_URL = process.env.EXPLORER_URL || 'https://testnet.aescan.io';
const SUPPORT_EMAIL = process.env.SUPPORT_EMAIL || '[email protected]';
// graylisting
const CACHE_MAX_SIZE = process.env.CACHE_MAX_SIZE || 6000;
Expand Down Expand Up @@ -65,14 +61,14 @@ app.use(cors());
// set up mustache templating
app.engine('mustache', mustache());
app.set('view engine', 'mustache');
app.set('views', `${__dirname}/templates`);
app.set('views', path.resolve('templates'));

// static assets
app.use('/assets', express.static(path.join(__dirname, 'assets')));
app.use('/assets', express.static(path.resolve('assets')));

// serve frontend
app.get('/', (req, res) => {
res.render('index', {amount: `${TOPUP_AMOUNT} AE`, node: NODE_URL, explorer_url: EXPLORER_URL});
res.render('index', {amount: TOPUP_AMOUNT, node: NODE_URL, explorer_url: EXPLORER_URL});
});

let nonce;
Expand Down Expand Up @@ -135,3 +131,6 @@ logger.info(`Faucet listening at http://${SERVER_LISTEN_ADDRESS}:${SERVER_LISTEN
logger.info(`Faucet Address: ${aeSdk.address}`);
logger.info(`Faucet Balance: ${toAe(await aeSdk.getBalance(aeSdk.address))} AE`);
logger.info(`Log-level: ${FAUCET_LOG_LEVEL}`);

process.on('SIGINT', () => app.close());
process.on('SIGTERM', () => app.close());
Loading

0 comments on commit 35cf806

Please sign in to comment.