Skip to content

Commit ce919e8

Browse files
committed
saleRecipient mapping for DropERC1155
1 parent d503221 commit ce919e8

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

contracts/drop/DropERC1155.sol

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,19 @@ contract DropERC1155 is
7171
/// @dev Mapping from token ID => maximum possible total circulating supply of tokens with that ID.
7272
mapping(uint256 => uint256) public maxTotalSupply;
7373

74+
/// @dev Mapping from token ID => the address of the recipient of primary sales.
75+
mapping(uint256 => address) public saleRecipient;
76+
7477
/*///////////////////////////////////////////////////////////////
7578
Events
7679
//////////////////////////////////////////////////////////////*/
7780

7881
/// @dev Emitted when the global max supply of a token is updated.
7982
event MaxTotalSupplyUpdated(uint256 tokenId, uint256 maxTotalSupply);
8083

84+
/// @dev Emitted when the sale recipient for a particular tokenId is updated.
85+
event SaleRecipientForTokenUpdated(uint256 indexed tokenId, address saleRecipient);
86+
8187
/*///////////////////////////////////////////////////////////////
8288
Constructor + initializer logic
8389
//////////////////////////////////////////////////////////////*/
@@ -206,6 +212,12 @@ contract DropERC1155 is
206212
emit MaxTotalSupplyUpdated(_tokenId, _maxTotalSupply);
207213
}
208214

215+
/// @dev Lets a contract admin set the recipient for all primary sales.
216+
function setSaleRecipientForToken(uint256 _tokenId, address _saleRecipient) external onlyRole(DEFAULT_ADMIN_ROLE) {
217+
saleRecipient[_tokenId] = _saleRecipient;
218+
emit SaleRecipientForTokenUpdated(_tokenId, _saleRecipient);
219+
}
220+
209221
/*///////////////////////////////////////////////////////////////
210222
Internal functions
211223
//////////////////////////////////////////////////////////////*/
@@ -231,6 +243,7 @@ contract DropERC1155 is
231243

232244
/// @dev Collects and distributes the primary sale value of NFTs being claimed.
233245
function collectPriceOnClaim(
246+
uint256 _tokenId,
234247
address _primarySaleRecipient,
235248
uint256 _quantityToClaim,
236249
address _currency,
@@ -242,7 +255,9 @@ contract DropERC1155 is
242255

243256
(address platformFeeRecipient, uint16 platformFeeBps) = getPlatformFeeInfo();
244257

245-
address saleRecipient = _primarySaleRecipient == address(0) ? primarySaleRecipient() : _primarySaleRecipient;
258+
address _saleRecipient = _primarySaleRecipient == address(0)
259+
? (saleRecipient[_tokenId] == address(0) ? primarySaleRecipient() : saleRecipient[_tokenId])
260+
: _primarySaleRecipient;
246261

247262
uint256 totalPrice = _quantityToClaim * _pricePerToken;
248263
uint256 platformFees = (totalPrice * platformFeeBps) / MAX_BPS;
@@ -254,7 +269,7 @@ contract DropERC1155 is
254269
}
255270

256271
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
257-
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), saleRecipient, totalPrice - platformFees);
272+
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), _saleRecipient, totalPrice - platformFees);
258273
}
259274

260275
/// @dev Transfers the NFTs being claimed.

contracts/extension/Drop1155.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract contract Drop1155 is IDrop1155 {
4848
claimCondition[_tokenId].supplyClaimedByWallet[activeConditionId][_dropMsgSender()] += _quantity;
4949

5050
// If there's a price, collect price.
51-
collectPriceOnClaim(address(0), _quantity, _currency, _pricePerToken);
51+
collectPriceOnClaim(_tokenId, address(0), _quantity, _currency, _pricePerToken);
5252

5353
// Mint the relevant NFTs to claimer.
5454
transferTokensOnClaim(_receiver, _tokenId, _quantity); //-------refactor
@@ -255,6 +255,7 @@ abstract contract Drop1155 is IDrop1155 {
255255

256256
/// @dev Collects and distributes the primary sale value of NFTs being claimed.
257257
function collectPriceOnClaim(
258+
uint256 _tokenId,
258259
address _primarySaleRecipient,
259260
uint256 _quantityToClaim,
260261
address _currency,

0 commit comments

Comments
 (0)