ERC6900TypesLib
Title: ERC6900TypesLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from ERC-6900 reference implementation (https://github.com/erc6900/reference-implementation)
Pure pack/unpack helpers for the ERC-6900 packed value types ModuleEntity / ValidationConfig /
IERC6900); these helpers are written fresh. Layout (big-endian / left-aligned within the type):
- ModuleEntity (bytes24): address module [0..19] ‖ uint32 entityId [20..23]
- ValidationConfig (bytes25): ModuleEntity [0..23] ‖ flags [24]
- HookConfig (bytes25): ModuleEntity [0..23] ‖ flags [24]
ValidationConfig and HookConfig share byte 24 but interpret its bits differently — never decode a
flag byte with the other type's masks (_VALIDATION_* vs _HOOK_*).
Constants
_VALIDATION_FLAG_IS_USER_OP
uint8 internal constant _VALIDATION_FLAG_IS_USER_OP = 0x01;_VALIDATION_FLAG_IS_SIGNATURE
uint8 internal constant _VALIDATION_FLAG_IS_SIGNATURE = 0x02;_VALIDATION_FLAG_IS_GLOBAL
uint8 internal constant _VALIDATION_FLAG_IS_GLOBAL = 0x04;_HOOK_TYPE_VALIDATION
uint8 internal constant _HOOK_TYPE_VALIDATION = 0x01;_HOOK_FLAG_HAS_POST
uint8 internal constant _HOOK_FLAG_HAS_POST = 0x02;_HOOK_FLAG_HAS_PRE
uint8 internal constant _HOOK_FLAG_HAS_PRE = 0x04;Functions
pack
function pack(address module_, uint32 entityId_) internal pure returns (ModuleEntity);Parameters
| Name | Type | Description |
|---|---|---|
| module_ | address | |
| entityId_ | uint32 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | ModuleEntity |
unpack
function unpack(ModuleEntity self) internal pure returns (address module_, uint32 entityId_);Parameters
| Name | Type | Description |
|---|---|---|
| self | ModuleEntity |
Returns
| Name | Type | Description |
|---|---|---|
| module_ | address | |
| entityId_ | uint32 |
isEmpty
function isEmpty(ModuleEntity self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | ModuleEntity |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
eq
function eq(ModuleEntity a, ModuleEntity b) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| a | ModuleEntity | |
| b | ModuleEntity |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
pack
function pack(address module_, uint32 entityId_, bool isGlobal_, bool isSignatureValidation_, bool isUserOp_)
internal
pure
returns (ValidationConfig);Parameters
| Name | Type | Description |
|---|---|---|
| module_ | address | |
| entityId_ | uint32 | |
| isGlobal_ | bool | |
| isSignatureValidation_ | bool | |
| isUserOp_ | bool |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | ValidationConfig |
pack
function pack(ModuleEntity validationFunction, bool isGlobal_, bool isSignatureValidation_, bool isUserOp_)
internal
pure
returns (ValidationConfig);Parameters
| Name | Type | Description |
|---|---|---|
| validationFunction | ModuleEntity | |
| isGlobal_ | bool | |
| isSignatureValidation_ | bool | |
| isUserOp_ | bool |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | ValidationConfig |
unpack
function unpack(ValidationConfig self)
internal
pure
returns (ModuleEntity validationFunction, ValidationFlags flags);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationConfig |
Returns
| Name | Type | Description |
|---|---|---|
| validationFunction | ModuleEntity | |
| flags | ValidationFlags |
module
function module(ValidationConfig self) internal pure returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
entityId
function entityId(ValidationConfig self) internal pure returns (uint32);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint32 |
moduleEntity
function moduleEntity(ValidationConfig self) internal pure returns (ModuleEntity);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | ModuleEntity |
isGlobal
function isGlobal(ValidationConfig self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
isSignatureValidation
function isSignatureValidation(ValidationConfig self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
isUserOpValidation
function isUserOpValidation(ValidationConfig self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
isGlobal
function isGlobal(ValidationFlags self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationFlags |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
isSignatureValidation
function isSignatureValidation(ValidationFlags self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationFlags |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
isUserOpValidation
function isUserOpValidation(ValidationFlags self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | ValidationFlags |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
packValidationHook
function packValidationHook(ModuleEntity hookFunction) internal pure returns (HookConfig);Parameters
| Name | Type | Description |
|---|---|---|
| hookFunction | ModuleEntity |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | HookConfig |
packExecHook
function packExecHook(ModuleEntity hookFunction, bool hasPre, bool hasPost) internal pure returns (HookConfig);Parameters
| Name | Type | Description |
|---|---|---|
| hookFunction | ModuleEntity | |
| hasPre | bool | |
| hasPost | bool |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | HookConfig |
unpackExecHook
function unpackExecHook(HookConfig self)
internal
pure
returns (ModuleEntity hookFunction, bool hasPre, bool hasPost);Parameters
| Name | Type | Description |
|---|---|---|
| self | HookConfig |
Returns
| Name | Type | Description |
|---|---|---|
| hookFunction | ModuleEntity | |
| hasPre | bool | |
| hasPost | bool |
module
function module(HookConfig self) internal pure returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| self | HookConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
entityId
function entityId(HookConfig self) internal pure returns (uint32);Parameters
| Name | Type | Description |
|---|---|---|
| self | HookConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint32 |
moduleEntity
function moduleEntity(HookConfig self) internal pure returns (ModuleEntity);Parameters
| Name | Type | Description |
|---|---|---|
| self | HookConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | ModuleEntity |
isValidationHook
function isValidationHook(HookConfig self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | HookConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
hasPreHook
function hasPreHook(HookConfig self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | HookConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
hasPostHook
function hasPostHook(HookConfig self) internal pure returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| self | HookConfig |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |