Skip to content

Commit

Permalink
updated solhint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Amiel committed Jun 27, 2023
1 parent f668693 commit 3ca19d5
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 33 deletions.
8 changes: 7 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"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",
"var-name-mixedcase": "off",
"no-complex-fallback": "off",
"not-rely-on-time": "off"
}
}
8 changes: 1 addition & 7 deletions contracts/AxelarGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ contract AxelarGateway is IAxelarGateway, 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 @@ -169,7 +167,6 @@ contract AxelarGateway is IAxelarGateway, 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 @@ -246,7 +243,6 @@ contract AxelarGateway is IAxelarGateway, 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 @@ -331,7 +327,7 @@ contract AxelarGateway is IAxelarGateway, 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 @@ -356,7 +352,6 @@ contract AxelarGateway is IAxelarGateway, 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 @@ -596,7 +591,6 @@ contract AxelarGateway is IAxelarGateway, 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
4 changes: 0 additions & 4 deletions contracts/AxelarGatewayProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ contract AxelarGatewayProxy is EternalStorage {

if (gatewayImplementation.code.length == 0) revert InvalidImplementation();

// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = gatewayImplementation.delegatecall(abi.encodeWithSelector(IAxelarGateway.setup.selector, params));

if (!success) revert SetupFailed();
}

// solhint-disable-next-line no-empty-blocks
function setup(bytes calldata params) external {}

// solhint-disable-next-line no-complex-fallback
fallback() external payable {
address implementation = getAddress(KEY_IMPLEMENTATION);

// solhint-disable-next-line no-inline-assembly
assembly {
calldatacopy(0, 0, calldatasize())

Expand Down
1 change: 0 additions & 1 deletion contracts/ECDSA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ library ECDSA {

// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
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
1 change: 0 additions & 1 deletion contracts/deposit-service/AxelarDepositServiceProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ contract AxelarDepositServiceProxy is Proxy {
}

// @dev This function is for receiving refunds when refundAddress was 0x0
// solhint-disable-next-line no-empty-blocks
receive() external payable override {}
}
3 changes: 0 additions & 3 deletions contracts/deposit-service/DepositReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ contract DepositReceiver {
constructor(bytes memory delegateData, address refundAddress) {
// Reading the implementation of the AxelarDepositService
// and delegating the call back to it
// solhint-disable-next-line avoid-low-level-calls
(bool success, ) = IAxelarDepositService(msg.sender).receiverImplementation().delegatecall(delegateData);

// if not success revert with the original revert data
if (!success) {
// solhint-disable-next-line no-inline-assembly
assembly {
let ptr := mload(0x40)
let size := returndatasize()
Expand All @@ -28,6 +26,5 @@ contract DepositReceiver {
}

// @dev This function is for receiving Ether from unwrapping WETH9
// solhint-disable-next-line no-empty-blocks
receive() external payable {}
}
11 changes: 2 additions & 9 deletions contracts/util/Proxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ contract Proxy {
bytes32 internal constant _OWNER_SLOT = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0;

constructor() {
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(_OWNER_SLOT, caller())
}
Expand All @@ -29,44 +28,38 @@ contract Proxy {
bytes memory params
) external {
address owner;
// solhint-disable-next-line no-inline-assembly
assembly {
owner := sload(_OWNER_SLOT)
}
if (msg.sender != owner) revert NotOwner();
if (implementation() != address(0)) revert AlreadyInitialized();
if (IUpgradable(implementationAddress).contractId() != contractId()) revert InvalidImplementation();

// solhint-disable-next-line no-inline-assembly
assembly {
sstore(_IMPLEMENTATION_SLOT, implementationAddress)
sstore(_OWNER_SLOT, newOwner)
}
// solhint-disable-next-line avoid-low-level-calls

(bool success, ) = implementationAddress.delegatecall(
//0x9ded06df is the setup selector.
abi.encodeWithSelector(0x9ded06df, params)
);
if (!success) revert SetupFailed();
}

// solhint-disable-next-line no-empty-blocks
function contractId() internal pure virtual returns (bytes32) {}

function implementation() public view returns (address implementation_) {
// solhint-disable-next-line no-inline-assembly
assembly {
implementation_ := sload(_IMPLEMENTATION_SLOT)
}
}

// solhint-disable-next-line no-empty-blocks
function setup(bytes calldata data) public {}

// solhint-disable-next-line no-complex-fallback
fallback() external payable {
address implementaion_ = implementation();
// solhint-disable-next-line no-inline-assembly

assembly {
calldatacopy(0, 0, calldatasize())

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 {}
}

0 comments on commit 3ca19d5

Please sign in to comment.