Search code examples
blockchainsoliditycloud-foundryforgeopenzeppelin

Solidity Error: Identifier not found or not unique (UserOperation)


I'm encountering a compilation error in my Solidity code related to the UserOperation type. I'm using the BaseAccount contract from the account-abstraction library and trying to implement the _validateSignature function. However, the compiler throws an error saying "Identifier not found or not unique (UserOperation)".

Error (7920): Identifier not found or not unique.
   --> src/email-account/EmailAccount.sol:230:9:
    |
230 |         UserOperation calldata userOp,
    |         ^^^^^^^^^^^^^

Here's the relevant code snippet:


import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";

import "account-abstraction/core/BaseAccount.sol";
import "account-abstraction/core/Helpers.sol";
import "../callback/TokenCallbackHandler.sol";

import {Verifier} from "./Verifier.sol";
import "../utils/StringUtils.sol";

contract EmailAccount is
    BaseAccount,
    TokenCallbackHandler,
    UUPSUpgradeable,
    Initializable
{
/// implement template method of BaseAccount
    function _validateSignature(
        UserOperation calldata userOp,
        bytes32 userOpHash
    ) internal virtual override returns (uint256 validationData) {
        bytes32 hash = userOpHash.toEthSignedMessageHash();
        if (owner != hash.recover(userOp.signature))
            return SIG_VALIDATION_FAILED;
        return 0;
    }
}

Thank you in advance.


Solution

  • you are using variable UserOperation from one of the inherited classes. check those classes and most likely you are either using UserOperation wrong or it does not even exist.