From 272f6e6a1c693f67b1a942e6bca77117f834bb63 Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Thu, 29 Aug 2024 11:04:47 +0100 Subject: [PATCH] chore: adapt marketplace interface (#791) * chore: adapt marketplace interface * revert breaking compatibility for getOrder()/getOrders() methods * fix e2e test compilation issue --- e2e/tests/opensea-price-discovery.test.ts | 12 ++++----- packages/core-sdk/src/marketplaces/opensea.ts | 27 +++++++++---------- packages/core-sdk/src/marketplaces/types.ts | 24 ++++++++--------- scripts/opensea/fulfil-order.ts | 12 ++++----- 4 files changed, 34 insertions(+), 41 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..cd2d32a39 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; @@ -595,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, @@ -617,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 2f8ef29fd..f324079a8 100644 --- a/packages/core-sdk/src/marketplaces/types.ts +++ b/packages/core-sdk/src/marketplaces/types.ts @@ -82,31 +82,29 @@ 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; - 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;