Skip to content

Commit

Permalink
Drop interfaces token structure (#173)
Browse files Browse the repository at this point in the history
* new drop interface structure

* update gitignore

* update docs

* add our own Multicall extension

* dev build
  • Loading branch information
joaquim-verges authored Jun 10, 2022
1 parent f544ef1 commit 5d74f29
Show file tree
Hide file tree
Showing 21 changed files with 606 additions and 36,034 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ yarn-error.log*
/relayerTest
./contracts/v2/Market.sol
/notes.txt
<<<<<<< HEAD
.yalc/
yalc.lock
package-lock.json
yarn.lock

# Forge
#/lib
Expand Down
4 changes: 3 additions & 1 deletion contracts/feature/Drop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
pragma solidity ^0.8.0;

import "./interface/IDrop.sol";
import "./interface/IClaimConditionsMultiPhase.sol";
import "./LazyMint.sol";
import "../lib/MerkleProof.sol";
import "../lib/TWBitMaps.sol";

abstract contract Drop is IDrop {
abstract contract Drop is LazyMint, IDrop, IClaimConditionsMultiPhase {
using TWBitMaps for TWBitMaps.BitMap;

/*///////////////////////////////////////////////////////////////
Expand Down
10 changes: 6 additions & 4 deletions contracts/feature/DropSinglePhase.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "./interface/IDropSinglePhase.sol";
import "./interface/IClaimConditionsSinglePhase.sol";
import "./interface/IDrop.sol";
import "./LazyMint.sol";
import "../lib/MerkleProof.sol";
import "../lib/TWBitMaps.sol";

abstract contract DropSinglePhase is IDropSinglePhase {
abstract contract DropSinglePhase is LazyMint, IDrop, IClaimConditionsSinglePhase {
using TWBitMaps for TWBitMaps.BitMap;

/*///////////////////////////////////////////////////////////////
/*///////////////////////////////////////////////////x////////////
State variables
//////////////////////////////////////////////////////////////*/

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

emit TokensClaimed(_dropMsgSender(), _receiver, startTokenId, _quantity);
emit TokensClaimed(0, _dropMsgSender(), _receiver, startTokenId, _quantity);

_afterClaim(_receiver, _quantity, _currency, _pricePerToken, _allowlistProof, _data);
}
Expand Down
25 changes: 25 additions & 0 deletions contracts/feature/Multicall.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)

pragma solidity ^0.8.0;

import "../lib/TWAddress.sol";
import "./interface/IMulticall.sol";

/**
* @dev Provides a function to batch together multiple calls in a single external call.
*
* _Available since v4.1._
*/
contract Multicall is IMulticall {
/**
* @dev Receives and executes a batch of function calls on this contract.
*/
function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = TWAddress.functionDelegateCall(address(this), data[i]);
}
return results;
}
}
29 changes: 29 additions & 0 deletions contracts/feature/interface/IClaimConditionsMultiPhase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "../../lib/TWBitMaps.sol";
import "./IClaimCondition.sol";

/**
* Thirdweb's 'Drop' contracts are distribution mechanisms for tokens.
*
* A contract admin (i.e. a holder of `DEFAULT_ADMIN_ROLE`) can set a series of claim conditions,
* ordered by their respective `startTimestamp`. A claim condition defines criteria under which
* accounts can mint tokens. Claim conditions can be overwritten or added to by the contract admin.
* At any moment, there is only one active claim condition.
*/

interface IClaimConditionsMultiPhase is IClaimCondition {
event ClaimConditionsUpdated(ClaimCondition[] claimConditions);

/**
* @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) set claim conditions.
*
* @param phases Claim conditions in ascending order by `startTimestamp`.
*
* @param resetClaimEligibility Whether to reset `limitLastClaimTimestamp` and `limitMerkleProofClaim` values when setting new
* claim conditions.
*
*/
function setClaimConditions(ClaimCondition[] calldata phases, bool resetClaimEligibility) external;
}
29 changes: 29 additions & 0 deletions contracts/feature/interface/IClaimConditionsSinglePhase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "../../lib/TWBitMaps.sol";
import "./IClaimCondition.sol";

/**
* Thirdweb's 'Drop' contracts are distribution mechanisms for tokens.
*
* A contract admin (i.e. a holder of `DEFAULT_ADMIN_ROLE`) can set a series of claim conditions,
* ordered by their respective `startTimestamp`. A claim condition defines criteria under which
* accounts can mint tokens. Claim conditions can be overwritten or added to by the contract admin.
* At any moment, there is only one active claim condition.
*/

interface IClaimConditionsSinglePhase is IClaimCondition {
event ClaimConditionUpdated(ClaimCondition claimConditions, bool resetClaimEligibility);

/**
* @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) set claim conditions.
*
* @param phase Claim conditions in ascending order by `startTimestamp`.
*
* @param resetClaimEligibility Whether to reset `limitLastClaimTimestamp` and `limitMerkleProofClaim` values when setting new
* claim conditions.
*
*/
function setClaimConditions(ClaimCondition calldata phase, bool resetClaimEligibility) external;
}
17 changes: 2 additions & 15 deletions contracts/feature/interface/IDrop.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "./IClaimCondition.sol";
import "./ILazyMint.sol";

interface IDrop is IClaimCondition {
interface IDrop is ILazyMint {
struct AllowlistProof {
bytes32[] proof;
uint256 maxQuantityInAllowlist;
Expand All @@ -17,8 +17,6 @@ interface IDrop is IClaimCondition {
uint256 quantityClaimed
);

event ClaimConditionsUpdated(ClaimCondition[] claimConditions);

/**
* @notice Lets an account claim a given quantity of NFTs.
*
Expand All @@ -38,15 +36,4 @@ interface IDrop is IClaimCondition {
AllowlistProof calldata allowlistProof,
bytes memory data
) external payable;

/**
* @notice Lets a contract admin (account with `DEFAULT_ADMIN_ROLE`) set claim conditions.
*
* @param phases Claim conditions in ascending order by `startTimestamp`.
*
* @param resetClaimEligibility Whether to reset `limitLastClaimTimestamp` and `limitMerkleProofClaim` values when setting new
* claim conditions.
*
*/
function setClaimConditions(ClaimCondition[] calldata phases, bool resetClaimEligibility) external;
}
50 changes: 0 additions & 50 deletions contracts/feature/interface/IDropSinglePhase.sol

This file was deleted.

Loading

0 comments on commit 5d74f29

Please sign in to comment.