Skip to content

Commit

Permalink
use caller, not publisher, for registry.add
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishang Nadgauda authored and Krishang Nadgauda committed May 13, 2022
1 parent 7db0967 commit bf7b8d7
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 8 deletions.
13 changes: 8 additions & 5 deletions contracts/ByocFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ contract ByocFactory is IByocFactory, ERC2771Context, Multicall, AccessControlEn
uint256 _value,
string memory publishMetadataUri
) external onlyUnpausedOrAdmin returns (address deployedAddress) {

address caller = _msgSender();

bytes32 salt = _salt == ""
? keccak256(abi.encodePacked(_msgSender(), block.number, _implementation, _initializeData))
: keccak256(abi.encodePacked(_msgSender(), _salt));
? keccak256(abi.encodePacked(caller, block.number, _implementation, _initializeData))
: keccak256(abi.encodePacked(caller, _salt));

address computedContractAddress = Clones.predictDeterministicAddress(_implementation, salt, address(this));
getContractDeployer[computedContractAddress] = _msgSender();
getContractDeployer[computedContractAddress] = caller;

deployedAddress = Clones.cloneDeterministic(_implementation, salt);

Expand All @@ -106,14 +109,14 @@ contract ByocFactory is IByocFactory, ERC2771Context, Multicall, AccessControlEn
"Not a thirdweb contract"
);

registry.add(_publisher, deployedAddress);
registry.add(caller, deployedAddress);

if (_initializeData.length > 0) {
// slither-disable-next-line unused-return
Address.functionCallWithValue(deployedAddress, _initializeData, _value);
}

emit ContractDeployed(_msgSender(), _publisher, deployedAddress);
emit ContractDeployed(caller, _publisher, deployedAddress);
}

/*///////////////////////////////////////////////////////////////
Expand Down
33 changes: 30 additions & 3 deletions docs/ByocFactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,21 @@ Deploys a clone pointing to an implementation of a published contract.
|---|---|---|
| deployedAddress | address | undefined

### deployer
### getContractDeployer

```solidity
function deployer() external view returns (address)
function getContractDeployer(address) external view returns (address)
```



*Empty var used in deployment.*
*contract address deployed through the factory => deployer*

#### Parameters

| Name | Type | Description |
|---|---|---|
| _0 | address | undefined

#### Returns

Expand Down Expand Up @@ -244,6 +249,28 @@ function isTrustedForwarder(address forwarder) external view returns (bool)
|---|---|---|
| _0 | bool | undefined

### multicall

```solidity
function multicall(bytes[] data) external nonpayable returns (bytes[] results)
```



*Receives and executes a batch of function calls on this contract.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| data | bytes[] | undefined

#### Returns

| Name | Type | Description |
|---|---|---|
| results | bytes[] | undefined

### renounceRole

```solidity
Expand Down
37 changes: 37 additions & 0 deletions docs/IContractDeployer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# IContractDeployer









## Methods

### getContractDeployer

```solidity
function getContractDeployer(address _contract) external view returns (address)
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| _contract | address | undefined

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | address | undefined




14 changes: 14 additions & 0 deletions docs/ThirdwebContract.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,17 @@ function setPublishMetadataUri(string uri) external nonpayable



## Errors

### ThirdwebContract_MetadataAlreadyInitialized

```solidity
error ThirdwebContract_MetadataAlreadyInitialized()
```







0 comments on commit bf7b8d7

Please sign in to comment.