Skip to content

Commit 0d3b885

Browse files
authored
Default admin param in base contract constructors (#435)
* remove msg.sender from base contract constructors * v3.8.0-0
1 parent 10e06b5 commit 0d3b885

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+88
-49
lines changed

contracts/base/ERC1155Base.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ contract ERC1155Base is
6464
//////////////////////////////////////////////////////////////*/
6565

6666
constructor(
67+
address _defaultAdmin,
6768
string memory _name,
6869
string memory _symbol,
6970
address _royaltyRecipient,
7071
uint128 _royaltyBps
7172
) ERC1155(_name, _symbol) {
72-
_setupOwner(msg.sender);
73+
_setupOwner(_defaultAdmin);
7374
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
7475
_setOperatorRestriction(true);
7576
}

contracts/base/ERC1155DelayedReveal.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ contract ERC1155DelayedReveal is ERC1155LazyMint, DelayedReveal {
3232
//////////////////////////////////////////////////////////////*/
3333

3434
constructor(
35+
address _defaultAdmin,
3536
string memory _name,
3637
string memory _symbol,
3738
address _royaltyRecipient,
3839
uint128 _royaltyBps
39-
) ERC1155LazyMint(_name, _symbol, _royaltyRecipient, _royaltyBps) {}
40+
) ERC1155LazyMint(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {}
4041

4142
/*//////////////////////////////////////////////////////////////
4243
Overriden Metadata logic

contracts/base/ERC1155Drop.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ contract ERC1155Drop is
7272
//////////////////////////////////////////////////////////////*/
7373

7474
constructor(
75+
address _defaultAdmin,
7576
string memory _name,
7677
string memory _symbol,
7778
address _royaltyRecipient,
7879
uint128 _royaltyBps,
7980
address _primarySaleRecipient
8081
) ERC1155(_name, _symbol) {
81-
_setupOwner(msg.sender);
82+
_setupOwner(_defaultAdmin);
8283
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
8384
_setupPrimarySaleRecipient(_primarySaleRecipient);
8485
_setOperatorRestriction(true);

contracts/base/ERC1155LazyMint.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ contract ERC1155LazyMint is
7878
//////////////////////////////////////////////////////////////*/
7979

8080
constructor(
81+
address _defaultAdmin,
8182
string memory _name,
8283
string memory _symbol,
8384
address _royaltyRecipient,
8485
uint128 _royaltyBps
8586
) ERC1155(_name, _symbol) {
86-
_setupOwner(msg.sender);
87+
_setupOwner(_defaultAdmin);
8788
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
8889
_setOperatorRestriction(true);
8990
}

contracts/base/ERC1155SignatureMint.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ contract ERC1155SignatureMint is ERC1155Base, PrimarySale, SignatureMintERC1155
2929
//////////////////////////////////////////////////////////////*/
3030

3131
constructor(
32+
address _defaultAdmin,
3233
string memory _name,
3334
string memory _symbol,
3435
address _royaltyRecipient,
3536
uint128 _royaltyBps,
3637
address _primarySaleRecipient
37-
) ERC1155Base(_name, _symbol, _royaltyRecipient, _royaltyBps) {
38+
) ERC1155Base(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {
3839
_setupPrimarySaleRecipient(_primarySaleRecipient);
3940
}
4041

contracts/base/ERC20Base.sol

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ contract ERC20Base is ContractMetadata, Multicall, Ownable, ERC20Permit, IMintab
3131
Constructor
3232
//////////////////////////////////////////////////////////////*/
3333

34-
constructor(string memory _name, string memory _symbol) ERC20Permit(_name, _symbol) {
35-
_setupOwner(msg.sender);
34+
constructor(
35+
address _defaultAdmin,
36+
string memory _name,
37+
string memory _symbol
38+
) ERC20Permit(_name, _symbol) {
39+
_setupOwner(_defaultAdmin);
3640
}
3741

3842
/*//////////////////////////////////////////////////////////////

contracts/base/ERC20Drop.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ contract ERC20Drop is ContractMetadata, Multicall, Ownable, ERC20Permit, Primary
4040
//////////////////////////////////////////////////////////////*/
4141

4242
constructor(
43+
address _defaultAdmin,
4344
string memory _name,
4445
string memory _symbol,
4546
address _primarySaleRecipient
4647
) ERC20Permit(_name, _symbol) {
47-
_setupOwner(msg.sender);
48+
_setupOwner(_defaultAdmin);
4849
_setupPrimarySaleRecipient(_primarySaleRecipient);
4950
}
5051

contracts/base/ERC20DropVote.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ contract ERC20DropVote is ContractMetadata, Multicall, Ownable, ERC20Votes, Prim
3939
//////////////////////////////////////////////////////////////*/
4040

4141
constructor(
42+
address _defaultAdmin,
4243
string memory _name,
4344
string memory _symbol,
4445
address _primarySaleRecipient
4546
) ERC20Permit(_name, _symbol) {
46-
_setupOwner(msg.sender);
47+
_setupOwner(_defaultAdmin);
4748
_setupPrimarySaleRecipient(_primarySaleRecipient);
4849
}
4950

contracts/base/ERC20SignatureMint.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ contract ERC20SignatureMint is ERC20Base, PrimarySale, SignatureMintERC20 {
2929
//////////////////////////////////////////////////////////////*/
3030

3131
constructor(
32+
address _defaultAdmin,
3233
string memory _name,
3334
string memory _symbol,
3435
address _primarySaleRecipient
35-
) ERC20Base(_name, _symbol) {
36+
) ERC20Base(_defaultAdmin, _name, _symbol) {
3637
_setupPrimarySaleRecipient(_primarySaleRecipient);
3738
}
3839

contracts/base/ERC20SignatureMintVote.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ contract ERC20SignatureMintVote is ERC20Vote, PrimarySale, SignatureMintERC20 {
2929
//////////////////////////////////////////////////////////////*/
3030

3131
constructor(
32+
address _defaultAdmin,
3233
string memory _name,
3334
string memory _symbol,
3435
address _primarySaleRecipient
35-
) ERC20Vote(_name, _symbol) {
36+
) ERC20Vote(_defaultAdmin, _name, _symbol) {
3637
_setupPrimarySaleRecipient(_primarySaleRecipient);
3738
}
3839

contracts/base/ERC20Vote.sol

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ contract ERC20Vote is ContractMetadata, Multicall, Ownable, ERC20Votes, IMintabl
3131
Constructor
3232
//////////////////////////////////////////////////////////////*/
3333

34-
constructor(string memory _name, string memory _symbol) ERC20Permit(_name, _symbol) {
35-
_setupOwner(msg.sender);
34+
constructor(
35+
address _defaultAdmin,
36+
string memory _name,
37+
string memory _symbol
38+
) ERC20Permit(_name, _symbol) {
39+
_setupOwner(_defaultAdmin);
3640
}
3741

3842
/*//////////////////////////////////////////////////////////////

contracts/base/ERC721Base.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ contract ERC721Base is
5353
//////////////////////////////////////////////////////////////*/
5454

5555
constructor(
56+
address _defaultAdmin,
5657
string memory _name,
5758
string memory _symbol,
5859
address _royaltyRecipient,
5960
uint128 _royaltyBps
6061
) ERC721A(_name, _symbol) {
61-
_setupOwner(msg.sender);
62+
_setupOwner(_defaultAdmin);
6263
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
6364
_setOperatorRestriction(true);
6465
}

contracts/base/ERC721DelayedReveal.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ contract ERC721DelayedReveal is ERC721LazyMint, DelayedReveal {
3333
//////////////////////////////////////////////////////////////*/
3434

3535
constructor(
36+
address _defaultAdmin,
3637
string memory _name,
3738
string memory _symbol,
3839
address _royaltyRecipient,
3940
uint128 _royaltyBps
40-
) ERC721LazyMint(_name, _symbol, _royaltyRecipient, _royaltyBps) {}
41+
) ERC721LazyMint(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {}
4142

4243
/*//////////////////////////////////////////////////////////////
4344
Overriden ERC721 logic

contracts/base/ERC721Drop.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ contract ERC721Drop is
6262
//////////////////////////////////////////////////////////////*/
6363

6464
constructor(
65+
address _defaultAdmin,
6566
string memory _name,
6667
string memory _symbol,
6768
address _royaltyRecipient,
6869
uint128 _royaltyBps,
6970
address _primarySaleRecipient
7071
) ERC721A(_name, _symbol) {
71-
_setupOwner(msg.sender);
72+
_setupOwner(_defaultAdmin);
7273
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
7374
_setupPrimarySaleRecipient(_primarySaleRecipient);
7475
_setOperatorRestriction(true);

contracts/base/ERC721LazyMint.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ contract ERC721LazyMint is
6262
//////////////////////////////////////////////////////////////*/
6363

6464
constructor(
65+
address _defaultAdmin,
6566
string memory _name,
6667
string memory _symbol,
6768
address _royaltyRecipient,
6869
uint128 _royaltyBps
6970
) ERC721A(_name, _symbol) {
70-
_setupOwner(msg.sender);
71+
_setupOwner(_defaultAdmin);
7172
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
7273
_setOperatorRestriction(true);
7374
}

contracts/base/ERC721Multiwrap.sol

+5-4
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,20 @@ contract ERC721Multiwrap is
8282
//////////////////////////////////////////////////////////////*/
8383

8484
constructor(
85+
address _defaultAdmin,
8586
string memory _name,
8687
string memory _symbol,
8788
address _royaltyRecipient,
8889
uint128 _royaltyBps,
8990
address _nativeTokenWrapper
9091
) ERC721A(_name, _symbol) TokenStore(_nativeTokenWrapper) {
91-
_setupOwner(msg.sender);
92+
_setupOwner(_defaultAdmin);
9293
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
9394
_setOperatorRestriction(true);
9495

95-
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
96-
_setupRole(MINTER_ROLE, msg.sender);
97-
_setupRole(TRANSFER_ROLE, msg.sender);
96+
_setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
97+
_setupRole(MINTER_ROLE, _defaultAdmin);
98+
_setupRole(TRANSFER_ROLE, _defaultAdmin);
9899

99100
_setupRole(ASSET_ROLE, address(0));
100101
_setupRole(UNWRAP_ROLE, address(0));

contracts/base/ERC721SignatureMint.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ contract ERC721SignatureMint is ERC721Base, PrimarySale, SignatureMintERC721 {
3030
//////////////////////////////////////////////////////////////*/
3131

3232
constructor(
33+
address _defaultAdmin,
3334
string memory _name,
3435
string memory _symbol,
3536
address _royaltyRecipient,
3637
uint128 _royaltyBps,
3738
address _primarySaleRecipient
38-
) ERC721Base(_name, _symbol, _royaltyRecipient, _royaltyBps) {
39+
) ERC721Base(_defaultAdmin, _name, _symbol, _royaltyRecipient, _royaltyBps) {
3940
_setupPrimarySaleRecipient(_primarySaleRecipient);
4041
}
4142

contracts/base/Staking1155Base.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ contract Staking1155Base is ContractMetadata, Multicall, Ownable, Staking1155, E
5555
uint256 private rewardTokenBalance;
5656

5757
constructor(
58+
address _defaultAdmin,
5859
uint256 _defaultTimeUnit,
5960
uint256 _defaultRewardsPerUnitTime,
6061
address _stakingToken,
6162
address _rewardToken,
6263
address _nativeTokenWrapper
6364
) Staking1155(_stakingToken) {
64-
_setupOwner(msg.sender);
65+
_setupOwner(_defaultAdmin);
6566
_setDefaultStakingCondition(_defaultTimeUnit, _defaultRewardsPerUnitTime);
6667

6768
rewardToken = _rewardToken;

contracts/base/Staking20Base.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ contract Staking20Base is ContractMetadata, Multicall, Ownable, Staking20 {
5151
uint256 private rewardTokenBalance;
5252

5353
constructor(
54+
address _defaultAdmin,
5455
uint256 _timeUnit,
5556
uint256 _rewardRatioNumerator,
5657
uint256 _rewardRatioDenominator,
@@ -65,7 +66,7 @@ contract Staking20Base is ContractMetadata, Multicall, Ownable, Staking20 {
6566
IERC20Metadata(_rewardToken).decimals()
6667
)
6768
{
68-
_setupOwner(msg.sender);
69+
_setupOwner(_defaultAdmin);
6970
_setStakingCondition(_timeUnit, _rewardRatioNumerator, _rewardRatioDenominator);
7071

7172
require(_rewardToken != _stakingToken, "Reward Token and Staking Token can't be same.");

contracts/base/Staking721Base.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ contract Staking721Base is ContractMetadata, Multicall, Ownable, Staking721, ERC
5555
uint256 private rewardTokenBalance;
5656

5757
constructor(
58+
address _defaultAdmin,
5859
uint256 _timeUnit,
5960
uint256 _rewardsPerUnitTime,
6061
address _stakingToken,
6162
address _rewardToken,
6263
address _nativeTokenWrapper
6364
) Staking721(_stakingToken) {
64-
_setupOwner(msg.sender);
65+
_setupOwner(_defaultAdmin);
6566
_setStakingCondition(_timeUnit, _rewardsPerUnitTime);
6667

6768
rewardToken = _rewardToken;

contracts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thirdweb-dev/contracts",
33
"description": "Collection of smart contracts deployable via the thirdweb SDK, dashboard and CLI",
4-
"version": "3.7.0",
4+
"version": "3.8.0-0",
55
"license": "Apache-2.0",
66
"repository": {
77
"type": "git",

src/test/marketplace/DirectListings.t.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,9 @@ contract MarketplaceDirectListingsTest is BaseTest {
477477
// create token with ERC2981
478478
address royaltyRecipient = address(0x12345);
479479
uint128 royaltyBps = 10;
480-
ERC721Base nft2981 = new ERC721Base("NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
480+
ERC721Base nft2981 = new ERC721Base(address(0x12345), "NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
481481
// Mint the ERC721 tokens to seller. These tokens will be listed.
482+
vm.prank(address(0x12345));
482483
nft2981.mintTo(seller, "");
483484

484485
vm.prank(marketplaceDeployer);
@@ -508,7 +509,8 @@ contract MarketplaceDirectListingsTest is BaseTest {
508509
// create token with ERC2981
509510
address royaltyRecipient = address(0x12345);
510511
uint128 royaltyBps = 10;
511-
ERC721Base nft2981 = new ERC721Base("NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
512+
ERC721Base nft2981 = new ERC721Base(address(0x12345), "NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
513+
vm.prank(address(0x12345));
512514
nft2981.mintTo(seller, "");
513515

514516
vm.prank(marketplaceDeployer);

src/test/marketplace/EnglishAuctions.t.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ contract MarketplaceEnglishAuctionsTest is BaseTest {
283283
// create token with ERC2981
284284
address royaltyRecipient = address(0x12345);
285285
uint128 royaltyBps = 10;
286-
ERC721Base nft2981 = new ERC721Base("NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
286+
ERC721Base nft2981 = new ERC721Base(address(0x12345), "NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
287287
// Mint the ERC721 tokens to seller. These tokens will be listed.
288+
vm.prank(address(0x12345));
288289
nft2981.mintTo(seller, "");
289290

290291
vm.prank(marketplaceDeployer);
@@ -319,7 +320,8 @@ contract MarketplaceEnglishAuctionsTest is BaseTest {
319320
// create token with ERC2981
320321
address royaltyRecipient = address(0x12345);
321322
uint128 royaltyBps = 10;
322-
ERC721Base nft2981 = new ERC721Base("NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
323+
ERC721Base nft2981 = new ERC721Base(address(0x12345), "NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
324+
vm.prank(address(0x12345));
323325
nft2981.mintTo(seller, "");
324326

325327
vm.prank(marketplaceDeployer);

src/test/marketplace/Offers.t.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ contract MarketplaceOffersTest is BaseTest {
223223
// create token with ERC2981
224224
address royaltyRecipient = address(0x12345);
225225
uint128 royaltyBps = 10;
226-
ERC721Base nft2981 = new ERC721Base("NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
226+
ERC721Base nft2981 = new ERC721Base(address(0x12345), "NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
227227
// Mint the ERC721 tokens to seller. These tokens will be sold.
228+
vm.prank(address(0x12345));
228229
nft2981.mintTo(seller, "");
229230

230231
vm.prank(marketplaceDeployer);
@@ -254,7 +255,8 @@ contract MarketplaceOffersTest is BaseTest {
254255
// create token with ERC2981
255256
address royaltyRecipient = address(0x12345);
256257
uint128 royaltyBps = 10;
257-
ERC721Base nft2981 = new ERC721Base("NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
258+
ERC721Base nft2981 = new ERC721Base(address(0x12345), "NFT 2981", "NFT2981", royaltyRecipient, royaltyBps);
259+
vm.prank(address(0x12345));
258260
nft2981.mintTo(seller, "");
259261

260262
vm.prank(marketplaceDeployer);

src/test/sdk/base/ERC1155Base.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract ERC1155BaseTest is DSTest, Test {
2323
nftHolder = address(0x456);
2424

2525
vm.prank(admin);
26-
base = new ERC1155Base("name", "symbol", admin, 0);
26+
base = new ERC1155Base(admin, "name", "symbol", admin, 0);
2727
}
2828

2929
// ================== `mintTo` tests ========================

src/test/sdk/base/ERC1155DelayedReveal.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ contract ERC1155DelayedRevealTest is DSTest, Test {
2929
nftHolder = address(0x456);
3030

3131
vm.prank(admin);
32-
base = new ERC1155DelayedReveal("name", "symbol", admin, 0);
32+
base = new ERC1155DelayedReveal(admin, "name", "symbol", admin, 0);
3333

3434
bytes memory encryptedBaseURI = base.encryptDecrypt(bytes(baseURI), key);
3535
bytes32 provenanceHash = keccak256(abi.encodePacked(baseURI, key, block.chainid));

0 commit comments

Comments
 (0)