Skip to content

Commit 36e8605

Browse files
authored
feat: add includeOptionalCreatorFees to fulfillOrder (#1828)
Add includeOptionalCreatorFees parameter to fulfill offer and fulfill listing endpoints. When set to true, optional creator fees will be included in the fulfillment. If creator fees are already required, this is a no-op. Defaults to false. Changes: - Add includeOptionalCreatorFees param to getFulfillListingPayload/getFulfillOfferPayload - Add includeOptionalCreatorFees param to generateFulfillmentData in OrdersAPI and OpenSeaAPI - Add includeOptionalCreatorFees param to fulfillOrder in FulfillmentManager and OpenSeaSDK - Update tests to cover new parameter
1 parent 3491bab commit 36e8605

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

src/api/api.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export class OpenSeaAPI {
280280
* @param tokenId Optional token ID for criteria offers (e.g., collection offers)
281281
* @param unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers.
282282
* @param recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.
283+
* @param includeOptionalCreatorFees Whether to include optional creator fees in the fulfillment. If creator fees are already required, this is a no-op. Defaults to false.
283284
* @returns The {@link FulfillmentDataResponse}
284285
*/
285286
public async generateFulfillmentData(
@@ -291,6 +292,7 @@ export class OpenSeaAPI {
291292
tokenId?: string,
292293
unitsToFill?: string,
293294
recipientAddress?: string,
295+
includeOptionalCreatorFees: boolean = false,
294296
): Promise<FulfillmentDataResponse> {
295297
return this.ordersAPI.generateFulfillmentData(
296298
fulfillerAddress,
@@ -301,6 +303,7 @@ export class OpenSeaAPI {
301303
tokenId,
302304
unitsToFill,
303305
recipientAddress,
306+
includeOptionalCreatorFees,
304307
);
305308
}
306309

src/api/orders.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export class OrdersAPI {
137137
tokenId?: string,
138138
unitsToFill?: string,
139139
recipientAddress?: string,
140+
includeOptionalCreatorFees: boolean = false,
140141
): Promise<FulfillmentDataResponse> {
141142
let payload: object | null = null;
142143
if (side === OrderSide.LISTING) {
@@ -149,6 +150,7 @@ export class OrdersAPI {
149150
tokenId,
150151
unitsToFill,
151152
recipientAddress,
153+
includeOptionalCreatorFees,
152154
);
153155
} else {
154156
payload = getFulfillOfferPayload(
@@ -159,6 +161,7 @@ export class OrdersAPI {
159161
assetContractAddress,
160162
tokenId,
161163
unitsToFill,
164+
includeOptionalCreatorFees,
162165
);
163166
}
164167
const response = await this.fetcher.post<FulfillmentDataResponse>(

src/orders/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const getFulfillListingPayload = (
9191
tokenId?: string,
9292
unitsToFill: string = "1",
9393
recipientAddress?: string,
94+
includeOptionalCreatorFees: boolean = false,
9495
) => {
9596
const payload: {
9697
listing: {
@@ -107,6 +108,7 @@ export const getFulfillListingPayload = (
107108
};
108109
units_to_fill: string;
109110
recipient?: string;
111+
include_optional_creator_fees: boolean;
110112
} = {
111113
listing: {
112114
hash: order_hash,
@@ -117,6 +119,7 @@ export const getFulfillListingPayload = (
117119
address: fulfillerAddress,
118120
},
119121
units_to_fill: unitsToFill,
122+
include_optional_creator_fees: includeOptionalCreatorFees,
120123
};
121124

122125
// Add consideration for criteria listings if needed
@@ -143,6 +146,7 @@ export const getFulfillOfferPayload = (
143146
assetContractAddress?: string,
144147
tokenId?: string,
145148
unitsToFill: string = "1",
149+
includeOptionalCreatorFees: boolean = false,
146150
) => {
147151
const payload: {
148152
offer: {
@@ -158,6 +162,7 @@ export const getFulfillOfferPayload = (
158162
token_id: string;
159163
};
160164
units_to_fill: string;
165+
include_optional_creator_fees: boolean;
161166
} = {
162167
offer: {
163168
hash: order_hash,
@@ -168,6 +173,7 @@ export const getFulfillOfferPayload = (
168173
address: fulfillerAddress,
169174
},
170175
units_to_fill: unitsToFill,
176+
include_optional_creator_fees: includeOptionalCreatorFees,
171177
};
172178

173179
// Add consideration for criteria offers (e.g., collection offers)

src/sdk.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ export class OpenSeaSDK {
490490
* @param options.tokenId Optional token ID for criteria offers (e.g., collection offers). Required when fulfilling collection offers.
491491
* @param options.unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers.
492492
* @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.
493+
* @param options.includeOptionalCreatorFees Whether to include optional creator fees in the fulfillment. If creator fees are already required, this is a no-op. Defaults to false.
493494
* @param options.overrides Transaction overrides, ignored if not set.
494495
* @returns Transaction hash of the order.
495496
*
@@ -505,6 +506,7 @@ export class OpenSeaSDK {
505506
tokenId,
506507
unitsToFill,
507508
recipientAddress,
509+
includeOptionalCreatorFees = false,
508510
overrides,
509511
}: {
510512
order: OrderV2 | Order | Listing | Offer;
@@ -513,6 +515,7 @@ export class OpenSeaSDK {
513515
tokenId?: string;
514516
unitsToFill?: BigNumberish;
515517
recipientAddress?: string;
518+
includeOptionalCreatorFees?: boolean;
516519
overrides?: Overrides;
517520
}): Promise<string> {
518521
return this._fulfillmentManager.fulfillOrder({
@@ -522,6 +525,7 @@ export class OpenSeaSDK {
522525
tokenId,
523526
unitsToFill,
524527
recipientAddress,
528+
includeOptionalCreatorFees,
525529
overrides,
526530
});
527531
}

src/sdk/fulfillment.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class FulfillmentManager {
9999
* @param options.tokenId Optional token ID for criteria offers (e.g., collection offers). Required when fulfilling collection offers.
100100
* @param options.unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers.
101101
* @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.
102+
* @param options.includeOptionalCreatorFees Whether to include optional creator fees in the fulfillment. If creator fees are already required, this is a no-op. Defaults to false.
102103
* @param options.overrides Transaction overrides, ignored if not set.
103104
* @returns Transaction hash of the order.
104105
*
@@ -114,6 +115,7 @@ export class FulfillmentManager {
114115
tokenId,
115116
unitsToFill,
116117
recipientAddress,
118+
includeOptionalCreatorFees = false,
117119
overrides,
118120
}: {
119121
order: OrderV2 | Order | Listing | Offer;
@@ -122,6 +124,7 @@ export class FulfillmentManager {
122124
tokenId?: string;
123125
unitsToFill?: BigNumberish;
124126
recipientAddress?: string;
127+
includeOptionalCreatorFees?: boolean;
125128
overrides?: Overrides;
126129
}): Promise<string> {
127130
await this.context.requireAccountIsAvailable(accountAddress);
@@ -167,6 +170,7 @@ export class FulfillmentManager {
167170
tokenId,
168171
unitsToFillStr,
169172
recipientAddress,
173+
includeOptionalCreatorFees,
170174
);
171175

172176
// Use the transaction data returned by the API

test/orders/utils.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,27 @@ suite("Orders: utils", () => {
352352
address: "0xFulfiller",
353353
},
354354
units_to_fill: "1",
355+
include_optional_creator_fees: false,
355356
});
356357
expect(result.consideration).to.be.undefined;
357358
});
358359

360+
test("should include includeOptionalCreatorFees when set to true", () => {
361+
const result = getFulfillListingPayload(
362+
"0xFulfiller",
363+
"0xOrderHash",
364+
"0xProtocol",
365+
Chain.Mainnet,
366+
undefined,
367+
undefined,
368+
"1",
369+
undefined,
370+
true,
371+
);
372+
373+
expect(result.include_optional_creator_fees).to.be.true;
374+
});
375+
359376
test("should add consideration for criteria listings", () => {
360377
const result = getFulfillListingPayload(
361378
"0xFulfiller",
@@ -417,6 +434,7 @@ suite("Orders: utils", () => {
417434
address: "0xFulfiller",
418435
},
419436
units_to_fill: "1",
437+
include_optional_creator_fees: false,
420438
});
421439
expect(result.consideration).to.be.undefined;
422440
});
@@ -436,6 +454,21 @@ suite("Orders: utils", () => {
436454
token_id: "456",
437455
});
438456
});
457+
458+
test("should include includeOptionalCreatorFees when set to true", () => {
459+
const result = getFulfillOfferPayload(
460+
"0xFulfiller",
461+
"0xOrderHash",
462+
"0xProtocol",
463+
Chain.Polygon,
464+
undefined,
465+
undefined,
466+
"1",
467+
true,
468+
);
469+
470+
expect(result.include_optional_creator_fees).to.be.true;
471+
});
439472
});
440473

441474
suite("deserializeOrder", () => {

0 commit comments

Comments
 (0)