@xoxno/sdk-js 0.0.8-alpha → 0.0.9-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.
Files changed (41) hide show
  1. package/dist/collection/index.d.ts +3 -3
  2. package/dist/collection/index.js +154 -0
  3. package/dist/collection/index.js.map +1 -0
  4. package/dist/index.d.ts +5 -0
  5. package/dist/index.js +40 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/interactions/index.js +209 -0
  8. package/dist/interactions/index.js.map +1 -0
  9. package/dist/launchpad/index.js +158 -0
  10. package/dist/launchpad/index.js.map +1 -0
  11. package/dist/nft/index.js +87 -0
  12. package/dist/nft/index.js.map +1 -0
  13. package/dist/types/collection.js +78 -0
  14. package/dist/types/collection.js.map +1 -0
  15. package/dist/types/index.d.ts +1 -0
  16. package/dist/types/index.js +21 -0
  17. package/dist/types/index.js.map +1 -0
  18. package/dist/types/interactions.js +3 -0
  19. package/dist/types/interactions.js.map +1 -0
  20. package/dist/types/nft.js +3 -0
  21. package/dist/types/nft.js.map +1 -0
  22. package/dist/types/trading.js +24 -0
  23. package/dist/types/trading.js.map +1 -0
  24. package/dist/utils/SmartContractAbis.js +81 -0
  25. package/dist/utils/SmartContractAbis.js.map +1 -0
  26. package/dist/utils/SmartContractService.js +13 -0
  27. package/dist/utils/SmartContractService.js.map +1 -0
  28. package/dist/utils/api.js +91 -0
  29. package/dist/utils/api.js.map +1 -0
  30. package/dist/utils/const.js +17 -0
  31. package/dist/utils/const.js.map +1 -0
  32. package/dist/utils/getActivity.js +48 -0
  33. package/dist/utils/getActivity.js.map +1 -0
  34. package/dist/utils/helpers.js +16 -0
  35. package/dist/utils/helpers.js.map +1 -0
  36. package/dist/utils/regex.js +12 -0
  37. package/dist/utils/regex.js.map +1 -0
  38. package/dist/utils/scCalls.js +39 -0
  39. package/dist/utils/scCalls.js.map +1 -0
  40. package/package.json +6 -7
  41. package/dist/index.min.js +0 -1
@@ -50,10 +50,10 @@ export declare class CollectionModule {
50
50
  */
51
51
  getTradingActivity: (args: TradincActivityArgs) => Promise<TradingActivityResponse>;
52
52
  /**
53
- * Searches for NFTs in a collection based on the provided arguments.
54
- * @param {GetCollectionsArgs} args - The SearchNFTsArgs object containing the search parameters.
53
+ * Fetch collections profiles based on the provided arguments.
54
+ * @param {GetCollectionsArgs} args - The GetCollectionsArgs object containing the search parameters.
55
55
  * @returns {Promise<CollectionsNFTsResponse>} A Promise that resolves to the CollectionsNFTsResponse object.
56
- * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 35.
56
+ * @throws An error if the 'top' value is greater than 35.
57
57
  */
58
58
  getCollections: (args?: GetCollectionsArgs) => Promise<CollectionsNFTsResponse>;
59
59
  }
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CollectionModule = void 0;
13
+ const api_1 = require("../utils/api");
14
+ const getActivity_1 = require("../utils/getActivity");
15
+ const regex_1 = require("../utils/regex");
16
+ /**
17
+ * CollectionModule provides a set of methods to interact with NFT collections.
18
+ * It includes methods for getting collection profile information, floor price,
19
+ * collection attributes, and searching NFTs within a collection.
20
+ *
21
+ * @example
22
+ * const xoxno = new XOXNO({ apiURL: 'https://api.xoxno.com', apiKey: 'your-api-key' });
23
+ * const collectionModule = xoxno.collection;
24
+ */
25
+ class CollectionModule {
26
+ constructor() {
27
+ /**
28
+ * Fetches the profile of a collection.
29
+ * @param collection - The ticker of the collection.
30
+ * @returns A Promise that resolves to the ICollectionProfile object.
31
+ * @throws An error if the provided collection ticker is invalid.
32
+ */
33
+ this.getCollectionProfile = (collection) => __awaiter(this, void 0, void 0, function* () {
34
+ if (!(0, regex_1.isValidCollectionTicker)(collection)) {
35
+ throw new Error('Invalid collection ticker: ' + collection);
36
+ }
37
+ const response = yield this.api.fetchWithTimeout(`/getCollectionProfile/${collection}`);
38
+ return response;
39
+ });
40
+ /**
41
+ * Fetches the floor price of a collection.
42
+ * @param collection - The ticker of the collection.
43
+ * @param token - The token for the floor price calculation (default: 'EGLD').
44
+ * @returns A Promise that resolves to the collection's floor price as a number.
45
+ * @throws An error if the provided collection ticker is invalid.
46
+ */
47
+ this.getCollectionFloorPrice = (collection, token = 'EGLD') => __awaiter(this, void 0, void 0, function* () {
48
+ if (!(0, regex_1.isValidCollectionTicker)(collection)) {
49
+ throw new Error('Invalid collection ticker: ' + collection);
50
+ }
51
+ const response = yield this.api.fetchWithTimeout(`/getFloorPrice/${collection}/${token}`);
52
+ return response;
53
+ });
54
+ /**
55
+ * Fetches the attributes of a collection.
56
+ * @param collection - The ticker of the collection.
57
+ * @returns A Promise that resolves to the ICollectionAttributes object.
58
+ * @throws An error if the provided collection ticker is invalid.
59
+ */
60
+ this.getCollectionAttributes = (collection) => __awaiter(this, void 0, void 0, function* () {
61
+ if (!(0, regex_1.isValidCollectionTicker)(collection)) {
62
+ throw new Error('Invalid collection ticker: ' + collection);
63
+ }
64
+ const response = yield this.api.fetchWithTimeout(`/getCollectionAttributes/${collection}`);
65
+ return response;
66
+ });
67
+ /**
68
+ * Searches for NFTs in a collection based on the provided arguments.
69
+ * @param {SearchNFTsArgs} args - The SearchNFTsArgs object containing the search parameters.
70
+ * @returns {Promise<SearchNFTsResponse>} A Promise that resolves to the SearchNFTsResponse object.
71
+ * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 35.
72
+ */
73
+ this.searchNFTs = (args) => __awaiter(this, void 0, void 0, function* () {
74
+ var _a, _b, _c, _d;
75
+ if (!(0, regex_1.isValidCollectionTicker)(args.collection)) {
76
+ throw new Error('Invalid collection ticker: ' + args.collection);
77
+ }
78
+ if (args.top && args.top > 35) {
79
+ throw new Error('Top cannot be greater than 35');
80
+ }
81
+ const payloadBody = {
82
+ filters: {
83
+ onSale: args.onlyOnSale || false,
84
+ marketplace: args.listedOnlyOn || undefined,
85
+ auctionTypes: args.onlyOnSale
86
+ ? args.onlyAuctions
87
+ ? ['NftBid', 'SftAll']
88
+ : ['Nft', 'SftOnePerPayment']
89
+ : undefined,
90
+ tokens: args.listedInToken || undefined,
91
+ attributes: args.attributes || undefined,
92
+ range: args.priceRange
93
+ ? Object.assign(Object.assign({}, args.priceRange), { type: args.onlyAuctions
94
+ ? 'saleInfoNft/current_bid_short'
95
+ : 'saleInfoNft/min_bid_short' }) : undefined,
96
+ rankRange: args.rankRange || undefined,
97
+ levelRange: args.cantinaLevelRange || undefined,
98
+ },
99
+ name: args.searchName || '',
100
+ orderBy: args.orderBy || undefined,
101
+ collection: args.collection,
102
+ select: args.onlySelectFields || undefined,
103
+ top: args.top || 35,
104
+ skip: args.skip || 0,
105
+ };
106
+ const buffer = Buffer.from(JSON.stringify(payloadBody)).toString('base64');
107
+ const response = yield this.api.fetchWithTimeout(`/searchNFTs/${buffer}`);
108
+ return Object.assign(Object.assign({}, response), { getNextPagePayload: Object.assign(Object.assign({}, args), { skip: ((_a = args.skip) !== null && _a !== void 0 ? _a : 0) + ((_b = args.top) !== null && _b !== void 0 ? _b : 35) }), hasMoreResults: response.resultsCount > ((_c = args.skip) !== null && _c !== void 0 ? _c : 0) + ((_d = args.top) !== null && _d !== void 0 ? _d : 35) });
109
+ });
110
+ /**
111
+ * Retrieves trading history based on the provided arguments.
112
+ *
113
+ * @param {TradincActivityArgs} args - The arguments for filtering the trading activity.
114
+ * @returns {Promise<TradingActivityResponse>} A promise resolving to a TradingActivityResponse object containing the activity.
115
+ * @throws {Error} Throws an error if the 'top' argument is greater than 35.
116
+ */
117
+ this.getTradingActivity = (args) => __awaiter(this, void 0, void 0, function* () {
118
+ return yield (0, getActivity_1.getActivity)(args, this.api);
119
+ });
120
+ /**
121
+ * Fetch collections profiles based on the provided arguments.
122
+ * @param {GetCollectionsArgs} args - The GetCollectionsArgs object containing the search parameters.
123
+ * @returns {Promise<CollectionsNFTsResponse>} A Promise that resolves to the CollectionsNFTsResponse object.
124
+ * @throws An error if the 'top' value is greater than 35.
125
+ */
126
+ this.getCollections = (args) => __awaiter(this, void 0, void 0, function* () {
127
+ if ((args === null || args === void 0 ? void 0 : args.top) && args.top > 25) {
128
+ throw new Error('Top cannot be greater than 25');
129
+ }
130
+ const payloadBody = {
131
+ skip: (args === null || args === void 0 ? void 0 : args.skip) || 0,
132
+ top: (args === null || args === void 0 ? void 0 : args.top) || 25,
133
+ select: (args === null || args === void 0 ? void 0 : args.onlySelectFields) || [],
134
+ filters: Object.assign({ dataType: 'collectionProfile', isMintable: (args === null || args === void 0 ? void 0 : args.onlyMintable) || undefined }, ((args === null || args === void 0 ? void 0 : args.collections) &&
135
+ args.collections.length > 0 && {
136
+ collection: args.collections,
137
+ })),
138
+ orderBy: [(args === null || args === void 0 ? void 0 : args.orderBy) || 'statistics.tradeData.weekEgldVolume desc'],
139
+ };
140
+ const buffer = Buffer.from(JSON.stringify(payloadBody)).toString('base64');
141
+ const response = yield this.api.fetchWithTimeout(`/collections/${buffer}`);
142
+ return {
143
+ results: response,
144
+ resultsCount: response.length,
145
+ empty: response.length === 0,
146
+ getNextPagePayload: Object.assign(Object.assign({}, args), { skip: ((args === null || args === void 0 ? void 0 : args.skip) || 0) + ((args === null || args === void 0 ? void 0 : args.top) || 25) }),
147
+ hasMoreResults: response.length < ((args === null || args === void 0 ? void 0 : args.top) || 25),
148
+ };
149
+ });
150
+ this.api = api_1.APIClient.getClient();
151
+ }
152
+ }
153
+ exports.CollectionModule = CollectionModule;
154
+ //# sourceMappingURL=index.js.map
@@ -0,0 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I,CAAE,GAAG,KAAI,EAAE,CAAC;aACpD,CAAC;QACJ,CAAC,CAAA,CAAC;QAhLA,IAAI,CAAC,GAAG,GAAG,eAAS,CAAC,SAAS,EAAE,CAAC;IACnC,CAAC;CAgLF;AApLD,4CAoLC"}
package/dist/index.d.ts CHANGED
@@ -10,3 +10,8 @@ export declare class XOXNO {
10
10
  */
11
11
  constructor(apiUrl?: string, apiKey?: string);
12
12
  }
13
+ export * from './types';
14
+ export * from './collection';
15
+ export * from './launchpad';
16
+ export * from './interactions';
17
+ export * from './nft';
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.XOXNO = void 0;
18
+ const api_1 = require("./utils/api");
19
+ const const_1 = require("./utils/const");
20
+ /**
21
+ * Represents an XOXNO Marketplace SDK, providing a simplified interface for
22
+ * interacting with an XOXNO API.
23
+ */
24
+ class XOXNO {
25
+ /**
26
+ * Creates a new XOXNO instance.
27
+ * @param apiUrl - The base URL of the XOXNO API.
28
+ * @param apiKey - The API key for accessing the XOXNO API.
29
+ */
30
+ constructor(apiUrl = const_1.API_URL, apiKey = '') {
31
+ api_1.APIClient.init(apiUrl, apiKey);
32
+ }
33
+ }
34
+ exports.XOXNO = XOXNO;
35
+ __exportStar(require("./types"), exports);
36
+ __exportStar(require("./collection"), exports);
37
+ __exportStar(require("./launchpad"), exports);
38
+ __exportStar(require("./interactions"), exports);
39
+ __exportStar(require("./nft"), exports);
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAwC;AACxC,yCAAwC;AAExC;;;GAGG;AACH,MAAa,KAAK;IAChB;;;;OAIG;IACH,YAAY,SAAiB,eAAO,EAAE,MAAM,GAAG,EAAE;QAC/C,eAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC;CACF;AATD,sBASC;AAED,0CAAwB;AACxB,+CAA6B;AAC7B,8CAA4B;AAC5B,iDAA+B;AAC/B,wCAAsB"}
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SCInteraction = void 0;
13
+ const api_1 = require("../utils/api");
14
+ const scCalls_1 = require("../utils/scCalls");
15
+ const SmartContractAbis_1 = require("../utils/SmartContractAbis");
16
+ const SmartContractService_1 = require("../utils/SmartContractService");
17
+ const numerical_1 = require("@multiversx/sdk-core/out/smartcontracts/typesystem/numerical");
18
+ class SCInteraction {
19
+ constructor(marketAbiXOXNO) {
20
+ /**
21
+ * Gets the percentage of each transaction that will be paid to the marketplace.
22
+ *
23
+ * @returns The percentage of each transaction that will be paid to the marketplace.
24
+ */
25
+ this.getMarketplaceFees = () => __awaiter(this, void 0, void 0, function* () {
26
+ var _a;
27
+ const interaction = this.xo.methods.getMarketplaceCutPercentage();
28
+ const result = yield this.getResult(interaction);
29
+ return parseInt((_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf());
30
+ });
31
+ /**
32
+ * Retrieves the list of accepted payment tokens.
33
+ * @returns {string[]} A list of accepted payment tokens.
34
+ */
35
+ this.getAcceptedPaymentTokens = () => __awaiter(this, void 0, void 0, function* () {
36
+ var _b;
37
+ const interaction = this.xo.methods.getAcceptedTokens();
38
+ const result = yield this.getResult(interaction);
39
+ return (_b = result.firstValue) === null || _b === void 0 ? void 0 : _b.valueOf();
40
+ });
41
+ /**
42
+ * This function returns a list of IDs of global offers.
43
+ * @returns {number[]} a list of IDs of global offers.
44
+ */
45
+ this.getGlobalOfferIDs = () => __awaiter(this, void 0, void 0, function* () {
46
+ var _c;
47
+ const interaction = this.xo.methods.getGlobalOffers();
48
+ const result = yield this.getResult(interaction);
49
+ return (_c = result.firstValue) === null || _c === void 0 ? void 0 : _c.valueOf().map((id) => parseInt(id));
50
+ });
51
+ /**
52
+ * Returns the global offer data for the offer with the given id.
53
+ *
54
+ * @param global_offer_id The id of the global offer for which to return the data.
55
+ *
56
+ * @returns An object containing the global offer data for the offer with the given id. If the global offer id is invalid, the return value will be null.
57
+ */
58
+ this.getGlobalOfferData = (global_offer_id) => __awaiter(this, void 0, void 0, function* () {
59
+ var _d;
60
+ const interaction = this.xo.methods.getGlobalOffer([global_offer_id]);
61
+ const result = yield this.getResult(interaction);
62
+ const body = (_d = result.firstValue) === null || _d === void 0 ? void 0 : _d.valueOf();
63
+ body.offer_id = parseInt(body.offer_id.valueOf());
64
+ body.marketplace = 'XO';
65
+ body.short_price = parseFloat(new numerical_1.BigUIntValue(body.price).valueOf().shiftedBy(-18).toString());
66
+ body.new_version = Boolean(body.new_version);
67
+ if (!body.new_version) {
68
+ body.isActive = this.isOfferActive(body.short_price, yield this.getUserPoolBalance(body.owner, body.payment_token, body.payment_nonce));
69
+ }
70
+ else {
71
+ body.isActive = true;
72
+ }
73
+ body.quantity = parseInt(body.quantity.valueOf());
74
+ body.payment_nonce = parseInt(body.payment_nonce.valueOf());
75
+ body.price = body.price.valueOf();
76
+ body.timestamp = parseInt(body.timestamp.valueOf());
77
+ body.owner = body.owner.valueOf().toString();
78
+ if (body.attributes) {
79
+ body.attributes = JSON.parse(Buffer.from(body.attributes.valueOf().toString(), 'base64').toString('ascii'));
80
+ }
81
+ return body;
82
+ });
83
+ this.xo = marketAbiXOXNO;
84
+ this.call = new scCalls_1.ContractQueryRunner();
85
+ }
86
+ static create() {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const config = api_1.APIClient.getClient().config;
89
+ const marketAbiXOXNO = yield SmartContractAbis_1.SmartContractAbis.getMarket();
90
+ const xo_abi = (0, SmartContractService_1.getSmartContract)(marketAbiXOXNO, config.XO_SC);
91
+ return new SCInteraction(xo_abi);
92
+ });
93
+ }
94
+ getResult(interaction) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ return yield this.call.runQuery(this.xo, interaction);
97
+ });
98
+ }
99
+ /**
100
+ * Gets the balance of a user in a token of a specific pool.
101
+ * @param address The address of the user.
102
+ * @param token The token address.
103
+ * @param nonce The nonce of the pool.
104
+ * @returns {number} The balance of the user in the token of the pool.
105
+ */
106
+ getUserPoolBalance(address, token, nonce) {
107
+ return __awaiter(this, void 0, void 0, function* () {
108
+ const result = yield this.getResult(this.xo.methods.userDeposit([address, token, nonce]));
109
+ if (!(result === null || result === void 0 ? void 0 : result.firstValue)) {
110
+ return 0;
111
+ }
112
+ return new numerical_1.BigUIntValue(result.firstValue.valueOf().amount)
113
+ .valueOf()
114
+ .shiftedBy(-18)
115
+ .toNumber();
116
+ });
117
+ }
118
+ // function to determine if the offer is active
119
+ // based on the offer price and user balance
120
+ isOfferActive(offer_price, user_balance) {
121
+ return offer_price <= user_balance;
122
+ }
123
+ /** Gets the number of listings.
124
+ * @returns {number} The number of listings.
125
+ * */
126
+ getListingsCount() {
127
+ var _a;
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const result = yield this.getResult(this.xo.methods.getListingsCount());
130
+ const count = parseInt((_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf());
131
+ return count;
132
+ });
133
+ }
134
+ /** Gets the number of custom offers.
135
+ * @returns {number} The number of custom offers.
136
+ * */
137
+ getOffersCount() {
138
+ var _a;
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const result = yield this.getResult(this.xo.methods.getOffersCount());
141
+ const count = parseInt((_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf());
142
+ return count;
143
+ });
144
+ }
145
+ /** Gets the number of global offers.
146
+ * @returns {number} The number of global offers.
147
+ * */
148
+ getGlobalOffersCount() {
149
+ var _a;
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ const result = yield this.getResult(this.xo.methods.getGlobalOffersCount());
152
+ const count = parseInt((_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf());
153
+ return count;
154
+ });
155
+ }
156
+ /** Gets the number of collections listed.
157
+ * @returns {number} The number of collections listed.
158
+ * */
159
+ getCollectionsCount() {
160
+ var _a;
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const result = yield this.getResult(this.xo.methods.getCollectionsCount());
163
+ const count = parseInt((_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf());
164
+ return count;
165
+ });
166
+ }
167
+ /**
168
+ * Checks whether a collection is listed with at least 1 NFT.
169
+ *
170
+ * @param collection name of the collection
171
+ * @return true if the collection is listed, false otherwise
172
+ */
173
+ isCollectionListed(collection) {
174
+ var _a;
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ const result = yield this.getResult(this.xo.methods.isCollectionListed([collection]));
177
+ return Boolean((_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf());
178
+ });
179
+ }
180
+ /** Gets the on sale NFT count of the collection.
181
+ *
182
+ * @param collection The collection identifier for which one wants to get the on sale NFT count.
183
+ *
184
+ * @returns {number} The on sale NFT count of the collection.
185
+ * */
186
+ getCollectionNFTsOnSaleCount(collection) {
187
+ var _a;
188
+ return __awaiter(this, void 0, void 0, function* () {
189
+ const result = yield this.getResult(this.xo.methods.getTokenItemsForSaleCount([collection]));
190
+ return parseInt((_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf());
191
+ });
192
+ }
193
+ /** Gets the active unique auction IDs of collection.
194
+ *
195
+ * @param collection The collection identifier for which one wants to get the active unique auction IDs.
196
+ *
197
+ * @returns {number[]} The active unique auction IDs of collection.
198
+ * */
199
+ getAuctionIDsForCollection(collection) {
200
+ var _a;
201
+ return __awaiter(this, void 0, void 0, function* () {
202
+ const result = yield this.getResult(this.xo.methods.getAuctionsForTicker([collection]));
203
+ const ids = (_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf().map((id) => parseInt(id));
204
+ return ids;
205
+ });
206
+ }
207
+ }
208
+ exports.SCInteraction = SCInteraction;
209
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sCAAyC;AACzC,8CAAuD;AACvD,kEAA+D;AAC/D,wEAAiE;AAEjE,4FAA4F;AAE5F,MAAa,aAAa;IAGxB,YAAY,cAA6B;QAiBzC;;;;WAIG;QACI,uBAAkB,GAAG,GAA0B,EAAE;;YACtD,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC;YAClE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YACjD,OAAO,QAAQ,CAAC,MAAA,MAAM,CAAC,UAAU,0CAAE,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC,CAAA,CAAC;QA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SAKK;IACQ,4BAA4B,CACvC,UAAkB;;;YAElB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CACjC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,UAAU,CAAC,CAAC,CACxD,CAAC;YACF,OAAO,QAAQ,CAAC,MAAA,MAAM,CAAC,UAAU,0CAAE,OAAO,EAAE,CAAC,CAAC;;KAC/C;IAED;;;;;SAKK;IAEQ,0BAA0B,CACrC,UAAkB;;;YAElB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CACjC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,UAAU,CAAC,CAAC,CACnD,CAAC;YACF,MAAM,GAAG,GAAG,MAAA,MAAM,CAAC,UAAU,0CAAE,OAAO,GAAG,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3E,OAAO,GAAG,CAAC;;KACZ;CACF;AAnND,sCAmNC"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LaunchpadModule = void 0;
13
+ const SmartContractAbis_1 = require("../utils/SmartContractAbis");
14
+ const SmartContractService_1 = require("../utils/SmartContractService");
15
+ const scCalls_1 = require("../utils/scCalls");
16
+ /**
17
+ * LaunchpadModule provides methods to interact with the minter smart contract.
18
+ * @class
19
+ */
20
+ class LaunchpadModule {
21
+ /**
22
+ * @constructor
23
+ * @param {SmartContract} minterAbiXOXNO - The minter smart contract instance.
24
+ */
25
+ constructor(minterAbiXOXNO) {
26
+ /**
27
+ * Fetches all unique tags from the minter smart contract.
28
+ * @public
29
+ * @returns {Promise<string[]>} An array of unique tags.
30
+ */
31
+ this.getAllUniqueTags = () => __awaiter(this, void 0, void 0, function* () {
32
+ var _a;
33
+ const interaction = this.minter.methods.collections();
34
+ const result = yield this.getResult(interaction);
35
+ return (_a = result.firstValue) === null || _a === void 0 ? void 0 : _a.valueOf().map((x) => x.toString());
36
+ });
37
+ /**
38
+ * Fetches the global buy count for a user and tag.
39
+ * @public
40
+ * @param {string} user - The user's address.
41
+ * @param {string} tag - The tag.
42
+ * @returns {Promise<number>} The global buy count.
43
+ */
44
+ this.getWalletGlobalBuyCount = (user, tag) => __awaiter(this, void 0, void 0, function* () {
45
+ var _b;
46
+ const interaction = this.minter.methods.buysPerWallet([user, tag]);
47
+ const result = yield this.getResult(interaction);
48
+ return (_b = result.firstValue) === null || _b === void 0 ? void 0 : _b.valueOf();
49
+ });
50
+ /**
51
+ * Fetches the stage buy count for a user, tag, and stage.
52
+ * @public
53
+ * @param {string} user - The user's address.
54
+ * @param {string} tag - The tag.
55
+ * @param {string} stage - The stage.
56
+ * @returns {Promise<number>} The stage buy count.
57
+ */
58
+ this.getWalletStageBuyCount = (user, tag, stage) => __awaiter(this, void 0, void 0, function* () {
59
+ var _c;
60
+ const interaction = this.minter.methods.buysStagePerWallet([
61
+ user,
62
+ tag,
63
+ stage,
64
+ ]);
65
+ const result = yield this.getResult(interaction);
66
+ return (_c = result.firstValue) === null || _c === void 0 ? void 0 : _c.valueOf();
67
+ });
68
+ /**
69
+ * Fetches the local owner's address from the minter smart contract.
70
+ * @public
71
+ * @returns {Promise<string>} The local owner's address.
72
+ */
73
+ this.getLocalOwner = () => __awaiter(this, void 0, void 0, function* () {
74
+ var _d;
75
+ const interaction = this.minter.methods.localOwner();
76
+ const result = yield this.getResult(interaction);
77
+ return (_d = result.firstValue) === null || _d === void 0 ? void 0 : _d.valueOf();
78
+ });
79
+ /**
80
+ * Fetches the launchpad cut fee percentage from the minter smart contract.
81
+ * @public
82
+ * @returns {Promise<number>} The launchpad cut fee percentage.
83
+ */
84
+ this.getLaunchpadCutFee = () => __awaiter(this, void 0, void 0, function* () {
85
+ var _e;
86
+ const interaction = this.minter.methods.cutPercentage();
87
+ const result = yield this.getResult(interaction);
88
+ return (_e = result.firstValue) === null || _e === void 0 ? void 0 : _e.valueOf();
89
+ });
90
+ /**
91
+ * Fetches the stage whitelist of wallets for a tag and stage.
92
+ * @public
93
+ * @param {string} tag - The tag.
94
+ * @param {string} stage - The stage.
95
+ * @returns {Promise<string[]>} An array of whitelisted wallet addresses.
96
+ */
97
+ this.getStageWhitelist = (tag, stage) => __awaiter(this, void 0, void 0, function* () {
98
+ var _f;
99
+ const interaction = this.minter.methods.getWhitelistedWallets([tag, stage]);
100
+ const result = yield this.getResult(interaction);
101
+ return (_f = result.firstValue) === null || _f === void 0 ? void 0 : _f.valueOf().map((x) => x.toString());
102
+ });
103
+ /**
104
+ * Fetches the list of stages for a tag.
105
+ * @public
106
+ * @param {string} tag - The tag.
107
+ * @returns {Promise<string[]>} An array of stages.
108
+ */
109
+ this.getStages = (tag) => __awaiter(this, void 0, void 0, function* () {
110
+ var _g;
111
+ const interaction = this.minter.methods.mintStage([tag]);
112
+ const result = yield this.getResult(interaction);
113
+ return (_g = result.firstValue) === null || _g === void 0 ? void 0 : _g.valueOf().map((x) => {
114
+ const body = x[1].valueOf();
115
+ body.name = body.name.toString();
116
+ body.tag = body.name.toString();
117
+ body.start_time = parseInt(body.start_time.toString());
118
+ body.end_time = parseInt(body.end_time.toString());
119
+ body.mint_limit = parseInt(body.mint_limit.toString());
120
+ body.mint_count = parseInt(body.mint_count.toString());
121
+ body.max_per_wallet = parseInt(body.max_per_wallet.toString());
122
+ body.prices = body.prices.map((x) => {
123
+ const pr = x.valueOf();
124
+ return Object.assign(Object.assign({}, pr), { token_nonce: parseInt(pr.token_nonce.toString()), amount: pr.amount.toString() });
125
+ });
126
+ return body;
127
+ });
128
+ });
129
+ this.minter = minterAbiXOXNO;
130
+ this.call = new scCalls_1.ContractQueryRunner();
131
+ }
132
+ /**
133
+ * Executes the provided interaction and returns the result.
134
+ * @private
135
+ * @param {Interaction} interaction - The smart contract interaction.
136
+ * @returns {Promise<any>} The result of the interaction.
137
+ */
138
+ getResult(interaction) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ return yield this.call.runQuery(this.minter, interaction);
141
+ });
142
+ }
143
+ /**
144
+ * Initializes the LaunchpadModule with a minter smart contract instance.
145
+ * @static
146
+ * @param {string} minterSC - The minter smart contract address.
147
+ * @returns {Promise<LaunchpadModule>} A new instance of LaunchpadModule.
148
+ */
149
+ static init(minterSC) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ const minterAbiXOXNO = yield SmartContractAbis_1.SmartContractAbis.getMinter();
152
+ const minter_abi = (0, SmartContractService_1.getSmartContract)(minterAbiXOXNO, minterSC);
153
+ return new LaunchpadModule(minter_abi);
154
+ });
155
+ }
156
+ }
157
+ exports.LaunchpadModule = LaunchpadModule;
158
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/launchpad/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kEAA+D;AAC/D,wEAAiE;AACjE,8CAAuD;AAGvD;;;GAGG;AACH,MAAa,eAAe;IAG1B;;;OAGG;IACH,YAAY,cAA6B;QA2BzC;;;;WAIG;QACI,qBAAgB,GAAG,GAA4B,EAAE;;YACtD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YACtD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YACjD,OAAO,MAAA,MA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