Skip to content

Commit

Permalink
Add tx overrides (#1229)
Browse files Browse the repository at this point in the history
* bump package.json version to 6.1.12

* update to seaport-js v2.0.8

* add transaction overrides from latest seaport-js release
  • Loading branch information
ryanio authored Oct 13, 2023
1 parent ccb6939 commit 7b7e994
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opensea-js",
"version": "6.1.11",
"version": "6.1.12",
"description": "JavaScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data!",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"types": "lib/index.d.ts",
"dependencies": {
"@opensea/seaport-js": "^2.0.0",
"@opensea/seaport-js": "^2.0.8",
"ethers": "^5.7.2"
},
"devDependencies": {
Expand Down
15 changes: 14 additions & 1 deletion src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
BigNumberish,
Contract,
FixedNumber,
PayableOverrides,
Wallet,
ethers,
providers,
Expand Down Expand Up @@ -658,16 +659,19 @@ export class OpenSeaSDK {
* @param options.accountAddress Address of the wallet taking the order.
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
* This can be used for on-chain order attribution to assist with analytics.
* @param options.overrides Transaction overrides, ignored if not set.
* @returns Transaction hash of the order.
*/
private async fulfillPrivateOrder({
order,
accountAddress,
domain,
overrides,
}: {
order: OrderV2;
accountAddress: string;
domain?: string;
overrides?: PayableOverrides;
}): Promise<string> {
if (!order.taker?.address) {
throw new Error(
Expand All @@ -684,6 +688,7 @@ export class OpenSeaSDK {
orders: [order.protocolData, counterOrder],
fulfillments,
overrides: {
...overrides,
value: counterOrder.parameters.offer[0].startAmount,
},
accountAddress,
Expand All @@ -707,6 +712,7 @@ export class OpenSeaSDK {
* @param options.accountAddress Address of the wallet taking the offer.
* @param options.recipientAddress The optional address to receive the order's item(s) or curriencies. If not specified, defaults to accountAddress.
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata. This can be used for on-chain order attribution to assist with analytics.
* @param options.overrides Transaction overrides, ignored if not set.
* @returns Transaction hash of the order.
*
* @throws Error if the accountAddress is not available through wallet or provider.
Expand All @@ -718,11 +724,13 @@ export class OpenSeaSDK {
accountAddress,
recipientAddress,
domain,
overrides,
}: {
order: OrderV2;
accountAddress: string;
recipientAddress?: string;
domain?: string;
overrides?: PayableOverrides;
}): Promise<string> {
await this._requireAccountIsAvailable(accountAddress);
requireValidProtocol(order.protocolAddress);
Expand Down Expand Up @@ -760,6 +768,7 @@ export class OpenSeaSDK {
order,
accountAddress,
domain,
overrides,
});
}

Expand All @@ -769,6 +778,7 @@ export class OpenSeaSDK {
recipientAddress,
extraData,
domain,
overrides,
});
const transaction = await executeAllActions();

Expand All @@ -787,18 +797,21 @@ export class OpenSeaSDK {
* @param options.accountAddress The account address cancelling the orders.
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
* This can be used for on-chain order attribution to assist with analytics.
* @param options.overrides Transaction overrides, ignored if not set.
* @returns Transaction hash of the order.
*/
private async cancelSeaportOrders({
orders,
accountAddress,
domain,
protocolAddress = DEFAULT_SEAPORT_CONTRACT_ADDRESS,
overrides,
}: {
orders: OrderComponents[];
accountAddress: string;
domain?: string;
protocolAddress?: string;
overrides?: PayableOverrides;
}): Promise<string> {
const checksummedProtocolAddress = ethers.utils.getAddress(protocolAddress);
if (checksummedProtocolAddress !== DEFAULT_SEAPORT_CONTRACT_ADDRESS) {
Expand All @@ -808,7 +821,7 @@ export class OpenSeaSDK {
}

const transaction = await this.seaport_v1_5
.cancelOrders(orders, accountAddress, domain)
.cancelOrders(orders, accountAddress, domain, overrides)
.transact();

return transaction.hash;
Expand Down

0 comments on commit 7b7e994

Please sign in to comment.