Skip to content

Commit

Permalink
Merge pull request #15 from ProjectOpenSea/1.6
Browse files Browse the repository at this point in the history
Seaport 1.6 Updates
  • Loading branch information
0age authored Mar 5, 2024
2 parents d4e8c74 + 088f012 commit ec87ef4
Show file tree
Hide file tree
Showing 30 changed files with 4,695 additions and 1,646 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env

.DS_Store
9 changes: 6 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[profile.default]
solc = "0.8.24"
evm_version = "cancun"
via_ir = true
bytecode_hash = "none"
optimizer_runs = 4_294_967_295
src = "src"
out = "out"
libs = ["lib"]
remappings = ['seaport-types/=lib/seaport-types/']

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
remappings = ["seaport-types/=lib/seaport-types/"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seaport-core",
"version": "1.5.0",
"version": "1.6.0",
"description": "Core smart contracts for the Seaport protocol",
"main": "src/",
"repository": "https://github.com/ProjectOpenSea/seaport-core.git",
Expand Down
8 changes: 4 additions & 4 deletions src/Seaport.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
pragma solidity ^0.8.24;

import { Consideration } from "./lib/Consideration.sol";

/**
* @title Seaport
* @custom:version 1.5
* @custom:version 1.6
* @author 0age (0age.eth)
* @custom:coauthor d1ll0n (d1ll0n.eth)
* @custom:coauthor transmissions11 (t11s.eth)
* @custom:coauthor James Wenzel (emo.eth)
* @custom:coauthor Daniel Viau (snotrocket.eth)
* @custom:contributor Kartik (slokh.eth)
* @custom:contributor LeFevre (lefevre.eth)
* @custom:contributor Joseph Schiarizzi (CupOJoseph.eth)
* @custom:contributor Aspyn Palatnick (stuckinaboot.eth)
* @custom:contributor Stephan Min (stephanm.eth)
* @custom:contributor Ryan Ghods (ralxz.eth)
* @custom:contributor Daniel Viau (snotrocket.eth)
* @custom:contributor hack3r-0m (hack3r-0m.eth)
* @custom:contributor Diego Estevez (antidiego.eth)
* @custom:contributor Chomtana (chomtana.eth)
Expand Down Expand Up @@ -91,7 +91,7 @@ contract Seaport is Consideration {
* that may optionally be used to transfer approved
* ERC20/721/1155 tokens.
*/
constructor(address conduitController) Consideration(conduitController) {}
constructor(address conduitController) Consideration(conduitController) { }

/**
* @dev Internal pure function to retrieve and return the name of this
Expand Down
38 changes: 24 additions & 14 deletions src/conduit/Conduit.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
pragma solidity ^0.8.24;

import {ConduitInterface} from "seaport-types/src/interfaces/ConduitInterface.sol";
import {
ConduitInterface
} from "seaport-types/src/interfaces/ConduitInterface.sol";

import {ConduitItemType} from "seaport-types/src/conduit/lib/ConduitEnums.sol";
import {
ConduitItemType
} from "seaport-types/src/conduit/lib/ConduitEnums.sol";

import {TokenTransferrer} from "../lib/TokenTransferrer.sol";
import { TokenTransferrer } from "../lib/TokenTransferrer.sol";

import {ConduitBatch1155Transfer, ConduitTransfer} from "seaport-types/src/conduit/lib/ConduitStructs.sol";
import {
ConduitBatch1155Transfer,
ConduitTransfer
} from "seaport-types/src/conduit/lib/ConduitStructs.sol";

import {
ChannelClosed_channel_ptr,
Expand Down Expand Up @@ -53,7 +60,9 @@ contract Conduit is ConduitInterface, TokenTransferrer {

// Derive the position in storage of _channels[msg.sender]
// and check if the stored value is zero.
if iszero(sload(keccak256(ChannelKey_channel_ptr, ChannelKey_length))) {
if iszero(
sload(keccak256(ChannelKey_channel_ptr, ChannelKey_length))
) {
// The caller is not an open channel; revert with
// ChannelClosed(caller). First, set error signature in memory.
mstore(ChannelClosed_error_ptr, ChannelClosed_error_signature)
Expand Down Expand Up @@ -134,12 +143,9 @@ contract Conduit is ConduitInterface, TokenTransferrer {
* @return magicValue A magic value indicating that the item transfers were
* performed successfully.
*/
function executeBatch1155(ConduitBatch1155Transfer[] calldata batchTransfers)
external
override
onlyOpenChannel
returns (bytes4 magicValue)
{
function executeBatch1155(
ConduitBatch1155Transfer[] calldata batchTransfers
) external override onlyOpenChannel returns (bytes4 magicValue) {
// Perform 1155 batch transfers. Note that memory should be considered
// entirely corrupted from this point forward.
_performERC1155BatchTransfers(batchTransfers);
Expand Down Expand Up @@ -237,10 +243,14 @@ contract Conduit is ConduitInterface, TokenTransferrer {
}

// Transfer ERC721 token.
_performERC721Transfer(item.token, item.from, item.to, item.identifier);
_performERC721Transfer(
item.token, item.from, item.to, item.identifier
);
} else if (item.itemType == ConduitItemType.ERC1155) {
// Transfer ERC1155 token.
_performERC1155Transfer(item.token, item.from, item.to, item.identifier, item.amount);
_performERC1155Transfer(
item.token, item.from, item.to, item.identifier, item.amount
);
} else {
// Throw with an error.
revert InvalidItemType();
Expand Down
118 changes: 96 additions & 22 deletions src/conduit/ConduitController.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
pragma solidity ^0.8.24;

import {ConduitControllerInterface} from "seaport-types/src/interfaces/ConduitControllerInterface.sol";
import { ConduitControllerInterface } from
"seaport-types/src/interfaces/ConduitControllerInterface.sol";

import {ConduitInterface} from "seaport-types/src/interfaces/ConduitInterface.sol";
import { ConduitInterface } from
"seaport-types/src/interfaces/ConduitInterface.sol";

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

/**
* @title ConduitController
Expand Down Expand Up @@ -51,7 +53,11 @@ contract ConduitController is ConduitControllerInterface {
*
* @return conduit The address of the newly deployed conduit.
*/
function createConduit(bytes32 conduitKey, address initialOwner) external override returns (address conduit) {
function createConduit(bytes32 conduitKey, address initialOwner)
external
override
returns (address conduit)
{
// Ensure that an initial owner has been supplied.
if (initialOwner == address(0)) {
revert InvalidInitialOwner();
Expand All @@ -67,7 +73,14 @@ contract ConduitController is ConduitControllerInterface {
conduit = address(
uint160(
uint256(
keccak256(abi.encodePacked(bytes1(0xff), address(this), conduitKey, _CONDUIT_CREATION_CODE_HASH))
keccak256(
abi.encodePacked(
bytes1(0xff),
address(this),
conduitKey,
_CONDUIT_CREATION_CODE_HASH
)
)
)
)
);
Expand Down Expand Up @@ -109,7 +122,10 @@ contract ConduitController is ConduitControllerInterface {
* @param channel The channel to open or close on the conduit.
* @param isOpen A boolean indicating whether to open or close the channel.
*/
function updateChannel(address conduit, address channel, bool isOpen) external override {
function updateChannel(address conduit, address channel, bool isOpen)
external
override
{
// Ensure the caller is the current owner of the conduit in question.
_assertCallerIsConduitOwner(conduit);

Expand All @@ -120,7 +136,8 @@ contract ConduitController is ConduitControllerInterface {
ConduitProperties storage conduitProperties = _conduits[conduit];

// Retrieve the index, if one currently exists, for the updated channel.
uint256 channelIndexPlusOne = (conduitProperties.channelIndexesPlusOne[channel]);
uint256 channelIndexPlusOne =
(conduitProperties.channelIndexesPlusOne[channel]);

// Determine whether the updated channel is already tracked as open.
bool channelPreviouslyOpen = channelIndexPlusOne != 0;
Expand All @@ -131,7 +148,8 @@ contract ConduitController is ConduitControllerInterface {
conduitProperties.channels.push(channel);

// Add new open channel length to associated mapping as index + 1.
conduitProperties.channelIndexesPlusOne[channel] = (conduitProperties.channels.length);
conduitProperties.channelIndexesPlusOne[channel] =
(conduitProperties.channels.length);
} else if (!isOpen && channelPreviouslyOpen) {
// Set a previously open channel as closed via "swap & pop" method.
// Decrement located index to get the index of the closed channel.
Expand All @@ -149,13 +167,15 @@ contract ConduitController is ConduitControllerInterface {
// If closed channel is not last channel in the channels array...
if (finalChannelIndex != removedChannelIndex) {
// Retrieve the final channel and place the value on the stack.
address finalChannel = (conduitProperties.channels[finalChannelIndex]);
address finalChannel =
(conduitProperties.channels[finalChannelIndex]);

// Overwrite the removed channel using the final channel value.
conduitProperties.channels[removedChannelIndex] = finalChannel;

// Update final index in associated mapping to removed index.
conduitProperties.channelIndexesPlusOne[finalChannel] = (channelIndexPlusOne);
conduitProperties.channelIndexesPlusOne[finalChannel] =
(channelIndexPlusOne);
}

// Remove the last channel from the channels array for the conduit.
Expand All @@ -175,7 +195,10 @@ contract ConduitController is ConduitControllerInterface {
* @param conduit The conduit for which to initiate ownership transfer.
* @param newPotentialOwner The new potential owner of the conduit.
*/
function transferOwnership(address conduit, address newPotentialOwner) external override {
function transferOwnership(address conduit, address newPotentialOwner)
external
override
{
// Ensure the caller is the current owner of the conduit in question.
_assertCallerIsConduitOwner(conduit);

Expand Down Expand Up @@ -242,7 +265,11 @@ contract ConduitController is ConduitControllerInterface {
_conduits[conduit].potentialOwner = address(0);

// Emit an event indicating conduit ownership has been transferred.
emit OwnershipTransferred(conduit, _conduits[conduit].owner, msg.sender);
emit OwnershipTransferred(
conduit,
_conduits[conduit].owner,
msg.sender
);

// Set the caller as the owner of the conduit.
_conduits[conduit].owner = msg.sender;
Expand All @@ -255,7 +282,12 @@ contract ConduitController is ConduitControllerInterface {
*
* @return owner The owner of the supplied conduit.
*/
function ownerOf(address conduit) external view override returns (address owner) {
function ownerOf(address conduit)
external
view
override
returns (address owner)
{
// Ensure that the conduit in question exists.
_assertConduitExists(conduit);

Expand All @@ -272,7 +304,12 @@ contract ConduitController is ConduitControllerInterface {
*
* @return conduitKey The conduit key used to deploy the supplied conduit.
*/
function getKey(address conduit) external view override returns (bytes32 conduitKey) {
function getKey(address conduit)
external
view
override
returns (bytes32 conduitKey)
{
// Attempt to retrieve a conduit key for the conduit in question.
conduitKey = _conduits[conduit].key;

Expand All @@ -293,12 +330,24 @@ contract ConduitController is ConduitControllerInterface {
* @return exists A boolean indicating whether the derived conduit has been
* deployed or not.
*/
function getConduit(bytes32 conduitKey) external view override returns (address conduit, bool exists) {
function getConduit(bytes32 conduitKey)
external
view
override
returns (address conduit, bool exists)
{
// Derive address from deployer, conduit key and creation code hash.
conduit = address(
uint160(
uint256(
keccak256(abi.encodePacked(bytes1(0xff), address(this), conduitKey, _CONDUIT_CREATION_CODE_HASH))
keccak256(
abi.encodePacked(
bytes1(0xff),
address(this),
conduitKey,
_CONDUIT_CREATION_CODE_HASH
)
)
)
)
);
Expand All @@ -317,7 +366,12 @@ contract ConduitController is ConduitControllerInterface {
*
* @return potentialOwner The potential owner, if any, for the conduit.
*/
function getPotentialOwner(address conduit) external view override returns (address potentialOwner) {
function getPotentialOwner(address conduit)
external
view
override
returns (address potentialOwner)
{
// Ensure that the conduit in question exists.
_assertConduitExists(conduit);

Expand All @@ -334,7 +388,12 @@ contract ConduitController is ConduitControllerInterface {
*
* @return isOpen The status of the channel on the given conduit.
*/
function getChannelStatus(address conduit, address channel) external view override returns (bool isOpen) {
function getChannelStatus(address conduit, address channel)
external
view
override
returns (bool isOpen)
{
// Ensure that the conduit in question exists.
_assertConduitExists(conduit);

Expand All @@ -349,7 +408,12 @@ contract ConduitController is ConduitControllerInterface {
*
* @return totalChannels The total number of open channels for the conduit.
*/
function getTotalChannels(address conduit) external view override returns (uint256 totalChannels) {
function getTotalChannels(address conduit)
external
view
override
returns (uint256 totalChannels)
{
// Ensure that the conduit in question exists.
_assertConduitExists(conduit);

Expand All @@ -367,7 +431,12 @@ contract ConduitController is ConduitControllerInterface {
*
* @return channel The open channel, if any, at the specified channel index.
*/
function getChannel(address conduit, uint256 channelIndex) external view override returns (address channel) {
function getChannel(address conduit, uint256 channelIndex)
external
view
override
returns (address channel)
{
// Ensure that the conduit in question exists.
_assertConduitExists(conduit);

Expand All @@ -392,7 +461,12 @@ contract ConduitController is ConduitControllerInterface {
*
* @return channels An array of open channels on the given conduit.
*/
function getChannels(address conduit) external view override returns (address[] memory channels) {
function getChannels(address conduit)
external
view
override
returns (address[] memory channels)
{
// Ensure that the conduit in question exists.
_assertConduitExists(conduit);

Expand Down
Loading

0 comments on commit ec87ef4

Please sign in to comment.