Skip to content

Commit

Permalink
Update contracts/proxy/Clones.sol
Browse files Browse the repository at this point in the history
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
  • Loading branch information
Vectorized and Amxx committed Aug 24, 2022
1 parent 29d68b3 commit 75e5770
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions contracts/proxy/Clones.sol
Expand Up @@ -25,12 +25,11 @@ library Clones {
function clone(address implementation) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000, shr(0xe8, shl(0x60, implementation))))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create(0, 0x09, 0x37)
// Packs the size 3 bytes of `implementation` with the bytecode before the address.
mstore(0x00, or(shr(0x88, implementation), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create(0, 0x00, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
Expand Down

0 comments on commit 75e5770

Please sign in to comment.