Skip to content

Commit 2be8cff

Browse files
Krishang NadgaudaKrishang Nadgauda
authored andcommitted
wip _thirdwebMsgSender callback solution
1 parent 6af54ba commit 2be8cff

File tree

7 files changed

+69
-1225
lines changed

7 files changed

+69
-1225
lines changed

contracts/ByocFactory.sol

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import { IByocFactory } from "./interfaces/IByocFactory.sol";
1313
import { TWRegistry } from "./TWRegistry.sol";
1414
import "./ThirdwebContract.sol";
1515

16-
contract ByocFactory is IByocFactory, ERC2771Context, AccessControlEnumerable, ThirdwebContract {
16+
import "hardhat/console.sol";
17+
18+
contract ByocFactory is IByocFactory, ERC2771Context, AccessControlEnumerable {
1719
/*///////////////////////////////////////////////////////////////
1820
State variables
1921
//////////////////////////////////////////////////////////////*/
@@ -24,6 +26,9 @@ contract ByocFactory is IByocFactory, ERC2771Context, AccessControlEnumerable, T
2426
/// @dev Whether the registry is paused.
2527
bool public isPaused;
2628

29+
/// @dev Empty var used in deployment.
30+
address public deployer;
31+
2732
/*///////////////////////////////////////////////////////////////
2833
Constructor + modifiers
2934
//////////////////////////////////////////////////////////////*/
@@ -53,6 +58,9 @@ contract ByocFactory is IByocFactory, ERC2771Context, AccessControlEnumerable, T
5358
uint256 _value,
5459
string memory publishMetadataUri
5560
) external onlyUnpausedOrAdmin returns (address deployedAddress) {
61+
62+
deployer = _msgSender();
63+
5664
require(bytes(publishMetadataUri).length > 0, "No publish metadata");
5765

5866
bytes memory contractBytecode = abi.encodePacked(_contractBytecode, _constructorArgs);
@@ -69,6 +77,8 @@ contract ByocFactory is IByocFactory, ERC2771Context, AccessControlEnumerable, T
6977

7078
registry.add(_publisher, deployedAddress);
7179

80+
delete deployer;
81+
7282
emit ContractDeployed(_msgSender(), _publisher, deployedAddress);
7383
}
7484

contracts/ThirdwebContract.sol

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity ^0.8.0;
33

4+
interface IDeployer {
5+
function deployer() external view returns (address);
6+
}
7+
48
contract ThirdwebContract {
59
/// @dev The publish metadata of the contract of which this contract is an instance.
610
string private publishMetadataUri;
711

812
/// @dev The address of the thirdweb factory.
9-
address private immutable factory;
13+
address private factory;
14+
15+
/// @dev Address of the contract deployer.
16+
address private deployer;
1017

1118
constructor() {
1219
factory = msg.sender;
20+
deployer = IDeployer(msg.sender).deployer();
1321
}
1422

1523
/// @dev Returns the publish metadata for this contract.
@@ -26,10 +34,7 @@ contract ThirdwebContract {
2634
/// @dev Returns msg.sender, if caller is not thirdweb factory. Returns the intended msg.sender if caller is factory.
2735
function _thirdwebMsgSender() internal view returns (address sender) {
2836
if (msg.sender == factory) {
29-
// The assembly code is more direct than the Solidity version using `abi.decode`.
30-
assembly {
31-
sender := shr(96, calldataload(sub(calldatasize(), 20)))
32-
}
37+
sender = deployer;
3338
} else {
3439
sender = msg.sender;
3540
}

docs/ByocFactory.md

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ Deploys a clone pointing to an implementation of a published contract.
8181
|---|---|---|
8282
| deployedAddress | address | undefined
8383

84-
### getPublishMetadataUri
84+
### deployer
8585

8686
```solidity
87-
function getPublishMetadataUri() external view returns (string)
87+
function deployer() external view returns (address)
8888
```
8989

9090

9191

92-
*Returns the publish metadata for this contract.*
92+
*Empty var used in deployment.*
9393

9494

9595
#### Returns
9696

9797
| Name | Type | Description |
9898
|---|---|---|
99-
| _0 | string | undefined
99+
| _0 | address | undefined
100100

101101
### getRoleAdmin
102102

@@ -294,22 +294,6 @@ function setPause(bool _pause) external nonpayable
294294
|---|---|---|
295295
| _pause | bool | undefined
296296

297-
### setPublisheMetadataUi
298-
299-
```solidity
300-
function setPublisheMetadataUi(string uri) external nonpayable
301-
```
302-
303-
304-
305-
*Initializes the publish metadata and at deploy time.*
306-
307-
#### Parameters
308-
309-
| Name | Type | Description |
310-
|---|---|---|
311-
| uri | string | undefined
312-
313297
### supportsInterface
314298

315299
```solidity

docs/IDeployer.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# IDeployer
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
## Methods
12+
13+
### deployer
14+
15+
```solidity
16+
function deployer() external view returns (address)
17+
```
18+
19+
20+
21+
22+
23+
24+
#### Returns
25+
26+
| Name | Type | Description |
27+
|---|---|---|
28+
| _0 | address | undefined
29+
30+
31+
32+

docs/ITempMultiwrap.md

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)