-
Notifications
You must be signed in to change notification settings - Fork 707
Expand file tree
/
Copy pathBytes32AddressLib.sol
More file actions
22 lines (18 loc) · 877 Bytes
/
Bytes32AddressLib.sol
File metadata and controls
22 lines (18 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Library for converting between addresses and bytes32 values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/Bytes32AddressLib.sol)
library Bytes32AddressLib {
/// @notice Converts a bytes32 value into an address.
/// @param bytesValue The bytes32 value to convert.
/// @return The resulting address.
function fromLast20Bytes(bytes32 bytesValue) internal pure returns (address) {
return address(uint160(uint256(bytesValue)));
}
/// @notice Converts an address to a bytes32 representation.
/// @param addressValue The address to convert.
/// @return The resulting bytes32 value.
function fillLast12Bytes(address addressValue) internal pure returns (bytes32) {
return bytes32(bytes20(addressValue));
}
}