Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tokenIds #583

Merged
merged 15 commits into from
Apr 20, 2023
34 changes: 5 additions & 29 deletions contracts/interfaces/clients/IBosonVoucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IERC721MetadataUpgradeable } from "@openzeppelin/contracts-upgradeable/
*
* @notice This is the interface for the Boson Protocol ERC-721 Voucher contract.
*
* The ERC-165 identifier for this interface is: 0x0db62fa8
* The ERC-165 identifier for this interface is: 0xaf16da6e
*/
interface IBosonVoucher is IERC721Upgradeable, IERC721MetadataUpgradeable {
event ContractURIChanged(string contractURI);
Expand All @@ -33,19 +33,19 @@ interface IBosonVoucher is IERC721Upgradeable, IERC721MetadataUpgradeable {
* Minted voucher supply is sent to the buyer.
* Caller must have PROTOCOL role.
*
* @param _exchangeId - the id of the exchange (corresponds to the ERC-721 token id)
* @param _tokenId - voucher token id corresponds to <<uint128(offerId)>>.<<uint128(exchangeId)>>
* @param _buyer - the buyer address
*/
function issueVoucher(uint256 _exchangeId, address _buyer) external;
function issueVoucher(uint256 _tokenId, address _buyer) external;

/**
* @notice Burns a voucher.
*
* Caller must have PROTOCOL role.
*
* @param _exchangeId - the id of the exchange (corresponds to the ERC-721 token id)
* @param _tokenId - voucher token id corresponds to <<uint128(offerId)>>.<<uint128(exchangeId)>>
*/
function burnVoucher(uint256 _exchangeId) external;
function burnVoucher(uint256 _tokenId) external;

/**
* @notice Gets the seller id.
Expand Down Expand Up @@ -196,30 +196,6 @@ interface IBosonVoucher is IERC721Upgradeable, IERC721MetadataUpgradeable {
*/
function burnPremintedVouchers(uint256 _offerId) external;

mischat marked this conversation as resolved.
Show resolved Hide resolved
/**
* @notice Non-standard ERC721 function to transfer a pre-minted token from one address to another.
*
* Reverts if:
* - TokenId was already used to commit
* - TokenId already exists (i.e. has an owner)
* - TokenId has not been preminted yet
* - TokenId was already burned
* - From is not the owner of the voucher contract
*
* @param _from - the address to transfer from
* @param _to - the address to transfer to
* @param _offerId - the id of the offer
* @param _tokenId - the id of the token
* @param _data - data to pass if receiver is contract
*/
function transferPremintedFrom(
address _from,
address _to,
uint256 _offerId,
uint256 _tokenId,
bytes memory _data
) external;

/**
* @notice Gets the number of vouchers available to be pre-minted for an offer.
*
Expand Down
3 changes: 2 additions & 1 deletion contracts/mock/MockExchangeHandlerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ contract MockExchangeHandlerFacet is BuyerBase, DisputeBase {
// Burn the voucher
(, Offer storage offer) = fetchOffer(_exchange.offerId);
IBosonVoucher bosonVoucher = IBosonVoucher(protocolLookups().cloneAddress[offer.sellerId]);
bosonVoucher.burnVoucher(_exchange.id);
uint256 tokenId = _exchange.id + (_exchange.offerId << 128);
bosonVoucher.burnVoucher(tokenId);
}

/**
Expand Down
12 changes: 0 additions & 12 deletions contracts/protocol/bases/BeaconClientBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ abstract contract BeaconClientBase is BosonTypes {
(, offer, offerDates, , , ) = IBosonOfferHandler(protocolDiamond).getOffer(_offerId);
}

/**
* @notice Gets the exchange associated with a voucher
*
* @param _exchangeId - the id of the exchange
* @return exists - the exchange was found
* @return exchange - the exchange associated with the _exchangeId
*/
function getBosonExchange(uint256 _exchangeId) internal view returns (bool exists, Exchange memory exchange) {
address protocolDiamond = IClientExternalAddresses(BeaconClientLib._beacon()).getProtocolAddress();
(exists, exchange, ) = IBosonExchangeHandler(protocolDiamond).getExchange(_exchangeId);
}

/**
* @notice Informs protocol of new buyer associated with an exchange
*
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocol/bases/OfferBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents {
require(offer.quantityAvailable >= _length, INVALID_RANGE_LENGTH);

// Prevent reservation of too large range, since it affects exchangeId
require(_length < (1 << 128), INVALID_RANGE_LENGTH);
require(_length < (1 << 64), INVALID_RANGE_LENGTH);

// Get starting token id
ProtocolLib.ProtocolCounters storage pc = protocolCounters();
Expand Down
Loading