Skip to content

Commit

Permalink
Minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
telome committed Dec 20, 2023
1 parent 681f536 commit aff8051
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/LockstakeEngine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ contract LockstakeEngine is Multicall {
}

// See the reference implementation in https://eips.ethereum.org/EIPS/eip-1167
function _initCode(bytes20 _target) internal pure returns (bytes memory code) {
function _initCode() internal view returns (bytes memory code) {
code = new bytes(55);
bytes20 impl = bytes20(urnImplementation);
assembly {
mstore(add(code, 0x20), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(code, add(0x20,0x14)), _target)
mstore(add(code, add(0x20,0x28)), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
mstore(add(code, add(0x20, 0x14)), impl)
mstore(add(code, add(0x20, 0x28)), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
}
}

Expand Down Expand Up @@ -212,7 +213,7 @@ contract LockstakeEngine is Multicall {

function getUrn(address owner, uint256 index) external view returns (address urn) {
uint256 salt = uint256(keccak256(abi.encode(owner, index)));
bytes32 codeHash = keccak256(abi.encodePacked(_initCode(bytes20(urnImplementation))));
bytes32 codeHash = keccak256(abi.encodePacked(_initCode()));
urn = address(uint160(uint256(
keccak256(
abi.encodePacked(bytes1(0xff), address(this), salt, codeHash)
Expand All @@ -229,7 +230,7 @@ contract LockstakeEngine is Multicall {
require(index == usrAmts[msg.sender]++, "LockstakeEngine/urn-already-opened");

uint256 salt = uint256(keccak256(abi.encode(msg.sender, index)));
bytes memory initCode = _initCode(bytes20(urnImplementation));
bytes memory initCode = _initCode();
assembly {
urn := create2(0, add(initCode, 0x20), mload(initCode), salt)
if iszero(extcodesize(urn)) { revert(0, 0) }
Expand Down

0 comments on commit aff8051

Please sign in to comment.