|
2 | 2 | pragma solidity ^0.8.20; |
3 | 3 |
|
4 | 4 | import {ModuleEntity} from "../interfaces/IModularAccount.sol"; |
| 5 | +// ModuleEntity is a packed representation of a module function |
| 6 | +// Layout: |
| 7 | +// 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA________________________ // Address |
| 8 | +// 0x________________________________________BBBBBBBB________________ // Entity ID |
| 9 | +// 0x________________________________________________0000000000000000 // unused |
5 | 10 |
|
6 | 11 | library ModuleEntityLib { |
7 | | - // Magic value for hooks that should always revert. |
8 | | - ModuleEntity internal constant _PRE_HOOK_ALWAYS_DENY = ModuleEntity.wrap(bytes24(uint192(2))); |
9 | | - |
10 | 12 | function pack(address addr, uint32 entityId) internal pure returns (ModuleEntity) { |
11 | 13 | return ModuleEntity.wrap(bytes24(bytes20(addr)) | bytes24(uint192(entityId))); |
12 | 14 | } |
13 | 15 |
|
14 | | - function unpack(ModuleEntity fr) internal pure returns (address addr, uint32 entityId) { |
15 | | - bytes24 underlying = ModuleEntity.unwrap(fr); |
| 16 | + function unpack(ModuleEntity moduleEntity) internal pure returns (address addr, uint32 entityId) { |
| 17 | + bytes24 underlying = ModuleEntity.unwrap(moduleEntity); |
16 | 18 | addr = address(bytes20(underlying)); |
17 | 19 | entityId = uint32(bytes4(underlying << 160)); |
18 | 20 | } |
19 | 21 |
|
20 | | - function isEmpty(ModuleEntity fr) internal pure returns (bool) { |
21 | | - return ModuleEntity.unwrap(fr) == bytes24(0); |
| 22 | + function isEmpty(ModuleEntity moduleEntity) internal pure returns (bool) { |
| 23 | + return ModuleEntity.unwrap(moduleEntity) == bytes24(0); |
22 | 24 | } |
23 | 25 |
|
24 | | - function notEmpty(ModuleEntity fr) internal pure returns (bool) { |
25 | | - return ModuleEntity.unwrap(fr) != bytes24(0); |
| 26 | + function notEmpty(ModuleEntity moduleEntity) internal pure returns (bool) { |
| 27 | + return ModuleEntity.unwrap(moduleEntity) != bytes24(0); |
26 | 28 | } |
27 | 29 |
|
28 | 30 | function eq(ModuleEntity a, ModuleEntity b) internal pure returns (bool) { |
|
0 commit comments