Skip to content

Commit 5d74f29

Browse files
Drop interfaces token structure (#173)
* new drop interface structure * update gitignore * update docs * add our own Multicall extension * dev build
1 parent f544ef1 commit 5d74f29

21 files changed

+606
-36034
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ yarn-error.log*
3434
/relayerTest
3535
./contracts/v2/Market.sol
3636
/notes.txt
37-
<<<<<<< HEAD
3837
.yalc/
3938
yalc.lock
39+
package-lock.json
40+
yarn.lock
4041

4142
# Forge
4243
#/lib

contracts/feature/Drop.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
pragma solidity ^0.8.0;
33

44
import "./interface/IDrop.sol";
5+
import "./interface/IClaimConditionsMultiPhase.sol";
6+
import "./LazyMint.sol";
57
import "../lib/MerkleProof.sol";
68
import "../lib/TWBitMaps.sol";
79

8-
abstract contract Drop is IDrop {
10+
abstract contract Drop is LazyMint, IDrop, IClaimConditionsMultiPhase {
911
using TWBitMaps for TWBitMaps.BitMap;
1012

1113
/*///////////////////////////////////////////////////////////////

contracts/feature/DropSinglePhase.sol

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity ^0.8.0;
33

4-
import "./interface/IDropSinglePhase.sol";
4+
import "./interface/IClaimConditionsSinglePhase.sol";
5+
import "./interface/IDrop.sol";
6+
import "./LazyMint.sol";
57
import "../lib/MerkleProof.sol";
68
import "../lib/TWBitMaps.sol";
79

8-
abstract contract DropSinglePhase is IDropSinglePhase {
10+
abstract contract DropSinglePhase is LazyMint, IDrop, IClaimConditionsSinglePhase {
911
using TWBitMaps for TWBitMaps.BitMap;
1012

11-
/*///////////////////////////////////////////////////////////////
13+
/*///////////////////////////////////////////////////x////////////
1214
State variables
1315
//////////////////////////////////////////////////////////////*/
1416

@@ -88,7 +90,7 @@ abstract contract DropSinglePhase is IDropSinglePhase {
8890
// Mint the relevant NFTs to claimer.
8991
uint256 startTokenId = transferTokensOnClaim(_receiver, _quantity);
9092

91-
emit TokensClaimed(_dropMsgSender(), _receiver, startTokenId, _quantity);
93+
emit TokensClaimed(0, _dropMsgSender(), _receiver, startTokenId, _quantity);
9294

9395
_afterClaim(_receiver, _quantity, _currency, _pricePerToken, _allowlistProof, _data);
9496
}

contracts/feature/Multicall.sol

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import "../lib/TWAddress.sol";
7+
import "./interface/IMulticall.sol";
8+
9+
/**
10+
* @dev Provides a function to batch together multiple calls in a single external call.
11+
*
12+
* _Available since v4.1._
13+
*/
14+
contract Multicall is IMulticall {
15+
/**
16+
* @dev Receives and executes a batch of function calls on this contract.
17+
*/
18+
function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
19+
results = new bytes[](data.length);
20+
for (uint256 i = 0; i < data.length; i++) {
21+
results[i] = TWAddress.functionDelegateCall(address(this), data[i]);
22+
}
23+
return results;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
import "../../lib/TWBitMaps.sol";
5+
import "./IClaimCondition.sol";
6+
7+
/**
8+
* Thirdweb's 'Drop' contracts are distribution mechanisms for tokens.
9+
*
10+
* A contract admin (i.e. a holder of `DEFAULT_ADMIN_ROLE`) can set a series of claim conditions,
11+
* ordered by their respective `startTimestamp`. A claim condition defines criteria under which
12+
* accounts can mint tokens. Claim conditions can be overwritten or added to by the contract admin.
13+
* At any moment, there is only one active claim condition.
14+
*/
15+
16+
interface IClaimConditionsMultiPhase is IClaimCondition {
17+
event ClaimConditionsUpdated(ClaimCondition[] claimConditions);
18+
19+
/**
20+
* @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) set claim conditions.
21+
*
22+
* @param phases Claim conditions in ascending order by `startTimestamp`.
23+
*
24+
* @param resetClaimEligibility Whether to reset `limitLastClaimTimestamp` and `limitMerkleProofClaim` values when setting new
25+
* claim conditions.
26+
*
27+
*/
28+
function setClaimConditions(ClaimCondition[] calldata phases, bool resetClaimEligibility) external;
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
import "../../lib/TWBitMaps.sol";
5+
import "./IClaimCondition.sol";
6+
7+
/**
8+
* Thirdweb's 'Drop' contracts are distribution mechanisms for tokens.
9+
*
10+
* A contract admin (i.e. a holder of `DEFAULT_ADMIN_ROLE`) can set a series of claim conditions,
11+
* ordered by their respective `startTimestamp`. A claim condition defines criteria under which
12+
* accounts can mint tokens. Claim conditions can be overwritten or added to by the contract admin.
13+
* At any moment, there is only one active claim condition.
14+
*/
15+
16+
interface IClaimConditionsSinglePhase is IClaimCondition {
17+
event ClaimConditionUpdated(ClaimCondition claimConditions, bool resetClaimEligibility);
18+
19+
/**
20+
* @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) set claim conditions.
21+
*
22+
* @param phase Claim conditions in ascending order by `startTimestamp`.
23+
*
24+
* @param resetClaimEligibility Whether to reset `limitLastClaimTimestamp` and `limitMerkleProofClaim` values when setting new
25+
* claim conditions.
26+
*
27+
*/
28+
function setClaimConditions(ClaimCondition calldata phase, bool resetClaimEligibility) external;
29+
}

contracts/feature/interface/IDrop.sol

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity ^0.8.0;
33

4-
import "./IClaimCondition.sol";
4+
import "./ILazyMint.sol";
55

6-
interface IDrop is IClaimCondition {
6+
interface IDrop is ILazyMint {
77
struct AllowlistProof {
88
bytes32[] proof;
99
uint256 maxQuantityInAllowlist;
@@ -17,8 +17,6 @@ interface IDrop is IClaimCondition {
1717
uint256 quantityClaimed
1818
);
1919

20-
event ClaimConditionsUpdated(ClaimCondition[] claimConditions);
21-
2220
/**
2321
* @notice Lets an account claim a given quantity of NFTs.
2422
*
@@ -38,15 +36,4 @@ interface IDrop is IClaimCondition {
3836
AllowlistProof calldata allowlistProof,
3937
bytes memory data
4038
) external payable;
41-
42-
/**
43-
* @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) set claim conditions.
44-
*
45-
* @param phases Claim conditions in ascending order by `startTimestamp`.
46-
*
47-
* @param resetClaimEligibility Whether to reset `limitLastClaimTimestamp` and `limitMerkleProofClaim` values when setting new
48-
* claim conditions.
49-
*
50-
*/
51-
function setClaimConditions(ClaimCondition[] calldata phases, bool resetClaimEligibility) external;
5239
}

contracts/feature/interface/IDropSinglePhase.sol

-50
This file was deleted.

0 commit comments

Comments
 (0)