Skip to content

Commit

Permalink
add zero address checks
Browse files Browse the repository at this point in the history
  • Loading branch information
canercidam committed Dec 26, 2024
1 parent 09feff1 commit 9952341
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/AttesterWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {IAttesterWallet} from "./interfaces/IAttesterWallet.sol";
*/
contract AttesterWallet is IAttesterWallet, ERC20Upgradeable, AccessControlUpgradeable {
error ZeroBeneficiary();
error ZeroChargeAccount();
error ZeroSecurityValidator();
error ZeroTrustedAttesters();
error FailedToWithdrawFunds();
error FailedToFundAttester();

Expand All @@ -38,7 +41,9 @@ contract AttesterWallet is IAttesterWallet, ERC20Upgradeable, AccessControlUpgra
) public initializer {
__ERC20_init("Forta Attester Gas", "FORTAGAS");
_grantRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
if (address(_securityValidator) == address(0)) revert ZeroSecurityValidator();
securityValidator = _securityValidator;
if (address(_trustedAttesters) == address(0)) revert ZeroTrustedAttesters();
trustedAttesters = _trustedAttesters;
}

Expand All @@ -62,6 +67,7 @@ contract AttesterWallet is IAttesterWallet, ERC20Upgradeable, AccessControlUpgra
* @param _securityValidator Security validator address
*/
function setSecurityValidator(ISecurityValidator _securityValidator) public onlyRole(DEFAULT_ADMIN_ROLE) {
if (address(_securityValidator) == address(0)) revert ZeroSecurityValidator();
securityValidator = _securityValidator;
}

Expand Down Expand Up @@ -106,6 +112,8 @@ contract AttesterWallet is IAttesterWallet, ERC20Upgradeable, AccessControlUpgra
address chargeAccount,
uint256 chargeAmount
) public onlyTrustedAttester {
if (beneficiary == address(0)) revert ZeroBeneficiary();
if (chargeAccount == address(0)) revert ZeroChargeAccount();
securityValidator.storeAttestationForOrigin(attestation, attestationSignature, beneficiary);
/// Burn from user balance and send user ETH to the attester EOA.
_burn(chargeAccount, chargeAmount);
Expand Down
2 changes: 2 additions & 0 deletions src/SecurityValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract SecurityValidator is ISecurityValidator, EIP712 {
error AttestationNotFound();
error EmptyAttestation();
error UntrustedAttester(address currentAttester);
error ZeroOrigin();

/**
* @notice Transient storage slots used for storing the attestation values
Expand Down Expand Up @@ -100,6 +101,7 @@ contract SecurityValidator is ISecurityValidator, EIP712 {
bytes calldata attestationSignature,
address origin
) public onlyTrustedAttester {
if (origin == address(0)) revert ZeroOrigin();
_storeAttestation(attestation, attestationSignature, origin);
}

Expand Down

0 comments on commit 9952341

Please sign in to comment.