Skip to content

Commit

Permalink
fix: update rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dristpunk committed Feb 1, 2024
1 parent bba63f9 commit 1de0ab8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 682 deletions.
16 changes: 2 additions & 14 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
{
"extends": "solhint:recommended",
"plugins": ["defi-wonderland"],
"rules": {
"compiler-version": ["off"],
"constructor-syntax": "warn",
"quotes": ["error", "single"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"not-rely-on-time": "off",
"func-name-mixedcase": "off",
"var-name-mixedcase": "off",
"const-name-snakecase": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "off",
"private-vars-leading-underscore": ["warn", { "strict": false }],
"defi-wonderland/non-state-vars-leading-underscore": ["warn"],
"defi-wonderland/contract-data-order": ["warn"],
"defi-wonderland/enum-name-camelcase": ["warn"],
"defi-wonderland/immutable-name-snakecase": ["warn"],
"defi-wonderland/import-statement-format": ["warn"],
"defi-wonderland/interface-member-order": ["warn"],
"defi-wonderland/interface-starts-with-i": ["warn"],
"defi-wonderland/named-return-values": ["warn"],
"defi-wonderland/struct-name-camelcase": ["warn"],
"defi-wonderland/wonder-var-name-mixedcase": ["warn"],
"ordering": "warn",
"immutable-name-snakecase": "warn",
"avoid-low-level-calls": "off",
"no-console": "off"
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"husky": ">=8",
"lint-staged": ">=10",
"solhint": "github:solhint-community/solhint-community#v4.0.0-rc01",
"solhint-plugin-defi-wonderland": "1.1.0",
"sort-package-json": "1.53.1"
}
}
32 changes: 16 additions & 16 deletions solidity/contracts/Greeter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ contract Greeter is IGreeter {
/// @inheritdoc IGreeter
IERC20 public token;

/**
* @notice Reverts in case the function was not called by the owner of the contract
*/
modifier onlyOwner() {
if (msg.sender != OWNER) {
revert Greeter_OnlyOwner();
}
_;
}

/**
* @notice Defines the owner to the msg.sender and sets the initial greeting
* @param _greeting Initial greeting
Expand All @@ -31,6 +41,12 @@ contract Greeter is IGreeter {
setGreeting(_greeting);
}

/// @inheritdoc IGreeter
function greet() external view returns (string memory _greeting, uint256 _balance) {
_greeting = greeting;
_balance = token.balanceOf(msg.sender);
}

/// @inheritdoc IGreeter
function setGreeting(string memory _greeting) public onlyOwner {
if (keccak256(bytes(_greeting)) == _EMPTY_STRING) {
Expand All @@ -40,20 +56,4 @@ contract Greeter is IGreeter {
greeting = _greeting;
emit GreetingSet(_greeting);
}

/// @inheritdoc IGreeter
function greet() external view returns (string memory _greeting, uint256 _balance) {
_greeting = greeting;
_balance = token.balanceOf(msg.sender);
}

/**
* @notice Reverts in case the function was not called by the owner of the contract
*/
modifier onlyOwner() {
if (msg.sender != OWNER) {
revert Greeter_OnlyOwner();
}
_;
}
}
20 changes: 10 additions & 10 deletions solidity/interfaces/IGreeter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ interface IGreeter {
*/
error Greeter_InvalidGreeting();

/*///////////////////////////////////////////////////////////////
LOGIC
//////////////////////////////////////////////////////////////*/
/**
* @notice Sets a new greeting
* @dev Only callable by the owner
* @param _newGreeting The new greeting to be set
*/
function setGreeting(string memory _newGreeting) external;

/*///////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -62,14 +72,4 @@ interface IGreeter {
* @return _balance Current token balance of the caller
*/
function greet() external view returns (string memory _greeting, uint256 _balance);

/*///////////////////////////////////////////////////////////////
LOGIC
//////////////////////////////////////////////////////////////*/
/**
* @notice Sets a new greeting
* @dev Only callable by the owner
* @param _newGreeting The new greeting to be set
*/
function setGreeting(string memory _newGreeting) external;
}
Loading

0 comments on commit 1de0ab8

Please sign in to comment.