Skip to content

Commit b270beb

Browse files
committed
fix: solhint lints
1 parent c064d1f commit b270beb

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

.solhint.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
"extends": "solhint:recommended",
33
"rules": {
44
"func-visibility": ["warn", { "ignoreConstructors": true }],
5-
"compiler-version": ["error", "^0.8.0"],
65
"max-line-length": ["warn", 120],
76
"import-path-check": "off",
87
"use-natspec": "off",
9-
"gas-custom-errors": "warn",
10-
"gas-indexed-events": "warn",
11-
"gas-increment-by-one": "warn",
12-
"immutable-vars-naming": "warn"
8+
"gas-custom-errors": "error",
9+
"gas-indexed-events": "error",
10+
"gas-increment-by-one": "error",
11+
"immutable-vars-naming": "error"
1312
}
1413
}

contracts/src/NILFaucet.sol

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,26 @@ import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol
1111
/// @custom:security-contact security@nillion.com
1212
contract NILFaucet is Ownable, Pausable, ReentrancyGuard {
1313
using SafeERC20 for IERC20;
14-
IERC20 public immutable token;
14+
15+
error InvalidAddress();
16+
error ClaimNotAllowed(string reason);
17+
18+
IERC20 public immutable TOKEN;
1519
uint256 public dripAmount; // token smallest units
1620
uint256 public cooldownSeconds; // seconds between claims per address
1721
mapping(address => uint256) public lastClaimAt;
1822
mapping(address => uint256) public claimCount;
1923

20-
event Claimed(address indexed claimer, uint256 amount);
21-
event DripAmountUpdated(uint256 newAmount);
22-
event CooldownUpdated(uint256 newCooldownSeconds);
23-
event Withdrawn(address indexed to, uint256 amount);
24+
event Claimed(address indexed claimer, uint256 indexed amount);
25+
event DripAmountUpdated(uint256 indexed newAmount);
26+
event CooldownUpdated(uint256 indexed newCooldownSeconds);
27+
event Withdrawn(address indexed to, uint256 indexed amount);
2428

2529
constructor(address tokenAddress, uint256 _dripAmount, uint256 _cooldownSeconds, address initialOwner)
2630
Ownable(initialOwner)
2731
{
28-
require(tokenAddress != address(0), "BAD_TOKEN");
29-
token = IERC20(tokenAddress);
32+
if (tokenAddress == address(0)) revert InvalidAddress();
33+
TOKEN = IERC20(tokenAddress);
3034
dripAmount = _dripAmount;
3135
cooldownSeconds = _cooldownSeconds;
3236
}
@@ -50,7 +54,7 @@ contract NILFaucet is Ownable, Pausable, ReentrancyGuard {
5054
}
5155

5256
function faucetBalance() public view returns (uint256) {
53-
return token.balanceOf(address(this));
57+
return TOKEN.balanceOf(address(this));
5458
}
5559

5660
function canClaim(address user) public view returns (bool ok, string memory reason) {
@@ -69,16 +73,16 @@ contract NILFaucet is Ownable, Pausable, ReentrancyGuard {
6973

7074
function claim() external whenNotPaused nonReentrant {
7175
(bool ok, string memory reason) = canClaim(msg.sender);
72-
require(ok, reason);
76+
if (!ok) revert ClaimNotAllowed(reason);
7377
lastClaimAt[msg.sender] = block.timestamp;
74-
claimCount[msg.sender] += 1;
75-
token.safeTransfer(msg.sender, dripAmount);
78+
++claimCount[msg.sender];
79+
TOKEN.safeTransfer(msg.sender, dripAmount);
7680
emit Claimed(msg.sender, dripAmount);
7781
}
7882

7983
function withdraw(address to, uint256 amount) external onlyOwner nonReentrant {
80-
require(to != address(0), "BAD_TO");
81-
token.safeTransfer(to, amount);
84+
if (to == address(0)) revert InvalidAddress();
85+
TOKEN.safeTransfer(to, amount);
8286
emit Withdrawn(to, amount);
8387
}
8488
}

0 commit comments

Comments
 (0)