Skip to content

Commit 8f62994

Browse files
author
yushihang
committed
https://github.com/iden3/contracts/pull/327
create internal method instead _checkOracleSigningAddress and use custom error error OracleSigningAddressShouldNotBeZero() in it?
1 parent 1a2407a commit 8f62994

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

contracts/cross-chain/CrossChainProofValidator.sol

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
1313
contract CrossChainProofValidator is Ownable, EIP712, ICrossChainProofValidator {
1414
using ECDSA for bytes32;
1515

16+
error OracleSigningAddressShouldNotBeZero();
17+
1618
bytes32 public constant TYPE_HASH =
1719
keccak256(
1820
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
@@ -35,12 +37,18 @@ contract CrossChainProofValidator is Ownable, EIP712, ICrossChainProofValidator
3537

3638
address private _oracleSigningAddress;
3739

40+
function _checkOracleSigningAddress(address oracleSigningAddress) internal pure {
41+
if (oracleSigningAddress == address(0)) {
42+
revert OracleSigningAddressShouldNotBeZero();
43+
}
44+
}
45+
3846
constructor(
3947
string memory domainName,
4048
string memory signatureVersion,
4149
address oracleSigningAddress
4250
) EIP712(domainName, signatureVersion) Ownable(msg.sender) {
43-
require(oracleSigningAddress != address(0), "Oracle signing address should not be zero");
51+
_checkOracleSigningAddress(oracleSigningAddress);
4452
bytes32 hashedName = keccak256(bytes(domainName));
4553
bytes32 hashedVersion = keccak256(bytes(signatureVersion));
4654
uint256 chainId = 0;
@@ -64,7 +72,7 @@ contract CrossChainProofValidator is Ownable, EIP712, ICrossChainProofValidator
6472
* @param oracleSigningAddress The new oracle signing address
6573
**/
6674
function setOracleSigningAddress(address oracleSigningAddress) public onlyOwner {
67-
require(oracleSigningAddress != address(0), "Oracle signing address should not be zero");
75+
_checkOracleSigningAddress(oracleSigningAddress);
6876
_oracleSigningAddress = oracleSigningAddress;
6977
}
7078

0 commit comments

Comments
 (0)