@reyaxyz/api-sdk 0.30.6 → 0.31.0

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.
@@ -21,6 +21,7 @@ var account_1 = __importDefault(require("./modules/account"));
21
21
  var trade_simulation_1 = __importDefault(require("./modules/trade.simulation"));
22
22
  var lp_1 = __importDefault(require("./modules/lp"));
23
23
  var tokens_1 = __importDefault(require("./modules/tokens"));
24
+ var src_1 = require("@reyaxyz/common/src");
24
25
  /**
25
26
  * @description Client for API
26
27
  */
@@ -29,6 +30,10 @@ var ApiClient = /** @class */ (function () {
29
30
  this.apiEndpoint = config.environment
30
31
  ? constants_1.API_URLS[config.environment]
31
32
  : constants_1.API_URLS['test'];
33
+ ApiClient.chain =
34
+ config.environment === 'production'
35
+ ? src_1.ReyaChainId.reyaNetwork
36
+ : src_1.ReyaChainId.reyaCronos;
32
37
  ApiClient.config = __assign(__assign({}, ApiClient.config), config);
33
38
  this._markets = new markets_1.default(this.apiEndpoint);
34
39
  this._account = new account_1.default(this.apiEndpoint);
@@ -46,6 +51,16 @@ var ApiClient = /** @class */ (function () {
46
51
  }
47
52
  return ApiClient.instance;
48
53
  };
54
+ Object.defineProperty(ApiClient, "network", {
55
+ get: function () {
56
+ if (!ApiClient.chain) {
57
+ throw new Error('ApiClient is not configured');
58
+ }
59
+ return ApiClient.chain;
60
+ },
61
+ enumerable: false,
62
+ configurable: true
63
+ });
49
64
  Object.defineProperty(ApiClient, "markets", {
50
65
  /**
51
66
  * Provides access to the MarketsClient instance.
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA2E;AAC3E,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAE5C;;GAEG;AACH;IAaE,mBAAoB,MAAqB;QACvC,IAAI,CAAC,WAAW,GAAG,MAAM,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;;;WAYG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC;QACnD,CAAC;;;OAAA;IAYD,sBAAkB,eAAE;QAVpB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC;QACrC,CAAC;;;OAAA;IAYD,sBAAkB,mBAAM;QAVxB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC;QACzC,CAAC;;;OAAA;IAvGc,gBAAM,GAAkB;QACrC,WAAW,EAAE,MAAM,EAAE,gBAAgB;QACrC,OAAO,EAAE,uBAAW,EAAE,yCAAyC;KAChE,CAAC;IAqGJ,gBAAC;CAAA,AA1GD,IA0GC;AA1GY,8BAAS","sourcesContent":["import { ServiceConfig, API_TIMEOUT, API_URLS } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = {\n environment: 'test', // default value\n timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds\n };\n private readonly apiEndpoint: string;\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _trade_simulation: TradeSimulationClient;\n private readonly _tokens: TokensClient;\n\n private constructor(config: ServiceConfig) {\n this.apiEndpoint = config.environment\n ? API_URLS[config.environment]\n : API_URLS['test'];\n ApiClient.config = { ...ApiClient.config, ...config };\n this._markets = new MarketsClient(this.apiEndpoint);\n this._account = new AccountClient(this.apiEndpoint);\n this._lp = new LpClient(this.apiEndpoint);\n this._trade_simulation = new TradeSimulationClient(this._account);\n this._tokens = new TokensClient(this.apiEndpoint);\n }\n\n public static configure(config: ServiceConfig): void {\n ApiClient.config = config;\n ApiClient.instance = new ApiClient(config);\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_trade_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._trade_simulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the Tokensclient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n}\n"]}
1
+ {"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA2E;AAC3E,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAC5C,2CAAkD;AAElD;;GAEG;AACH;IAcE,mBAAoB,MAAqB;QACvC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;YACnC,CAAC,CAAC,oBAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;YAC9B,CAAC,CAAC,oBAAQ,CAAC,MAAM,CAAC,CAAC;QACrB,SAAS,CAAC,KAAK;YACb,MAAM,CAAC,WAAW,KAAK,YAAY;gBACjC,CAAC,CAAC,iBAAW,CAAC,WAAW;gBACzB,CAAC,CAAC,iBAAW,CAAC,UAAU,CAAC;QAC7B,SAAS,CAAC,MAAM,yBAAQ,SAAS,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;QACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,GAAG,GAAG,IAAI,YAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,0BAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,IAAI,gBAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAEa,mBAAS,GAAvB,UAAwB,MAAqB;QAC3C,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1B,SAAS,CAAC,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, API_URLS, ServiceConfig } from './helpers/constants';\nimport MarketsClient from './modules/markets';\nimport AccountClient from './modules/account';\nimport TradeSimulationClient from './modules/trade.simulation';\nimport LpClient from './modules/lp';\nimport TokensClient from './modules/tokens';\nimport { ReyaChainId } from '@reyaxyz/common/src';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = {\n environment: 'test', // default value\n timeout: API_TIMEOUT, // default value, e.g., 5000 milliseconds\n };\n private readonly apiEndpoint: string;\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _trade_simulation: TradeSimulationClient;\n private readonly _tokens: TokensClient;\n private static chain: ReyaChainId;\n\n private constructor(config: ServiceConfig) {\n this.apiEndpoint = config.environment\n ? API_URLS[config.environment]\n : API_URLS['test'];\n ApiClient.chain =\n config.environment === 'production'\n ? ReyaChainId.reyaNetwork\n : ReyaChainId.reyaCronos;\n ApiClient.config = { ...ApiClient.config, ...config };\n this._markets = new MarketsClient(this.apiEndpoint);\n this._account = new AccountClient(this.apiEndpoint);\n this._lp = new LpClient(this.apiEndpoint);\n this._trade_simulation = new TradeSimulationClient(this._account);\n this._tokens = new TokensClient(this.apiEndpoint);\n }\n\n public static configure(config: ServiceConfig): void {\n ApiClient.config = config;\n ApiClient.instance = new ApiClient(config);\n }\n\n private static getInstance(): ApiClient {\n if (!ApiClient.instance) {\n throw new Error(\n 'ApiClient is not configured. Please configure it before using.',\n );\n }\n return ApiClient.instance;\n }\n public static get network(): ReyaChainId {\n if (!ApiClient.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.chain;\n }\n\n /**\n * Provides access to the MarketsClient instance.\n * This getter allows for interacting with market-related API functionalities.\n *\n * @returns {MarketsClient} An instance of MarketsClient for market-related operations.\n * @memberof ApiClient\n */\n public static get markets(): MarketsClient {\n return ApiClient.getInstance()._markets;\n }\n\n /**\n * Provides access to the AccountClient instance.\n * This getter allows for interacting with account-related API functionalities.\n *\n * @returns {AccountClient} An instance of AccountClient for account-related operations.\n * @memberof ApiClient\n */\n public static get account(): AccountClient {\n return ApiClient.getInstance()._account;\n }\n\n /**\n * Provides access to the TradeSimulationClient instance.\n * This getter allows for interacting with trade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_trade_simulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TradeSimulationClient} An instance of TradeSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the trade simulation client from the ApiClient\n * const tradeSimulationClient = ApiClient.tradeSimulation;\n */\n\n public static get tradeSimulation(): TradeSimulationClient {\n return ApiClient.getInstance()._trade_simulation;\n }\n\n /**\n * Gets the current instance of the LpClient from the ApiClient.\n *\n * This static getter allows access to the LpClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LpClient directly, bypassing the need to manually access the internal `_lp` property of the ApiClient instance.\n *\n * @returns {LpClient} The LpClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and LpClient are properly set up\n * const lpClient = ApiClient.lp;\n */\n public static get lp(): LpClient {\n return ApiClient.getInstance()._lp;\n }\n\n /**\n * Gets the current instance of the TokensClient from the ApiClient.\n *\n * This static getter allows access to the Tokensclient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the TokensClient directly, bypassing the need to manually access the internal `_tokens` property of the ApiClient instance.\n *\n * @returns {TokensClient} The TokensClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and TokensClient are properly set up\n * const tokensClient = ApiClient.tokens;\n */\n public static get tokens(): TokensClient {\n return ApiClient.getInstance()._tokens;\n }\n}\n"]}
@@ -4,6 +4,7 @@ import AccountClient from './modules/account';
4
4
  import TradeSimulationClient from './modules/trade.simulation';
5
5
  import LpClient from './modules/lp';
6
6
  import TokensClient from './modules/tokens';
7
+ import { ReyaChainId } from '@reyaxyz/common/src';
7
8
  /**
8
9
  * @description Client for API
9
10
  */
@@ -16,9 +17,11 @@ export declare class ApiClient {
16
17
  private readonly _lp;
17
18
  private readonly _trade_simulation;
18
19
  private readonly _tokens;
20
+ private static chain;
19
21
  private constructor();
20
22
  static configure(config: ServiceConfig): void;
21
23
  private static getInstance;
24
+ static get network(): ReyaChainId;
22
25
  /**
23
26
  * Provides access to the MarketsClient instance.
24
27
  * This getter allows for interacting with market-related API functionalities.
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAY;IACnC,OAAO,CAAC,MAAM,CAAC,MAAM,CAGnB;IACF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAW;IAC/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC,OAAO;WAYO,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAKpD,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;IAED;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;IAED;;;;;;;;;;;;OAYG;IAEH,WAAkB,eAAe,IAAI,qBAAqB,CAEzD;IAED;;;;;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;;;;;;;;OASG;IACH,WAAkB,EAAE,IAAI,QAAQ,CAE/B;IAED;;;;;;;;;OASG;IACH,WAAkB,MAAM,IAAI,YAAY,CAEvC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/api-sdk",
3
- "version": "0.30.6",
3
+ "version": "0.31.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -33,10 +33,10 @@
33
33
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
34
34
  },
35
35
  "dependencies": {
36
- "@reyaxyz/common": "0.3.0",
36
+ "@reyaxyz/common": "0.4.0",
37
37
  "axios": "^1.6.2",
38
38
  "bignumber.js": "^9.1.2"
39
39
  },
40
40
  "packageManager": "pnpm@8.10.4",
41
- "gitHead": "037cbc040faa91d6148afb21e36a739a017cef89"
41
+ "gitHead": "97ba4c6bdb6da053613cdc311179c442a8dbb487"
42
42
  }
@@ -1,9 +1,10 @@
1
- import { ServiceConfig, API_TIMEOUT, API_URLS } from './helpers/constants';
1
+ import { API_TIMEOUT, API_URLS, ServiceConfig } from './helpers/constants';
2
2
  import MarketsClient from './modules/markets';
3
3
  import AccountClient from './modules/account';
4
4
  import TradeSimulationClient from './modules/trade.simulation';
5
5
  import LpClient from './modules/lp';
6
6
  import TokensClient from './modules/tokens';
7
+ import { ReyaChainId } from '@reyaxyz/common/src';
7
8
 
8
9
  /**
9
10
  * @description Client for API
@@ -20,11 +21,16 @@ export class ApiClient {
20
21
  private readonly _lp: LpClient;
21
22
  private readonly _trade_simulation: TradeSimulationClient;
22
23
  private readonly _tokens: TokensClient;
24
+ private static chain: ReyaChainId;
23
25
 
24
26
  private constructor(config: ServiceConfig) {
25
27
  this.apiEndpoint = config.environment
26
28
  ? API_URLS[config.environment]
27
29
  : API_URLS['test'];
30
+ ApiClient.chain =
31
+ config.environment === 'production'
32
+ ? ReyaChainId.reyaNetwork
33
+ : ReyaChainId.reyaCronos;
28
34
  ApiClient.config = { ...ApiClient.config, ...config };
29
35
  this._markets = new MarketsClient(this.apiEndpoint);
30
36
  this._account = new AccountClient(this.apiEndpoint);
@@ -46,6 +52,12 @@ export class ApiClient {
46
52
  }
47
53
  return ApiClient.instance;
48
54
  }
55
+ public static get network(): ReyaChainId {
56
+ if (!ApiClient.chain) {
57
+ throw new Error('ApiClient is not configured');
58
+ }
59
+ return ApiClient.chain;
60
+ }
49
61
 
50
62
  /**
51
63
  * Provides access to the MarketsClient instance.