Skip to content

Commit

Permalink
Merge pull request #50 from forta-network/caner/zero-address-checks
Browse files Browse the repository at this point in the history
Add zero address checks
  • Loading branch information
canercidam authored Dec 26, 2024
2 parents eee8916 + 9952341 commit 48af12f
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 Down Expand Up @@ -44,7 +47,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 @@ -68,6 +73,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 @@ -112,6 +118,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 48af12f

Please sign in to comment.