Skip to content

Commit

Permalink
Shift to _isAllowed() function
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJem committed Jan 18, 2024
1 parent 7bc9988 commit be3c092
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/AuctionHouse.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ contract AuctionHouse is Derivatizer, Auctioneer, Router {

error AmountLessThanMinimum();

error NotAuthorized();

error UnsupportedToken(address token_);

error InvalidHook();
Expand Down Expand Up @@ -323,7 +321,7 @@ contract AuctionHouse is Derivatizer, Auctioneer, Router {

// Check if the purchaser is on the allowlist
if (!_isAllowed(routing.allowlist, params_.lotId, msg.sender, params_.allowlistProof)) {
revert NotAuthorized();
revert InvalidBidder(msg.sender);
}

uint256 totalFees = _allocateFees(params_.referrer, routing.quoteToken, params_.amount);
Expand Down Expand Up @@ -376,7 +374,7 @@ contract AuctionHouse is Derivatizer, Auctioneer, Router {

// Determine if the bidder is authorized to bid
if (!_isAllowed(routing.allowlist, params_.lotId, msg.sender, params_.allowlistProof)) {
revert NotAuthorized();
revert InvalidBidder(msg.sender);
}

// Transfer the quote token from the bidder
Expand Down Expand Up @@ -443,12 +441,15 @@ contract AuctionHouse is Derivatizer, Auctioneer, Router {
uint256 totalAmountOut;
for (uint256 i; i < len; i++) {
// If there is an allowlist, validate that the winners are on the allowlist
if (address(routing.allowlist) != address(0)) {
if (
!routing.allowlist.isAllowed(
settlement_.bids[i].bidder, settlement_.allowlistProofs[i]
)
) revert InvalidBidder(settlement_.bids[i].bidder);
if (
!_isAllowed(
routing.allowlist,
id_,
settlement_.bids[i].bidder,
settlement_.allowlistProofs[i]
)
) {
revert InvalidBidder(settlement_.bids[i].bidder);
}

// Check that the amounts out are at least the minimum specified by the bidder
Expand Down
2 changes: 1 addition & 1 deletion test/AuctionHouse/purchase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ contract PurchaseTest is Test, Permit2User {

function test_givenCallerNotOnAllowlist() external givenAuctionHasAllowlist {
// Expect revert
bytes memory err = abi.encodeWithSelector(AuctionHouse.NotAuthorized.selector);
bytes memory err = abi.encodeWithSelector(AuctionHouse.InvalidBidder.selector, alice);
vm.expectRevert(err);

// Purchase
Expand Down

0 comments on commit be3c092

Please sign in to comment.