-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
pragma solidity ^0.5.7; | ||
|
||
contract Deployer { | ||
event InstanceDeployed(address instance); | ||
|
||
event InstanceDeployed(address instance); | ||
|
||
function deploy(address _logic) internal returns (address instance) { | ||
bytes20 targetBytes = bytes20(_logic); | ||
assembly { | ||
let clone := mload(0x40) | ||
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) | ||
mstore(add(clone, 0x14), targetBytes) | ||
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) | ||
instance := create(0, clone, 0x37) | ||
function deploy( | ||
address _logic | ||
) | ||
internal | ||
returns (address instance) | ||
{ | ||
bytes20 targetBytes = bytes20(_logic); | ||
/* solium-disable-next-line security/no-inline-assembly */ | ||
assembly { | ||
let clone := mload(0x40) | ||
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) | ||
mstore(add(clone, 0x14), targetBytes) | ||
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) | ||
instance := create(0, clone, 0x37) | ||
} | ||
emit InstanceDeployed(address(instance)); | ||
} | ||
emit InstanceDeployed(address(instance)); | ||
} | ||
} |