@xoxno/sdk-js 0.0.1 → 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/README.md +22 -0
- package/dist/xoxno.min.js +1 -0
- package/package.json +1 -1
- package/src/collection/__tests__/collection.test.ts +9 -2
- package/src/collection/index.ts +48 -2
- package/src/launchpad/__tests__/market.test.ts +25 -0
- package/src/launchpad/index.ts +166 -0
- package/src/types/collection.d.ts +65 -0
- package/.github/workflows/npm-publish-github-packages.yml +0 -36
- package/.vscode/settings.json +0 -3
- package/coverage/clover.xml +0 -280
- package/coverage/coverage-final.json +0 -12
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/collection/index.html +0 -116
- package/coverage/lcov-report/collection/index.ts.html +0 -559
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -161
- package/coverage/lcov-report/interactions/index.html +0 -116
- package/coverage/lcov-report/interactions/index.ts.html +0 -775
- package/coverage/lcov-report/nft/index.html +0 -116
- package/coverage/lcov-report/nft/index.ts.html +0 -379
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/utils/SmartContractAbis.ts.html +0 -331
- package/coverage/lcov-report/utils/SmartContractService.ts.html +0 -136
- package/coverage/lcov-report/utils/api.ts.html +0 -484
- package/coverage/lcov-report/utils/const.ts.html +0 -163
- package/coverage/lcov-report/utils/getActivity.ts.html +0 -250
- package/coverage/lcov-report/utils/helpers.ts.html +0 -127
- package/coverage/lcov-report/utils/index.html +0 -221
- package/coverage/lcov-report/utils/regex.ts.html +0 -106
- package/coverage/lcov-report/utils/scCalls.ts.html +0 -229
- package/coverage/lcov.info +0 -525
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -64
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1279
- package/docs/classes/collection.CollectionModule.html +0 -232
- package/docs/classes/interactions.SCInteraction.html +0 -370
- package/docs/classes/nft.NFTModule.html +0 -208
- package/docs/classes/utils_SmartContractAbis.SmartContractAbis.html +0 -198
- package/docs/classes/utils_api.APIClient.html +0 -212
- package/docs/classes/utils_scCalls.ContractQueryRunner.html +0 -129
- package/docs/enums/types_collection.FieldsToSelect.html +0 -186
- package/docs/enums/types_collection.Marketplace.html +0 -102
- package/docs/enums/types_collection.SearchOrderBy.html +0 -130
- package/docs/enums/types_trading.OrderByTradingActivity.html +0 -102
- package/docs/enums/types_trading.SelectFieldsTradingActivity.html +0 -144
- package/docs/enums/utils_api.Chain.html +0 -88
- package/docs/functions/utils_SmartContractService.getSmartContract.html +0 -77
- package/docs/functions/utils_getActivity.getActivity.html +0 -89
- package/docs/functions/utils_helpers.getIdentifierFromColAndNonce.html +0 -76
- package/docs/functions/utils_helpers.nonceToHex.html +0 -74
- package/docs/functions/utils_regex.isValidCollectionTicker.html +0 -74
- package/docs/functions/utils_regex.isValidNftIdentifier.html +0 -74
- package/docs/index.html +0 -55
- package/docs/interfaces/types_collection.AttributeData.html +0 -99
- package/docs/interfaces/types_collection.Filter.html +0 -157
- package/docs/interfaces/types_collection.GlobalOffer.html +0 -176
- package/docs/interfaces/types_collection.ICollectionAttributes.html +0 -85
- package/docs/interfaces/types_collection.ICollectionProfile.html +0 -263
- package/docs/interfaces/types_collection.IMintInfo.html +0 -155
- package/docs/interfaces/types_collection.ISocials.html +0 -127
- package/docs/interfaces/types_collection.MetadataAttribute.html +0 -92
- package/docs/interfaces/types_collection.SearchNFTs.html +0 -127
- package/docs/interfaces/types_collection.SearchNFTsArgs.html +0 -225
- package/docs/interfaces/types_collection.SearchNFTsResponse.html +0 -132
- package/docs/interfaces/types_collection.TradingActivity.html +0 -232
- package/docs/interfaces/types_collection.TraitValues.html +0 -85
- package/docs/interfaces/types_nft.GameData.html +0 -92
- package/docs/interfaces/types_nft.NFTAttribute.html +0 -127
- package/docs/interfaces/types_nft.NFTMetadata.html +0 -104
- package/docs/interfaces/types_nft.NftData.html +0 -253
- package/docs/interfaces/types_nft.NftValue.html +0 -106
- package/docs/interfaces/types_nft.OffersInfo.html +0 -169
- package/docs/interfaces/types_nft.OriginalMedia.html +0 -92
- package/docs/interfaces/types_nft.SaleInfoNft.html +0 -211
- package/docs/interfaces/types_trading.TradincActivityArgs.html +0 -225
- package/docs/interfaces/types_trading.TradingActivityQueryFilter.html +0 -151
- package/docs/interfaces/types_trading.TradingActivityResponse.html +0 -106
- package/docs/modules/collection.html +0 -71
- package/docs/modules/interactions.html +0 -71
- package/docs/modules/nft.html +0 -71
- package/docs/modules/types.html +0 -189
- package/docs/modules/types_collection.html +0 -104
- package/docs/modules/types_interactions.html +0 -69
- package/docs/modules/types_nft.html +0 -85
- package/docs/modules/types_trading.html +0 -82
- package/docs/modules/utils_SmartContractAbis.html +0 -71
- package/docs/modules/utils_SmartContractService.html +0 -71
- package/docs/modules/utils_api.html +0 -76
- package/docs/modules/utils_const.html +0 -95
- package/docs/modules/utils_getActivity.html +0 -71
- package/docs/modules/utils_helpers.html +0 -73
- package/docs/modules/utils_regex.html +0 -73
- package/docs/modules/utils_scCalls.html +0 -71
- package/docs/modules.html +0 -76
- package/docs/types/types_interactions.Offer.html +0 -89
- package/docs/variables/utils_const.API_URL.html +0 -76
- package/docs/variables/utils_const.API_URL_DEV.html +0 -76
- package/docs/variables/utils_const.DR_SC.html +0 -76
- package/docs/variables/utils_const.FM_SC.html +0 -76
- package/docs/variables/utils_const.KG_SC.html +0 -76
- package/docs/variables/utils_const.Manager_SC.html +0 -76
- package/docs/variables/utils_const.Manager_SC_DEV.html +0 -76
- package/docs/variables/utils_const.P2P_SC.html +0 -76
- package/docs/variables/utils_const.P2P_SC_DEV.html +0 -76
- package/docs/variables/utils_const.Staking_SC.html +0 -76
- package/docs/variables/utils_const.Staking_SC_DEV.html +0 -76
- package/docs/variables/utils_const.XOXNO_SC.html +0 -76
- package/docs/variables/utils_const.XOXNO_SC_DEV.html +0 -76
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# XOXNO SDK
|
|
2
|
+
|
|
3
|
+
XOXNO SDK is a JavaScript library that simplifies the interaction with the XOXNO Protocol for developers. It includes a set of helper functions and modules that make it easy to fetch, filter, and interact with data from the XOXNO Protocol and its NFT marketplace.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Initialization](#initialization)
|
|
10
|
+
- [Fetching Data](#fetching-data)
|
|
11
|
+
- [Interacting with the Smart Contract](#interacting-with-the-smart-contract)
|
|
12
|
+
- [Testing](#testing)
|
|
13
|
+
- [Contributing](#contributing)
|
|
14
|
+
- [License](#license)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
To install the XOXNO SDK, simply run the following command in your project's root directory:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install xoxno-sdk
|
|
22
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.XOXNO=e():t.XOXNO=e()}(self,(()=>(()=>{"use strict";var t={d:(e,o)=>{for(var i in o)t.o(o,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:o[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XOXNO:()=>r});class o{static instance;apiUrl;apiKey;constructor(t,e){this.apiUrl=t,this.apiKey=e}static init(t,e){return o.instance||(o.instance=new o(t,e)),o.instance}static getClient(){if(!o.instance)throw new Error("APIClient has not been initialized");return o.instance}fetchWithTimeout=async(t,e={},o=4e4)=>{const i=new AbortController,{signal:n}=i,r=Math.round((new Date).getTime()/1e3),a=setTimeout((()=>{i.abort()}),o);let s;const c={"Accept-Encoding":"gzip,deflate,br","xo-time":`Sent-At:${r}`,Referer:"https://xoxno.dev","User-Agent":"XOXNO/1.0/SDK",..."POST"===e.method?{"Content-Type":"application/json"}:{},...e.headers??{}};try{if(s=await fetch(`${this.apiUrl}${t}${e.params?"?"+Object.keys(e.params).map((t=>`${t}=${encodeURIComponent(e.params[t])}`)).join("&"):""}`,{signal:n,...e,...Object.keys(c).length?{headers:c}:{},method:e.method??"GET"}),!s.ok){const t=await(s?.text());throw new Error(t)}return clearTimeout(a),await s.json()}catch(o){throw new Error("Something went wrong inside fetchWithTimeout "+t+" "+JSON.stringify(e)+" "+o)}}}const i=t=>/^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(t);class n{api;constructor(){this.api=o.getClient()}getCollectionProfile=async t=>{if(!i(t))throw new Error("Invalid collection ticker: "+t);return await this.api.fetchWithTimeout(`/getCollectionProfile/${t}`)};getCollectionFloorPrice=async(t,e="EGLD")=>{if(!i(t))throw new Error("Invalid collection ticker: "+t);return await this.api.fetchWithTimeout(`/getFloorPrice/${t}/${e}`)};getCollectionAttributes=async t=>{if(!i(t))throw new Error("Invalid collection ticker: "+t);return await this.api.fetchWithTimeout(`/getCollectionAttributes/${t}`)};searchNFTs=async t=>{if(!i(t.collection))throw new Error("Invalid collection ticker: "+t.collection);if(t.top&&t.top>35)throw new Error("Top cannot be greater than 35");const e={filters:{onSale:t.onlyOnSale||!1,marketplace:t.listedOnlyOn||void 0,auctionTypes:t.onlyOnSale?t.onlyAuctions?["NftBid","SftAll"]:["Nft","SftOnePerPayment"]:void 0,tokens:t.listedInToken||void 0,attributes:t.attributes||void 0,range:t.priceRange?{...t.priceRange,type:t.onlyAuctions?"saleInfoNft/current_bid_short":"saleInfoNft/min_bid_short"}:void 0,rankRange:t.rankRange||void 0,levelRange:t.cantinaLevelRange||void 0},name:t.searchName||"",orderBy:t.orderBy||void 0,collection:t.collection,top:t.top||35,skip:t.skip||0},o=Buffer.from(JSON.stringify(e)).toString("base64"),n=await this.api.fetchWithTimeout(`/searchNFTs/${o}`);return{...n,getNextPagePayload:{...t,skip:(t.skip??0)+(t.top??35)},hasMoreResults:n.resultsCount>(t.skip??0)+(t.top??35)}};getTradingActivity=async t=>await(async(t,e)=>{if(t.top&&t.top>35)throw new Error("Top cannot be greater than 35");const o={filters:{collection:t.collections,identifier:t.identifier||void 0,address:t.owners||void 0,tokens:t.placedInToken||void 0,marketplace:t.marketplaces||void 0,action:t.actions||void 0,range:t.priceRange,rankRange:t.rankRange,timestampRange:t.timestampRange,attributes:t.attributes},orderBy:t.orderBy,select:t.select,top:t.top||35,skip:t.skip||0},i=Buffer.from(JSON.stringify(o)).toString("base64"),n=await e.fetchWithTimeout(`/getTradingActivity/${i}`);return{...n,getNextPagePayload:{...t,skip:(t.skip??0)+(t.top??35)},empty:0===n.resources.length}})(t,this.api)}class r{collection;constructor(t="https://proxy-api.xoxno.com",e=""){o.init(t,e),this.collection=new n}}return e})()));
|
package/package.json
CHANGED
|
@@ -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
|
package/src/collection/index.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LaunchpadModule } from '../index';
|
|
2
|
+
import { APIClient } from '../../utils/api';
|
|
3
|
+
|
|
4
|
+
describe('SCInteraction', () => {
|
|
5
|
+
let sc: LaunchpadModule;
|
|
6
|
+
beforeAll(async () => {
|
|
7
|
+
APIClient.init();
|
|
8
|
+
sc = await LaunchpadModule.init(
|
|
9
|
+
'erd1qqqqqqqqqqqqqpgqtwtp5uz97u232zvzd973upqxwe2xnqv2ys5s3c7jx9'
|
|
10
|
+
);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should return all the unique tags of the launchpad SC', async () => {
|
|
14
|
+
const tags = await sc.getAllUniqueTags();
|
|
15
|
+
expect(tags).toBeDefined();
|
|
16
|
+
expect(tags).toContain('Elonverse');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return all the unique stages of a collection from the launchpad SC', async () => {
|
|
20
|
+
const tags = await sc.getStages('Elonverse');
|
|
21
|
+
expect(tags).toBeDefined();
|
|
22
|
+
// expect(tags).toContain('Elonverse');
|
|
23
|
+
// console.log(tags);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { SmartContract, Address, Interaction } from '@multiversx/sdk-core/out';
|
|
2
|
+
import { SmartContractAbis } from '../utils/SmartContractAbis';
|
|
3
|
+
import { getSmartContract } from '../utils/SmartContractService';
|
|
4
|
+
import { ContractQueryRunner } from '../utils/scCalls';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LaunchpadModule provides methods to interact with the minter smart contract.
|
|
8
|
+
* @class
|
|
9
|
+
*/
|
|
10
|
+
export class LaunchpadModule {
|
|
11
|
+
private minter: SmartContract;
|
|
12
|
+
private call: ContractQueryRunner;
|
|
13
|
+
/**
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {SmartContract} minterAbiXOXNO - The minter smart contract instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor(minterAbiXOXNO: SmartContract) {
|
|
18
|
+
this.minter = minterAbiXOXNO;
|
|
19
|
+
this.call = new ContractQueryRunner();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Executes the provided interaction and returns the result.
|
|
24
|
+
* @private
|
|
25
|
+
* @param {Interaction} interaction - The smart contract interaction.
|
|
26
|
+
* @returns {Promise<any>} The result of the interaction.
|
|
27
|
+
*/
|
|
28
|
+
private async getResult(interaction: Interaction) {
|
|
29
|
+
return await this.call.runQuery(this.minter, interaction);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Initializes the LaunchpadModule with a minter smart contract instance.
|
|
34
|
+
* @static
|
|
35
|
+
* @param {string} minterSC - The minter smart contract address.
|
|
36
|
+
* @returns {Promise<LaunchpadModule>} A new instance of LaunchpadModule.
|
|
37
|
+
*/
|
|
38
|
+
static async init(minterSC: string) {
|
|
39
|
+
const minterAbiXOXNO = await SmartContractAbis.getMinter();
|
|
40
|
+
const minter_abi = getSmartContract(
|
|
41
|
+
minterAbiXOXNO,
|
|
42
|
+
new Address(minterSC),
|
|
43
|
+
'Minter'
|
|
44
|
+
);
|
|
45
|
+
return new LaunchpadModule(minter_abi);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Fetches all unique tags from the minter smart contract.
|
|
50
|
+
* @public
|
|
51
|
+
* @returns {Promise<string[]>} An array of unique tags.
|
|
52
|
+
*/
|
|
53
|
+
public getAllUniqueTags = async (): Promise<string[]> => {
|
|
54
|
+
const interaction = this.minter.methods.collections();
|
|
55
|
+
const result = await this.getResult(interaction);
|
|
56
|
+
return result.firstValue?.valueOf().map((x: any) => x.toString());
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Fetches the global buy count for a user and tag.
|
|
61
|
+
* @public
|
|
62
|
+
* @param {string} user - The user's address.
|
|
63
|
+
* @param {string} tag - The tag.
|
|
64
|
+
* @returns {Promise<number>} The global buy count.
|
|
65
|
+
*/
|
|
66
|
+
public getWalletGlobalBuyCount = async (
|
|
67
|
+
user: string,
|
|
68
|
+
tag: string
|
|
69
|
+
): Promise<number> => {
|
|
70
|
+
const interaction = this.minter.methods.buysPerWallet([user, tag]);
|
|
71
|
+
const result = await this.getResult(interaction);
|
|
72
|
+
return result.firstValue?.valueOf();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Fetches the stage buy count for a user, tag, and stage.
|
|
77
|
+
* @public
|
|
78
|
+
* @param {string} user - The user's address.
|
|
79
|
+
* @param {string} tag - The tag.
|
|
80
|
+
* @param {string} stage - The stage.
|
|
81
|
+
* @returns {Promise<number>} The stage buy count.
|
|
82
|
+
*/
|
|
83
|
+
public getWalletStageBuyCount = async (
|
|
84
|
+
user: string,
|
|
85
|
+
tag: string,
|
|
86
|
+
stage: string
|
|
87
|
+
): Promise<number> => {
|
|
88
|
+
const interaction = this.minter.methods.buysStagePerWallet([
|
|
89
|
+
user,
|
|
90
|
+
tag,
|
|
91
|
+
stage,
|
|
92
|
+
]);
|
|
93
|
+
const result = await this.getResult(interaction);
|
|
94
|
+
return result.firstValue?.valueOf();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Fetches the local owner's address from the minter smart contract.
|
|
99
|
+
* @public
|
|
100
|
+
* @returns {Promise<string>} The local owner's address.
|
|
101
|
+
*/
|
|
102
|
+
public getLocalOwner = async (): Promise<string> => {
|
|
103
|
+
const interaction = this.minter.methods.localOwner();
|
|
104
|
+
const result = await this.getResult(interaction);
|
|
105
|
+
return result.firstValue?.valueOf();
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Fetches the launchpad cut fee percentage from the minter smart contract.
|
|
110
|
+
* @public
|
|
111
|
+
* @returns {Promise<number>} The launchpad cut fee percentage.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
public getLaunchpadCutFee = async (): Promise<number> => {
|
|
115
|
+
const interaction = this.minter.methods.cutPercentage();
|
|
116
|
+
const result = await this.getResult(interaction);
|
|
117
|
+
return result.firstValue?.valueOf();
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Fetches the stage whitelist of wallets for a tag and stage.
|
|
122
|
+
* @public
|
|
123
|
+
* @param {string} tag - The tag.
|
|
124
|
+
* @param {string} stage - The stage.
|
|
125
|
+
* @returns {Promise<string[]>} An array of whitelisted wallet addresses.
|
|
126
|
+
*/
|
|
127
|
+
public getStageWhitelist = async (
|
|
128
|
+
tag: string,
|
|
129
|
+
stage: string
|
|
130
|
+
): Promise<string[]> => {
|
|
131
|
+
const interaction = this.minter.methods.getWhitelistedWallets([tag, stage]);
|
|
132
|
+
const result = await this.getResult(interaction);
|
|
133
|
+
return result.firstValue?.valueOf().map((x: any) => x.toString());
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Fetches the list of stages for a tag.
|
|
138
|
+
* @public
|
|
139
|
+
* @param {string} tag - The tag.
|
|
140
|
+
* @returns {Promise<string[]>} An array of stages.
|
|
141
|
+
*/
|
|
142
|
+
public getStages = async (tag: string): Promise<string[]> => {
|
|
143
|
+
const interaction = this.minter.methods.mintStage([tag]);
|
|
144
|
+
const result = await this.getResult(interaction);
|
|
145
|
+
return result.firstValue?.valueOf().map((x: any) => {
|
|
146
|
+
const body = x[1].valueOf();
|
|
147
|
+
body.name = body.name.toString();
|
|
148
|
+
body.tag = body.name.toString();
|
|
149
|
+
body.start_time = parseInt(body.start_time.toString());
|
|
150
|
+
body.end_time = parseInt(body.end_time.toString());
|
|
151
|
+
body.mint_limit = parseInt(body.mint_limit.toString());
|
|
152
|
+
body.mint_count = parseInt(body.mint_count.toString());
|
|
153
|
+
body.max_per_wallet = parseInt(body.max_per_wallet.toString());
|
|
154
|
+
body.prices = body.prices.map((x: any) => {
|
|
155
|
+
const pr = x.valueOf();
|
|
156
|
+
return {
|
|
157
|
+
...pr,
|
|
158
|
+
token_nonce: parseInt(pr.token_nonce.toString()),
|
|
159
|
+
amount: pr.amount.toString(),
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return body;
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -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}}
|
package/.vscode/settings.json
DELETED