diff --git a/src/IPNFT.sol b/src/IPNFT.sol index 597869e3..68ed2f78 100644 --- a/src/IPNFT.sol +++ b/src/IPNFT.sol @@ -23,7 +23,7 @@ import { IReservable } from "./IReservable.sol"; \▓▓▓▓▓▓\▓▓ \▓▓ \▓▓\▓▓ \▓▓ */ -/// @title IPNFT V2.4 +/// @title IPNFT V2.5 /// @author molecule.to /// @notice IP-NFTs capture intellectual property to be traded and synthesized contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReservable, UUPSUpgradeable, OwnableUpgradeable, PausableUpgradeable { @@ -92,14 +92,23 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser * @notice reserves a new token id. Checks that the caller is authorized, according to the current implementation of IAuthorizeMints. * @return reservationId a new reservation id */ - function reserve() external whenNotPaused returns (uint256 reservationId) { - if (!mintAuthorizer.authorizeReservation(_msgSender())) { + function reserve() external returns (uint256 reservationId) { + return reserveFor(_msgSender()); + } + + /** + * @notice reserves a new token id for an account. Checks that the caller is authorized, according to the current implementation of IAuthorizeMints. + * @param _for the address that will own the reserved id + * @return reservationId a new reservation id + */ + function reserveFor(address _for) public whenNotPaused returns (uint256 reservationId) { + if (!mintAuthorizer.authorizeReservation(_for)) { revert Unauthorized(); } reservationId = _reservationCounter.current(); _reservationCounter.increment(); - reservations[reservationId] = _msgSender(); - emit Reserved(_msgSender(), reservationId); + reservations[reservationId] = _for; + emit Reserved(_for, reservationId); } /** diff --git a/src/Tokenizer.sol b/src/Tokenizer.sol index a6d9b38d..65b43359 100644 --- a/src/Tokenizer.sol +++ b/src/Tokenizer.sol @@ -124,7 +124,7 @@ contract Tokenizer is UUPSUpgradeable, OwnableUpgradeable, IControlIPTs { string memory tokenSymbol, string memory agreementCid, bytes calldata signedAgreement - ) external returns (IPToken token) { + ) public returns (IPToken token) { if (_msgSender() != controllerOf(ipnftId)) { revert MustControlIpnft(); } @@ -155,6 +155,14 @@ contract Tokenizer is UUPSUpgradeable, OwnableUpgradeable, IControlIPTs { token.issue(_msgSender(), tokenAmount); } + function reserveNewIpnftIdAndTokenize(uint256 amount, string memory tokenSymbol, string memory agreementCid, bytes calldata signedAgreement) + external + returns (uint256 reservationId, IPToken ipToken) + { + reservationId = ipnft.reserve(); + ipToken = tokenizeIpnft(reservationId, amount, tokenSymbol, agreementCid, signedAgreement); + } + /** * @notice issues more IPTs when not capped. This can be used for new owners of legacy IPTs that otherwise wouldn't be able to pass their `onlyIssuerOrOwner` gate * @param ipToken The ip token to control