@covalenthq/client-sdk 2.2.2 → 2.2.3

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.
@@ -1,6 +1,6 @@
1
1
  import { type Execution } from "../utils/functions/execution";
2
2
  import { type Chain, type GoldRushResponse } from "../utils/types/Generic.types";
3
- import { type ChainCollectionResponse, type CheckOwnershipInNftQueryParamOpts, type GetChainCollectionsQueryParamOpts, type GetNftMetadataForGivenTokenIdForContractQueryParamOpts, type GetNftTransactionsForContractTokenIdQueryParamOpts, type GetNftsForAddressQueryParamOpts, type GetTokenIdsForContractWithMetadataQueryParamOpts, type NftAddressBalanceNftResponse, type NftCollectionAttributesForTraitResponse, type NftCollectionTraitsResponse, type NftCollectionTraitsSummaryResponse, type NftMetadataResponse, type NftOwnershipForCollectionResponse, type NftTransactionsResponse } from "../utils/types/NftService.types";
3
+ import { type ChainCollectionResponse, type CheckOwnershipInNftQueryParamOpts, type GetChainCollectionsQueryParamOpts, type GetCollectionMarketDataQueryParamOpts, type GetNftMetadataForGivenTokenIdForContractQueryParamOpts, type GetNftTransactionsForContractTokenIdQueryParamOpts, type GetNftsForAddressQueryParamOpts, type GetTokenIdsForContractWithMetadataQueryParamOpts, type NftAddressBalanceNftResponse, type NftCollectionAttributesForTraitResponse, type NftCollectionFloorPriceResponse, type NftCollectionSalesCountResponse, type NftCollectionTraitsResponse, type NftCollectionTraitsSummaryResponse, type NftCollectionVolumeResponse, type NftMetadataResponse, type NftOwnershipForCollectionResponse, type NftTransactionsResponse } from "../utils/types/NftService.types";
4
4
  /**
5
5
  * NFTs API
6
6
  *
@@ -130,6 +130,42 @@ export declare class NftService {
130
130
  *
131
131
  */
132
132
  getCollectionTraitsSummary(chainName: Chain, collectionContract: string): Promise<GoldRushResponse<NftCollectionTraitsSummaryResponse>>;
133
+ /**
134
+ *
135
+ * Commonly used to render a price floor chart for an NFT collection.
136
+ *
137
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
138
+ * @param {string} collectionAddress - The requested address.
139
+ * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
140
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
141
+ * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
142
+ *
143
+ */
144
+ getHistoricalFloorPricesForCollection(chainName: Chain, collectionAddress: string, queryParamOpts?: GetCollectionMarketDataQueryParamOpts): Promise<GoldRushResponse<NftCollectionFloorPriceResponse>>;
145
+ /**
146
+ *
147
+ * Commonly used to build a time-series chart of the transaction volume of an NFT collection.
148
+ *
149
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
150
+ * @param {string} collectionAddress - The requested address.
151
+ * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
152
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
153
+ * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
154
+ *
155
+ */
156
+ getHistoricalVolumeForCollection(chainName: Chain, collectionAddress: string, queryParamOpts?: GetCollectionMarketDataQueryParamOpts): Promise<GoldRushResponse<NftCollectionVolumeResponse>>;
157
+ /**
158
+ *
159
+ * Commonly used to build a time-series chart of the sales count of an NFT collection.
160
+ *
161
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
162
+ * @param {string} collectionAddress - The requested address.
163
+ * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
164
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
165
+ * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
166
+ *
167
+ */
168
+ getHistoricalSalesCountForCollection(chainName: Chain, collectionAddress: string, queryParamOpts?: GetCollectionMarketDataQueryParamOpts): Promise<GoldRushResponse<NftCollectionSalesCountResponse>>;
133
169
  /**
134
170
  *
135
171
  * Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.
@@ -73,7 +73,7 @@ export type MultiChainBalanceItem = Nullable<{
73
73
  /** * The timestamp when the token was transferred. */
74
74
  last_transferred_at: Date;
75
75
  /** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
76
- native_token: boolean;
76
+ is_native_token: boolean;
77
77
  /** * One of `cryptocurrency`, `stablecoin`, `nft` or `dust`. */
78
78
  type: string;
79
79
  /** * Denotes whether the token is suspected spam. */
@@ -1,4 +1,4 @@
1
- import { type ChainID, type ChainName, type LogEvent, type NftData, type Nullable, type Pagination } from "./Generic.types";
1
+ import { type ChainID, type ChainName, type LogEvent, type NftData, type Nullable, type Pagination, type Quote } from "./Generic.types";
2
2
  export type ChainCollectionResponse = Nullable<{
3
3
  /** * The timestamp when the response was generated. Useful to show data staleness to users. */
4
4
  updated_at: Date;
@@ -271,3 +271,85 @@ export type CheckOwnershipInNftQueryParamOpts = Nullable<{
271
271
  /** * Filters NFTs based on a specific trait value. If this filter is used, the API will return all NFTs with the specified trait value. Must be used with "traits-filter", is case-sensitive, and requires proper URL encoding. */
272
272
  valuesFilter?: string;
273
273
  }>;
274
+ export type GetCollectionMarketDataQueryParamOpts = Nullable<{
275
+ /** * The requested quote currency eg: `USD`. */
276
+ quote_currency?: Quote;
277
+ /** The number of days to return data for. Request up 365 days. Defaults to 30 days. */
278
+ days?: number;
279
+ }>;
280
+ export type NftCollectionFloorPriceResponse = Nullable<{
281
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
282
+ updated_at: Date;
283
+ /** The requested address. */
284
+ address: string;
285
+ /** * The requested quote currency eg: `USD`. */
286
+ quote_currency: Quote;
287
+ /** * The requested chain name eg: `eth-mainnet`. */
288
+ chain_name: ChainName;
289
+ /** * The requested chain ID eg: `1`. */
290
+ chain_id: ChainID;
291
+ /** * List of response items. */
292
+ items: NftCollectionFloorPriceItem[];
293
+ }>;
294
+ export type NftCollectionFloorPriceItem = Nullable<{
295
+ /** * The timestamp of the date of sale. */
296
+ date: Date;
297
+ /** * The ticker symbol for the native currency. */
298
+ native_ticker_symbol: string;
299
+ /** * The contract name of the native currency. */
300
+ native_name: string;
301
+ /** * The current floor price in native currency. */
302
+ floor_price_native_quote: number;
303
+ /** * The current floor price converted to fiat in quote-currency. */
304
+ floor_price_quote: number;
305
+ /** * A prettier version of the floor price quote for rendering purposes. */
306
+ pretty_floor_price_quote: string;
307
+ }>;
308
+ export type NftCollectionVolumeResponse = Nullable<{
309
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
310
+ updated_at: Date;
311
+ /** The requested address. */
312
+ address: string;
313
+ /** * The requested quote currency eg: `USD`. */
314
+ quote_currency: Quote;
315
+ /** * The requested chain name eg: `eth-mainnet`. */
316
+ chain_name: ChainName;
317
+ /** * The requested chain ID eg: `1`. */
318
+ chain_id: ChainID;
319
+ /** * List of response items. */
320
+ items: NftCollectionVolumeItem[];
321
+ }>;
322
+ export type NftCollectionVolumeItem = Nullable<{
323
+ /** * The timestamp of the date of sale. */
324
+ date: Date;
325
+ /** * The ticker symbol for the native currency. */
326
+ native_ticker_symbol: string;
327
+ /** * The contract name of the native currency. */
328
+ native_name: string;
329
+ /** * The current volume converted to fiat in `quoteCurrency`. */
330
+ volume_quote: number;
331
+ /** * The current volume in native currency. */
332
+ volume_native_quote: number;
333
+ /** * A prettier version of the volume quote for rendering purposes. */
334
+ pretty_volume_quote: string;
335
+ }>;
336
+ export type NftCollectionSalesCountResponse = Nullable<{
337
+ /** * The timestamp when the response was generated. Useful to show data staleness to users. */
338
+ updated_at: Date;
339
+ /** The requested address. */
340
+ address: string;
341
+ /** * The requested quote currency eg: `USD`. */
342
+ quote_currency: Quote;
343
+ /** * The requested chain name eg: `eth-mainnet`. */
344
+ chain_name: ChainName;
345
+ /** * The requested chain ID eg: `1`. */
346
+ chain_id: ChainID;
347
+ /** * List of response items. */
348
+ items: NftCollectionSalesCountItem[];
349
+ }>;
350
+ export type NftCollectionSalesCountItem = Nullable<{
351
+ /** * The timestamp of the date of sale. */
352
+ date: Date;
353
+ /** * The total amount of sales for the current day. */
354
+ sales_count: string;
355
+ }>;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var version = "2.2.2";
1
+ var version = "2.2.3";
2
2
 
3
3
  const bigIntParser = (val) => {
4
4
  if (val === null || val === undefined) {
@@ -2162,6 +2162,120 @@ class NftService {
2162
2162
  };
2163
2163
  return await this.execution.execute(endpoint, parseData);
2164
2164
  }
2165
+ /**
2166
+ *
2167
+ * Commonly used to render a price floor chart for an NFT collection.
2168
+ *
2169
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
2170
+ * @param {string} collectionAddress - The requested address.
2171
+ * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
2172
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2173
+ * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
2174
+ *
2175
+ */
2176
+ async getHistoricalFloorPricesForCollection(chainName, collectionAddress, queryParamOpts) {
2177
+ const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/floor_price`, [
2178
+ {
2179
+ key: "days",
2180
+ value: queryParamOpts?.days,
2181
+ },
2182
+ {
2183
+ key: "quote-currency",
2184
+ value: queryParamOpts?.quote_currency,
2185
+ },
2186
+ ]);
2187
+ const parseData = (data) => {
2188
+ if (data.data) {
2189
+ data.data.updated_at = data.data.updated_at
2190
+ ? new Date(data.data.updated_at)
2191
+ : null;
2192
+ data.data.items = data.data.items
2193
+ ? data.data.items.map((floorPriceItem) => ({
2194
+ ...floorPriceItem,
2195
+ date: floorPriceItem.date ? new Date(floorPriceItem.date) : null,
2196
+ }))
2197
+ : null;
2198
+ }
2199
+ return data;
2200
+ };
2201
+ return await this.execution.execute(endpoint, parseData);
2202
+ }
2203
+ /**
2204
+ *
2205
+ * Commonly used to build a time-series chart of the transaction volume of an NFT collection.
2206
+ *
2207
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
2208
+ * @param {string} collectionAddress - The requested address.
2209
+ * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
2210
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2211
+ * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
2212
+ *
2213
+ */
2214
+ async getHistoricalVolumeForCollection(chainName, collectionAddress, queryParamOpts) {
2215
+ const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/volume`, [
2216
+ {
2217
+ key: "days",
2218
+ value: queryParamOpts?.days,
2219
+ },
2220
+ {
2221
+ key: "quote-currency",
2222
+ value: queryParamOpts?.quote_currency,
2223
+ },
2224
+ ]);
2225
+ const parseData = (data) => {
2226
+ if (data.data) {
2227
+ data.data.updated_at = data.data.updated_at
2228
+ ? new Date(data.data.updated_at)
2229
+ : null;
2230
+ data.data.items = data.data.items
2231
+ ? data.data.items.map((floorPriceItem) => ({
2232
+ ...floorPriceItem,
2233
+ date: floorPriceItem.date ? new Date(floorPriceItem.date) : null,
2234
+ }))
2235
+ : null;
2236
+ }
2237
+ return data;
2238
+ };
2239
+ return await this.execution.execute(endpoint, parseData);
2240
+ }
2241
+ /**
2242
+ *
2243
+ * Commonly used to build a time-series chart of the sales count of an NFT collection.
2244
+ *
2245
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
2246
+ * @param {string} collectionAddress - The requested address.
2247
+ * @param {GetNftsForAddressQueryParamOpts} queryParamOpts
2248
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
2249
+ * - `days`: The number of days to return data for. Request up 365 days. Defaults to 30 days.
2250
+ *
2251
+ */
2252
+ async getHistoricalSalesCountForCollection(chainName, collectionAddress, queryParamOpts) {
2253
+ const endpoint = endpointGenerator(`${chainName}/nft_market/${collectionAddress}/sale_count`, [
2254
+ {
2255
+ key: "days",
2256
+ value: queryParamOpts?.days,
2257
+ },
2258
+ {
2259
+ key: "quote-currency",
2260
+ value: queryParamOpts?.quote_currency,
2261
+ },
2262
+ ]);
2263
+ const parseData = (data) => {
2264
+ if (data.data) {
2265
+ data.data.updated_at = data.data.updated_at
2266
+ ? new Date(data.data.updated_at)
2267
+ : null;
2268
+ data.data.items = data.data.items
2269
+ ? data.data.items.map((floorPriceItem) => ({
2270
+ ...floorPriceItem,
2271
+ date: floorPriceItem.date ? new Date(floorPriceItem.date) : null,
2272
+ }))
2273
+ : null;
2274
+ }
2275
+ return data;
2276
+ };
2277
+ return await this.execution.execute(endpoint, parseData);
2278
+ }
2165
2279
  /**
2166
2280
  *
2167
2281
  * Commonly used to verify ownership of NFTs (including ERC-721 and ERC-1155) within a collection.