Skip to content

Commit

Permalink
update error message display on view
Browse files Browse the repository at this point in the history
  • Loading branch information
okedeji committed Mar 28, 2024
1 parent 6939e37 commit 98e4ec5
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 13 deletions.
6 changes: 3 additions & 3 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default {
},
blockchains: [
{
name: "allora-edgenet",
name: "edgenet",
endpoint: {
// make sure that CORS is enabled in rpc section in config.toml
// cors_allowed_origins = ["*"]
rpc_endpoint: "allora-rpc.prod-us-east-1.edgenet.allora.network:8443",
rpc_endpoint: "https://allora-rpc.edgenet.allora.network",
},
sender: {
mnemonic,
Expand All @@ -44,7 +44,7 @@ export default {
},
limit: {
// how many times each wallet address is allowed in a window(24h)
address: 300,
address: 2,
// how many times each ip is allowed in a window(24h),
// if you use proxy, double check if the req.ip is return client's ip.
ip: 10000
Expand Down
9 changes: 7 additions & 2 deletions faucet.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ app.get('/send/:chain/:address', async (req, res, next) => {
await checker.update(address)
res.send({ result: ret, tokens: chainConf.tx.amount, recipient: address})
}else {
res.send({ result: "You requested too often" })
res.send({
result: {
code: 429,
message: 'Too Many Requests',
}
})
}
} else {
res.send({ result: `Address [${address}] is not supported.` })
Expand Down Expand Up @@ -212,4 +217,4 @@ async function sendEvmosTx2(recipient, chain) {
const chainConf = conf.blockchains.find(x => x.name === chain)
// create a wallet instance
const wallet = Wallet.fromMnemonic(chainConf.sender.mnemonic).connect(chainConf.endpoint.evm_endpoint);
}
}
129 changes: 129 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@
document.getElementById("button-loading").style.display = 'none';
// show result
this.message = `
<div class="alert alert-${data.result.code === 0 ? 'success' : 'danger'} alert-dismissible show fade mt-2" role="alert">
<li>${data.result.code === 0 ? 'Tokens sent' : 'Request failed'}</li>
<textarea class="form-control mt-1" rows="5" style="background-color:transparent">${JSON.stringify(data.tokens, null, 2)}</textarea>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-${data.result.code === 0 ? 'success' : 'danger'} alert-dismissible show fade mt-2" role="alert">
<li>${data.result.code === 0 ? 'Tokens sent' : data.result.message || 'Request failed'}</li>
<textarea class="form-control mt-1" rows="5" style="background-color:transparent">${data.result.code === 0 ? JSON.stringify(data.tokens, null, 2) : (data.result.code === 429 ? "Sorry, you've exceeded the daily limit for requests from this address or IP": JSON.stringify(data.result, null, 2)) || 'Error details not available.'}</textarea>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`;
} catch (e) {
// show request failed message
Expand All @@ -137,4 +137,4 @@
<script>
</script>
</body>
</html>
</html>
Loading

0 comments on commit 98e4ec5

Please sign in to comment.