Skip to content

Commit 930598e

Browse files
authored
Authority utils assembly (#5074)
1 parent 9586aaf commit 930598e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

contracts/access/manager/AuthorityUtils.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ library AuthorityUtils {
1717
address target,
1818
bytes4 selector
1919
) internal view returns (bool immediate, uint32 delay) {
20-
(bool success, bytes memory data) = authority.staticcall(
21-
abi.encodeCall(IAuthority.canCall, (caller, target, selector))
22-
);
23-
if (success) {
24-
if (data.length >= 0x40) {
25-
(immediate, delay) = abi.decode(data, (bool, uint32));
26-
} else if (data.length >= 0x20) {
27-
immediate = abi.decode(data, (bool));
20+
bytes memory data = abi.encodeCall(IAuthority.canCall, (caller, target, selector));
21+
22+
assembly ("memory-safe") {
23+
mstore(0x00, 0x00)
24+
mstore(0x20, 0x00)
25+
26+
if staticcall(gas(), authority, add(data, 0x20), mload(data), 0x00, 0x40) {
27+
immediate := mload(0x00)
28+
delay := mload(0x20)
2829
}
2930
}
30-
return (immediate, delay);
3131
}
3232
}

0 commit comments

Comments
 (0)