Skip to content

Commit

Permalink
chore: adapt marketplace interface (#791)
Browse files Browse the repository at this point in the history
* chore: adapt marketplace interface

* revert breaking compatibility for getOrder()/getOrders() methods

* fix e2e test compilation issue
  • Loading branch information
levalleux-ludo authored Aug 29, 2024
1 parent ee02c01 commit 272f6e6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 41 deletions.
12 changes: 5 additions & 7 deletions e2e/tests/opensea-price-discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 13 additions & 14 deletions packages/core-sdk/src/marketplaces/opensea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ export class OpenSeaMarketplace extends Marketplace {
asset: {
contract: string;
tokenId: string;
withWrapper?: boolean;
},
filter: OrderFilterOptions = {},
withWrapper = false
filter: OrderFilterOptions = {}
): Promise<AdvancedOrder> {
// 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({
Expand All @@ -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(
Expand All @@ -303,13 +303,12 @@ export class OpenSeaMarketplace extends Marketplace {
return inputData.orders[0];
}

public async generateFulfilmentData(
asset: {
contract: string;
tokenId: string;
},
withWrapper = false
): Promise<PriceDiscoveryStruct> {
public async generateFulfilmentData(asset: {
contract: string;
tokenId: string;
withWrapper?: boolean;
}): Promise<PriceDiscoveryStruct> {
const withWrapper = !!asset.withWrapper;
const wrapper = withWrapper
? await this.getOrCreateVouchersWrapper(asset.contract)
: undefined;
Expand Down Expand Up @@ -595,8 +594,8 @@ export class OpenSeaMarketplace extends Marketplace {
contract: string;
tokenId: string;
},
filter: OrderFilterOptions = {},
side: Side
side: Side,
filter: OrderFilterOptions = {}
): Promise<SignedOrder> {
const osOrder = await this._handler.api.getOrder({
assetContractAddress: asset.contract,
Expand All @@ -617,8 +616,8 @@ export class OpenSeaMarketplace extends Marketplace {
contract: string;
tokenIds: string[];
},
filter: OrderFilterOptions = {},
side: Side
side: Side,
filter: OrderFilterOptions = {}
): Promise<SignedOrder[]> {
const { orders } = await this._handler.api.getOrders({
assetContractAddress: asset.contract,
Expand Down
24 changes: 11 additions & 13 deletions packages/core-sdk/src/marketplaces/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,29 @@ export abstract class Marketplace {
contract: string;
tokenId: string;
},
filter: OrderFilterOptions,
side: Side
side: Side,
filter?: OrderFilterOptions
): Promise<SignedOrder>;
public abstract getOrders(
asset: {
contract: string;
tokenIds: string[];
},
filter: OrderFilterOptions,
side: Side
side: Side,
filter?: OrderFilterOptions
): Promise<SignedOrder[]>;
public abstract generateFulfilmentData(
asset: {
contract: string;
tokenId: string;
},
withWrapper?: boolean
): Promise<PriceDiscoveryStruct>;
public abstract generateFulfilmentData(asset: {
contract: string;
tokenId: string;
withWrapper?: boolean;
}): Promise<PriceDiscoveryStruct>;
public abstract buildAdvancedOrder(
asset: {
contract: string;
tokenId: string;
withWrapper?: boolean;
},
filter: OrderFilterOptions,
withWrapper?: boolean
filter?: OrderFilterOptions
): Promise<AdvancedOrder>;
public abstract wrapVouchers(
contract: string,
Expand Down
12 changes: 5 additions & 7 deletions scripts/opensea/fulfil-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 272f6e6

Please sign in to comment.