Skip to content

Commit

Permalink
Make MAX_BALANCE optional
Browse files Browse the repository at this point in the history
  • Loading branch information
harryttd committed Oct 13, 2023
1 parent 0b165da commit 0ec4db9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Optional:
- `AUTHORIZED_HOST`: CORS origin whitelist (default `*`)
- `DISABLE_CHALLENGES`: `true` to disable challenges (default: `false`)
- `ENABLE_CAPTCHA`: `true` to enable ReCAPTCHA, `false` otherwise (default: `true`)
- `MAX_BALANCE`: maximum address balance beyond which sending of XTZ is refused (default: `6000`)
- `MAX_BALANCE`: maximum address balance beyond which sending of XTZ is refused (default: `null`)
- `MIN_TEZ`: Minimum amount of Tez that can be requested (default: `1`)
- `MAX_TEZ`: Maximum amount of Tez that can be requested (default: `6000`)
- `DIFFICULTY`: Difficulty level for challenges (default: `4`)
Expand Down
2 changes: 1 addition & 1 deletion src/Tezos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const sendTez = async (
const userBalanceMutez = await Tezos.tz.getBalance(address)
const userBalance = Number(format("mutez", "tz", userBalanceMutez).valueOf())

if (userBalance + amount > env.MAX_BALANCE) {
if (env.MAX_BALANCE !== null && userBalance + amount > env.MAX_BALANCE) {
console.log(`${address} balance too high (${userBalance}). Not sending.`)
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type InfoResponseBody = {
faucetAddress: string
captchaEnabled: boolean
challengesEnabled: boolean
maxBalance: number
maxBalance: number | null
minTez: number,
maxTez: number
}
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const env = {
...process.env,
DISABLE_CHALLENGES: DISABLE_CHALLENGES === "true",
ENABLE_CAPTCHA: ENABLE_CAPTCHA !== "false",
MAX_BALANCE: MAX_BALANCE ? Number(MAX_BALANCE) : 6000,
MAX_BALANCE: MAX_BALANCE ? Number(MAX_BALANCE) : null,
MIN_TEZ: MIN_TEZ ? Number(MIN_TEZ) : 1,
MAX_TEZ: MAX_TEZ ? Number(MAX_TEZ) : 6000,
CHALLENGE_SIZE: CHALLENGE_SIZE ? Number(CHALLENGE_SIZE) : 2048,
Expand Down

0 comments on commit 0ec4db9

Please sign in to comment.