Skip to content

Commit

Permalink
fix solhint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Feb 3, 2025
1 parent d46b262 commit ccd69f9
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion contracts/AlwaysRevert.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.27;

error TheContractIsDisabled();

/// @title This contract as a dummy implementation for Proxy contract if we need to revert all calls
// This can be applied to disable all methods of a proxy contract with explicit error message
contract AlwaysRevert {
fallback() external payable {
revert("The contract is disabled");
revert TheContractIsDisabled();
}
}
2 changes: 2 additions & 0 deletions contracts/Create2AddressAnchor.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.27;

/* solhint-disable no-empty-blocks */
contract Create2AddressAnchor {}
/* solhint-enable no-empty-blocks */
2 changes: 2 additions & 0 deletions contracts/imports.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ pragma solidity 0.8.27;

// We import these here to force Hardhat to compile them.
// This ensures that their artifacts are available for Hardhat Ignition to use.
/* solhint-disable no-unused-import */
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
/* solhint-enable no-unused-import */
1 change: 1 addition & 0 deletions contracts/validators/auth/AuthV2Validator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract AuthV2Validator is Ownable2StepUpgradeable, IAuthValidator, ERC165 {
* @return userID user ID of public signals as result.
*/
function verify(
// solhint-disable-next-line no-unused-vars
address sender,
bytes calldata proof,
// solhint-disable-next-line no-unused-vars
Expand Down
7 changes: 5 additions & 2 deletions contracts/validators/auth/EthIdentityValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ pragma solidity 0.8.27;

import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IGroth16Verifier} from "../../interfaces/IGroth16Verifier.sol";
import {GenesisUtils} from "../../lib/GenesisUtils.sol";
import {IAuthValidator} from "../../interfaces/IAuthValidator.sol";
import {IState} from "../../interfaces/IState.sol";

error SenderIsNotIdentityOwner();

/**
* @dev EthIdentityValidator validator
*/
Expand Down Expand Up @@ -95,6 +96,8 @@ contract EthIdentityValidator is Ownable2StepUpgradeable, IAuthValidator, ERC165
function _verifyEthIdentity(uint256 id, address sender) internal view {
bytes2 idType = _getState().getIdTypeIfSupported(id);
uint256 calcId = GenesisUtils.calcIdFromEthAddress(idType, sender);
require(calcId == id, "Sender is not owner of the ethereum identity");
if (calcId != id) {
revert SenderIsNotIdentityOwner();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity 0.8.27;
import {CredentialAtomicQueryValidatorBase} from "./CredentialAtomicQueryValidatorBase.sol";
import {IGroth16Verifier} from "../../interfaces/IGroth16Verifier.sol";
import {IRequestValidator} from "../../interfaces/IRequestValidator.sol";
import {IState} from "../../interfaces/IState.sol";

/**
* @dev Base contract for credential atomic query v2 validators circuits.
Expand Down
5 changes: 4 additions & 1 deletion scripts/maintenance/disableProxyContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ async function main() {
await new Promise((resolve) => setTimeout(resolve, 20000));

// !!!!! Put proper function name here to make some check, e.g. getDefaultIdType() for State contract !!!!!
await expect(contract.getDefaultIdType()).to.be.revertedWith("The contract is disabled");
await expect(contract.getDefaultIdType()).to.be.revertedWithCustomError(
contract,
"TheContractIsDisabled",
);

const network = hre.network.name;
console.log(
Expand Down
4 changes: 2 additions & 2 deletions test/disable-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe("Disable Proxy Contract test", async () => {

const alwaysRevertFactory = await ethers.getContractFactory("AlwaysRevert");
await upgrades.upgradeProxy(await verifier.getAddress(), alwaysRevertFactory);
await expect(verifier.verifyProof(d[0], d[1], d[2], d[3])).to.be.revertedWith(
"The contract is disabled",
await expect(verifier.verifyProof(d[0], d[1], d[2], d[3])).to.be.rejectedWith(
"TheContractIsDisabled()",
);

await upgrades.upgradeProxy(await verifier.getAddress(), verifierStubFactory);
Expand Down

0 comments on commit ccd69f9

Please sign in to comment.