@xoxno/sdk-js 0.1.353 → 0.1.355

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
- import type { ActivityChain, NftData } from '../types/nft';
2
- import type { TradincActivityArgs, TradingActivityResponse } from '../types/trading';
3
- import type { UserOffers } from '../types/user';
1
+ import type { GetSingleNftOfferResponseDto, NftDoc } from '@xoxno/types';
2
+ import type { ArgsQueryTop } from '../types';
3
+ import type { ActivityChain } from '../types/nft';
4
4
  /**
5
5
  * NFTModule provides a set of methods to interact with single NFTs.
6
6
  * It includes methods for getting single NFT information, and searching NFTs by collection and nonce.
@@ -16,7 +16,7 @@ export declare class NFTModule {
16
16
  * @async
17
17
  * @function getNFTByIdentifier
18
18
  * @param {string} identifier - The identifier of the NFT to fetch data for.
19
- * @returns {Promise<NftData>} A promise that resolves to the fetched NFT data.
19
+ * @returns {Promise<NftDoc>} A promise that resolves to the fetched NFT data.
20
20
  *
21
21
  * This function fetches data for a given NFT by its identifier. It takes the following parameter:
22
22
  * - identifier (string): The identifier of the NFT to fetch data for.
@@ -25,13 +25,13 @@ export declare class NFTModule {
25
25
  * If it is valid, the function fetches the NFT data using the API.
26
26
  * Finally, it returns a promise that resolves to the fetched NFT data.
27
27
  */
28
- getNFTByIdentifier: (identifier: string, extra?: RequestInit) => Promise<NftData>;
28
+ getNFTByIdentifier: (identifier: string, extra?: RequestInit) => Promise<NftDoc>;
29
29
  /**
30
30
  * @public
31
31
  * @async
32
32
  * @function getNFTByIdentifier
33
33
  * @param {string} identifier - The identifier of the NFT to fetch data for.
34
- * @returns {Promise<NftData>} A promise that resolves to the fetched NFT data.
34
+ * @returns {Promise<NftDoc>} A promise that resolves to the fetched NFT data.
35
35
  *
36
36
  * This function fetches data for a given NFT by its identifier. It takes the following parameter:
37
37
  * - identifier (string): The identifier of the NFT to fetch data for.
@@ -40,36 +40,36 @@ export declare class NFTModule {
40
40
  * If it is valid, the function fetches the NFT data using the API.
41
41
  * Finally, it returns a promise that resolves to the fetched NFT data.
42
42
  */
43
- getNFTsOffers: (identifier: string, skip?: number, top?: number) => Promise<UserOffers>;
43
+ getNFTsOffers: ({ identifier, ...args }: ArgsQueryTop) => Promise<GetSingleNftOfferResponseDto>;
44
44
  /**
45
45
  * Gets an NFT by collection and nonce.
46
46
  * @param collection The collection ticker.
47
47
  * @param nonce The nonce of the NFT.
48
- * @returns {Promise<NftData>} The NFT data.
48
+ * @returns {Promise<NftDoc>} The NFT data.
49
49
  * @throws Throws an error when the collection ticker is invalid.
50
50
  */
51
- getNFTByCollectionAndNonce: (collection: string, nonce: number) => Promise<NftData>;
51
+ getNFTByCollectionAndNonce: (collection: string, nonce: number) => Promise<NftDoc>;
52
+ /**
53
+ * @public
54
+ * @async
55
+ * @function getDailyTrending
56
+ * @returns {Promise<NftDoc[]>} A promise that resolves to the array of trending NFTs.
57
+ * This function fetches the top NFTs that are trending today based on their floor and volumes
58
+ */
59
+ getDailyTrending: () => Promise<NftDoc[]>;
52
60
  /**
53
61
  * @public
54
62
  * @async
55
63
  * @function getPinnedNFTs
56
- * @returns {Promise<NftData[]>} A promise that resolves to the fetched pinned collections.
64
+ * @returns {Promise<NftDoc[]>} A promise that resolves to the fetched pinned collections.
57
65
  */
58
- getPinnedNFTs: (chain?: ActivityChain) => Promise<NftData[]>;
66
+ getPinnedNFTs: (chain?: ActivityChain) => Promise<NftDoc[]>;
59
67
  /**
60
68
  * Get NFT by collection and nonce hex
61
69
  *
62
70
  * @param collection - collection ticker
63
71
  * @param nonceHex - nonce hex
64
- * @return {Promise<NftData>} NFT data
65
- */
66
- getNFTByCollectionAndNonceHex: (collection: string, nonceHex: string) => Promise<NftData>;
67
- /**
68
- * Retrieves trading history based on the provided arguments.
69
- *
70
- * @param {TradincActivityArgs} args - The arguments for filtering the trading activity.
71
- * @returns {Promise<TradingActivityResponse>} A promise resolving to a TradingActivityResponse object containing the activity.
72
- * @throws {Error} Throws an error if the 'top' argument is greater than 100.
72
+ * @return {Promise<NftDoc>} NFT data
73
73
  */
74
- getTradingActivity: (args: TradincActivityArgs) => Promise<TradingActivityResponse>;
74
+ getNFTByCollectionAndNonceHex: (collection: string, nonceHex: string) => Promise<NftDoc>;
75
75
  }
@@ -1,7 +1,7 @@
1
1
  import type { IEventDoc } from './event';
2
2
  import type { ActivityChain, CollectionInfo, Media, NftData, NFTMetadata, Owner, SaleInfo } from './nft';
3
3
  import type { NftActivityType } from './trading';
4
- import type { CreatorProfile, IUserProfileSearch, OfferBody } from './user';
4
+ import type { CreatorProfile, IUserProfileSearch } from './user';
5
5
  export interface ISocials {
6
6
  twitter: string;
7
7
  instagram: string;
@@ -281,69 +281,6 @@ export declare enum AuctionTypes {
281
281
  All = "All",
282
282
  AllListed = "AllListed"
283
283
  }
284
- export interface GetNFTsArgs {
285
- /** Listed by different users */
286
- listedBy?: string[];
287
- /** Owned by different users */
288
- ownedBy?: string[];
289
- identifiers?: string[];
290
- auctionType: AuctionTypes;
291
- /** If set, will return only NFTs from the specified collections */
292
- collections?: string[];
293
- chain?: ActivityChain[];
294
- /** If set, will return only NFTs from verified collections */
295
- onlyVerified?: boolean;
296
- /** If true, will return only NFTs that are on sale */
297
- onlyOnSale?: boolean;
298
- /** If true, will return only NFTs that are active, deadline not expired */
299
- activeAuctions?: boolean;
300
- /** If true the extra details of an NFT will be appended to each NFT, such as collection size and owners name */
301
- applyNftExtraDetails?: boolean;
302
- /** If set, will return only NFTs with a price in the specified range */
303
- priceRange?: {
304
- min: number;
305
- max: number;
306
- };
307
- /** If set, will return only NFTs listed in the specified tokens */
308
- listedInToken?: string[];
309
- /** If set, will return only NFTs with a rank in the specified range */
310
- rankRange?: {
311
- min: number;
312
- max: number;
313
- };
314
- /** If set, will return only NFTs with a cantina level in the specified range */
315
- cantinaLevelRange?: {
316
- min: number;
317
- max: number;
318
- };
319
- /** If set, will return the total count of the NFTs, recommended to be set true only for the first call, then false for the next pages */
320
- includeCount?: boolean;
321
- /** If set, will apply the extra manual filters on top of the main payload */
322
- extraSearch?: string[];
323
- /** If set, will return only NFTs with a name that contains the specified string */
324
- searchName?: string;
325
- /** The number of results to return */
326
- top?: number;
327
- /** The order by to use */
328
- skip?: number;
329
- /** Document type */
330
- dataType?: string[];
331
- /** The nonces of the NFTs */
332
- nonces?: number[];
333
- /** If set, will return only NFTs that are staked */
334
- isStaked?: boolean;
335
- /** The order of the results based on a field */
336
- orderBy?: SearchOrderBy[];
337
- /** If set, will return only the specified fields */
338
- onlySelectFields?: FieldsToSelect[];
339
- /** If set, will return only NFTs listed in the specified marketplaces */
340
- listedOnlyOn?: Marketplace[];
341
- /** If set, will return only NFTs with the specified attributes */
342
- attributes?: MetadataAttribute[];
343
- /** If set, will return only the selected fields */
344
- strictSelect?: boolean;
345
- name?: string;
346
- }
347
284
  export interface GETDropsArgs {
348
285
  name?: string;
349
286
  /** If set, will return only NFTs from the specified collections */
@@ -380,26 +317,6 @@ export interface SuggestNFTsArgs {
380
317
  orderBy?: SuggestOrderBy[];
381
318
  chain?: ActivityChain[];
382
319
  }
383
- export interface SearchNFTsResponse {
384
- /** The total count of the results for the specific query */
385
- count?: number;
386
- /** The results for the current page */
387
- resources: NftData[];
388
- /** The payload to use to get the next page */
389
- getNextPagePayload: GetNFTsArgs;
390
- /** If there are more results to fetch */
391
- hasMoreResults: boolean;
392
- }
393
- export interface GetDropsResponse {
394
- /** The total count of the results for the specific query */
395
- count?: number;
396
- /** The results for the current page */
397
- resources: GetCollectionMintInfo[];
398
- /** The payload to use to get the next page */
399
- getNextPagePayload: GETDropsArgs;
400
- /** If there are more results to fetch */
401
- hasMoreResults: boolean;
402
- }
403
320
  export interface OfferFilters {
404
321
  isActive?: boolean[];
405
322
  identifier?: string[];
@@ -422,11 +339,6 @@ export interface GetOffersArgs {
422
339
  includeCount?: boolean;
423
340
  filters?: OfferFilters;
424
341
  }
425
- export interface GetOffersResponse {
426
- count?: number;
427
- resources: OfferBody[];
428
- hasMoreResults: boolean;
429
- }
430
342
  export type ActivityData = {
431
343
  collection: string;
432
344
  identifier: string;
@@ -501,17 +413,10 @@ export interface CollectionsNFTsResponse {
501
413
  /** The results for the current page */
502
414
  results: ICollectionProfile[];
503
415
  /** If the results are empty */
504
- empty: boolean;
505
416
  /** The payload to use to get the next page */
506
- getNextPagePayload: GetCollectionsArgs;
507
417
  /** If there are more results to fetch */
508
418
  hasMoreResults: boolean;
509
419
  }
510
- export interface SuggestResults {
511
- count: number;
512
- hasMoreResults: boolean;
513
- resources: ResultsBody;
514
- }
515
420
  export interface ResultsBody {
516
421
  collections: (ICollectionProfile & {
517
422
  floorPrice: number;
@@ -641,12 +546,6 @@ export type HoldedDetails = {
641
546
  export interface AvgHolder extends HoldedDetails {
642
547
  avgPerHodler: number;
643
548
  }
644
- export type GlobalOffersResult = {
645
- resources: GlobalOffers[];
646
- hasMoreResults: boolean;
647
- lastSkip: number;
648
- getNextPagePayload?: GetGlobalOffersArgs;
649
- };
650
549
  export type GlobalOffers = {
651
550
  offerId: number;
652
551
  collection: string;
@@ -716,11 +615,6 @@ export type StagePrice = {
716
615
  usdValue: number;
717
616
  decimals: number;
718
617
  };
719
- export type CollectionStatsResults = {
720
- resources: CollectionStatsDoc[];
721
- hasMoreResults: boolean;
722
- getNextPagePayload?: GetCollectionStatsArgs;
723
- };
724
618
  export type GetCollectionStatsArgs = {
725
619
  filters?: {
726
620
  chain?: ActivityChain[];
@@ -6,3 +6,18 @@ export * from './staking';
6
6
  export * from './user';
7
7
  export * from './common';
8
8
  export * from './event';
9
+ export type PublicOnly<T> = {
10
+ [K in keyof T as T[K] extends Function ? never : K]: T[K];
11
+ };
12
+ export interface ArgsQueryTop {
13
+ identifier: string;
14
+ skip: number;
15
+ top: number;
16
+ }
17
+ export interface ArgsUserOffers extends ArgsQueryTop {
18
+ type: OfferType;
19
+ }
20
+ export declare enum OfferType {
21
+ Received = "received",
22
+ Placed = "placed"
23
+ }
@@ -1,4 +1,4 @@
1
- import type { Marketplace, MetadataAttribute, RangeFilter, TradingActivity } from './collection';
1
+ import type { Marketplace, MetadataAttribute, RangeFilter } from './collection';
2
2
  import type { ActivityChain } from './nft';
3
3
  export declare enum NftActivityType {
4
4
  NFT_CREATE = "nftCreate",
@@ -109,11 +109,3 @@ export declare enum SelectFieldsTradingActivity {
109
109
  'marketplace' = 8,
110
110
  'payment_token' = 9
111
111
  }
112
- export interface TradingActivityResponse {
113
- hasMoreResults: boolean;
114
- /** The total count of the results for the specific query */
115
- count?: number;
116
- resources: TradingActivity[];
117
- getNextPagePayload: TradincActivityArgs;
118
- empty: boolean;
119
- }
@@ -86,21 +86,6 @@ export interface UserInventory {
86
86
  value: number;
87
87
  chain?: ActivityChain;
88
88
  }
89
- export interface UserOffers {
90
- hasMoreResults: boolean;
91
- count: number;
92
- resources: OfferBody[];
93
- }
94
- export interface ArgsUserOffers {
95
- address: string;
96
- type: OfferType;
97
- skip: number;
98
- top: number;
99
- }
100
- export declare enum OfferType {
101
- Received = "received",
102
- Placed = "placed"
103
- }
104
89
  export interface OfferBody {
105
90
  dataType: string;
106
91
  identifier: string;
@@ -124,12 +109,6 @@ export interface OfferBody {
124
109
  floorPrice: number;
125
110
  chain?: ActivityChain;
126
111
  }
127
- export type Nfts = {
128
- count: number;
129
- resultsCount: number;
130
- results: NftData[];
131
- empty: boolean;
132
- };
133
112
  export declare enum Type {
134
113
  NonFungibleESDT = "NonFungibleESDT"
135
114
  }
@@ -1,5 +1,6 @@
1
- import type { CollectionCreatorInfo, CreatorInfo, EventCreatorInfo, GetNFTsArgs, SearchNFTsResponse, StakingStatus, StakingSummaryPools, StakingSummaryPoolsSlim, StatusResponse, SuggestNFTsArgs, SuggestResults, TradincActivityArgs, TradingActivityResponse } from '../types';
2
- import type { ArgsUserOffers, BulkAccount, CreatorProfile, IApiShareholder, IOwnerInfo, IUserProfile, StakingCreatorInfo, UserAnalyticSummary, UserInventory, UserNetworkAccount, UserOffers, UserPoolStakingInfo, UserStats, UserTokenInventory, UserXOXNODrop } from '../types/user';
1
+ import type { FilterQueryDto, GetUserOffersResponseDto, GlobalSearchResponseDto, NftCosmosResponse, NftDocFilter } from '@xoxno/types';
2
+ import type { ArgsQueryTop, ArgsUserOffers, CollectionCreatorInfo, CreatorInfo, EventCreatorInfo, PublicOnly, StakingStatus, StakingSummaryPools, StakingSummaryPoolsSlim, StatusResponse } from '../types';
3
+ import type { BulkAccount, CreatorProfile, IApiShareholder, IOwnerInfo, IUserProfile, StakingCreatorInfo, UserAnalyticSummary, UserInventory, UserNetworkAccount, UserPoolStakingInfo, UserStats, UserTokenInventory, UserXOXNODrop } from '../types/user';
3
4
  export declare class UserModule {
4
5
  private api;
5
6
  private collection;
@@ -44,14 +45,14 @@ export declare class UserModule {
44
45
  * @param address - The user's address
45
46
  * @returns {UserInventory} - A list of token ids and the price
46
47
  */
47
- getUserNFTs: (args: GetNFTsArgs) => Promise<SearchNFTsResponse>;
48
+ getUserNFTs: (args: PublicOnly<NftDocFilter>) => Promise<NftCosmosResponse>;
48
49
  /**
49
50
  * @name getUserOffers
50
51
  * @description Fetches all offers sent or received associated with a user address
51
- * @param {String} address - The user's wallet address
52
+ * @param {ArgsUserOffers} address - The user's wallet address
52
53
  * @returns {UserOffers} - The user's listings
53
54
  */
54
- getUserOffers: (args: ArgsUserOffers) => Promise<UserOffers>;
55
+ getUserOffers: ({ identifier: address, ...args }: ArgsUserOffers) => Promise<GetUserOffersResponseDto>;
55
56
  /**
56
57
  * @public
57
58
  * @async
@@ -66,15 +67,7 @@ export declare class UserModule {
66
67
  *
67
68
  * Finally, it returns a promise that resolves to the fetched users results.
68
69
  */
69
- suggestUsers: (args: SuggestNFTsArgs) => Promise<SuggestResults>;
70
- /**
71
- * Retrieves trading history based on the provided arguments.
72
- *
73
- * @param {TradincActivityArgs} args - The arguments for filtering the trading activity.
74
- * @returns {Promise<TradingActivityResponse>} A promise resolving to a TradingActivityResponse object containing the activity.
75
- * @throws {Error} Throws an error if the 'top' argument is greater than 100.
76
- */
77
- getTradingActivity: (args: TradincActivityArgs) => Promise<TradingActivityResponse>;
70
+ suggestUsers: (args: PublicOnly<FilterQueryDto>) => Promise<GlobalSearchResponseDto>;
78
71
  /** Gets user's creator profile
79
72
  * @param {String} address - User's address
80
73
  * @returns {CreatorProfile} User's creator profile struct
@@ -141,10 +134,10 @@ export declare class UserModule {
141
134
  * @param {String} address - User's address
142
135
  * @param {number} top - Top
143
136
  * @param {number} skip - Skip
144
- * @returns {NftData[]} Array of NFTs
137
+ * @returns {NftDoc[]} Array of NFTs
145
138
  * @throws {Error} Throws an error if the address is invalid
146
139
  * */
147
- getUserFavoriteNFTs: (address: string, top: number, skip: number) => Promise<SearchNFTsResponse>;
140
+ getUserFavoriteNFTs: ({ identifier: address, ...args }: ArgsQueryTop) => Promise<NftCosmosResponse>;
148
141
  /** Gets user's favorite collection tickers
149
142
  * @param {String} address - User's address
150
143
  * @returns {String[]} Array of tickers
@@ -26,5 +26,7 @@ export declare class XOXNOClient {
26
26
  chain?: Chain;
27
27
  }>): XOXNOClient;
28
28
  static getInstance(): XOXNOClient;
29
- fetchWithTimeout: <T>(path: string, options?: Record<string, any>) => Promise<T>;
29
+ fetchWithTimeout: <T>(path: string, options?: RequestInit & {
30
+ params?: Record<string, any>;
31
+ }) => Promise<T>;
30
32
  }
@@ -0,0 +1,12 @@
1
+ export declare class CollectionNotFoundError extends Error {
2
+ constructor(item: string);
3
+ }
4
+ export declare class AddressNotFoundError extends Error {
5
+ constructor(item: string);
6
+ }
7
+ export declare class NFTNotFoundError extends Error {
8
+ constructor(item: string);
9
+ }
10
+ export declare class PaginatedTopError extends Error {
11
+ constructor(top: number);
12
+ }
@@ -0,0 +1,7 @@
1
+ export declare function collectionGuard<T>(collection: string, callback: Promise<T>): Promise<T>;
2
+ export declare function addressGuard<T>(address: string, callback: Promise<T>): Promise<T>;
3
+ export declare function nftGuard<T>(identifier: string, callback: Promise<T>): Promise<T>;
4
+ export declare function collectionGuardOnly(collection: string): Promise<void>;
5
+ export declare function paginatedGuard<T extends {
6
+ top?: number;
7
+ }, R>(filter: T, callback: (filter: string) => Promise<R>): Promise<R>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xoxno/sdk-js",
3
- "version": "0.1.353",
3
+ "version": "0.1.355",
4
4
  "description": "The SDK to interact with the XOXNO Protocol!",
5
5
  "type": "module",
6
6
  "exports": {
@@ -98,6 +98,7 @@
98
98
  "dependencies": {
99
99
  "@multiversx/sdk-core": "^13.17.2",
100
100
  "@multiversx/sdk-network-providers": "^2.9.3",
101
+ "@xoxno/types": "^1.0.11",
101
102
  "axios": "^1.7.9",
102
103
  "protobufjs": "^7.4.0",
103
104
  "webpack-bundle-analyzer": "^4.10.2"
@@ -1,10 +0,0 @@
1
- import type { XOXNOClient } from '..';
2
- import type { TradincActivityArgs, TradingActivityResponse } from '../types/trading';
3
- /**
4
- * Fetches the trading activity of the given collections
5
- * @param args - The trading activity arguments
6
- * @param api - The API client
7
- * @returns - The trading activity response
8
- * @throws - If the top is greater than 100
9
- */
10
- export declare const getActivity: (args: TradincActivityArgs, api: XOXNOClient) => Promise<TradingActivityResponse>;