@opensea/sdk 12.1.0 → 12.1.1
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/README.md +2 -2
- package/lib/api/accounts.js +1 -1
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +10 -0
- package/lib/api/api.js +20 -3
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +17 -0
- package/lib/api/apiPaths.js +87 -63
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/walletAuth.js +31 -31
- package/lib/api/walletAuth.js.map +1 -1
- package/lib/types.d.ts +11 -3
- package/package.json +2 -2
- package/src/api/accounts.ts +1 -1
- package/src/api/api.ts +33 -3
- package/src/api/apiPaths.ts +87 -61
- package/src/api/walletAuth.ts +1 -2
- package/src/types.ts +12 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletAuth.js","sourceRoot":"","sources":["../../src/api/walletAuth.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"walletAuth.js","sourceRoot":"","sources":["../../src/api/walletAuth.ts"],"names":[],"mappings":";;;AAOA,yCAAoC;AAcpC,8DAA8D;AAC9D,MAAa,aAAa;IACJ;IAApB,YAAoB,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAElD,kBAAkB,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,iBAAiB,IAAA,kBAAO,EAAC,IAAI,CAAC,cAAc,CAC7C,CAAA;IACH,CAAC;IAED,YAAY,CACV,OAAe,EACf,KAAgD;QAEhD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,mBAAmB,IAAA,kBAAO,EAAC,OAAO,CAAC,YAAY,EAC/C,KAAK,CACN,CAAA;IACH,CAAC;IAED,iBAAiB,CAAC,OAAe;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,mBAAmB,IAAA,k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
260
|
*/
|
|
261
261
|
export type SocialMediaAccount = Camelize<ApiSocialMediaAccount>;
|
|
262
262
|
/**
|
|
263
|
-
*
|
|
263
|
+
* Error thrown for any non-OK API response. `statusCode` is always set, so a caller can separate
|
|
264
|
+
* a retryable failure from a permanent one without parsing the message. That matters for clients
|
|
265
|
+
* that scrub remote error text before surfacing it, which have no other way to recover the status.
|
|
264
266
|
* @category API Models
|
|
265
267
|
*/
|
|
266
|
-
export interface
|
|
268
|
+
export interface OpenSeaApiError extends Error {
|
|
267
269
|
/** The HTTP status code of the error response */
|
|
268
270
|
statusCode?: number;
|
|
269
|
-
/** The number of seconds to wait before retrying the request */
|
|
271
|
+
/** The number of seconds to wait before retrying the request, on rate limit responses */
|
|
270
272
|
retryAfter?: number;
|
|
271
273
|
/** The response body from the API */
|
|
272
274
|
responseBody?: unknown;
|
|
273
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* @deprecated Use {@link OpenSeaApiError}. Retained as an alias: the shape is identical and
|
|
278
|
+
* `retryAfter` was always optional, so existing rate-limit handling is unaffected.
|
|
279
|
+
* @category API Models
|
|
280
|
+
*/
|
|
281
|
+
export type OpenSeaRateLimitError = OpenSeaApiError;
|
|
274
282
|
/**
|
|
275
283
|
* Options for controlling HTTP request behavior.
|
|
276
284
|
* @category API Models
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensea/sdk",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs, tokens, and our marketplace data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "OpenSea Developers",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"types": "lib/index.d.ts",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@noble/hashes": "^2.0.1",
|
|
50
|
-
"@opensea/api-types": "^0.9.
|
|
50
|
+
"@opensea/api-types": "^0.9.2",
|
|
51
51
|
"@opensea/seaport-js": "^4.2.0",
|
|
52
52
|
"ethers": "^6.16.0"
|
|
53
53
|
},
|
package/src/api/accounts.ts
CHANGED
|
@@ -88,7 +88,7 @@ export class AccountsAPI {
|
|
|
88
88
|
addressOrUsername: string,
|
|
89
89
|
): Promise<AgentProfileRelationshipsResponse> {
|
|
90
90
|
return this.fetcher.get<AgentProfileRelationshipsResponse>(
|
|
91
|
-
getAgentProfileRelationshipsPath(
|
|
91
|
+
getAgentProfileRelationshipsPath(addressOrUsername),
|
|
92
92
|
)
|
|
93
93
|
}
|
|
94
94
|
|
package/src/api/api.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Chain,
|
|
5
5
|
type OpenSeaAccount,
|
|
6
6
|
type OpenSeaAPIConfig,
|
|
7
|
+
type OpenSeaApiError,
|
|
7
8
|
type OpenSeaCollection,
|
|
8
9
|
type OpenSeaCollectionStats,
|
|
9
10
|
type OpenSeaPaymentToken,
|
|
@@ -1634,10 +1635,16 @@ export class OpenSeaAPI {
|
|
|
1634
1635
|
: typeof errors === "string"
|
|
1635
1636
|
? errors
|
|
1636
1637
|
: JSON.stringify(errors)
|
|
1637
|
-
throw
|
|
1638
|
+
throw OpenSeaAPI._createApiError(
|
|
1639
|
+
response,
|
|
1640
|
+
`Server Error: ${errorMessage}`,
|
|
1641
|
+
responseBody,
|
|
1642
|
+
)
|
|
1638
1643
|
}
|
|
1639
|
-
throw
|
|
1644
|
+
throw OpenSeaAPI._createApiError(
|
|
1645
|
+
response,
|
|
1640
1646
|
`Server Error (${response.status}): ${response.statusText}`,
|
|
1647
|
+
responseBody,
|
|
1641
1648
|
)
|
|
1642
1649
|
}
|
|
1643
1650
|
if (
|
|
@@ -1685,7 +1692,8 @@ export class OpenSeaAPI {
|
|
|
1685
1692
|
body: "{}",
|
|
1686
1693
|
})
|
|
1687
1694
|
if (!response.ok) {
|
|
1688
|
-
throw
|
|
1695
|
+
throw OpenSeaAPI._createApiError(
|
|
1696
|
+
response,
|
|
1689
1697
|
`Server Error (${response.status}): ${response.statusText}`,
|
|
1690
1698
|
)
|
|
1691
1699
|
}
|
|
@@ -1744,6 +1752,28 @@ export class OpenSeaAPI {
|
|
|
1744
1752
|
* @param response The HTTP response object from the API
|
|
1745
1753
|
* @returns An enhanced Error object with statusCode, retryAfter and responseBody properties
|
|
1746
1754
|
*/
|
|
1755
|
+
/**
|
|
1756
|
+
* Builds an error carrying the HTTP status. Every non-OK response goes through here or through
|
|
1757
|
+
* {@link _createRateLimitError}, so `statusCode` is present on every API error rather than only
|
|
1758
|
+
* on rate limits. A caller that scrubs remote error text still has the status to retry on.
|
|
1759
|
+
* @param response The HTTP response object from the API
|
|
1760
|
+
* @param message The error message
|
|
1761
|
+
* @param responseBody The already-parsed body, when the caller read one
|
|
1762
|
+
* @returns An Error with `statusCode` and, when available, `responseBody`
|
|
1763
|
+
*/
|
|
1764
|
+
private static _createApiError(
|
|
1765
|
+
response: Response,
|
|
1766
|
+
message: string,
|
|
1767
|
+
responseBody?: unknown,
|
|
1768
|
+
): OpenSeaApiError {
|
|
1769
|
+
const error = new Error(message) as OpenSeaApiError
|
|
1770
|
+
error.statusCode = response.status
|
|
1771
|
+
if (responseBody !== undefined) {
|
|
1772
|
+
error.responseBody = responseBody
|
|
1773
|
+
}
|
|
1774
|
+
return error
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1747
1777
|
private async _createRateLimitError(
|
|
1748
1778
|
response: Response,
|
|
1749
1779
|
): Promise<OpenSeaRateLimitError> {
|
package/src/api/apiPaths.ts
CHANGED
|
@@ -4,42 +4,68 @@ import type { Chain } from "../types"
|
|
|
4
4
|
/** Base path prefix for all OpenSea API v2 endpoints. */
|
|
5
5
|
export const API_V2_PREFIX = "/api/v2"
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Encodes a single path segment.
|
|
9
|
+
*
|
|
10
|
+
* Every builder below interpolates caller-supplied values into a URL path. Without encoding, a
|
|
11
|
+
* value containing `/` re-targets the request at a different endpoint once the URL is normalized,
|
|
12
|
+
* and a consumer that caches by path collides with the endpoint it lands on. Encoding is a no-op
|
|
13
|
+
* for every legitimate value: collection slugs, hex addresses, base58 addresses, token ids and
|
|
14
|
+
* transaction hashes all survive `encodeURIComponent` unchanged.
|
|
15
|
+
*
|
|
16
|
+
* `.` and `..` are rejected rather than encoded, because encoding cannot neutralize them. The
|
|
17
|
+
* WHATWG URL parser decodes percent-escapes before it removes dot segments, so `%2E%2E` collapses
|
|
18
|
+
* exactly as `..` does, and there is no spelling of a bare dot segment that survives as a literal.
|
|
19
|
+
* No collection slug, address, token id or transaction hash is `.` or `..`, so a caller reaching
|
|
20
|
+
* this is passing through unvalidated input and should hear about it rather than silently request
|
|
21
|
+
* a different endpoint.
|
|
22
|
+
*/
|
|
23
|
+
export const segment = (value: string | number) => {
|
|
24
|
+
const raw = String(value)
|
|
25
|
+
if (raw === "." || raw === "..") {
|
|
26
|
+
throw new RangeError(
|
|
27
|
+
`Invalid path segment: ${JSON.stringify(raw)} would traverse to a different endpoint`,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
return encodeURIComponent(raw)
|
|
31
|
+
}
|
|
32
|
+
|
|
7
33
|
export const getPostListingPath = (chain: Chain, protocol: OrderProtocol) => {
|
|
8
|
-
return `${API_V2_PREFIX}/orders/${chain}/${protocol}/listings`
|
|
34
|
+
return `${API_V2_PREFIX}/orders/${segment(chain)}/${segment(protocol)}/listings`
|
|
9
35
|
}
|
|
10
36
|
|
|
11
37
|
export const getPostOfferPath = (chain: Chain, protocol: OrderProtocol) => {
|
|
12
|
-
return `${API_V2_PREFIX}/orders/${chain}/${protocol}/offers`
|
|
38
|
+
return `${API_V2_PREFIX}/orders/${segment(chain)}/${segment(protocol)}/offers`
|
|
13
39
|
}
|
|
14
40
|
|
|
15
41
|
export const getAllOffersAPIPath = (collectionSlug: string) => {
|
|
16
|
-
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/all`
|
|
42
|
+
return `${API_V2_PREFIX}/offers/collection/${segment(collectionSlug)}/all`
|
|
17
43
|
}
|
|
18
44
|
|
|
19
45
|
export const getAllListingsAPIPath = (collectionSlug: string) => {
|
|
20
|
-
return `${API_V2_PREFIX}/listings/collection/${collectionSlug}/all`
|
|
46
|
+
return `${API_V2_PREFIX}/listings/collection/${segment(collectionSlug)}/all`
|
|
21
47
|
}
|
|
22
48
|
|
|
23
49
|
export const getBestOfferAPIPath = (
|
|
24
50
|
collectionSlug: string,
|
|
25
51
|
tokenId: string | number,
|
|
26
52
|
) => {
|
|
27
|
-
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/nfts/${tokenId}/best`
|
|
53
|
+
return `${API_V2_PREFIX}/offers/collection/${segment(collectionSlug)}/nfts/${segment(tokenId)}/best`
|
|
28
54
|
}
|
|
29
55
|
|
|
30
56
|
export const getBestListingAPIPath = (
|
|
31
57
|
collectionSlug: string,
|
|
32
58
|
tokenId: string | number,
|
|
33
59
|
) => {
|
|
34
|
-
return `${API_V2_PREFIX}/listings/collection/${collectionSlug}/nfts/${tokenId}/best`
|
|
60
|
+
return `${API_V2_PREFIX}/listings/collection/${segment(collectionSlug)}/nfts/${segment(tokenId)}/best`
|
|
35
61
|
}
|
|
36
62
|
|
|
37
63
|
export const getBestListingsAPIPath = (collectionSlug: string) => {
|
|
38
|
-
return `${API_V2_PREFIX}/listings/collection/${collectionSlug}/best`
|
|
64
|
+
return `${API_V2_PREFIX}/listings/collection/${segment(collectionSlug)}/best`
|
|
39
65
|
}
|
|
40
66
|
|
|
41
67
|
export const getCollectionPath = (slug: string) => {
|
|
42
|
-
return `${API_V2_PREFIX}/collections/${slug}`
|
|
68
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}`
|
|
43
69
|
}
|
|
44
70
|
|
|
45
71
|
export const getCollectionsPath = () => {
|
|
@@ -47,19 +73,19 @@ export const getCollectionsPath = () => {
|
|
|
47
73
|
}
|
|
48
74
|
|
|
49
75
|
export const getCollectionStatsPath = (slug: string) => {
|
|
50
|
-
return `${API_V2_PREFIX}/collections/${slug}/stats`
|
|
76
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}/stats`
|
|
51
77
|
}
|
|
52
78
|
|
|
53
79
|
export const getPaymentTokenPath = (chain: Chain, address: string) => {
|
|
54
|
-
return `${API_V2_PREFIX}/chain/${chain}/payment_token/${address}`
|
|
80
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/payment_token/${segment(address)}`
|
|
55
81
|
}
|
|
56
82
|
|
|
57
83
|
export const getAccountPath = (address: string) => {
|
|
58
|
-
return `${API_V2_PREFIX}/accounts/${address}`
|
|
84
|
+
return `${API_V2_PREFIX}/accounts/${segment(address)}`
|
|
59
85
|
}
|
|
60
86
|
|
|
61
87
|
export const getAgentProfileRelationshipsPath = (addressOrUsername: string) => {
|
|
62
|
-
return `${API_V2_PREFIX}/accounts/${addressOrUsername}/agent-relationships`
|
|
88
|
+
return `${API_V2_PREFIX}/accounts/${segment(addressOrUsername)}/agent-relationships`
|
|
63
89
|
}
|
|
64
90
|
|
|
65
91
|
export const getBuildOfferPath = () => {
|
|
@@ -71,19 +97,19 @@ export const getPostCollectionOfferPath = () => {
|
|
|
71
97
|
}
|
|
72
98
|
|
|
73
99
|
export const getCollectionOffersPath = (slug: string) => {
|
|
74
|
-
return `${API_V2_PREFIX}/offers/collection/${slug}`
|
|
100
|
+
return `${API_V2_PREFIX}/offers/collection/${segment(slug)}`
|
|
75
101
|
}
|
|
76
102
|
|
|
77
103
|
export const getListNFTsByCollectionPath = (slug: string) => {
|
|
78
|
-
return `${API_V2_PREFIX}/collection/${slug}/nfts`
|
|
104
|
+
return `${API_V2_PREFIX}/collection/${segment(slug)}/nfts`
|
|
79
105
|
}
|
|
80
106
|
|
|
81
107
|
export const getListNFTsByContractPath = (chain: Chain, address: string) => {
|
|
82
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts`
|
|
108
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}/nfts`
|
|
83
109
|
}
|
|
84
110
|
|
|
85
111
|
export const getListNFTsByAccountPath = (chain: Chain, address: string) => {
|
|
86
|
-
return `${API_V2_PREFIX}/chain/${chain}/account/${address}/nfts`
|
|
112
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/account/${segment(address)}/nfts`
|
|
87
113
|
}
|
|
88
114
|
|
|
89
115
|
export const getNFTPath = (
|
|
@@ -91,7 +117,7 @@ export const getNFTPath = (
|
|
|
91
117
|
address: string,
|
|
92
118
|
identifier: string,
|
|
93
119
|
) => {
|
|
94
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}`
|
|
120
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}/nfts/${segment(identifier)}`
|
|
95
121
|
}
|
|
96
122
|
|
|
97
123
|
export const getRefreshMetadataPath = (
|
|
@@ -99,7 +125,7 @@ export const getRefreshMetadataPath = (
|
|
|
99
125
|
address: string,
|
|
100
126
|
identifier: string,
|
|
101
127
|
) => {
|
|
102
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/refresh`
|
|
128
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}/nfts/${segment(identifier)}/refresh`
|
|
103
129
|
}
|
|
104
130
|
|
|
105
131
|
export const getOrderByHashPath = (
|
|
@@ -107,7 +133,7 @@ export const getOrderByHashPath = (
|
|
|
107
133
|
protocolAddress: string,
|
|
108
134
|
orderHash: string,
|
|
109
135
|
) => {
|
|
110
|
-
return `${API_V2_PREFIX}/orders/chain/${chain}/protocol/${protocolAddress}/${orderHash}`
|
|
136
|
+
return `${API_V2_PREFIX}/orders/chain/${segment(chain)}/protocol/${segment(protocolAddress)}/${segment(orderHash)}`
|
|
111
137
|
}
|
|
112
138
|
|
|
113
139
|
export const getCancelOrderPath = (
|
|
@@ -115,7 +141,7 @@ export const getCancelOrderPath = (
|
|
|
115
141
|
protocolAddress: string,
|
|
116
142
|
orderHash: string,
|
|
117
143
|
) => {
|
|
118
|
-
return `${API_V2_PREFIX}/orders/chain/${chain}/protocol/${protocolAddress}/${orderHash}/cancel`
|
|
144
|
+
return `${API_V2_PREFIX}/orders/chain/${segment(chain)}/protocol/${segment(protocolAddress)}/${segment(orderHash)}/cancel`
|
|
119
145
|
}
|
|
120
146
|
|
|
121
147
|
export const getCreateCancelOrderActionsPath = (
|
|
@@ -123,7 +149,7 @@ export const getCreateCancelOrderActionsPath = (
|
|
|
123
149
|
protocolAddress: string,
|
|
124
150
|
orderIdentifier: string,
|
|
125
151
|
) => {
|
|
126
|
-
return `${API_V2_PREFIX}/orders/chain/${chain}/protocol/${protocolAddress}/${orderIdentifier}/cancel/actions`
|
|
152
|
+
return `${API_V2_PREFIX}/orders/chain/${segment(chain)}/protocol/${segment(protocolAddress)}/${segment(orderIdentifier)}/cancel/actions`
|
|
127
153
|
}
|
|
128
154
|
|
|
129
155
|
export const getCreateListingFulfillmentActionsPath = () => {
|
|
@@ -139,14 +165,14 @@ export const getCreateOfferFulfillmentActionsPath = () => {
|
|
|
139
165
|
}
|
|
140
166
|
|
|
141
167
|
export const getTraitOffersPath = (collectionSlug: string) => {
|
|
142
|
-
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/traits`
|
|
168
|
+
return `${API_V2_PREFIX}/offers/collection/${segment(collectionSlug)}/traits`
|
|
143
169
|
}
|
|
144
170
|
|
|
145
171
|
export const getOffersByNFTPath = (
|
|
146
172
|
collectionSlug: string,
|
|
147
173
|
identifier: string | number,
|
|
148
174
|
) => {
|
|
149
|
-
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/nfts/${identifier}`
|
|
175
|
+
return `${API_V2_PREFIX}/offers/collection/${segment(collectionSlug)}/nfts/${segment(identifier)}`
|
|
150
176
|
}
|
|
151
177
|
|
|
152
178
|
export const getSweepListingsPath = () => {
|
|
@@ -166,11 +192,11 @@ export const getEventsAPIPath = () => {
|
|
|
166
192
|
}
|
|
167
193
|
|
|
168
194
|
export const getEventsByAccountAPIPath = (address: string) => {
|
|
169
|
-
return `${API_V2_PREFIX}/events/accounts/${address}`
|
|
195
|
+
return `${API_V2_PREFIX}/events/accounts/${segment(address)}`
|
|
170
196
|
}
|
|
171
197
|
|
|
172
198
|
export const getEventsByCollectionAPIPath = (collectionSlug: string) => {
|
|
173
|
-
return `${API_V2_PREFIX}/events/collection/${collectionSlug}`
|
|
199
|
+
return `${API_V2_PREFIX}/events/collection/${segment(collectionSlug)}`
|
|
174
200
|
}
|
|
175
201
|
|
|
176
202
|
export const getEventsByNFTAPIPath = (
|
|
@@ -178,15 +204,15 @@ export const getEventsByNFTAPIPath = (
|
|
|
178
204
|
address: string,
|
|
179
205
|
identifier: string,
|
|
180
206
|
) => {
|
|
181
|
-
return `${API_V2_PREFIX}/events/chain/${chain}/contract/${address}/nfts/${identifier}`
|
|
207
|
+
return `${API_V2_PREFIX}/events/chain/${segment(chain)}/contract/${segment(address)}/nfts/${segment(identifier)}`
|
|
182
208
|
}
|
|
183
209
|
|
|
184
210
|
export const getContractPath = (chain: Chain, address: string) => {
|
|
185
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}`
|
|
211
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}`
|
|
186
212
|
}
|
|
187
213
|
|
|
188
214
|
export const getTraitsPath = (collectionSlug: string) => {
|
|
189
|
-
return `${API_V2_PREFIX}/traits/${collectionSlug}`
|
|
215
|
+
return `${API_V2_PREFIX}/traits/${segment(collectionSlug)}`
|
|
190
216
|
}
|
|
191
217
|
|
|
192
218
|
export const getTrendingTokensPath = () => {
|
|
@@ -202,7 +228,7 @@ export const getSwapQuotePath = () => {
|
|
|
202
228
|
}
|
|
203
229
|
|
|
204
230
|
export const getTokenPath = (chain: string, address: string) => {
|
|
205
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}`
|
|
231
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}`
|
|
206
232
|
}
|
|
207
233
|
|
|
208
234
|
export const getSearchPath = () => {
|
|
@@ -214,7 +240,7 @@ export const getChainsPath = () => {
|
|
|
214
240
|
}
|
|
215
241
|
|
|
216
242
|
export const getAccountTokensPath = (address: string) => {
|
|
217
|
-
return `${API_V2_PREFIX}/account/${address}/tokens`
|
|
243
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/tokens`
|
|
218
244
|
}
|
|
219
245
|
|
|
220
246
|
export const getValidateMetadataPath = (
|
|
@@ -222,7 +248,7 @@ export const getValidateMetadataPath = (
|
|
|
222
248
|
address: string,
|
|
223
249
|
identifier: string,
|
|
224
250
|
) => {
|
|
225
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/validate-metadata`
|
|
251
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}/nfts/${segment(identifier)}/validate-metadata`
|
|
226
252
|
}
|
|
227
253
|
|
|
228
254
|
export const getDropsPath = () => {
|
|
@@ -230,15 +256,15 @@ export const getDropsPath = () => {
|
|
|
230
256
|
}
|
|
231
257
|
|
|
232
258
|
export const getDropPath = (slug: string) => {
|
|
233
|
-
return `${API_V2_PREFIX}/drops/${slug}`
|
|
259
|
+
return `${API_V2_PREFIX}/drops/${segment(slug)}`
|
|
234
260
|
}
|
|
235
261
|
|
|
236
262
|
export const getDropMintPath = (slug: string) => {
|
|
237
|
-
return `${API_V2_PREFIX}/drops/${slug}/mint`
|
|
263
|
+
return `${API_V2_PREFIX}/drops/${segment(slug)}/mint`
|
|
238
264
|
}
|
|
239
265
|
|
|
240
266
|
export const getCrossChainDropMintPath = (slug: string) => {
|
|
241
|
-
return `${API_V2_PREFIX}/drops/${slug}/cross_chain_mint`
|
|
267
|
+
return `${API_V2_PREFIX}/drops/${segment(slug)}/cross_chain_mint`
|
|
242
268
|
}
|
|
243
269
|
|
|
244
270
|
export const getTrendingCollectionsPath = () => {
|
|
@@ -250,7 +276,7 @@ export const getTopCollectionsPath = () => {
|
|
|
250
276
|
}
|
|
251
277
|
|
|
252
278
|
export const getResolveAccountPath = (identifier: string) => {
|
|
253
|
-
return `${API_V2_PREFIX}/accounts/resolve/${identifier}`
|
|
279
|
+
return `${API_V2_PREFIX}/accounts/resolve/${segment(identifier)}`
|
|
254
280
|
}
|
|
255
281
|
|
|
256
282
|
export const getNFTCollectionPath = (
|
|
@@ -258,7 +284,7 @@ export const getNFTCollectionPath = (
|
|
|
258
284
|
address: string,
|
|
259
285
|
identifier: string,
|
|
260
286
|
) => {
|
|
261
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/collection`
|
|
287
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}/nfts/${segment(identifier)}/collection`
|
|
262
288
|
}
|
|
263
289
|
|
|
264
290
|
export const getNFTMetadataPath = (
|
|
@@ -266,7 +292,7 @@ export const getNFTMetadataPath = (
|
|
|
266
292
|
contractAddress: string,
|
|
267
293
|
tokenId: string,
|
|
268
294
|
) => {
|
|
269
|
-
return `${API_V2_PREFIX}/metadata/${chain}/${contractAddress}/${tokenId}`
|
|
295
|
+
return `${API_V2_PREFIX}/metadata/${segment(chain)}/${segment(contractAddress)}/${segment(tokenId)}`
|
|
270
296
|
}
|
|
271
297
|
|
|
272
298
|
export const getTokenGroupsPath = () => {
|
|
@@ -274,7 +300,7 @@ export const getTokenGroupsPath = () => {
|
|
|
274
300
|
}
|
|
275
301
|
|
|
276
302
|
export const getTokenGroupPath = (slug: string) => {
|
|
277
|
-
return `${API_V2_PREFIX}/token-groups/${slug}`
|
|
303
|
+
return `${API_V2_PREFIX}/token-groups/${segment(slug)}`
|
|
278
304
|
}
|
|
279
305
|
|
|
280
306
|
export const getCrossChainFulfillmentDataPath = () => {
|
|
@@ -312,7 +338,7 @@ export const getDeployDropPath = () => {
|
|
|
312
338
|
}
|
|
313
339
|
|
|
314
340
|
export const getDeployDropReceiptPath = (chain: Chain, txHash: string) => {
|
|
315
|
-
return `${API_V2_PREFIX}/drops/deploy/${chain}/${txHash}/receipt`
|
|
341
|
+
return `${API_V2_PREFIX}/drops/deploy/${segment(chain)}/${segment(txHash)}/receipt`
|
|
316
342
|
}
|
|
317
343
|
|
|
318
344
|
// ── Assets transfer ─────────────────────────────────────────────────
|
|
@@ -324,45 +350,45 @@ export const getTransferAssetsPath = () => {
|
|
|
324
350
|
// ── Collection analytics ────────────────────────────────────────────
|
|
325
351
|
|
|
326
352
|
export const getCollectionOfferAggregatesPath = (slug: string) => {
|
|
327
|
-
return `${API_V2_PREFIX}/collections/${slug}/offer_aggregates`
|
|
353
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}/offer_aggregates`
|
|
328
354
|
}
|
|
329
355
|
|
|
330
356
|
export const getCollectionHoldersPath = (slug: string) => {
|
|
331
|
-
return `${API_V2_PREFIX}/collections/${slug}/holders`
|
|
357
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}/holders`
|
|
332
358
|
}
|
|
333
359
|
|
|
334
360
|
export const getCollectionFloorPricesPath = (slug: string) => {
|
|
335
|
-
return `${API_V2_PREFIX}/collections/${slug}/floor_prices`
|
|
361
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}/floor_prices`
|
|
336
362
|
}
|
|
337
363
|
|
|
338
364
|
// ── Token analytics ─────────────────────────────────────────────────
|
|
339
365
|
|
|
340
366
|
export const getTokenPriceHistoryPath = (chain: Chain, address: string) => {
|
|
341
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/price_history`
|
|
367
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/price_history`
|
|
342
368
|
}
|
|
343
369
|
|
|
344
370
|
export const getTokenOhlcvPath = (chain: Chain, address: string) => {
|
|
345
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/ohlcv`
|
|
371
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/ohlcv`
|
|
346
372
|
}
|
|
347
373
|
|
|
348
374
|
export const getTokenActivityPath = (chain: Chain, address: string) => {
|
|
349
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/activity`
|
|
375
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/activity`
|
|
350
376
|
}
|
|
351
377
|
|
|
352
378
|
export const getTokenActivityStatsPath = (chain: Chain, address: string) => {
|
|
353
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/activity/stats`
|
|
379
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/activity/stats`
|
|
354
380
|
}
|
|
355
381
|
|
|
356
382
|
export const getAccountTokenActivityPath = (address: string) => {
|
|
357
|
-
return `${API_V2_PREFIX}/account/${address}/token-activity`
|
|
383
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/token-activity`
|
|
358
384
|
}
|
|
359
385
|
|
|
360
386
|
export const getTokenHoldersPath = (chain: Chain, address: string) => {
|
|
361
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/holders`
|
|
387
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/holders`
|
|
362
388
|
}
|
|
363
389
|
|
|
364
390
|
export const getTokenLiquidityPoolsPath = (chain: Chain, address: string) => {
|
|
365
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/liquidity-pools`
|
|
391
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/liquidity-pools`
|
|
366
392
|
}
|
|
367
393
|
|
|
368
394
|
// ── NFT analytics ───────────────────────────────────────────────────
|
|
@@ -372,7 +398,7 @@ export const getNFTOwnersPath = (
|
|
|
372
398
|
address: string,
|
|
373
399
|
identifier: string,
|
|
374
400
|
) => {
|
|
375
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/owners`
|
|
401
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}/nfts/${segment(identifier)}/owners`
|
|
376
402
|
}
|
|
377
403
|
|
|
378
404
|
export const getNFTAnalyticsPath = (
|
|
@@ -380,47 +406,47 @@ export const getNFTAnalyticsPath = (
|
|
|
380
406
|
address: string,
|
|
381
407
|
identifier: string,
|
|
382
408
|
) => {
|
|
383
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/analytics`
|
|
409
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}/nfts/${segment(identifier)}/analytics`
|
|
384
410
|
}
|
|
385
411
|
|
|
386
412
|
// ── Account portfolio / profile ─────────────────────────────────────
|
|
387
413
|
|
|
388
414
|
export const getPortfolioStatsPath = (address: string) => {
|
|
389
|
-
return `${API_V2_PREFIX}/account/${address}/portfolio`
|
|
415
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/portfolio`
|
|
390
416
|
}
|
|
391
417
|
|
|
392
418
|
export const getPortfolioHistoryPath = (address: string) => {
|
|
393
|
-
return `${API_V2_PREFIX}/account/${address}/portfolio/history`
|
|
419
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/portfolio/history`
|
|
394
420
|
}
|
|
395
421
|
|
|
396
422
|
export const getProfileOffersReceivedPath = (address: string) => {
|
|
397
|
-
return `${API_V2_PREFIX}/account/${address}/offers_received`
|
|
423
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/offers_received`
|
|
398
424
|
}
|
|
399
425
|
|
|
400
426
|
export const getProfileOffersPath = (address: string) => {
|
|
401
|
-
return `${API_V2_PREFIX}/account/${address}/offers`
|
|
427
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/offers`
|
|
402
428
|
}
|
|
403
429
|
|
|
404
430
|
export const getProfileListingsPath = (address: string) => {
|
|
405
|
-
return `${API_V2_PREFIX}/account/${address}/listings`
|
|
431
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/listings`
|
|
406
432
|
}
|
|
407
433
|
|
|
408
434
|
export const getProfileFavoritesPath = (address: string) => {
|
|
409
|
-
return `${API_V2_PREFIX}/account/${address}/favorites`
|
|
435
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/favorites`
|
|
410
436
|
}
|
|
411
437
|
|
|
412
438
|
export const getWalletPnlPath = (address: string) => {
|
|
413
|
-
return `${API_V2_PREFIX}/account/${address}/pnl`
|
|
439
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/pnl`
|
|
414
440
|
}
|
|
415
441
|
|
|
416
442
|
export const getWalletClosedPositionsPath = (address: string) => {
|
|
417
|
-
return `${API_V2_PREFIX}/account/${address}/pnl/closed-positions`
|
|
443
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/pnl/closed-positions`
|
|
418
444
|
}
|
|
419
445
|
|
|
420
446
|
export const getWalletTokenTransfersPath = (address: string) => {
|
|
421
|
-
return `${API_V2_PREFIX}/account/${address}/pnl/token-transfers`
|
|
447
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/pnl/token-transfers`
|
|
422
448
|
}
|
|
423
449
|
|
|
424
450
|
export const getProfileCollectionsPath = (address: string) => {
|
|
425
|
-
return `${API_V2_PREFIX}/account/${address}/collections`
|
|
451
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/collections`
|
|
426
452
|
}
|
package/src/api/walletAuth.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
operations,
|
|
6
6
|
} from "@opensea/api-types"
|
|
7
7
|
import type { Camelize } from "../utils/case"
|
|
8
|
+
import { segment } from "./apiPaths"
|
|
8
9
|
import type { WalletAuthFetcher } from "./fetcher"
|
|
9
10
|
|
|
10
11
|
type OperationName = keyof operations
|
|
@@ -18,8 +19,6 @@ export type WalletAuthQuery<T extends OperationName> = Camelize<
|
|
|
18
19
|
OperationQueryParams<T>
|
|
19
20
|
>
|
|
20
21
|
|
|
21
|
-
const segment = (value: string | number) => encodeURIComponent(String(value))
|
|
22
|
-
|
|
23
22
|
/** Typed helpers for wallet-authenticated REST operations. */
|
|
24
23
|
export class WalletAuthAPI {
|
|
25
24
|
constructor(private fetcher: WalletAuthFetcher) {}
|
package/src/types.ts
CHANGED
|
@@ -297,18 +297,27 @@ export type OpenSeaAccount = Camelize<AccountResponse>
|
|
|
297
297
|
export type SocialMediaAccount = Camelize<ApiSocialMediaAccount>
|
|
298
298
|
|
|
299
299
|
/**
|
|
300
|
-
*
|
|
300
|
+
* Error thrown for any non-OK API response. `statusCode` is always set, so a caller can separate
|
|
301
|
+
* a retryable failure from a permanent one without parsing the message. That matters for clients
|
|
302
|
+
* that scrub remote error text before surfacing it, which have no other way to recover the status.
|
|
301
303
|
* @category API Models
|
|
302
304
|
*/
|
|
303
|
-
export interface
|
|
305
|
+
export interface OpenSeaApiError extends Error {
|
|
304
306
|
/** The HTTP status code of the error response */
|
|
305
307
|
statusCode?: number
|
|
306
|
-
/** The number of seconds to wait before retrying the request */
|
|
308
|
+
/** The number of seconds to wait before retrying the request, on rate limit responses */
|
|
307
309
|
retryAfter?: number
|
|
308
310
|
/** The response body from the API */
|
|
309
311
|
responseBody?: unknown
|
|
310
312
|
}
|
|
311
313
|
|
|
314
|
+
/**
|
|
315
|
+
* @deprecated Use {@link OpenSeaApiError}. Retained as an alias: the shape is identical and
|
|
316
|
+
* `retryAfter` was always optional, so existing rate-limit handling is unaffected.
|
|
317
|
+
* @category API Models
|
|
318
|
+
*/
|
|
319
|
+
export type OpenSeaRateLimitError = OpenSeaApiError
|
|
320
|
+
|
|
312
321
|
/**
|
|
313
322
|
* Options for controlling HTTP request behavior.
|
|
314
323
|
* @category API Models
|