-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMainModuleDynamicAuth.sol
More file actions
83 lines (73 loc) · 2.77 KB
/
MainModuleDynamicAuth.sol
File metadata and controls
83 lines (73 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.17;
import "./commons/ModuleAuthDynamic.sol";
import "./commons/ModuleReceivers.sol";
import "./commons/ModuleCalls.sol";
import "./commons/ModuleUpdate.sol";
import "../interfaces/erc4337/IAccount.sol";
/**
* TODO Peter update docs
* @notice Contains the core functionality arcadeum wallets will inherit with
* the added functionality that the main-module can be changed.
* @dev If using a new main module, developpers must ensure that all inherited
* contracts by the mainmodule don't conflict and are accounted for to be
* supported by the supportsInterface method.
*/
contract MainModuleDynamicAuth is
ModuleAuthDynamic,
ModuleCalls,
ModuleReceivers,
ModuleUpdate,
IAccount
{
// solhint-disable-next-line no-empty-blocks
constructor(address _factory, address _startup) ModuleAuthDynamic (_factory, _startup) { }
/**
* @notice Query if a contract implements an interface
* @param _interfaceID The interface identifier, as specified in ERC-165
* @dev If using a new main module, developpers must ensure that all inherited
* contracts by the mainmodule don't conflict and are accounted for to be
* supported by the supportsInterface method.
* @return `true` if the contract implements `_interfaceID`
*/
function supportsInterface(
bytes4 _interfaceID
) public override(
ModuleAuthUpgradable,
ModuleCalls,
ModuleReceivers,
ModuleUpdate
) pure returns (bool) {
if (_interfaceID == type(IAccount).interfaceId) {
return true;
}
return super.supportsInterface(_interfaceID);
}
function validateUserOp(
UserOperation calldata userOp,
bytes32 userOpHash,
uint256 missingAccountFunds
) external override returns (uint256 validationData) {
// Check if there are missing funds.
// This is a basic check, a full implementation would require more logic.
if (missingAccountFunds > 0) {
revert("Not enough funds to cover transaction costs");
}
// Use the existing internal signature validation function.
// The nonce from the userOp is part of the userOpHash.
// Per ERC-4337, return 1 on signature failure. This is interpreted by the
// EntryPoint as a packed value where the `authorizer` field is 1, and the
// timestamp fields are 0.
if (!_signatureValidation(userOpHash, userOp.signature)) {
return 1;
}
// Return 0 for a standard signature validation. This is interpreted by the
// EntryPoint as a packed value where the `authorizer`, `validUntil`, and
// `validAfter` fields are all 0.
return 0;
}
function version() external pure virtual returns (uint256) {
return 1;
}
}