Rename variable master to implementation
This commit is contained in:
@ -17,16 +17,16 @@ pragma solidity ^0.8.0;
|
|||||||
*/
|
*/
|
||||||
library Clones {
|
library Clones {
|
||||||
/**
|
/**
|
||||||
* @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
|
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
|
||||||
*
|
*
|
||||||
* This function uses the create opcode, which should never revert.
|
* This function uses the create opcode, which should never revert.
|
||||||
*/
|
*/
|
||||||
function clone(address master) internal returns (address instance) {
|
function clone(address implementation) internal returns (address instance) {
|
||||||
// solhint-disable-next-line no-inline-assembly
|
// solhint-disable-next-line no-inline-assembly
|
||||||
assembly {
|
assembly {
|
||||||
let ptr := mload(0x40)
|
let ptr := mload(0x40)
|
||||||
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
||||||
mstore(add(ptr, 0x14), shl(0x60, master))
|
mstore(add(ptr, 0x14), shl(0x60, implementation))
|
||||||
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
|
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
|
||||||
instance := create(0, ptr, 0x37)
|
instance := create(0, ptr, 0x37)
|
||||||
}
|
}
|
||||||
@ -34,18 +34,18 @@ library Clones {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
|
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
|
||||||
*
|
*
|
||||||
* This function uses the create2 opcode and a `salt` to deterministically deploy
|
* This function uses the create2 opcode and a `salt` to deterministically deploy
|
||||||
* the clone. Using the same `master` and `salt` multiple time will revert, since
|
* the clone. Using the same `implementation` and `salt` multiple time will revert, since
|
||||||
* the clones cannot be deployed twice at the same address.
|
* the clones cannot be deployed twice at the same address.
|
||||||
*/
|
*/
|
||||||
function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {
|
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
|
||||||
// solhint-disable-next-line no-inline-assembly
|
// solhint-disable-next-line no-inline-assembly
|
||||||
assembly {
|
assembly {
|
||||||
let ptr := mload(0x40)
|
let ptr := mload(0x40)
|
||||||
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
||||||
mstore(add(ptr, 0x14), shl(0x60, master))
|
mstore(add(ptr, 0x14), shl(0x60, implementation))
|
||||||
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
|
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
|
||||||
instance := create2(0, ptr, 0x37, salt)
|
instance := create2(0, ptr, 0x37, salt)
|
||||||
}
|
}
|
||||||
@ -55,12 +55,12 @@ library Clones {
|
|||||||
/**
|
/**
|
||||||
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
|
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
|
||||||
*/
|
*/
|
||||||
function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {
|
function predictDeterministicAddress(address implementation, bytes32 salt, address deployer) internal pure returns (address predicted) {
|
||||||
// solhint-disable-next-line no-inline-assembly
|
// solhint-disable-next-line no-inline-assembly
|
||||||
assembly {
|
assembly {
|
||||||
let ptr := mload(0x40)
|
let ptr := mload(0x40)
|
||||||
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
|
||||||
mstore(add(ptr, 0x14), shl(0x60, master))
|
mstore(add(ptr, 0x14), shl(0x60, implementation))
|
||||||
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
|
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
|
||||||
mstore(add(ptr, 0x38), shl(0x60, deployer))
|
mstore(add(ptr, 0x38), shl(0x60, deployer))
|
||||||
mstore(add(ptr, 0x4c), salt)
|
mstore(add(ptr, 0x4c), salt)
|
||||||
@ -72,7 +72,7 @@ library Clones {
|
|||||||
/**
|
/**
|
||||||
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
|
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
|
||||||
*/
|
*/
|
||||||
function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {
|
function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) {
|
||||||
return predictDeterministicAddress(master, salt, address(this));
|
return predictDeterministicAddress(implementation, salt, address(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user