forked from ProjectOpenSea/seaport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReferenceZoneInteraction.sol
133 lines (125 loc) · 4.92 KB
/
ReferenceZoneInteraction.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import { ZoneInterface } from "contracts/interfaces/ZoneInterface.sol";
import { OrderType } from "contracts/lib/ConsiderationEnums.sol";
import {
AdvancedOrder,
CriteriaResolver
} from "contracts/lib/ConsiderationStructs.sol";
import "contracts/lib/ConsiderationConstants.sol";
import {
ZoneInteractionErrors
} from "contracts/interfaces/ZoneInteractionErrors.sol";
/**
* @title ZoneInteraction
* @author 0age
* @notice ZoneInteraction contains logic related to interacting with zones.
*/
contract ReferenceZoneInteraction is ZoneInteractionErrors {
/**
* @dev Internal view function to determine if an order has a restricted
* order type and, if so, to ensure that either the offerer or the zone
* are the fulfiller or that a staticcall to `isValidOrder` on the zone
* returns a magic value indicating that the order is currently valid.
*
* @param orderHash The hash of the order.
* @param zoneHash The hash to provide upon calling the zone.
* @param orderType The type of the order.
* @param offerer The offerer in question.
* @param zone The zone in question.
*/
function _assertRestrictedBasicOrderValidity(
bytes32 orderHash,
bytes32 zoneHash,
OrderType orderType,
address offerer,
address zone
) internal view {
// Order type 2-3 require zone or offerer be caller or zone to approve.
if (
uint256(orderType) > 1 &&
msg.sender != zone &&
msg.sender != offerer
) {
if (
ZoneInterface(zone).isValidOrder(
orderHash,
msg.sender,
offerer,
zoneHash
) != ZoneInterface.isValidOrder.selector
) {
revert InvalidRestrictedOrder(orderHash);
}
}
}
/**
* @dev Internal view function to determine if a proxy should be utilized
* for a given order and to ensure that the submitter is allowed by the
* order type.
*
* @param advancedOrder The order in question.
* @param criteriaResolvers An array where each element contains a reference
* to a specific offer or consideration, a token
* identifier, and a proof that the supplied token
* identifier is contained in the order's merkle
* root. Note that a criteria of zero indicates
* that any (transferable) token identifier is
* valid and that no proof needs to be supplied.
* @param priorOrderHashes The order hashes of each order supplied prior to
* the current order as part of a "match" variety
* of order fulfillment (e.g. this array will be
* empty for single or "fulfill available").
* @param orderHash The hash of the order.
* @param zoneHash The hash to provide upon calling the zone.
* @param orderType The type of the order.
* @param offerer The offerer in question.
* @param zone The zone in question.
*/
function _assertRestrictedAdvancedOrderValidity(
AdvancedOrder memory advancedOrder,
CriteriaResolver[] memory criteriaResolvers,
bytes32[] memory priorOrderHashes,
bytes32 orderHash,
bytes32 zoneHash,
OrderType orderType,
address offerer,
address zone
) internal view {
// Order type 2-3 require zone or offerer be caller or zone to approve.
if (
uint256(orderType) > 1 &&
msg.sender != zone &&
msg.sender != offerer
) {
// If no extraData or criteria resolvers are supplied...
if (
advancedOrder.extraData.length == 0 &&
criteriaResolvers.length == 0
) {
if (
ZoneInterface(zone).isValidOrder(
orderHash,
msg.sender,
offerer,
zoneHash
) != ZoneInterface.isValidOrder.selector
) {
revert InvalidRestrictedOrder(orderHash);
}
} else {
if (
ZoneInterface(zone).isValidOrderIncludingExtraData(
orderHash,
msg.sender,
advancedOrder,
priorOrderHashes,
criteriaResolvers
) != ZoneInterface.isValidOrder.selector
) {
revert InvalidRestrictedOrder(orderHash);
}
}
}
}
}