Skip to content

Commit 249a3be

Browse files
authored
Resolve solhint and slither issues (#252)
* Resolve solhint and slither issues
1 parent 7fe0e65 commit 249a3be

21 files changed

+60
-70
lines changed

contracts/access/MintingAccessControl.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// SPDX-License-Identifier: Apache 2.0
33
pragma solidity 0.8.19;
44

5-
// solhint-disable no-unused-import
6-
import {AccessControlEnumerable, AccessControl, IAccessControl} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
5+
import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
76

87
abstract contract MintingAccessControl is AccessControlEnumerable {
98
/// @notice Role to mint tokens

contracts/bridge/x/v4/CoreV4.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// the StarkEx contract ABI that was provided by StarkWare via slack.
1010
pragma solidity ^0.8.19;
1111

12+
// solhint-disable func-name-mixedcase
1213
interface CoreV4 {
1314
fallback() external payable;
1415

contracts/deployer/create/OwnableCreateDeploy.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ contract OwnableCreateDeploy {
2222
* @param bytecode The bytecode of the contract to be deployed
2323
*/
2424
// slither-disable-next-line locked-ether
25-
2625
function deploy(bytes memory bytecode) external payable {
27-
// solhint-disable-next-line custom-errors
26+
// solhint-disable-next-line custom-errors, reason-string
2827
require(msg.sender == owner, "CreateDeploy: caller is not the owner");
28+
// solhint-disable no-inline-assembly
2929
assembly {
3030
if iszero(create(callvalue(), add(bytecode, 32), mload(bytecode))) {
3131
revert(0, 0)

contracts/deployer/create2/OwnableCreate2Deployer.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache 2.0
33
pragma solidity 0.8.19;
44

5-
import "@openzeppelin/contracts/access/Ownable.sol";
5+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
66
import {Deployer} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/Deployer.sol";
77
import {Create2} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/Create2.sol";
88

@@ -32,6 +32,8 @@ contract OwnableCreate2Deployer is Ownable, Create2, Deployer {
3232
* @param deploySalt A salt which is a hash of the salt provided by the sender and the sender's address.
3333
* @return The address of the deployed contract
3434
*/
35+
// Slither 0.10.4 is mistakenly seeing this as dead code. It is called from Deployer.deploy
36+
// slither-disable-next-line dead-code
3537
function _deploy(bytes memory bytecode, bytes32 deploySalt) internal override onlyOwner returns (address) {
3638
return _create2(bytecode, deploySalt);
3739
}

contracts/deployer/create3/OwnableCreate3.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ contract OwnableCreate3 is OwnableCreate3Address, IDeploy {
2727
* @param deploySalt A salt to influence the contract address
2828
* @return deployed The address of the deployed contract
2929
*/
30-
function _create3(bytes memory bytecode, bytes32 deploySalt) internal returns (address deployed) {
30+
// Slither 0.10.4 is mistakenly seeing this as dead code. It is called
31+
// from OwnableCreate3Deployer.deploy and could be called from other contracts.
32+
// slither-disable-next-line dead-code
33+
function _create3(bytes memory bytecode, bytes32 deploySalt) internal returns (address deployed) {
3134
deployed = _create3Address(deploySalt);
3235

3336
if (bytecode.length == 0) revert EmptyBytecode();

contracts/deployer/create3/OwnableCreate3Address.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ abstract contract OwnableCreate3Address {
1515
bytes32 internal immutable createDeployBytecodeHash;
1616

1717
constructor() {
18+
// Slither is mistakenly seeing the expansion of type(OwnableCreateDeploy).creationCode
19+
// as a very large number.
20+
// slither-disable-next-line too-many-digits
1821
createDeployBytecodeHash = keccak256(type(OwnableCreateDeploy).creationCode);
1922
}
2023

contracts/deployer/create3/OwnableCreate3Deployer.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache 2.0
33
pragma solidity 0.8.19;
44

5-
import "@openzeppelin/contracts/access/Ownable.sol";
5+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
66
import {Deployer} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/Deployer.sol";
77

88
import {OwnableCreate3} from "./OwnableCreate3.sol";
@@ -37,6 +37,8 @@ contract OwnableCreate3Deployer is Ownable, OwnableCreate3, Deployer {
3737
* @param deploySalt A salt which is a hash of the salt provided by the sender and the sender's address.
3838
* @return The address of the deployed contract
3939
*/
40+
// Slither 0.10.4 is mistakenly seeing this as dead code. It is called from Deployer.deploy
41+
// slither-disable-next-line dead-code
4042
function _deploy(bytes memory bytecode, bytes32 deploySalt) internal override onlyOwner returns (address) {
4143
return _create3(bytecode, deploySalt);
4244
}

contracts/token/erc1155/abstract/ERC1155Permit.sol

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,23 @@
22
// SPDX-License-Identifier: Apache 2.0
33
pragma solidity 0.8.19;
44

5-
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
6-
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
7-
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
8-
import "solidity-bytes-utils/contracts/BytesLib.sol";
9-
import "./IERC1155Permit.sol";
5+
import {ERC1155Burnable, ERC1155} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
6+
import {EIP712, ECDSA} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
7+
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
8+
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
9+
import {IERC1155Permit} from "./IERC1155Permit.sol";
1010
import {IImmutableERC1155Errors} from "../../../errors/Errors.sol";
1111

1212
abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImmutableERC1155Errors {
13-
1413
bytes32 private immutable _PERMIT_TYPEHASH =
1514
keccak256("Permit(address owner,address spender,bool approved,uint256 nonce,uint256 deadline)");
1615

17-
mapping(address => uint256) private _nonces;
16+
mapping(address account => uint256 nonce) private _nonces;
1817

19-
constructor(string memory name, string memory uri)
20-
ERC1155(uri)
21-
EIP712(name, "1")
22-
{}
18+
constructor(string memory name, string memory uri) ERC1155(uri) EIP712(name, "1") {}
2319

2420
function permit(address owner, address spender, bool approved, uint256 deadline, bytes memory sig) external {
21+
// solhint-disable-next-line not-rely-on-time
2522
if (deadline < block.timestamp) {
2623
revert PermitExpired();
2724
}
@@ -30,7 +27,7 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm
3027

3128
// smart contract signature validation
3229
if (_isValidERC1271Signature(owner, digest, sig)) {
33-
_setApprovalForAll(owner, spender, approved);
30+
_setApprovalForAll(owner, spender, approved);
3431
return;
3532
}
3633

@@ -63,16 +60,15 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm
6360
* @param owner The address for which to retrieve the nonce.
6461
* @return Current nonce of the given token.
6562
*/
66-
function nonces(
67-
address owner
68-
) external view returns (uint256) {
63+
function nonces(address owner) external view returns (uint256) {
6964
return _nonces[owner];
7065
}
7166

7267
/**
7368
* @notice Returns the domain separator used in the encoding of the signature for permits, as defined by EIP-712
7469
* @return the bytes32 domain separator
7570
*/
71+
// solhint-disable-next-line func-name-mixedcase
7672
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
7773
return _domainSeparatorV4();
7874
}
@@ -82,16 +78,10 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm
8278
* @param interfaceId The interface identifier, which is a 4-byte selector.
8379
* @return True if the contract implements `interfaceId` and the call doesn't revert, otherwise false.
8480
*/
85-
function supportsInterface(bytes4 interfaceId)
86-
public
87-
view
88-
virtual
89-
override(ERC1155)
90-
returns (bool)
91-
{
92-
return
93-
interfaceId == type(IERC1155Permit).interfaceId || // 0x9e3ae8e4
94-
super.supportsInterface(interfaceId);
81+
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155) returns (bool) {
82+
return
83+
interfaceId == type(IERC1155Permit).interfaceId || // 0x9e3ae8e4
84+
super.supportsInterface(interfaceId);
9585
}
9686

9787
/**
@@ -107,18 +97,10 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm
10797
bool approved,
10898
uint256 deadline
10999
) internal returns (bytes32) {
110-
return _hashTypedDataV4(
111-
keccak256(
112-
abi.encode(
113-
_PERMIT_TYPEHASH,
114-
owner,
115-
spender,
116-
approved,
117-
_nonces[owner]++,
118-
deadline
119-
)
120-
)
121-
);
100+
return
101+
_hashTypedDataV4(
102+
keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, approved, _nonces[owner]++, deadline))
103+
);
122104
}
123105

124106
/**
@@ -128,14 +110,10 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm
128110
* @param sig The actual signature bytes.
129111
* @return True if the signature is valid according to EIP-1271, otherwise false.
130112
*/
131-
function _isValidERC1271Signature(address spender, bytes32 digest, bytes memory sig) private view returns(bool) {
113+
function _isValidERC1271Signature(address spender, bytes32 digest, bytes memory sig) private view returns (bool) {
132114
// slither-disable-next-line low-level-calls
133115
(bool success, bytes memory res) = spender.staticcall(
134-
abi.encodeWithSelector(
135-
IERC1271.isValidSignature.selector,
136-
digest,
137-
sig
138-
)
116+
abi.encodeWithSelector(IERC1271.isValidSignature.selector, digest, sig)
139117
);
140118

141119
if (success && res.length == 32) {
@@ -154,8 +132,7 @@ abstract contract ERC1155Permit is ERC1155Burnable, EIP712, IERC1155Permit, IImm
154132
* @param owner The owner of the tokens.
155133
* @return True if the signature is from an approved operator or owner, otherwise false.
156134
*/
157-
function _isValidEOASignature(address recoveredSigner, address owner) private pure returns(bool) {
135+
function _isValidEOASignature(address recoveredSigner, address owner) private pure returns (bool) {
158136
return recoveredSigner != address(0) && recoveredSigner == owner;
159137
}
160-
161138
}

contracts/token/erc1155/abstract/ImmutableERC1155Base.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
// SPDX-License-Identifier: Apache 2.0
33
pragma solidity 0.8.19;
44

5-
import {ERC1155, ERC1155Permit} from "../../../token/erc1155/abstract/ERC1155Permit.sol";
5+
import {ERC1155Permit, ERC1155} from "../../../token/erc1155/abstract/ERC1155Permit.sol";
66

77
// Allowlist
88
import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
99
import {OperatorAllowlistEnforced} from "../../../allowlist/OperatorAllowlistEnforced.sol";
1010

1111
import {AccessControlEnumerable, MintingAccessControl} from "../../../access/MintingAccessControl.sol";
1212

13-
1413
abstract contract ImmutableERC1155Base is OperatorAllowlistEnforced, ERC1155Permit, ERC2981, MintingAccessControl {
1514
/// @dev Contract level metadata
1615
string public contractURI;

contracts/token/erc20/preset/ImmutableERC20MinterBurnerPermit.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ pragma solidity 0.8.19;
55
import {ERC20Permit, ERC20} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
66
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
77
import {ERC20Capped} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";
8-
import {MintingAccessControl, AccessControl, IAccessControl} from "../../../access/MintingAccessControl.sol";
8+
import {AccessControl, IAccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
9+
import {MintingAccessControl} from "../../../access/MintingAccessControl.sol";
910
import {IImmutableERC20Errors} from "./Errors.sol";
1011

1112
/**

0 commit comments

Comments
 (0)