opensea-js 6.0.6 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api.d.ts +160 -0
- package/lib/api/api.js +380 -0
- package/lib/api/api.js.map +1 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +18 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/types.d.ts +52 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/bundle.js +747 -357
- package/lib/constants.d.ts +1 -9
- package/lib/constants.js +3 -11
- package/lib/constants.js.map +1 -1
- package/lib/orders/types.d.ts +1 -29
- package/lib/orders/utils.d.ts +6 -2
- package/lib/orders/utils.js +20 -12
- package/lib/orders/utils.js.map +1 -1
- package/lib/sdk.d.ts +3 -2
- package/lib/sdk.js +14 -10
- package/lib/sdk.js.map +1 -1
- package/lib/types.d.ts +20 -2
- package/lib/types.js +21 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/utils.d.ts +8 -5
- package/lib/utils/utils.js +39 -5
- package/lib/utils/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/{api.ts → api/api.ts} +138 -16
- package/src/api/index.ts +1 -0
- package/src/api/types.ts +61 -0
- package/src/constants.ts +2 -13
- package/src/orders/types.ts +1 -39
- package/src/orders/utils.ts +27 -11
- package/src/sdk.ts +22 -18
- package/src/types.ts +22 -1
- package/src/utils/utils.ts +38 -6
- package/src/utils/tokens/goerli.ts +0 -11
- package/src/utils/tokens/index.ts +0 -29
- package/src/utils/tokens/main.ts +0 -11
package/lib/api/api.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { BuildOfferResponse, PostOfferResponse, ListNFTsResponse, GetNFTResponse } from "./types";
|
|
3
|
+
import { FulfillmentDataResponse, OrderAPIOptions, OrderSide, OrdersQueryOptions, OrderV2, ProtocolData, QueryCursors } from "../orders/types";
|
|
4
|
+
import { Chain, OpenSeaAPIConfig, OpenSeaAsset, OpenSeaAssetBundle, OpenSeaAssetBundleQuery, OpenSeaAssetQuery, OpenSeaCollection, OpenSeaFungibleToken, OpenSeaFungibleTokenQuery } from "../types";
|
|
5
|
+
export declare class OpenSeaAPI {
|
|
6
|
+
/**
|
|
7
|
+
* Base url for the API
|
|
8
|
+
*/
|
|
9
|
+
readonly apiBaseUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* Page size to use for fetching orders
|
|
12
|
+
*/
|
|
13
|
+
pageSize: number;
|
|
14
|
+
/**
|
|
15
|
+
* Logger function to use when debugging
|
|
16
|
+
*/
|
|
17
|
+
logger: (arg: string) => void;
|
|
18
|
+
private apiKey;
|
|
19
|
+
private chain;
|
|
20
|
+
private retryDelay;
|
|
21
|
+
/**
|
|
22
|
+
* Create an instance of the OpenSea API
|
|
23
|
+
* @param config OpenSeaAPIConfig for setting up the API, including an optional API key, Chain name, and base URL
|
|
24
|
+
* @param logger Optional function for logging debug strings before and after requests are made
|
|
25
|
+
*/
|
|
26
|
+
constructor(config: OpenSeaAPIConfig, logger?: (arg: string) => void);
|
|
27
|
+
/**
|
|
28
|
+
* Gets an order from API based on query options. Throws when no order is found.
|
|
29
|
+
*/
|
|
30
|
+
getOrder({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<OrderV2>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets a list of orders from API based on query options and returns orders
|
|
33
|
+
* with next and previous cursors.
|
|
34
|
+
*/
|
|
35
|
+
getOrders({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<QueryCursors & {
|
|
36
|
+
orders: OrderV2[];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Generate the data needed to fulfill a listing or an offer
|
|
40
|
+
*/
|
|
41
|
+
generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide): Promise<FulfillmentDataResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Send an order to be posted. Throws when the order is invalid.
|
|
44
|
+
*/
|
|
45
|
+
postOrder(order: ProtocolData, apiOptions: OrderAPIOptions, { retries }?: {
|
|
46
|
+
retries?: number;
|
|
47
|
+
}): Promise<OrderV2>;
|
|
48
|
+
/**
|
|
49
|
+
* Build an offer
|
|
50
|
+
*/
|
|
51
|
+
buildOffer(offererAddress: string, quantity: number, collectionSlug: string): Promise<BuildOfferResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Post collection offer
|
|
54
|
+
*/
|
|
55
|
+
postCollectionOffer(order: ProtocolData, slug: string, retries?: number): Promise<PostOfferResponse | null>;
|
|
56
|
+
/**
|
|
57
|
+
* Fetch an asset from the API, throwing if none is found
|
|
58
|
+
* @param tokenAddress Address of the asset's contract
|
|
59
|
+
* @param tokenId The asset's token ID, or null if ERC-20
|
|
60
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
61
|
+
*/
|
|
62
|
+
getAsset({ tokenAddress, tokenId, }: {
|
|
63
|
+
tokenAddress: string;
|
|
64
|
+
tokenId: string | number | null;
|
|
65
|
+
}, retries?: number): Promise<OpenSeaAsset>;
|
|
66
|
+
/**
|
|
67
|
+
* Fetch multiple NFTs for a collection from the API
|
|
68
|
+
* @param slug The collection you would like to list NFTs for
|
|
69
|
+
* @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
|
|
70
|
+
* @param next Cursor to retrieve the next page of NFTs
|
|
71
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
72
|
+
*/
|
|
73
|
+
getNFTsByCollection(slug: string, limit?: number | undefined, next?: string | undefined, retries?: number): Promise<ListNFTsResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Fetch multiple NFTs for a contract from the API
|
|
76
|
+
* @param chain chain the contract is deployed to
|
|
77
|
+
* @param address address of the smart contract
|
|
78
|
+
* @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
|
|
79
|
+
* @param next Cursor to retrieve the next page of NFTs
|
|
80
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
81
|
+
*/
|
|
82
|
+
getNFTsByContract(chain: Chain, address: string, limit?: number | undefined, next?: string | undefined, retries?: number): Promise<ListNFTsResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Fetch metadata, traits, ownership information, and rarity for an NFT from the API
|
|
85
|
+
* @param chain chain the contract is deployed to
|
|
86
|
+
* @param address address of the smart contract
|
|
87
|
+
* @param identifierthe identifier of the NFT (i.e. token_id)
|
|
88
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
89
|
+
*/
|
|
90
|
+
getNFT(chain: Chain, address: string, identifier: string, retries?: number): Promise<GetNFTResponse>;
|
|
91
|
+
/**
|
|
92
|
+
* Fetch list of assets from the API, returning the page of assets and the count of total assets
|
|
93
|
+
* @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetJSON` type is supported
|
|
94
|
+
*/
|
|
95
|
+
getAssets(query?: OpenSeaAssetQuery): Promise<{
|
|
96
|
+
assets: OpenSeaAsset[];
|
|
97
|
+
estimatedCount: number;
|
|
98
|
+
next: string | undefined;
|
|
99
|
+
previous: string | undefined;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Fetch a collection through the API
|
|
103
|
+
*/
|
|
104
|
+
getCollection(slug: string): Promise<OpenSeaCollection>;
|
|
105
|
+
/**
|
|
106
|
+
* Fetch list of fungible tokens from the API matching parameters
|
|
107
|
+
* @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetJSON` type is supported
|
|
108
|
+
* @param page Page number, defaults to 1. Can be overridden by
|
|
109
|
+
* `limit` and `offset` attributes from OpenSeaFungibleTokenQuery
|
|
110
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
111
|
+
*/
|
|
112
|
+
getPaymentTokens(query?: OpenSeaFungibleTokenQuery, page?: number, retries?: number): Promise<{
|
|
113
|
+
tokens: OpenSeaFungibleToken[];
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Fetch a bundle from the API, return null if it isn't found
|
|
117
|
+
* @param slug The bundle's identifier
|
|
118
|
+
*/
|
|
119
|
+
getBundle({ slug, }: {
|
|
120
|
+
slug: string;
|
|
121
|
+
}): Promise<OpenSeaAssetBundle | null>;
|
|
122
|
+
/**
|
|
123
|
+
* Fetch list of bundles from the API, returning the page of bundles and the count of total bundles
|
|
124
|
+
* @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetBundleJSON` type is supported
|
|
125
|
+
* @param page Page number, defaults to 1. Can be overridden by
|
|
126
|
+
* `limit` and `offset` attributes from OpenSeaAssetBundleQuery
|
|
127
|
+
*/
|
|
128
|
+
getBundles(query?: OpenSeaAssetBundleQuery, page?: number): Promise<{
|
|
129
|
+
bundles: OpenSeaAssetBundle[];
|
|
130
|
+
estimatedCount: number;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Used to force refresh the metadata for an NFT from the API
|
|
134
|
+
* @param chain chain the contract is deployed to
|
|
135
|
+
* @param address address of the smart contract
|
|
136
|
+
* @param identifierthe identifier of the NFT (i.e. token_id)
|
|
137
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
138
|
+
*/
|
|
139
|
+
refreshNFTMetadata(chain: Chain, address: string, identifier: string, retries?: number): Promise<unknown>;
|
|
140
|
+
/**
|
|
141
|
+
* Get JSON data from API, sending auth token in headers
|
|
142
|
+
* @param apiPath Path to URL endpoint under API
|
|
143
|
+
* @param query Data to send. Will be stringified using QueryString
|
|
144
|
+
*/
|
|
145
|
+
get<T>(apiPath: string, query?: object): Promise<T>;
|
|
146
|
+
/**
|
|
147
|
+
* POST JSON data to API, sending auth token in headers
|
|
148
|
+
* @param apiPath Path to URL endpoint under API
|
|
149
|
+
* @param body Data to send. Will be JSON.stringified
|
|
150
|
+
* @param opts ethers ConnectionInfo, similar to Fetch API.
|
|
151
|
+
*/
|
|
152
|
+
post<T>(apiPath: string, body?: object, opts?: ethers.utils.ConnectionInfo): Promise<T>;
|
|
153
|
+
private objectToSearchParams;
|
|
154
|
+
/**
|
|
155
|
+
* Get from an API Endpoint, sending auth token in headers
|
|
156
|
+
* @param opts ethers ConnectionInfo, similar to Fetch API
|
|
157
|
+
* @param body Optional body to send. If set, will POST, otherwise GET
|
|
158
|
+
*/
|
|
159
|
+
private _fetch;
|
|
160
|
+
}
|
package/lib/api/api.js
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.OpenSeaAPI = void 0;
|
|
24
|
+
const ethers_1 = require("ethers");
|
|
25
|
+
const constants_1 = require("../constants");
|
|
26
|
+
const utils_1 = require("../orders/utils");
|
|
27
|
+
const types_1 = require("../types");
|
|
28
|
+
const utils_2 = require("../utils/utils");
|
|
29
|
+
class OpenSeaAPI {
|
|
30
|
+
/**
|
|
31
|
+
* Create an instance of the OpenSea API
|
|
32
|
+
* @param config OpenSeaAPIConfig for setting up the API, including an optional API key, Chain name, and base URL
|
|
33
|
+
* @param logger Optional function for logging debug strings before and after requests are made
|
|
34
|
+
*/
|
|
35
|
+
constructor(config, logger) {
|
|
36
|
+
var _a;
|
|
37
|
+
/**
|
|
38
|
+
* Page size to use for fetching orders
|
|
39
|
+
*/
|
|
40
|
+
this.pageSize = 20;
|
|
41
|
+
this.retryDelay = 3000;
|
|
42
|
+
this.apiKey = config.apiKey;
|
|
43
|
+
this.chain = (_a = config.chain) !== null && _a !== void 0 ? _a : types_1.Chain.Mainnet;
|
|
44
|
+
this.apiBaseUrl = (0, utils_2.isTestChain)(this.chain)
|
|
45
|
+
? constants_1.API_BASE_TESTNET
|
|
46
|
+
: constants_1.API_BASE_MAINNET;
|
|
47
|
+
// Debugging: default to nothing
|
|
48
|
+
this.logger = logger !== null && logger !== void 0 ? logger : ((arg) => arg);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets an order from API based on query options. Throws when no order is found.
|
|
52
|
+
*/
|
|
53
|
+
getOrder(_a) {
|
|
54
|
+
var { side, protocol = "seaport", orderDirection = "desc", orderBy = "created_date" } = _a, restOptions = __rest(_a, ["side", "protocol", "orderDirection", "orderBy"]);
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const { orders } = yield this.get((0, utils_1.getOrdersAPIPath)(this.chain, protocol, side), (0, utils_1.serializeOrdersQueryOptions)(Object.assign({ limit: 1, orderBy,
|
|
57
|
+
orderDirection }, restOptions)));
|
|
58
|
+
if (orders.length === 0) {
|
|
59
|
+
throw new Error("Not found: no matching order found");
|
|
60
|
+
}
|
|
61
|
+
return (0, utils_1.deserializeOrder)(orders[0]);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets a list of orders from API based on query options and returns orders
|
|
66
|
+
* with next and previous cursors.
|
|
67
|
+
*/
|
|
68
|
+
getOrders(_a) {
|
|
69
|
+
var { side, protocol = "seaport", orderDirection = "desc", orderBy = "created_date" } = _a, restOptions = __rest(_a, ["side", "protocol", "orderDirection", "orderBy"]);
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const response = yield this.get((0, utils_1.getOrdersAPIPath)(this.chain, protocol, side), (0, utils_1.serializeOrdersQueryOptions)(Object.assign({ limit: this.pageSize, orderBy,
|
|
72
|
+
orderDirection }, restOptions)));
|
|
73
|
+
return Object.assign(Object.assign({}, response), { orders: response.orders.map(utils_1.deserializeOrder) });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Generate the data needed to fulfill a listing or an offer
|
|
78
|
+
*/
|
|
79
|
+
generateFulfillmentData(fulfillerAddress, orderHash, protocolAddress, side) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
let payload = null;
|
|
82
|
+
if (side === "ask") {
|
|
83
|
+
payload = (0, utils_1.getFulfillListingPayload)(fulfillerAddress, orderHash, protocolAddress, this.chain);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
payload = (0, utils_1.getFulfillOfferPayload)(fulfillerAddress, orderHash, protocolAddress, this.chain);
|
|
87
|
+
}
|
|
88
|
+
const response = yield this.post((0, utils_1.getFulfillmentDataPath)(side), payload);
|
|
89
|
+
return response;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Send an order to be posted. Throws when the order is invalid.
|
|
94
|
+
*/
|
|
95
|
+
postOrder(order, apiOptions, { retries = 2 } = {}) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
let response;
|
|
98
|
+
// TODO: Validate apiOptions. Avoid API calls that will definitely fail
|
|
99
|
+
const { protocol = "seaport", side, protocolAddress } = apiOptions;
|
|
100
|
+
try {
|
|
101
|
+
response = yield this.post((0, utils_1.getOrdersAPIPath)(this.chain, protocol, side), Object.assign(Object.assign({}, order), { protocol_address: protocolAddress }));
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
_throwOrContinue(error, retries);
|
|
105
|
+
yield (0, utils_2.delay)(this.retryDelay);
|
|
106
|
+
return this.postOrder(order, apiOptions, { retries: retries - 1 });
|
|
107
|
+
}
|
|
108
|
+
return (0, utils_1.deserializeOrder)(response.order);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Build an offer
|
|
113
|
+
*/
|
|
114
|
+
buildOffer(offererAddress, quantity, collectionSlug) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
const payload = (0, utils_1.getBuildCollectionOfferPayload)(offererAddress, quantity, collectionSlug);
|
|
117
|
+
const response = yield this.post((0, utils_1.getBuildOfferPath)(), payload);
|
|
118
|
+
return response;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Post collection offer
|
|
123
|
+
*/
|
|
124
|
+
postCollectionOffer(order, slug, retries = 0) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const payload = (0, utils_1.getPostCollectionOfferPayload)(slug, order);
|
|
127
|
+
try {
|
|
128
|
+
return yield this.post((0, utils_1.getPostCollectionOfferPath)(), payload);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
_throwOrContinue(error, retries);
|
|
132
|
+
yield (0, utils_2.delay)(1000);
|
|
133
|
+
return this.postCollectionOffer(order, slug, retries - 1);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fetch an asset from the API, throwing if none is found
|
|
139
|
+
* @param tokenAddress Address of the asset's contract
|
|
140
|
+
* @param tokenId The asset's token ID, or null if ERC-20
|
|
141
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
142
|
+
*/
|
|
143
|
+
getAsset({ tokenAddress, tokenId, }, retries = 1) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
let json;
|
|
146
|
+
try {
|
|
147
|
+
json = yield this.get(`${constants_1.API_PATH}/asset/${tokenAddress}/${tokenId !== null && tokenId !== void 0 ? tokenId : 0}/`);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
_throwOrContinue(error, retries);
|
|
151
|
+
yield (0, utils_2.delay)(1000);
|
|
152
|
+
return this.getAsset({ tokenAddress, tokenId }, retries - 1);
|
|
153
|
+
}
|
|
154
|
+
return (0, utils_2.assetFromJSON)(json);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Fetch multiple NFTs for a collection from the API
|
|
159
|
+
* @param slug The collection you would like to list NFTs for
|
|
160
|
+
* @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
|
|
161
|
+
* @param next Cursor to retrieve the next page of NFTs
|
|
162
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
163
|
+
*/
|
|
164
|
+
getNFTsByCollection(slug, limit = undefined, next = undefined, retries = 1) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
let response;
|
|
167
|
+
try {
|
|
168
|
+
response = yield this.get((0, utils_1.getListNFTsByCollectionPath)(slug), {
|
|
169
|
+
limit,
|
|
170
|
+
next,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
_throwOrContinue(error, retries);
|
|
175
|
+
yield (0, utils_2.delay)(1000);
|
|
176
|
+
return this.getNFTsByCollection(slug, limit, next, retries - 1);
|
|
177
|
+
}
|
|
178
|
+
return response;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Fetch multiple NFTs for a contract from the API
|
|
183
|
+
* @param chain chain the contract is deployed to
|
|
184
|
+
* @param address address of the smart contract
|
|
185
|
+
* @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
|
|
186
|
+
* @param next Cursor to retrieve the next page of NFTs
|
|
187
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
188
|
+
*/
|
|
189
|
+
getNFTsByContract(chain, address, limit = undefined, next = undefined, retries = 1) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
let response;
|
|
192
|
+
try {
|
|
193
|
+
response = yield this.get((0, utils_1.getListNFTsByContractPath)(chain, address), {
|
|
194
|
+
limit,
|
|
195
|
+
next,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
_throwOrContinue(error, retries);
|
|
200
|
+
yield (0, utils_2.delay)(1000);
|
|
201
|
+
return this.getNFTsByContract(chain, address, limit, next, retries - 1);
|
|
202
|
+
}
|
|
203
|
+
return response;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Fetch metadata, traits, ownership information, and rarity for an NFT from the API
|
|
208
|
+
* @param chain chain the contract is deployed to
|
|
209
|
+
* @param address address of the smart contract
|
|
210
|
+
* @param identifierthe identifier of the NFT (i.e. token_id)
|
|
211
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
212
|
+
*/
|
|
213
|
+
getNFT(chain, address, identifier, retries = 1) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
let response;
|
|
216
|
+
try {
|
|
217
|
+
response = yield this.get((0, utils_1.getNFTPath)(chain, address, identifier));
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
_throwOrContinue(error, retries);
|
|
221
|
+
yield (0, utils_2.delay)(1000);
|
|
222
|
+
return this.getNFT(chain, address, identifier, retries - 1);
|
|
223
|
+
}
|
|
224
|
+
return response;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Fetch list of assets from the API, returning the page of assets and the count of total assets
|
|
229
|
+
* @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetJSON` type is supported
|
|
230
|
+
*/
|
|
231
|
+
getAssets(query = {}) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
const json = yield this.get(`${constants_1.API_PATH}/assets/`, Object.assign({ limit: this.pageSize }, query));
|
|
234
|
+
return {
|
|
235
|
+
assets: json.assets.map((j) => (0, utils_2.assetFromJSON)(j)),
|
|
236
|
+
next: json.next,
|
|
237
|
+
previous: json.previous,
|
|
238
|
+
estimatedCount: json.estimated_count,
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Fetch a collection through the API
|
|
244
|
+
*/
|
|
245
|
+
getCollection(slug) {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
const path = (0, utils_1.getCollectionPath)(slug);
|
|
248
|
+
const response = yield this.get(path);
|
|
249
|
+
return (0, utils_2.collectionFromJSON)(response.collection);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Fetch list of fungible tokens from the API matching parameters
|
|
254
|
+
* @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetJSON` type is supported
|
|
255
|
+
* @param page Page number, defaults to 1. Can be overridden by
|
|
256
|
+
* `limit` and `offset` attributes from OpenSeaFungibleTokenQuery
|
|
257
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
258
|
+
*/
|
|
259
|
+
getPaymentTokens(query = {}, page = 1, retries = 1) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
let json;
|
|
262
|
+
try {
|
|
263
|
+
json = yield this.get(`${constants_1.API_PATH}/tokens/`, Object.assign(Object.assign({}, query), { limit: this.pageSize, offset: (page - 1) * this.pageSize }));
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
_throwOrContinue(error, retries);
|
|
267
|
+
yield (0, utils_2.delay)(1000);
|
|
268
|
+
return this.getPaymentTokens(query, page, retries - 1);
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
tokens: json.map((t) => (0, utils_2.tokenFromJSON)(t)),
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Fetch a bundle from the API, return null if it isn't found
|
|
277
|
+
* @param slug The bundle's identifier
|
|
278
|
+
*/
|
|
279
|
+
getBundle({ slug, }) {
|
|
280
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
+
const json = yield this.get(`${constants_1.API_PATH}/bundle/${slug}/`);
|
|
282
|
+
return json ? (0, utils_2.assetBundleFromJSON)(json) : null;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Fetch list of bundles from the API, returning the page of bundles and the count of total bundles
|
|
287
|
+
* @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetBundleJSON` type is supported
|
|
288
|
+
* @param page Page number, defaults to 1. Can be overridden by
|
|
289
|
+
* `limit` and `offset` attributes from OpenSeaAssetBundleQuery
|
|
290
|
+
*/
|
|
291
|
+
getBundles(query = {}, page = 1) {
|
|
292
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
const json = yield this.get(`${constants_1.API_PATH}/bundles/`, Object.assign(Object.assign({}, query), { limit: this.pageSize, offset: (page - 1) * this.pageSize }));
|
|
294
|
+
return {
|
|
295
|
+
bundles: json.bundles.map((j) => (0, utils_2.assetBundleFromJSON)(j)),
|
|
296
|
+
estimatedCount: json.estimated_count,
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Used to force refresh the metadata for an NFT from the API
|
|
302
|
+
* @param chain chain the contract is deployed to
|
|
303
|
+
* @param address address of the smart contract
|
|
304
|
+
* @param identifierthe identifier of the NFT (i.e. token_id)
|
|
305
|
+
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
306
|
+
*/
|
|
307
|
+
refreshNFTMetadata(chain, address, identifier, retries = 1) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
let response;
|
|
310
|
+
try {
|
|
311
|
+
response = yield this.post((0, utils_1.getRefreshMetadataPath)(chain, address, identifier), {});
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
_throwOrContinue(error, retries);
|
|
315
|
+
yield (0, utils_2.delay)(1000);
|
|
316
|
+
return this.refreshNFTMetadata(chain, address, identifier, retries - 1);
|
|
317
|
+
}
|
|
318
|
+
return response;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Get JSON data from API, sending auth token in headers
|
|
323
|
+
* @param apiPath Path to URL endpoint under API
|
|
324
|
+
* @param query Data to send. Will be stringified using QueryString
|
|
325
|
+
*/
|
|
326
|
+
get(apiPath, query = {}) {
|
|
327
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
328
|
+
const qs = this.objectToSearchParams(query);
|
|
329
|
+
const url = `${this.apiBaseUrl}${apiPath}?${qs}`;
|
|
330
|
+
return yield this._fetch({ url });
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* POST JSON data to API, sending auth token in headers
|
|
335
|
+
* @param apiPath Path to URL endpoint under API
|
|
336
|
+
* @param body Data to send. Will be JSON.stringified
|
|
337
|
+
* @param opts ethers ConnectionInfo, similar to Fetch API.
|
|
338
|
+
*/
|
|
339
|
+
post(apiPath, body, opts) {
|
|
340
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
341
|
+
const options = Object.assign({ url: `${this.apiBaseUrl}${apiPath}` }, opts);
|
|
342
|
+
return yield this._fetch(options, body);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
objectToSearchParams(params = {}) {
|
|
346
|
+
const urlSearchParams = new URLSearchParams();
|
|
347
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
348
|
+
if (value && Array.isArray(value)) {
|
|
349
|
+
value.forEach((item) => item && urlSearchParams.append(key, item));
|
|
350
|
+
}
|
|
351
|
+
else if (value) {
|
|
352
|
+
urlSearchParams.append(key, value);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
return urlSearchParams.toString();
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get from an API Endpoint, sending auth token in headers
|
|
359
|
+
* @param opts ethers ConnectionInfo, similar to Fetch API
|
|
360
|
+
* @param body Optional body to send. If set, will POST, otherwise GET
|
|
361
|
+
*/
|
|
362
|
+
_fetch(opts, body) {
|
|
363
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
364
|
+
const headers = Object.assign(Object.assign({ "x-app-id": "opensea-js" }, (this.apiKey ? { "X-API-KEY": this.apiKey } : {})), opts.headers);
|
|
365
|
+
const req = Object.assign(Object.assign({}, opts), { headers });
|
|
366
|
+
this.logger(`Sending request: ${opts.url} ${JSON.stringify(req).slice(0, 200)}...`);
|
|
367
|
+
return yield ethers_1.ethers.utils.fetchJson(req, body ? JSON.stringify(body) : undefined);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
exports.OpenSeaAPI = OpenSeaAPI;
|
|
372
|
+
function _throwOrContinue(error, retries) {
|
|
373
|
+
const isUnavailable = error instanceof Error &&
|
|
374
|
+
!!error.message &&
|
|
375
|
+
(error.message.includes("503") || error.message.includes("429"));
|
|
376
|
+
if (retries <= 0 || !isUnavailable) {
|
|
377
|
+
throw error;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgC;AAQhC,4CAA4E;AAY5E,2CAgByB;AACzB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AAC,IAAiC,EAAE,IAAa;;YACnE,MAAM,OAAO,iCACX,UAAU,EAAE,YAAY,IACrB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACjD,IAAI,CAAC,OAAO,CAChB,CAAC;YACF,MAAM,GAAG,mCACJ,IAAI,KACP,OAAO,GACR,CAAC;YAEF,IAAI,CAAC,MAAM,CACT,oBAAoB,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CACvE,CAAC;YAEF,OAAO,MAAM,eAAM,CAAC,KAAK,CAAC,SAAS,CACjC,GAAG,EACH,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CACxC,CAAC;QACJ,CAAC;KAAA;CACF;AA/fD,gCA+fC;AAED,SAAS,gBAAgB,CAAC,KAAc,EAAE,OAAe;IACvD,MAAM,aAAa,GACjB,KAAK,YAAY,KAAK;QACtB,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAEnE,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;QAClC,MAAM,KAAK,CAAC;KACb;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
package/lib/api/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ConsiderationItem } from "@opensea/seaport-js/lib/types";
|
|
2
|
+
import { ProtocolData } from "src/orders/types";
|
|
3
|
+
export type BuildOfferResponse = {
|
|
4
|
+
partialParameters: PartialParameters;
|
|
5
|
+
};
|
|
6
|
+
type PartialParameters = {
|
|
7
|
+
consideration: ConsiderationItem[];
|
|
8
|
+
zone: string;
|
|
9
|
+
zoneHash: string;
|
|
10
|
+
};
|
|
11
|
+
type Criteria = {
|
|
12
|
+
collection: CollectionCriteria;
|
|
13
|
+
contract?: ContractCriteria;
|
|
14
|
+
};
|
|
15
|
+
type CollectionCriteria = {
|
|
16
|
+
slug: string;
|
|
17
|
+
};
|
|
18
|
+
type ContractCriteria = {
|
|
19
|
+
address: string;
|
|
20
|
+
};
|
|
21
|
+
export type GetCollectionResponse = {
|
|
22
|
+
collection: object;
|
|
23
|
+
};
|
|
24
|
+
export type PostOfferResponse = {
|
|
25
|
+
order_hash: string;
|
|
26
|
+
chain: string;
|
|
27
|
+
criteria: Criteria;
|
|
28
|
+
protocol_data: ProtocolData;
|
|
29
|
+
protocol_address: string;
|
|
30
|
+
};
|
|
31
|
+
export type ListNFTsResponse = {
|
|
32
|
+
nfts: NFT[];
|
|
33
|
+
next: string;
|
|
34
|
+
};
|
|
35
|
+
export type GetNFTResponse = {
|
|
36
|
+
nft: NFT;
|
|
37
|
+
};
|
|
38
|
+
type NFT = {
|
|
39
|
+
identifier: string;
|
|
40
|
+
collection: string;
|
|
41
|
+
contract: string;
|
|
42
|
+
token_standard: string;
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
image_url: string;
|
|
46
|
+
metadata_url: string;
|
|
47
|
+
created_at: string;
|
|
48
|
+
updated_at: string;
|
|
49
|
+
is_disabled: boolean;
|
|
50
|
+
is_nsfw: boolean;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
package/lib/api/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":""}
|