Skip to content

Commit

Permalink
add zone parameter to createListing, make default zone ZeroAddress (#…
Browse files Browse the repository at this point in the history
…1517)

* make default zone ZeroAddress, add zone parameter to createListing

* bump version
  • Loading branch information
ryanio authored Jul 12, 2024
1 parent fdb5257 commit 760ee98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opensea-js",
"version": "7.1.11",
"version": "7.1.12",
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down
5 changes: 3 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FixedNumber, ZeroAddress } from "ethers";
import { FixedNumber } from "ethers";

export const FIXED_NUMBER_100 = FixedNumber.fromValue(100);
export const INVERSE_BASIS_POINT = 10_000n; // 100 basis points per 1%
Expand All @@ -7,8 +7,9 @@ export const MAX_EXPIRATION_MONTHS = 1;
export const API_BASE_MAINNET = "https://api.opensea.io";
export const API_BASE_TESTNET = "https://testnets-api.opensea.io";

export const DEFAULT_ZONE = ZeroAddress;
// eslint-disable-next-line import/no-unused-modules
export const SIGNED_ZONE = "0x000056f7000000ece9003ca63978907a00ffd100";

export const ENGLISH_AUCTION_ZONE_MAINNETS =
"0x110b2b128a9ed1be5ef3232d8e4e41640df5c2cd";
export const ENGLISH_AUCTION_ZONE_TESTNETS =
Expand Down
26 changes: 13 additions & 13 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import {
parseEther,
JsonRpcProvider,
ContractTransactionResponse,
ZeroAddress,
} from "ethers";
import { OpenSeaAPI } from "./api/api";
import { CollectionOffer, Listing, NFT, Order } from "./api/types";
import {
INVERSE_BASIS_POINT,
DEFAULT_ZONE,
SIGNED_ZONE,
ENGLISH_AUCTION_ZONE_MAINNETS,
ENGLISH_AUCTION_ZONE_TESTNETS,
} from "./constants";
Expand Down Expand Up @@ -343,7 +342,8 @@ export class OpenSeaSDK {
* @param options.expirationTime Expiration time for the order, in UTC seconds
* @param options.paymentTokenAddress ERC20 address for the payment token in the order. If unspecified, defaults to WETH
* @param options.excludeOptionalCreatorFees If true, optional creator fees will be excluded from the offer. Default: false.
* @param options.zone The zone to use for the order. If unspecified, defaults to SIGNED_ZONE.
* @param options.zone The zone to use for the order. For order protection, pass SIGNED_ZONE. If unspecified, defaults to no zone.
*
* @returns The {@link OrderV2} that was created.
*
* @throws Error if the asset does not contain a token id.
Expand All @@ -361,7 +361,7 @@ export class OpenSeaSDK {
expirationTime,
paymentTokenAddress = getWETHAddress(this.chain),
excludeOptionalCreatorFees = false,
zone = SIGNED_ZONE, // Add the zone parameter with default value SIGNED_ZONE
zone = ZeroAddress,
}: {
asset: AssetWithTokenId;
accountAddress: string;
Expand All @@ -372,7 +372,7 @@ export class OpenSeaSDK {
expirationTime?: BigNumberish;
paymentTokenAddress?: string;
excludeOptionalCreatorFees?: boolean;
zone?: string; // Add the zone type
zone?: string;
}): Promise<OrderV2> {
await this._requireAccountIsAvailable(accountAddress);

Expand Down Expand Up @@ -418,7 +418,7 @@ export class OpenSeaSDK {
zone,
domain,
salt: BigInt(salt ?? 0).toString(),
restrictedByZone: zone !== DEFAULT_ZONE,
restrictedByZone: zone !== ZeroAddress,
allowPartialFills: true,
},
accountAddress,
Expand Down Expand Up @@ -448,6 +448,7 @@ export class OpenSeaSDK {
* @param options.buyerAddress Optional address that's allowed to purchase this item. If specified, no other address will be able to take the order, unless its value is the null address.
* @param options.englishAuction If true, the order will be listed as an English auction.
* @param options.excludeOptionalCreatorFees If true, optional creator fees will be excluded from the listing. Default: false.
* @param options.zone The zone to use for the order. For order protection, pass SIGNED_ZONE. If unspecified, defaults to no zone.
* @returns The {@link OrderV2} that was created.
*
* @throws Error if the asset does not contain a token id.
Expand All @@ -469,6 +470,7 @@ export class OpenSeaSDK {
buyerAddress,
englishAuction,
excludeOptionalCreatorFees = false,
zone = ZeroAddress,
}: {
asset: AssetWithTokenId;
accountAddress: string;
Expand All @@ -483,6 +485,7 @@ export class OpenSeaSDK {
buyerAddress?: string;
englishAuction?: boolean;
excludeOptionalCreatorFees?: boolean;
zone?: string;
}): Promise<OrderV2> {
await this._requireAccountIsAvailable(accountAddress);

Expand Down Expand Up @@ -520,13 +523,10 @@ export class OpenSeaSDK {
);
}

let zone = DEFAULT_ZONE;
if (englishAuction) {
if (isTestChain(this.chain)) {
zone = ENGLISH_AUCTION_ZONE_TESTNETS;
} else {
zone = ENGLISH_AUCTION_ZONE_MAINNETS;
}
zone = isTestChain(this.chain)
? ENGLISH_AUCTION_ZONE_TESTNETS
: ENGLISH_AUCTION_ZONE_MAINNETS;
} else if (collection.requiredZone) {
zone = collection.requiredZone;
}
Expand All @@ -542,7 +542,7 @@ export class OpenSeaSDK {
zone,
domain,
salt: BigInt(salt ?? 0).toString(),
restrictedByZone: zone !== DEFAULT_ZONE,
restrictedByZone: zone !== ZeroAddress,
allowPartialFills: englishAuction ? false : true,
},
accountAddress,
Expand Down

0 comments on commit 760ee98

Please sign in to comment.