Skip to content
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

⚡️ Allow encodeMode to be inlinable #1241

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/accounts/LibERC7579.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ library LibERC7579 {
{
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, callType)
mstore(0x01, execType)
mstore(0x02, shr(32, selector)) // Clean the lower bytes of `execType`.
mstore(0x0a, payload)
result := mload(0x00)
result := or(shl(8, byte(0, callType)), byte(0, execType))
result := or(shr(224, selector), shl(64, result))
result := or(shr(80, payload), shl(176, result))
}
}

Expand Down
7 changes: 7 additions & 0 deletions test/LibERC7579.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ contract LibERC7579Test is SoladyTest {
}
}

function testEncodeAndDecodeMode() public {
bytes32 mode = LibERC7579.encodeMode(
0x01, 0x00, 0x11223344, 0xffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb
);
assertEq(mode, 0x01000000000011223344ffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb);
}

struct Call {
address target;
uint256 value;
Expand Down
Loading