Skip to content

Commit c84e1bc

Browse files
switch to msgSender in deployInstance as well
1 parent bf7b8d7 commit c84e1bc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

contracts/ByocFactory.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ contract ByocFactory is IByocFactory, ERC2771Context, Multicall, AccessControlEn
5959
) external onlyUnpausedOrAdmin returns (address deployedAddress) {
6060
require(bytes(publishMetadataUri).length > 0, "No publish metadata");
6161

62+
address caller = _msgSender();
63+
6264
bytes memory contractBytecode = abi.encodePacked(_contractBytecode, _constructorArgs);
6365
bytes32 salt = _salt == ""
64-
? keccak256(abi.encodePacked(_msgSender(), block.number, keccak256(contractBytecode)))
65-
: keccak256(abi.encodePacked(_msgSender(), _salt));
66+
? keccak256(abi.encodePacked(caller, block.number, keccak256(contractBytecode)))
67+
: keccak256(abi.encodePacked(caller, _salt));
6668

6769
address computedContractAddress = Create2.computeAddress(salt, keccak256(contractBytecode), address(this));
68-
getContractDeployer[computedContractAddress] = _msgSender();
70+
getContractDeployer[computedContractAddress] = caller;
6971

7072
deployedAddress = Create2.deploy(_value, salt, contractBytecode);
7173

@@ -76,9 +78,9 @@ contract ByocFactory is IByocFactory, ERC2771Context, Multicall, AccessControlEn
7678
"Not a thirdweb contract"
7779
);
7880

79-
registry.add(_publisher, deployedAddress);
81+
registry.add(caller, deployedAddress);
8082

81-
emit ContractDeployed(_msgSender(), _publisher, deployedAddress);
83+
emit ContractDeployed(caller, _publisher, deployedAddress);
8284
}
8385

8486
/// @notice Deploys a clone pointing to an implementation of a published contract.
@@ -90,7 +92,6 @@ contract ByocFactory is IByocFactory, ERC2771Context, Multicall, AccessControlEn
9092
uint256 _value,
9193
string memory publishMetadataUri
9294
) external onlyUnpausedOrAdmin returns (address deployedAddress) {
93-
9495
address caller = _msgSender();
9596

9697
bytes32 salt = _salt == ""

contracts/ThirdwebContract.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ contract ThirdwebContract {
2525
}
2626

2727
/// @dev Enable access to the original contract deployer in the constructor. If this function is called outside of a constructor, it will return address(0) instead.
28-
/// Save 1 storage slot from not storing the factory address and not having to hardcode the factory address.
2928
function _contractDeployer() internal view returns (address) {
3029
if (address(this).code.length == 0) {
3130
try IContractDeployer(msg.sender).getContractDeployer(address(this)) returns (address deployer) {

0 commit comments

Comments
 (0)