opensea-js
Advanced tools
Comparing version 7.1.9 to 7.1.10
@@ -32,3 +32,3 @@ import { BuildOfferResponse, GetCollectionsResponse, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse, GetOrdersResponse, GetBestOfferResponse, GetBestListingResponse, GetOffersResponse, GetListingsResponse, CollectionOffer, CollectionOrderByOption, CancelOrderResponse } from "./types"; | ||
* @param options | ||
* @param options.side The side of the order (buy or sell | ||
* @param options.side The side of the order (listing or offer) | ||
* @param options.protocol The protocol, typically seaport, to query orders for | ||
@@ -35,0 +35,0 @@ * @param options.orderDirection The direction to sort the orders |
@@ -11,9 +11,2 @@ "use strict"; | ||
const utils_2 = require("../utils/utils"); | ||
function stall(duration) { | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, duration); | ||
}); | ||
} | ||
/** | ||
@@ -50,3 +43,3 @@ * The API class for the OpenSea SDK. | ||
* @param options | ||
* @param options.side The side of the order (buy or sell | ||
* @param options.side The side of the order (listing or offer) | ||
* @param options.protocol The protocol, typically seaport, to query orders for | ||
@@ -178,3 +171,3 @@ * @param options.orderDirection The direction to sort the orders | ||
let payload = null; | ||
if (side === types_2.OrderSide.ASK) { | ||
if (side === types_2.OrderSide.LISTING) { | ||
payload = (0, utils_1.getFulfillListingPayload)(fulfillerAddress, orderHash, protocolAddress, this.chain); | ||
@@ -448,10 +441,3 @@ } | ||
// Set the throttle params | ||
// - Should be able to replace this retryFunc with `setThrottleParams({ slotInterval: 1000 })` | ||
// when this bug is fixed in ethers: https://github.com/ethers-io/ethers.js/issues/4663 | ||
req.retryFunc = async (_req, resp, attempt) => { | ||
this.logger(`Fetch attempt ${attempt} failed with status ${resp.statusCode}`); | ||
// Wait 1s between tries | ||
await stall(1000); | ||
return true; | ||
}; | ||
req.setThrottleParams({ slotInterval: 1000 }); | ||
this.logger(`Sending request: ${url} ${JSON.stringify({ | ||
@@ -458,0 +444,0 @@ request: req, |
@@ -6,3 +6,3 @@ "use strict"; | ||
const getOrdersAPIPath = (chain, protocol, side) => { | ||
const sidePath = side === types_1.OrderSide.ASK ? "listings" : "offers"; | ||
const sidePath = side === types_1.OrderSide.LISTING ? "listings" : "offers"; | ||
return `/v2/orders/${chain}/${protocol}/${sidePath}`; | ||
@@ -9,0 +9,0 @@ }; |
@@ -46,3 +46,3 @@ import { BasicOrderParametersStruct } from "@opensea/seaport-js/lib/typechain-types/seaport/contracts/Seaport"; | ||
takerFees: OrderFee[]; | ||
/** The side of the order. Ask/Bid */ | ||
/** The side of the order. Listing/Offer */ | ||
side: OrderSide; | ||
@@ -49,0 +49,0 @@ /** The type of the order. Basic/English/Criteria */ |
@@ -49,3 +49,3 @@ "use strict"; | ||
const getFulfillmentDataPath = (side) => { | ||
const sidePath = side === types_1.OrderSide.ASK ? "listings" : "offers"; | ||
const sidePath = side === types_1.OrderSide.LISTING ? "listings" : "offers"; | ||
return `/v2/${sidePath}/fulfillment_data`; | ||
@@ -52,0 +52,0 @@ }; |
@@ -200,3 +200,3 @@ "use strict"; | ||
const considerationAssetItems = this.getNFTItems([nft], [BigInt(quantity ?? 1)]); | ||
const { basePrice } = await this._getPriceParameters(types_2.OrderSide.BID, paymentTokenAddress, expirationTime ?? (0, utils_2.getMaxOrderExpirationTimestamp)(), startAmount); | ||
const { basePrice } = await this._getPriceParameters(types_2.OrderSide.OFFER, paymentTokenAddress, expirationTime ?? (0, utils_2.getMaxOrderExpirationTimestamp)(), startAmount); | ||
const collection = await this.api.getCollection(nft.collection); | ||
@@ -234,3 +234,3 @@ const considerationFeeItems = await this.getFees({ | ||
protocolAddress: utils_1.DEFAULT_SEAPORT_CONTRACT_ADDRESS, | ||
side: types_2.OrderSide.BID, | ||
side: types_2.OrderSide.OFFER, | ||
}); | ||
@@ -268,3 +268,3 @@ } | ||
} | ||
const { basePrice, endPrice } = await this._getPriceParameters(types_2.OrderSide.ASK, paymentTokenAddress, expirationTime ?? (0, utils_2.getMaxOrderExpirationTimestamp)(), startAmount, endAmount ?? undefined); | ||
const { basePrice, endPrice } = await this._getPriceParameters(types_2.OrderSide.LISTING, paymentTokenAddress, expirationTime ?? (0, utils_2.getMaxOrderExpirationTimestamp)(), startAmount, endAmount ?? undefined); | ||
const collection = await this.api.getCollection(nft.collection); | ||
@@ -310,3 +310,3 @@ const considerationFeeItems = await this.getFees({ | ||
protocolAddress: utils_1.DEFAULT_SEAPORT_CONTRACT_ADDRESS, | ||
side: types_2.OrderSide.ASK, | ||
side: types_2.OrderSide.LISTING, | ||
}); | ||
@@ -342,3 +342,3 @@ } | ||
}; | ||
const { basePrice } = await this._getPriceParameters(types_2.OrderSide.ASK, paymentTokenAddress, expirationTime ?? (0, utils_2.getMaxOrderExpirationTimestamp)(), amount); | ||
const { basePrice } = await this._getPriceParameters(types_2.OrderSide.LISTING, paymentTokenAddress, expirationTime ?? (0, utils_2.getMaxOrderExpirationTimestamp)(), amount); | ||
const considerationFeeItems = await this.getFees({ | ||
@@ -433,4 +433,4 @@ collection, | ||
([types_1.OrderType.BASIC, types_1.OrderType.ENGLISH].includes(order.type) | ||
? types_2.OrderSide.ASK | ||
: types_2.OrderSide.BID); | ||
? types_2.OrderSide.LISTING | ||
: types_2.OrderSide.OFFER); | ||
let extraData = undefined; | ||
@@ -761,3 +761,3 @@ const protocolData = order.protocolData ?? order.protocol_data; | ||
} | ||
if (isEther && orderSide === types_2.OrderSide.BID) { | ||
if (isEther && orderSide === types_2.OrderSide.OFFER) { | ||
throw new Error("Offers must use wrapped ETH or an ERC-20 token."); | ||
@@ -786,2 +786,5 @@ } | ||
} | ||
else if ("getAddress" in this._signerOrProvider) { | ||
availableAccounts.push(await this._signerOrProvider.getAddress()); | ||
} | ||
return availableAccounts; | ||
@@ -788,0 +791,0 @@ } |
@@ -145,7 +145,7 @@ import { BigNumberish } from "ethers"; | ||
/** | ||
* Order side: ask (sell, listing) or bid (buy, offer) | ||
* Order side: listing (ask) or offer (bid) | ||
*/ | ||
export declare enum OrderSide { | ||
ASK = "ask", | ||
BID = "bid" | ||
LISTING = "ask", | ||
OFFER = "bid" | ||
} | ||
@@ -152,0 +152,0 @@ /** |
@@ -110,8 +110,8 @@ "use strict"; | ||
/** | ||
* Order side: ask (sell, listing) or bid (buy, offer) | ||
* Order side: listing (ask) or offer (bid) | ||
*/ | ||
var OrderSide; | ||
(function (OrderSide) { | ||
OrderSide["ASK"] = "ask"; | ||
OrderSide["BID"] = "bid"; | ||
OrderSide["LISTING"] = "ask"; | ||
OrderSide["OFFER"] = "bid"; | ||
})(OrderSide || (exports.OrderSide = OrderSide = {})); | ||
@@ -118,0 +118,0 @@ /** |
{ | ||
"name": "opensea-js", | ||
"version": "7.1.9", | ||
"version": "7.1.10", | ||
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data", | ||
@@ -65,3 +65,3 @@ "license": "MIT", | ||
"mocha": "^10.0.0", | ||
"nyc": "^15.1.0", | ||
"nyc": "^17.0.0", | ||
"prettier": "^3.0.0", | ||
@@ -68,0 +68,0 @@ "prettier-package-json": "^2.8.0", |
@@ -76,10 +76,2 @@ import { ethers } from "ethers"; | ||
function stall(duration: number): Promise<void> { | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, duration); | ||
}); | ||
} | ||
/** | ||
@@ -130,3 +122,3 @@ * The API class for the OpenSea SDK. | ||
* @param options | ||
* @param options.side The side of the order (buy or sell | ||
* @param options.side The side of the order (listing or offer) | ||
* @param options.protocol The protocol, typically seaport, to query orders for | ||
@@ -319,3 +311,3 @@ * @param options.orderDirection The direction to sort the orders | ||
let payload: object | null = null; | ||
if (side === OrderSide.ASK) { | ||
if (side === OrderSide.LISTING) { | ||
payload = getFulfillListingPayload( | ||
@@ -732,12 +724,3 @@ fulfillerAddress, | ||
// Set the throttle params | ||
// - Should be able to replace this retryFunc with `setThrottleParams({ slotInterval: 1000 })` | ||
// when this bug is fixed in ethers: https://github.com/ethers-io/ethers.js/issues/4663 | ||
req.retryFunc = async (_req, resp, attempt) => { | ||
this.logger( | ||
`Fetch attempt ${attempt} failed with status ${resp.statusCode}`, | ||
); | ||
// Wait 1s between tries | ||
await stall(1000); | ||
return true; | ||
}; | ||
req.setThrottleParams({ slotInterval: 1000 }); | ||
@@ -744,0 +727,0 @@ this.logger( |
@@ -9,3 +9,3 @@ import { OrderProtocol } from "../orders/types"; | ||
) => { | ||
const sidePath = side === OrderSide.ASK ? "listings" : "offers"; | ||
const sidePath = side === OrderSide.LISTING ? "listings" : "offers"; | ||
return `/v2/orders/${chain}/${protocol}/${sidePath}`; | ||
@@ -12,0 +12,0 @@ }; |
@@ -52,3 +52,3 @@ import { BasicOrderParametersStruct } from "@opensea/seaport-js/lib/typechain-types/seaport/contracts/Seaport"; | ||
takerFees: OrderFee[]; | ||
/** The side of the order. Ask/Bid */ | ||
/** The side of the order. Listing/Offer */ | ||
side: OrderSide; | ||
@@ -55,0 +55,0 @@ /** The type of the order. Basic/English/Criteria */ |
@@ -67,3 +67,3 @@ import { CROSS_CHAIN_SEAPORT_V1_6_ADDRESS } from "@opensea/seaport-js/lib/constants"; | ||
export const getFulfillmentDataPath = (side: OrderSide) => { | ||
const sidePath = side === OrderSide.ASK ? "listings" : "offers"; | ||
const sidePath = side === OrderSide.LISTING ? "listings" : "offers"; | ||
return `/v2/${sidePath}/fulfillment_data`; | ||
@@ -70,0 +70,0 @@ }; |
@@ -382,3 +382,3 @@ import EventEmitter = require("events"); | ||
const { basePrice } = await this._getPriceParameters( | ||
OrderSide.BID, | ||
OrderSide.OFFER, | ||
paymentTokenAddress, | ||
@@ -429,3 +429,3 @@ expirationTime ?? getMaxOrderExpirationTimestamp(), | ||
protocolAddress: DEFAULT_SEAPORT_CONTRACT_ADDRESS, | ||
side: OrderSide.BID, | ||
side: OrderSide.OFFER, | ||
}); | ||
@@ -498,3 +498,3 @@ } | ||
const { basePrice, endPrice } = await this._getPriceParameters( | ||
OrderSide.ASK, | ||
OrderSide.LISTING, | ||
paymentTokenAddress, | ||
@@ -555,3 +555,3 @@ expirationTime ?? getMaxOrderExpirationTimestamp(), | ||
protocolAddress: DEFAULT_SEAPORT_CONTRACT_ADDRESS, | ||
side: OrderSide.ASK, | ||
side: OrderSide.LISTING, | ||
}); | ||
@@ -624,3 +624,3 @@ } | ||
const { basePrice } = await this._getPriceParameters( | ||
OrderSide.ASK, | ||
OrderSide.LISTING, | ||
paymentTokenAddress, | ||
@@ -772,4 +772,4 @@ expirationTime ?? getMaxOrderExpirationTimestamp(), | ||
([OrderType.BASIC, OrderType.ENGLISH].includes((order as Listing).type) | ||
? OrderSide.ASK | ||
: OrderSide.BID); | ||
? OrderSide.LISTING | ||
: OrderSide.OFFER); | ||
@@ -1270,3 +1270,3 @@ let extraData: string | undefined = undefined; | ||
} | ||
if (isEther && orderSide === OrderSide.BID) { | ||
if (isEther && orderSide === OrderSide.OFFER) { | ||
throw new Error("Offers must use wrapped ETH or an ERC-20 token."); | ||
@@ -1302,2 +1302,4 @@ } | ||
availableAccounts.push(...addresses); | ||
} else if ("getAddress" in this._signerOrProvider) { | ||
availableAccounts.push(await this._signerOrProvider.getAddress()); | ||
} | ||
@@ -1304,0 +1306,0 @@ |
@@ -154,7 +154,7 @@ import { BigNumberish } from "ethers"; | ||
/** | ||
* Order side: ask (sell, listing) or bid (buy, offer) | ||
* Order side: listing (ask) or offer (bid) | ||
*/ | ||
export enum OrderSide { | ||
ASK = "ask", | ||
BID = "bid", | ||
LISTING = "ask", | ||
OFFER = "bid", | ||
} | ||
@@ -161,0 +161,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
511984
12620