Skip to content

Commit a3ad805

Browse files
committed
Revert when setting zero address zone or setting to already allowed value
1 parent 8e7b8ae commit a3ad805

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

contracts/trading/seaport16/ImmutableSeaport.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ contract ImmutableSeaport is Consideration, Ownable, ImmutableSeaportEvents {
2626
mapping(address => bool) public allowedZones;
2727

2828
error OrderNotRestricted(uint8 orderType);
29+
error AllowedZoneAlreadySet(address zone);
2930
error InvalidZone(address zone);
3031

3132
/**
@@ -48,6 +49,12 @@ contract ImmutableSeaport is Consideration, Ownable, ImmutableSeaportEvents {
4849
* @dev Set the validity of a zone for use during fulfillment.
4950
*/
5051
function setAllowedZone(address zone, bool allowed) external onlyOwner {
52+
require(zone != address(0), "ImmutableSeaport: zone is the zero address");
53+
54+
if (allowedZones[zone] == allowed) {
55+
revert AllowedZoneAlreadySet(zone);
56+
}
57+
5158
allowedZones[zone] = allowed;
5259
emit AllowedZoneSet(zone, allowed);
5360
}

test/trading/seaport16/ImmutableSeaportConfig.t.sol

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
pragma solidity ^0.8.13;
33

44
import {ImmutableSeaportBaseTest} from "./ImmutableSeaportBase.t.sol";
5+
import {ImmutableSeaport} from "../../../contracts/trading/seaport16/ImmutableSeaport.sol";
56

67
contract ImmutableSeaportConfigTest is ImmutableSeaportBaseTest {
7-
88
function testEmitsAllowedZoneSetEvent() public {
99
address zone = makeAddr("zone");
1010
bool allowed = true;
@@ -14,4 +14,21 @@ contract ImmutableSeaportConfigTest is ImmutableSeaportBaseTest {
1414
emit AllowedZoneSet(zone, allowed);
1515
immutableSeaport.setAllowedZone(zone, allowed);
1616
}
17+
18+
function testRejectZeroAddressZone() public {
19+
vm.prank(owner);
20+
vm.expectRevert("ImmutableSeaport: zone is the zero address");
21+
immutableSeaport.setAllowedZone(address(0), true);
22+
}
23+
24+
function testRejectAllowedZoneAlreadySet() public {
25+
address zone = makeAddr("zone");
26+
27+
vm.prank(owner);
28+
immutableSeaport.setAllowedZone(zone, true);
29+
30+
vm.prank(owner);
31+
vm.expectRevert(abi.encodeWithSelector(ImmutableSeaport.AllowedZoneAlreadySet.selector, zone));
32+
immutableSeaport.setAllowedZone(zone, true);
33+
}
1734
}

0 commit comments

Comments
 (0)