Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export class OpenSeaAPI {
* @param tokenId Optional token ID for criteria offers (e.g., collection offers)
* @param unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers.
* @param recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.
* @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.
* @returns The {@link FulfillmentDataResponse}
*/
public async generateFulfillmentData(
Expand All @@ -291,6 +292,7 @@ export class OpenSeaAPI {
tokenId?: string,
unitsToFill?: string,
recipientAddress?: string,
includeOptionalCreatorFees: boolean = false,
): Promise<FulfillmentDataResponse> {
return this.ordersAPI.generateFulfillmentData(
fulfillerAddress,
Expand All @@ -301,6 +303,7 @@ export class OpenSeaAPI {
tokenId,
unitsToFill,
recipientAddress,
includeOptionalCreatorFees,
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/api/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class OrdersAPI {
tokenId?: string,
unitsToFill?: string,
recipientAddress?: string,
includeOptionalCreatorFees: boolean = false,
): Promise<FulfillmentDataResponse> {
let payload: object | null = null;
if (side === OrderSide.LISTING) {
Expand All @@ -149,6 +150,7 @@ export class OrdersAPI {
tokenId,
unitsToFill,
recipientAddress,
includeOptionalCreatorFees,
);
} else {
payload = getFulfillOfferPayload(
Expand All @@ -159,6 +161,7 @@ export class OrdersAPI {
assetContractAddress,
tokenId,
unitsToFill,
includeOptionalCreatorFees,
);
}
const response = await this.fetcher.post<FulfillmentDataResponse>(
Expand Down
6 changes: 6 additions & 0 deletions src/orders/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const getFulfillListingPayload = (
tokenId?: string,
unitsToFill: string = "1",
recipientAddress?: string,
includeOptionalCreatorFees: boolean = false,
) => {
const payload: {
listing: {
Expand All @@ -107,6 +108,7 @@ export const getFulfillListingPayload = (
};
units_to_fill: string;
recipient?: string;
include_optional_creator_fees: boolean;
} = {
listing: {
hash: order_hash,
Expand All @@ -117,6 +119,7 @@ export const getFulfillListingPayload = (
address: fulfillerAddress,
},
units_to_fill: unitsToFill,
include_optional_creator_fees: includeOptionalCreatorFees,
};

// Add consideration for criteria listings if needed
Expand All @@ -143,6 +146,7 @@ export const getFulfillOfferPayload = (
assetContractAddress?: string,
tokenId?: string,
unitsToFill: string = "1",
includeOptionalCreatorFees: boolean = false,
) => {
const payload: {
offer: {
Expand All @@ -158,6 +162,7 @@ export const getFulfillOfferPayload = (
token_id: string;
};
units_to_fill: string;
include_optional_creator_fees: boolean;
} = {
offer: {
hash: order_hash,
Expand All @@ -168,6 +173,7 @@ export const getFulfillOfferPayload = (
address: fulfillerAddress,
},
units_to_fill: unitsToFill,
include_optional_creator_fees: includeOptionalCreatorFees,
};

// Add consideration for criteria offers (e.g., collection offers)
Expand Down
4 changes: 4 additions & 0 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export class OpenSeaSDK {
* @param options.tokenId Optional token ID for criteria offers (e.g., collection offers). Required when fulfilling collection offers.
* @param options.unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers.
* @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.
* @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.
* @param options.overrides Transaction overrides, ignored if not set.
* @returns Transaction hash of the order.
*
Expand All @@ -505,6 +506,7 @@ export class OpenSeaSDK {
tokenId,
unitsToFill,
recipientAddress,
includeOptionalCreatorFees = false,
overrides,
}: {
order: OrderV2 | Order | Listing | Offer;
Expand All @@ -513,6 +515,7 @@ export class OpenSeaSDK {
tokenId?: string;
unitsToFill?: BigNumberish;
recipientAddress?: string;
includeOptionalCreatorFees?: boolean;
overrides?: Overrides;
}): Promise<string> {
return this._fulfillmentManager.fulfillOrder({
Expand All @@ -522,6 +525,7 @@ export class OpenSeaSDK {
tokenId,
unitsToFill,
recipientAddress,
includeOptionalCreatorFees,
overrides,
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/fulfillment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class FulfillmentManager {
* @param options.tokenId Optional token ID for criteria offers (e.g., collection offers). Required when fulfilling collection offers.
* @param options.unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers.
* @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.
* @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.
* @param options.overrides Transaction overrides, ignored if not set.
* @returns Transaction hash of the order.
*
Expand All @@ -114,6 +115,7 @@ export class FulfillmentManager {
tokenId,
unitsToFill,
recipientAddress,
includeOptionalCreatorFees = false,
overrides,
}: {
order: OrderV2 | Order | Listing | Offer;
Expand All @@ -122,6 +124,7 @@ export class FulfillmentManager {
tokenId?: string;
unitsToFill?: BigNumberish;
recipientAddress?: string;
includeOptionalCreatorFees?: boolean;
overrides?: Overrides;
}): Promise<string> {
await this.context.requireAccountIsAvailable(accountAddress);
Expand Down Expand Up @@ -167,6 +170,7 @@ export class FulfillmentManager {
tokenId,
unitsToFillStr,
recipientAddress,
includeOptionalCreatorFees,
);

// Use the transaction data returned by the API
Expand Down
33 changes: 33 additions & 0 deletions test/orders/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,27 @@ suite("Orders: utils", () => {
address: "0xFulfiller",
},
units_to_fill: "1",
include_optional_creator_fees: false,
});
expect(result.consideration).to.be.undefined;
});

test("should include includeOptionalCreatorFees when set to true", () => {
const result = getFulfillListingPayload(
"0xFulfiller",
"0xOrderHash",
"0xProtocol",
Chain.Mainnet,
undefined,
undefined,
"1",
undefined,
true,
);

expect(result.include_optional_creator_fees).to.be.true;
});

test("should add consideration for criteria listings", () => {
const result = getFulfillListingPayload(
"0xFulfiller",
Expand Down Expand Up @@ -417,6 +434,7 @@ suite("Orders: utils", () => {
address: "0xFulfiller",
},
units_to_fill: "1",
include_optional_creator_fees: false,
});
expect(result.consideration).to.be.undefined;
});
Expand All @@ -436,6 +454,21 @@ suite("Orders: utils", () => {
token_id: "456",
});
});

test("should include includeOptionalCreatorFees when set to true", () => {
const result = getFulfillOfferPayload(
"0xFulfiller",
"0xOrderHash",
"0xProtocol",
Chain.Polygon,
undefined,
undefined,
"1",
true,
);

expect(result.include_optional_creator_fees).to.be.true;
});
});

suite("deserializeOrder", () => {
Expand Down