diff --git a/src/Billboard/Billboard.sol b/src/Billboard/Billboard.sol index 3656213..02e0ce4 100644 --- a/src/Billboard/Billboard.sol +++ b/src/Billboard/Billboard.sol @@ -135,14 +135,6 @@ contract Billboard is IBillboard { /// Auction ////////////////////////////// - /// @inheritdoc IBillboard - function getAuction( - uint256 tokenId_, - uint256 auctionId_ - ) external view returns (IBillboardRegistry.Auction memory auction) { - auction = registry.getAuction(tokenId_, auctionId_); - } - /// @inheritdoc IBillboard function clearAuction(uint256 tokenId_) public returns (uint256 price, uint256 tax) { // revert if board not found diff --git a/src/Billboard/BillboardRegistry.sol b/src/Billboard/BillboardRegistry.sol index 7c9c1c5..7f6a87b 100644 --- a/src/Billboard/BillboardRegistry.sol +++ b/src/Billboard/BillboardRegistry.sol @@ -183,6 +183,22 @@ contract BillboardRegistry is IBillboardRegistry, ERC721 { } } + /// @inheritdoc IBillboardRegistry + function setBidURIs( + uint256 tokenId_, + uint256 epoch_, + address bidder_, + string calldata contentURI_, + string calldata redirectURI_ + ) external isFromOperator { + Bid memory _bid = auctionBids[tokenId_][epoch_][bidder_]; + + _bid.contentURI = contentURI_; + _bid.redirectURI = redirectURI_; + + emit BidUpdated(tokenId_, epoch_, bidder_, _bid.price, _bid.tax, contentURI_, redirectURI_); + } + /// @inheritdoc IBillboardRegistry function setBidWon(uint256 tokenId_, uint256 epoch_, address bidder_, bool isWon_) external isFromOperator { auctionBids[tokenId_][epoch_][bidder_].isWon = isWon_; @@ -215,14 +231,14 @@ contract BillboardRegistry is IBillboardRegistry, ERC721 { ////////////////////////////// /// @inheritdoc IBillboardRegistry - function transferTokenByOperator(address to_, uint256 amount_) external isFromOperator { - require(to_ != address(0), "Zero address"); - require(token.transfer(to_, amount_), "Failed token transfer"); + function safeTransferByOperator(address from_, address to_, uint256 tokenId_) external isFromOperator { + _safeTransfer(from_, to_, tokenId_, ""); } /// @inheritdoc IBillboardRegistry - function safeTransferByOperator(address from_, address to_, uint256 tokenId_) external isFromOperator { - _safeTransfer(from_, to_, tokenId_, ""); + function transferTokenByOperator(address to_, uint256 amount_) external isFromOperator { + require(to_ != address(0), "Zero address"); + require(token.transfer(to_, amount_), "Failed token transfer"); } ////////////////////////////// diff --git a/src/Billboard/IBillboard.sol b/src/Billboard/IBillboard.sol index bd5d735..41cfd00 100644 --- a/src/Billboard/IBillboard.sol +++ b/src/Billboard/IBillboard.sol @@ -12,7 +12,7 @@ import "./IBillboardRegistry.sol"; * - Owner of a billboard can set the AD data of a billboard: call `setBoardName`, `setBoardDescription` and `setBoardLocation`. * - Tenant of a billboard can set the AD data of a billboard: call `setBoardContentURI` and `setBoardRedirectURI`. * - * ## Auction + * ## Auction & Bid * - User needs to call `approve` on currency (USDT) contract before starting. * - User can place a bid on a billboard: call `placeBid`. * - User can clear auction on a billboard: call `clearAuction`. @@ -42,7 +42,7 @@ interface IBillboard { ////////////////////////////// /** - * @notice Add address to white list. + * @notice Add address to whitelist. * * @param tokenId_ Token ID. * @param address_ Address of user will be added into whitelist. @@ -50,7 +50,7 @@ interface IBillboard { function addToWhitelist(uint256 tokenId_, address address_) external; /** - * @notice Remove address from white list. + * @notice Remove address from whitelist. * * @param tokenId_ Token ID. * @param address_ Address of user will be removed from whitelist. @@ -64,71 +64,33 @@ interface IBillboard { /** * @notice Mint a new board (NFT). * - * @param to_ Address of the new board receiver. - */ - function newBoard(address to_) external returns (uint256 tokenId); - - /** - * @notice Get a board data. - * - * @param tokenId_ Token ID. + * @param to_ Address of the board owner. + * @param taxRate_ Tax rate of the new board. + * @param epochInterval_ Epoch interval of the new board. * - * @return board Board data. + * @return tokenId Token ID of the new board. */ - function getBoard(uint256 tokenId_) external view returns (IBillboardRegistry.Board memory board); + function newBoard(address to_, uint256 taxRate_, uint256 epochInterval_) external returns (uint256 tokenId); /** - * @notice Set the name of a board by board creator. + * @notice Set metadata of a board by creator. * - * @param tokenId_ Token ID. + * @param tokenId_ Token ID of a board. * @param name_ Board name. - */ - function setBoardName(uint256 tokenId_, string calldata name_) external; - - /** - * @notice Set the name of a board by board creator. - * - * @param tokenId_ Token ID. * @param description_ Board description. + * @param imageURI_ Image URI of a board. + * @param location_ Location of a board. */ - function setBoardDescription(uint256 tokenId_, string calldata description_) external; - - /** - * @notice Set the location of a board by board creator. - * - * @param tokenId_ Token ID. - * @param location_ Digital address where a board located. - */ - function setBoardLocation(uint256 tokenId_, string calldata location_) external; - - /** - * @notice Set the image of a board by board creator. - * - * @param tokenId_ Token ID. - * @param uri_ URI of the image. - */ - function setBoardImage(uint256 tokenId_, string calldata uri_) external; - - /** - * @notice Set the (AD) content URI of a board by the tenant - * - * @param tokenId_ Token ID. - * @param epoch_ Epoch. - * @param contentURI_ Content URI. - */ - function setBoardContentURI(uint256 tokenId_, uint256 epoch_, string calldata contentURI_) external; - - /** - * @notice Set the (AD) redirect URI of a board by the tenant - * - * @param tokenId_ Token ID. - * @param epoch_ Epoch. - * @param redirectURI_ Redirect URI when users clicking. - */ - function setBoardRedirectURI(uint256 tokenId_, uint256 epoch_, string calldata redirectURI_) external; + function setBoard( + uint256 tokenId_, + string calldata name_, + string calldata description_, + string calldata imageURI_, + string calldata location_ + ) external; ////////////////////////////// - /// Auction + /// Auction & Bid ////////////////////////////// /** @@ -136,46 +98,45 @@ interface IBillboard { * * @param tokenId_ Token ID. * @param epoch_ Epoch. + * + * @return highestBidder Address of the highest bidder. + * @return price Price of the highest bid. + * @return tax Tax of the highest bid. */ - function clearAuction(uint256 tokenId_, uint256 epoch_) external returns (uint256 price, uint256 tax); + function clearAuction( + uint256 tokenId_, + uint256 epoch_ + ) external returns (address highestBidder, uint256 price, uint256 tax); /** * @notice Clear the next auction of mutiple boards. * * @param tokenIds_ Token IDs of boards. + * @param epochs_ Epochs of auctions. + * + * @return highestBidders Addresses of the highest bidders. + * @return prices Prices of the highest bids. + * @return taxes Taxes of the highest bids. */ function clearAuctions( - uint256[] calldata tokenIds_ - ) external returns (uint256[] memory prices, uint256[] memory taxes); + uint256[] calldata tokenIds_, + uint256[] calldata epochs_ + ) external returns (address[] memory highestBidders, uint256[] memory prices, uint256[] memory taxes); /** - * @notice Place bid for the next auction. + * @notice Place bid on a board auction. * * @param tokenId_ Token ID. + * @param epoch_ Epoch. * @param amount_ Amount of a bid. */ - function placeBid(uint256 tokenId_, uint256 amount_) external payable; - - /** - * @notice Get bid of a board auction by auction ID. - * - * @param tokenId_ Token ID. - * @param auctionId_ Auction ID. - * @param bidder_ Address of a bidder. - * - * @return bid Bid. - */ - function getBid( - uint256 tokenId_, - uint256 auctionId_, - address bidder_ - ) external view returns (IBillboardRegistry.Bid memory bid); + function placeBid(uint256 tokenId_, uint256 epoch_, uint256 amount_) external payable; /** - * @notice Get bids of a board auction by auction ID. + * @notice Get bids of a board auction. * * @param tokenId_ Token ID. - * @param auctionId_ Auction ID. + * @param epoch_ Epoch. * @param limit_ Limit of returned bids. * @param offset_ Offset of returned bids. * @@ -186,7 +147,7 @@ interface IBillboard { */ function getBids( uint256 tokenId_, - uint256 auctionId_, + uint256 epoch_, uint256 limit_, uint256 offset_ ) external view returns (uint256 total, uint256 limit, uint256 offset, IBillboardRegistry.Bid[] memory bids); @@ -195,26 +156,15 @@ interface IBillboard { /// Tax & Withdraw ////////////////////////////// - /** - * @notice Get the global tax rate. - * - * @return taxRate Tax rate. - */ - function getTaxRate() external view returns (uint256 taxRate); - - /** - * @notice Set the global tax rate. - * - * @param taxRate_ Tax rate. - */ - function setTaxRate(uint256 taxRate_) external; - /** * @notice Calculate tax of a bid. * + * @param tokenId_ Token ID. * @param amount_ Amount of a bid. + * + * @return tax Tax of a bid. */ - function calculateTax(uint256 amount_) external returns (uint256 tax); + function calculateTax(uint256 tokenId_, uint256 amount_) external returns (uint256 tax); /** * @notice Withdraw accumulated taxation. @@ -226,7 +176,7 @@ interface IBillboard { * @notice Withdraw bid that were not won by auction id; * * @param tokenId_ Token ID. - * @param auctionId_ Auction ID. + * @param epoch_ Epoch. */ - function withdrawBid(uint256 tokenId_, uint256 auctionId_) external; + function withdrawBid(uint256 tokenId_, uint256 epoch_) external; } diff --git a/src/Billboard/IBillboardRegistry.sol b/src/Billboard/IBillboardRegistry.sol index 9a4a4ea..ea72071 100644 --- a/src/Billboard/IBillboardRegistry.sol +++ b/src/Billboard/IBillboardRegistry.sol @@ -181,18 +181,28 @@ interface IBillboardRegistry is IERC721 { function getBidCount(uint256 tokenId_, uint256 epoch_) external view returns (uint256 count); /** - * @notice Create or update a bid + * @notice Create a bid * * @param tokenId_ Token ID of a board. * @param epoch_ Epoch of an auction. * @param bidder_ Bidder of an auction. * @param price_ Price of a bid. * @param tax_ Tax of a bid. + * @param contentURI_ Content URI of a bid. + * @param redirectURI_ Redirect URI of a bid. */ - function setBid(uint256 tokenId_, uint256 epoch_, address bidder_, uint256 price_, uint256 tax_) external; + function newBid( + uint256 tokenId_, + uint256 epoch_, + address bidder_, + uint256 price_, + uint256 tax_, + string calldata contentURI_, + string calldata redirectURI_ + ) external; /** - * @notice Create or update a bid + * @notice Update a bid * * @param tokenId_ Token ID of a board. * @param epoch_ Epoch of an auction. @@ -217,12 +227,14 @@ interface IBillboardRegistry is IERC721 { * * @param tokenId_ Token ID of a board. * @param epoch_ Epoch. + * @param bidder_ Bidder of an auction. * @param contentURI_ Content URI of a board. * @param redirectURI_ Redirect URI of a board. */ function setBidURIs( uint256 tokenId_, uint256 epoch_, + address bidder_, string calldata contentURI_, string calldata redirectURI_ ) external;