Skip to content

Commit

Permalink
Add payableOverrides to the fulfillOrder method. (#363)
Browse files Browse the repository at this point in the history
* add payableOverrides to the fulfillOrder method.

* update documentation

* type 🤦
  • Loading branch information
tenthirtyone authored Oct 10, 2023
1 parent 047888a commit 1f9f820
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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

0 comments on commit 1f9f820

Please sign in to comment.