@xoxno/sdk-js 0.1.179-alpha → 0.1.183

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.
Files changed (135) hide show
  1. package/package.json +1 -1
  2. package/dist/collection/index.d.ts +0 -297
  3. package/dist/collection/index.d.ts.map +0 -1
  4. package/dist/collection/index.js +0 -692
  5. package/dist/collection/index.js.map +0 -1
  6. package/dist/common/index.d.ts +0 -71
  7. package/dist/common/index.d.ts.map +0 -1
  8. package/dist/common/index.js +0 -145
  9. package/dist/common/index.js.map +0 -1
  10. package/dist/email/Markdown.d.ts +0 -4
  11. package/dist/email/Markdown.d.ts.map +0 -1
  12. package/dist/email/email.d.ts +0 -31
  13. package/dist/email/email.d.ts.map +0 -1
  14. package/dist/email/email.js +0 -248
  15. package/dist/email/email.js.map +0 -1
  16. package/dist/email/event-email.d.ts +0 -20
  17. package/dist/email/event-email.d.ts.map +0 -1
  18. package/dist/email/post-email.d.ts +0 -19
  19. package/dist/email/post-email.d.ts.map +0 -1
  20. package/dist/email/types.d.ts +0 -68
  21. package/dist/email/types.d.ts.map +0 -1
  22. package/dist/email/types.js +0 -30
  23. package/dist/email/types.js.map +0 -1
  24. package/dist/email/utils.d.ts +0 -84
  25. package/dist/email/utils.d.ts.map +0 -1
  26. package/dist/email-node.cjs.js +0 -1854
  27. package/dist/email-node.cjs.js.LICENSE.txt +0 -102
  28. package/dist/email-node.esm.js +0 -1854
  29. package/dist/email-node.esm.js.LICENSE.txt +0 -102
  30. package/dist/email.cjs.js +0 -1854
  31. package/dist/email.cjs.js.LICENSE.txt +0 -102
  32. package/dist/email.d.ts +0 -15
  33. package/dist/email.d.ts.map +0 -1
  34. package/dist/email.esm.js +0 -1854
  35. package/dist/email.esm.js.LICENSE.txt +0 -102
  36. package/dist/email.js +0 -3
  37. package/dist/email.js.map +0 -1
  38. package/dist/index.cjs.js +0 -1
  39. package/dist/index.d.ts +0 -8
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/index.esm.js +0 -1
  42. package/dist/index.js +0 -8
  43. package/dist/index.js.map +0 -1
  44. package/dist/interactions/index.d.ts +0 -256
  45. package/dist/interactions/index.d.ts.map +0 -1
  46. package/dist/interactions/index.js +0 -700
  47. package/dist/interactions/index.js.map +0 -1
  48. package/dist/interactor.cjs.js +0 -2
  49. package/dist/interactor.cjs.js.LICENSE.txt +0 -10
  50. package/dist/interactor.d.ts +0 -6
  51. package/dist/interactor.d.ts.map +0 -1
  52. package/dist/interactor.esm.js +0 -2
  53. package/dist/interactor.esm.js.LICENSE.txt +0 -10
  54. package/dist/interactor.js +0 -6
  55. package/dist/interactor.js.map +0 -1
  56. package/dist/launchpad/index.d.ts +0 -79
  57. package/dist/launchpad/index.d.ts.map +0 -1
  58. package/dist/launchpad/index.js +0 -140
  59. package/dist/launchpad/index.js.map +0 -1
  60. package/dist/nft/index.d.ts +0 -69
  61. package/dist/nft/index.d.ts.map +0 -1
  62. package/dist/nft/index.js +0 -109
  63. package/dist/nft/index.js.map +0 -1
  64. package/dist/staking/index.d.ts +0 -12
  65. package/dist/staking/index.d.ts.map +0 -1
  66. package/dist/staking/index.js +0 -17
  67. package/dist/staking/index.js.map +0 -1
  68. package/dist/types/collection.d.ts +0 -851
  69. package/dist/types/collection.d.ts.map +0 -1
  70. package/dist/types/collection.js +0 -192
  71. package/dist/types/collection.js.map +0 -1
  72. package/dist/types/common.d.ts +0 -72
  73. package/dist/types/common.d.ts.map +0 -1
  74. package/dist/types/common.js +0 -2
  75. package/dist/types/common.js.map +0 -1
  76. package/dist/types/index.d.ts +0 -8
  77. package/dist/types/index.d.ts.map +0 -1
  78. package/dist/types/index.js +0 -8
  79. package/dist/types/index.js.map +0 -1
  80. package/dist/types/interactions.d.ts +0 -97
  81. package/dist/types/interactions.d.ts.map +0 -1
  82. package/dist/types/interactions.js +0 -8
  83. package/dist/types/interactions.js.map +0 -1
  84. package/dist/types/nft.d.ts +0 -105
  85. package/dist/types/nft.d.ts.map +0 -1
  86. package/dist/types/nft.js +0 -2
  87. package/dist/types/nft.js.map +0 -1
  88. package/dist/types/staking.d.ts +0 -67
  89. package/dist/types/staking.d.ts.map +0 -1
  90. package/dist/types/staking.js +0 -18
  91. package/dist/types/staking.js.map +0 -1
  92. package/dist/types/trading.d.ts +0 -115
  93. package/dist/types/trading.d.ts.map +0 -1
  94. package/dist/types/trading.js +0 -49
  95. package/dist/types/trading.js.map +0 -1
  96. package/dist/types/user.d.ts +0 -302
  97. package/dist/types/user.d.ts.map +0 -1
  98. package/dist/types/user.js +0 -10
  99. package/dist/types/user.js.map +0 -1
  100. package/dist/users/index.d.ts +0 -202
  101. package/dist/users/index.d.ts.map +0 -1
  102. package/dist/users/index.js +0 -380
  103. package/dist/users/index.js.map +0 -1
  104. package/dist/utils/SmartContractAbis.d.ts +0 -16
  105. package/dist/utils/SmartContractAbis.d.ts.map +0 -1
  106. package/dist/utils/SmartContractAbis.js +0 -84
  107. package/dist/utils/SmartContractAbis.js.map +0 -1
  108. package/dist/utils/SmartContractService.d.ts +0 -4
  109. package/dist/utils/SmartContractService.d.ts.map +0 -1
  110. package/dist/utils/SmartContractService.js +0 -9
  111. package/dist/utils/SmartContractService.js.map +0 -1
  112. package/dist/utils/api.d.ts +0 -31
  113. package/dist/utils/api.d.ts.map +0 -1
  114. package/dist/utils/api.js +0 -93
  115. package/dist/utils/api.js.map +0 -1
  116. package/dist/utils/const.d.ts +0 -14
  117. package/dist/utils/const.d.ts.map +0 -1
  118. package/dist/utils/const.js +0 -14
  119. package/dist/utils/const.js.map +0 -1
  120. package/dist/utils/getActivity.d.ts +0 -11
  121. package/dist/utils/getActivity.d.ts.map +0 -1
  122. package/dist/utils/getActivity.js +0 -65
  123. package/dist/utils/getActivity.js.map +0 -1
  124. package/dist/utils/helpers.d.ts +0 -4
  125. package/dist/utils/helpers.d.ts.map +0 -1
  126. package/dist/utils/helpers.js +0 -19
  127. package/dist/utils/helpers.js.map +0 -1
  128. package/dist/utils/regex.d.ts +0 -3
  129. package/dist/utils/regex.d.ts.map +0 -1
  130. package/dist/utils/regex.js +0 -7
  131. package/dist/utils/regex.js.map +0 -1
  132. package/dist/utils/scCalls.d.ts +0 -10
  133. package/dist/utils/scCalls.d.ts.map +0 -1
  134. package/dist/utils/scCalls.js +0 -25
  135. package/dist/utils/scCalls.js.map +0 -1
@@ -1,692 +0,0 @@
1
- import { GlobalOfferOrderBy, AuctionTypes, } from '../types/collection';
2
- import { XOXNOClient } from '..';
3
- import { getActivity } from '../utils/getActivity';
4
- import { isValidCollectionTicker } from '../utils/regex';
5
- /**
6
- * CollectionModule provides a set of methods to interact with NFT collections.
7
- * It includes methods for getting collection profile information, floor price,
8
- * collection attributes, and searching NFTs within a collection.
9
- *
10
- * @example
11
- * const collectionModule = new CollectionModule();
12
- */
13
- export class CollectionModule {
14
- api;
15
- constructor() {
16
- this.api = XOXNOClient.getInstance();
17
- }
18
- /**
19
- * @public
20
- * @async
21
- * @function getCollectionProfile
22
- * @param {string} collection - The ticker of the collection to fetch the profile for.
23
- * @returns {Promise<ICollectionProfile>} A promise that resolves to the fetched collection profile.
24
- *
25
- * This function fetches the profile of a given collection. It takes the following parameter:
26
- * - collection (string): The ticker of the collection to fetch the profile for.
27
- *
28
- * The function first validates the input ticker and checks if it is a valid collection ticker.
29
- * If it is valid, the function fetches the collection profile using the API.
30
- * Finally, it returns a promise that resolves to the fetched collection profile.
31
- */
32
- getCollectionProfile = async (collection) => {
33
- if (!isValidCollectionTicker(collection)) {
34
- throw new Error('Invalid collection ticker: ' + collection);
35
- }
36
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/profile`, {
37
- next: {
38
- tags: ['getCollectionProfile'],
39
- revalidate: 30,
40
- },
41
- });
42
- return response;
43
- };
44
- /**
45
- * @public
46
- * @async
47
- * @function getDailyTrending
48
- * @returns {Promise<NftData[]>} A promise that resolves to the array of trending NFTs.
49
- * This function fetches the top NFTs that are trending today based on their floor and volumes
50
- */
51
- getDailyTrending = async () => {
52
- const response = await this.api.fetchWithTimeout('/nfts/getDailyTrending', {
53
- next: {
54
- tags: ['getDailyTrending'],
55
- revalidate: 180,
56
- },
57
- });
58
- return response;
59
- };
60
- /**
61
- * Fetches the floor price of a collection.
62
- * @param collection - The ticker of the collection.
63
- * @param token - The token for the floor price calculation (default: 'EGLD').
64
- * @returns A Promise that resolves to the collection's floor price as a number.
65
- * @throws An error if the provided collection ticker is invalid.
66
- */
67
- getCollectionFloorPrice = async (collection, token = 'EGLD') => {
68
- if (!isValidCollectionTicker(collection)) {
69
- throw new Error('Invalid collection ticker: ' + collection);
70
- }
71
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/floor-price`, {
72
- next: {
73
- tags: ['getCollectionFloorPrice'],
74
- },
75
- params: {
76
- token,
77
- },
78
- });
79
- return response?.price ? response.price : 0;
80
- };
81
- /**
82
- * @public
83
- * @async
84
- * @function getCollectionAttributes
85
- * @param {string} collection - The ticker of the collection to fetch the attributes for.
86
- * @returns {Promise<ICollectionAttributes>} A promise that resolves to the fetched collection attributes.
87
- *
88
- * This function fetches the attributes of a given collection. It takes the following parameter:
89
- * - collection (string): The ticker of the collection to fetch the attributes for.
90
- *
91
- * The function first validates the input ticker and checks if it is a valid collection ticker.
92
- * If it is valid, the function fetches the collection attributes using the API.
93
- * Finally, it returns a promise that resolves to the fetched collection attributes.
94
- */
95
- getCollectionAttributes = async (collection) => {
96
- if (!isValidCollectionTicker(collection)) {
97
- throw new Error('Invalid collection ticker: ' + collection);
98
- }
99
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/attributes`, {
100
- next: {
101
- tags: ['getCollectionAttributes'],
102
- revalidate: 180,
103
- },
104
- });
105
- return response;
106
- };
107
- /**
108
- * Searches for NFTs based on the provided arguments.
109
- * @param {SearchNFTsArgs} args - The SearchNFTsArgs object containing the search parameters.
110
- * @returns {Promise<SearchNFTsResponse>} A Promise that resolves to the SearchNFTsResponse object.
111
- * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 100.
112
- */
113
- getNFTs = async (args) => {
114
- args?.collections?.forEach((element) => {
115
- if (!isValidCollectionTicker(element)) {
116
- throw new Error('Invalid collection ticker: ' + element);
117
- }
118
- });
119
- if (args.top && args.top > 100) {
120
- throw new Error('Top cannot be greater than 100');
121
- }
122
- const ranges = [];
123
- if (args.priceRange) {
124
- ranges.push({
125
- ...args.priceRange,
126
- field: args.auctionType == AuctionTypes.Auctions
127
- ? 'saleInfo.currentBidShort'
128
- : 'saleInfo.minBidShort',
129
- });
130
- }
131
- if (args.rankRange) {
132
- ranges.push({
133
- ...args.rankRange,
134
- field: 'metadata.rarity.rank',
135
- });
136
- }
137
- const payloadBody = {
138
- filters: {
139
- dataType: args.dataType ?? ['nft'],
140
- // @borispoehland Has to be false only if we want to show the expired auctions, undefined to show all, and true only actives
141
- activeAuction: args.activeAuctions,
142
- collection: args.collections ?? [],
143
- onSale: args.onlyOnSale,
144
- saleInfo: {
145
- seller: args.listedBy || [],
146
- marketplace: args.listedOnlyOn || undefined,
147
- paymentToken: args.listedInToken || [],
148
- auctionType: args.auctionType == AuctionTypes.Auctions
149
- ? ['NftBid', 'SftAll']
150
- : args.auctionType == AuctionTypes.FixedPrice
151
- ? ['Nft', 'SftOnePerPayment']
152
- : args.auctionType == AuctionTypes.AllListed
153
- ? ['NftBid', 'SftAll', 'Nft', 'SftOnePerPayment']
154
- : undefined,
155
- },
156
- owner: args.ownedBy || [],
157
- verifiedOnly: args.onlyVerified || false,
158
- metadata: {
159
- attributes: args.attributes || undefined,
160
- },
161
- range: ranges,
162
- nonce: args.nonces || undefined,
163
- cp_staked: args.isStaked ?? undefined,
164
- },
165
- applyNftExtraDetails: args.applyNftExtraDetails,
166
- orderBy: args.orderBy || [],
167
- select: args.onlySelectFields || [],
168
- strictSelect: args.strictSelect || false,
169
- includeCount: args.includeCount || false,
170
- top: args.top || 35,
171
- skip: args.skip || 0,
172
- };
173
- const response = await this.api.fetchWithTimeout(`/nft/query`, {
174
- params: {
175
- filter: JSON.stringify(payloadBody),
176
- },
177
- next: {
178
- tags: ['getCollectionNFTs'],
179
- },
180
- cache: 'no-store',
181
- });
182
- return {
183
- ...response,
184
- getNextPagePayload: {
185
- ...args,
186
- skip: (args.skip ?? 0) + (args.top ?? 35),
187
- },
188
- };
189
- };
190
- /**
191
- * @public
192
- * @async
193
- * @function suggestCollections
194
- * @param {SuggestNFTsArgs} args - An object containing the necessary parameters to fetch suggested collections results.
195
- * @returns {Promise<SuggestResults>} A promise that resolves to the fetched collections results.
196
- *
197
- * This function fetches suggested collections results based on the provided arguments. It takes an object with the following properties:
198
- * - name (string): The name to search for (required).
199
- * - top (number, optional): The maximum number of results to return (default is 35, cannot be greater than 100).
200
- * - skip (number, optional): The number of results to skip (default is 0).
201
- *
202
- * Finally, it returns a promise that resolves to the fetched collections results.
203
- */
204
- suggestCollections = async (args) => {
205
- if (args.top && args.top > 100) {
206
- throw new Error('Top cannot be greater than 100');
207
- }
208
- const payloadBody = {
209
- name: args.name,
210
- top: args.top || 35,
211
- skip: args.skip || 0,
212
- };
213
- return await this.api.fetchWithTimeout(`/collection/search`, {
214
- params: {
215
- filter: JSON.stringify(payloadBody),
216
- },
217
- next: {
218
- tags: ['/collection/search'],
219
- revalidate: 180,
220
- },
221
- });
222
- };
223
- /**
224
- * @public
225
- * @async
226
- * @function collectionListingsAnalytics
227
- * @param {string} ticker - The unique collection identifier called ticker
228
- * @returns {Promise<CollectionListings>} A promise that resolves to the distribution of listings
229
- */
230
- collectionListingsAnalytics = async (ticker) => {
231
- return await this.api.fetchWithTimeout(`/collection/${ticker}/listings`, {
232
- next: {
233
- tags: ['collection/${ticker}/listings'],
234
- revalidate: 500,
235
- },
236
- });
237
- };
238
- /**
239
- * Retrieves trading history based on the provided arguments.
240
- *
241
- * @param {TradincActivityArgs} args - The arguments for filtering the trading activity.
242
- * @returns {Promise<TradingActivityResponse>} A promise resolving to a TradingActivityResponse object containing the activity.
243
- * @throws {Error} Throws an error if the 'top' argument is greater than 100.
244
- */
245
- getTradingActivity = async (args) => {
246
- return await getActivity(args, this.api);
247
- };
248
- /**
249
- * Fetch collections profiles based on the provided arguments.
250
- * @param {GetCollectionsArgs} args - The GetCollectionsArgs object containing the search parameters.
251
- * @returns {Promise<CollectionsNFTsResponse>} A Promise that resolves to the CollectionsNFTsResponse object.
252
- * @throws An error if the 'top' value is greater than 100.
253
- */
254
- getCollections = async (args) => {
255
- if (args?.top && args.top > 100) {
256
- throw new Error('Top cannot be greater than 100');
257
- }
258
- const payloadBody = {
259
- skip: args?.skip || 0,
260
- top: args?.top || 25,
261
- select: args?.onlySelectFields || [],
262
- filters: {
263
- dataType: 'collectionProfile',
264
- isMintable: args?.onlyMintable || undefined,
265
- ...(args?.collections &&
266
- args.collections.length > 0 && {
267
- collection: args.collections,
268
- }),
269
- },
270
- orderBy: [args?.orderBy || 'statistics.tradeData.weekEgldVolume desc'],
271
- };
272
- const response = await this.api.fetchWithTimeout(`/collection/query`, {
273
- params: {
274
- filter: JSON.stringify(payloadBody),
275
- },
276
- next: {
277
- tags: ['getCollections'],
278
- revalidate: 180,
279
- },
280
- });
281
- return {
282
- results: response,
283
- resultsCount: response.length,
284
- empty: response.length === 0,
285
- getNextPagePayload: {
286
- ...args,
287
- skip: (args?.skip || 0) + (args?.top || 25),
288
- },
289
- hasMoreResults: response.length >= (args?.top || 25),
290
- };
291
- };
292
- /**
293
- * Fetch global offers based on the provided arguments.
294
- * @param {GetGlobalOffersArgs} args - The GetCollectionsArgs object containing the search parameters.
295
- * @returns {Promise<GlobalOffersResult>} A Promise that resolves to the GlobalOffersResult object.
296
- * @throws An error if the 'top' value is greater than 100.
297
- */
298
- getGlobalOffers = async (args) => {
299
- if (args?.top && args.top > 100) {
300
- throw new Error('Top cannot be greater than 100');
301
- }
302
- const payloadBody = {
303
- skip: args?.skip || 0,
304
- top: args?.top || 25,
305
- select: args?.onlySelectFields || [],
306
- filters: {
307
- collection: args?.collections || [],
308
- withAttributes: args?.withAttributes ?? false,
309
- isActive: args?.onlyActive ?? true,
310
- offerId: args?.offerIds,
311
- owner: args?.ownedBy,
312
- marketplace: args?.listedOnlyOn,
313
- range: args?.priceRange
314
- ? { ...args.priceRange, type: 'priceShort' }
315
- : undefined,
316
- attributes: args?.attributes,
317
- },
318
- orderBy: [args?.orderBy || GlobalOfferOrderBy.PriceHighToLow],
319
- };
320
- const response = await this.api.fetchWithTimeout(`/collection/global-offer/query`, {
321
- params: {
322
- filter: JSON.stringify(payloadBody),
323
- },
324
- next: {
325
- tags: ['getGlobalOffers'],
326
- revalidate: 12,
327
- },
328
- });
329
- return {
330
- ...response,
331
- getNextPagePayload: {
332
- ...args,
333
- skip: (args?.top || 25) + response.lastSkip,
334
- },
335
- };
336
- };
337
- /**
338
- * @public
339
- * @async
340
- * @function getCollectionVolume
341
- * @param {string} collection - The ticker of the collection to fetch the volume for (e.g., 'EAPES-8f3c1f').
342
- * @param {string} after - The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').
343
- * @param {string} before - The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').
344
- * @param {string} bin - The binning period for the volume data (e.g., '1d' for 1 day).
345
- * @returns {Promise<CollectionVolume[]>} A promise that resolves to an array of collection volume data.
346
- *
347
- * This function fetches volume data for a given collection within a specified date range and binning period. It takes the following parameters:
348
- * - collection (string): The ticker of the collection to fetch the volume for (e.g., 'EAPES-8f3c1f').
349
- * - after (string): The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').
350
- * - before (string): The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').
351
- * - bin (string): The binning period for the volume data (e.g., '1d' for 1 day).
352
- *
353
- * The function first validates the input collection ticker and checks if it is a valid collection ticker.
354
- * If it is valid, the function fetches the collection volume data using the API with the specified query parameters.
355
- * Finally, it returns a promise that resolves to an array of collection volume data.
356
- */
357
- getCollectionVolume = async (collection, after, before, bin) => {
358
- if (!isValidCollectionTicker(collection)) {
359
- throw new Error('Invalid collection ticker: ' + collection);
360
- }
361
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/analytics/volume?startTime=${after}&endTime=${before}&bin=${bin}`, {
362
- next: {
363
- tags: ['getCollectionVolume'],
364
- revalidate: 180,
365
- },
366
- });
367
- return response;
368
- };
369
- /**
370
- * @public
371
- * @async
372
- * @function getMarketplaceVolume
373
- * @param {string} after - The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').
374
- * @param {string} before - The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').
375
- * @param {string} bin - The binning period for the volume data (e.g., '1d' for 1 day).
376
- * @returns {Promise<CollectionVolume[]>} A promise that resolves to an array of collection volume data.
377
- *
378
- * This function fetches volume data for a given collection within a specified date range and binning period. It takes the following parameters:
379
- * - collection (string): The ticker of the collection to fetch the volume for (e.g., 'EAPES-8f3c1f').
380
- * - after (string): The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').
381
- * - before (string): The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').
382
- * - bin (string): The binning period for the volume data (e.g., '1d' for 1 day).
383
- *
384
- * The function first validates the input collection ticker and checks if it is a valid collection ticker.
385
- * If it is valid, the function fetches the collection volume data using the API with the specified query parameters.
386
- * Finally, it returns a promise that resolves to an array of collection volume data.
387
- */
388
- getMarketplaceVolume = async (after, before, bin) => {
389
- const response = await this.api.fetchWithTimeout(`/analytics/volume?startTime=${after}&endTime=${before}&bin=${bin}`, {
390
- next: {
391
- tags: ['getMarketplaceVolume'],
392
- revalidate: 180,
393
- },
394
- });
395
- return response;
396
- };
397
- /**
398
- * @public
399
- * @async
400
- * @function getCollectionOwners
401
- * @param {string} collection - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').
402
- * @returns {Promise<IOwners>} A promise that resolves a struct of collection information about holders
403
- *
404
- * This function fetches owner information for a given collection. It takes the following parameter:
405
- * - collection (string): The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').
406
- *
407
- * The function first validates the input collection ticker and checks if it is a valid collection ticker.
408
- * If it is valid, the function fetches the collection owner information using the API.
409
- * Finally, it returns a promise that resolves a struct of collection information about holders
410
- */
411
- getCollectionOwners = async (collection) => {
412
- if (!isValidCollectionTicker(collection)) {
413
- throw new Error('Invalid collection ticker: ' + collection);
414
- }
415
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/holders`, {
416
- next: {
417
- tags: ['getCollectionOwners'],
418
- revalidate: 500,
419
- },
420
- });
421
- return response;
422
- };
423
- /**
424
- * @public
425
- * @async
426
- * @function getExportOwners
427
- * @param {string} collection - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').
428
- * @returns {Promise<ISingleHolder[]>} A promise that resolves an array of holders part of the collection.
429
- *
430
- * This function fetches owners information for a given collection. It takes the following parameter:
431
- * - collection (string): The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').
432
- *
433
- * The function first validates the input collection ticker and checks if it is a valid collection ticker.
434
- * If it is valid, the function fetches the collection owner information using the API.
435
- * Finally, it returns a promise that resolves to an array of collection owner information.
436
- */
437
- getExportOwners = async (collection) => {
438
- if (!isValidCollectionTicker(collection)) {
439
- throw new Error('Invalid collection ticker: ' + collection);
440
- }
441
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/holders?exportHolders=true`, {
442
- next: {
443
- tags: ['getExportOwners'],
444
- },
445
- });
446
- return response;
447
- };
448
- /**
449
- * @public
450
- * @async
451
- * @function getCollectionsStatistics
452
- * @param {GetCollectionStatsArgs} args - The filter payload for the collection statsitics
453
- * @returns {Promise<CollectionStatsResults>} A promise that resolves to a struct with information
454
- * Finally, it returns a promise that resolves a struct with information
455
- */
456
- getCollectionsStatistics = async (args) => {
457
- if (args?.top && args.top > 100) {
458
- throw new Error('Top cannot be greater than 100');
459
- }
460
- const response = await this.api.fetchWithTimeout(`/collection/stats/query`, {
461
- params: {
462
- filter: JSON.stringify(args),
463
- },
464
- next: {
465
- tags: ['collectionStatistics'],
466
- revalidate: 12,
467
- },
468
- });
469
- return {
470
- ...response,
471
- getNextPagePayload: {
472
- ...args,
473
- skip: args.skip + args.top,
474
- },
475
- };
476
- };
477
- /**
478
- * @public
479
- * @async
480
- * @function getCollectionStats
481
- * @param {GetCollectionStatsArgs} args - The filter payload for the collection statsitics
482
- * @returns {Promise<CollectionStatsDoc>} A promise that resolves to a struct with information
483
- * Finally, it returns a promise that resolves a struct with information
484
- */
485
- getCollectionStats = async (ticker) => {
486
- if (!isValidCollectionTicker(ticker)) {
487
- throw new Error('Invalid collection ticker: ' + ticker);
488
- }
489
- return await this.api.fetchWithTimeout(`/collection/${ticker}/stats`, {
490
- next: {
491
- tags: ['collectionStatistics'],
492
- revalidate: 12,
493
- },
494
- });
495
- };
496
- getAwaitEmpty = async (delay) => {
497
- return new Promise((resolve) => {
498
- setTimeout(() => {
499
- resolve(true);
500
- }, delay);
501
- });
502
- };
503
- /**
504
- * @public
505
- * @async
506
- * @function getCollectionMintInfo
507
- * @param {string} ticker - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').
508
- * @returns {Promise<GetCollectionMintInfo>} A promise that resolves to a struct with information
509
- * Finally, it returns a promise that resolves a struct with information
510
- */
511
- getCollectionMintInfo = async ({ ticker, extra, }) => {
512
- if (!isValidCollectionTicker(ticker)) {
513
- throw new Error('Invalid collection ticker: ' + ticker);
514
- }
515
- const response = await this.api.fetchWithTimeout(`/collection/${ticker}/drop-info`, {
516
- next: {
517
- tags: [`/collection/${ticker}/drop-info`],
518
- revalidate: 12,
519
- },
520
- ...extra,
521
- });
522
- return response;
523
- };
524
- /**
525
- * @public
526
- * @async
527
- * @function getCollectionRanks
528
- * @param {string} ticker - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').
529
- * @returns {Promise<CollectionRanksExport[]>} A promise that resolves to a struct with information
530
- * Finally, it returns a promise that resolves a struct with information
531
- */
532
- getCollectionRanks = async ({ ticker, extra, }) => {
533
- if (!isValidCollectionTicker(ticker)) {
534
- throw new Error('Invalid collection ticker: ' + ticker);
535
- }
536
- const response = await this.api.fetchWithTimeout(`/collection/${ticker}/ranks`, {
537
- next: {
538
- tags: [`/collection/${ticker}/ranks`],
539
- revalidate: 60,
540
- },
541
- ...extra,
542
- });
543
- return response;
544
- };
545
- /**
546
- * @public
547
- * @async
548
- * @function getDropInfo
549
- * @param {string} collectionTag - The unique ID of the collection part of the launchpad smart contract
550
- * @param {string} creatorTag - The unique ID of the creator part of the launchpad smart contract
551
- * @returns {Promise<GetCollectionMintInfo>} A promise that resolves to a struct with information
552
- * Finally, it returns a promise that resolves a struct with information
553
- */
554
- getDropInfo = async ({ collectionTag, creatorTag, extra, }) => {
555
- const response = await this.api.fetchWithTimeout(`/collection/${creatorTag}/${collectionTag}/drop-info`, {
556
- next: {
557
- tags: [`/collection/${creatorTag}/${collectionTag}/drop-info`],
558
- revalidate: 12,
559
- },
560
- ...extra,
561
- });
562
- return response;
563
- };
564
- /**
565
- * @public
566
- * @async
567
- * @function getCollectionGraphData
568
- * @param category - The ticker of the collection.
569
- * @returns {Promise<AnalyticsGraphs>} A promise the required analytics data
570
- * This function gets the global graph data
571
- */
572
- getCollectionGraphData = async (collection, startTime, endTime, bin) => {
573
- if (!isValidCollectionTicker(collection)) {
574
- throw new Error('Invalid collection ticker: ' + collection);
575
- }
576
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/analytics/volume`, {
577
- params: {
578
- startTime: startTime,
579
- endTime: endTime,
580
- bin: bin,
581
- },
582
- next: {
583
- tags: [`/collection/${collection}/analytics/volume`],
584
- revalidate: 60,
585
- },
586
- });
587
- return response;
588
- };
589
- /**
590
- * @public
591
- * @async
592
- * @function getPinnedCollections
593
- * @returns {Promise<ICollectionProfile[]>} A promise that resolves to the fetched pinned collections.
594
- */
595
- getPinnedCollections = async () => {
596
- const response = await this.api.fetchWithTimeout(`/collection/pinned`, {
597
- next: {
598
- tags: [`/collection/pinned`],
599
- revalidate: 60,
600
- },
601
- });
602
- return response;
603
- };
604
- /**
605
- * Get drops based on the provided arguments.
606
- * @param {SearchNFTsArgs} args - The SearchNFTsArgs object containing the search parameters.
607
- * @returns {Promise<SearchNFTsResponse>} A Promise that resolves to the SearchNFTsResponse object.
608
- * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 100.
609
- */
610
- getDrops = async (args) => {
611
- args?.collections?.forEach((element) => {
612
- if (!isValidCollectionTicker(element)) {
613
- throw new Error('Invalid collection ticker: ' + element);
614
- }
615
- });
616
- if (args.top && args.top > 100) {
617
- throw new Error('Top cannot be greater than 100');
618
- }
619
- const ranges = [];
620
- if (args.timeRange) {
621
- ranges.push({
622
- ...args.timeRange,
623
- field: 'startTime',
624
- });
625
- }
626
- const payloadBody = {
627
- filters: {
628
- collection: args.collections ?? [],
629
- verifiedOnly: args.onlyVerified || false,
630
- mintToken: args.listedInToken || undefined,
631
- range: ranges,
632
- },
633
- orderBy: args.orderBy || [],
634
- select: args.onlySelectFields || [],
635
- includeCount: args.includeCount || false,
636
- top: args.top || 35,
637
- skip: args.skip || 0,
638
- };
639
- const response = await this.api.fetchWithTimeout(`/collection/drops/query`, {
640
- params: {
641
- filter: JSON.stringify(payloadBody),
642
- },
643
- next: {
644
- tags: ['/collection/drops/query'],
645
- },
646
- cache: 'no-store',
647
- });
648
- return {
649
- ...response,
650
- getNextPagePayload: {
651
- ...args,
652
- skip: (args.skip ?? 0) + (args.top ?? 35),
653
- },
654
- };
655
- };
656
- /** Gets collection staking info
657
- * @param {String} collection - User's address
658
- * @returns {StakingSummaryPools[]} Collection's staking info
659
- * @throws {Error} Throws an error if the collection is invalid
660
- * */
661
- getCollectionStakingSummary = async ({ collection, extra, }) => {
662
- if (!isValidCollectionTicker(collection)) {
663
- throw new Error('Invalid collection ticker: ' + collection);
664
- }
665
- const response = await this.api.fetchWithTimeout(`/collection/${collection}/staking/summary`, {
666
- ...extra,
667
- });
668
- return response;
669
- };
670
- /**
671
- * @public
672
- * @async
673
- * @function getCollectionsFloor
674
- * @param collections - The tickers of the collection.
675
- * @returns {Promise<Record<string, number>>} Floor price of the collections
676
- * This function gets the floor price of the collections
677
- */
678
- getCollectionsFloor = async (collections) => {
679
- collections?.forEach((element) => {
680
- if (!isValidCollectionTicker(element)) {
681
- throw new Error('Invalid collection ticker: ' + element);
682
- }
683
- });
684
- const response = await this.api.fetchWithTimeout(`/collection/floor-price`, {
685
- params: {
686
- collection: collections.join(','),
687
- },
688
- });
689
- return response;
690
- };
691
- }
692
- //# sourceMappingURL=index.js.map