-
Notifications
You must be signed in to change notification settings - Fork 17
Add ERC-6900 account extension #80
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
Open
jeremyjams
wants to merge
15
commits into
OpenZeppelin:master
Choose a base branch
from
jeremyjams:aa/account-extension-erc6900
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a0c5832
Init ERC-6900 account extension
jeremyjams 0025f7c
Remove unused errors
jeremyjams c3a5636
Merge remote-tracking branch 'upstream/master' into aa/account-extens…
jeremyjams 5f5e785
Bump version pragma of ERC6900Utils for consistency
jeremyjams a4a5d23
Lint AccountERC6900 test files
jeremyjams 65c96c0
Add missings inheritdoc
jeremyjams 078c232
Remove duplicated HookConfig extractor
jeremyjams 2c133a6
Add missing line break
jeremyjams ace9b03
Bubble revert reason when execute fails
jeremyjams dbb5521
Move errors to AccountERC6900
jeremyjams 19df12e
Init fallback
jeremyjams 1490ca9
Update signature validation comment
jeremyjams 6e39db1
Check validation applicability
jeremyjams 21949b0
Count supported interfaces
jeremyjams a566839
Expose ERC-1271 signature validation
jeremyjams 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.24; | ||
|
||
import {ValidationConfig, ModuleEntity, ValidationFlags, HookConfig, ExecutionManifest, ManifestExecutionHook, ManifestExecutionFunction, Call} from "../../interfaces/IERC6900.sol"; | ||
import {Bytes} from "@openzeppelin/contracts/utils/Bytes.sol"; | ||
import {Packing} from "@openzeppelin/contracts/utils/Packing.sol"; | ||
import {Address} from "@openzeppelin/contracts/utils/Address.sol"; | ||
|
||
/** | ||
* @dev Library with common ERC-6900 utility functions. | ||
* | ||
* See https://eips.ethereum.org/EIPS/eip-6900[ERC-6900]. | ||
*/ | ||
// slither-disable-next-line unused-state | ||
library ERC6900Utils { | ||
using Packing for *; | ||
|
||
// ModuleEntity | ||
|
||
function unpack(ModuleEntity moduleEntity) internal pure returns (address, uint32) { | ||
return (module(moduleEntity), entityId(moduleEntity)); | ||
} | ||
|
||
function module(ModuleEntity moduleEntity) internal pure returns (address) { | ||
return address(Packing.extract_32_20(ModuleEntity.unwrap(moduleEntity), 0)); | ||
} | ||
|
||
function entityId(ModuleEntity moduleEntity) internal pure returns (uint32) { | ||
return uint32(Packing.extract_32_4(ModuleEntity.unwrap(moduleEntity), 20)); | ||
} | ||
|
||
// ValidationFlags | ||
|
||
function isGlobalValidation(ValidationFlags validationFlags) internal pure returns (bool) { | ||
return ValidationFlags.unwrap(validationFlags) & uint8(0x04) == 0x04; // 0b00000100 | ||
} | ||
|
||
function isSignatureValidation(ValidationFlags validationFlags) internal pure returns (bool) { | ||
return ValidationFlags.unwrap(validationFlags) & uint8(0x02) == 0x02; // 0b00000010 | ||
} | ||
|
||
function isUserOpValidation(ValidationFlags validationFlags) internal pure returns (bool) { | ||
return ValidationFlags.unwrap(validationFlags) & uint8(0x01) == 0x01; // 0b00000001 | ||
} | ||
|
||
// ValidationConfig | ||
|
||
// function module(ValidationConfig validationConfig) internal pure returns (address) { | ||
// return address(Packing.extract_32_20(ValidationConfig.unwrap(validationConfig), 0)); | ||
// } | ||
|
||
// function module(bytes calldata hook) internal pure returns (address) { | ||
// return address(Packing.extract_32_20(bytes32(hook), 0)); | ||
// } | ||
|
||
// function entityId(ValidationConfig validationConfig) internal pure returns (uint32) { | ||
// return uint32(Packing.extract_32_4(ValidationConfig.unwrap(validationConfig), 20)); | ||
// } | ||
|
||
function unpack(ValidationConfig validationConfig) internal pure returns (ModuleEntity, ValidationFlags) { | ||
return ( | ||
ModuleEntity.wrap(Packing.extract_32_24(ValidationConfig.unwrap(validationConfig), 0)), | ||
ValidationFlags.wrap(uint8(Packing.extract_32_1(ValidationConfig.unwrap(validationConfig), 21))) | ||
); | ||
} | ||
|
||
// function moduleEntity(ValidationConfig validationConfig) internal pure returns (ModuleEntity) { | ||
// return ModuleEntity.wrap(Packing.extract_32_24(ValidationConfig.unwrap(validationConfig), 0)); | ||
// } | ||
|
||
// function getValidationFlags(ValidationConfig validationConfig) internal pure returns (ValidationFlags) { | ||
// return ValidationFlags.wrap(uint8(Packing.extract_32_1(ValidationConfig.unwrap(validationConfig), 21))); | ||
// } | ||
|
||
// HookConfig | ||
|
||
function extractHookConfig(bytes calldata hook) internal pure returns (HookConfig) { | ||
return HookConfig.wrap(bytes25(hook[:25])); | ||
} | ||
|
||
function isValidationHook(HookConfig hookConfig) internal pure returns (bool) { | ||
return uint8(Packing.extract_32_1(HookConfig.unwrap(hookConfig), 24) & bytes1(0x01)) == 1; | ||
} | ||
|
||
function module(HookConfig hookConfig) internal pure returns (address) { | ||
return address(Packing.extract_32_20(HookConfig.unwrap(hookConfig), 0)); | ||
} | ||
|
||
function entity(HookConfig hookConfig) internal pure returns (uint32) { | ||
return uint32(Packing.extract_32_4(HookConfig.unwrap(hookConfig), 20)); | ||
} | ||
|
||
// function pack( | ||
// address module, | ||
// uint32 entityId, | ||
// bool isPreHook, | ||
// bool isPostHook | ||
// ) internal pure returns (bytes calldata) { | ||
// return hook[:25]; | ||
// } | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.