@xoxno/sdk-js 0.1.74-alpha → 0.1.76-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/out/cjs/collection/index.js +625 -0
- package/out/cjs/collection/index.js.map +1 -0
- package/out/cjs/common/index.js +141 -0
- package/out/cjs/common/index.js.map +1 -0
- package/out/cjs/index.js +26 -0
- package/out/cjs/index.js.map +1 -0
- package/out/cjs/index.large.js +19 -0
- package/out/cjs/index.large.js.map +1 -0
- package/out/cjs/interactions/index.js +678 -0
- package/out/cjs/interactions/index.js.map +1 -0
- package/out/cjs/launchpad/index.js +158 -0
- package/out/cjs/launchpad/index.js.map +1 -0
- package/out/cjs/nft/index.js +121 -0
- package/out/cjs/nft/index.js.map +1 -0
- package/out/cjs/staking/index.js +29 -0
- package/out/cjs/staking/index.js.map +1 -0
- package/{dist → out/cjs}/types/collection.d.ts +7 -1
- package/{dist → out/cjs}/types/collection.js +34 -26
- package/out/cjs/types/collection.js.map +1 -0
- package/out/cjs/types/common.js +3 -0
- package/{dist → out/cjs}/types/common.js.map +1 -1
- package/out/cjs/types/index.js +24 -0
- package/out/cjs/types/index.js.map +1 -0
- package/{dist → out/cjs}/types/interactions.js +5 -2
- package/out/cjs/types/interactions.js.map +1 -0
- package/out/cjs/types/nft.js +3 -0
- package/out/cjs/types/nft.js.map +1 -0
- package/out/cjs/types/staking.js +15 -0
- package/out/cjs/types/staking.js.map +1 -0
- package/{dist → out/cjs}/types/trading.js +9 -6
- package/out/cjs/types/trading.js.map +1 -0
- package/out/cjs/types/user.js +13 -0
- package/out/cjs/types/user.js.map +1 -0
- package/out/cjs/users/index.js +335 -0
- package/out/cjs/users/index.js.map +1 -0
- package/out/cjs/utils/SmartContractAbis.js +103 -0
- package/out/cjs/utils/SmartContractAbis.js.map +1 -0
- package/out/cjs/utils/SmartContractService.js +13 -0
- package/out/cjs/utils/SmartContractService.js.map +1 -0
- package/out/cjs/utils/api.js +79 -0
- package/out/cjs/utils/api.js.map +1 -0
- package/out/cjs/utils/const.js +17 -0
- package/out/cjs/utils/const.js.map +1 -0
- package/out/cjs/utils/getActivity.js +65 -0
- package/out/cjs/utils/getActivity.js.map +1 -0
- package/out/cjs/utils/helpers.js +27 -0
- package/out/cjs/utils/helpers.js.map +1 -0
- package/out/cjs/utils/regex.js +12 -0
- package/out/cjs/utils/regex.js.map +1 -0
- package/out/cjs/utils/scCalls.js +39 -0
- package/out/cjs/utils/scCalls.js.map +1 -0
- package/out/src/collection/__tests__/collection.test.js +2 -0
- package/out/src/collection/__tests__/collection.test.js.map +1 -0
- package/out/src/collection/index.js +2 -0
- package/out/src/collection/index.js.map +1 -0
- package/out/src/common/index.js +2 -0
- package/out/src/common/index.js.map +1 -0
- package/out/src/index.js +2 -0
- package/out/src/index.js.map +1 -0
- package/out/src/index.large.js +2 -0
- package/out/src/index.large.js.map +1 -0
- package/out/src/interactions/__tests__/market.test.js +2 -0
- package/out/src/interactions/__tests__/market.test.js.map +1 -0
- package/out/src/interactions/index.js +2 -0
- package/out/src/interactions/index.js.map +1 -0
- package/out/src/launchpad/__tests__/market.test.js +2 -0
- package/out/src/launchpad/__tests__/market.test.js.map +1 -0
- package/out/src/launchpad/index.js +2 -0
- package/out/src/launchpad/index.js.map +1 -0
- package/out/src/nft/__tests__/nft.test.js +2 -0
- package/out/src/nft/__tests__/nft.test.js.map +1 -0
- package/out/src/nft/index.js +2 -0
- package/out/src/nft/index.js.map +1 -0
- package/out/src/staking/index.js +2 -0
- package/out/src/staking/index.js.map +1 -0
- package/out/src/types/collection.js +2 -0
- package/out/src/types/collection.js.map +1 -0
- package/out/src/types/common.js +2 -0
- package/out/src/types/common.js.map +1 -0
- package/out/src/types/index.js +2 -0
- package/out/src/types/index.js.map +1 -0
- package/out/src/types/interactions.js +2 -0
- package/out/src/types/interactions.js.map +1 -0
- package/out/src/types/nft.js +2 -0
- package/out/src/types/nft.js.map +1 -0
- package/out/src/types/staking.js +2 -0
- package/out/src/types/staking.js.map +1 -0
- package/out/src/types/trading.js +2 -0
- package/out/src/types/trading.js.map +1 -0
- package/out/src/types/user.js +2 -0
- package/out/src/types/user.js.map +1 -0
- package/out/src/users/__tests__/user.test.js +2 -0
- package/out/src/users/__tests__/user.test.js.map +1 -0
- package/out/src/users/index.js +2 -0
- package/out/src/users/index.js.map +1 -0
- package/out/src/utils/SmartContractAbis.js +2 -0
- package/out/src/utils/SmartContractAbis.js.map +1 -0
- package/out/src/utils/SmartContractService.js +2 -0
- package/out/src/utils/SmartContractService.js.map +1 -0
- package/out/src/utils/api.js +2 -0
- package/out/src/utils/api.js.map +1 -0
- package/out/src/utils/const.js +2 -0
- package/out/src/utils/const.js.map +1 -0
- package/out/src/utils/getActivity.js +2 -0
- package/out/src/utils/getActivity.js.map +1 -0
- package/out/src/utils/helpers.js +2 -0
- package/out/src/utils/helpers.js.map +1 -0
- package/out/src/utils/regex.js +2 -0
- package/out/src/utils/regex.js.map +1 -0
- package/out/src/utils/scCalls.js +2 -0
- package/out/src/utils/scCalls.js.map +1 -0
- package/package.json +27 -14
- package/.eslintrc.json +0 -19
- package/dist/collection/index.js +0 -660
- package/dist/collection/index.js.map +0 -1
- package/dist/common/index.js +0 -132
- package/dist/common/index.js.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/index.large.js +0 -3
- package/dist/index.large.js.map +0 -1
- package/dist/interactions/index.js +0 -619
- package/dist/interactions/index.js.map +0 -1
- package/dist/launchpad/index.js +0 -140
- package/dist/launchpad/index.js.map +0 -1
- package/dist/nft/index.js +0 -109
- package/dist/nft/index.js.map +0 -1
- package/dist/staking/index.js +0 -17
- package/dist/staking/index.js.map +0 -1
- package/dist/types/collection.js.map +0 -1
- package/dist/types/common.js +0 -2
- package/dist/types/index.js +0 -8
- package/dist/types/index.js.map +0 -1
- package/dist/types/interactions.js.map +0 -1
- package/dist/types/nft.js +0 -2
- package/dist/types/nft.js.map +0 -1
- package/dist/types/staking.js +0 -12
- package/dist/types/staking.js.map +0 -1
- package/dist/types/trading.js.map +0 -1
- package/dist/types/user.js +0 -10
- package/dist/types/user.js.map +0 -1
- package/dist/users/index.js +0 -324
- package/dist/users/index.js.map +0 -1
- package/dist/utils/SmartContractAbis.js +0 -84
- package/dist/utils/SmartContractAbis.js.map +0 -1
- package/dist/utils/SmartContractService.js +0 -9
- package/dist/utils/SmartContractService.js.map +0 -1
- package/dist/utils/api.js +0 -82
- package/dist/utils/api.js.map +0 -1
- package/dist/utils/const.js +0 -14
- package/dist/utils/const.js.map +0 -1
- package/dist/utils/getActivity.js +0 -64
- package/dist/utils/getActivity.js.map +0 -1
- package/dist/utils/helpers.js +0 -21
- package/dist/utils/helpers.js.map +0 -1
- package/dist/utils/regex.js +0 -7
- package/dist/utils/regex.js.map +0 -1
- package/dist/utils/scCalls.js +0 -25
- package/dist/utils/scCalls.js.map +0 -1
- /package/{dist → out/cjs}/collection/index.d.ts +0 -0
- /package/{dist → out/cjs}/common/index.d.ts +0 -0
- /package/{dist → out/cjs}/index.d.ts +0 -0
- /package/{dist → out/cjs}/index.large.d.ts +0 -0
- /package/{dist → out/cjs}/interactions/index.d.ts +0 -0
- /package/{dist → out/cjs}/launchpad/index.d.ts +0 -0
- /package/{dist → out/cjs}/nft/index.d.ts +0 -0
- /package/{dist → out/cjs}/staking/index.d.ts +0 -0
- /package/{dist → out/cjs}/types/common.d.ts +0 -0
- /package/{dist → out/cjs}/types/index.d.ts +0 -0
- /package/{dist → out/cjs}/types/interactions.d.ts +0 -0
- /package/{dist → out/cjs}/types/nft.d.ts +0 -0
- /package/{dist → out/cjs}/types/staking.d.ts +0 -0
- /package/{dist → out/cjs}/types/trading.d.ts +0 -0
- /package/{dist → out/cjs}/types/user.d.ts +0 -0
- /package/{dist → out/cjs}/users/index.d.ts +0 -0
- /package/{dist → out/cjs}/utils/SmartContractAbis.d.ts +0 -0
- /package/{dist → out/cjs}/utils/SmartContractService.d.ts +0 -0
- /package/{dist → out/cjs}/utils/api.d.ts +0 -0
- /package/{dist → out/cjs}/utils/const.d.ts +0 -0
- /package/{dist → out/cjs}/utils/getActivity.d.ts +0 -0
- /package/{dist → out/cjs}/utils/helpers.d.ts +0 -0
- /package/{dist → out/cjs}/utils/regex.d.ts +0 -0
- /package/{dist → out/cjs}/utils/scCalls.d.ts +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
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.getActivity = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches the trading activity of the given collections
|
|
15
|
+
* @param args - The trading activity arguments
|
|
16
|
+
* @param api - The API client
|
|
17
|
+
* @returns - The trading activity response
|
|
18
|
+
* @throws - If the top is greater than 35
|
|
19
|
+
*/
|
|
20
|
+
const getActivity = (args, api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
if (args.top && args.top > 35) {
|
|
23
|
+
throw new Error('Top cannot be greater than 35');
|
|
24
|
+
}
|
|
25
|
+
const ranges = [];
|
|
26
|
+
if (args.priceRange) {
|
|
27
|
+
ranges.push(Object.assign(Object.assign({}, args.priceRange), { field: 'activityData.egldValue' }));
|
|
28
|
+
}
|
|
29
|
+
if (args.timestampRange) {
|
|
30
|
+
ranges.push(Object.assign(Object.assign({}, args.timestampRange), { field: 'timestamp' }));
|
|
31
|
+
}
|
|
32
|
+
const payloadBody = {
|
|
33
|
+
filters: {
|
|
34
|
+
activityData: args.from == null && args.to == null
|
|
35
|
+
? {
|
|
36
|
+
collection: args.collections,
|
|
37
|
+
identifier: args.identifiers || undefined,
|
|
38
|
+
}
|
|
39
|
+
: undefined,
|
|
40
|
+
from: args.from,
|
|
41
|
+
to: args.to,
|
|
42
|
+
activityAddress: args.wallets || undefined,
|
|
43
|
+
source: args.source || undefined,
|
|
44
|
+
activityType: args.activityType || undefined,
|
|
45
|
+
range: ranges,
|
|
46
|
+
},
|
|
47
|
+
strictSelect: args.strictSelect,
|
|
48
|
+
orderBy: args.orderBy,
|
|
49
|
+
select: args.select,
|
|
50
|
+
top: args.top || 35,
|
|
51
|
+
skip: args.skip || 0,
|
|
52
|
+
};
|
|
53
|
+
const response = yield api.fetchWithTimeout(`/activity/query`, {
|
|
54
|
+
params: {
|
|
55
|
+
filter: JSON.stringify(payloadBody),
|
|
56
|
+
},
|
|
57
|
+
next: {
|
|
58
|
+
tags: ['getActivity'],
|
|
59
|
+
revalidate: 180,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
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) }), empty: response.resources.length === 0 });
|
|
63
|
+
});
|
|
64
|
+
exports.getActivity = getActivity;
|
|
65
|
+
//# sourceMappingURL=getActivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getActivity.js","sourceRoot":"","sources":["../../../src/utils/getActivity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CACzB,IAAyB,EACzB,GAAgB,EACkB,EAAE;;IACpC,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG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AAC,SAAS,CAAC,WAAW,CAAC;SACpC;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC,aAAa,CAAC;YACrB,UAAU,EAAE,GAAG;SAChB;KACF,CACF,CAAC;IAEF,uCACK,QAAQ,KACX,kBAAkB,kCACb,IAAI,KACP,IAAI,EAAE,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,IAAI,CAAC,GAAG,mCAAI,EAAE,CAAC,KAE3C,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,IACtC;AACJ,CAAC,CAAA,CAAC;AAlEW,QAAA,WAAW,eAkEtB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAddressValid = exports.getIdentifierFromColAndNonce = exports.nonceToHex = void 0;
|
|
4
|
+
const address_1 = require("@multiversx/sdk-core/out/address");
|
|
5
|
+
const nonceToHex = (nonce) => {
|
|
6
|
+
let nonceHex = nonce.toString(16);
|
|
7
|
+
if (nonceHex.length % 2 !== 0) {
|
|
8
|
+
nonceHex = '0' + nonceHex;
|
|
9
|
+
}
|
|
10
|
+
return nonceHex;
|
|
11
|
+
};
|
|
12
|
+
exports.nonceToHex = nonceToHex;
|
|
13
|
+
const getIdentifierFromColAndNonce = (collection, nonce) => {
|
|
14
|
+
return [collection, (0, exports.nonceToHex)(nonce)].join('-');
|
|
15
|
+
};
|
|
16
|
+
exports.getIdentifierFromColAndNonce = getIdentifierFromColAndNonce;
|
|
17
|
+
const isAddressValid = (address) => {
|
|
18
|
+
try {
|
|
19
|
+
new address_1.Address(address);
|
|
20
|
+
return true && address.includes('erd1');
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.isAddressValid = isAddressValid;
|
|
27
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":";;;AAAA,8DAA2D;AAEpD,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE;IAClD,IAAI,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAClC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC;IAC5B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,UAAU,cAMrB;AAEK,MAAM,4BAA4B,GAAG,CAC1C,UAAkB,EAClB,KAAa,EACL,EAAE;IACV,OAAO,CAAC,UAAU,EAAE,IAAA,kBAAU,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEK,MAAM,cAAc,GAAG,CAAC,OAAwB,EAAW,EAAE;IAClE,IAAI,CAAC;QACH,IAAI,iBAAO,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAPW,QAAA,cAAc,kBAOzB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidNftIdentifier = exports.isValidCollectionTicker = void 0;
|
|
4
|
+
const isValidCollectionTicker = (ticker) => {
|
|
5
|
+
return /^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(ticker);
|
|
6
|
+
};
|
|
7
|
+
exports.isValidCollectionTicker = isValidCollectionTicker;
|
|
8
|
+
const isValidNftIdentifier = (identifier) => {
|
|
9
|
+
return /^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,5}(?:-\d+(?:-[A-Za-z0-9]+)?)?$/.test(identifier);
|
|
10
|
+
};
|
|
11
|
+
exports.isValidNftIdentifier = isValidNftIdentifier;
|
|
12
|
+
//# sourceMappingURL=regex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex.js","sourceRoot":"","sources":["../../../src/utils/regex.ts"],"names":[],"mappings":";;;AAAO,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAW,EAAE;IACjE,OAAO,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC;AAEK,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAW,EAAE;IAClE,OAAO,gFAAgF,CAAC,IAAI,CAC1F,UAAU,CACX,CAAC;AACJ,CAAC,CAAC;AAJW,QAAA,oBAAoB,wBAI/B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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.ContractQueryRunner = void 0;
|
|
13
|
+
const index_1 = require("../index");
|
|
14
|
+
const resultsParser_1 = require("@multiversx/sdk-core/out/smartcontracts/resultsParser");
|
|
15
|
+
const proxyNetworkProvider_1 = require("@multiversx/sdk-network-providers/out/proxyNetworkProvider");
|
|
16
|
+
class ContractQueryRunner {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.parser = new resultsParser_1.ResultsParser();
|
|
19
|
+
const api = index_1.XOXNOClient.init().apiUrl;
|
|
20
|
+
this.proxy = new proxyNetworkProvider_1.ProxyNetworkProvider(api, {
|
|
21
|
+
timeout: 10000,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
runQuery(contract, interaction) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const queryResponse = yield this.proxy.queryContract(interaction.buildQuery());
|
|
28
|
+
return this.parser.parseQueryResponse(queryResponse, interaction.getEndpoint());
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.log(`Unexpected error when running query '${interaction.buildQuery().func}' to sc '${contract.getAddress().bech32()}' `);
|
|
32
|
+
console.error(error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ContractQueryRunner = ContractQueryRunner;
|
|
39
|
+
//# sourceMappingURL=scCalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scCalls.js","sourceRoot":"","sources":["../../../src/utils/scCalls.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,oCAAuC;AACvC,yFAAsF;AAKtF,qGAAkG;AAElG,MAAa,mBAAmB;IAI9B;QAFiB,WAAM,GAAkB,IAAI,6BAAa,EAAE,CAAC;QAG3D,MAAM,GAAG,GAAG,mBAAW,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,2CAAoB,CAAC,GAAG,EAAE;YACzC,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;IACL,CAAC;IAEK,QAAQ,CACZ,QAAuB,EACvB,WAAwB;;YAExB,IAAI,CAAC;gBACH,MAAM,aAAa,GACjB,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;gBAE3D,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CACnC,aAAa,EACb,WAAW,CAAC,WAAW,EAAE,CAC1B,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CACT,wCACE,WAAW,CAAC,UAAU,EAAE,CAAC,IAC3B,YAAY,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,IAAI,CAC/C,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAErB,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;CACF;AAlCD,kDAkCC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});const _index=require("../../index");const _types=require("../../types");describe("CollectionModule",()=>{let collectionModule;const inputCollection="BANANA-e955fd";beforeAll(()=>{_index.XOXNOClient.init();collectionModule=new _index.CollectionModule});beforeEach(async()=>{return new Promise(resolve=>setTimeout(resolve,1e3))});test("getCollectionProfile should return the correct result",async()=>{const collectionModule=new _index.CollectionModule;const result=await collectionModule.getCollectionProfile(inputCollection);expect(result.collection).toEqual(inputCollection)});test("getCollectionProfiles should return the correct results",async()=>{const collectionModule=new _index.CollectionModule;const result=await collectionModule.getCollections();expect(result).toBeDefined();expect(result.results).toHaveLength(25)});it("should get the floor price of a collection",async()=>{const floorPrice=await collectionModule.getCollectionFloorPrice(inputCollection);expect(floorPrice).toBeLessThan(1)});it("should get the collection attributes",async()=>{const attributesInfo=await collectionModule.getCollectionAttributes(inputCollection);expect(attributesInfo).toMatchObject({Accessorie:{Dollars:{attributeOccurrence:260}}})});it("should get the collection trading activity",async()=>{const tradingActivity=await collectionModule.getTradingActivity({collections:[inputCollection],top:1});expect(tradingActivity).toMatchObject({getNextPagePayload:{top:1,skip:1,collections:[inputCollection]}});const tradingActivitySecondPage=await collectionModule.getTradingActivity(tradingActivity.getNextPagePayload);expect(tradingActivitySecondPage).toMatchObject({getNextPagePayload:{top:1,skip:2,collections:[inputCollection]}})});it("should get fetch and filter NFTs from a collection",async()=>{const nfts=await collectionModule.getNFTs({collections:[inputCollection],onlyOnSale:true,auctionType:_types.AuctionTypes.FixedPrice,top:1,onlySelectFields:[_types.FieldsToSelect.Attributes,_types.FieldsToSelect.Name,_types.FieldsToSelect.SaleInfo,_types.FieldsToSelect.Rank,_types.FieldsToSelect.Description,_types.FieldsToSelect.Royalties,_types.FieldsToSelect.Collection]});expect(nfts).toMatchObject({getNextPagePayload:{top:1,skip:1}});const nftsSecondPage=await collectionModule.getNFTs(nfts.getNextPagePayload);expect(nftsSecondPage).toMatchObject({getNextPagePayload:{top:1,skip:2}})})});
|
|
2
|
+
//# sourceMappingURL=collection.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/collection/__tests__/collection.test.ts"],"sourcesContent":["import { CollectionModule, XOXNOClient } from '../../index';\nimport { AuctionTypes, FieldsToSelect, SearchNFTsResponse } from '../../types';\n\ndescribe('CollectionModule', () => {\n let collectionModule: CollectionModule;\n const inputCollection = 'BANANA-e955fd';\n beforeAll(() => {\n XOXNOClient.init();\n collectionModule = new CollectionModule();\n });\n\n beforeEach(async () => {\n return new Promise((resolve) => setTimeout(resolve, 1000));\n });\n\n test('getCollectionProfile should return the correct result', async () => {\n const collectionModule = new CollectionModule();\n const result = await collectionModule.getCollectionProfile(inputCollection);\n expect(result.collection).toEqual(inputCollection);\n });\n\n test('getCollectionProfiles should return the correct results', async () => {\n const collectionModule = new CollectionModule();\n const result = await collectionModule.getCollections();\n expect(result).toBeDefined();\n expect(result.results).toHaveLength(25);\n });\n\n it('should get the floor price of a collection', async () => {\n const floorPrice =\n await collectionModule.getCollectionFloorPrice(inputCollection);\n expect(floorPrice).toBeLessThan(1);\n });\n\n it('should get the collection attributes', async () => {\n const attributesInfo =\n await collectionModule.getCollectionAttributes(inputCollection);\n expect(attributesInfo).toMatchObject({\n Accessorie: {\n Dollars: {\n attributeOccurrence: 260,\n },\n },\n });\n });\n\n it('should get the collection trading activity', async () => {\n const tradingActivity = await collectionModule.getTradingActivity({\n collections: [inputCollection],\n top: 1,\n });\n expect(tradingActivity).toMatchObject({\n getNextPagePayload: {\n top: 1,\n skip: 1,\n collections: [inputCollection],\n },\n });\n\n const tradingActivitySecondPage = await collectionModule.getTradingActivity(\n tradingActivity.getNextPagePayload\n );\n expect(tradingActivitySecondPage).toMatchObject({\n getNextPagePayload: {\n top: 1,\n skip: 2,\n collections: [inputCollection],\n },\n });\n });\n\n it('should get fetch and filter NFTs from a collection', async () => {\n const nfts: SearchNFTsResponse = await collectionModule.getNFTs({\n collections: [inputCollection],\n onlyOnSale: true,\n auctionType: AuctionTypes.FixedPrice,\n top: 1,\n onlySelectFields: [\n FieldsToSelect.Attributes,\n FieldsToSelect.Name,\n FieldsToSelect.SaleInfo,\n FieldsToSelect.Rank,\n FieldsToSelect.Description,\n FieldsToSelect.Royalties,\n FieldsToSelect.Collection,\n ],\n });\n expect(nfts).toMatchObject({\n getNextPagePayload: {\n top: 1,\n skip: 1,\n },\n });\n\n const nftsSecondPage = await collectionModule.getNFTs(\n nfts.getNextPagePayload\n );\n expect(nftsSecondPage).toMatchObject({\n getNextPagePayload: {\n top: 1,\n skip: 2,\n },\n });\n });\n});\n"],"names":["describe","collectionModule","inputCollection","beforeAll","XOXNOClient","init","CollectionModule","beforeEach","Promise","resolve","setTimeout","test","result","getCollectionProfile","expect","collection","toEqual","getCollections","toBeDefined","results","toHaveLength","it","floorPrice","getCollectionFloorPrice","toBeLessThan","attributesInfo","getCollectionAttributes","toMatchObject","Accessorie","Dollars","attributeOccurrence","tradingActivity","getTradingActivity","collections","top","getNextPagePayload","skip","tradingActivitySecondPage","nfts","getNFTs","onlyOnSale","auctionType","AuctionTypes","FixedPrice","onlySelectFields","FieldsToSelect","Attributes","Name","SaleInfo","Rank","Description","Royalties","Collection","nftsSecondPage"],"rangeMappings":"","mappings":"2FAA8C,oCACmB,eAEjEA,SAAS,mBAAoB,KAC3B,IAAIC,iBACJ,MAAMC,gBAAkB,gBACxBC,UAAU,KACRC,kBAAW,CAACC,IAAI,GAChBJ,iBAAmB,IAAIK,uBAAgB,AACzC,GAEAC,WAAW,UACT,OAAO,IAAIC,QAAQ,AAACC,SAAYC,WAAWD,QAAS,KACtD,GAEAE,KAAK,wDAAyD,UAC5D,MAAMV,iBAAmB,IAAIK,uBAAgB,CAC7C,MAAMM,OAAS,MAAMX,iBAAiBY,oBAAoB,CAACX,iBAC3DY,OAAOF,OAAOG,UAAU,EAAEC,OAAO,CAACd,gBACpC,GAEAS,KAAK,0DAA2D,UAC9D,MAAMV,iBAAmB,IAAIK,uBAAgB,CAC7C,MAAMM,OAAS,MAAMX,iBAAiBgB,cAAc,GACpDH,OAAOF,QAAQM,WAAW,GAC1BJ,OAAOF,OAAOO,OAAO,EAAEC,YAAY,CAAC,GACtC,GAEAC,GAAG,6CAA8C,UAC/C,MAAMC,WACJ,MAAMrB,iBAAiBsB,uBAAuB,CAACrB,iBACjDY,OAAOQ,YAAYE,YAAY,CAAC,EAClC,GAEAH,GAAG,uCAAwC,UACzC,MAAMI,eACJ,MAAMxB,iBAAiByB,uBAAuB,CAACxB,iBACjDY,OAAOW,gBAAgBE,aAAa,CAAC,CACnCC,WAAY,CACVC,QAAS,CACPC,oBAAqB,GACvB,CACF,CACF,EACF,GAEAT,GAAG,6CAA8C,UAC/C,MAAMU,gBAAkB,MAAM9B,iBAAiB+B,kBAAkB,CAAC,CAChEC,YAAa,CAAC/B,gBAAgB,CAC9BgC,IAAK,CACP,GACApB,OAAOiB,iBAAiBJ,aAAa,CAAC,CACpCQ,mBAAoB,CAClBD,IAAK,EACLE,KAAM,EACNH,YAAa,CAAC/B,gBAAgB,AAChC,CACF,GAEA,MAAMmC,0BAA4B,MAAMpC,iBAAiB+B,kBAAkB,CACzED,gBAAgBI,kBAAkB,EAEpCrB,OAAOuB,2BAA2BV,aAAa,CAAC,CAC9CQ,mBAAoB,CAClBD,IAAK,EACLE,KAAM,EACNH,YAAa,CAAC/B,gBAAgB,AAChC,CACF,EACF,GAEAmB,GAAG,qDAAsD,UACvD,MAAMiB,KAA2B,MAAMrC,iBAAiBsC,OAAO,CAAC,CAC9DN,YAAa,CAAC/B,gBAAgB,CAC9BsC,WAAY,KACZC,YAAaC,mBAAY,CAACC,UAAU,CACpCT,IAAK,EACLU,iBAAkB,CAChBC,qBAAc,CAACC,UAAU,CACzBD,qBAAc,CAACE,IAAI,CACnBF,qBAAc,CAACG,QAAQ,CACvBH,qBAAc,CAACI,IAAI,CACnBJ,qBAAc,CAACK,WAAW,CAC1BL,qBAAc,CAACM,SAAS,CACxBN,qBAAc,CAACO,UAAU,CAC1B,AACH,GACAtC,OAAOwB,MAAMX,aAAa,CAAC,CACzBQ,mBAAoB,CAClBD,IAAK,EACLE,KAAM,CACR,CACF,GAEA,MAAMiB,eAAiB,MAAMpD,iBAAiBsC,OAAO,CACnDD,KAAKH,kBAAkB,EAEzBrB,OAAOuC,gBAAgB1B,aAAa,CAAC,CACnCQ,mBAAoB,CAClBD,IAAK,EACLE,KAAM,CACR,CACF,EACF,EACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"CollectionModule",{enumerable:true,get:function(){return CollectionModule}});const _collection=require("../types/collection");const _index=require("../index");const _getActivity=require("../utils/getActivity");const _regex=require("../utils/regex");let CollectionModule=class CollectionModule{api;constructor(){this.api=_index.XOXNOClient.init()}getCollectionProfile=async collection=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/profile`,{next:{tags:["getCollectionProfile"],revalidate:30}});return response};getDailyTrending=async()=>{const response=await this.api.fetchWithTimeout("/nfts/getDailyTrending",{next:{tags:["getDailyTrending"],revalidate:180}});return response};getCollectionFloorPrice=async(collection,token="EGLD")=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/floor-price`,{next:{tags:["getCollectionFloorPrice"]},params:{token}});return response?.price?response.price:0};getCollectionAttributes=async collection=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/attributes`,{next:{tags:["getCollectionAttributes"],revalidate:180}});return response};getNFTs=async args=>{args?.collections?.forEach(element=>{if(!(0,_regex.isValidCollectionTicker)(element)){throw new Error("Invalid collection ticker: "+element)}});if(args.top&&args.top>35){throw new Error("Top cannot be greater than 35")}const ranges=[];if(args.priceRange){ranges.push({...args.priceRange,field:args.auctionType==_collection.AuctionTypes.Auctions?"saleInfo.currentBidShort":"saleInfo.minBidShort"})}if(args.rankRange){ranges.push({...args.rankRange,field:"metadata.rarity.rank"})}const payloadBody={filters:{dataType:args.dataType??["nft"],activeAuction:args.activeAuctions,collection:args.collections??[],onSale:args.onlyOnSale,saleInfo:{seller:args.listedBy||[],marketplace:args.listedOnlyOn||undefined,paymentToken:args.listedInToken||[],auctionType:args.auctionType==_collection.AuctionTypes.Auctions?["NftBid","SftAll"]:args.auctionType==_collection.AuctionTypes.FixedPrice?["Nft","SftOnePerPayment"]:args.auctionType==_collection.AuctionTypes.AllListed?["NftBid","SftAll","Nft","SftOnePerPayment"]:undefined},owner:args.ownedBy||[],verifiedOnly:args.onlyVerified||false,metadata:{attributes:args.attributes||undefined},range:ranges,cp_staked:args.isStaked||undefined},applyNftExtraDetails:args.applyNftExtraDetails,orderBy:args.orderBy||[],select:args.onlySelectFields||[],includeCount:args.includeCount||false,top:args.top||35,skip:args.skip||0};const response=await this.api.fetchWithTimeout(`/nft/query`,{params:{filter:JSON.stringify(payloadBody)},next:{tags:["getCollectionNFTs"]},cache:"no-store"});return{...response,getNextPagePayload:{...args,skip:(args.skip??0)+(args.top??35)}}};suggestCollections=async args=>{if(args.top&&args.top>35){throw new Error("Top cannot be greater than 35")}if(!args.name){throw new Error("Name is required")}const payloadBody={name:args.name,top:args.top||35,skip:args.skip||0};return await this.api.fetchWithTimeout(`/collection/search`,{params:{filter:JSON.stringify(payloadBody)},next:{tags:["/collection/search"],revalidate:180}})};collectionListingsAnalytics=async ticker=>{return await this.api.fetchWithTimeout(`collection/${ticker}/listing`,{next:{tags:["collection/${ticker}/listing"],revalidate:500}})};getTradingActivity=async args=>{return await (0,_getActivity.getActivity)(args,this.api)};getCollections=async args=>{if(args?.top&&args.top>25){throw new Error("Top cannot be greater than 25")}const payloadBody={skip:args?.skip||0,top:args?.top||25,select:args?.onlySelectFields||[],filters:{dataType:"collectionProfile",isMintable:args?.onlyMintable||undefined,...args?.collections&&args.collections.length>0&&{collection:args.collections}},orderBy:[args?.orderBy||"statistics.tradeData.weekEgldVolume desc"]};const response=await this.api.fetchWithTimeout(`/collection/query`,{params:{filter:JSON.stringify(payloadBody)},next:{tags:["getCollections"],revalidate:180}});return{results:response,resultsCount:response.length,empty:response.length===0,getNextPagePayload:{...args,skip:(args?.skip||0)+(args?.top||25)},hasMoreResults:response.length>=(args?.top||25)}};getGlobalOffers=async args=>{if(args?.top&&args.top>25){throw new Error("Top cannot be greater than 25")}const payloadBody={skip:args?.skip||0,top:args?.top||25,select:args?.onlySelectFields||[],filters:{collection:args?.collections||[],withAttributes:args?.withAttributes??false,isActive:args?.onlyActive??true,offerId:args?.offerIds,owner:args?.ownedBy,marketplace:args?.listedOnlyOn,range:args?.priceRange?{...args.priceRange,type:"priceShort"}:undefined,attributes:args?.attributes},orderBy:[args?.orderBy||_collection.GlobalOfferOrderBy.PriceHighToLow]};const response=await this.api.fetchWithTimeout(`/collection/global-offer/query`,{params:{filter:JSON.stringify(payloadBody)},next:{tags:["getGlobalOffers"],revalidate:12}});return{...response,getNextPagePayload:{...args,skip:(args?.top||25)+response.lastSkip}}};getCollectionVolume=async(collection,after,before,bin)=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/analytics/volume?startTime=${after}&endTime=${before}&bin=${bin}`,{next:{tags:["getCollectionVolume"],revalidate:180}});return response};getMarketplaceVolume=async(after,before,bin)=>{const response=await this.api.fetchWithTimeout(`/analytics/volume?startTime=${after}&endTime=${before}&bin=${bin}`,{next:{tags:["getMarketplaceVolume"],revalidate:180}});return response};getCollectionOwners=async collection=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/holders`,{next:{tags:["getCollectionOwners"],revalidate:500}});return response};getExportOwners=async collection=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/holders?exportHolders=true`,{next:{tags:["getExportOwners"]}});return response};getCollectionsStatistics=async args=>{if(args?.top&&args.top>25){throw new Error("Top cannot be greater than 25")}const response=await this.api.fetchWithTimeout(`/collection/stats/query`,{params:{filter:JSON.stringify(args)},next:{tags:["collectionStatistics"],revalidate:12}});return{...response,getNextPagePayload:{...args,skip:args.skip+args.top}}};getCollectionStats=async ticker=>{if(!(0,_regex.isValidCollectionTicker)(ticker)){throw new Error("Invalid collection ticker: "+ticker)}return await this.api.fetchWithTimeout(`/collection/${ticker}/stats`,{next:{tags:["collectionStatistics"],revalidate:12}})};getAwaitEmpty=async delay=>{return new Promise(resolve=>{setTimeout(()=>{resolve(true)},delay)})};getCollectionMintInfo=async({ticker,extra})=>{if(!(0,_regex.isValidCollectionTicker)(ticker)){throw new Error("Invalid collection ticker: "+ticker)}const response=await this.api.fetchWithTimeout(`/collection/${ticker}/drop-info`,{next:{tags:[`/collection/${ticker}/drop-info`],revalidate:12},...extra});return response};getCollectionRanks=async({ticker,extra})=>{if(!(0,_regex.isValidCollectionTicker)(ticker)){throw new Error("Invalid collection ticker: "+ticker)}const response=await this.api.fetchWithTimeout(`/collection/${ticker}/ranks`,{next:{tags:[`/collection/${ticker}/ranks`],revalidate:60},...extra});return response};getDropInfo=async({collectionTag,creatorTag,extra})=>{const response=await this.api.fetchWithTimeout(`/collection/${creatorTag}/${collectionTag}/drop-info`,{next:{tags:[`/collection/${creatorTag}/${collectionTag}/drop-info`],revalidate:12},...extra});return response};getCollectionGraphData=async(collection,startTime,endTime,bin)=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/analytics/volume`,{params:{startTime:startTime,endTime:endTime,bin:bin},next:{tags:[`/collection/${collection}/analytics/volume`],revalidate:60}});return response};getPinnedCollections=async()=>{const response=await this.api.fetchWithTimeout(`/collection/pinned`,{next:{tags:[`/collection/pinned`],revalidate:60}});return response};getDrops=async args=>{args?.collections?.forEach(element=>{if(!(0,_regex.isValidCollectionTicker)(element)){throw new Error("Invalid collection ticker: "+element)}});if(args.top&&args.top>35){throw new Error("Top cannot be greater than 35")}const ranges=[];if(args.timeRange){ranges.push({...args.timeRange,field:"startTime"})}const payloadBody={filters:{collection:args.collections??[],verifiedOnly:args.onlyVerified||false,mintToken:args.listedInToken||undefined,range:ranges},orderBy:args.orderBy||[],select:args.onlySelectFields||[],includeCount:args.includeCount||false,top:args.top||35,skip:args.skip||0};const response=await this.api.fetchWithTimeout(`/collection/drops/query`,{params:{filter:JSON.stringify(payloadBody)},next:{tags:["/collection/drops/query"]},cache:"no-store"});return{...response,getNextPagePayload:{...args,skip:(args.skip??0)+(args.top??35)}}};getCollectionStakingSummary=async({collection,extra})=>{if(!(0,_regex.isValidCollectionTicker)(collection)){throw new Error("Invalid collection ticker: "+collection)}const response=await this.api.fetchWithTimeout(`/collection/${collection}/staking/summary`,{...extra});return response}};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/collection/index.ts"],"sourcesContent":["import { AnalyticsGraphs, NftData, StakingSummaryPools } from '../types';\nimport {\n CollectionsNFTsResponse,\n GetCollectionsArgs,\n ICollectionAttributes,\n ICollectionProfile,\n SearchNFTs,\n GetNFTsArgs,\n SearchNFTsResponse,\n SuggestNFTsArgs,\n SuggestResults,\n CollectionVolume,\n IOwners,\n ISingleHolder,\n GetGlobalOffersArgs,\n GlobalOffersResult,\n GlobalOfferOrderBy,\n ListingDistribution,\n GetCollectionMintInfo,\n GetCollectionStatsArgs,\n CollectionStatsResults,\n CollectionRanksExport,\n CollectionStatsDoc,\n AuctionTypes,\n GETDropsArgs,\n GetDropsResponse,\n} from '../types/collection';\nimport { TradincActivityArgs, TradingActivityResponse } from '../types/trading';\nimport { XOXNOClient } from '../index';\nimport { getActivity } from '../utils/getActivity';\nimport { isValidCollectionTicker } from '../utils/regex';\n\n/**\n * CollectionModule provides a set of methods to interact with NFT collections.\n * It includes methods for getting collection profile information, floor price,\n * collection attributes, and searching NFTs within a collection.\n *\n * @example\n * const collectionModule = new CollectionModule();\n */\nexport class CollectionModule {\n private api: XOXNOClient;\n constructor() {\n this.api = XOXNOClient.init();\n }\n\n /**\n * @public\n * @async\n * @function getCollectionProfile\n * @param {string} collection - The ticker of the collection to fetch the profile for.\n * @returns {Promise<ICollectionProfile>} A promise that resolves to the fetched collection profile.\n *\n * This function fetches the profile of a given collection. It takes the following parameter:\n * - collection (string): The ticker of the collection to fetch the profile for.\n *\n * The function first validates the input ticker and checks if it is a valid collection ticker.\n * If it is valid, the function fetches the collection profile using the API.\n * Finally, it returns a promise that resolves to the fetched collection profile.\n */\n public getCollectionProfile = async (\n collection: string\n ): Promise<ICollectionProfile> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n const response = await this.api.fetchWithTimeout<ICollectionProfile>(\n `/collection/${collection}/profile`,\n {\n next: {\n tags: ['getCollectionProfile'],\n revalidate: 30,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getDailyTrending\n * @returns {Promise<NftData[]>} A promise that resolves to the array of trending NFTs.\n * This function fetches the top NFTs that are trending today based on their floor and volumes\n */\n public getDailyTrending = async (): Promise<NftData[]> => {\n const response = await this.api.fetchWithTimeout<NftData[]>(\n '/nfts/getDailyTrending',\n {\n next: {\n tags: ['getDailyTrending'],\n revalidate: 180,\n },\n }\n );\n return response;\n };\n\n /**\n * Fetches the floor price of a collection.\n * @param collection - The ticker of the collection.\n * @param token - The token for the floor price calculation (default: 'EGLD').\n * @returns A Promise that resolves to the collection's floor price as a number.\n * @throws An error if the provided collection ticker is invalid.\n */\n public getCollectionFloorPrice = async (\n collection: string,\n token = 'EGLD'\n ): Promise<number> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n const response = await this.api.fetchWithTimeout<{\n price: number;\n }>(`/collection/${collection}/floor-price`, {\n next: {\n tags: ['getCollectionFloorPrice'],\n },\n params: {\n token,\n },\n });\n return response?.price ? response.price : 0;\n };\n\n /**\n * @public\n * @async\n * @function getCollectionAttributes\n * @param {string} collection - The ticker of the collection to fetch the attributes for.\n * @returns {Promise<ICollectionAttributes>} A promise that resolves to the fetched collection attributes.\n *\n * This function fetches the attributes of a given collection. It takes the following parameter:\n * - collection (string): The ticker of the collection to fetch the attributes for.\n *\n * The function first validates the input ticker and checks if it is a valid collection ticker.\n * If it is valid, the function fetches the collection attributes using the API.\n * Finally, it returns a promise that resolves to the fetched collection attributes.\n */\n public getCollectionAttributes = async (\n collection: string\n ): Promise<ICollectionAttributes> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n const response = await this.api.fetchWithTimeout<ICollectionAttributes>(\n `/collection/${collection}/attributes`,\n {\n next: {\n tags: ['getCollectionAttributes'],\n revalidate: 180,\n },\n }\n );\n return response;\n };\n\n /**\n * Searches for NFTs based on the provided arguments.\n * @param {SearchNFTsArgs} args - The SearchNFTsArgs object containing the search parameters.\n * @returns {Promise<SearchNFTsResponse>} A Promise that resolves to the SearchNFTsResponse object.\n * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 35.\n */\n public getNFTs = async (args: GetNFTsArgs): Promise<SearchNFTsResponse> => {\n args?.collections?.forEach((element) => {\n if (!isValidCollectionTicker(element)) {\n throw new Error('Invalid collection ticker: ' + element);\n }\n });\n\n if (args.top && args.top > 35) {\n throw new Error('Top cannot be greater than 35');\n }\n const ranges = [];\n if (args.priceRange) {\n ranges.push({\n ...args.priceRange,\n field:\n args.auctionType == AuctionTypes.Auctions\n ? 'saleInfo.currentBidShort'\n : 'saleInfo.minBidShort',\n });\n }\n if (args.rankRange) {\n ranges.push({\n ...args.rankRange,\n field: 'metadata.rarity.rank',\n });\n }\n const payloadBody: SearchNFTs = {\n filters: {\n dataType: args.dataType ?? ['nft'],\n // @borispoehland Has to be false only if we want to show the expired auctions, undefined to show all, and true only actives\n activeAuction: args.activeAuctions,\n collection: args.collections ?? [],\n onSale: args.onlyOnSale,\n saleInfo: {\n seller: args.listedBy || [],\n marketplace: args.listedOnlyOn || undefined,\n paymentToken: args.listedInToken || [],\n auctionType:\n args.auctionType == AuctionTypes.Auctions\n ? ['NftBid', 'SftAll']\n : args.auctionType == AuctionTypes.FixedPrice\n ? ['Nft', 'SftOnePerPayment']\n : args.auctionType == AuctionTypes.AllListed\n ? ['NftBid', 'SftAll', 'Nft', 'SftOnePerPayment']\n : undefined,\n },\n owner: args.ownedBy || [],\n verifiedOnly: args.onlyVerified || false,\n metadata: {\n attributes: args.attributes || undefined,\n },\n range: ranges,\n cp_staked: args.isStaked || undefined,\n },\n applyNftExtraDetails: args.applyNftExtraDetails,\n orderBy: args.orderBy || [],\n select: args.onlySelectFields || [],\n includeCount: args.includeCount || false,\n top: args.top || 35,\n skip: args.skip || 0,\n };\n\n const response = await this.api.fetchWithTimeout<SearchNFTsResponse>(\n `/nft/query`,\n {\n params: {\n filter: JSON.stringify(payloadBody),\n },\n next: {\n tags: ['getCollectionNFTs'],\n },\n cache: 'no-store',\n }\n );\n return {\n ...response,\n getNextPagePayload: {\n ...args,\n skip: (args.skip ?? 0) + (args.top ?? 35),\n },\n };\n };\n\n /**\n * @public\n * @async\n * @function suggestCollections\n * @param {SuggestNFTsArgs} args - An object containing the necessary parameters to fetch suggested collections results.\n * @returns {Promise<SuggestResults>} A promise that resolves to the fetched collections results.\n *\n * This function fetches suggested collections results based on the provided arguments. It takes an object with the following properties:\n * - name (string): The name to search for (required).\n * - top (number, optional): The maximum number of results to return (default is 35, cannot be greater than 35).\n * - skip (number, optional): The number of results to skip (default is 0).\n *\n * Finally, it returns a promise that resolves to the fetched collections results.\n */\n public suggestCollections = async (\n args: SuggestNFTsArgs\n ): Promise<SuggestResults> => {\n if (args.top && args.top > 35) {\n throw new Error('Top cannot be greater than 35');\n }\n if (!args.name) {\n throw new Error('Name is required');\n }\n\n const payloadBody: SuggestNFTsArgs = {\n name: args.name,\n top: args.top || 35,\n skip: args.skip || 0,\n };\n\n return await this.api.fetchWithTimeout<SuggestResults>(\n `/collection/search`,\n {\n params: {\n filter: JSON.stringify(payloadBody),\n },\n next: {\n tags: ['/collection/search'],\n revalidate: 180,\n },\n }\n );\n };\n\n /**\n * @public\n * @async\n * @function collectionListings\n * @param {string} ticker - The unique collection identifier called ticker\n * @returns {Promise<ListingDistribution[]>} A promise that resolves to the distribution of listings\n */\n public collectionListingsAnalytics = async (\n ticker: string\n ): Promise<ListingDistribution[]> => {\n return await this.api.fetchWithTimeout<ListingDistribution[]>(\n `collection/${ticker}/listing`,\n {\n next: {\n tags: ['collection/${ticker}/listing'],\n revalidate: 500,\n },\n }\n );\n };\n\n /**\n * Retrieves trading history based on the provided arguments.\n *\n * @param {TradincActivityArgs} args - The arguments for filtering the trading activity.\n * @returns {Promise<TradingActivityResponse>} A promise resolving to a TradingActivityResponse object containing the activity.\n * @throws {Error} Throws an error if the 'top' argument is greater than 35.\n */\n public getTradingActivity = async (\n args: TradincActivityArgs\n ): Promise<TradingActivityResponse> => {\n return await getActivity(args, this.api);\n };\n\n /**\n * Fetch collections profiles based on the provided arguments.\n * @param {GetCollectionsArgs} args - The GetCollectionsArgs object containing the search parameters.\n * @returns {Promise<CollectionsNFTsResponse>} A Promise that resolves to the CollectionsNFTsResponse object.\n * @throws An error if the 'top' value is greater than 35.\n */\n public getCollections = async (\n args?: GetCollectionsArgs\n ): Promise<CollectionsNFTsResponse> => {\n if (args?.top && args.top > 25) {\n throw new Error('Top cannot be greater than 25');\n }\n\n const payloadBody = {\n skip: args?.skip || 0,\n top: args?.top || 25,\n select: args?.onlySelectFields || [],\n filters: {\n dataType: 'collectionProfile',\n isMintable: args?.onlyMintable || undefined,\n ...(args?.collections &&\n args.collections.length > 0 && {\n collection: args.collections,\n }),\n },\n orderBy: [args?.orderBy || 'statistics.tradeData.weekEgldVolume desc'],\n };\n\n const response = await this.api.fetchWithTimeout<ICollectionProfile[]>(\n `/collection/query`,\n {\n params: {\n filter: JSON.stringify(payloadBody),\n },\n next: {\n tags: ['getCollections'],\n revalidate: 180,\n },\n }\n );\n return {\n results: response,\n resultsCount: response.length,\n empty: response.length === 0,\n getNextPagePayload: {\n ...args,\n skip: (args?.skip || 0) + (args?.top || 25),\n },\n hasMoreResults: response.length >= (args?.top || 25),\n };\n };\n\n /**\n * Fetch global offers based on the provided arguments.\n * @param {GetGlobalOffersArgs} args - The GetCollectionsArgs object containing the search parameters.\n * @returns {Promise<GlobalOffersResult>} A Promise that resolves to the GlobalOffersResult object.\n * @throws An error if the 'top' value is greater than 35.\n */\n public getGlobalOffers = async (\n args?: GetGlobalOffersArgs\n ): Promise<GlobalOffersResult> => {\n if (args?.top && args.top > 25) {\n throw new Error('Top cannot be greater than 25');\n }\n\n const payloadBody = {\n skip: args?.skip || 0,\n top: args?.top || 25,\n select: args?.onlySelectFields || [],\n filters: {\n collection: args?.collections || [],\n withAttributes: args?.withAttributes ?? false,\n isActive: args?.onlyActive ?? true,\n offerId: args?.offerIds,\n owner: args?.ownedBy,\n marketplace: args?.listedOnlyOn,\n range: args?.priceRange\n ? { ...args.priceRange, type: 'priceShort' }\n : undefined,\n attributes: args?.attributes,\n },\n orderBy: [args?.orderBy || GlobalOfferOrderBy.PriceHighToLow],\n };\n\n const response = await this.api.fetchWithTimeout<GlobalOffersResult>(\n `/collection/global-offer/query`,\n {\n params: {\n filter: JSON.stringify(payloadBody),\n },\n next: {\n tags: ['getGlobalOffers'],\n revalidate: 12,\n },\n }\n );\n return {\n ...response,\n getNextPagePayload: {\n ...args,\n skip: (args?.top || 25) + response.lastSkip,\n },\n };\n };\n\n /**\n * @public\n * @async\n * @function getCollectionVolume\n * @param {string} collection - The ticker of the collection to fetch the volume for (e.g., 'EAPES-8f3c1f').\n * @param {string} after - The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').\n * @param {string} before - The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').\n * @param {string} bin - The binning period for the volume data (e.g., '1d' for 1 day).\n * @returns {Promise<CollectionVolume[]>} A promise that resolves to an array of collection volume data.\n *\n * This function fetches volume data for a given collection within a specified date range and binning period. It takes the following parameters:\n * - collection (string): The ticker of the collection to fetch the volume for (e.g., 'EAPES-8f3c1f').\n * - after (string): The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').\n * - before (string): The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').\n * - bin (string): The binning period for the volume data (e.g., '1d' for 1 day).\n *\n * The function first validates the input collection ticker and checks if it is a valid collection ticker.\n * If it is valid, the function fetches the collection volume data using the API with the specified query parameters.\n * Finally, it returns a promise that resolves to an array of collection volume data.\n */\n public getCollectionVolume = async (\n collection: string,\n after: string,\n before: string,\n bin: string\n ): Promise<CollectionVolume[]> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n const response = await this.api.fetchWithTimeout<CollectionVolume[]>(\n `/collection/${collection}/analytics/volume?startTime=${after}&endTime=${before}&bin=${bin}`,\n {\n next: {\n tags: ['getCollectionVolume'],\n revalidate: 180,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getMarketplaceVolume\n * @param {string} after - The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').\n * @param {string} before - The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').\n * @param {string} bin - The binning period for the volume data (e.g., '1d' for 1 day).\n * @returns {Promise<CollectionVolume[]>} A promise that resolves to an array of collection volume data.\n *\n * This function fetches volume data for a given collection within a specified date range and binning period. It takes the following parameters:\n * - collection (string): The ticker of the collection to fetch the volume for (e.g., 'EAPES-8f3c1f').\n * - after (string): The start date (inclusive) of the date range for the volume data (e.g., '2023-04-17').\n * - before (string): The end date (inclusive) of the date range for the volume data (e.g., '2023-04-25').\n * - bin (string): The binning period for the volume data (e.g., '1d' for 1 day).\n *\n * The function first validates the input collection ticker and checks if it is a valid collection ticker.\n * If it is valid, the function fetches the collection volume data using the API with the specified query parameters.\n * Finally, it returns a promise that resolves to an array of collection volume data.\n */\n public getMarketplaceVolume = async (\n after: string,\n before: string,\n bin: string\n ): Promise<CollectionVolume[]> => {\n const response = await this.api.fetchWithTimeout<CollectionVolume[]>(\n `/analytics/volume?startTime=${after}&endTime=${before}&bin=${bin}`,\n {\n next: {\n tags: ['getMarketplaceVolume'],\n revalidate: 180,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getCollectionOwners\n * @param {string} collection - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').\n * @returns {Promise<IOwners>} A promise that resolves a struct of collection information about holders\n *\n * This function fetches owner information for a given collection. It takes the following parameter:\n * - collection (string): The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').\n *\n * The function first validates the input collection ticker and checks if it is a valid collection ticker.\n * If it is valid, the function fetches the collection owner information using the API.\n * Finally, it returns a promise that resolves a struct of collection information about holders\n */\n public getCollectionOwners = async (collection: string): Promise<IOwners> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n const response = await this.api.fetchWithTimeout<IOwners>(\n `/collection/${collection}/holders`,\n\n {\n next: {\n tags: ['getCollectionOwners'],\n revalidate: 500,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getExportOwners\n * @param {string} collection - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').\n * @returns {Promise<ISingleHolder[]>} A promise that resolves an array of holders part of the collection.\n *\n * This function fetches owners information for a given collection. It takes the following parameter:\n * - collection (string): The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').\n *\n * The function first validates the input collection ticker and checks if it is a valid collection ticker.\n * If it is valid, the function fetches the collection owner information using the API.\n * Finally, it returns a promise that resolves to an array of collection owner information.\n */\n public getExportOwners = async (\n collection: string\n ): Promise<ISingleHolder[]> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n const response = await this.api.fetchWithTimeout<ISingleHolder[]>(\n `/collection/${collection}/holders?exportHolders=true`,\n\n {\n next: {\n tags: ['getExportOwners'],\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getCollectionsStatistics\n * @param {GetCollectionStatsArgs} args - The filter payload for the collection statsitics\n * @returns {Promise<CollectionStatsResults>} A promise that resolves to a struct with information\n * Finally, it returns a promise that resolves a struct with information\n */\n public getCollectionsStatistics = async (\n args: GetCollectionStatsArgs\n ): Promise<CollectionStatsResults> => {\n if (args?.top && args.top > 25) {\n throw new Error('Top cannot be greater than 25');\n }\n\n const response = await this.api.fetchWithTimeout<CollectionStatsResults>(\n `/collection/stats/query`,\n {\n params: {\n filter: JSON.stringify(args),\n },\n next: {\n tags: ['collectionStatistics'],\n revalidate: 12,\n },\n }\n );\n return {\n ...response,\n getNextPagePayload: {\n ...args,\n skip: args.skip + args.top,\n },\n };\n };\n\n /**\n * @public\n * @async\n * @function getCollectionStats\n * @param {GetCollectionStatsArgs} args - The filter payload for the collection statsitics\n * @returns {Promise<CollectionStatsDoc>} A promise that resolves to a struct with information\n * Finally, it returns a promise that resolves a struct with information\n */\n public getCollectionStats = async (\n ticker: string\n ): Promise<CollectionStatsDoc> => {\n if (!isValidCollectionTicker(ticker)) {\n throw new Error('Invalid collection ticker: ' + ticker);\n }\n\n return await this.api.fetchWithTimeout<CollectionStatsDoc>(\n `/collection/${ticker}/stats`,\n {\n next: {\n tags: ['collectionStatistics'],\n revalidate: 12,\n },\n }\n );\n };\n\n public getAwaitEmpty = async (delay: number): Promise<boolean> => {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(true);\n }, delay);\n });\n };\n\n /**\n * @public\n * @async\n * @function getCollectionMintInfo\n * @param {string} ticker - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').\n * @returns {Promise<GetCollectionMintInfo>} A promise that resolves to a struct with information\n * Finally, it returns a promise that resolves a struct with information\n */\n public getCollectionMintInfo = async ({\n ticker,\n extra,\n }: {\n ticker: string;\n extra?: RequestInit;\n }): Promise<GetCollectionMintInfo> => {\n if (!isValidCollectionTicker(ticker)) {\n throw new Error('Invalid collection ticker: ' + ticker);\n }\n const response = await this.api.fetchWithTimeout<GetCollectionMintInfo>(\n `/collection/${ticker}/drop-info`,\n {\n next: {\n tags: [`/collection/${ticker}/drop-info`],\n revalidate: 12,\n },\n ...extra,\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getCollectionRanks\n * @param {string} ticker - The ticker of the collection to fetch the owner information for (e.g., 'EAPES-8f3c1f').\n * @returns {Promise<CollectionRanksExport[]>} A promise that resolves to a struct with information\n * Finally, it returns a promise that resolves a struct with information\n */\n public getCollectionRanks = async ({\n ticker,\n extra,\n }: {\n ticker: string;\n extra?: RequestInit;\n }): Promise<CollectionRanksExport[]> => {\n if (!isValidCollectionTicker(ticker)) {\n throw new Error('Invalid collection ticker: ' + ticker);\n }\n const response = await this.api.fetchWithTimeout<CollectionRanksExport[]>(\n `/collection/${ticker}/ranks`,\n {\n next: {\n tags: [`/collection/${ticker}/ranks`],\n revalidate: 60,\n },\n ...extra,\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getDropInfo\n * @param {string} collectionTag - The unique ID of the collection part of the launchpad smart contract\n * @param {string} creatorTag - The unique ID of the creator part of the launchpad smart contract\n * @returns {Promise<GetCollectionMintInfo>} A promise that resolves to a struct with information\n * Finally, it returns a promise that resolves a struct with information\n */\n public getDropInfo = async ({\n collectionTag,\n creatorTag,\n extra,\n }: {\n collectionTag: string;\n creatorTag: string;\n extra?: RequestInit;\n }): Promise<GetCollectionMintInfo> => {\n const response = await this.api.fetchWithTimeout<GetCollectionMintInfo>(\n `/collection/${creatorTag}/${collectionTag}/drop-info`,\n {\n next: {\n tags: [`/collection/${creatorTag}/${collectionTag}/drop-info`],\n revalidate: 12,\n },\n ...extra,\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getCollectionGraphData\n * @param category - The ticker of the collection.\n * @returns {Promise<AnalyticsGraphs>} A promise the required analytics data\n * This function gets the global graph data\n */\n public getCollectionGraphData = async (\n collection: string,\n startTime: string,\n endTime: string,\n bin: string\n ): Promise<AnalyticsGraphs> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n const response = await this.api.fetchWithTimeout<AnalyticsGraphs>(\n `/collection/${collection}/analytics/volume`,\n {\n params: {\n startTime: startTime,\n endTime: endTime,\n bin: bin,\n },\n next: {\n tags: [`/collection/${collection}/analytics/volume`],\n revalidate: 60,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getPinnedCollections\n * @returns {Promise<ICollectionProfile[]>} A promise that resolves to the fetched pinned collections.\n */\n public getPinnedCollections = async (): Promise<\n Pick<\n ICollectionProfile,\n | 'name'\n | 'profile'\n | 'collection'\n | 'banner'\n | 'description'\n | 'isMintable'\n | 'creator'\n >[]\n > => {\n const response = await this.api.fetchWithTimeout<\n Pick<\n ICollectionProfile,\n | 'name'\n | 'profile'\n | 'collection'\n | 'banner'\n | 'description'\n | 'isMintable'\n | 'creator'\n >[]\n >(`/collection/pinned`, {\n next: {\n tags: [`/collection/pinned`],\n revalidate: 60,\n },\n });\n return response;\n };\n\n /**\n * Get drops based on the provided arguments.\n * @param {SearchNFTsArgs} args - The SearchNFTsArgs object containing the search parameters.\n * @returns {Promise<SearchNFTsResponse>} A Promise that resolves to the SearchNFTsResponse object.\n * @throws An error if the provided collection ticker is invalid or if the 'top' value is greater than 35.\n */\n public getDrops = async (args: GETDropsArgs): Promise<GetDropsResponse> => {\n args?.collections?.forEach((element) => {\n if (!isValidCollectionTicker(element)) {\n throw new Error('Invalid collection ticker: ' + element);\n }\n });\n\n if (args.top && args.top > 35) {\n throw new Error('Top cannot be greater than 35');\n }\n const ranges = [];\n\n if (args.timeRange) {\n ranges.push({\n ...args.timeRange,\n field: 'startTime',\n });\n }\n const payloadBody = {\n filters: {\n collection: args.collections ?? [],\n verifiedOnly: args.onlyVerified || false,\n mintToken: args.listedInToken || undefined,\n range: ranges,\n },\n orderBy: args.orderBy || [],\n select: args.onlySelectFields || [],\n includeCount: args.includeCount || false,\n top: args.top || 35,\n skip: args.skip || 0,\n };\n\n const response = await this.api.fetchWithTimeout<GetDropsResponse>(\n `/collection/drops/query`,\n {\n params: {\n filter: JSON.stringify(payloadBody),\n },\n next: {\n tags: ['/collection/drops/query'],\n },\n cache: 'no-store',\n }\n );\n return {\n ...response,\n getNextPagePayload: {\n ...args,\n skip: (args.skip ?? 0) + (args.top ?? 35),\n },\n };\n };\n\n /** Gets collection staking info\n * @param {String} collection - User's address\n * @returns {StakingSummaryPools[]} Collection's staking info\n * @throws {Error} Throws an error if the collection is invalid\n * */\n public getCollectionStakingSummary = async ({\n collection,\n extra,\n }: {\n collection: string;\n extra?: RequestInit;\n }): Promise<StakingSummaryPools[]> => {\n if (!isValidCollectionTicker(collection)) {\n throw new Error('Invalid collection ticker: ' + collection);\n }\n\n const response = await this.api.fetchWithTimeout<StakingSummaryPools[]>(\n `/collection/${collection}/staking/summary`,\n {\n ...extra,\n }\n );\n return response;\n };\n}\n"],"names":["CollectionModule","api","constructor","XOXNOClient","init","getCollectionProfile","collection","isValidCollectionTicker","Error","response","fetchWithTimeout","next","tags","revalidate","getDailyTrending","getCollectionFloorPrice","token","params","price","getCollectionAttributes","getNFTs","args","collections","forEach","element","top","ranges","priceRange","push","field","auctionType","AuctionTypes","Auctions","rankRange","payloadBody","filters","dataType","activeAuction","activeAuctions","onSale","onlyOnSale","saleInfo","seller","listedBy","marketplace","listedOnlyOn","undefined","paymentToken","listedInToken","FixedPrice","AllListed","owner","ownedBy","verifiedOnly","onlyVerified","metadata","attributes","range","cp_staked","isStaked","applyNftExtraDetails","orderBy","select","onlySelectFields","includeCount","skip","filter","JSON","stringify","cache","getNextPagePayload","suggestCollections","name","collectionListingsAnalytics","ticker","getTradingActivity","getActivity","getCollections","isMintable","onlyMintable","length","results","resultsCount","empty","hasMoreResults","getGlobalOffers","withAttributes","isActive","onlyActive","offerId","offerIds","type","GlobalOfferOrderBy","PriceHighToLow","lastSkip","getCollectionVolume","after","before","bin","getMarketplaceVolume","getCollectionOwners","getExportOwners","getCollectionsStatistics","getCollectionStats","getAwaitEmpty","delay","Promise","resolve","setTimeout","getCollectionMintInfo","extra","getCollectionRanks","getDropInfo","collectionTag","creatorTag","getCollectionGraphData","startTime","endTime","getPinnedCollections","getDrops","timeRange","mintToken","getCollectionStakingSummary"],"rangeMappings":"","mappings":"oGAwCaA,0DAAAA,8CAdN,4CAEqB,uCACA,6CACY,kBAUjC,IAAA,AAAMA,iBAAN,MAAMA,iBACX,AAAQC,GAAiB,AACzBC,cAAc,CACZ,IAAI,CAACD,GAAG,CAAGE,kBAAW,CAACC,IAAI,EAC7B,CAgBA,AAAOC,qBAAu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EAAC,CACzC,CACF,CACF,CAAE,AAOF,CAAOiG,4BAA8B,MAAO,CAC1CpH,UAAU,CACVwG,KAAK,CAIN,IACC,GAAI,CAACvG,GAAAA,8BAAuB,EAACD,YAAa,CACxC,MAAM,IAAIE,MAAM,8BAAgCF,WAClD,CAEA,MAAMG,SAAW,MAAM,IAAI,CAACR,GAAG,CAACS,gBAAgB,CAC9C,CAAC,YAAY,EAAEJ,WAAW,gBAAgB,CAAC,CAC3C,CACE,GAAGwG,KAAK,AACV,GAEF,OAAOrG,QACT,CAAE,AACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"CommonModule",{enumerable:true,get:function(){return CommonModule}});const _collection=require("../types/collection");const _api=require("../utils/api");let CommonModule=class CommonModule{api;constructor(){this.api=_api.XOXNOClient.init()}getTokensUsdPrice=async()=>{const response=await this.api.fetchWithTimeout(`/tokens/usd-price`);return response};getAshSwapAmount=async({originalToken,originalTokenValue,paymentToken})=>{const response=await this.api.fetchWithTimeout(`/ash/min-token-quantity`,{params:{originalToken:originalToken,originalTokenValue:originalTokenValue,paymentToken:paymentToken}});return response};getFungibleTokens=async(categories=[_collection.AssetCategory.ALL],identifiers)=>{let params={};if(identifiers){params={identifier:identifiers.join(",")}}if(categories){params={...params,category:categories.join(",")}}const response=await this.api.fetchWithTimeout(`/tokens`,{params});return response};getGlobalGraphData=async(startTime,endTime,bin)=>{const response=await this.api.fetchWithTimeout(`/analytics/volume`,{params:{startTime:startTime,endTime:endTime,bin:bin},next:{tags:["/analytics/volume"],revalidate:60}});return response};getAnalyticsOverview=async()=>{const response=await this.api.fetchWithTimeout(`/analytics/overview`,{next:{tags:["/analytics/overview"],revalidate:60}});return response};suggestResults=async args=>{if(args.top&&args.top>35){throw new Error("Top cannot be greater than 35")}if(!args.name){throw new Error("Name is required")}const payloadBody={name:args.name,top:args.top||35,skip:args.skip||0};return await this.api.fetchWithTimeout(`/search`,{params:{filter:JSON.stringify(payloadBody)},next:{tags:["/search/global"],revalidate:180}})};getExploreStaking=async()=>{const response=await this.api.fetchWithTimeout(`/collection/staking/explore`,{next:{tags:["/collection/staking/explore"],revalidate:60}});return response}};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/common/index.ts"],"sourcesContent":["import {\n AssetCategory,\n FungibleAssetsMap,\n SuggestNFTsArgs,\n SuggestResults,\n} from '../types/collection';\nimport {\n AnalyticsGraphs,\n AshSwapPaymentData,\n StakingExplore,\n StatisticsSummary,\n TokenUSDPrices,\n} from '../types/common';\nimport { XOXNOClient } from '../utils/api';\n\nexport class CommonModule {\n private api: XOXNOClient;\n constructor() {\n this.api = XOXNOClient.init();\n }\n /** Gets all tokens usd price\n * @returns {TokenUSDPrices} User's creator info\n * */\n public getTokensUsdPrice = async (): Promise<TokenUSDPrices> => {\n const response =\n await this.api.fetchWithTimeout<TokenUSDPrices>(`/tokens/usd-price`);\n return response;\n };\n\n /** Gets all tokens usd price\n * @returns {TokenUSDPrices} User's creator info\n * */\n public getAshSwapAmount = async ({\n originalToken,\n originalTokenValue,\n paymentToken,\n }: {\n originalToken: string;\n originalTokenValue: string;\n paymentToken: string;\n }): Promise<AshSwapPaymentData> => {\n const response = await this.api.fetchWithTimeout<AshSwapPaymentData>(\n `/ash/min-token-quantity`,\n {\n params: {\n originalToken: originalToken,\n originalTokenValue: originalTokenValue,\n paymentToken: paymentToken,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getFungibleTokens\n * @param category - The ticker of the collection.\n * @returns {Promise<FungibleAssetsMap>} A promise that resolves a map of ESDT tokens and their info\n * This function fetches all branded fungible assets and their info\n */\n public getFungibleTokens = async (\n categories: AssetCategory[] = [AssetCategory.ALL],\n identifiers?: string[]\n ): Promise<FungibleAssetsMap> => {\n let params = {};\n\n if (identifiers) {\n params = {\n identifier: identifiers.join(','),\n };\n }\n\n if (categories) {\n params = {\n ...params,\n category: categories.join(','),\n };\n }\n const response = await this.api.fetchWithTimeout<FungibleAssetsMap>(\n `/tokens`,\n {\n params,\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getGlobalGraphData\n * @param category - The ticker of the collection.\n * @returns {Promise<AnalyticsGraphs>} A promise the required analytics data\n * This function gets the global graph data\n */\n public getGlobalGraphData = async (\n startTime: string,\n endTime: string,\n bin: string\n ): Promise<AnalyticsGraphs> => {\n const response = await this.api.fetchWithTimeout<AnalyticsGraphs>(\n `/analytics/volume`,\n {\n params: {\n startTime: startTime,\n endTime: endTime,\n bin: bin,\n },\n next: {\n tags: ['/analytics/volume'],\n revalidate: 60,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function getAnalyticsOverview\n * @returns {Promise<StatisticsSummary>} A promise the required analytics data\n * This function gets the global graph data\n */\n public getAnalyticsOverview = async (): Promise<StatisticsSummary> => {\n const response = await this.api.fetchWithTimeout<StatisticsSummary>(\n `/analytics/overview`,\n {\n next: {\n tags: ['/analytics/overview'],\n revalidate: 60,\n },\n }\n );\n return response;\n };\n\n /**\n * @public\n * @async\n * @function suggestResults\n * @param {SuggestNFTsArgs} args - An object containing the necessary parameters to fetch suggested NFT results.\n * @returns {Promise<SuggestResults>} A promise that resolves to the fetched NFT results.\n *\n * This function fetches suggested NFT results based on the provided arguments. It takes an object with the following properties:\n * - name (string): The name to search for (required).\n * - orderBy (SuggestOrderBy[], optional): An array of ordering preferences for the results.\n * - top (number, optional): The maximum number of results to return (default is 35, cannot be greater than 35).\n * - skip (number, optional): The number of results to skip (default is 0).\n *\n * The function first validates the input arguments and constructs a payload body with the provided parameters.\n * Then, it converts the payload body into a base64 string and fetches the suggested results using the API.\n * Finally, it returns a promise that resolves to the fetched NFT results.\n */\n public suggestResults = async (\n args: SuggestNFTsArgs\n ): Promise<SuggestResults> => {\n if (args.top && args.top > 35) {\n throw new Error('Top cannot be greater than 35');\n }\n if (!args.name) {\n throw new Error('Name is required');\n }\n\n const payloadBody: SuggestNFTsArgs = {\n name: args.name,\n top: args.top || 35,\n skip: args.skip || 0,\n };\n\n return await this.api.fetchWithTimeout<SuggestResults>(`/search`, {\n params: {\n filter: JSON.stringify(payloadBody),\n },\n next: {\n tags: ['/search/global'],\n revalidate: 180,\n },\n });\n };\n\n /**\n * @public\n * @async\n * @function getExploreStaking\n * @returns {Promise<StakingExplore[]>} A promise that resolves to the fetched staking explore data.\n * This function fetches the staking explore data.\n */\n public getExploreStaking = async (): Promise<StakingExplore[]> => {\n const response = await this.api.fetchWithTimeout<StakingExplore[]>(\n `/collection/staking/explore`,\n {\n next: {\n tags: ['/collection/staking/explore'],\n revalidate: 60,\n },\n }\n );\n return response;\n };\n}\n"],"names":["CommonModule","api","constructor","XOXNOClient","init","getTokensUsdPrice","response","fetchWithTimeout","getAshSwapAmount","originalToken","originalTokenValue","paymentToken","params","getFungibleTokens","categories","AssetCategory","ALL","identifiers","identifier","join","category","getGlobalGraphData","startTime","endTime","bin","next","tags","revalidate","getAnalyticsOverview","suggestResults","args","top","Error","name","payloadBody","skip","filter","JSON","stringify","getExploreStaking"],"rangeMappings":"","mappings":"oGAeaA,sDAAAA,0CAVN,0CAQqB,gBAErB,IAAA,AAAMA,aAAN,MAAMA,aACX,AAAQC,GAAiB,AACzBC,cAAc,CACZ,IAAI,CAACD,GAAG,CAAGE,gBAAW,CAACC,IAAI,EAC7B,CAIA,AAAOC,kBAAoB,UACzB,MAAMC,SACJ,MAAM,IAAI,CAACL,GAAG,CAACM,gBAAgB,CAAiB,CAAC,iBAAiB,CAAC,EACrE,OAAOD,QACT,CAAE,AAKF,CAAOE,iBAAmB,MAAO,CAC/BC,aAAa,CACbC,kBAAkB,CAClBC,YAAY,CAKb,IACC,MAAML,SAAW,MAAM,IAAI,CAACL,GAAG,CAACM,gBAAgB,CAC9C,CAAC,uBAAuB,CAAC,CACzB,CACEK,OAAQ,CACNH,cAAeA,cACfC,mBAAoBA,mBAC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,OAAO,MAAM,IAAI,CAAClC,GAAG,CAACM,gBAAgB,CAAiB,CAAC,OAAO,CAAC,CAAE,CAChEK,OAAQ,CACNwB,OAAQC,KAAKC,SAAS,CAACJ,YACzB,EACAT,KAAM,CACJC,KAAM,CAAC,iBAAiB,CACxBC,WAAY,GACd,CACF,EACF,CAAE,AASF,CAAOY,kBAAoB,UACzB,MAAMjC,SAAW,MAAM,IAAI,CAACL,GAAG,CAACM,gBAAgB,CAC9C,CAAC,2BAA2B,CAAC,CAC7B,CACEkB,KAAM,CACJC,KAAM,CAAC,8BAA8B,CACrCC,WAAY,EACd,CACF,GAEF,OAAOrB,QACT,CAAE,AACJ"}
|
package/out/src/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});_export_star(require("./types"),exports);_export_star(require("./collection"),exports);_export_star(require("./nft"),exports);_export_star(require("./users"),exports);_export_star(require("./staking"),exports);_export_star(require("./utils/api"),exports);_export_star(require("./common"),exports);_export_star(require("./interactions"),exports);_export_star(require("./launchpad"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './types';\nexport * from './collection';\nexport * from './nft';\nexport * from './users';\nexport * from './staking';\nexport * from './utils/api';\nexport * from './common';\nexport * from './interactions';\nexport * from './launchpad';\n"],"names":[],"rangeMappings":"","mappings":"2FAAc,yCACA,8CACA,uCACA,yCACA,2CACA,6CACA,0CACA,gDACA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});_export_star(require("./interactions"),exports);_export_star(require("./launchpad"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
|
|
2
|
+
//# sourceMappingURL=index.large.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.large.ts"],"sourcesContent":["export * from './interactions';\nexport * from './launchpad';\n"],"names":[],"rangeMappings":"","mappings":"2FAAc,gDACA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});const _index=require("../../index");describe("SCInteraction",()=>{let sc;beforeAll(async()=>{_index.XOXNOClient.init();sc=await _index.SCInteraction.init()});beforeEach(async()=>{return new Promise(resolve=>setTimeout(resolve,1e3))});it("should return the XOXNO marketplace cut fees from SC",async()=>{const fees=await sc.getMarketplaceFees();expect(fees).toBeDefined();expect(fees).toEqual(100)});it("should return the XOXNO marketplace accepted payment tokens",async()=>{const tokens=await sc.getAcceptedPaymentTokens();expect(tokens).toBeDefined();expect(tokens).toContain("EGLD")});it("should return the XOXNO marketplace global offers unique IDs",async()=>{const global_offer_ids=await sc.getGlobalOfferIDs();expect(global_offer_ids).toBeDefined();expect(global_offer_ids.length).toBeGreaterThan(1)});it("should return the XOXNO listings count",async()=>{const listings=await sc.getListingsCount();expect(listings).toBeDefined();expect(listings).toBeGreaterThan(1)});it("should return the XOXNO custom offers count",async()=>{const listings=await sc.getOffersCount();expect(listings).toBeDefined();expect(listings).toBeGreaterThan(1)});it("should return the XOXNO global offers count",async()=>{const listings=await sc.getGlobalOffersCount();expect(listings).toBeDefined();expect(listings).toBeGreaterThan(1)});it("should return the XOXNO user deposit balance",async()=>{const balance=await sc.getUserPoolBalance("erd1fmd662htrgt07xxd8me09newa9s0euzvpz3wp0c4pz78f83grt9qm6pn57","EGLD",0);expect(balance).toBeDefined();expect(balance).toBeGreaterThan(0)});it("should return the XOXNO unique listed collections",async()=>{const listings=await sc.getCollectionsCount();expect(listings).toBeDefined();expect(listings).toBeGreaterThan(1)});it("should return the XOXNO unique auction IDs of a collection",async()=>{const IDs=await sc.getAuctionIDsForCollection("COW-cd463d");expect(IDs).toBeDefined();expect(IDs.length).toBeGreaterThan(1)});it("should return the XOXNO on sale NFT count of a collection",async()=>{const count=await sc.getCollectionNFTsOnSaleCount("COW-cd463d");expect(count).toBeDefined();expect(count).toBeGreaterThan(10)});it("should return if the collection is listed on XOXNO",async()=>{const isListed=await sc.isCollectionListed("COW-cd463d");expect(isListed).toBeDefined();expect(isListed).toEqual(true)});it("should create the transaction to withdraw auctions",async()=>{const interaction=await sc.withdrawAuctions([1],{address:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",nonce:1},"XO");expect(interaction).toBeDefined();expect(interaction.buildTransaction().toSendable()).toEqual({nonce:1,value:"0",receiver:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",sender:"erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8",gasPrice:1e9,gasLimit:2e7,data:"d2l0aGRyYXdAMDE=",chainID:"1",version:1,options:undefined,guardian:undefined,signature:undefined,guardianSignature:undefined})})});
|
|
2
|
+
//# sourceMappingURL=market.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/interactions/__tests__/market.test.ts"],"sourcesContent":["import { SCInteraction, XOXNOClient } from '../../index';\n\ndescribe('SCInteraction', () => {\n let sc: SCInteraction;\n beforeAll(async () => {\n XOXNOClient.init();\n sc = await SCInteraction.init();\n });\n\n beforeEach(async () => {\n return new Promise((resolve) => setTimeout(resolve, 1000));\n });\n\n it('should return the XOXNO marketplace cut fees from SC', async () => {\n const fees = await sc.getMarketplaceFees();\n expect(fees).toBeDefined();\n expect(fees).toEqual(100);\n });\n\n it('should return the XOXNO marketplace accepted payment tokens', async () => {\n const tokens = await sc.getAcceptedPaymentTokens();\n expect(tokens).toBeDefined();\n expect(tokens).toContain('EGLD');\n });\n\n it('should return the XOXNO marketplace global offers unique IDs', async () => {\n const global_offer_ids = await sc.getGlobalOfferIDs();\n expect(global_offer_ids).toBeDefined();\n expect(global_offer_ids.length).toBeGreaterThan(1);\n });\n\n it('should return the XOXNO listings count', async () => {\n const listings = await sc.getListingsCount();\n expect(listings).toBeDefined();\n expect(listings).toBeGreaterThan(1);\n });\n\n it('should return the XOXNO custom offers count', async () => {\n const listings = await sc.getOffersCount();\n expect(listings).toBeDefined();\n expect(listings).toBeGreaterThan(1);\n });\n\n it('should return the XOXNO global offers count', async () => {\n const listings = await sc.getGlobalOffersCount();\n expect(listings).toBeDefined();\n expect(listings).toBeGreaterThan(1);\n });\n\n it('should return the XOXNO user deposit balance', async () => {\n const balance = await sc.getUserPoolBalance(\n 'erd1fmd662htrgt07xxd8me09newa9s0euzvpz3wp0c4pz78f83grt9qm6pn57',\n 'EGLD',\n 0\n );\n expect(balance).toBeDefined();\n expect(balance).toBeGreaterThan(0);\n });\n\n it('should return the XOXNO unique listed collections', async () => {\n const listings = await sc.getCollectionsCount();\n expect(listings).toBeDefined();\n expect(listings).toBeGreaterThan(1);\n });\n\n it('should return the XOXNO unique auction IDs of a collection', async () => {\n const IDs = await sc.getAuctionIDsForCollection('COW-cd463d');\n expect(IDs).toBeDefined();\n expect(IDs.length).toBeGreaterThan(1);\n });\n\n it('should return the XOXNO on sale NFT count of a collection', async () => {\n const count = await sc.getCollectionNFTsOnSaleCount('COW-cd463d');\n expect(count).toBeDefined();\n expect(count).toBeGreaterThan(10);\n });\n\n it('should return if the collection is listed on XOXNO', async () => {\n const isListed = await sc.isCollectionListed('COW-cd463d');\n expect(isListed).toBeDefined();\n expect(isListed).toEqual(true);\n });\n\n it('should create the transaction to withdraw auctions', async () => {\n const interaction = await sc.withdrawAuctions(\n [1],\n {\n address:\n 'erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8',\n nonce: 1,\n },\n 'XO'\n );\n expect(interaction).toBeDefined();\n expect(interaction.buildTransaction().toSendable()).toEqual({\n nonce: 1,\n value: '0',\n receiver:\n 'erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8',\n sender: 'erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8',\n gasPrice: 1000000000,\n gasLimit: 20000000,\n data: 'd2l0aGRyYXdAMDE=',\n chainID: '1',\n version: 1,\n options: undefined,\n guardian: undefined,\n signature: undefined,\n guardianSignature: undefined,\n });\n });\n});\n"],"names":["describe","sc","beforeAll","XOXNOClient","init","SCInteraction","beforeEach","Promise","resolve","setTimeout","it","fees","getMarketplaceFees","expect","toBeDefined","toEqual","tokens","getAcceptedPaymentTokens","toContain","global_offer_ids","getGlobalOfferIDs","length","toBeGreaterThan","listings","getListingsCount","getOffersCount","getGlobalOffersCount","balance","getUserPoolBalance","getCollectionsCount","IDs","getAuctionIDsForCollection","count","getCollectionNFTsOnSaleCount","isListed","isCollectionListed","interaction","withdrawAuctions","address","nonce","buildTransaction","toSendable","value","receiver","sender","gasPrice","gasLimit","data","chainID","version","options","undefined","guardian","signature","guardianSignature"],"rangeMappings":"","mappings":"2FAA2C,eAE3CA,SAAS,gBAAiB,KACxB,IAAIC,GACJC,UAAU,UACRC,kBAAW,CAACC,IAAI,GAChBH,GAAK,MAAMI,oBAAa,CAACD,IAAI,EAC/B,GAEAE,WAAW,UACT,OAAO,IAAIC,QAAQ,AAACC,SAAYC,WAAWD,QAAS,KACtD,GAEAE,GAAG,uDAAwD,UACzD,MAAMC,KAAO,MAAMV,GAAGW,kBAAkB,GACxCC,OAAOF,MAAMG,WAAW,GACxBD,OAAOF,MAAMI,OAAO,CAAC,IACvB,GAEAL,GAAG,8DAA+D,UAChE,MAAMM,OAAS,MAAMf,GAAGgB,wBAAwB,GAChDJ,OAAOG,QAAQF,WAAW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UACvD,MAAMwB,SAAW,MAAMjC,GAAGkC,kBAAkB,CAAC,cAC7CtB,OAAOqB,UAAUpB,WAAW,GAC5BD,OAAOqB,UAAUnB,OAAO,CAAC,KAC3B,GAEAL,GAAG,qDAAsD,UACvD,MAAM0B,YAAc,MAAMnC,GAAGoC,gBAAgB,CAC3C,CAAC,EAAE,CACH,CACEC,QACE,iEACFC,MAAO,CACT,EACA,MAEF1B,OAAOuB,aAAatB,WAAW,GAC/BD,OAAOuB,YAAYI,gBAAgB,GAAGC,UAAU,IAAI1B,OAAO,CAAC,CAC1DwB,MAAO,EACPG,MAAO,IACPC,SACE,iEACFC,OAAQ,iEACRC,SAAU,IACVC,SAAU,IACVC,KAAM,mBACNC,QAAS,IACTC,QAAS,EACTC,QAASC,UACTC,SAAUD,UACVE,UAAWF,UACXG,kBAAmBH,SACrB,EACF,EACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"SCInteraction",{enumerable:true,get:function(){return SCInteraction}});const _=require("..");const _scCalls=require("../utils/scCalls");const _SmartContractAbis=require("../utils/SmartContractAbis");const _SmartContractService=require("../utils/SmartContractService");const _numerical=require("@multiversx/sdk-core/out/smartcontracts/typesystem/numerical");const _interactions=require("../types/interactions");const _bignumber=_interop_require_default(require("bignumber.js"));const _struct=require("@multiversx/sdk-core/out/smartcontracts/typesystem/struct");const _tokenIdentifier=require("@multiversx/sdk-core/out/smartcontracts/typesystem/tokenIdentifier");const _fields=require("@multiversx/sdk-core/out/smartcontracts/typesystem/fields");const _boolean=require("@multiversx/sdk-core/out/smartcontracts/typesystem/boolean");const _address=require("@multiversx/sdk-core/out/address");const _tokens=require("@multiversx/sdk-core/out/tokens");function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}let SCInteraction=class SCInteraction{xo;call;api;constructor(marketAbiXOXNO){this.xo=marketAbiXOXNO;this.call=new _scCalls.ContractQueryRunner;this.api=_.XOXNOClient.init()}static async init(){const config=_.XOXNOClient.init().config;const marketAbiXOXNO=await _SmartContractAbis.SmartContractAbis.getMarket();const xo_abi=(0,_SmartContractService.getSmartContract)(marketAbiXOXNO,config.XO_SC);return new SCInteraction(xo_abi)}async getResult(interaction){return await this.call.runQuery(this.xo,interaction)}getMarketplaceFees=async()=>{const interaction=this.xo.methods.getMarketplaceCutPercentage();const result=await this.getResult(interaction);return parseInt(result.firstValue?.valueOf())};getAcceptedPaymentTokens=async()=>{const interaction=this.xo.methods.getAcceptedTokens();const result=await this.getResult(interaction);return result.firstValue?.valueOf()};getGlobalOfferIDs=async()=>{const interaction=this.xo.methods.getGlobalOffers();const result=await this.getResult(interaction);return result.firstValue?.valueOf().map(id=>parseInt(id))};async getUserPoolBalance(address,token,nonce){const result=await this.getResult(this.xo.methods.userDeposit([address,token,nonce]));if(!result?.firstValue){return 0}return new _numerical.BigUIntValue(result.firstValue.valueOf().amount).valueOf().shiftedBy(-18).toNumber()}isOfferActive(offer_price,user_balance){return offer_price<=user_balance}getGlobalOfferData=async global_offer_id=>{const interaction=this.xo.methods.getGlobalOffer([global_offer_id]);const result=await this.getResult(interaction);const body=result.firstValue?.valueOf();body.offer_id=parseInt(body.offer_id.valueOf());body.marketplace="XO";body.short_price=parseFloat(new _numerical.BigUIntValue(body.price).valueOf().shiftedBy(-18).toString());body.new_version=Boolean(body.new_version);if(!body.new_version){body.isActive=this.isOfferActive(body.short_price,await this.getUserPoolBalance(body.owner,body.payment_token,body.payment_nonce))}else{body.isActive=true}body.quantity=parseInt(body.quantity.valueOf());body.payment_nonce=parseInt(body.payment_nonce.valueOf());body.price=body.price.valueOf();body.timestamp=parseInt(body.timestamp.valueOf());body.owner=body.owner.valueOf().toString();if(body.attributes){body.attributes=JSON.parse(Buffer.from(body.attributes.valueOf().toString(),"base64").toString("ascii"))}return body};getAuctionInfo=async auctionID=>{const interaction=this.xo.methods.getFullAuctionData([auctionID]);const result=await this.getResult(interaction);const body=result.firstValue?.valueOf();if(!body){return null}body.auctioned_token_nonce=parseInt(body.auctioned_token_nonce.valueOf());body.nr_auctioned_tokens=parseInt(body.nr_auctioned_tokens.valueOf());body.auction_type=body.auction_type.name;body.payment_token_nonce=parseInt(body.payment_token_nonce.valueOf());body.min_bid=body.min_bid.valueOf();body.max_bid=body.max_bid.valueOf();body.start_time=parseInt(body.start_time.valueOf());body.deadline=parseInt(body.deadline.valueOf());body.original_owner=body.original_owner.valueOf().toString();body.current_winner=body.current_winner.valueOf().toString();body.current_bid=body.current_bid.valueOf().toString();body.marketplace_cut_percentage=body.marketplace_cut_percentage.valueOf();body.creator_royalties_percentage=body.creator_royalties_percentage.valueOf();return body};async getListingsCount(){const result=await this.getResult(this.xo.methods.getListingsCount());const count=parseInt(result.firstValue?.valueOf());return count}async getOffersCount(){const result=await this.getResult(this.xo.methods.getOffersCount());const count=parseInt(result.firstValue?.valueOf());return count}async getGlobalOffersCount(){const result=await this.getResult(this.xo.methods.getGlobalOffersCount());const count=parseInt(result.firstValue?.valueOf());return count}async getCollectionsCount(){const result=await this.getResult(this.xo.methods.getCollectionsCount());const count=parseInt(result.firstValue?.valueOf());return count}async isCollectionListed(collection){const result=await this.getResult(this.xo.methods.isCollectionListed([collection]));return Boolean(result.firstValue?.valueOf())}async getCollectionNFTsOnSaleCount(collection){const result=await this.getResult(this.xo.methods.getTokenItemsForSaleCount([collection]));return parseInt(result.firstValue?.valueOf())}async getAuctionIDsForCollection(collection){const result=await this.getResult(this.xo.methods.getAuctionsForTicker([collection]));const ids=result.firstValue?.valueOf().map(id=>parseInt(id));return ids}withdrawAuctions(auctionIDs,senderNonce,market){if(market==="XO"){const interaction=this.xo.methods.withdraw(auctionIDs);if(senderNonce.nonce){interaction.withNonce(senderNonce.nonce)}return interaction.withChainID(this.api.chain).withSender(new _address.Address(senderNonce.address)).withGasLimit(Math.min(6e8,15e6+auctionIDs.length*5e6))}else{throw new Error("Market not supported")}}withdrawGlobalOffer(offerID,senderNonce){const interaction=this.xo.methods.withdrawGlobalOffer([offerID]);if(senderNonce.nonce){interaction.withNonce(senderNonce.nonce)}return interaction.withChainID(this.api.chain).withSender(new _address.Address(senderNonce.address)).withGasLimit(15e6)}acceptGlobalOffer({signature,offer_id,auction_id_opt,nft,address,nonce}){const interaction=signature?this.xo.methods.acceptGlobalOffer([offer_id,auction_id_opt,signature]):this.xo.methods.acceptGlobalOffer([offer_id,auction_id_opt]);interaction.withSender(new _address.Address(address));if(nft){interaction.withSingleESDTNFTTransfer(_tokens.TokenTransfer.semiFungible(nft.collection,nft.nonce,nft.amount??1))}if(nonce){interaction.withNonce(nonce)}return interaction.withChainID(this.api.chain).withGasLimit(3e7)}sendGlobalOffer({payment_token,payment_nonce,price,collection,attributes,depositAmount,address,nonce}){const interaction=attributes?this.xo.methods.sendGlobalOffer([payment_token,payment_nonce,_tokens.TokenTransfer.egldFromAmount(price).toString(),collection,attributes]):this.xo.methods.sendGlobalOffer([payment_token,payment_nonce,_tokens.TokenTransfer.egldFromAmount(price).toString(),collection]);if(nonce){interaction.withNonce(nonce)}interaction.withSender(new _address.Address(address));if(depositAmount){interaction.withValue(_tokens.TokenTransfer.egldFromAmount(depositAmount))}return interaction.withChainID(this.api.chain).withGasLimit(3e7)}sendCustomOffer({payment_token,payment_nonce,price,deadline,nft,depositAmount,address,nonce}){const interaction=this.xo.methods.sendOffer([payment_token,payment_nonce,_tokens.TokenTransfer.egldFromAmount(price).toString(),nft.collection,nft.nonce,nft.amount??1,deadline]);if(nonce){interaction.withNonce(nonce)}interaction.withSender(new _address.Address(address));if(depositAmount){interaction.withValue(_tokens.TokenTransfer.egldFromAmount(depositAmount))}return interaction.withChainID(this.api.chain).withGasLimit(3e7)}withdrawCustomOffer(offerID,senderNonce){const interaction=this.xo.methods.withdrawOffer([offerID]);if(senderNonce.nonce){interaction.withNonce(senderNonce.nonce)}interaction.withSender(new _address.Address(senderNonce.address));return interaction.withChainID(this.api.chain).withGasLimit(15e6)}declineCustomOffer(offerID,sender,nft){const interaction=this.xo.methods.declineOffer([offerID]);if(sender.nonce){interaction.withNonce(sender.nonce)}interaction.withSender(new _address.Address(sender.address));if(nft){interaction.withSingleESDTNFTTransfer(_tokens.TokenTransfer.semiFungible(nft.collection,nft.nonce,nft.amount??1))}return interaction.withChainID(this.api.chain).withGasLimit(2e7)}acceptCustomOffer(offerID,sender,nft){const interaction=this.xo.methods.acceptOffer([offerID]);if(sender.nonce){interaction.withNonce(sender.nonce)}interaction.withSender(new _address.Address(sender.address));if(nft){interaction.withSingleESDTNFTTransfer(_tokens.TokenTransfer.semiFungible(nft.collection,nft.nonce,nft.amount??1))}return interaction.withChainID(this.api.chain).withGasLimit(3e7)}endAuction(auctionID,sender,market="XO"){if(market=="XO"){const interaction=this.xo.methods.endAuction([auctionID]);if(sender.nonce){interaction.withNonce(sender.nonce)}interaction.withSender(new _address.Address(sender.address));return interaction.withChainID(this.api.chain).withGasLimit(15e6)}else{throw new Error("Market not supported")}}bidOnAuctionId(auctionID,collection,nonce,payment,sender){const interaction=this.xo.methods.bid([auctionID,collection,nonce]);if(!payment.amount){throw new Error("Payment amount is required")}if(sender.nonce){interaction.withNonce(sender.nonce)}interaction.withSender(new _address.Address(sender.address));if(payment.collection=="EGLD"&&payment.amount){interaction.withValue(_tokens.TokenTransfer.egldFromAmount(payment.amount))}else{interaction.withSingleESDTTransfer(_tokens.TokenTransfer.fungibleFromAmount(payment.collection,payment.amount,payment.decimals??18))}return interaction.withChainID(this.api.chain).withGasLimit(3e7)}bulkBuy(auctionIDs,payment,sender){const interaction=this.xo.methods.bid(auctionIDs);if(sender.nonce){interaction.withNonce(sender.nonce)}interaction.withSender(new _address.Address(sender.address));if(!payment.amount){throw new Error("Payment amount is required")}if(payment.collection=="EGLD"&&payment.amount){interaction.withValue(_tokens.TokenTransfer.egldFromAmount(payment.amount))}else{interaction.withSingleESDTTransfer(_tokens.TokenTransfer.fungibleFromAmount(payment.collection,payment.amount,payment.decimals??18))}return interaction.withChainID(this.api.chain).withGasLimit(Math.min(6e8,2e7+auctionIDs.length*5e6))}async buyAuctionById({auctionID,collection,nonce,paymentAmount,quantity=1,token="EGLD",withCheck=true,isBigUintPayment=false,address,nonce:senderNonce,isBid=false,decimals=18,market="XO"}){if(market!=="XO"){throw new Error("Market not supported")}if(!auctionID){throw new Error("AuctionID not provided")}let auction=null;if(!paymentAmount||!token||!collection||!nonce||withCheck){auction=await this.getAuctionInfo(auctionID);if(auction===null){throw new Error("Auction not found")}if(auction.auction_type===_interactions.AuctionType.Nft||auction.auction_type===_interactions.AuctionType.SftOnePerPayment){throw new Error("Auction type is not NFT or SftOnePerPayment")}}const paymentToken=auction?.payment_token_type??token;const bigNumber=auction?true:isBigUintPayment;let amount=isBid?auction?.max_bid??paymentAmount:auction?.min_bid??paymentAmount;if(!amount){throw new Error("Payment amount not provided")}const interaction=this.xo.methods.buy([auctionID,auction?.auctioned_token_type??collection,auction?.auctioned_token_nonce??nonce,quantity??1]);if(senderNonce){interaction.withNonce(senderNonce)}interaction.withSender(new _address.Address(address));if(token==="EGLD"){interaction.withValue(bigNumber?_tokens.TokenTransfer.egldFromBigInteger(new _bignumber.default(amount).multipliedBy(quantity)):_tokens.TokenTransfer.egldFromAmount(new _bignumber.default(amount).multipliedBy(quantity)))}else{if(!bigNumber){auction=await this.getAuctionInfo(auctionID);if(auction===null){throw new Error("Auction not found")}amount=isBid?auction.max_bid:auction.min_bid}interaction.withSingleESDTTransfer(_tokens.TokenTransfer.fungibleFromBigInteger(paymentToken,amount,decimals))}return interaction.withChainID(this.api.chain).withGasLimit(2e7)}async changeListing(listings,sender){const fooType=new _struct.StructType("BulkUpdateListing",[new _fields.FieldDefinition("payment_token_type","",new _tokenIdentifier.TokenIdentifierType),new _fields.FieldDefinition("new_price","",new _numerical.BigUIntType),new _fields.FieldDefinition("auction_id","",new _numerical.U64Type),new _fields.FieldDefinition("deadline","",new _numerical.U64Type)]);const structs=[];listings.forEach(({paymentToken,price,auctionID,deadline})=>{structs.push(new _struct.Struct(fooType,[new _fields.Field(new _tokenIdentifier.TokenIdentifierValue(paymentToken),"payment_token_type"),new _fields.Field(new _numerical.BigUIntValue(price),"new_price"),new _fields.Field(new _numerical.U64Value(auctionID),"auction_id"),new _fields.Field(new _numerical.U64Value(deadline),"deadline")]))});const interaction=this.xo.methods.changeListing(structs);if(sender.nonce){interaction.withNonce(sender.nonce)}interaction.withSender(new _address.Address(sender.address));return interaction.withChainID(this.api.chain).withGasLimit(Math.min(6e8,8e6+listings.length*2e6))}async listNFTs(listings,sender){const fooType=new _struct.StructType("BulkListing",[new _fields.FieldDefinition("min_bid","",new _numerical.BigUIntType),new _fields.FieldDefinition("max_bid","",new _numerical.BigUIntType),new _fields.FieldDefinition("deadline","",new _numerical.U64Type),new _fields.FieldDefinition("accepted_payment_token","",new _tokenIdentifier.TokenIdentifierType),new _fields.FieldDefinition("bid","",new _boolean.BooleanType),new _fields.FieldDefinition("opt_sft_max_one_per_payment","",new _boolean.BooleanType),new _fields.FieldDefinition("opt_start_time","",new _numerical.U64Type),new _fields.FieldDefinition("collection","",new _tokenIdentifier.TokenIdentifierType),new _fields.FieldDefinition("nonce","",new _numerical.U64Type),new _fields.FieldDefinition("nft_amount","",new _numerical.BigUIntType)]);const structs=[];const tokens=[];listings.forEach(listing=>{const decimals=listing.accepted_payment_token_decimals??18;const minBID=new _bignumber.default(listing.min_bid).shiftedBy(decimals);const maxBID=new _bignumber.default(listing.max_bid??0).shiftedBy(decimals);tokens.push(_tokens.TokenTransfer.semiFungible(listing.collection,listing.nonce,listing.nft_amount));structs.push(new _struct.Struct(fooType,[new _fields.Field(new _numerical.BigUIntValue(minBID),"min_bid"),new _fields.Field(new _numerical.BigUIntValue(maxBID),"max_bid"),new _fields.Field(new _numerical.U64Value(new _bignumber.default(listing.deadline??0)),"deadline"),new _fields.Field(new _tokenIdentifier.TokenIdentifierValue(listing.accepted_payment_token??"EGLD"),"accepted_payment_token"),new _fields.Field(new _boolean.BooleanValue(listing.bid??false),"bid"),new _fields.Field(new _boolean.BooleanValue(listing.isSFTPack??false),"opt_sft_max_one_per_payment"),new _fields.Field(new _numerical.U64Value(new _bignumber.default(listing.opt_start_time?listing.opt_start_time:0)),"opt_start_time"),new _fields.Field(new _tokenIdentifier.TokenIdentifierValue(listing.collection),"collection"),new _fields.Field(new _numerical.U64Value(listing.nonce),"nonce"),new _fields.Field(new _numerical.BigUIntValue(new _bignumber.default(listing.nft_amount)),"nft_amount")]))});const interaction=this.xo.methods.listings(structs);if(sender.nonce){interaction.withNonce(sender.nonce)}interaction.withSender(new _address.Address(sender.address));interaction.withMultiESDTNFTTransfer(tokens);return interaction.withChainID(this.api.chain).withGasLimit(Math.min(6e8,8e6+listings.length*2e6))}};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/interactions/index.ts"],"sourcesContent":["import type { Interaction } from '@multiversx/sdk-core/out/smartcontracts/interaction';\nimport { GlobalOffer } from '../types/collection';\nimport { XOXNOClient } from '../';\nimport { ContractQueryRunner } from '../utils/scCalls';\nimport { SmartContractAbis } from '../utils/SmartContractAbis';\nimport { getSmartContract } from '../utils/SmartContractService';\nimport type { SmartContract } from '@multiversx/sdk-core/out/smartcontracts/smartContract';\nimport {\n BigUIntType,\n BigUIntValue,\n U64Type,\n U64Value,\n} from '@multiversx/sdk-core/out/smartcontracts/typesystem/numerical';\nimport {\n AcceptGlobalOffer,\n Auction,\n AuctionType,\n ChangeListing,\n NFTBody,\n NewListingArgs,\n Payment,\n SendCustomOffer,\n SendGlobalOffer,\n WithSenderAndNonce,\n} from '../types/interactions';\nimport BigNumber from 'bignumber.js';\nimport {\n Struct,\n StructType,\n} from '@multiversx/sdk-core/out/smartcontracts/typesystem/struct';\nimport {\n TokenIdentifierType,\n TokenIdentifierValue,\n} from '@multiversx/sdk-core/out/smartcontracts/typesystem/tokenIdentifier';\nimport {\n Field,\n FieldDefinition,\n} from '@multiversx/sdk-core/out/smartcontracts/typesystem/fields';\nimport {\n BooleanType,\n BooleanValue,\n} from '@multiversx/sdk-core/out/smartcontracts/typesystem/boolean';\nimport { Address } from '@multiversx/sdk-core/out/address';\nimport { TokenTransfer } from '@multiversx/sdk-core/out/tokens';\nexport class SCInteraction {\n private xo: SmartContract;\n private call: ContractQueryRunner;\n private api: XOXNOClient;\n private constructor(marketAbiXOXNO: SmartContract) {\n this.xo = marketAbiXOXNO;\n this.call = new ContractQueryRunner();\n this.api = XOXNOClient.init();\n }\n\n static async init() {\n const config = XOXNOClient.init().config;\n const marketAbiXOXNO = await SmartContractAbis.getMarket();\n const xo_abi = getSmartContract(marketAbiXOXNO, config.XO_SC);\n\n return new SCInteraction(xo_abi);\n }\n\n private async getResult(interaction: Interaction) {\n return await this.call.runQuery(this.xo, interaction);\n }\n\n /**\n * Gets the percentage of each transaction that will be paid to the marketplace.\n *\n * @returns The percentage of each transaction that will be paid to the marketplace.\n */\n public getMarketplaceFees = async (): Promise<number> => {\n const interaction = this.xo.methods.getMarketplaceCutPercentage();\n const result = await this.getResult(interaction);\n return parseInt(result.firstValue?.valueOf());\n };\n\n /**\n * Retrieves the list of accepted payment tokens.\n * @returns {string[]} A list of accepted payment tokens.\n */\n public getAcceptedPaymentTokens = async (): Promise<string[]> => {\n const interaction = this.xo.methods.getAcceptedTokens();\n const result = await this.getResult(interaction);\n return result.firstValue?.valueOf();\n };\n\n /**\n * This function returns a list of IDs of global offers.\n * @returns {number[]} a list of IDs of global offers.\n */\n\n public getGlobalOfferIDs = async (): Promise<number[]> => {\n const interaction = this.xo.methods.getGlobalOffers();\n const result = await this.getResult(interaction);\n return result.firstValue?.valueOf().map((id: string) => parseInt(id));\n };\n\n /**\n * Gets the balance of a user in a token of a specific pool.\n * @param address The address of the user.\n * @param token The token address.\n * @param nonce The nonce of the pool.\n * @returns {number} The balance of the user in the token of the pool.\n */\n async getUserPoolBalance(\n address: string,\n token: string,\n nonce: number\n ): Promise<number> {\n const result = await this.getResult(\n this.xo.methods.userDeposit([address, token, nonce])\n );\n\n if (!result?.firstValue) {\n return 0;\n }\n return new BigUIntValue(result.firstValue.valueOf().amount)\n .valueOf()\n .shiftedBy(-18)\n .toNumber();\n }\n\n // function to determine if the offer is active\n // based on the offer price and user balance\n private isOfferActive(offer_price: number, user_balance: number): boolean {\n return offer_price <= user_balance;\n }\n\n /**\n * Returns the global offer data for the offer with the given id.\n *\n * @param global_offer_id The id of the global offer for which to return the data.\n *\n * @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.\n */\n\n public getGlobalOfferData = async (\n global_offer_id: number\n ): Promise<GlobalOffer> => {\n const interaction = this.xo.methods.getGlobalOffer([global_offer_id]);\n const result = await this.getResult(interaction);\n const body = result.firstValue?.valueOf();\n body.offer_id = parseInt(body.offer_id.valueOf());\n body.marketplace = 'XO';\n body.short_price = parseFloat(\n new BigUIntValue(body.price).valueOf().shiftedBy(-18).toString()\n );\n body.new_version = Boolean(body.new_version);\n if (!body.new_version) {\n body.isActive = this.isOfferActive(\n body.short_price,\n await this.getUserPoolBalance(\n body.owner,\n body.payment_token,\n body.payment_nonce\n )\n );\n } else {\n body.isActive = true;\n }\n body.quantity = parseInt(body.quantity.valueOf());\n body.payment_nonce = parseInt(body.payment_nonce.valueOf());\n body.price = body.price.valueOf();\n\n body.timestamp = parseInt(body.timestamp.valueOf());\n body.owner = body.owner.valueOf().toString();\n if (body.attributes) {\n body.attributes = JSON.parse(\n Buffer.from(body.attributes.valueOf().toString(), 'base64').toString(\n 'ascii'\n )\n );\n }\n return body as GlobalOffer;\n };\n\n /**\n * Returns the auction struct for the given id.\n *\n * @param auctionID The id of the auction for which to return the data.\n *\n * @returns {Auction} An object containing the auction data for the given id. If the auction id is invalid, the return value will be null.\n */\n\n public getAuctionInfo = async (\n auctionID: number\n ): Promise<Auction | null> => {\n const interaction = this.xo.methods.getFullAuctionData([auctionID]);\n const result = await this.getResult(interaction);\n const body = result.firstValue?.valueOf();\n if (!body) {\n return null;\n }\n body.auctioned_token_nonce = parseInt(body.auctioned_token_nonce.valueOf());\n body.nr_auctioned_tokens = parseInt(body.nr_auctioned_tokens.valueOf());\n body.auction_type = body.auction_type.name;\n body.payment_token_nonce = parseInt(body.payment_token_nonce.valueOf());\n body.min_bid = body.min_bid.valueOf();\n body.max_bid = body.max_bid.valueOf();\n body.start_time = parseInt(body.start_time.valueOf());\n body.deadline = parseInt(body.deadline.valueOf());\n body.original_owner = body.original_owner.valueOf().toString();\n body.current_winner = body.current_winner.valueOf().toString();\n body.current_bid = body.current_bid.valueOf().toString();\n body.marketplace_cut_percentage = body.marketplace_cut_percentage.valueOf();\n body.creator_royalties_percentage =\n body.creator_royalties_percentage.valueOf();\n\n return body as Auction;\n };\n\n /** Gets the number of listings.\n * @returns {number} The number of listings.\n * */\n public async getListingsCount(): Promise<number> {\n const result = await this.getResult(this.xo.methods.getListingsCount());\n const count = parseInt(result.firstValue?.valueOf());\n return count;\n }\n\n /** Gets the number of custom offers.\n * @returns {number} The number of custom offers.\n * */\n public async getOffersCount(): Promise<number> {\n const result = await this.getResult(this.xo.methods.getOffersCount());\n const count = parseInt(result.firstValue?.valueOf());\n return count;\n }\n\n /** Gets the number of global offers.\n * @returns {number} The number of global offers.\n * */\n public async getGlobalOffersCount(): Promise<number> {\n const result = await this.getResult(this.xo.methods.getGlobalOffersCount());\n const count = parseInt(result.firstValue?.valueOf());\n return count;\n }\n\n /** Gets the number of collections listed.\n * @returns {number} The number of collections listed.\n * */\n public async getCollectionsCount(): Promise<number> {\n const result = await this.getResult(this.xo.methods.getCollectionsCount());\n const count = parseInt(result.firstValue?.valueOf());\n return count;\n }\n\n /**\n * Checks whether a collection is listed with at least 1 NFT.\n *\n * @param collection name of the collection\n * @return true if the collection is listed, false otherwise\n */\n public async isCollectionListed(collection: string): Promise<boolean> {\n const result = await this.getResult(\n this.xo.methods.isCollectionListed([collection])\n );\n return Boolean(result.firstValue?.valueOf());\n }\n\n /** Gets the on sale NFT count of the collection.\n *\n * @param collection The collection identifier for which one wants to get the on sale NFT count.\n *\n * @returns {number} The on sale NFT count of the collection.\n * */\n public async getCollectionNFTsOnSaleCount(\n collection: string\n ): Promise<number> {\n const result = await this.getResult(\n this.xo.methods.getTokenItemsForSaleCount([collection])\n );\n return parseInt(result.firstValue?.valueOf());\n }\n\n /** Gets the active unique auction IDs of collection.\n *\n * @param collection The collection identifier for which one wants to get the active unique auction IDs.\n *\n * @returns {number[]} The active unique auction IDs of collection.\n * */\n\n public async getAuctionIDsForCollection(\n collection: string\n ): Promise<number[]> {\n const result = await this.getResult(\n this.xo.methods.getAuctionsForTicker([collection])\n );\n const ids = result.firstValue?.valueOf().map((id: string) => parseInt(id));\n return ids;\n }\n\n /**\n * Withdraw auctions from the smart contract.\n *\n * @param auctionIDs The IDs of the auctions to withdraw from\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public withdrawAuctions(\n auctionIDs: number[],\n senderNonce: WithSenderAndNonce,\n market: 'XO'\n ): Interaction {\n if (market === 'XO') {\n const interaction = this.xo.methods.withdraw(auctionIDs);\n\n if (senderNonce.nonce) {\n interaction.withNonce(senderNonce.nonce);\n }\n return interaction\n .withChainID(this.api.chain)\n .withSender(new Address(senderNonce.address))\n .withGasLimit(\n Math.min(600_000_000, 15_000_000 + auctionIDs.length * 5_000_000)\n );\n } else {\n throw new Error('Market not supported');\n }\n }\n\n /**\n * Withdraw global offer from the smart contract.\n *\n * @param auctionIDs The IDs of the global offer to withdraw\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public withdrawGlobalOffer(\n offerID: number,\n senderNonce: WithSenderAndNonce\n ): Interaction {\n const interaction = this.xo.methods.withdrawGlobalOffer([offerID]);\n\n if (senderNonce.nonce) {\n interaction.withNonce(senderNonce.nonce);\n }\n return interaction\n .withChainID(this.api.chain)\n .withSender(new Address(senderNonce.address))\n .withGasLimit(15_000_000);\n }\n\n /**\n * Accept a global offer\n *\n * @param offerID The offer ID\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public acceptGlobalOffer({\n signature,\n offer_id,\n auction_id_opt,\n nft,\n address,\n nonce,\n }: AcceptGlobalOffer & WithSenderAndNonce): Interaction {\n const interaction = signature\n ? this.xo.methods.acceptGlobalOffer([offer_id, auction_id_opt, signature])\n : this.xo.methods.acceptGlobalOffer([offer_id, auction_id_opt]);\n interaction.withSender(new Address(address));\n if (nft) {\n interaction.withSingleESDTNFTTransfer(\n TokenTransfer.semiFungible(nft.collection, nft.nonce, nft.amount ?? 1)\n );\n }\n if (nonce) {\n interaction.withNonce(nonce);\n }\n return interaction.withChainID(this.api.chain).withGasLimit(30_000_000);\n }\n\n /**\n * Send a global offer\n * @param payment_token The token used for payment\n * @param payment_nonce The nonce of the payment token\n * @param price The price of the offer\n * @param collection The collection of the NFT\n * @param attributes The attributes of the NFT\n * @param depositAmount The deposit amount\n * @returns {Interaction} The interaction object of the smart contract\n * */\n public sendGlobalOffer({\n payment_token,\n payment_nonce,\n price,\n collection,\n attributes,\n depositAmount,\n address,\n nonce,\n }: SendGlobalOffer & WithSenderAndNonce): Interaction {\n const interaction = attributes\n ? this.xo.methods.sendGlobalOffer([\n payment_token,\n payment_nonce,\n TokenTransfer.egldFromAmount(price).toString(),\n collection,\n attributes,\n ])\n : this.xo.methods.sendGlobalOffer([\n payment_token,\n payment_nonce,\n TokenTransfer.egldFromAmount(price).toString(),\n collection,\n ]);\n\n if (nonce) {\n interaction.withNonce(nonce);\n }\n interaction.withSender(new Address(address));\n if (depositAmount) {\n interaction.withValue(TokenTransfer.egldFromAmount(depositAmount));\n }\n return interaction.withChainID(this.api.chain).withGasLimit(30_000_000);\n }\n\n /**\n * Send a custom offer\n * @param payment_token The token used for payment\n * @param payment_nonce The nonce of the payment token\n * @param price The price of the offer\n * @param deadline The deadline of the offer\n * @param nft The NFT to be sold\n * @param depositAmount The deposit amount\n * @returns {Interaction} The interaction object of the smart contract\n * */\n public sendCustomOffer({\n payment_token,\n payment_nonce,\n price,\n deadline,\n nft,\n depositAmount,\n address,\n nonce,\n }: SendCustomOffer & WithSenderAndNonce): Interaction {\n const interaction = this.xo.methods.sendOffer([\n payment_token,\n payment_nonce,\n TokenTransfer.egldFromAmount(price).toString(),\n nft.collection,\n nft.nonce,\n nft.amount ?? 1,\n deadline,\n ]);\n if (nonce) {\n interaction.withNonce(nonce);\n }\n interaction.withSender(new Address(address));\n if (depositAmount) {\n interaction.withValue(TokenTransfer.egldFromAmount(depositAmount));\n }\n return interaction.withChainID(this.api.chain).withGasLimit(30_000_000);\n }\n\n /**\n * Withdraws a custom offer\n *\n * @param offerID The offer ID\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public withdrawCustomOffer(\n offerID: number,\n senderNonce: WithSenderAndNonce\n ): Interaction {\n const interaction = this.xo.methods.withdrawOffer([offerID]);\n if (senderNonce.nonce) {\n interaction.withNonce(senderNonce.nonce);\n }\n interaction.withSender(new Address(senderNonce.address));\n return interaction.withChainID(this.api.chain).withGasLimit(15_000_000);\n }\n\n /**\n * Decline a custom offer\n *\n * @param offerID The offer ID\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public declineCustomOffer(\n offerID: number,\n sender: WithSenderAndNonce,\n nft?: NFTBody\n ): Interaction {\n const interaction = this.xo.methods.declineOffer([offerID]);\n if (sender.nonce) {\n interaction.withNonce(sender.nonce);\n }\n interaction.withSender(new Address(sender.address));\n if (nft) {\n interaction.withSingleESDTNFTTransfer(\n TokenTransfer.semiFungible(nft.collection, nft.nonce, nft.amount ?? 1)\n );\n }\n return interaction.withChainID(this.api.chain).withGasLimit(20_000_000);\n }\n\n /**\n * Accept a custom offer\n *\n * @param offerID The offer ID\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public acceptCustomOffer(\n offerID: number,\n sender: WithSenderAndNonce,\n nft?: NFTBody\n ): Interaction {\n const interaction = this.xo.methods.acceptOffer([offerID]);\n\n if (sender.nonce) {\n interaction.withNonce(sender.nonce);\n }\n interaction.withSender(new Address(sender.address));\n if (nft) {\n interaction.withSingleESDTNFTTransfer(\n TokenTransfer.semiFungible(nft.collection, nft.nonce, nft.amount ?? 1)\n );\n }\n return interaction.withChainID(this.api.chain).withGasLimit(30_000_000);\n }\n\n /**\n * @public\n * @function endAuction\n * @param {number} auctionID - The unique identifier of the auction.\n * @returns {Interaction} The resulting interaction with the specified chainID and gas limit.\n *\n * This function allows ending an auction by its auctionID. It takes the following parameter:\n * - auctionID (number): The unique identifier of the auction.\n *\n * The function calls the `endAuction` method on the smart contract with the provided auctionID.\n * Finally, it returns the resulting interaction with the specified chainID and gas limit.\n */\n\n public endAuction(\n auctionID: number,\n sender: WithSenderAndNonce,\n market = 'XO'\n ): Interaction {\n if (market == 'XO') {\n const interaction = this.xo.methods.endAuction([auctionID]);\n\n if (sender.nonce) {\n interaction.withNonce(sender.nonce);\n }\n interaction.withSender(new Address(sender.address));\n return interaction.withChainID(this.api.chain).withGasLimit(15_000_000);\n } else {\n throw new Error('Market not supported');\n }\n }\n\n /**\n * Bid on an auction\n *\n * @param auctionID The auction ID\n * @param collection The NFT Collection\n * @param nonce The NFT nonce\n * @param payment The payment object\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public bidOnAuctionId(\n auctionID: number,\n collection: string,\n nonce: number,\n payment: Payment,\n sender: WithSenderAndNonce\n ): Interaction {\n const interaction = this.xo.methods.bid([auctionID, collection, nonce]);\n if (!payment.amount) {\n throw new Error('Payment amount is required');\n }\n\n if (sender.nonce) {\n interaction.withNonce(sender.nonce);\n }\n interaction.withSender(new Address(sender.address));\n if (payment.collection == 'EGLD' && payment.amount) {\n interaction.withValue(TokenTransfer.egldFromAmount(payment.amount));\n } else {\n interaction.withSingleESDTTransfer(\n TokenTransfer.fungibleFromAmount(\n payment.collection,\n payment.amount,\n payment.decimals ?? 18\n )\n );\n }\n return interaction.withChainID(this.api.chain).withGasLimit(30_000_000);\n }\n\n /**\n * Bulk buy auctions\n *\n * @param auctionIDs The auction IDs\n * @param payment The payment object\n * @returns {Interaction} The interaction object of the smart contract\n */\n\n public bulkBuy(\n auctionIDs: number[],\n payment: Payment,\n sender: WithSenderAndNonce\n ): Interaction {\n const interaction = this.xo.methods.bid(auctionIDs);\n\n if (sender.nonce) {\n interaction.withNonce(sender.nonce);\n }\n interaction.withSender(new Address(sender.address));\n if (!payment.amount) {\n throw new Error('Payment amount is required');\n }\n if (payment.collection == 'EGLD' && payment.amount) {\n interaction.withValue(TokenTransfer.egldFromAmount(payment.amount));\n } else {\n interaction.withSingleESDTTransfer(\n TokenTransfer.fungibleFromAmount(\n payment.collection,\n payment.amount,\n payment.decimals ?? 18\n )\n );\n }\n return interaction\n .withChainID(this.api.chain)\n .withGasLimit(\n Math.min(600_000_000, 20_000_000 + auctionIDs.length * 5_000_000)\n );\n }\n\n /**\n * @public\n * @async\n * @function buyAuctionById\n * @param {Object} options - An object containing the necessary parameters to buy an auction.\n * @param {number} options.auctionID - The unique identifier of the auction.\n * @param {string} [options.collection] - The collection the auctioned token belongs to (optional).\n * @param {number} [options.nonce] - The nonce of the auctioned token (optional).\n * @param {number} [options.quantity=1] - The quantity of tokens to buy (default is 1).\n * @param {string} [options.token='EGLD'] - The payment token (default is 'EGLD').\n * @param {number} [options.paymentAmount] - The payment amount for the auction (optional).\n * @param {boolean} [options.withCheck=true] - Whether to check the auction information (default is true).\n * @param {boolean} [options.isBigUintPayment=false] - Whether the payment amount is a big integer (default is false).\n * @returns {Promise<Interaction>} The resulting interaction with the specified chainID and gas limit.\n *\n * This function allows a user to buy an auction by its auctionID. It takes an object with the following properties:\n * - auctionID (number): The unique identifier of the auction.\n * - collection (string, optional): The collection the auctioned token belongs to.\n * - nonce (number, optional): The nonce of the auctioned token.\n * - quantity (number, optional): The quantity of tokens to buy (default is 1).\n * - token (string, optional): The payment token (default is 'EGLD').\n * - paymentAmount (number, optional): The payment amount for the auction.\n * - withCheck (boolean, optional): Whether to check the auction information (default is true).\n * - isBigUintPayment (boolean, optional): Whether the payment amount is a big integer (default is false).\n *\n * The function first checks if the auction exists and if its type is NFT or SftOnePerPayment. If not, an error is thrown.\n * Then, it calculates the payment amount and calls the `buy` method on the smart contract with the provided parameters.\n * Finally, the function returns the resulting interaction with the specified chainID and gas limit.\n */\n public async buyAuctionById({\n auctionID,\n collection,\n nonce,\n paymentAmount,\n quantity = 1,\n token = 'EGLD',\n withCheck = true,\n isBigUintPayment = false,\n address,\n nonce: senderNonce,\n isBid = false,\n decimals = 18,\n market = 'XO',\n }: {\n auctionID: number;\n collection?: string;\n nonce?: number;\n quantity?: number;\n token?: string;\n paymentAmount?: number;\n withCheck?: boolean;\n isBigUintPayment?: boolean;\n isBid?: boolean;\n market?: string;\n decimals?: number;\n } & WithSenderAndNonce): Promise<Interaction> {\n if (market !== 'XO') {\n throw new Error('Market not supported');\n }\n if (!auctionID) {\n throw new Error('AuctionID not provided');\n }\n let auction: Auction | null = null;\n if (!paymentAmount || !token || !collection || !nonce || withCheck) {\n auction = await this.getAuctionInfo(auctionID);\n if (auction === null) {\n throw new Error('Auction not found');\n }\n if (\n auction.auction_type === AuctionType.Nft ||\n auction.auction_type === AuctionType.SftOnePerPayment\n ) {\n throw new Error('Auction type is not NFT or SftOnePerPayment');\n }\n }\n const paymentToken = auction?.payment_token_type ?? token;\n const bigNumber = auction ? true : isBigUintPayment;\n let amount = isBid\n ? auction?.max_bid ?? paymentAmount\n : auction?.min_bid ?? paymentAmount;\n if (!amount) {\n throw new Error('Payment amount not provided');\n }\n\n const interaction = this.xo.methods.buy([\n auctionID,\n auction?.auctioned_token_type ?? collection,\n auction?.auctioned_token_nonce ?? nonce,\n quantity ?? 1,\n ]);\n\n if (senderNonce) {\n interaction.withNonce(senderNonce);\n }\n interaction.withSender(new Address(address));\n if (token === 'EGLD') {\n interaction.withValue(\n bigNumber\n ? TokenTransfer.egldFromBigInteger(\n new BigNumber(amount).multipliedBy(quantity)\n )\n : TokenTransfer.egldFromAmount(\n new BigNumber(amount).multipliedBy(quantity)\n )\n );\n } else {\n if (!bigNumber) {\n auction = await this.getAuctionInfo(auctionID);\n if (auction === null) {\n throw new Error('Auction not found');\n }\n amount = isBid ? auction.max_bid : auction.min_bid;\n }\n interaction.withSingleESDTTransfer(\n TokenTransfer.fungibleFromBigInteger(paymentToken, amount, decimals)\n );\n }\n\n return interaction.withChainID(this.api.chain).withGasLimit(20_000_000);\n }\n\n /**\n * @docutype\n * @public\n * @async\n * @function changeListing\n * @param {ChangeListing[]} listings - An array of objects containing the information needed to change a listing.\n * @returns {Interaction} The resulting interaction with the specified chainID and gas limit.\n *\n * This function takes an array of `ChangeListing` objects and constructs `Struct` instances using the provided\n * information. Each `ChangeListing` object should have the following properties:\n * - paymentToken (string): The identifier of the payment token type.\n * - price (BigInt): The new price for the listing.\n * - auctionID (number): The unique identifier of the auction.\n * - deadline (number): The deadline (in Unix time) for the listing.\n *\n * The function then calls the `changeListing` method on the smart contract and returns the resulting interaction\n * with the specified chainID and gas limit.\n */\n public async changeListing(\n listings: ChangeListing[],\n sender: WithSenderAndNonce\n ) {\n const fooType = new StructType('BulkUpdateListing', [\n new FieldDefinition('payment_token_type', '', new TokenIdentifierType()),\n new FieldDefinition('new_price', '', new BigUIntType()),\n new FieldDefinition('auction_id', '', new U64Type()),\n new FieldDefinition('deadline', '', new U64Type()),\n ]);\n const structs: Struct[] = [];\n listings.forEach(({ paymentToken, price, auctionID, deadline }) => {\n structs.push(\n new Struct(fooType, [\n new Field(\n new TokenIdentifierValue(paymentToken),\n 'payment_token_type'\n ),\n new Field(new BigUIntValue(price), 'new_price'),\n new Field(new U64Value(auctionID), 'auction_id'),\n new Field(new U64Value(deadline), 'deadline'),\n ])\n );\n });\n const interaction = this.xo.methods.changeListing(structs);\n if (sender.nonce) {\n interaction.withNonce(sender.nonce);\n }\n interaction.withSender(new Address(sender.address));\n\n return interaction\n .withChainID(this.api.chain)\n .withGasLimit(\n Math.min(600_000_000, 8_000_000 + listings.length * 2_000_000)\n );\n }\n\n public async listNFTs(\n listings: NewListingArgs[],\n sender: WithSenderAndNonce\n ) {\n const fooType = new StructType('BulkListing', [\n new FieldDefinition('min_bid', '', new BigUIntType()),\n new FieldDefinition('max_bid', '', new BigUIntType()),\n new FieldDefinition('deadline', '', new U64Type()),\n new FieldDefinition(\n 'accepted_payment_token',\n '',\n new TokenIdentifierType()\n ),\n new FieldDefinition('bid', '', new BooleanType()),\n new FieldDefinition('opt_sft_max_one_per_payment', '', new BooleanType()),\n new FieldDefinition('opt_start_time', '', new U64Type()),\n new FieldDefinition('collection', '', new TokenIdentifierType()),\n new FieldDefinition('nonce', '', new U64Type()),\n new FieldDefinition('nft_amount', '', new BigUIntType()),\n ]);\n const structs: Struct[] = [];\n const tokens: any = [];\n listings.forEach((listing: NewListingArgs) => {\n const decimals = listing.accepted_payment_token_decimals ?? 18;\n const minBID = new BigNumber(listing.min_bid).shiftedBy(decimals);\n const maxBID = new BigNumber(listing.max_bid ?? 0).shiftedBy(decimals);\n\n tokens.push(\n TokenTransfer.semiFungible(\n listing.collection,\n listing.nonce,\n listing.nft_amount\n )\n );\n\n structs.push(\n new Struct(fooType, [\n new Field(new BigUIntValue(minBID), 'min_bid'),\n new Field(new BigUIntValue(maxBID), 'max_bid'),\n new Field(\n new U64Value(new BigNumber(listing.deadline ?? 0)),\n 'deadline'\n ),\n new Field(\n new TokenIdentifierValue(listing.accepted_payment_token ?? 'EGLD'),\n 'accepted_payment_token'\n ),\n new Field(new BooleanValue(listing.bid ?? false), 'bid'),\n new Field(\n new BooleanValue(listing.isSFTPack ?? false),\n 'opt_sft_max_one_per_payment'\n ),\n new Field(\n new U64Value(\n new BigNumber(listing.opt_start_time ? listing.opt_start_time : 0)\n ),\n 'opt_start_time'\n ),\n new Field(new TokenIdentifierValue(listing.collection), 'collection'),\n new Field(new U64Value(listing.nonce), 'nonce'),\n new Field(\n new BigUIntValue(new BigNumber(listing.nft_amount)),\n 'nft_amount'\n ),\n ])\n );\n });\n\n const interaction = this.xo.methods.listings(structs);\n if (sender.nonce) {\n interaction.withNonce(sender.nonce);\n }\n interaction.withSender(new Address(sender.address));\n interaction.withMultiESDTNFTTransfer(tokens);\n return interaction\n .withChainID(this.api.chain)\n .withGasLimit(\n Math.min(600_000_000, 8_000_000 + listings.length * 2_000_000)\n );\n }\n}\n"],"names":["SCInteraction","xo","call","api","marketAbiXOXNO","ContractQueryRunner","XOXNOClient","init","config","SmartContractAbis","getMarket","xo_abi","getSmartContract","XO_SC","getResult","interaction","runQuery","getMarketplaceFees","methods","getMarketplaceCutPercentage","result","parseInt","firstValue","valueOf","getAcceptedPaymentTokens","getAcceptedTokens","getGlobalOfferIDs","getGlobalOffers","map","id","getUserPoolBalance","address","token","nonce","userDeposit","BigUIntValue","amount","shiftedBy","toNumber","isOfferActive","offer_price","user_balance","getGlobalOfferData","global_offer_id","getGlobalOffer","body","offer_id","marketplace","short_price","parseFloat","price","toString","new_version","Boolean","isActive","owner","payment_token","payment_nonce","quantity","timestamp","attributes","JSON","parse","Buffer","from","getAuctionInfo","auctionID","getFullAuctionData","auctioned_token_nonce","nr_auctioned_tokens","auction_type","name","payment_token_nonce","min_bid","max_bid","start_time","deadline","original_owner","current_winner","current_bid","marketplace_cut_percentage","creator_royalties_percentage","getListingsCount","count","getOffersCount","getGlobalOffersCount","getCollectionsCount","isCollectionListed","collection","getCollectionNFTsOnSaleCount","getTokenItemsForSaleCount","getAuctionIDsForCollection","getAuctionsForTicker","ids","withdrawAuctions","auctionIDs","senderNonce","market","withdraw","withNonce","withChainID","chain","withSender","Address","withGasLimit","Math","min","length","Error","withdrawGlobalOffer","offerID","acceptGlobalOffer","signature","auction_id_opt","nft","withSingleESDTNFTTransfer","TokenTransfer","semiFungible","sendGlobalOffer","depositAmount","egldFromAmount","withValue","sendCustomOffer","sendOffer","withdrawCustomOffer","withdrawOffer","declineCustomOffer","sender","declineOffer","acceptCustomOffer","acceptOffer","endAuction","bidOnAuctionId","payment","bid","withSingleESDTTransfer","fungibleFromAmount","decimals","bulkBuy","buyAuctionById","paymentAmount","withCheck","isBigUintPayment","isBid","auction","AuctionType","Nft","SftOnePerPayment","paymentToken","payment_token_type","bigNumber","buy","auctioned_token_type","egldFromBigInteger","BigNumber","multipliedBy","fungibleFromBigInteger","changeListing","listings","fooType","StructType","FieldDefinition","TokenIdentifierType","BigUIntType","U64Type","structs","forEach","push","Struct","Field","TokenIdentifierValue","U64Value","listNFTs","BooleanType","tokens","listing","accepted_payment_token_decimals","minBID","maxBID","nft_amount","accepted_payment_token","BooleanValue","isSFTPack","opt_start_time","withMultiESDTNFTTransfer"],"rangeMappings":"","mappings":"oGA4CaA,uDAAAA,iCA1Ce,6BACQ,qDACF,kEACD,0DAO1B,4FAYA,2EACe,uCAIf,4FAIA,4FAIA,oFAIA,qFACiB,0DACM,uHACvB,IAAA,AAAMA,cAAN,MAAMA,cACX,AAAQC,EAAkB,AAC1B,CAAQC,IAA0B,AAClC,CAAQC,GAAiB,AACzB,aAAoBC,cAA6B,CAAE,CACjD,IAAI,CAACH,EAAE,CAAGG,cACV,CAAA,IAAI,CAACF,IAAI,CAAG,IAAIG,4BAAmB,AACnC,CAAA,IAAI,CAACF,GAAG,CAAGG,aAAW,CAACC,IAAI,EAC7B,CAEA,aAAaA,MAAO,CAClB,MAAMC,OAASF,aAAW,CAACC,IAAI,GAAGC,MAAM,CACxC,MAAMJ,eAAiB,MAAMK,oCAAiB,CAACC,SAAS,GACxD,MAAMC,OAASC,GAAAA,sCAAgB,EAACR,eAAgBI,OAAOK,KAAK,EAE5D,OAAO,IAAIb,cAAcW,OAC3B,CAEA,MAAcG,UAAUC,WAAwB,CAAE,CAChD,OAAO,MAAM,IAAI,CAACb,IAAI,CAACc,QAAQ,CAAC,IAAI,CAACf,EAAE,CAAEc,YAC3C,CAOA,AAAOE,mBAAqB,UAC1B,MAAMF,YAAc,IAAI,CAACd,EAAE,CAACiB,OAAO,CAACC,2BAA2B,GAC/D,MAAMC,OAAS,MAAM,IAAI,CAACN,SAAS,CAACC,aACpC,OAAOM,SAASD,OAAOE,UAAU,EAAEC,UACrC,CAAE,AAMF,CAAOC,yBAA2B,UACh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,CACAlB,YAAYuF,UAAU,CAAC,IAAIC,gBAAO,CAACwB,OAAOhG,OAAO,GACjDhB,YAAYyK,wBAAwB,CAACV,QACrC,OAAO/J,YACJqF,WAAW,CAAC,IAAI,CAACjG,GAAG,CAACkG,KAAK,EAC1BG,YAAY,CACXC,KAAKC,GAAG,CAAC,IAAa,IAAYoD,SAASnD,MAAM,CAAG,KAE1D,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});const _=require("..");const _api=require("../../utils/api");describe("SCInteraction",()=>{let sc;beforeAll(async()=>{_api.XOXNOClient.init();sc=await _.LaunchpadModule.init("erd1qqqqqqqqqqqqqpgqtwtp5uz97u232zvzd973upqxwe2xnqv2ys5s3c7jx9")});beforeEach(async()=>{return new Promise(resolve=>setTimeout(resolve,1e3))});it("should return all the unique tags of the launchpad SC",async()=>{const tags=await sc.getAllUniqueTags();expect(tags).toBeDefined();expect(tags).toContain("Elonverse")});it("should return all the unique stages of a collection from the launchpad SC",async()=>{const tags=await sc.getStages("Elonverse");expect(tags).toBeDefined()})});
|
|
2
|
+
//# sourceMappingURL=market.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/launchpad/__tests__/market.test.ts"],"sourcesContent":["import { LaunchpadModule } from '..';\nimport { XOXNOClient } from '../../utils/api';\n\ndescribe('SCInteraction', () => {\n let sc: LaunchpadModule;\n beforeAll(async () => {\n XOXNOClient.init();\n sc = await LaunchpadModule.init(\n 'erd1qqqqqqqqqqqqqpgqtwtp5uz97u232zvzd973upqxwe2xnqv2ys5s3c7jx9'\n );\n });\n\n beforeEach(async () => {\n return new Promise((resolve) => setTimeout(resolve, 1000));\n });\n\n it('should return all the unique tags of the launchpad SC', async () => {\n const tags = await sc.getAllUniqueTags();\n expect(tags).toBeDefined();\n expect(tags).toContain('Elonverse');\n });\n\n it('should return all the unique stages of a collection from the launchpad SC', async () => {\n const tags = await sc.getStages('Elonverse');\n expect(tags).toBeDefined();\n });\n});\n"],"names":["describe","sc","beforeAll","XOXNOClient","init","LaunchpadModule","beforeEach","Promise","resolve","setTimeout","it","tags","getAllUniqueTags","expect","toBeDefined","toContain","getStages"],"rangeMappings":"","mappings":"sFAAgC,yBACJ,mBAE5BA,SAAS,gBAAiB,KACxB,IAAIC,GACJC,UAAU,UACRC,gBAAW,CAACC,IAAI,GAChBH,GAAK,MAAMI,iBAAe,CAACD,IAAI,CAC7B,iEAEJ,GAEAE,WAAW,UACT,OAAO,IAAIC,QAAQ,AAACC,SAAYC,WAAWD,QAAS,KACtD,GAEAE,GAAG,wDAAyD,UAC1D,MAAMC,KAAO,MAAMV,GAAGW,gBAAgB,GACtCC,OAAOF,MAAMG,WAAW,GACxBD,OAAOF,MAAMI,SAAS,CAAC,YACzB,GAEAL,GAAG,4EAA6E,UAC9E,MAAMC,KAAO,MAAMV,GAAGe,SAAS,CAAC,aAChCH,OAAOF,MAAMG,WAAW,EAC1B,EACF"}
|