Skip to content

Commit

Permalink
Add Seaport v1.5 (#226)
Browse files Browse the repository at this point in the history
* add seaport v1.5 (default init still v1.4)

* simpilfy test setup since we dont need a separate seaport v1.5 instance
  • Loading branch information
ryanio authored Apr 27, 2023
1 parent 57b6b11 commit ba842e9
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 2,655 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensea/seaport-js",
"version": "1.1.0",
"version": "1.2.0",
"description": "[Seaport](https://github.com/ProjectOpenSea/seaport) is a new marketplace protocol for safely and efficiently buying and selling NFTs. This is a JavaScript library intended to make interfacing with the contract reasonable and easy.",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down Expand Up @@ -91,8 +91,8 @@
"prettier": "^2.5.1",
"prettier-package-json": "^2.6.3",
"prettier-plugin-solidity": "^1.0.0-beta.13",
"seaport": "ProjectOpenSea/seaport#76e508657888e3ec84039e1da269c822826991ef",
"seaport_v1_4": "ProjectOpenSea/seaport#1.4",
"seaport_v1_5": "ProjectOpenSea/seaport#1.5",
"sinon": "^13.0.1",
"sinon-chai": "^3.7.0",
"solhint": "^3.3.7",
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/basic-fulfill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describeWithFixture(
// Should revert because signature is empty
await expect(
action.transactionMethods.transact()
).to.be.revertedWith("InvalidSigner");
).to.be.revertedWith("InvalidSignature");

await seaport.validate([order], offerer.address).transact();

Expand Down Expand Up @@ -296,7 +296,7 @@ describeWithFixture(

await expect(
fulfillAction.transactionMethods.transact()
).to.be.revertedWith("InvalidSigner");
).to.be.revertedWith("InvalidSignature");

await seaport.validate([order], offerer.address).transact();

Expand Down Expand Up @@ -505,7 +505,7 @@ describeWithFixture(
// Should revert because signature is empty
await expect(
fulfillAction.transactionMethods.transact()
).to.be.revertedWith("InvalidSigner");
).to.be.revertedWith("InvalidSignature");

await seaport.validate([order], offerer.address).transact();

Expand Down Expand Up @@ -670,7 +670,7 @@ describeWithFixture(

await expect(
fulfillAction.transactionMethods.transact()
).to.be.revertedWith("InvalidSigner");
).to.be.revertedWith("InvalidSignature");

await seaport.validate([order], offerer.address).transact();

Expand Down
9 changes: 5 additions & 4 deletions src/__tests__/cancel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";
import { BigNumber } from "ethers";
import { parseEther } from "ethers/lib/utils";
import { ethers } from "hardhat";
import { ItemType } from "../constants";
Expand Down Expand Up @@ -77,9 +76,11 @@ describeWithFixture("As a user I want to cancel an order", (fixture) => {
await expect(executeAllFulfillActionsOffChainOrder()).to.be.reverted;
await expect(executeAllFulfillActionsOnChainOrder()).to.be.reverted;

expect(await seaport.getCounter(offerer.address)).to.deep.equal(
BigNumber.from(offChainOrder.parameters.counter).add(1)
);
expect(
(await seaport.getCounter(offerer.address)).gt(
offChainOrder.parameters.counter
)
).to.be.true;
});

it("validate then cancel single order", async () => {
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/create-bulk-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describeWithFixture(
"As a user I want to create bulk orders with one signature",
(fixture) => {
it("should create the orders after setting needed approvals", async () => {
const { seaportv12Contract, seaportv12, testErc721 } = fixture;
const { seaportContract, seaport, testErc721 } = fixture;

const [offerer, zone, randomSigner] = await ethers.getSigners();

Expand Down Expand Up @@ -56,7 +56,7 @@ describeWithFixture(
{ ...order, offer: [{ ...order.offer[0], identifier: nftId3 }] },
];

const { actions } = await seaportv12.createBulkOrders(orders);
const { actions } = await seaport.createBulkOrders(orders);

// Expect only one approval action for the collection of tokens nftId1-nftId3
expect(actions.filter((a) => a.type === "approval")).to.have.lengthOf(1);
Expand All @@ -69,7 +69,7 @@ describeWithFixture(
identifierOrCriteria: nftId1,
itemType: ItemType.ERC721,
transactionMethods: approvalAction.transactionMethods,
operator: seaportv12Contract.address,
operator: seaportContract.address,
});

await approvalAction.transactionMethods.transact();
Expand All @@ -78,7 +78,7 @@ describeWithFixture(
expect(
await testErc721.isApprovedForAll(
offerer.address,
seaportv12Contract.address
seaportContract.address
)
).to.be.true;

Expand Down Expand Up @@ -133,7 +133,7 @@ describeWithFixture(
signature: order.signature,
});

const isValid = await seaportv12Contract
const isValid = await seaportContract
.connect(randomSigner)
.callStatic.validate([
{
Expand Down
11 changes: 2 additions & 9 deletions src/__tests__/create-order.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from "chai";
import { parseEther } from "ethers/lib/utils";
import { ethers } from "hardhat";
import { Seaport } from "../seaport";
import { ItemType, MAX_INT, NO_CONDUIT, OrderType } from "../constants";
import { ApprovalAction, CreateOrderAction } from "../types";
import { generateRandomSalt } from "../utils/order";
Expand Down Expand Up @@ -514,15 +513,9 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
});

it("skips balance and approval validation if consideration config is set to skip on order creation", async () => {
const { seaportContract, testErc721 } = fixture;
const { seaport, seaportContract, testErc721 } = fixture;

const seaport = new Seaport(ethers.provider, {
balanceAndApprovalChecksOnOrderCreation: false,
overrides: {
contractAddress: seaportContract.address,
},
seaportVersion: "1.1",
});
(seaport as any).config.balanceAndApprovalChecksOnOrderCreation = false;

const [offerer, zone, randomSigner] = await ethers.getSigners();
const nftId = "1";
Expand Down
24 changes: 2 additions & 22 deletions src/__tests__/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ chai.use(sinonChai);

type Fixture = {
seaportContract: SeaportContract;
seaportv12Contract: SeaportContract;
seaport: Seaport;
seaportv12: Seaport;
domainRegistry: DomainRegistry;
testErc721: TestERC721;
testErc20: TestERC20;
Expand All @@ -34,11 +32,7 @@ export const describeWithFixture = (

beforeEach(async () => {
const SeaportFactory = await ethers.getContractFactory(
"seaport/contracts/Seaport.sol:Seaport"
);

const Seaportv12Factory = await ethers.getContractFactory(
"seaport_v1_4/contracts/Seaport.sol:Seaport"
"seaport_v1_5/contracts/Seaport.sol:Seaport"
);

const ConduitControllerFactory = await ethers.getContractFactory(
Expand All @@ -51,10 +45,6 @@ export const describeWithFixture = (
conduitController.address
)) as SeaportContract;

const seaportv12Contract = (await Seaportv12Factory.deploy(
conduitController.address
)) as SeaportContract;

await seaportContract.deployed();

const DomainRegistryFactory = await ethers.getContractFactory(
Expand All @@ -68,15 +58,7 @@ export const describeWithFixture = (
contractAddress: seaportContract.address,
domainRegistryAddress: domainRegistry.address,
},
seaportVersion: "1.1",
});

const seaportv12 = new Seaport(ethers.provider, {
overrides: {
contractAddress: seaportv12Contract.address,
domainRegistryAddress: domainRegistry.address,
},
seaportVersion: "1.4",
seaportVersion: "1.5",
});

const TestERC721 = await ethers.getContractFactory("TestERC721");
Expand All @@ -94,9 +76,7 @@ export const describeWithFixture = (
// In order for cb to get the correct fixture values we have
// to pass a reference to an object that you we mutate.
fixture.seaportContract = seaportContract;
fixture.seaportv12Contract = seaportv12Contract;
fixture.seaport = seaport;
fixture.seaportv12 = seaportv12;
fixture.domainRegistry = domainRegistry;
fixture.testErc721 = testErc721;
fixture.testErc1155 = testErc1155;
Expand Down
Loading

0 comments on commit ba842e9

Please sign in to comment.