Skip to content

Commit

Permalink
Check for NotMaker on claimNFTs
Browse files Browse the repository at this point in the history
  • Loading branch information
doublesharp committed Aug 5, 2024
1 parent 5235367 commit f67d77c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/SamWitchOrderBook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ contract SamWitchOrderBook is ISamWitchOrderBook, ERC1155Holder, UUPSUpgradeable
if (amount == 0) {
revert NothingToClaim();
}

if (tokenClaimable[orderId].maker != _msgSender()) {
revert NotMaker();
}

nftAmountsFromUs[i] = amount;
amountClaimableForTokenId[tokenId][orderId] = 0;
}
Expand Down
7 changes: 7 additions & 0 deletions test/SamWitchOrderBook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2733,6 +2733,13 @@ describe("SamWitchOrderBook", function () {
expect((await orderBook.nftsClaimable([orderId], [tokenId]))[0]).to.eq(10);
expect((await orderBook.nftsClaimable([orderId + 1], [tokenId]))[0]).to.eq(0);

// try to claim as a different user (not maker)
await expect(orderBook.connect(alice).claimNFTs([orderId], [tokenId])).to.be.revertedWithCustomError(
orderBook,
"NotMaker",
);

// claim as the maker
await expect(orderBook.claimNFTs([orderId], [tokenId]))
.to.emit(orderBook, "ClaimedNFTs")
.withArgs(owner.address, [orderId], [tokenId], [10]);
Expand Down

0 comments on commit f67d77c

Please sign in to comment.