-
Notifications
You must be signed in to change notification settings - Fork 38
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
refactor: add docs + cleanup MA and MABase with small opt #259
Merged
+25
−18
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -43,6 +43,10 @@ import {ModularAccountView} from "./ModularAccountView.sol"; | |||||
import {ModuleManagerInternals} from "./ModuleManagerInternals.sol"; | ||||||
import {TokenReceiver} from "./TokenReceiver.sol"; | ||||||
|
||||||
/// @title Modular Account Base | ||||||
/// @author Alchemy | ||||||
/// @notice This abstract account is a modular account that is compliant with ERC-6900 standard. It supports | ||||||
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.
Suggested change
|
||||||
/// deferred actions during validation. | ||||||
abstract contract ModularAccountBase is | ||||||
IModularAccount, | ||||||
ModularAccountView, | ||||||
|
@@ -100,6 +104,7 @@ abstract contract ModularAccountBase is | |||||
error ValidationFunctionMissing(bytes4 selector); | ||||||
error DeferredActionNonceInvalid(); | ||||||
error DeferredActionSignatureInvalid(); | ||||||
// This error is trigged in performCreate and performCreate2 | ||||||
error CreateFailed(); | ||||||
|
||||||
// Wraps execution of a native function with runtime validation and hooks | ||||||
|
@@ -144,13 +149,6 @@ abstract contract ModularAccountBase is | |||||
/// @param value The value to send to the new contract constructor | ||||||
/// @param initCode The initCode to deploy. | ||||||
/// @return createdAddr The created contract address. | ||||||
/// | ||||||
/// @dev Assembly procedure: | ||||||
/// 1. Load the free memory pointer. | ||||||
/// 2. Get the initCode length. | ||||||
/// 3. Copy the initCode from callata to memory at the free memory pointer. | ||||||
/// 4. Create the contract. | ||||||
/// 5. If creation failed (the address returned is zero), revert with CreateFailed(). | ||||||
function performCreate(uint256 value, bytes calldata initCode) | ||||||
external | ||||||
payable | ||||||
|
@@ -159,15 +157,21 @@ abstract contract ModularAccountBase is | |||||
returns (address createdAddr) | ||||||
{ | ||||||
assembly ("memory-safe") { | ||||||
// Load the free memory pointer. | ||||||
let fmp := mload(0x40) | ||||||
|
||||||
// Get the initCode length. | ||||||
let len := initCode.length | ||||||
|
||||||
// Copy the initCode from callata to memory at the free memory pointer. | ||||||
calldatacopy(fmp, initCode.offset, len) | ||||||
|
||||||
// Create the contract. | ||||||
createdAddr := create(value, fmp, len) | ||||||
|
||||||
if iszero(createdAddr) { | ||||||
let createFailedError := 0x7e16b8cd | ||||||
mstore(0x00, createFailedError) | ||||||
// If creation failed (the address returned is zero), revert with CreateFailed(). | ||||||
mstore(0x00, 0x7e16b8cd) | ||||||
revert(0x1c, 0x04) | ||||||
} | ||||||
} | ||||||
|
@@ -178,13 +182,6 @@ abstract contract ModularAccountBase is | |||||
/// @param initCode The initCode to deploy. | ||||||
/// @param salt The salt to use for the create2 operation. | ||||||
/// @return createdAddr The created contract address. | ||||||
/// | ||||||
/// @dev Assembly procedure: | ||||||
/// 1. Load the free memory pointer. | ||||||
/// 2. Get the initCode length. | ||||||
/// 3. Copy the initCode from callata to memory at the free memory pointer. | ||||||
/// 4. Create the contract using Create2 with the passed salt parameter. | ||||||
/// 5. If creation failed (the address returned is zero), revert with CreateFailed(). | ||||||
function performCreate2(uint256 value, bytes calldata initCode, bytes32 salt) | ||||||
external | ||||||
payable | ||||||
|
@@ -193,15 +190,21 @@ abstract contract ModularAccountBase is | |||||
returns (address createdAddr) | ||||||
{ | ||||||
assembly ("memory-safe") { | ||||||
// Load the free memory pointer. | ||||||
let fmp := mload(0x40) | ||||||
|
||||||
// Get the initCode length. | ||||||
let len := initCode.length | ||||||
|
||||||
// Copy the initCode from callata to memory at the free memory pointer. | ||||||
calldatacopy(fmp, initCode.offset, len) | ||||||
|
||||||
// Create the contract using Create2 with the passed salt parameter. | ||||||
createdAddr := create2(value, fmp, len, salt) | ||||||
|
||||||
if iszero(createdAddr) { | ||||||
let createFailedError := 0x7e16b8cd | ||||||
mstore(0x00, createFailedError) | ||||||
// If creation failed (the address returned is zero), revert with CreateFailed(). | ||||||
mstore(0x00, 0x7e16b8cd) | ||||||
revert(0x1c, 0x04) | ||||||
} | ||||||
} | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.