Skip to content

Commit 6225e9e

Browse files
leanify thirdwebContract
1 parent 58b793f commit 6225e9e

File tree

3 files changed

+15
-38
lines changed

3 files changed

+15
-38
lines changed

contracts/ByocFactory.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ contract ByocFactory is IByocFactory, ERC2771Context, AccessControlEnumerable, T
5151
bytes memory _constructorArgs,
5252
bytes32 _salt,
5353
uint256 _value,
54-
ThirdwebContract.ThirdwebInfo memory _thirdwebInfo
54+
string memory publishMetadataUri
5555
) external onlyUnpausedOrAdmin returns (address deployedAddress) {
56-
require(bytes(_thirdwebInfo.publishMetadataUri).length > 0, "No publish metadata");
56+
require(bytes(publishMetadataUri).length > 0, "No publish metadata");
5757

5858
bytes memory contractBytecode = abi.encodePacked(_contractBytecode, _constructorArgs);
5959
bytes32 salt = _salt == "" ? keccak256(abi.encodePacked(_msgSender(), block.number)) : _salt;
6060

6161
deployedAddress = Create2.deploy(_value, salt, contractBytecode);
6262

63-
ThirdwebContract(deployedAddress).setThirdwebInfo(_thirdwebInfo);
63+
ThirdwebContract(deployedAddress).setPublisheMetadataUi(publishMetadataUri);
6464
require(
6565
keccak256(bytes(ThirdwebContract(deployedAddress).getPublishMetadataUri())) ==
66-
keccak256(bytes(_thirdwebInfo.publishMetadataUri)),
66+
keccak256(bytes(publishMetadataUri)),
6767
"Not a thirdweb contract"
6868
);
6969

@@ -79,15 +79,15 @@ contract ByocFactory is IByocFactory, ERC2771Context, AccessControlEnumerable, T
7979
bytes memory _initializeData,
8080
bytes32 _salt,
8181
uint256 _value,
82-
ThirdwebContract.ThirdwebInfo memory _thirdwebInfo
82+
string memory publishMetadataUri
8383
) external onlyUnpausedOrAdmin returns (address deployedAddress) {
8484
bytes32 salt = _salt == "" ? keccak256(abi.encodePacked(_msgSender(), block.number)) : _salt;
8585
deployedAddress = Clones.cloneDeterministic(_implementation, salt);
8686

87-
ThirdwebContract(deployedAddress).setThirdwebInfo(_thirdwebInfo);
87+
ThirdwebContract(deployedAddress).setPublisheMetadataUi(publishMetadataUri);
8888
require(
8989
keccak256(bytes(ThirdwebContract(deployedAddress).getPublishMetadataUri())) ==
90-
keccak256(bytes(_thirdwebInfo.publishMetadataUri)),
90+
keccak256(bytes(publishMetadataUri)),
9191
"Not a thirdweb contract"
9292
);
9393

contracts/ThirdwebContract.sol

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity ^0.8.0;
33

4-
import "./feature/Ownable.sol";
5-
import "./feature/ContractMetadata.sol";
6-
7-
contract ThirdwebContract is Ownable, ContractMetadata {
8-
struct ThirdwebInfo {
9-
string publishMetadataUri;
10-
string contractURI;
11-
address owner;
12-
}
13-
4+
contract ThirdwebContract {
145
/// @dev The publish metadata of the contract of which this contract is an instance.
156
string private publishMetadataUri;
167

@@ -19,23 +10,9 @@ contract ThirdwebContract is Ownable, ContractMetadata {
1910
return publishMetadataUri;
2011
}
2112

22-
/// @dev Initializes the publish metadata and contract metadata at deploy time.
23-
function setThirdwebInfo(ThirdwebInfo memory _thirdwebInfo) external {
13+
/// @dev Initializes the publish metadata and at deploy time.
14+
function setPublisheMetadataUi(string memory uri) external {
2415
require(bytes(publishMetadataUri).length == 0, "Published metadata already initialized");
25-
require(owner == address(0), "Owner already initialized");
26-
27-
publishMetadataUri = _thirdwebInfo.publishMetadataUri;
28-
contractURI = _thirdwebInfo.contractURI;
29-
owner = _thirdwebInfo.owner;
30-
}
31-
32-
/// @dev Returns whether owner can be set
33-
function _canSetOwner() internal virtual override returns (bool) {
34-
return msg.sender == owner;
35-
}
36-
37-
/// @dev Returns whether contract metadata can be set
38-
function _canSetContractURI() internal virtual override returns (bool) {
39-
return msg.sender == owner;
16+
publishMetadataUri = uri;
4017
}
4118
}

contracts/interfaces/IByocFactory.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface IByocFactory {
1818
* @param constructorArgs The encoded constructor args to deploy the contract with.
1919
* @param salt The salt to use in the CREATE2 contract deployment.
2020
* @param value The native token value to pass to the contract on deployment.
21-
* @param thirdwebInfo The publish metadata URI and contract URI for the contract to deploy.
21+
* @param publishMetadataUri The publish metadata URI for the contract to deploy.
2222
*
2323
* @return deployedAddress The address of the contract deployed.
2424
*/
@@ -28,7 +28,7 @@ interface IByocFactory {
2828
bytes memory constructorArgs,
2929
bytes32 salt,
3030
uint256 value,
31-
ThirdwebContract.ThirdwebInfo memory thirdwebInfo
31+
string memory publishMetadataUri
3232
) external returns (address deployedAddress);
3333

3434
/**
@@ -39,7 +39,7 @@ interface IByocFactory {
3939
* @param initializeData The encoded function call to initialize the contract with.
4040
* @param salt The salt to use in the CREATE2 contract deployment.
4141
* @param value The native token value to pass to the contract on deployment.
42-
* @param thirdwebInfo The publish metadata URI and contract URI for the contract to deploy.
42+
* @param publishMetadataUri The publish metadata URI and for the contract to deploy.
4343
*
4444
* @return deployedAddress The address of the contract deployed.
4545
*/
@@ -49,6 +49,6 @@ interface IByocFactory {
4949
bytes memory initializeData,
5050
bytes32 salt,
5151
uint256 value,
52-
ThirdwebContract.ThirdwebInfo memory thirdwebInfo
52+
string memory publishMetadataUri
5353
) external returns (address deployedAddress);
5454
}

0 commit comments

Comments
 (0)