Skip to content

Commit

Permalink
chore: adapt marketplace interface
Browse files Browse the repository at this point in the history
  • Loading branch information
levalleux-ludo committed Aug 28, 2024
1 parent ee02c01 commit a37ddb2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 33 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
19 changes: 9 additions & 10 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
16 changes: 7 additions & 9 deletions packages/core-sdk/src/marketplaces/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,18 @@ export abstract class Marketplace {
filter: OrderFilterOptions,
side: Side
): 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 a37ddb2

Please sign in to comment.