@xoxno/sdk-js 0.0.2-alpha → 0.0.3-alpha

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xoxno/sdk-js",
3
- "version": "0.0.2-alpha",
3
+ "version": "0.0.3-alpha",
4
4
  "description": "The SDK to interact with the XOXNO Protocol!",
5
5
  "main": "./src/index.ts",
6
6
  "scripts": {
@@ -1,12 +1,12 @@
1
1
  import { CollectionModule } from './../index';
2
2
  import { APIClient } from '../../utils/api';
3
- import { FieldsToSelect } from '../../types';
3
+ import { CollectionsFieldsToSelect, FieldsToSelect } from '../../types';
4
4
 
5
5
  describe('CollectionModule', () => {
6
6
  let collectionModule: CollectionModule;
7
7
  const inputCollection = 'BANANA-e955fd';
8
8
  beforeAll(() => {
9
- APIClient.init('https://api.xoxno.com', '');
9
+ APIClient.init('https://proxy-api.xoxno.com', '');
10
10
  collectionModule = new CollectionModule();
11
11
  });
12
12
 
@@ -16,6 +16,13 @@ describe('CollectionModule', () => {
16
16
  expect(result.collection).toEqual(inputCollection);
17
17
  });
18
18
 
19
+ test('getCollectionProfiles should return the correct results', async () => {
20
+ const collectionModule = new CollectionModule();
21
+ const result = await collectionModule.getCollections();
22
+ expect(result).toBeDefined();
23
+ expect(result.results).toHaveLength(25);
24
+ });
25
+
19
26
  it('should get the floor price of a collection', async () => {
20
27
  const floorPrice = await collectionModule.getCollectionFloorPrice(
21
28
  inputCollection
@@ -1,4 +1,6 @@
1
1
  import {
2
+ CollectionsNFTsResponse,
3
+ GetCollectionsArgs,
2
4
  ICollectionAttributes,
3
5
  ICollectionProfile,
4
6
  SearchNFTs,
@@ -83,8 +85,8 @@ export class CollectionModule {
83
85
 
84
86
  /**
85
87
  * Searches for NFTs in a collection based on the provided arguments.
86
- * @param args - The SearchNFTsArgs object containing the search parameters.
87
- * @returns A Promise that resolves to the SearchNFTsResponse object.
88
+ * @param {SearchNFTsArgs} args - The SearchNFTsArgs object containing the search parameters.
89
+ * @returns {Promise<SearchNFTsResponse>} A Promise that resolves to the SearchNFTsResponse object.
88
90
  * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 35.
89
91
  */
90
92
  public searchNFTs = async (
@@ -155,4 +157,48 @@ export class CollectionModule {
155
157
  ): Promise<TradingActivityResponse> => {
156
158
  return await getActivity(args, this.api);
157
159
  };
160
+
161
+ /**
162
+ * Searches for NFTs in a collection based on the provided arguments.
163
+ * @param {GetCollectionsArgs} args - The SearchNFTsArgs object containing the search parameters.
164
+ * @returns {Promise<CollectionsNFTsResponse>} A Promise that resolves to the CollectionsNFTsResponse object.
165
+ * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 35.
166
+ */
167
+ public getCollections = async (
168
+ args?: GetCollectionsArgs
169
+ ): Promise<CollectionsNFTsResponse> => {
170
+ if (args?.top && args.top > 25) {
171
+ throw new Error('Top cannot be greater than 25');
172
+ }
173
+
174
+ const payloadBody = {
175
+ skip: args?.skip || 0,
176
+ top: args?.top || 25,
177
+ select: args?.onlySelectFields || [],
178
+ filters: {
179
+ dataType: 'collectionProfile',
180
+ isMintable: args?.onlyMintable || undefined,
181
+ ...(args?.collections &&
182
+ args.collections.length > 0 && {
183
+ collection: args.collections,
184
+ }),
185
+ },
186
+ orderBy: [args?.orderBy || 'statistics.tradeData.weekEgldVolume desc'],
187
+ };
188
+
189
+ const buffer = Buffer.from(JSON.stringify(payloadBody)).toString('base64');
190
+ const response = await this.api.fetchWithTimeout<ICollectionProfile[]>(
191
+ `/collections/${buffer}`
192
+ );
193
+ return {
194
+ results: response,
195
+ resultsCount: response.length,
196
+ empty: response.length === 0,
197
+ getNextPagePayload: {
198
+ ...args,
199
+ skip: (args?.skip || 0) + (args?.top || 25),
200
+ },
201
+ hasMoreResults: response.length < (args?.top || 25),
202
+ };
203
+ };
158
204
  }
@@ -20,6 +20,6 @@ describe('SCInteraction', () => {
20
20
  const tags = await sc.getStages('Elonverse');
21
21
  expect(tags).toBeDefined();
22
22
  // expect(tags).toContain('Elonverse');
23
- console.log(tags);
23
+ // console.log(tags);
24
24
  });
25
25
  });
@@ -155,6 +155,43 @@ export const enum SearchOrderBy {
155
155
  OldestListed = 'saleInfoNft/timestamp asc',
156
156
  }
157
157
 
158
+ export const enum CollectionsOrderBy {
159
+ WeekVolumeHighToLow = 'statistics.tradeData.weekEgldVolume desc',
160
+ WeekVolumeLowToHigh = 'statistics.tradeData.weekEgldVolume asc',
161
+ DailyVolumeHighToLow = 'statistics.tradeData.dayEgldVolume desc',
162
+ DailyVolumeLowToHigh = 'statistics.tradeData.dayEgldVolume asc',
163
+ TotalVolumeHighToLow = 'statistics.tradeData.totalEgldVolume desc',
164
+ TotalVolumeLowToHigh = 'statistics.tradeData.totalEgldVolume asc',
165
+ AvgVolumePriceHighToLow = 'statistics.tradeData.averageEgldPrice desc',
166
+ AvgVolumePriceLowToHigh = 'statistics.tradeData.averageEgldPrice asc',
167
+ ATHHighToLow = 'statistics.tradeData.athEgldPrice desc',
168
+ ATHLowToHigh = 'statistics.tradeData.athEgldPrice asc',
169
+ TotalTradesHighToLow = 'statistics.tradeData.totalTrades desc',
170
+ TotalTradesLowToHigh = 'statistics.tradeData.totalTrades asc',
171
+ SupplyHighToLow = 'statistics.other.nftCount desc',
172
+ SupplyLowToHigh = 'statistics.other.nftCount asc',
173
+ FollowersHighToLow = 'statistics.other.followCount desc',
174
+ FollowersLowToHigh = 'statistics.other.followCount asc',
175
+ }
176
+
177
+ export const enum CollectionsFieldsToSelect {
178
+ Profile = 'profile',
179
+ Description = 'description',
180
+ Creator = 'creator',
181
+ Owner = 'owner',
182
+ Socials = 'socials',
183
+ Type = 'type',
184
+ HasStaking = 'hasStaking',
185
+ MintInfo = 'mintInfo',
186
+ MintStages = 'mintStages',
187
+ Name = 'name',
188
+ Banner = 'banner',
189
+ IsVerified = 'isVerified',
190
+ IsMintable = 'isMintable',
191
+ Statistics = 'statistics',
192
+ Collection = 'collection',
193
+ }
194
+
158
195
  export interface Filter {
159
196
  marketplace?: Marketplace[];
160
197
  onSale?: boolean;
@@ -265,3 +302,31 @@ export interface TradingActivity {
265
302
  webpUrl: string;
266
303
  _ts: number;
267
304
  }
305
+
306
+ export interface GetCollectionsArgs {
307
+ /** The collections to fetch the profile */
308
+ collections?: string[];
309
+ /** If true, will return only NFTs that are mintable */
310
+ onlyMintable?: boolean;
311
+ /** The number of results to return */
312
+ top?: number;
313
+ /** The order by to use */
314
+ skip?: number;
315
+ /** The order of the results based on a field */
316
+ orderBy?: CollectionsOrderBy;
317
+ /** If set, will return only the specified fields */
318
+ onlySelectFields?: CollectionsFieldsToSelect[];
319
+ }
320
+
321
+ export interface CollectionsNFTsResponse {
322
+ /** The results count for the current page */
323
+ resultsCount: number;
324
+ /** The results for the current page */
325
+ results: ICollectionProfile[];
326
+ /** If the results are empty */
327
+ empty: boolean;
328
+ /** The payload to use to get the next page */
329
+ getNextPagePayload: GetCollectionsArgs;
330
+ /** If there are more results to fetch */
331
+ hasMoreResults: boolean;
332
+ }
@@ -1,36 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: npm ci
19
- - run: npm test
20
-
21
- publish-gpr:
22
- needs: build
23
- runs-on: ubuntu-latest
24
- permissions:
25
- contents: read
26
- packages: write
27
- steps:
28
- - uses: actions/checkout@v3
29
- - uses: actions/setup-node@v3
30
- with:
31
- node-version: 16
32
- registry-url: https://npm.pkg.github.com/
33
- - run: npm ci
34
- - run: npm publish
35
- env:
36
- NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -1,33 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: npm ci
19
- - run: npm test
20
-
21
- publish-npm:
22
- needs: build
23
- runs-on: ubuntu-latest
24
- steps:
25
- - uses: actions/checkout@v3
26
- - uses: actions/setup-node@v3
27
- with:
28
- node-version: 16
29
- registry-url: https://registry.npmjs.org/
30
- - run: npm ci
31
- - run: npm publish
32
- env:
33
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -1,3 +0,0 @@
1
- {
2
- "livePreview.defaultPreviewPath": "/docs/index.html"
3
- }