@opensea/sdk 12.0.1 → 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 +29 -2
- package/lib/api/accounts.js +1 -1
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +27 -1
- package/lib/api/api.js +46 -5
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +21 -0
- package/lib/api/apiPaths.js +102 -62
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/listings.d.ts +5 -1
- package/lib/api/listings.js +6 -0
- package/lib/api/listings.js.map +1 -1
- package/lib/api/offers.d.ts +9 -1
- package/lib/api/offers.js +12 -0
- package/lib/api/offers.js.map +1 -1
- package/lib/api/orders.d.ts +5 -1
- package/lib/api/orders.js +6 -0
- package/lib/api/orders.js.map +1 -1
- package/lib/api/types.d.ts +9 -1
- package/lib/api/walletAuth.d.ts +21 -1
- package/lib/api/walletAuth.js +52 -33
- package/lib/api/walletAuth.js.map +1 -1
- package/lib/sdk/base.d.ts +1 -0
- package/lib/types.d.ts +11 -3
- package/lib/utils/rateLimit.d.ts +6 -0
- package/lib/utils/rateLimit.js +22 -5
- package/lib/utils/rateLimit.js.map +1 -1
- package/package.json +2 -2
- package/src/api/accounts.ts +1 -1
- package/src/api/api.ts +87 -5
- package/src/api/apiPaths.ts +106 -60
- package/src/api/listings.ts +15 -0
- package/src/api/offers.ts +30 -0
- package/src/api/orders.ts +18 -0
- package/src/api/types.ts +21 -0
- package/src/api/walletAuth.ts +30 -4
- package/src/types.ts +12 -3
- package/src/utils/rateLimit.ts +29 -4
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,18 +141,38 @@ 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`
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export const getCreateCancelOrderActionsPath = (
|
|
148
|
+
chain: Chain,
|
|
149
|
+
protocolAddress: string,
|
|
150
|
+
orderIdentifier: string,
|
|
151
|
+
) => {
|
|
152
|
+
return `${API_V2_PREFIX}/orders/chain/${segment(chain)}/protocol/${segment(protocolAddress)}/${segment(orderIdentifier)}/cancel/actions`
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const getCreateListingFulfillmentActionsPath = () => {
|
|
156
|
+
return `${API_V2_PREFIX}/listings/fulfillment/actions`
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const getCreateOfferActionsPath = () => {
|
|
160
|
+
return `${API_V2_PREFIX}/offers/actions`
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const getCreateOfferFulfillmentActionsPath = () => {
|
|
164
|
+
return `${API_V2_PREFIX}/offers/fulfillment/actions`
|
|
119
165
|
}
|
|
120
166
|
|
|
121
167
|
export const getTraitOffersPath = (collectionSlug: string) => {
|
|
122
|
-
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/traits`
|
|
168
|
+
return `${API_V2_PREFIX}/offers/collection/${segment(collectionSlug)}/traits`
|
|
123
169
|
}
|
|
124
170
|
|
|
125
171
|
export const getOffersByNFTPath = (
|
|
126
172
|
collectionSlug: string,
|
|
127
173
|
identifier: string | number,
|
|
128
174
|
) => {
|
|
129
|
-
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/nfts/${identifier}`
|
|
175
|
+
return `${API_V2_PREFIX}/offers/collection/${segment(collectionSlug)}/nfts/${segment(identifier)}`
|
|
130
176
|
}
|
|
131
177
|
|
|
132
178
|
export const getSweepListingsPath = () => {
|
|
@@ -146,11 +192,11 @@ export const getEventsAPIPath = () => {
|
|
|
146
192
|
}
|
|
147
193
|
|
|
148
194
|
export const getEventsByAccountAPIPath = (address: string) => {
|
|
149
|
-
return `${API_V2_PREFIX}/events/accounts/${address}`
|
|
195
|
+
return `${API_V2_PREFIX}/events/accounts/${segment(address)}`
|
|
150
196
|
}
|
|
151
197
|
|
|
152
198
|
export const getEventsByCollectionAPIPath = (collectionSlug: string) => {
|
|
153
|
-
return `${API_V2_PREFIX}/events/collection/${collectionSlug}`
|
|
199
|
+
return `${API_V2_PREFIX}/events/collection/${segment(collectionSlug)}`
|
|
154
200
|
}
|
|
155
201
|
|
|
156
202
|
export const getEventsByNFTAPIPath = (
|
|
@@ -158,15 +204,15 @@ export const getEventsByNFTAPIPath = (
|
|
|
158
204
|
address: string,
|
|
159
205
|
identifier: string,
|
|
160
206
|
) => {
|
|
161
|
-
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)}`
|
|
162
208
|
}
|
|
163
209
|
|
|
164
210
|
export const getContractPath = (chain: Chain, address: string) => {
|
|
165
|
-
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}`
|
|
211
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/contract/${segment(address)}`
|
|
166
212
|
}
|
|
167
213
|
|
|
168
214
|
export const getTraitsPath = (collectionSlug: string) => {
|
|
169
|
-
return `${API_V2_PREFIX}/traits/${collectionSlug}`
|
|
215
|
+
return `${API_V2_PREFIX}/traits/${segment(collectionSlug)}`
|
|
170
216
|
}
|
|
171
217
|
|
|
172
218
|
export const getTrendingTokensPath = () => {
|
|
@@ -182,7 +228,7 @@ export const getSwapQuotePath = () => {
|
|
|
182
228
|
}
|
|
183
229
|
|
|
184
230
|
export const getTokenPath = (chain: string, address: string) => {
|
|
185
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}`
|
|
231
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}`
|
|
186
232
|
}
|
|
187
233
|
|
|
188
234
|
export const getSearchPath = () => {
|
|
@@ -194,7 +240,7 @@ export const getChainsPath = () => {
|
|
|
194
240
|
}
|
|
195
241
|
|
|
196
242
|
export const getAccountTokensPath = (address: string) => {
|
|
197
|
-
return `${API_V2_PREFIX}/account/${address}/tokens`
|
|
243
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/tokens`
|
|
198
244
|
}
|
|
199
245
|
|
|
200
246
|
export const getValidateMetadataPath = (
|
|
@@ -202,7 +248,7 @@ export const getValidateMetadataPath = (
|
|
|
202
248
|
address: string,
|
|
203
249
|
identifier: string,
|
|
204
250
|
) => {
|
|
205
|
-
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`
|
|
206
252
|
}
|
|
207
253
|
|
|
208
254
|
export const getDropsPath = () => {
|
|
@@ -210,15 +256,15 @@ export const getDropsPath = () => {
|
|
|
210
256
|
}
|
|
211
257
|
|
|
212
258
|
export const getDropPath = (slug: string) => {
|
|
213
|
-
return `${API_V2_PREFIX}/drops/${slug}`
|
|
259
|
+
return `${API_V2_PREFIX}/drops/${segment(slug)}`
|
|
214
260
|
}
|
|
215
261
|
|
|
216
262
|
export const getDropMintPath = (slug: string) => {
|
|
217
|
-
return `${API_V2_PREFIX}/drops/${slug}/mint`
|
|
263
|
+
return `${API_V2_PREFIX}/drops/${segment(slug)}/mint`
|
|
218
264
|
}
|
|
219
265
|
|
|
220
266
|
export const getCrossChainDropMintPath = (slug: string) => {
|
|
221
|
-
return `${API_V2_PREFIX}/drops/${slug}/cross_chain_mint`
|
|
267
|
+
return `${API_V2_PREFIX}/drops/${segment(slug)}/cross_chain_mint`
|
|
222
268
|
}
|
|
223
269
|
|
|
224
270
|
export const getTrendingCollectionsPath = () => {
|
|
@@ -230,7 +276,7 @@ export const getTopCollectionsPath = () => {
|
|
|
230
276
|
}
|
|
231
277
|
|
|
232
278
|
export const getResolveAccountPath = (identifier: string) => {
|
|
233
|
-
return `${API_V2_PREFIX}/accounts/resolve/${identifier}`
|
|
279
|
+
return `${API_V2_PREFIX}/accounts/resolve/${segment(identifier)}`
|
|
234
280
|
}
|
|
235
281
|
|
|
236
282
|
export const getNFTCollectionPath = (
|
|
@@ -238,7 +284,7 @@ export const getNFTCollectionPath = (
|
|
|
238
284
|
address: string,
|
|
239
285
|
identifier: string,
|
|
240
286
|
) => {
|
|
241
|
-
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`
|
|
242
288
|
}
|
|
243
289
|
|
|
244
290
|
export const getNFTMetadataPath = (
|
|
@@ -246,7 +292,7 @@ export const getNFTMetadataPath = (
|
|
|
246
292
|
contractAddress: string,
|
|
247
293
|
tokenId: string,
|
|
248
294
|
) => {
|
|
249
|
-
return `${API_V2_PREFIX}/metadata/${chain}/${contractAddress}/${tokenId}`
|
|
295
|
+
return `${API_V2_PREFIX}/metadata/${segment(chain)}/${segment(contractAddress)}/${segment(tokenId)}`
|
|
250
296
|
}
|
|
251
297
|
|
|
252
298
|
export const getTokenGroupsPath = () => {
|
|
@@ -254,7 +300,7 @@ export const getTokenGroupsPath = () => {
|
|
|
254
300
|
}
|
|
255
301
|
|
|
256
302
|
export const getTokenGroupPath = (slug: string) => {
|
|
257
|
-
return `${API_V2_PREFIX}/token-groups/${slug}`
|
|
303
|
+
return `${API_V2_PREFIX}/token-groups/${segment(slug)}`
|
|
258
304
|
}
|
|
259
305
|
|
|
260
306
|
export const getCrossChainFulfillmentDataPath = () => {
|
|
@@ -292,7 +338,7 @@ export const getDeployDropPath = () => {
|
|
|
292
338
|
}
|
|
293
339
|
|
|
294
340
|
export const getDeployDropReceiptPath = (chain: Chain, txHash: string) => {
|
|
295
|
-
return `${API_V2_PREFIX}/drops/deploy/${chain}/${txHash}/receipt`
|
|
341
|
+
return `${API_V2_PREFIX}/drops/deploy/${segment(chain)}/${segment(txHash)}/receipt`
|
|
296
342
|
}
|
|
297
343
|
|
|
298
344
|
// ── Assets transfer ─────────────────────────────────────────────────
|
|
@@ -304,45 +350,45 @@ export const getTransferAssetsPath = () => {
|
|
|
304
350
|
// ── Collection analytics ────────────────────────────────────────────
|
|
305
351
|
|
|
306
352
|
export const getCollectionOfferAggregatesPath = (slug: string) => {
|
|
307
|
-
return `${API_V2_PREFIX}/collections/${slug}/offer_aggregates`
|
|
353
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}/offer_aggregates`
|
|
308
354
|
}
|
|
309
355
|
|
|
310
356
|
export const getCollectionHoldersPath = (slug: string) => {
|
|
311
|
-
return `${API_V2_PREFIX}/collections/${slug}/holders`
|
|
357
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}/holders`
|
|
312
358
|
}
|
|
313
359
|
|
|
314
360
|
export const getCollectionFloorPricesPath = (slug: string) => {
|
|
315
|
-
return `${API_V2_PREFIX}/collections/${slug}/floor_prices`
|
|
361
|
+
return `${API_V2_PREFIX}/collections/${segment(slug)}/floor_prices`
|
|
316
362
|
}
|
|
317
363
|
|
|
318
364
|
// ── Token analytics ─────────────────────────────────────────────────
|
|
319
365
|
|
|
320
366
|
export const getTokenPriceHistoryPath = (chain: Chain, address: string) => {
|
|
321
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/price_history`
|
|
367
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/price_history`
|
|
322
368
|
}
|
|
323
369
|
|
|
324
370
|
export const getTokenOhlcvPath = (chain: Chain, address: string) => {
|
|
325
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/ohlcv`
|
|
371
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/ohlcv`
|
|
326
372
|
}
|
|
327
373
|
|
|
328
374
|
export const getTokenActivityPath = (chain: Chain, address: string) => {
|
|
329
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/activity`
|
|
375
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/activity`
|
|
330
376
|
}
|
|
331
377
|
|
|
332
378
|
export const getTokenActivityStatsPath = (chain: Chain, address: string) => {
|
|
333
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/activity/stats`
|
|
379
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/activity/stats`
|
|
334
380
|
}
|
|
335
381
|
|
|
336
382
|
export const getAccountTokenActivityPath = (address: string) => {
|
|
337
|
-
return `${API_V2_PREFIX}/account/${address}/token-activity`
|
|
383
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/token-activity`
|
|
338
384
|
}
|
|
339
385
|
|
|
340
386
|
export const getTokenHoldersPath = (chain: Chain, address: string) => {
|
|
341
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/holders`
|
|
387
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/holders`
|
|
342
388
|
}
|
|
343
389
|
|
|
344
390
|
export const getTokenLiquidityPoolsPath = (chain: Chain, address: string) => {
|
|
345
|
-
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/liquidity-pools`
|
|
391
|
+
return `${API_V2_PREFIX}/chain/${segment(chain)}/token/${segment(address)}/liquidity-pools`
|
|
346
392
|
}
|
|
347
393
|
|
|
348
394
|
// ── NFT analytics ───────────────────────────────────────────────────
|
|
@@ -352,7 +398,7 @@ export const getNFTOwnersPath = (
|
|
|
352
398
|
address: string,
|
|
353
399
|
identifier: string,
|
|
354
400
|
) => {
|
|
355
|
-
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`
|
|
356
402
|
}
|
|
357
403
|
|
|
358
404
|
export const getNFTAnalyticsPath = (
|
|
@@ -360,47 +406,47 @@ export const getNFTAnalyticsPath = (
|
|
|
360
406
|
address: string,
|
|
361
407
|
identifier: string,
|
|
362
408
|
) => {
|
|
363
|
-
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`
|
|
364
410
|
}
|
|
365
411
|
|
|
366
412
|
// ── Account portfolio / profile ─────────────────────────────────────
|
|
367
413
|
|
|
368
414
|
export const getPortfolioStatsPath = (address: string) => {
|
|
369
|
-
return `${API_V2_PREFIX}/account/${address}/portfolio`
|
|
415
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/portfolio`
|
|
370
416
|
}
|
|
371
417
|
|
|
372
418
|
export const getPortfolioHistoryPath = (address: string) => {
|
|
373
|
-
return `${API_V2_PREFIX}/account/${address}/portfolio/history`
|
|
419
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/portfolio/history`
|
|
374
420
|
}
|
|
375
421
|
|
|
376
422
|
export const getProfileOffersReceivedPath = (address: string) => {
|
|
377
|
-
return `${API_V2_PREFIX}/account/${address}/offers_received`
|
|
423
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/offers_received`
|
|
378
424
|
}
|
|
379
425
|
|
|
380
426
|
export const getProfileOffersPath = (address: string) => {
|
|
381
|
-
return `${API_V2_PREFIX}/account/${address}/offers`
|
|
427
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/offers`
|
|
382
428
|
}
|
|
383
429
|
|
|
384
430
|
export const getProfileListingsPath = (address: string) => {
|
|
385
|
-
return `${API_V2_PREFIX}/account/${address}/listings`
|
|
431
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/listings`
|
|
386
432
|
}
|
|
387
433
|
|
|
388
434
|
export const getProfileFavoritesPath = (address: string) => {
|
|
389
|
-
return `${API_V2_PREFIX}/account/${address}/favorites`
|
|
435
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/favorites`
|
|
390
436
|
}
|
|
391
437
|
|
|
392
438
|
export const getWalletPnlPath = (address: string) => {
|
|
393
|
-
return `${API_V2_PREFIX}/account/${address}/pnl`
|
|
439
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/pnl`
|
|
394
440
|
}
|
|
395
441
|
|
|
396
442
|
export const getWalletClosedPositionsPath = (address: string) => {
|
|
397
|
-
return `${API_V2_PREFIX}/account/${address}/pnl/closed-positions`
|
|
443
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/pnl/closed-positions`
|
|
398
444
|
}
|
|
399
445
|
|
|
400
446
|
export const getWalletTokenTransfersPath = (address: string) => {
|
|
401
|
-
return `${API_V2_PREFIX}/account/${address}/pnl/token-transfers`
|
|
447
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/pnl/token-transfers`
|
|
402
448
|
}
|
|
403
449
|
|
|
404
450
|
export const getProfileCollectionsPath = (address: string) => {
|
|
405
|
-
return `${API_V2_PREFIX}/account/${address}/collections`
|
|
451
|
+
return `${API_V2_PREFIX}/account/${segment(address)}/collections`
|
|
406
452
|
}
|
package/src/api/listings.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
getBestListingAPIPath,
|
|
4
4
|
getBestListingsAPIPath,
|
|
5
5
|
getCreateListingActionsPath,
|
|
6
|
+
getCreateListingFulfillmentActionsPath,
|
|
6
7
|
getCrossChainFulfillmentDataPath,
|
|
7
8
|
getSweepListingsPath,
|
|
8
9
|
} from "./apiPaths"
|
|
@@ -10,6 +11,8 @@ import type { Fetcher } from "./fetcher"
|
|
|
10
11
|
import {
|
|
11
12
|
type CreateListingActionsRequest,
|
|
12
13
|
type CreateListingActionsResponse,
|
|
14
|
+
type CreateListingFulfillmentActionsRequest,
|
|
15
|
+
type CreateListingFulfillmentActionsResponse,
|
|
13
16
|
type CrossChainFulfillmentRequest,
|
|
14
17
|
type CrossChainFulfillmentResponse,
|
|
15
18
|
encodeTraitsParam,
|
|
@@ -140,4 +143,16 @@ export class ListingsAPI {
|
|
|
140
143
|
request,
|
|
141
144
|
)
|
|
142
145
|
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get the ordered actions required to fulfill a listing.
|
|
149
|
+
*/
|
|
150
|
+
async createListingFulfillmentActions(
|
|
151
|
+
request: CreateListingFulfillmentActionsRequest,
|
|
152
|
+
): Promise<CreateListingFulfillmentActionsResponse> {
|
|
153
|
+
return this.fetcher.post<CreateListingFulfillmentActionsResponse>(
|
|
154
|
+
getCreateListingFulfillmentActionsPath(),
|
|
155
|
+
request,
|
|
156
|
+
)
|
|
157
|
+
}
|
|
143
158
|
}
|
package/src/api/offers.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
getBestOfferAPIPath,
|
|
10
10
|
getBuildOfferPath,
|
|
11
11
|
getCollectionOffersPath,
|
|
12
|
+
getCreateOfferActionsPath,
|
|
13
|
+
getCreateOfferFulfillmentActionsPath,
|
|
12
14
|
getOffersByNFTPath,
|
|
13
15
|
getPostCollectionOfferPath,
|
|
14
16
|
getTraitOffersPath,
|
|
@@ -17,6 +19,10 @@ import type { Fetcher } from "./fetcher"
|
|
|
17
19
|
import type {
|
|
18
20
|
BuildOfferResponse,
|
|
19
21
|
CollectionOffer,
|
|
22
|
+
CreateOfferActionsRequest,
|
|
23
|
+
CreateOfferActionsResponse,
|
|
24
|
+
CreateOfferFulfillmentActionsRequest,
|
|
25
|
+
CreateOfferFulfillmentActionsResponse,
|
|
20
26
|
GetBestOfferResponse,
|
|
21
27
|
GetOffersResponse,
|
|
22
28
|
} from "./types"
|
|
@@ -238,4 +244,28 @@ export class OffersAPI {
|
|
|
238
244
|
{ limit, next },
|
|
239
245
|
)
|
|
240
246
|
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Get the ordered actions required to create an offer.
|
|
250
|
+
*/
|
|
251
|
+
async createOfferActions(
|
|
252
|
+
request: CreateOfferActionsRequest,
|
|
253
|
+
): Promise<CreateOfferActionsResponse> {
|
|
254
|
+
return this.fetcher.post<CreateOfferActionsResponse>(
|
|
255
|
+
getCreateOfferActionsPath(),
|
|
256
|
+
request,
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Get the ordered actions required to fulfill an offer.
|
|
262
|
+
*/
|
|
263
|
+
async createOfferFulfillmentActions(
|
|
264
|
+
request: CreateOfferFulfillmentActionsRequest,
|
|
265
|
+
): Promise<CreateOfferFulfillmentActionsResponse> {
|
|
266
|
+
return this.fetcher.post<CreateOfferFulfillmentActionsResponse>(
|
|
267
|
+
getCreateOfferFulfillmentActionsPath(),
|
|
268
|
+
request,
|
|
269
|
+
)
|
|
270
|
+
}
|
|
241
271
|
}
|
package/src/api/orders.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { type Chain, OrderSide } from "../types"
|
|
|
8
8
|
import type { Camelize } from "../utils/case"
|
|
9
9
|
import {
|
|
10
10
|
getCancelOrderPath,
|
|
11
|
+
getCreateCancelOrderActionsPath,
|
|
11
12
|
getOrderByHashPath,
|
|
12
13
|
getPostListingPath,
|
|
13
14
|
getPostOfferPath,
|
|
@@ -15,6 +16,8 @@ import {
|
|
|
15
16
|
import type { Fetcher } from "./fetcher"
|
|
16
17
|
import type {
|
|
17
18
|
CancelOrderResponse,
|
|
19
|
+
CreateCancelOrderActionsRequest,
|
|
20
|
+
CreateCancelOrderActionsResponse,
|
|
18
21
|
GetOrderByHashResponse,
|
|
19
22
|
Listing,
|
|
20
23
|
Offer,
|
|
@@ -167,4 +170,19 @@ export class OrdersAPI {
|
|
|
167
170
|
{ snakeizeBody: false },
|
|
168
171
|
)
|
|
169
172
|
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Get the ordered actions required to cancel an order onchain.
|
|
176
|
+
*/
|
|
177
|
+
async createCancelOrderActions(
|
|
178
|
+
protocolAddress: string,
|
|
179
|
+
orderIdentifier: string,
|
|
180
|
+
request: CreateCancelOrderActionsRequest,
|
|
181
|
+
chain: Chain = this.chain,
|
|
182
|
+
): Promise<CreateCancelOrderActionsResponse> {
|
|
183
|
+
return this.fetcher.post<CreateCancelOrderActionsResponse>(
|
|
184
|
+
getCreateCancelOrderActionsPath(chain, protocolAddress, orderIdentifier),
|
|
185
|
+
request,
|
|
186
|
+
)
|
|
187
|
+
}
|
|
170
188
|
}
|
package/src/api/types.ts
CHANGED
|
@@ -1168,12 +1168,16 @@ import type {
|
|
|
1168
1168
|
BatchCollectionsRequest as ApiBatchCollectionsRequest,
|
|
1169
1169
|
BatchNftsRequest as ApiBatchNftsRequest,
|
|
1170
1170
|
BatchTokensRequest as ApiBatchTokensRequest,
|
|
1171
|
+
CancelOrderActionsRequest as ApiCancelOrderActionsRequest,
|
|
1172
|
+
CancelOrderActionsResponse as ApiCancelOrderActionsResponse,
|
|
1171
1173
|
ClosedPositionsResponse as ApiClosedPositionsResponse,
|
|
1172
1174
|
CollectionBatchResponse as ApiCollectionBatchResponse,
|
|
1173
1175
|
CollectionHoldersPaginatedResponse as ApiCollectionHoldersPaginatedResponse,
|
|
1174
1176
|
CollectionOfferAggregatesPaginatedResponse as ApiCollectionOfferAggregatesPaginatedResponse,
|
|
1175
1177
|
CreateListingActionsRequest as ApiCreateListingActionsRequest,
|
|
1176
1178
|
CreateListingActionsResponse as ApiCreateListingActionsResponse,
|
|
1179
|
+
CreateOfferActionsRequest as ApiCreateOfferActionsRequest,
|
|
1180
|
+
CreateOfferActionsResponse as ApiCreateOfferActionsResponse,
|
|
1177
1181
|
CrossChainDropMintRequest as ApiCrossChainDropMintRequest,
|
|
1178
1182
|
CrossChainDropMintResponse as ApiCrossChainDropMintResponse,
|
|
1179
1183
|
CrossChainFulfillmentRequest as ApiCrossChainFulfillmentRequest,
|
|
@@ -1184,6 +1188,9 @@ import type {
|
|
|
1184
1188
|
DropDeployResponse as ApiDropDeployResponse,
|
|
1185
1189
|
FloorPriceHistoryResponse as ApiFloorPriceHistoryResponse,
|
|
1186
1190
|
FulfillerObject as ApiFulfillerObject,
|
|
1191
|
+
FulfillmentActionsResponse as ApiFulfillmentActionsResponse,
|
|
1192
|
+
FullfillListingRequest as ApiFullfillListingRequest,
|
|
1193
|
+
FullfillmentDataRequest as ApiFullfillmentDataRequest,
|
|
1187
1194
|
ListingObject as ApiListingObject,
|
|
1188
1195
|
NftAnalyticsResponse as ApiNftAnalyticsResponse,
|
|
1189
1196
|
NftBatchResponse as ApiNftBatchResponse,
|
|
@@ -1211,8 +1218,15 @@ import type {
|
|
|
1211
1218
|
export type BatchCollectionsRequest = Camelize<ApiBatchCollectionsRequest>
|
|
1212
1219
|
export type BatchNftsRequest = Camelize<ApiBatchNftsRequest>
|
|
1213
1220
|
export type BatchTokensRequest = Camelize<ApiBatchTokensRequest>
|
|
1221
|
+
export type CreateCancelOrderActionsRequest =
|
|
1222
|
+
Camelize<ApiCancelOrderActionsRequest>
|
|
1214
1223
|
export type CreateListingActionsRequest =
|
|
1215
1224
|
Camelize<ApiCreateListingActionsRequest>
|
|
1225
|
+
export type CreateListingFulfillmentActionsRequest =
|
|
1226
|
+
Camelize<ApiFullfillListingRequest>
|
|
1227
|
+
export type CreateOfferActionsRequest = Camelize<ApiCreateOfferActionsRequest>
|
|
1228
|
+
export type CreateOfferFulfillmentActionsRequest =
|
|
1229
|
+
Camelize<ApiFullfillmentDataRequest>
|
|
1216
1230
|
export type CrossChainDropMintRequest = Camelize<ApiCrossChainDropMintRequest>
|
|
1217
1231
|
export type CrossChainFulfillmentRequest =
|
|
1218
1232
|
Camelize<ApiCrossChainFulfillmentRequest>
|
|
@@ -1227,8 +1241,15 @@ export type CollectionHoldersPaginatedResponse =
|
|
|
1227
1241
|
Camelize<ApiCollectionHoldersPaginatedResponse>
|
|
1228
1242
|
export type CollectionOfferAggregatesPaginatedResponse =
|
|
1229
1243
|
Camelize<ApiCollectionOfferAggregatesPaginatedResponse>
|
|
1244
|
+
export type CreateCancelOrderActionsResponse =
|
|
1245
|
+
Camelize<ApiCancelOrderActionsResponse>
|
|
1230
1246
|
export type CreateListingActionsResponse =
|
|
1231
1247
|
Camelize<ApiCreateListingActionsResponse>
|
|
1248
|
+
export type CreateListingFulfillmentActionsResponse =
|
|
1249
|
+
Camelize<ApiFulfillmentActionsResponse>
|
|
1250
|
+
export type CreateOfferActionsResponse = Camelize<ApiCreateOfferActionsResponse>
|
|
1251
|
+
export type CreateOfferFulfillmentActionsResponse =
|
|
1252
|
+
Camelize<ApiFulfillmentActionsResponse>
|
|
1232
1253
|
export type CrossChainDropMintResponse = Camelize<ApiCrossChainDropMintResponse>
|
|
1233
1254
|
export type CrossChainFulfillmentResponse =
|
|
1234
1255
|
Camelize<ApiCrossChainFulfillmentResponse>
|