From a37ddb27a8da993527796de3b1278d4cc2c58220 Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Wed, 28 Aug 2024 17:57:14 +0100 Subject: [PATCH 1/3] chore: adapt marketplace interface --- e2e/tests/opensea-price-discovery.test.ts | 12 +++++------- packages/core-sdk/src/marketplaces/opensea.ts | 19 +++++++++---------- packages/core-sdk/src/marketplaces/types.ts | 16 +++++++--------- scripts/opensea/fulfil-order.ts | 12 +++++------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/e2e/tests/opensea-price-discovery.test.ts b/e2e/tests/opensea-price-discovery.test.ts index dafc2c455..176d424d2 100644 --- a/e2e/tests/opensea-price-discovery.test.ts +++ b/e2e/tests/opensea-price-discovery.test.ts @@ -532,13 +532,11 @@ describe("Opensea Price Discovery", () => { sellerCoreSDK ); // Call commitToPriceDiscoveryOffer, that will fulfil the Order on Seaport - const fulfilmentData = await openseaSdkSeller.generateFulfilmentData( - { - contract: voucherContract, - tokenId: listing.asset.tokenId - }, - true // withWrapper - ); + const fulfilmentData = await openseaSdkSeller.generateFulfilmentData({ + contract: voucherContract, + tokenId: listing.asset.tokenId, + withWrapper: true + }); const txCommit = await sellerCoreSDK.commitToPriceDiscoveryOffer( buyerWallet.address, listing.asset.tokenId, diff --git a/packages/core-sdk/src/marketplaces/opensea.ts b/packages/core-sdk/src/marketplaces/opensea.ts index 6897a9c1f..e5ca8cdb1 100644 --- a/packages/core-sdk/src/marketplaces/opensea.ts +++ b/packages/core-sdk/src/marketplaces/opensea.ts @@ -273,9 +273,9 @@ export class OpenSeaMarketplace extends Marketplace { asset: { contract: string; tokenId: string; + withWrapper?: boolean; }, - filter: OrderFilterOptions = {}, - withWrapper = false + filter: OrderFilterOptions = {} ): Promise { // Assumption: we're fulfilling a Bid Order (don't know if it makes sense with an Ask order) const osOrder = await this._handler.api.getOrder({ @@ -284,7 +284,7 @@ export class OpenSeaMarketplace extends Marketplace { side: OrderSide.BID, ...filter }); - const fulfillerAddress = withWrapper + const fulfillerAddress = asset.withWrapper ? asset.contract // If the token is wrapped, the fulfiller is the wrapper contract itself : this._contracts.priceDiscoveryClient; // otherwise the address of the PriceDiscoveryClient contract const ffd = await this._handler.api.generateFulfillmentData( @@ -303,13 +303,12 @@ export class OpenSeaMarketplace extends Marketplace { return inputData.orders[0]; } - public async generateFulfilmentData( - asset: { - contract: string; - tokenId: string; - }, - withWrapper = false - ): Promise { + public async generateFulfilmentData(asset: { + contract: string; + tokenId: string; + withWrapper?: boolean; + }): Promise { + const withWrapper = !!asset.withWrapper; const wrapper = withWrapper ? await this.getOrCreateVouchersWrapper(asset.contract) : undefined; diff --git a/packages/core-sdk/src/marketplaces/types.ts b/packages/core-sdk/src/marketplaces/types.ts index 2f8ef29fd..761409229 100644 --- a/packages/core-sdk/src/marketplaces/types.ts +++ b/packages/core-sdk/src/marketplaces/types.ts @@ -93,20 +93,18 @@ export abstract class Marketplace { filter: OrderFilterOptions, side: Side ): Promise; - public abstract generateFulfilmentData( - asset: { - contract: string; - tokenId: string; - }, - withWrapper?: boolean - ): Promise; + public abstract generateFulfilmentData(asset: { + contract: string; + tokenId: string; + withWrapper?: boolean; + }): Promise; public abstract buildAdvancedOrder( asset: { contract: string; tokenId: string; + withWrapper?: boolean; }, - filter: OrderFilterOptions, - withWrapper?: boolean + filter: OrderFilterOptions ): Promise; public abstract wrapVouchers( contract: string, diff --git a/scripts/opensea/fulfil-order.ts b/scripts/opensea/fulfil-order.ts index f9774c4f9..7fdf75570 100644 --- a/scripts/opensea/fulfil-order.ts +++ b/scripts/opensea/fulfil-order.ts @@ -94,13 +94,11 @@ async function main() { ); } console.log("ORDER TO BE FULFILLED", order); - const priceDiscoveryStruct = await openseaSdkSeller.generateFulfilmentData( - { - contract: nftContract, - tokenId - }, - wrapped - ); + const priceDiscoveryStruct = await openseaSdkSeller.generateFulfilmentData({ + contract: nftContract, + tokenId, + withWrapper: wrapped + }); const BOSON_PROTOCOL = defaultConfig.contracts.protocolDiamond; From 940a52eb7796485e71a1ae7d68361502997d2ec8 Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Thu, 29 Aug 2024 09:43:41 +0100 Subject: [PATCH 2/3] revert breaking compatibility for getOrder()/getOrders() methods --- packages/core-sdk/src/marketplaces/opensea.ts | 8 ++++---- packages/core-sdk/src/marketplaces/types.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core-sdk/src/marketplaces/opensea.ts b/packages/core-sdk/src/marketplaces/opensea.ts index e5ca8cdb1..cd2d32a39 100644 --- a/packages/core-sdk/src/marketplaces/opensea.ts +++ b/packages/core-sdk/src/marketplaces/opensea.ts @@ -594,8 +594,8 @@ export class OpenSeaMarketplace extends Marketplace { contract: string; tokenId: string; }, - filter: OrderFilterOptions = {}, - side: Side + side: Side, + filter: OrderFilterOptions = {} ): Promise { const osOrder = await this._handler.api.getOrder({ assetContractAddress: asset.contract, @@ -616,8 +616,8 @@ export class OpenSeaMarketplace extends Marketplace { contract: string; tokenIds: string[]; }, - filter: OrderFilterOptions = {}, - side: Side + side: Side, + filter: OrderFilterOptions = {} ): Promise { const { orders } = await this._handler.api.getOrders({ assetContractAddress: asset.contract, diff --git a/packages/core-sdk/src/marketplaces/types.ts b/packages/core-sdk/src/marketplaces/types.ts index 761409229..828114163 100644 --- a/packages/core-sdk/src/marketplaces/types.ts +++ b/packages/core-sdk/src/marketplaces/types.ts @@ -82,16 +82,16 @@ export abstract class Marketplace { contract: string; tokenId: string; }, - filter: OrderFilterOptions, - side: Side + side: Side, + filter: OrderFilterOptions ): Promise; public abstract getOrders( asset: { contract: string; tokenIds: string[]; }, - filter: OrderFilterOptions, - side: Side + side: Side, + filter: OrderFilterOptions ): Promise; public abstract generateFulfilmentData(asset: { contract: string; From de4d32b707a8f625bb5e3c2919f56e19cd8c10e9 Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Thu, 29 Aug 2024 10:15:35 +0100 Subject: [PATCH 3/3] fix e2e test compilation issue --- packages/core-sdk/src/marketplaces/types.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core-sdk/src/marketplaces/types.ts b/packages/core-sdk/src/marketplaces/types.ts index 828114163..f324079a8 100644 --- a/packages/core-sdk/src/marketplaces/types.ts +++ b/packages/core-sdk/src/marketplaces/types.ts @@ -83,7 +83,7 @@ export abstract class Marketplace { tokenId: string; }, side: Side, - filter: OrderFilterOptions + filter?: OrderFilterOptions ): Promise; public abstract getOrders( asset: { @@ -91,7 +91,7 @@ export abstract class Marketplace { tokenIds: string[]; }, side: Side, - filter: OrderFilterOptions + filter?: OrderFilterOptions ): Promise; public abstract generateFulfilmentData(asset: { contract: string; @@ -104,7 +104,7 @@ export abstract class Marketplace { tokenId: string; withWrapper?: boolean; }, - filter: OrderFilterOptions + filter?: OrderFilterOptions ): Promise; public abstract wrapVouchers( contract: string,