diff --git a/CHANGELOG.md b/CHANGELOG.md index 6df5f88343..f0d8636ae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to ## [Unreleased] +### Fixed + +- @cosmjs/faucet: Fix cooldown value from 86 seconds to 24 hours. + ## [0.28.10] - 2022-06-29 ### Fixed diff --git a/packages/faucet/src/api/webserver.ts b/packages/faucet/src/api/webserver.ts index ae17951f1f..335bd1185f 100644 --- a/packages/faucet/src/api/webserver.ts +++ b/packages/faucet/src/api/webserver.ts @@ -67,10 +67,11 @@ export class Webserver { const entry = this.addressCounter.get(address); if (entry !== undefined) { - if (entry.getTime() + 24 * 3600 > Date.now()) { + const cooldownMs = constants.cooldown * 3600 * 1000; + if (entry.getTime() + cooldownMs > Date.now()) { throw new HttpError( 405, - "Too many request from the same address. Blocked to prevent draining. Please wait 24h and try it again!", + `Too many request for the same address. Blocked to prevent draining. Please wait ${constants.cooldown}h and try it again!`, ); } } diff --git a/packages/faucet/src/constants.ts b/packages/faucet/src/constants.ts index a6f5350513..40ca9d9f1b 100644 --- a/packages/faucet/src/constants.ts +++ b/packages/faucet/src/constants.ts @@ -17,3 +17,4 @@ export const pathPattern = process.env.FAUCET_PATH_PATTERN || "m/44'/118'/0'/0/a export const tokenConfig: TokenConfiguration = { bankTokens: parseBankTokens(process.env.FAUCET_TOKENS || "ucosm, ustake"), }; +export const cooldown = 24; // hours