Skip to content

Commit

Permalink
updated solhint with common warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Amiel committed Jul 4, 2023
1 parent 1c85714 commit d1b97d7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
13 changes: 12 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
"rules": {
"quotes": ["error", "single"],
"compiler-version": ["off"],
"func-visibility": ["warn", {"ignoreConstructors": true}]
"func-visibility": ["warn", { "ignoreConstructors": true }],
"no-inline-assembly": "off",
"no-empty-blocks": "off",
"avoid-low-level-calls": "off",
"not-rely-on-time": "off",
"no-complex-fallback": "off",
"const-name-snakecase": "off",
"var-name-mixedcase": "off",
"func-name-mixedcase": "off",
"state-visibility": "off",
"reason-string": "off",
"no-global-import": "off"
}
}
8 changes: 1 addition & 7 deletions contracts/AxelarGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ contract AxelarGateway is IAxelarGateway, IGovernable, AdminMultisigBase {
bytes32 internal constant SELECTOR_APPROVE_CONTRACT_CALL_WITH_MINT = keccak256('approveContractCallWithMint');
bytes32 internal constant SELECTOR_TRANSFER_OPERATORSHIP = keccak256('transferOperatorship');

// solhint-disable-next-line var-name-mixedcase
address internal immutable AUTH_MODULE;
// solhint-disable-next-line var-name-mixedcase
address internal immutable TOKEN_DEPLOYER_IMPLEMENTATION;

constructor(address authModule_, address tokenDeployerImplementation_) {
Expand Down Expand Up @@ -199,7 +197,6 @@ contract AxelarGateway is IAxelarGateway, IGovernable, AdminMultisigBase {
}

function tokenMintAmount(string memory symbol) public view override returns (uint256) {
// solhint-disable-next-line not-rely-on-time
return getUint(_getTokenMintAmountKey(symbol, block.timestamp / 6 hours));
}

Expand Down Expand Up @@ -284,7 +281,6 @@ contract AxelarGateway is IAxelarGateway, IGovernable, AdminMultisigBase {
// AUDIT: If `newImplementation.setup` performs `selfdestruct`, it will result in the loss of _this_ implementation (thereby losing the gateway)
// if `upgrade` is entered within the context of _this_ implementation itself.
if (setupParams.length != 0) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = newImplementation.delegatecall(abi.encodeWithSelector(IAxelarGateway.setup.selector, setupParams));

if (!success) revert SetupFailed();
Expand Down Expand Up @@ -364,7 +360,7 @@ contract AxelarGateway is IAxelarGateway, IGovernable, AdminMultisigBase {

// Prevent a re-entrancy from executing this command before it can be marked as successful.
_setCommandExecuted(commandId, true);
// solhint-disable-next-line avoid-low-level-calls

(bool success, ) = address(this).call(abi.encodeWithSelector(commandSelector, params[i], commandId));

if (success) emit Executed(commandId);
Expand All @@ -389,7 +385,6 @@ contract AxelarGateway is IAxelarGateway, IGovernable, AdminMultisigBase {
// If token address is no specified, it indicates a request to deploy one.
bytes32 salt = keccak256(abi.encodePacked(symbol));

// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory data) = TOKEN_DEPLOYER_IMPLEMENTATION.delegatecall(
abi.encodeWithSelector(ITokenDeployer.deployToken.selector, name, symbol, decimals, cap, salt)
);
Expand Down Expand Up @@ -629,7 +624,6 @@ contract AxelarGateway is IAxelarGateway, IGovernable, AdminMultisigBase {
uint256 limit = tokenMintLimit(symbol);
if (limit > 0 && amount > limit) revert ExceedMintLimit(symbol);

// solhint-disable-next-line not-rely-on-time
_setUint(_getTokenMintAmountKey(symbol, block.timestamp / 6 hours), amount);
}

Expand Down
1 change: 0 additions & 1 deletion contracts/auth/AxelarAuthWeighted.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ contract AxelarAuthWeighted is Ownable, IAxelarAuthWeighted {
mapping(uint256 => bytes32) public hashForEpoch;
mapping(bytes32 => uint256) public epochForHash;

// solhint-disable-next-line var-name-mixedcase
uint256 internal constant OLD_KEY_RETENTION = 16;

constructor(bytes[] memory recentOperators) {
Expand Down
8 changes: 2 additions & 6 deletions contracts/util/Upgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ abstract contract Upgradable is IUpgradable {
}

function owner() public view returns (address owner_) {
// solhint-disable-next-line no-inline-assembly
assembly {
owner_ := sload(_OWNER_SLOT)
}
Expand All @@ -26,14 +25,13 @@ abstract contract Upgradable is IUpgradable {
if (newOwner == address(0)) revert InvalidOwner();

emit OwnershipTransferred(newOwner);
// solhint-disable-next-line no-inline-assembly

assembly {
sstore(_OWNER_SLOT, newOwner)
}
}

function implementation() public view returns (address implementation_) {
// solhint-disable-next-line no-inline-assembly
assembly {
implementation_ := sload(_IMPLEMENTATION_SLOT)
}
Expand All @@ -48,14 +46,13 @@ abstract contract Upgradable is IUpgradable {
if (newImplementationCodeHash != newImplementation.codehash) revert InvalidCodeHash();

if (params.length > 0) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = newImplementation.delegatecall(abi.encodeWithSelector(this.setup.selector, params));

if (!success) revert SetupFailed();
}

emit Upgraded(newImplementation);
// solhint-disable-next-line no-inline-assembly

assembly {
sstore(_IMPLEMENTATION_SLOT, newImplementation)
}
Expand All @@ -68,6 +65,5 @@ abstract contract Upgradable is IUpgradable {
_setup(data);
}

// solhint-disable-next-line no-empty-blocks
function _setup(bytes calldata data) internal virtual {}
}
6 changes: 3 additions & 3 deletions test/AxelarGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ describe('AxelarGateway', () => {
const implementationBytecodeHash = keccak256(implementationBytecode);

const expected = {
istanbul: '0x17a01ff5bbba4c774611e48aa3fe775d0816d7e3dc4598fb518c07112cdd1c6c',
berlin: '0x5760b30dd8560a5036202d1dfcdb4cbd6293799816c97aa71155e23b3e265d12',
london: '0xe724c1ace9300cc8e768faee4b445062212155cd2d767b13ccba36aff016232d',
istanbul: '0x7244fa469d9705621f861fd4768c3bda4e6ac42f499df622f1c56d136b5d1916',
berlin: '0x799e7eae28ae24caf45cf390ba7e063dc11493fa09268078b326c81ef9afe39c',
london: '0x3dbcdca193daa494ebfcdef03d53e2807a5186e2c6c3131ee2ebdca277c7bfed',
}[getEVMVersion()];

expect(implementationBytecodeHash).to.be.equal(expected);
Expand Down

0 comments on commit d1b97d7

Please sign in to comment.