-
Notifications
You must be signed in to change notification settings - Fork 3
K1Validator
Inherits: IValidator
This contract is a simple validator for testing purposes, verifying user operation signatures against registered owners.
Mapping of smart account addresses to their respective owner addresses
mapping(address => address) public smartAccountOwners;
Important
This mapping stores the owner of each smart account. Ensuring this mapping is correctly maintained is critical for the validation of user operations.
Called upon module installation to set the owner of the smart account
function onInstall(bytes calldata data) external;
Parameters
Name | Type | Description |
---|---|---|
data |
bytes |
Encoded address of the owner |
Caution
Ensure the provided data contains a valid owner address to prevent installation failures.
Called upon module uninstallation to remove the owner of the smart account
function onUninstall(bytes calldata) external;
Checks if the smart account is initialized with an owner
function isInitialized(address smartAccount) external view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
smartAccount |
address |
The address of the smart account |
Returns
Name | Type | Description |
---|---|---|
<none> |
bool |
True if the smart account has an owner, false otherwise |
Validates a user operation by checking the signature against the owner's address
function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
userOp |
PackedUserOperation |
The user operation to validate |
userOpHash |
bytes32 |
The hash of the user operation |
Returns
Name | Type | Description |
---|---|---|
<none> |
uint256 |
The validation result (0 for success, 1 for failure) |
Validates a signature with the sender's address
function isValidSignatureWithSender(address, bytes32 hash, bytes calldata data) external view returns (bytes4);
Parameters
Name | Type | Description |
---|---|---|
<none> |
address |
|
hash |
bytes32 |
The hash of the data to validate |
data |
bytes |
The signature data |
Returns
Name | Type | Description |
---|---|---|
<none> |
bytes4 |
The magic value if the signature is valid, otherwise an invalid value |
Returns the name of the module
function name() external pure returns (string memory);
Returns
Name | Type | Description |
---|---|---|
<none> |
string |
The name of the module |
Returns the version of the module
function version() external pure returns (string memory);
Returns
Name | Type | Description |
---|---|---|
<none> |
string |
The version of the module |
Checks if the module is of the specified type
function isModuleType(uint256 typeID) external pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
typeID |
uint256 |
The type ID to check |
Returns
Name | Type | Description |
---|---|---|
<none> |
bool |
True if the module is of the specified type, false otherwise |
Error to indicate that no owner was provided during installation
error NoOwnerProvided();
Warning
Ensure that the owner's address is provided during the installation of the validator. Failure to do so will result in the NoOwnerProvided
error, preventing the module from being installed properly.
- Home
- Nexus Architecture
- Access Control
- Execution Framework
- Modules
- Factories
- Migration Guide
- Testing Documentation
- Configuration and Security
- Libraries
- FAQ
- Biconomy Solidity Style Guide
- Security Considerations
- Team
-
Contracts
- Nexus
- Base
- Common
- Factory
- AbstractNexusFactory
- BiconomyMetaFactory
- K1ValidatorFactory
- ModuleWhitelistFactory
- NexusAccountFactory
- Modules
- Utils