diff --git a/src/IPNFT.sol b/src/IPNFT.sol index 44845d27..95f37cef 100644 --- a/src/IPNFT.sol +++ b/src/IPNFT.sol @@ -122,7 +122,7 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser whenNotPaused returns (uint256) { - bool isPoi = reservationId > type(uint128).max; + bool isPoi = _verifyPoi(reservationId); if (!isPoi && reservations[reservationId] != _msgSender()) { revert NotOwningReservation(reservationId); } @@ -134,6 +134,10 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser if (!mintAuthorizer.authorizeMint(_msgSender(), to, abi.encode(SignedMintAuthorization(reservationId, _tokenURI, authorization)))) { revert Unauthorized(); } + if(!isPoi) { + delete reservations[reservationId]; + } + symbol[reservationId] = _symbol; mintAuthorizer.redeem(authorization); @@ -202,6 +206,10 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser super._burn(tokenId); } + function _verifyPoi(uint256 poi) internal pure returns (bool) { + return poi > type(uint128).max; + } + /// @inheritdoc ERC721Upgradeable function tokenURI(uint256 tokenId) public view virtual override(ERC721URIStorageUpgradeable, ERC721Upgradeable) returns (string memory) { return super.tokenURI(tokenId); diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 14713803..b7ada687 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -59,7 +59,7 @@ dataSources: file: ./src/swapMapping.ts - kind: ethereum/contract name: Tokenizer - network: foundry + network: mainnet source: abi: Tokenizer address: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e" @@ -84,7 +84,7 @@ dataSources: file: ./src/tokenizerMapping.ts - kind: ethereum/contract name: CrowdSale - network: foundry + network: mainnet source: abi: CrowdSale address: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F" @@ -121,7 +121,7 @@ dataSources: file: ./src/crowdSaleMapping.ts - kind: ethereum/contract name: StakedLockingCrowdSale - network: foundry + network: mainnet source: abi: StakedLockingCrowdSale address: "0x0B306BF915C4d645ff596e518fAf3F9669b97016" @@ -167,7 +167,7 @@ dataSources: file: ./src/stakedLockingCrowdSaleMapping.ts - kind: ethereum/contract name: TermsAcceptedPermissioner - network: foundry + network: mainnet source: abi: TermsAcceptedPermissioner address: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318" @@ -188,7 +188,7 @@ dataSources: templates: - name: IPToken kind: ethereum/contract - network: foundry + network: mainnet source: abi: IPToken mapping: @@ -208,7 +208,7 @@ templates: handler: handleCapped - name: TimelockedToken kind: ethereum/contract - network: foundry + network: mainnet source: abi: TimelockedToken mapping: @@ -240,4 +240,4 @@ templates: abis: - name: IPNFT file: ./abis/IPNFT.json - network: foundry + network: mainnet diff --git a/test/IPNFT.t.sol b/test/IPNFT.t.sol index 407b9f9f..908841fb 100644 --- a/test/IPNFT.t.sol +++ b/test/IPNFT.t.sol @@ -72,26 +72,24 @@ contract IPNFTTest is IPNFTMintHelper { assertEq(ipnft.reservations(2), bob); } + function testVerifyPoi() public { + uint256 tokenId = uint256(0x073cb54264ef688e56531a2d09ab47b14086b5c7813e3a23a2bd7b1bb6458a52); + bool isPoi = verifyPoi(tokenId); + assertEq(isPoi, true); + } + function testMintWithPoi() public { bytes32 poiHash = 0x073cb54264ef688e56531a2d09ab47b14086b5c7813e3a23a2bd7b1bb6458a52; uint256 tokenId = uint256(poiHash); - (, uint256 maliciousSignerPk) = makeAddrAndKey("malicious"); bytes32 authMessageHash = ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked(alice, alice, tokenId, ipfsUri))); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(maliciousSignerPk, authMessageHash); - bytes memory maliciousAuthorization = abi.encodePacked(r, s, v); vm.startPrank(deployer); ipnft.setAuthorizer(new SignedMintAuthorizer(deployer)); vm.stopPrank(); vm.startPrank(alice); - vm.expectRevert(IPNFT.MintingFeeTooLow.selector); - ipnft.mintReservation(alice, tokenId, ipfsUri, DEFAULT_SYMBOL, maliciousAuthorization); - - vm.expectRevert(IPNFT.Unauthorized.selector); - ipnft.mintReservation{ value: MINTING_FEE }(alice, tokenId, ipfsUri, DEFAULT_SYMBOL, maliciousAuthorization); - (v, r, s) = vm.sign(deployerPk, authMessageHash); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(deployerPk, authMessageHash); bytes memory authorization = abi.encodePacked(r, s, v); vm.expectEmit(true, true, false, true); emit IPNFTMinted(alice, tokenId, ipfsUri, DEFAULT_SYMBOL); @@ -99,6 +97,7 @@ contract IPNFTTest is IPNFTMintHelper { assertEq(ipnft.ownerOf(tokenId), alice); assertEq(ipnft.tokenURI(tokenId), ipfsUri); assertEq(ipnft.symbol(tokenId), DEFAULT_SYMBOL); + vm.stopPrank(); } diff --git a/test/IPNFTMintHelper.sol b/test/IPNFTMintHelper.sol index f9732ebe..cf05bc33 100644 --- a/test/IPNFTMintHelper.sol +++ b/test/IPNFTMintHelper.sol @@ -36,4 +36,8 @@ abstract contract IPNFTMintHelper is Test { vm.stopPrank(); return reservationId; } + + function verifyPoi(uint256 tokenId) public pure returns (bool) { + return tokenId > type(uint128).max; + } }