diff --git a/packages/core-sdk/src/erc20/handler.ts b/packages/core-sdk/src/erc20/handler.ts index 211d92e58..9348c9c9a 100644 --- a/packages/core-sdk/src/erc20/handler.ts +++ b/packages/core-sdk/src/erc20/handler.ts @@ -1,4 +1,4 @@ -import { Web3LibAdapter } from "@bosonprotocol/common"; +import { Web3LibAdapter, TransactionRequest } from "@bosonprotocol/common"; import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; import { erc20Iface } from "./interface"; @@ -7,8 +7,10 @@ export async function approve(args: { spender: string; value: BigNumberish; web3Lib: Web3LibAdapter; + txRequest?: TransactionRequest; }) { return args.web3Lib.sendTransaction({ + ...args.txRequest, to: args.contractAddress, data: erc20Iface.encodeFunctionData("approve", [args.spender, args.value]) }); @@ -74,6 +76,7 @@ export async function ensureAllowance(args: { contractAddress: string; value: BigNumberish; web3Lib: Web3LibAdapter; + txRequest?: TransactionRequest; }) { const allowance = await getAllowance(args); if (BigNumber.from(allowance).lt(args.value)) { diff --git a/packages/core-sdk/src/erc721/handler.ts b/packages/core-sdk/src/erc721/handler.ts index d20f67480..ce4f37815 100644 --- a/packages/core-sdk/src/erc721/handler.ts +++ b/packages/core-sdk/src/erc721/handler.ts @@ -1,4 +1,4 @@ -import { Web3LibAdapter } from "@bosonprotocol/common"; +import { TransactionRequest, Web3LibAdapter } from "@bosonprotocol/common"; import { BigNumberish } from "@ethersproject/bignumber"; import { erc721Iface } from "./interface"; @@ -101,8 +101,10 @@ export async function setApprovalForAll(args: { operator: string; approved: boolean; web3Lib: Web3LibAdapter; + txRequest?: TransactionRequest; }) { return args.web3Lib.sendTransaction({ + ...args.txRequest, to: args.contractAddress, data: erc721Iface.encodeFunctionData("setApprovalForAll", [ args.operator, diff --git a/packages/core-sdk/src/marketplaces/opensea.ts b/packages/core-sdk/src/marketplaces/opensea.ts index 9a8d9e013..4a58e9ff3 100644 --- a/packages/core-sdk/src/marketplaces/opensea.ts +++ b/packages/core-sdk/src/marketplaces/opensea.ts @@ -253,7 +253,7 @@ export class OpenSeaMarketplace extends Marketplace { const protocolAddress = listing.protocolAddress || this._contracts.seaport; if (!protocolAddress) { throw new Error( - `Seaport protocol address must be specified in Lsiting or CoreSDK config` + `Seaport protocol address must be specified in Listing or CoreSDK config` ); } @@ -265,18 +265,24 @@ export class OpenSeaMarketplace extends Marketplace { return this.convertOsOrder(osOrder); } - public async buildAdvancedOrder(asset: { - contract: string; - tokenId: string; - }): Promise { + public async buildAdvancedOrder( + asset: { + contract: string; + tokenId: string; + }, + withWrapper = false + ): Promise { // Asumption: we're fulfilling a Bid Order (don't know if it makes sense with an Ask order) const osOrder = await this._handler.api.getOrder({ assetContractAddress: asset.contract, tokenId: asset.tokenId, side: OrderSide.BID }); + const fulfillerAddress = 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( - this._contracts.priceDiscoveryClient, // the address of the PriceDiscoveryClient contract, which will call the fulfilment method + fulfillerAddress, osOrder.orderHash, osOrder.protocolAddress, osOrder.side diff --git a/packages/core-sdk/src/marketplaces/types.ts b/packages/core-sdk/src/marketplaces/types.ts index 5d2dca774..0972559a2 100644 --- a/packages/core-sdk/src/marketplaces/types.ts +++ b/packages/core-sdk/src/marketplaces/types.ts @@ -82,10 +82,13 @@ export abstract class Marketplace { }, withWrapper?: boolean ): Promise; - public abstract buildAdvancedOrder(asset: { - contract: string; - tokenId: string; - }): Promise; + public abstract buildAdvancedOrder( + asset: { + contract: string; + tokenId: string; + }, + withWrapper?: boolean + ): Promise; public abstract wrapVouchers( contract: string, tokenIds: string[]