-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release/v1.0.1 #226
Release/v1.0.1 #226
Changes from all commits
773943f
9937eef
9e7f3ab
70e7e89
1a81d3d
d64df5c
fa90983
1bf437e
d073e59
58069b5
db28ef9
17f12b4
2e83bed
ae30c5f
8797ddd
94d85f9
a7f8b32
fa415c4
4aba898
0351f93
69f437b
fad4eff
c109389
4136703
bbe68ea
d015436
c4f9b0f
cdd4d5f
792a770
f40701f
3c6af1b
0fd6769
72499c9
aca6343
28dbede
8f0458d
93241d2
673e4c0
26acfa5
984fd2a
4a49a10
bf4fea0
e81e477
9849de5
2a757c4
5592a2e
22c7cf0
8c5e492
b54d56b
d6d15af
1a63642
90b2d5a
889e46d
84d918d
bc78319
b827f46
7c4f41e
43e1a35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,10 @@ import { ExecLib } from "./lib/ExecLib.sol"; | |
import { INexus } from "./interfaces/INexus.sol"; | ||
import { BaseAccount } from "./base/BaseAccount.sol"; | ||
import { IERC7484 } from "./interfaces/IERC7484.sol"; | ||
import { IERC7739 } from "./interfaces/IERC7739.sol"; | ||
import { ModuleManager } from "./base/ModuleManager.sol"; | ||
import { ExecutionHelper } from "./base/ExecutionHelper.sol"; | ||
import { IValidator } from "./interfaces/modules/IValidator.sol"; | ||
import { MODULE_TYPE_VALIDATOR, MODULE_TYPE_EXECUTOR, MODULE_TYPE_FALLBACK, MODULE_TYPE_HOOK, MODULE_TYPE_MULTI, SUPPORTS_NESTED_TYPED_DATA_SIGN } from "./types/Constants.sol"; | ||
import { MODULE_TYPE_VALIDATOR, MODULE_TYPE_EXECUTOR, MODULE_TYPE_FALLBACK, MODULE_TYPE_HOOK, MODULE_TYPE_MULTI, SUPPORTS_ERC7739 } from "./types/Constants.sol"; | ||
import { ModeLib, ExecutionMode, ExecType, CallType, CALLTYPE_BATCH, CALLTYPE_SINGLE, CALLTYPE_DELEGATECALL, EXECTYPE_DEFAULT, EXECTYPE_TRY } from "./lib/ModeLib.sol"; | ||
import { NonceLib } from "./lib/NonceLib.sol"; | ||
import { SentinelListLib, SENTINEL, ZERO_ADDRESS } from "sentinellist/SentinelList.sol"; | ||
|
@@ -39,6 +38,7 @@ contract Nexus is INexus, BaseAccount, ExecutionHelper, ModuleManager, UUPSUpgra | |
using ModeLib for ExecutionMode; | ||
using ExecLib for bytes; | ||
using NonceLib for uint256; | ||
using SentinelListLib for SentinelListLib.SentinelList; | ||
|
||
/// @dev The timelock period for emergency hook uninstallation. | ||
uint256 internal constant _EMERGENCY_TIMELOCK = 1 days; | ||
|
@@ -226,6 +226,15 @@ contract Nexus is INexus, BaseAccount, ExecutionHelper, ModuleManager, UUPSUpgra | |
/// bytes4(keccak256("isValidSignature(bytes32,bytes)") = 0x1626ba7e | ||
/// @dev Delegates the validation to a validator module specified within the signature data. | ||
function isValidSignature(bytes32 hash, bytes calldata signature) external view virtual override returns (bytes4) { | ||
// Handle potential ERC7739 support detection request | ||
if (signature.length == 0) { | ||
// Forces the compiler to optimize for smaller bytecode size. | ||
if (uint256(hash) == (~signature.length / 0xffff) * 0x7739) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow. what's this doing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the same code that's already built into this function here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is to check that this is the 7739 support request and no, we can not because we should identify that this is the request at SA level |
||
return checkERC7739Support(hash, signature); | ||
} | ||
} | ||
// else proceed with normal signature verification | ||
|
||
// First 20 bytes of data will be validator address and rest of the bytes is complete signature. | ||
address validator = address(bytes20(signature[0:20])); | ||
require(_isValidatorInstalled(validator), ValidatorNotInstalled(validator)); | ||
|
@@ -320,19 +329,30 @@ contract Nexus is INexus, BaseAccount, ExecutionHelper, ModuleManager, UUPSUpgra | |
UUPSUpgradeable.upgradeToAndCall(newImplementation, data); | ||
} | ||
|
||
/// @dev For automatic detection that the smart account supports the nested EIP-712 workflow | ||
/// Offchain usage only | ||
/// Iterates over all the validators | ||
function supportsNestedTypedDataSign() public view virtual returns (bytes32) { | ||
SentinelListLib.SentinelList storage validators = _getAccountStorage().validators; | ||
address next = validators.entries[SENTINEL]; | ||
while (next != ZERO_ADDRESS && next != SENTINEL) { | ||
try IERC7739(next).supportsNestedTypedDataSign() returns (bytes32 res) { | ||
if (res == SUPPORTS_NESTED_TYPED_DATA_SIGN) return SUPPORTS_NESTED_TYPED_DATA_SIGN; | ||
} catch {} | ||
next = validators.entries[next]; | ||
/// @dev For automatic detection that the smart account supports the ERC7739 workflow | ||
/// Iterates over all the validators but only if this is a detection request | ||
/// ERC-7739 spec assumes that if the account doesn't support ERC-7739 | ||
/// it will try to handle the detection request as it was normal sig verification | ||
/// request and will return 0xffffffff since it won't be able to verify the 0x signature | ||
/// against 0x7739...7739 hash. | ||
/// So this approach is consistent with the ERC-7739 spec. | ||
/// If no validator supports ERC-7739, this function returns false | ||
/// thus the account will proceed with normal signature verification | ||
/// and return 0xffffffff as a result. | ||
function checkERC7739Support(bytes32 hash, bytes calldata signature) public view virtual returns (bytes4) { | ||
bytes4 result; | ||
unchecked { | ||
SentinelListLib.SentinelList storage validators = _getAccountStorage().validators; | ||
address next = validators.entries[SENTINEL]; | ||
while (next != ZERO_ADDRESS && next != SENTINEL) { | ||
bytes4 support = IValidator(next).isValidSignatureWithSender(msg.sender, hash, signature); | ||
if (bytes2(support) == bytes2(SUPPORTS_ERC7739) && support > result) { | ||
result = support; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't we break the loop in the case of result = support? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we want to find the latest supported version, so no, we can't |
||
} | ||
next = validators.getNext(next); | ||
} | ||
} | ||
return bytes4(0xffffffff); | ||
return result == bytes4(0) ? bytes4(0xffffffff) : result; | ||
} | ||
|
||
/// @dev Ensures that only authorized callers can upgrade the smart contract implementation. | ||
|
@@ -343,6 +363,6 @@ contract Nexus is INexus, BaseAccount, ExecutionHelper, ModuleManager, UUPSUpgra | |
/// @dev EIP712 domain name and version. | ||
function _domainNameAndVersion() internal pure override returns (string memory name, string memory version) { | ||
name = "Nexus"; | ||
version = "1.0.0"; | ||
version = "1.0.1"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be using the SentinelList4337 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case it is not needed as the list is in the account storage itself