Skip to content

Commit

Permalink
⚡️ Allow encodeMode to be inlinable (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized authored Dec 18, 2024
1 parent 7307154 commit 0dfa997
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit 0dfa997

Please sign in to comment.