Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add payableOverrides to the fulfillOrder method. #363

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/seaport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ export class Seaport {
* Defaults to the zero address which means the offer goes to the fulfiller
* @param input.domain optional domain to be hashed and appended to calldata
* @param input.exactApproval optional boolean to indicate whether the approval should be exact or not
* @param input.overrides any overrides the client wants, will ignore value
* @returns a use case containing the set of approval actions and fulfillment action
*/
public async fulfillOrder({
Expand All @@ -794,6 +795,7 @@ export class Seaport {
recipientAddress = ethers.constants.AddressZero,
domain,
exactApproval = false,
overrides,
}: {
order: OrderWithCounter;
unitsToFill?: BigNumberish;
Expand All @@ -806,6 +808,7 @@ export class Seaport {
recipientAddress?: string;
domain?: string;
exactApproval?: boolean;
overrides?: PayableOverrides;
}): Promise<
OrderUseCase<
ExchangeAction<
Expand Down Expand Up @@ -903,6 +906,7 @@ export class Seaport {
signer: fulfiller,
tips: tipConsiderationItems,
domain,
overrides,
},
exactApproval,
);
Expand Down Expand Up @@ -931,6 +935,7 @@ export class Seaport {
fulfillerOperator,
recipientAddress,
domain,
overrides,
},
exactApproval,
);
Expand Down
9 changes: 7 additions & 2 deletions src/utils/fulfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
BigNumberish,
ContractTransaction,
ethers,
PayableOverrides,
Signer,
} from "ethers";
import type {
Expand Down Expand Up @@ -191,6 +192,7 @@ export function fulfillBasicOrder(
tips = [],
conduitKey = NO_CONDUIT,
domain,
overrides,
}: {
order: Order;
seaportContract: Seaport;
Expand All @@ -203,6 +205,7 @@ export function fulfillBasicOrder(
tips?: ConsiderationItem[];
conduitKey: string;
domain?: string;
overrides?: PayableOverrides;
},
exactApproval: boolean,
): OrderUseCase<
Expand Down Expand Up @@ -281,7 +284,7 @@ export function fulfillBasicOrder(
zoneHash: order.parameters.zoneHash,
};

const payableOverrides = { value: totalNativeAmount };
const payableOverrides = { ...overrides, value: totalNativeAmount };

const approvalActions = getApprovalActions(
insufficientApprovals,
Expand Down Expand Up @@ -328,6 +331,7 @@ export function fulfillStandardOrder(
recipientAddress,
signer,
domain,
overrides,
}: {
order: Order;
unitsToFill?: BigNumberish;
Expand All @@ -347,6 +351,7 @@ export function fulfillStandardOrder(
timeBasedItemParams: TimeBasedItemParams;
signer: Signer;
domain?: string;
overrides?: PayableOverrides;
},
exactApproval: boolean,
): OrderUseCase<
Expand Down Expand Up @@ -417,7 +422,7 @@ export function fulfillStandardOrder(
fulfillerOperator,
});

const payableOverrides = { value: totalNativeAmount };
const payableOverrides = { ...overrides, value: totalNativeAmount };

const approvalActions = getApprovalActions(
insufficientApprovals,
Expand Down
3 changes: 3 additions & 0 deletions test/basic-fulfill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describeWithFixture(
const nftId = "1";
const erc1155Amount = "3";
const OPENSEA_DOMAIN = "opensea.io";
const overrideGasLimit = 10_000_000;

beforeEach(async () => {
fulfillBasicOrderSpy = sinon.spy(fulfill, "fulfillBasicOrder");
Expand Down Expand Up @@ -206,6 +207,7 @@ describeWithFixture(
order,
accountAddress: fulfiller.address,
domain: OPENSEA_DOMAIN,
overrides: { gasLimit: overrideGasLimit },
});

const approvalAction = actions[0];
Expand Down Expand Up @@ -248,6 +250,7 @@ describeWithFixture(
fulfillReceipt: receipt,
});
expect(fulfillBasicOrderSpy).calledOnce;
expect(transaction.gasLimit).equal(overrideGasLimit);
});

it("ERC721 <=> ERC20 (already validated order)", async () => {
Expand Down