Skip to content

Commit

Permalink
use required zone when provided (#1432)
Browse files Browse the repository at this point in the history
* use required zone

* bump version
  • Loading branch information
ryanio authored Apr 3, 2024
1 parent 3ea8931 commit 5946d72
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 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.2",
"version": "7.1.3",
"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
28 changes: 20 additions & 8 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ export class OpenSeaSDK {
excludeOptionalCreatorFees,
});

let zone = DEFAULT_ZONE;
if (collection.requiredZone) {
zone = collection.requiredZone;
}

const { executeAllActions } = await this.seaport_v1_6.createOrder(
{
offer: [
Expand All @@ -406,10 +411,10 @@ export class OpenSeaSDK {
expirationTime !== undefined
? BigInt(expirationTime).toString()
: getMaxOrderExpirationTimestamp().toString(),
zone: DEFAULT_ZONE,
zone,
domain,
salt: BigInt(salt ?? 0).toString(),
restrictedByZone: false,
restrictedByZone: zone !== DEFAULT_ZONE,
allowPartialFills: true,
},
accountAddress,
Expand Down Expand Up @@ -511,6 +516,17 @@ export class OpenSeaSDK {
);
}

let zone = DEFAULT_ZONE;
if (englishAuction) {
if (isTestChain(this.chain)) {
zone = ENGLISH_AUCTION_ZONE_TESTNETS;
} else {
zone = ENGLISH_AUCTION_ZONE_MAINNETS;
}
} else if (collection.requiredZone) {
zone = collection.requiredZone;
}

const { executeAllActions } = await this.seaport_v1_6.createOrder(
{
offer: offerAssetItems,
Expand All @@ -519,14 +535,10 @@ export class OpenSeaSDK {
endTime:
expirationTime?.toString() ??
getMaxOrderExpirationTimestamp().toString(),
zone: englishAuction
? isTestChain(this.chain)
? ENGLISH_AUCTION_ZONE_TESTNETS
: ENGLISH_AUCTION_ZONE_MAINNETS
: DEFAULT_ZONE,
zone,
domain,
salt: BigInt(salt ?? 0).toString(),
restrictedByZone: englishAuction ? true : false,
restrictedByZone: zone !== DEFAULT_ZONE,
allowPartialFills: englishAuction ? false : true,
},
accountAddress,
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ export interface OpenSeaCollection {
totalSupply: number;
/** The created date of the collection */
createdDate: string;
/** When defined, the zone required for orders for the collection */
requiredZone?: string;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const collectionFromJSON = (collection: any): OpenSeaCollection => {
paymentTokens: (collection.payment_tokens ?? []).map(paymentTokenFromJSON),
totalSupply: collection.total_supply,
createdDate: collection.created_date,
requiredZone: collection.required_zone,
};
};

Expand Down

0 comments on commit 5946d72

Please sign in to comment.