@xoxno/sdk-js 0.0.6-alpha → 0.0.7-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.
@@ -1,16 +0,0 @@
1
- export type Offer = {
2
- offer_id: number;
3
- collection: string;
4
- quantity: number;
5
- payment_token: string;
6
- payment_nonce: number;
7
- price: number;
8
- timestamp: number;
9
- owner: string;
10
- attributes: Array<{
11
- trait_type: string;
12
- value: string;
13
- }>;
14
- new_version: boolean;
15
- price_long: string;
16
- };
package/src/types/nft.ts DELETED
@@ -1,100 +0,0 @@
1
- export interface NFTAttribute {
2
- trait_type: string;
3
- value: string;
4
- occurance: number;
5
- rarity: number;
6
- frequency: number;
7
- OnSale?: number;
8
- FloorPrice?: number;
9
- }
10
-
11
- export interface NFTMetadata {
12
- description?: string;
13
- attributes: NFTAttribute[];
14
- rarity: {
15
- rank: number;
16
- };
17
- }
18
-
19
- export interface OriginalMedia {
20
- contentType: string;
21
- contentLength: number;
22
- }
23
-
24
- export interface SaleInfoNft {
25
- auction_id: number;
26
- seller: string;
27
- current_winner: string;
28
- min_bid: string;
29
- max_bid: string;
30
- current_bid: string;
31
- start_time: number;
32
- deadline: number;
33
- accepted_payment_token: string;
34
- accepted_payment_token_nonce: number;
35
- auction_type: string;
36
- timestamp: number;
37
- min_bid_short: number;
38
- max_bid_short: number;
39
- current_bid_short: number;
40
- quantity: null | number;
41
- marketplace: string;
42
- usd: string;
43
- usd_max_bid: string;
44
- }
45
-
46
- export interface NftValue {
47
- floorValue: number;
48
- avgValue: number;
49
- maxValue: number;
50
- collectionFp: number;
51
- }
52
-
53
- export interface GameData {
54
- name: string;
55
- value: number;
56
- }
57
-
58
- export interface OffersInfo {
59
- EgldValue: number;
60
- UsdValue: number;
61
- deadline: number;
62
- isActive: boolean;
63
- offer_id: number;
64
- owner: string;
65
- ownerUsername: string;
66
- payment_nonce: number;
67
- payment_token: string;
68
- price: string;
69
- price_short: number;
70
- quantity: number;
71
- timestamp: number;
72
- }
73
-
74
- export interface NftData {
75
- identifier: string;
76
- collection: string;
77
- attributes?: string;
78
- nonce: number;
79
- type: string;
80
- name: string;
81
- creator?: string;
82
- royalties: number;
83
- url: string;
84
- avifUrl: string;
85
- webpUrl: string;
86
- wasProcessed: boolean;
87
- onSale: boolean;
88
- hasOffers?: boolean;
89
- metadata: NFTMetadata;
90
- originalMedia: OriginalMedia;
91
- saleInfoNft: SaleInfoNft;
92
- offersInfo: OffersInfo[];
93
- gameData: GameData[]; // Only for Cantina Rolaye
94
- owner?: string;
95
- ownerCount?: number; // Only for SFTs with over 1 owner
96
- ownerUsername?: string;
97
- isVerified: boolean;
98
- isVisible: boolean;
99
- nftValue?: NftValue;
100
- }
@@ -1,95 +0,0 @@
1
- import { Marketplace, MetadataAttribute, TradingActivity } from './collection';
2
-
3
- export interface TradingActivityQueryFilter {
4
- filters: {
5
- collection?: string[];
6
- identifier?: string[];
7
- address?: string[];
8
- tokens?: string[];
9
- marketplace?: Marketplace[];
10
- action?: string[];
11
- range?: {
12
- min: number;
13
- max: number;
14
- };
15
- rankRange?: {
16
- min: number;
17
- max: number;
18
- };
19
- timestampRange?: {
20
- min: number;
21
- max: number;
22
- };
23
- attributes?: MetadataAttribute[];
24
- };
25
- top: number;
26
- skip: number;
27
- select?: SelectFieldsTradingActivity[];
28
- orderBy?: OrderByTradingActivity[];
29
- }
30
- export interface TradincActivityArgs {
31
- /** The collections to fetch the trading activity from */
32
- collections?: string[];
33
- /** The identifier of the NFTs to fetch the trading activity from */
34
- identifiers?: string[];
35
- /** The owners of the NFTs to fetch the trading activity from */
36
- owners?: string[];
37
- /** The marketplaces to fetch the trading activity from */
38
- marketplaces?: Marketplace[];
39
- /** The tokens to fetch the trading activity from */
40
- placedInToken?: string[];
41
- /** The price range to fetch the trading activity from */
42
- priceRange?: {
43
- min: number;
44
- max: number;
45
- };
46
- /** The rank range to fetch the trading activity from */
47
- rankRange?: {
48
- min: number;
49
- max: number;
50
- };
51
- /** The timestamp range to fetch the trading activity from */
52
- timestampRange?: {
53
- min: number;
54
- max: number;
55
- };
56
- /** The number of results to return */
57
- top?: number;
58
- /** The number of results to skip */
59
- skip?: number;
60
- /** The actions to fetch the trading activity from */
61
- actions?: string[];
62
- /** The fields to select from the trading activity */
63
- select?: SelectFieldsTradingActivity[];
64
- /** The fields to order the trading activity by */
65
- orderBy?: OrderByTradingActivity[];
66
- /** The attributes to fetch the trading activity from */
67
- attributes?: MetadataAttribute[];
68
- }
69
-
70
- export enum OrderByTradingActivity {
71
- PriceHighToLow = 'short_price desc',
72
- PriceLowToHigh = 'short_price asc',
73
- RecentPlaced = 'timestamp desc',
74
- OldestPlaced = 'timestamp asc',
75
- }
76
-
77
- export enum SelectFieldsTradingActivity {
78
- 'attributes',
79
- 'collection',
80
- 'offer_id',
81
- 'owner',
82
- 'short_price',
83
- 'price',
84
- 'id',
85
- 'dataType',
86
- 'marketplace',
87
- 'payment_token',
88
- }
89
-
90
- export interface TradingActivityResponse {
91
- hasMoreResults: boolean;
92
- resources: TradingActivity[];
93
- getNextPagePayload: TradincActivityArgs;
94
- empty: boolean;
95
- }
@@ -1,82 +0,0 @@
1
- import { AbiRegistry } from '@multiversx/sdk-core';
2
- import axios from 'axios';
3
-
4
- export class SmartContractAbis {
5
- private static manager: AbiRegistry;
6
- private static exchange: AbiRegistry;
7
- private static minter: AbiRegistry;
8
- private static market: AbiRegistry;
9
- private static staking: AbiRegistry;
10
- private static p2p: AbiRegistry;
11
-
12
- public static async getMarket(): Promise<AbiRegistry> {
13
- if (!SmartContractAbis.market) {
14
- const { data } = await axios(
15
- `${'https://media.xoxno.com/'}smartcontractabi/esdt-nft-marketplace.abi.json`
16
- );
17
- const abiRegistry = AbiRegistry.create(data);
18
- SmartContractAbis.market = abiRegistry;
19
- }
20
-
21
- return SmartContractAbis.market;
22
- }
23
- public static async getManager(): Promise<AbiRegistry> {
24
- if (!SmartContractAbis.manager) {
25
- const { data } = await axios(
26
- `${'https://media.xoxno.com/'}smartcontractabi/manage.json`
27
- );
28
- const abiRegistry = AbiRegistry.create(data);
29
- SmartContractAbis.manager = abiRegistry;
30
- }
31
-
32
- return SmartContractAbis.manager;
33
- }
34
-
35
- public static async getMinter(): Promise<AbiRegistry> {
36
- if (!SmartContractAbis.minter) {
37
- const { data } = await axios(
38
- `${'https://media.xoxno.com/'}smartcontractabi/minter.json`
39
- );
40
- const abiRegistry = AbiRegistry.create(data);
41
- SmartContractAbis.minter = abiRegistry;
42
- }
43
-
44
- return SmartContractAbis.minter;
45
- }
46
-
47
- public static async getStaking(): Promise<AbiRegistry> {
48
- if (!SmartContractAbis.staking) {
49
- const { data } = await axios(
50
- `${'https://media.xoxno.com/'}smartcontractabi/staking-nfts.abi.json`
51
- );
52
- const abiRegistry = AbiRegistry.create(data);
53
- SmartContractAbis.staking = abiRegistry;
54
- }
55
-
56
- return SmartContractAbis.staking;
57
- }
58
-
59
- public static async getExchange(): Promise<AbiRegistry> {
60
- if (!SmartContractAbis.exchange) {
61
- const { data } = await axios(
62
- `${'https://media.xoxno.com/'}smartcontractabi/rs-exchange.abi.json`
63
- );
64
- const abiRegistry = AbiRegistry.create(data);
65
- SmartContractAbis.exchange = abiRegistry;
66
- }
67
-
68
- return SmartContractAbis.exchange;
69
- }
70
-
71
- public static async getP2P(): Promise<AbiRegistry> {
72
- if (!SmartContractAbis.p2p) {
73
- const { data } = await axios(
74
- `${'https://media.xoxno.com/'}smartcontractabi/p2p.abi.json`
75
- );
76
- const abiRegistry = AbiRegistry.create(data);
77
- SmartContractAbis.p2p = abiRegistry;
78
- }
79
-
80
- return SmartContractAbis.p2p;
81
- }
82
- }
@@ -1,10 +0,0 @@
1
- import { Address } from '@multiversx/sdk-core/out/address';
2
- import { SmartContract } from '@multiversx/sdk-core/out/smartcontracts/smartContract';
3
- import type { AbiRegistry } from '@multiversx/sdk-core/out/smartcontracts/typesystem/abiRegistry';
4
-
5
- export const getSmartContract = (abiRegistry: AbiRegistry, address: string) => {
6
- return new SmartContract({
7
- address: new Address(address),
8
- abi: abiRegistry,
9
- });
10
- };
package/src/utils/api.ts DELETED
@@ -1,133 +0,0 @@
1
- import axios from 'axios';
2
- import {
3
- API_URL,
4
- DR_SC,
5
- FM_SC,
6
- KG_SC,
7
- Manager_SC,
8
- Manager_SC_DEV,
9
- P2P_SC,
10
- P2P_SC_DEV,
11
- Staking_SC,
12
- Staking_SC_DEV,
13
- XOXNO_SC,
14
- XOXNO_SC_DEV,
15
- } from './const';
16
- export enum Chain {
17
- MAINNET = '1',
18
- DEVNET = 'D',
19
- }
20
- export class APIClient {
21
- private static instance: APIClient;
22
- public apiUrl: string;
23
- private apiKey: string;
24
- public chain: Chain;
25
- public config: {
26
- XO_SC: string;
27
- FM_SC: string;
28
- DR_SC: string;
29
- KG_SC: string;
30
- Staking_SC: string;
31
- Manager_SC: string;
32
- P2P_SC: string;
33
- };
34
-
35
- private constructor(apiUrl: string, apiKey: string, chain: Chain) {
36
- this.apiUrl = apiUrl;
37
- this.apiKey = apiKey;
38
- this.chain = chain;
39
- this.config =
40
- chain === Chain.MAINNET
41
- ? {
42
- XO_SC: XOXNO_SC,
43
- FM_SC: FM_SC,
44
- DR_SC,
45
- KG_SC,
46
- Staking_SC,
47
- Manager_SC,
48
- P2P_SC,
49
- }
50
- : {
51
- XO_SC: XOXNO_SC_DEV,
52
- FM_SC,
53
- DR_SC,
54
- KG_SC,
55
- Staking_SC: Staking_SC_DEV,
56
- Manager_SC: Manager_SC_DEV,
57
- P2P_SC: P2P_SC_DEV,
58
- };
59
- }
60
-
61
- public static init(
62
- apiUrl: string = API_URL,
63
- apiKey = '',
64
- chain: Chain = Chain.MAINNET
65
- ): APIClient {
66
- if (!APIClient.instance) {
67
- APIClient.instance = new APIClient(apiUrl, apiKey, chain);
68
- }
69
- return APIClient.instance;
70
- }
71
-
72
- public static getClient(): APIClient {
73
- if (!APIClient.instance) {
74
- throw new Error('APIClient has not been initialized');
75
- }
76
- return APIClient.instance;
77
- }
78
-
79
- public fetchWithTimeout = async <T>(
80
- path: string,
81
- options: Record<string, unknown> = {},
82
- timeout = 40000
83
- ): Promise<T> => {
84
- const timestamp = Math.round(new Date().getTime() / 1000);
85
-
86
- const headers = {
87
- 'Accept-Encoding': 'gzip,deflate,br',
88
- 'xo-time': `Sent-At:${timestamp}`,
89
- Referer: 'https://xoxno.sdk',
90
- 'User-Agent': 'XOXNO/1.0/SDK',
91
- ...(options.method === 'POST'
92
- ? { 'Content-Type': 'application/json' }
93
- : {}),
94
- ...((options.headers as object) ?? {}),
95
- };
96
- try {
97
- const { data } = await axios(
98
- `${this.apiUrl}${path}${
99
- options.params
100
- ? '?' +
101
- Object.keys(options.params as any)
102
- .map((key) => {
103
- return `${key}=${encodeURIComponent(
104
- (options.params as any)[key]
105
- )}`;
106
- })
107
- .join('&')
108
- : ''
109
- }`,
110
- {
111
- timeout,
112
- ...options,
113
- ...(Object.keys(headers).length ? { headers } : {}),
114
- method: (options.method as any) ?? 'GET',
115
- }
116
- );
117
-
118
- const result = data;
119
-
120
- return result as T;
121
- } catch (error) {
122
- throw new Error(
123
- 'Something went wrong inside fetchWithTimeout' +
124
- ' ' +
125
- path +
126
- ' ' +
127
- JSON.stringify(options) +
128
- ' ' +
129
- error
130
- );
131
- }
132
- };
133
- }
@@ -1,26 +0,0 @@
1
- export const API_URL = 'https://api.xoxno.com';
2
- export const API_URL_DEV = 'https://api-dev.xoxno.com';
3
-
4
- export const XOXNO_SC =
5
- 'erd1qqqqqqqqqqqqqpgq6wegs2xkypfpync8mn2sa5cmpqjlvrhwz5nqgepyg8';
6
- export const FM_SC =
7
- 'erd1qqqqqqqqqqqqqpgq705fxpfrjne0tl3ece0rrspykq88mynn4kxs2cg43s';
8
- export const DR_SC =
9
- 'erd1qqqqqqqqqqqqqpgqd9rvv2n378e27jcts8vfwynpx0gfl5ufz6hqhfy0u0';
10
- export const KG_SC =
11
- 'erd1qqqqqqqqqqqqqpgq8xwzu82v8ex3h4ayl5lsvxqxnhecpwyvwe0sf2qj4e';
12
- export const Staking_SC =
13
- 'erd1qqqqqqqqqqqqqpgqvpkd3g3uwludduv3797j54qt6c888wa59w2shntt6z';
14
- export const Manager_SC =
15
- 'erd1qqqqqqqqqqqqqpgqg9fa0dmpn8fu3fnleeqn5zt8rl8mdqjkys5s2gtas7';
16
- export const P2P_SC =
17
- 'erd1qqqqqqqqqqqqqpgq47y8hnct68v6asjv6gxem6h9rumn9frzah0skhxxt6';
18
-
19
- export const XOXNO_SC_DEV =
20
- 'erd1qqqqqqqqqqqqqpgqn4fnwl43hhchz9emdy66eh5azzhl599zd8ssxjdyh3';
21
- export const Staking_SC_DEV =
22
- 'erd1qqqqqqqqqqqqqpgqmkt2fvumf0zgum5qd0awl2l46x2pxdgmr5rswjr6r8';
23
- export const Manager_SC_DEV =
24
- 'erd1qqqqqqqqqqqqqpgq6sysl7mga393a850xemfpawaqanf4da5d8ssp3xamn';
25
- export const P2P_SC_DEV =
26
- 'erd1qqqqqqqqqqqqqpgqhuvnvkwwmucdzy3g7pvgvjumjfcgfwf69w2svch5c2';
@@ -1,55 +0,0 @@
1
- import {
2
- TradincActivityArgs,
3
- TradingActivityResponse,
4
- TradingActivityQueryFilter,
5
- } from '../types/trading';
6
- import { APIClient } from '../utils/api';
7
-
8
- /**
9
- * Fetches the trading activity of the given collections
10
- * @param args - The trading activity arguments
11
- * @param api - The API client
12
- * @returns - The trading activity response
13
- * @throws - If the top is greater than 35
14
- */
15
- export const getActivity = async (
16
- args: TradincActivityArgs,
17
- api: APIClient
18
- ): Promise<TradingActivityResponse> => {
19
- if (args.top && args.top > 35) {
20
- throw new Error('Top cannot be greater than 35');
21
- }
22
-
23
- const payloadBody: TradingActivityQueryFilter = {
24
- filters: {
25
- collection: args.collections,
26
- identifier: args.identifiers || undefined,
27
- address: args.owners || undefined,
28
- tokens: args.placedInToken || undefined,
29
- marketplace: args.marketplaces || undefined,
30
- action: args.actions || undefined,
31
- range: args.priceRange,
32
- rankRange: args.rankRange,
33
- timestampRange: args.timestampRange,
34
- attributes: args.attributes,
35
- },
36
- orderBy: args.orderBy,
37
- select: args.select,
38
- top: args.top || 35,
39
- skip: args.skip || 0,
40
- };
41
-
42
- const buffer = Buffer.from(JSON.stringify(payloadBody)).toString('base64');
43
- const response = await api.fetchWithTimeout<TradingActivityResponse>(
44
- `/getTradingActivity/${buffer}`
45
- );
46
-
47
- return {
48
- ...response,
49
- getNextPagePayload: {
50
- ...args,
51
- skip: (args.skip ?? 0) + (args.top ?? 35),
52
- },
53
- empty: response.resources.length === 0,
54
- };
55
- };
@@ -1,14 +0,0 @@
1
- export const nonceToHex = (nonce: number): string => {
2
- let nonceHex = nonce.toString(16);
3
- if (nonceHex.length % 2 !== 0) {
4
- nonceHex = '0' + nonceHex;
5
- }
6
- return nonceHex;
7
- };
8
-
9
- export const getIdentifierFromColAndNonce = (
10
- collection: string,
11
- nonce: number
12
- ): string => {
13
- return [collection, nonceToHex(nonce)].join('-');
14
- };
@@ -1,7 +0,0 @@
1
- export const isValidCollectionTicker = (ticker: string): boolean => {
2
- return /^[A-Z0-9]{3,10}-[a-z0-9]{6}$/.test(ticker);
3
- };
4
-
5
- export const isValidNftIdentifier = (identifier: string): boolean => {
6
- return /^[A-Za-z0-9]{3,10}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2,5}$/.test(identifier);
7
- };
@@ -1,47 +0,0 @@
1
- import {
2
- ContractQueryResponse,
3
- ProxyNetworkProvider,
4
- } from '@multiversx/sdk-network-providers';
5
- import { INetworkProvider } from '@multiversx/sdk-network-providers/out/interface';
6
-
7
- import { APIClient } from './api';
8
- import { ResultsParser } from '@multiversx/sdk-core/out/smartcontracts/resultsParser';
9
- import type { SmartContract } from '@multiversx/sdk-core/out/smartcontracts/smartContract';
10
- import type { Interaction } from '@multiversx/sdk-core/out/smartcontracts/interaction';
11
- import type { TypedOutcomeBundle } from '@multiversx/sdk-core/out/smartcontracts/interface';
12
-
13
- export class ContractQueryRunner {
14
- private readonly proxy: INetworkProvider;
15
- private readonly parser: ResultsParser = new ResultsParser();
16
-
17
- constructor() {
18
- const api = APIClient.getClient().apiUrl;
19
- this.proxy = new ProxyNetworkProvider(api, {
20
- timeout: 10000,
21
- });
22
- }
23
-
24
- async runQuery(
25
- contract: SmartContract,
26
- interaction: Interaction
27
- ): Promise<TypedOutcomeBundle> {
28
- try {
29
- const queryResponse: ContractQueryResponse =
30
- await this.proxy.queryContract(interaction.buildQuery());
31
-
32
- return this.parser.parseQueryResponse(
33
- queryResponse,
34
- interaction.getEndpoint()
35
- );
36
- } catch (error) {
37
- console.log(
38
- `Unexpected error when running query '${
39
- interaction.buildQuery().func
40
- }' to sc '${contract.getAddress().bech32()}' `
41
- );
42
- console.error(error);
43
-
44
- throw error;
45
- }
46
- }
47
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "CommonJS",
4
- "target": "es2015",
5
- "outDir": "dist",
6
- "lib": ["ES2015", "DOM"],
7
- "sourceMap": true,
8
- "allowJs": true,
9
- "strict": true,
10
- "strictPropertyInitialization": true,
11
- "strictNullChecks": true,
12
- "skipLibCheck": true,
13
- "noImplicitReturns": true,
14
- "noFallthroughCasesInSwitch": true,
15
- "noUnusedParameters": true,
16
- "esModuleInterop": true,
17
- "declaration": true
18
- },
19
- "include": ["src"],
20
- "exclude": [
21
- "node_modules",
22
- "dist",
23
- "**/*.test.d.ts",
24
- "**/*.test.ts",
25
- ]
26
- }
package/webpack.config.js DELETED
@@ -1,28 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- const path = require('path');
3
-
4
- module.exports = {
5
- mode: 'production',
6
- entry: './src/index.ts',
7
- output: {
8
- path: path.resolve(__dirname, 'dist'),
9
- filename: 'index.min.js',
10
- library: {
11
- name: 'XOXNO',
12
- type: 'umd',
13
- },
14
- clean: true,
15
- },
16
- resolve: {
17
- extensions: ['.ts', '.js'],
18
- },
19
- module: {
20
- rules: [
21
- {
22
- test: /\.ts$/,
23
- use: 'ts-loader',
24
- exclude: /node_modules/,
25
- },
26
- ],
27
- },
28
- };