Skip to content

Commit

Permalink
Merge pull request #3 from shoyunft/feat/seaport-1.2
Browse files Browse the repository at this point in the history
Feat/seaport 1.2
  • Loading branch information
0xMasayoshi committed Feb 13, 2023
2 parents d758fd6 + da5a622 commit c5caa7a
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 2,074 deletions.
10 changes: 9 additions & 1 deletion constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ export const CONDUIT_CONTROLLER_ADDRESS: { [chainId: number]: string } = {
[ChainId.GÖRLI]: "0x00000000F9490004C11Cef243f5400493c00Ad63",
};

export const SEAPORT_ADDRESS: { [chainId: number]: string } = {
export const SEAPORT_ADDRESS_1_1: { [chainId: number]: string } = {
[ChainId.ETHEREUM]: "0x00000000006c3852cbef3e08e8df289169ede581",
[ChainId.RINKEBY]: "0x00000000006c3852cbef3e08e8df289169ede581",
[ChainId.GÖRLI]: "0x00000000006c3852cbEf3e08E8dF289169EdE581",
};

export const SEAPORT_ADDRESS_1_2: { [chainId: number]: string } = {
[ChainId.ETHEREUM]: "0x00000000000006c7676171937C444f6BDe3D6282",
[ChainId.RINKEBY]: "0x00000000000006c7676171937C444f6BDe3D6282",
[ChainId.GÖRLI]: "0x00000000000006c7676171937C444f6BDe3D6282",
};

export const SEAPORT_ADDRESS = SEAPORT_ADDRESS_1_1;
2 changes: 1 addition & 1 deletion contracts/seaport/Conduit.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;
pragma solidity ^0.8.13;

import "seaport/contracts/conduit/Conduit.sol";
2 changes: 1 addition & 1 deletion contracts/seaport/ConduitController.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;
pragma solidity ^0.8.13;

import "seaport/contracts/conduit/ConduitController.sol";
2 changes: 1 addition & 1 deletion contracts/seaport/ImmutableCreate2FactoryInterface.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;
pragma solidity ^0.8.13;

import "seaport/contracts/interfaces/ImmutableCreate2FactoryInterface.sol";
2 changes: 1 addition & 1 deletion contracts/seaport/Seaport.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;
pragma solidity ^0.8.17;

import "seaport/contracts/Seaport.sol";
273 changes: 2 additions & 271 deletions contracts/seaport/Zones/PausableZone.sol
Original file line number Diff line number Diff line change
@@ -1,273 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
pragma solidity ^0.8.13;

import { ZoneInterface } from "seaport/contracts/interfaces/ZoneInterface.sol";
import { ZoneInteractionErrors } from "seaport/contracts/interfaces/ZoneInteractionErrors.sol";

// prettier-ignore
import {
PausableZoneEventsAndErrors
} from "./PausableZoneEventsAndErrors.sol";

import { SeaportInterface } from "seaport/contracts/interfaces/SeaportInterface.sol";

// prettier-ignore
import {
AdvancedOrder,
CriteriaResolver,
Order,
OrderComponents,
Fulfillment,
Execution
} from "seaport/contracts/lib/ConsiderationStructs.sol";

import { PausableZoneInterface } from "./PausableZoneInterface.sol";

/**
* @title PausableZone
* @author cupOJoseph, BCLeFevre, ryanio
* @notice PausableZone is a simple zone implementation that approves every
* order. It can be self-destructed by its controller to pause
* restricted orders that have it set as their zone.
*/
contract PausableZone is
PausableZoneEventsAndErrors,
ZoneInterface,
PausableZoneInterface
{
// Set an immutable controller that can pause the zone & update an operator.
address internal immutable _controller;

// Set an operator that can instruct the zone to cancel or execute orders.
address public operator;

/**
* @dev Ensure that the caller is either the operator or controller.
*/
modifier isOperator() {
// Ensure that the caller is either the operator or the controller.
if (msg.sender != operator && msg.sender != _controller) {
revert InvalidOperator();
}

// Continue with function execution.
_;
}

/**
* @dev Ensure that the caller is the controller.
*/
modifier isController() {
// Ensure that the caller is the controller.
if (msg.sender != _controller) {
revert InvalidController();
}

// Continue with function execution.
_;
}

/**
* @notice Set the deployer as the controller of the zone.
*/
constructor() {
// Set the controller to the deployer.
_controller = msg.sender;

// Emit an event signifying that the zone is unpaused.
emit Unpaused();
}

/**
* @notice Cancel an arbitrary number of orders that have agreed to use the
* contract as their zone.
*
* @param seaport The Seaport address.
* @param orders The orders to cancel.
*
* @return cancelled A boolean indicating whether the supplied orders have
* been successfully cancelled.
*/
function cancelOrders(
SeaportInterface seaport,
OrderComponents[] calldata orders
) external override isOperator returns (bool cancelled) {
// Call cancel on Seaport and return its boolean value.
cancelled = seaport.cancel(orders);
}

/**
* @notice Pause this contract, safely stopping orders from using
* the contract as a zone. Restricted orders with this address as a
* zone will not be fulfillable unless the zone is redeployed to the
* same address.
*/
function pause(address payee) external override isController {
// Emit an event signifying that the zone is paused.
emit Paused();

// Destroy the zone, sending any ether to the transaction submitter.
selfdestruct(payable(payee));
}

/**
* @notice Assign the given address with the ability to operate the zone.
*
* @param operatorToAssign The address to assign as the operator.
*/
function assignOperator(address operatorToAssign)
external
override
isController
{
// Ensure the operator being assigned is not the null address.
if (operatorToAssign == address(0)) {
revert PauserCanNotBeSetAsZero();
}

// Set the given address as the new operator.
operator = operatorToAssign;

// Emit an event indicating the operator has been updated.
emit OperatorUpdated(operator);
}

/**
* @notice Execute an arbitrary number of matched orders, each with
* an arbitrary number of items for offer and consideration
* along with a set of fulfillments allocating offer components
* to consideration components.
*
* @param seaport The Seaport address.
* @param orders The orders to match.
* @param fulfillments An array of elements allocating offer components
* to consideration components.
*
* @return executions An array of elements indicating the sequence of
* transfers performed as part of matching the given
* orders.
*/
function executeMatchOrders(
SeaportInterface seaport,
Order[] calldata orders,
Fulfillment[] calldata fulfillments
)
external
payable
override
isOperator
returns (Execution[] memory executions)
{
// Call matchOrders on Seaport and return the sequence of transfers
// performed as part of matching the given orders.
executions = seaport.matchOrders{ value: msg.value }(
orders,
fulfillments
);
}

/**
* @notice Execute an arbitrary number of matched advanced orders,
* each with an arbitrary number of items for offer and
* consideration along with a set of fulfillments allocating
* offer components to consideration components.
*
* @param seaport The Seaport address.
* @param orders The orders to match.
* @param criteriaResolvers An array where each element contains a reference
* to a specific order as well as that order's
* offer or consideration, a token identifier, and
* a proof that the supplied token identifier is
* contained in the order's merkle root.
* @param fulfillments An array of elements allocating offer components
* to consideration components.
*
* @return executions An array of elements indicating the sequence of
* transfers performed as part of matching the given
* orders.
*/
function executeMatchAdvancedOrders(
SeaportInterface seaport,
AdvancedOrder[] calldata orders,
CriteriaResolver[] calldata criteriaResolvers,
Fulfillment[] calldata fulfillments
)
external
payable
override
isOperator
returns (Execution[] memory executions)
{
// Call matchAdvancedOrders on Seaport and return the sequence of
// transfers performed as part of matching the given orders.
executions = seaport.matchAdvancedOrders{ value: msg.value }(
orders,
criteriaResolvers,
fulfillments
);
}

/**
* @notice Check if a given order is currently valid.
*
* @dev This function is called by Seaport whenever extraData is not
* provided by the caller.
*
* @param orderHash The hash of the order.
* @param caller The caller in question.
* @param offerer The offerer in question.
* @param zoneHash The hash to provide upon calling the zone.
*
* @return validOrderMagicValue A magic value indicating if the order is
* currently valid.
*/
function isValidOrder(
bytes32 orderHash,
address caller,
address offerer,
bytes32 zoneHash
) external pure override returns (bytes4 validOrderMagicValue) {
orderHash;
caller;
offerer;
zoneHash;

// Return the selector of isValidOrder as the magic value.
validOrderMagicValue = ZoneInterface.isValidOrder.selector;
}

/**
* @notice Check if a given order including extraData is currently valid.
*
* @dev This function is called by Seaport whenever any extraData is
* provided by the caller.
*
* @param orderHash The hash of the order.
* @param caller The caller in question.
* @param order The order in question.
* @param priorOrderHashes The order hashes of each order supplied prior to
* the current order as part of a "match" variety
* of order fulfillment.
* @param criteriaResolvers The criteria resolvers corresponding to
* the order.
*
* @return validOrderMagicValue A magic value indicating if the order is
* currently valid.
*/
function isValidOrderIncludingExtraData(
bytes32 orderHash,
address caller,
AdvancedOrder calldata order,
bytes32[] calldata priorOrderHashes,
CriteriaResolver[] calldata criteriaResolvers
) external pure override returns (bytes4 validOrderMagicValue) {
orderHash;
caller;
order;
priorOrderHashes;
criteriaResolvers;

// Return the selector of isValidOrder as the magic value.
validOrderMagicValue = ZoneInterface.isValidOrder.selector;
}
}
import "seaport/contracts/zones/PausableZone.sol";
Loading

0 comments on commit c5caa7a

Please sign in to comment.