From de4e718a0463559b2df9d89e74c99358c9be6819 Mon Sep 17 00:00:00 2001 From: Coderdan Date: Thu, 12 Feb 2026 18:25:10 +0800 Subject: [PATCH 1/2] fix: persist ERC721 listing price updates --- contracts/Aavegotchi/libraries/LibERC721Marketplace.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/Aavegotchi/libraries/LibERC721Marketplace.sol b/contracts/Aavegotchi/libraries/LibERC721Marketplace.sol index 2b6453b8..689a546f 100644 --- a/contracts/Aavegotchi/libraries/LibERC721Marketplace.sol +++ b/contracts/Aavegotchi/libraries/LibERC721Marketplace.sol @@ -103,8 +103,8 @@ library LibERC721Marketplace { require(listing.cancelled == false, "ERC721Marketplace: listing already cancelled"); require(listing.seller == LibMeta.msgSender(), "ERC721Marketplace: Not seller of ERC721 listing"); - //comment out until graph event is added - // s.erc721Listings[_listingId].priceInWei = _priceInWei; + // Persist the new price on-chain (off-chain indexers also consume the event below). + listing.priceInWei = _priceInWei; emit ERC721ListingPriceUpdate(_listingId, _priceInWei, block.timestamp); } From d7ed7a92d52bff2d48d0f588246234e50ff6fedb Mon Sep 17 00:00:00 2001 From: Coderdan Date: Thu, 12 Feb 2026 20:39:14 +0800 Subject: [PATCH 2/2] test: add foundry regression for ERC721 listing price update --- .../ERC721ListingPriceUpdate.t.sol | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 test/foundryTests/ERC721ListingPriceUpdate.t.sol diff --git a/test/foundryTests/ERC721ListingPriceUpdate.t.sol b/test/foundryTests/ERC721ListingPriceUpdate.t.sol new file mode 100644 index 00000000..e3ea706a --- /dev/null +++ b/test/foundryTests/ERC721ListingPriceUpdate.t.sol @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.1; + +import {Constants} from "./constants.sol"; +import {OwnershipFacet} from "../../contracts/shared/facets/OwnershipFacet.sol"; +import {DiamondLoupeFacet} from "../../contracts/shared/facets/DiamondLoupeFacet.sol"; +import {IDiamondCut} from "../../contracts/shared/interfaces/IDiamondCut.sol"; +import {ERC1155MarketplaceFacet} from "../../contracts/Aavegotchi/facets/ERC1155MarketplaceFacet.sol"; +import {ERC721MarketplaceFacet} from "../../contracts/Aavegotchi/facets/ERC721MarketplaceFacet.sol"; +import {MarketplaceGetterFacet} from "../../contracts/Aavegotchi/facets/MarketplaceGetterFacet.sol"; +import {ERC721Listing} from "../../contracts/Aavegotchi/libraries/LibERC721Marketplace.sol"; +import {ERC721WithRoyalties} from "../../contracts/test/ERC721WithRoyalties.sol"; + +contract ERC721ListingPriceUpdateTest is Constants { + event ERC721ListingPriceUpdate(uint256 indexed listingId, uint256 priceInWei, uint256 time); + + Contracts c; + address diamondOwner; + + address seller; + ERC721WithRoyalties mockErc721; + uint256 tokenId; + uint256 listingId; + + function setUp() public { + vm.createSelectFork(baseMainnetRpcUrl()); + c = contractByChainId(block.chainid); + + diamondOwner = OwnershipFacet(c.aavegotchiDiamond).owner(); + + // Remove listing fee requirements for the test to stay self-contained. + vm.startPrank(diamondOwner); + ERC1155MarketplaceFacet(c.aavegotchiDiamond).setListingFee(0); + + // Upgrade only the selector under test to use the fixed LibERC721Marketplace implementation. + ERC721MarketplaceFacet patchedFacet = new ERC721MarketplaceFacet(); + _replaceSelector(c.aavegotchiDiamond, address(patchedFacet), ERC721MarketplaceFacet.updateERC721ListingPrice.selector); + vm.stopPrank(); + + seller = makeAddr("seller"); + + // Deploy a simple ERC721 on the fork and list it on the Baazaar. + mockErc721 = new ERC721WithRoyalties("Mock ERC721", "MOCK"); + tokenId = 0; + mockErc721.mint(seller, address(0), 0); + + vm.startPrank(seller); + mockErc721.approve(c.aavegotchiDiamond, tokenId); + ERC721MarketplaceFacet(c.aavegotchiDiamond).addERC721Listing(address(mockErc721), tokenId, 0, 1e18); + vm.stopPrank(); + + ERC721Listing memory listing = MarketplaceGetterFacet(c.aavegotchiDiamond).getERC721ListingFromToken( + address(mockErc721), + tokenId, + seller + ); + listingId = listing.listingId; + } + + function test_updateERC721ListingPrice_persistsNewPrice() public { + uint256 newPrice = 2e18; + + vm.startPrank(seller); + + uint256 nowTs = block.timestamp; + vm.expectEmit(true, false, false, true, c.aavegotchiDiamond); + emit ERC721ListingPriceUpdate(listingId, newPrice, nowTs); + + ERC721MarketplaceFacet(c.aavegotchiDiamond).updateERC721ListingPrice(listingId, newPrice); + + vm.stopPrank(); + + ERC721Listing memory listing = MarketplaceGetterFacet(c.aavegotchiDiamond).getERC721Listing(listingId); + assertEq(listing.priceInWei, newPrice); + } + + function _replaceSelector(address diamond, address deployedFacet, bytes4 selector) internal { + address existingFacet = DiamondLoupeFacet(diamond).facetAddress(selector); + require(existingFacet != address(0), "selector missing on diamond"); + + bytes4[] memory selectors = new bytes4[](1); + selectors[0] = selector; + + IDiamondCut.FacetCut[] memory cuts = new IDiamondCut.FacetCut[](1); + cuts[0] = IDiamondCut.FacetCut({ + facetAddress: deployedFacet, + action: IDiamondCut.FacetCutAction.Replace, + functionSelectors: selectors + }); + + IDiamondCut(diamond).diamondCut(cuts, address(0), ""); + } +} +