Skip to content

Commit 5edc1bf

Browse files
committed
add back deleting reservations / remove duplicate tests / add test case to verifyPoi
1 parent fd7539c commit 5edc1bf

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

src/IPNFT.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser
122122
whenNotPaused
123123
returns (uint256)
124124
{
125-
bool isPoi = reservationId > type(uint128).max;
125+
bool isPoi = _verifyPoi(reservationId);
126126
if (!isPoi && reservations[reservationId] != _msgSender()) {
127127
revert NotOwningReservation(reservationId);
128128
}
@@ -134,6 +134,10 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser
134134
if (!mintAuthorizer.authorizeMint(_msgSender(), to, abi.encode(SignedMintAuthorization(reservationId, _tokenURI, authorization)))) {
135135
revert Unauthorized();
136136
}
137+
if(!isPoi) {
138+
delete reservations[reservationId];
139+
}
140+
137141
symbol[reservationId] = _symbol;
138142
mintAuthorizer.redeem(authorization);
139143

@@ -202,6 +206,10 @@ contract IPNFT is ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, IReser
202206
super._burn(tokenId);
203207
}
204208

209+
function _verifyPoi(uint256 poi) internal pure returns (bool) {
210+
return poi > type(uint128).max;
211+
}
212+
205213
/// @inheritdoc ERC721Upgradeable
206214
function tokenURI(uint256 tokenId) public view virtual override(ERC721URIStorageUpgradeable, ERC721Upgradeable) returns (string memory) {
207215
return super.tokenURI(tokenId);

subgraph/subgraph.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ dataSources:
5959
file: ./src/swapMapping.ts
6060
- kind: ethereum/contract
6161
name: Tokenizer
62-
network: foundry
62+
network: mainnet
6363
source:
6464
abi: Tokenizer
6565
address: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
@@ -84,7 +84,7 @@ dataSources:
8484
file: ./src/tokenizerMapping.ts
8585
- kind: ethereum/contract
8686
name: CrowdSale
87-
network: foundry
87+
network: mainnet
8888
source:
8989
abi: CrowdSale
9090
address: "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F"
@@ -121,7 +121,7 @@ dataSources:
121121
file: ./src/crowdSaleMapping.ts
122122
- kind: ethereum/contract
123123
name: StakedLockingCrowdSale
124-
network: foundry
124+
network: mainnet
125125
source:
126126
abi: StakedLockingCrowdSale
127127
address: "0x0B306BF915C4d645ff596e518fAf3F9669b97016"
@@ -167,7 +167,7 @@ dataSources:
167167
file: ./src/stakedLockingCrowdSaleMapping.ts
168168
- kind: ethereum/contract
169169
name: TermsAcceptedPermissioner
170-
network: foundry
170+
network: mainnet
171171
source:
172172
abi: TermsAcceptedPermissioner
173173
address: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"
@@ -188,7 +188,7 @@ dataSources:
188188
templates:
189189
- name: IPToken
190190
kind: ethereum/contract
191-
network: foundry
191+
network: mainnet
192192
source:
193193
abi: IPToken
194194
mapping:
@@ -208,7 +208,7 @@ templates:
208208
handler: handleCapped
209209
- name: TimelockedToken
210210
kind: ethereum/contract
211-
network: foundry
211+
network: mainnet
212212
source:
213213
abi: TimelockedToken
214214
mapping:
@@ -240,4 +240,4 @@ templates:
240240
abis:
241241
- name: IPNFT
242242
file: ./abis/IPNFT.json
243-
network: foundry
243+
network: mainnet

test/IPNFT.t.sol

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,32 @@ contract IPNFTTest is IPNFTMintHelper {
7272
assertEq(ipnft.reservations(2), bob);
7373
}
7474

75+
function testVerifyPoi() public {
76+
uint256 tokenId = uint256(0x073cb54264ef688e56531a2d09ab47b14086b5c7813e3a23a2bd7b1bb6458a52);
77+
bool isPoi = verifyPoi(tokenId);
78+
assertEq(isPoi, true);
79+
}
80+
7581
function testMintWithPoi() public {
7682
bytes32 poiHash = 0x073cb54264ef688e56531a2d09ab47b14086b5c7813e3a23a2bd7b1bb6458a52;
7783
uint256 tokenId = uint256(poiHash);
78-
(, uint256 maliciousSignerPk) = makeAddrAndKey("malicious");
7984
bytes32 authMessageHash = ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked(alice, alice, tokenId, ipfsUri)));
80-
(uint8 v, bytes32 r, bytes32 s) = vm.sign(maliciousSignerPk, authMessageHash);
81-
bytes memory maliciousAuthorization = abi.encodePacked(r, s, v);
8285

8386
vm.startPrank(deployer);
8487
ipnft.setAuthorizer(new SignedMintAuthorizer(deployer));
8588
vm.stopPrank();
8689

8790
vm.startPrank(alice);
88-
vm.expectRevert(IPNFT.MintingFeeTooLow.selector);
89-
ipnft.mintReservation(alice, tokenId, ipfsUri, DEFAULT_SYMBOL, maliciousAuthorization);
90-
91-
vm.expectRevert(IPNFT.Unauthorized.selector);
92-
ipnft.mintReservation{ value: MINTING_FEE }(alice, tokenId, ipfsUri, DEFAULT_SYMBOL, maliciousAuthorization);
9391

94-
(v, r, s) = vm.sign(deployerPk, authMessageHash);
92+
(uint8 v, bytes32 r, bytes32 s) = vm.sign(deployerPk, authMessageHash);
9593
bytes memory authorization = abi.encodePacked(r, s, v);
9694
vm.expectEmit(true, true, false, true);
9795
emit IPNFTMinted(alice, tokenId, ipfsUri, DEFAULT_SYMBOL);
9896
ipnft.mintReservation{ value: MINTING_FEE }(alice, tokenId, ipfsUri, DEFAULT_SYMBOL, authorization);
9997
assertEq(ipnft.ownerOf(tokenId), alice);
10098
assertEq(ipnft.tokenURI(tokenId), ipfsUri);
10199
assertEq(ipnft.symbol(tokenId), DEFAULT_SYMBOL);
100+
102101
vm.stopPrank();
103102
}
104103

test/IPNFTMintHelper.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ abstract contract IPNFTMintHelper is Test {
3636
vm.stopPrank();
3737
return reservationId;
3838
}
39+
40+
function verifyPoi(uint256 tokenId) public pure returns (bool) {
41+
return tokenId > type(uint128).max;
42+
}
3943
}

0 commit comments

Comments
 (0)