CoreWalletFacet
Inherits: IAccount, MultiOwnable, ERC1271, Receiver
Inherits from MultiOwnable for standardized owner management and ERC1271 for signature validation
Core wallet functionality including ERC-4337 compatibility and basic operations
State Variables
REPLAYABLE_NONCE_KEY
uint256 public constant REPLAYABLE_NONCE_KEY = 0xCA95;
Functions
onlyEntryPoint
modifier onlyEntryPoint();
notInEmergencyMode
modifier notInEmergencyMode();
initialize
Initialize the wallet with owners and configuration
function initialize(bytes[] calldata owners, string calldata walletType, uint256 requiredApprovals) external;
Parameters
owners
bytes[]
Array of owner data (addresses or WebAuthn pubkeys)
walletType
string
Type of wallet being created (string-based)
requiredApprovals
uint256
Number of approvals required for transactions
execute
Execute a transaction from the wallet
function execute(address target, uint256 value, bytes calldata data)
external
onlyOwner
notInEmergencyMode
returns (bool success, bytes memory result);
Parameters
target
address
Target contract address
value
uint256
ETH value to send
data
bytes
Transaction data
executeBatch
Execute multiple transactions in batch
function executeBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata datas)
external
onlyOwner
notInEmergencyMode;
Parameters
targets
address[]
Array of target addresses
values
uint256[]
Array of ETH values
datas
bytes[]
Array of transaction data
validateUserOp
ERC-4337 user operation validation
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)
external
override
onlyEntryPoint
returns (uint256 validationData);
getWalletInfo
Get wallet information
function getWalletInfo()
external
view
returns (string memory walletType, uint256 ownerCount, uint256 requiredApprovals, bool emergencyMode);
entryPoint
Get EntryPoint address
function entryPoint() public view returns (address);
activateEmergencyMode
Activate emergency mode (can be called by any owner)
function activateEmergencyMode() external onlyOwner;
deactivateEmergencyMode
Deactivate emergency mode (requires multiple owners)
function deactivateEmergencyMode() external onlyOwner;
_executeTransaction
Internal function to execute a transaction
function _executeTransaction(address target, uint256 value, bytes memory data)
internal
returns (bool success, bytes memory result);
_domainNameAndVersion
ERC1271 domain name and version
function _domainNameAndVersion() internal pure override returns (string memory name, string memory version);
_isValidSignature
ERC1271 signature validation implementation
function _isValidSignature(bytes32 hash, bytes calldata signature) internal view override returns (bool);
Parameters
hash
bytes32
The hash that was signed
signature
bytes
The signature to validate
Returns
<none>
bool
Whether the signature is valid
executeWithoutChainIdValidation
Only callable by EntryPoint, requires REPLAYABLE_NONCE_KEY
Execute calls without chain ID validation for cross-chain compatibility
function executeWithoutChainIdValidation(bytes[] calldata calls) external payable onlyEntryPoint;
getUserOpHashWithoutChainId
Get UserOp hash without chain ID for cross-chain operations
function getUserOpHashWithoutChainId(PackedUserOperation calldata userOp) public view returns (bytes32);
canSkipChainIdValidation
Check if a function selector can skip chain ID validation
function canSkipChainIdValidation(bytes4 functionSelector) public pure returns (bool);
_call
Internal function to execute a call
function _call(address target, uint256 value, bytes memory data) internal;
receive
Receive ETH
receive() external payable override;
Events
WalletInitialized
event WalletInitialized(address indexed wallet, string walletType);
TransactionExecuted
event TransactionExecuted(address indexed target, uint256 value, bytes data, bool success);
EmergencyModeActivated
event EmergencyModeActivated(address indexed activator);
EmergencyModeDeactivated
event EmergencyModeDeactivated(address indexed deactivator);
Errors
AlreadyInitialized
error AlreadyInitialized();
EmergencyModeActive
error EmergencyModeActive();
InsufficientApprovals
error InsufficientApprovals();
SelectorNotAllowed
error SelectorNotAllowed(bytes4 selector);
InvalidNonceKey
error InvalidNonceKey(uint256 key);
Structs
SignatureWrapper
A wrapper struct used for signature validation so that callers can identify the owner that signed.
struct SignatureWrapper {
uint256 ownerIndex;
bytes signatureData;
}
Last updated
Was this helpful?