Skip to content

Commit

Permalink
Allow zoneHash to be passed in input to createOrder and `create…
Browse files Browse the repository at this point in the history
…BulkOrders` (#308)

* Allow `zoneHash` to be passed in `input` to `createOrder` and `createBulkOrders`

* Add test for `zone` and `zoneHash` inputs
  • Loading branch information
rombrom authored Jul 13, 2023
1 parent 680c0c2 commit 23f8fad
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/seaport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export class Seaport {
{
conduitKey = this.defaultConduitKey,
zone = ethers.constants.AddressZero,
zoneHash = ethers.constants.HashZero,
startTime = Math.floor(Date.now() / 1000).toString(),
endTime = MAX_INT.toString(),
offer,
Expand Down Expand Up @@ -363,7 +364,7 @@ export class Seaport {
const orderComponents: OrderComponents = {
offerer,
zone,
zoneHash: ethers.constants.HashZero,
zoneHash,
startTime,
endTime,
orderType,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export type Fee = {
export type CreateOrderInput = {
conduitKey?: string;
zone?: string;
zoneHash?: string;
startTime?: BigNumberish;
endTime?: BigNumberish;
offer: readonly CreateInputItem[];
Expand Down
48 changes: 48 additions & 0 deletions test/create-order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,54 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
expect(contractOrderHash).eq(localOrderHash);
expect(order.parameters.salt).eq(`0x${"0".repeat(60)}abcd`);
});

it("should create an order with the passed in zone and zoneHash", async () => {
const { seaportContract, seaport, testErc721 } = fixture;

const [offerer, recipient] = await ethers.getSigners();
const nftId = "1";
await testErc721.mint(offerer.address, nftId);
const startTime = "0";
const endTime = MAX_INT.toString();
const zone = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
const zoneHash = ethers.utils.keccak256("0xf00b");
const salt = "0xabcd";

const { executeAllActions } = await seaport.createOrder({
startTime,
endTime,
salt,
zone,
zoneHash,
offer: [
{
itemType: ItemType.ERC721,
token: testErc721.address,
identifier: nftId,
},
],
consideration: [
{
amount: ethers.utils.parseEther("10").toString(),
recipient: offerer.address,
},
],
// 2.5% fee
fees: [{ recipient: recipient.address, basisPoints: 250 }],
});

const order = await executeAllActions();

const contractOrderHash = await seaportContract.getOrderHash(
order.parameters,
);

const localOrderHash = seaport.getOrderHash(order.parameters);

expect(contractOrderHash).eq(localOrderHash);
expect(order.parameters.zone).eq(zone);
expect(order.parameters.zoneHash).eq(zoneHash);
});
});

const OPENSEA_DOMAIN = "opensea.io";
Expand Down

0 comments on commit 23f8fad

Please sign in to comment.