@reyaxyz/api-sdk 0.150.21 → 0.151.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.
- package/README.md +1 -1
- package/dist/clients/api-client.js +2 -3
- package/dist/clients/api-client.js.map +1 -1
- package/dist/clients/modules/lottery/constants.js +8 -4
- package/dist/clients/modules/lottery/constants.js.map +1 -1
- package/dist/clients/socket-client.js +1 -1
- package/dist/clients/socket-client.js.map +1 -1
- package/dist/types/clients/api-client.d.ts.map +1 -1
- package/dist/types/clients/modules/lottery/constants.d.ts.map +1 -1
- package/dist/types/clients/socket-client.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/clients/api-client.ts +3 -4
- package/src/clients/modules/lottery/constants.ts +8 -4
- package/src/clients/socket-client.ts +2 -4
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |  |
|
|
10
10
|
|
|
@@ -58,8 +58,7 @@ var ApiClient = /** @class */ (function () {
|
|
|
58
58
|
this._auth = new auth_1.default(ApiClient.config.apiEndpoint);
|
|
59
59
|
}
|
|
60
60
|
ApiClient.configure = function (environment) {
|
|
61
|
-
ApiClient.config =
|
|
62
|
-
common_1.API_CLIENT_CONFIGS[environment] || common_1.API_CLIENT_CONFIGS['test'];
|
|
61
|
+
ApiClient.config = (0, common_1.getApiClientConfig)(environment);
|
|
63
62
|
ApiClient.instance = new ApiClient();
|
|
64
63
|
};
|
|
65
64
|
ApiClient.getInstance = function () {
|
|
@@ -448,7 +447,7 @@ var ApiClient = /** @class */ (function () {
|
|
|
448
447
|
enumerable: false,
|
|
449
448
|
configurable: true
|
|
450
449
|
});
|
|
451
|
-
ApiClient.config = common_1.
|
|
450
|
+
ApiClient.config = (0, common_1.getApiClientConfig)('test');
|
|
452
451
|
return ApiClient;
|
|
453
452
|
}());
|
|
454
453
|
exports.ApiClient = ApiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AACzB,8DAA8C;AAC9C,8DAA8C;AAC9C,gFAA+D;AAC/D,oDAAoC;AACpC,4DAA4C;AAC5C,0DAA0C;AAC1C,oGAAkF;AAClF,4GAAyF;AACzF,kGAA+E;AAC/E,8GAA2F;AAC3F,4FAA0E;AAC1E,gHAA6F;AAC7F,4HAAwG;AACxG,sGAAmF;AACnF,4FAA0E;AAC1E,wEAAuD;AACvD,kGAAgF;AAChF,oFAAmE;AACnE,8DAA8C;AAC9C,gEAAgD;AAChD,wDAAwC;AACxC,oEAAmD;AAEnD;;GAEG;AACH;IA0BE;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,GAAG,GAAG,IAAI,YAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACtD,IAAI,CAAC,gBAAgB,GAAG,IAAI,0BAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjE,IAAI,CAAC,wBAAwB,GAAG,IAAI,mCAA6B,CAC/D,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,IAAI,sBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChE,IAAI,CAAC,yBAAyB,GAAG,IAAI,oCAA8B,CACjE,SAAS,CAAC,OAAO,EACjB,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,IAAI,CAAC,4BAA4B,GAAG,IAAI,wCAAiC,CACvE,IAAI,CAAC,yBAAyB,EAC9B,SAAS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CAAA,AAlaD,IAkaC;AAlaY,8BAAS","sourcesContent":["import {\n API_CLIENT_CONFIGS,\n ServiceConfig,\n ReyaChainId,\n} from '@reyaxyz/common';\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 OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport WithdrawPassivePoolSimulationClient from './modules/withdraw-passive-pool.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\nimport DepthChartSimulationClient from './modules/depth-chart.simulation';\nimport FundingRateClient from './modules/funding-rate';\nimport IsolatedOrderSimulationClient from './modules/isolated-order.simulation';\nimport ConditionalOrdersClient from './modules/conditional-orders';\nimport LotteryClient from './modules/lottery';\nimport ReferralClient from './modules/referral';\nimport AuthClient from './modules/auth';\nimport RageTradeClient from './modules/rage-trade';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = API_CLIENT_CONFIGS['test'];\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _tradeSimulation: TradeSimulationClient;\n private readonly _fundingRateHistory: FundingRateClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _depositPassivePoolSimulation: DepositPassivePoolSimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _withdrawPassivePoolSimulation: WithdrawPassivePoolSimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _depthSimulation: DepthChartSimulationClient;\n private readonly _isolatedOrderSimulation: IsolatedOrderSimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n private readonly _conditionalOrders: ConditionalOrdersClient;\n private readonly _lottery: LotteryClient;\n private readonly _referral: ReferralClient;\n private readonly _rageTrade: RageTradeClient;\n private readonly _auth: AuthClient;\n\n private constructor() {\n this._markets = new MarketsClient(ApiClient.config.apiEndpoint);\n this._account = new AccountClient(ApiClient.config.apiEndpoint);\n this._lp = new LpClient(ApiClient.config.apiEndpoint);\n this._tradeSimulation = new TradeSimulationClient(this._account);\n this._isolatedOrderSimulation = new IsolatedOrderSimulationClient(\n this._account,\n );\n this._fundingRateHistory = new FundingRateClient(this._markets);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.apiEndpoint,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(\n ApiClient.config.apiEndpoint,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._withdrawPassivePoolSimulation =\n new WithdrawPassivePoolSimulationClient(\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n\n this._depthSimulation = new DepthChartSimulationClient(this._lp);\n this._tokens = new TokensClient(ApiClient.config.apiEndpoint);\n this._owner = new OwnerClient(ApiClient.config.apiEndpoint);\n this._conditionalOrders = new ConditionalOrdersClient(\n ApiClient.network,\n ApiClient.config.apiEndpoint,\n );\n this._lottery = new LotteryClient(\n ApiClient.config.environment,\n ApiClient.config.apiEndpoint,\n );\n this._referral = new ReferralClient(ApiClient.config.apiEndpoint);\n this._rageTrade = new RageTradeClient(ApiClient.config.apiEndpoint);\n this._auth = new AuthClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config =\n API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];\n ApiClient.instance = new ApiClient();\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.config.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.config.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 `_tradeSimulation` 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()._tradeSimulation;\n }\n\n /**\n * Provides access to the IsolatedOrderSimulationClient instance.\n * This getter allows for interacting with isolatedTrade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_isolatedTradeSimulation` property, ensuring that isolatedTrade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {IsolatedOrderSimulationClient} An instance of IsolatedOrderSimulationClient for isolatedTrade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the isolatedTrade simulation client from the ApiClient\n * const isolatedTradeSimulationClient = ApiClient.isolatedTradeSimulation;\n */\n public static get isolatedSimulation(): IsolatedOrderSimulationClient {\n return ApiClient.getInstance()._isolatedOrderSimulation;\n }\n\n public static get fundingRateHistory(): FundingRateClient {\n return ApiClient.getInstance()._fundingRateHistory;\n }\n\n /**\n * Retrieves the DepthChartSimulationClient instance used for depth simulation.\n * This method provides access to the depth simulation client through the ApiClient.\n * @returns {DepthChartSimulationClient} The DepthChartSimulationClient instance.\n * @static\n * @public\n */\n public static get depthSimulation(): DepthChartSimulationClient {\n return ApiClient.getInstance()._depthSimulation;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._editCollateralSimulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient 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 `_depositExistingMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._depositExistingMASimulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient 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 `_depositNewMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._depositNewMASimulation;\n }\n\n /**\n * Provides access to the DepositPassivePoolSimulationClient 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 `_depositPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;\n */\n\n public static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient {\n return ApiClient.getInstance()._depositPassivePoolSimulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient 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 `_withdrawMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithdrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdrawMASimulation;\n }\n\n /**\n * Provides access to the WithdrawPassivePoolSimulationClient 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 `_withdrawPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawPassivePoolSimulationClient} An instance of WithdrawPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawPassivePoolSimulationClient = ApiClient.withdrawPassivePoolSimulation;\n */\n\n public static get withdrawPassivePoolSimulation(): WithdrawPassivePoolSimulationClient {\n return ApiClient.getInstance()._withdrawPassivePoolSimulation;\n }\n\n /**\n * Provides access to the TransferMarginBetweenMAsSimulationClient 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 `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient 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 `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\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 /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n\n /**\n * Gets the current instance of the ConditionalOrdersClient from the ApiClient.\n *\n * This static getter allows access to the ConditionalOrdersClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ConditionalOrdersClient directly, bypassing the need to manually access the internal `_conditionalOrders` property of the ApiClient instance.\n *\n * @returns {ConditionalOrdersClient} The ConditionalOrdersClient instance currently held by the ApiClient.\n */\n public static get conditionalOrders(): ConditionalOrdersClient {\n return ApiClient.getInstance()._conditionalOrders;\n }\n\n /**\n * Gets the current instance of the LotteryClient from the ApiClient.\n *\n * This static getter allows access to the LotteryClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LotteryClient directly, bypassing the need to manually access the internal `_lottery` property of the ApiClient instance.\n *\n * @returns {LotteryClient} The LotteryClient instance currently held by the ApiClient.\n */\n public static get lottery(): LotteryClient {\n return ApiClient.getInstance()._lottery;\n }\n\n /**\n * Gets the current instance of the ReferralClient from the ApiClient.\n *\n * This static getter allows access to the ReferralClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ReferralClient directly, bypassing the need to manually access the internal `_referral` property of the ApiClient instance.\n *\n * @returns {ReferralClient} The ReferralClient instance currently held by the ApiClient.\n */\n public static get referral(): ReferralClient {\n return ApiClient.getInstance()._referral;\n }\n\n /**\n * Gets the current instance of the RageTradeClient from the ApiClient.\n *\n * This static getter allows access to the RageTradeClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the RageTradeClient directly, bypassing the need to manually access the internal `_rageTrade` property of the ApiClient instance.\n *\n * @returns {RageTradeClient} The RageTradeClient instance currently held by the ApiClient.\n */\n\n public static get rageTrade(): RageTradeClient {\n return ApiClient.getInstance()._rageTrade;\n }\n\n /**\n * Gets the current instance of the AuthClient from the ApiClient.\n *\n * This static getter allows access to the AuthClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the AuthClient directly, bypassing the need to manually access the internal `_auth` property of the ApiClient instance.\n *\n * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.\n */\n public static get auth(): AuthClient {\n return ApiClient.getInstance()._auth;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,0CAIyB;AACzB,8DAA8C;AAC9C,8DAA8C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,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;IAYD,sBAAkB,kBAAK;QAVvB;;;;;;;;;WASG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC;QACxC,CAAC;;;OAAA;IASD,sBAAkB,8BAAiB;QAPnC;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,kBAAkB,CAAC;QACpD,CAAC;;;OAAA;IASD,sBAAkB,oBAAO;QAPzB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAC1C,CAAC;;;OAAA;IASD,sBAAkB,qBAAQ;QAP1B;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC;QAC3C,CAAC;;;OAAA;IAUD,sBAAkB,sBAAS;QAR3B;;;;;;WAMG;aAEH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC;QAC5C,CAAC;;;OAAA;IASD,sBAAkB,iBAAI;QAPtB;;;;;;WAMG;aACH;YACE,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC;QACvC,CAAC;;;OAAA;IA9Zc,gBAAM,GAAkB,IAAA,2BAAkB,EAAC,MAAM,CAAC,CAAC;IA+ZpE,gBAAC;CAAA,AAjaD,IAiaC;AAjaY,8BAAS","sourcesContent":["import {\n ServiceConfig,\n ReyaChainId,\n getApiClientConfig,\n} from '@reyaxyz/common';\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 OwnerClient from './modules/owner';\nimport EditCollateralSimulationClient from './modules/edit-collateral.simulation';\nimport DepositExistingMASimulationClient from './modules/deposit-existing-MA.simulation';\nimport DepositNewMASimulationClient from './modules/deposit-new-MA.simulation';\nimport DepositPassivePoolSimulationClient from './modules/deposit-passive-pool.simulation';\nimport WithdrawMASimulationClient from './modules/withdraw-MA.simulation';\nimport WithdrawPassivePoolSimulationClient from './modules/withdraw-passive-pool.simulation';\nimport TransferMarginBetweenMAsSimulationClient from './modules/transfer-margin-between-MAs.simulation';\nimport TransferMAPoolSimulationClient from './modules/transfer-MA-Pool.simulation';\nimport DepthChartSimulationClient from './modules/depth-chart.simulation';\nimport FundingRateClient from './modules/funding-rate';\nimport IsolatedOrderSimulationClient from './modules/isolated-order.simulation';\nimport ConditionalOrdersClient from './modules/conditional-orders';\nimport LotteryClient from './modules/lottery';\nimport ReferralClient from './modules/referral';\nimport AuthClient from './modules/auth';\nimport RageTradeClient from './modules/rage-trade';\n\n/**\n * @description Client for API\n */\nexport class ApiClient {\n private static instance: ApiClient;\n private static config: ServiceConfig = getApiClientConfig('test');\n private readonly _markets: MarketsClient;\n private readonly _account: AccountClient;\n private readonly _lp: LpClient;\n private readonly _tradeSimulation: TradeSimulationClient;\n private readonly _fundingRateHistory: FundingRateClient;\n private readonly _editCollateralSimulation: EditCollateralSimulationClient;\n private readonly _depositExistingMASimulation: DepositExistingMASimulationClient;\n private readonly _depositNewMASimulation: DepositNewMASimulationClient;\n private readonly _depositPassivePoolSimulation: DepositPassivePoolSimulationClient;\n private readonly _withdrawMASimulation: WithdrawMASimulationClient;\n private readonly _withdrawPassivePoolSimulation: WithdrawPassivePoolSimulationClient;\n private readonly _transferMarginBetweenMAsSimulation: TransferMarginBetweenMAsSimulationClient;\n private readonly _transferMAPoolSimulation: TransferMAPoolSimulationClient;\n private readonly _depthSimulation: DepthChartSimulationClient;\n private readonly _isolatedOrderSimulation: IsolatedOrderSimulationClient;\n private readonly _tokens: TokensClient;\n private readonly _owner: OwnerClient;\n private readonly _conditionalOrders: ConditionalOrdersClient;\n private readonly _lottery: LotteryClient;\n private readonly _referral: ReferralClient;\n private readonly _rageTrade: RageTradeClient;\n private readonly _auth: AuthClient;\n\n private constructor() {\n this._markets = new MarketsClient(ApiClient.config.apiEndpoint);\n this._account = new AccountClient(ApiClient.config.apiEndpoint);\n this._lp = new LpClient(ApiClient.config.apiEndpoint);\n this._tradeSimulation = new TradeSimulationClient(this._account);\n this._isolatedOrderSimulation = new IsolatedOrderSimulationClient(\n this._account,\n );\n this._fundingRateHistory = new FundingRateClient(this._markets);\n this._editCollateralSimulation = new EditCollateralSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._depositExistingMASimulation = new DepositExistingMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.apiEndpoint,\n );\n this._depositNewMASimulation = new DepositNewMASimulationClient(\n this._depositExistingMASimulation,\n );\n this._depositPassivePoolSimulation = new DepositPassivePoolSimulationClient(\n ApiClient.config.apiEndpoint,\n );\n this._withdrawMASimulation = new WithdrawMASimulationClient(\n this._editCollateralSimulation,\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._withdrawPassivePoolSimulation =\n new WithdrawPassivePoolSimulationClient(\n ApiClient.config.chain,\n ApiClient.config.apiEndpoint,\n );\n this._transferMarginBetweenMAsSimulation =\n new TransferMarginBetweenMAsSimulationClient(\n ApiClient.network,\n this._account,\n );\n this._transferMAPoolSimulation = new TransferMAPoolSimulationClient(\n this._editCollateralSimulation,\n );\n\n this._depthSimulation = new DepthChartSimulationClient(this._lp);\n this._tokens = new TokensClient(ApiClient.config.apiEndpoint);\n this._owner = new OwnerClient(ApiClient.config.apiEndpoint);\n this._conditionalOrders = new ConditionalOrdersClient(\n ApiClient.network,\n ApiClient.config.apiEndpoint,\n );\n this._lottery = new LotteryClient(\n ApiClient.config.environment,\n ApiClient.config.apiEndpoint,\n );\n this._referral = new ReferralClient(ApiClient.config.apiEndpoint);\n this._rageTrade = new RageTradeClient(ApiClient.config.apiEndpoint);\n this._auth = new AuthClient(ApiClient.config.apiEndpoint);\n }\n\n public static configure(environment: ServiceConfig['environment']): void {\n ApiClient.config = getApiClientConfig(environment);\n ApiClient.instance = new ApiClient();\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.config.chain) {\n throw new Error('ApiClient is not configured');\n }\n return ApiClient.config.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 `_tradeSimulation` 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()._tradeSimulation;\n }\n\n /**\n * Provides access to the IsolatedOrderSimulationClient instance.\n * This getter allows for interacting with isolatedTrade simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_isolatedTradeSimulation` property, ensuring that isolatedTrade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {IsolatedOrderSimulationClient} An instance of IsolatedOrderSimulationClient for isolatedTrade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the isolatedTrade simulation client from the ApiClient\n * const isolatedTradeSimulationClient = ApiClient.isolatedTradeSimulation;\n */\n public static get isolatedSimulation(): IsolatedOrderSimulationClient {\n return ApiClient.getInstance()._isolatedOrderSimulation;\n }\n\n public static get fundingRateHistory(): FundingRateClient {\n return ApiClient.getInstance()._fundingRateHistory;\n }\n\n /**\n * Retrieves the DepthChartSimulationClient instance used for depth simulation.\n * This method provides access to the depth simulation client through the ApiClient.\n * @returns {DepthChartSimulationClient} The DepthChartSimulationClient instance.\n * @static\n * @public\n */\n public static get depthSimulation(): DepthChartSimulationClient {\n return ApiClient.getInstance()._depthSimulation;\n }\n\n /**\n * Provides access to the EditCollateralSimulationClient instance.\n * This getter allows for interacting with edit collateral simulation functionalities.\n * It ensures a singleton pattern by fetching the instance from the ApiClient's\n * private `_editCollateralSimulation` property, ensuring that edit collateral simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {EditCollateralSimulationClient} An instance of EditCollateralSimulationClient for edit collateral simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the edit collateral simulation client from the ApiClient\n * const editCollateralSimulationClient = ApiClient.editCollateralSimulation;\n */\n\n public static get editCollateralSimulationClient(): EditCollateralSimulationClient {\n return ApiClient.getInstance()._editCollateralSimulation;\n }\n\n /**\n * Provides access to the DepositExistingMASimulationClient 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 `_depositExistingMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositExistingMASimulationClient} An instance of DepositExistingMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositExistingMASimulationClient = ApiClient.depositExistingMASimulation;\n */\n\n public static get depositExistingMASimulation(): DepositExistingMASimulationClient {\n return ApiClient.getInstance()._depositExistingMASimulation;\n }\n\n /**\n * Provides access to the DepositNewMASimulationClient 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 `_depositNewMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositNewMASimulationClient} An instance of DepositNewMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit new MA simulation client from the ApiClient\n * const depositNewMASimulationClient = ApiClient.depositNewMASimulation;\n */\n\n public static get depositNewMASimulation(): DepositNewMASimulationClient {\n return ApiClient.getInstance()._depositNewMASimulation;\n }\n\n /**\n * Provides access to the DepositPassivePoolSimulationClient 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 `_depositPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {DepositPassivePoolSimulationClient} An instance of DepositPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the deposit existing Ma simulation client from the ApiClient\n * const depositPassivePoolSimulationClient = ApiClient.depositPassivePoolSimulation;\n */\n\n public static get depositPassivePoolSimulation(): DepositPassivePoolSimulationClient {\n return ApiClient.getInstance()._depositPassivePoolSimulation;\n }\n\n /**\n * Provides access to the WithdrawMASimulationClient 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 `_withdrawMASimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawMASimulationClient} An instance of WithdrawMASimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawMASimulationClient = ApiClient.withdrawMASimulation;\n */\n\n public static get withdrawMASimulation(): WithdrawMASimulationClient {\n return ApiClient.getInstance()._withdrawMASimulation;\n }\n\n /**\n * Provides access to the WithdrawPassivePoolSimulationClient 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 `_withdrawPassivePoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {WithdrawPassivePoolSimulationClient} An instance of WithdrawPassivePoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the withdraw MA simulation client from the ApiClient\n * const withdrawPassivePoolSimulationClient = ApiClient.withdrawPassivePoolSimulation;\n */\n\n public static get withdrawPassivePoolSimulation(): WithdrawPassivePoolSimulationClient {\n return ApiClient.getInstance()._withdrawPassivePoolSimulation;\n }\n\n /**\n * Provides access to the TransferMarginBetweenMAsSimulationClient 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 `_transferMarginBetweenMAsSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMarginBetweenMAsSimulationClient} An instance of TransferMarginBetweenMAsSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer margin between MAs simulation client from the ApiClient\n * const transferMarginBetweenMAsSimulationClient = ApiClient.transferMarginBetweenMAsSimulation;\n */\n\n public static get transferMarginBetweenMAsSimulation(): TransferMarginBetweenMAsSimulationClient {\n return ApiClient.getInstance()._transferMarginBetweenMAsSimulation;\n }\n\n /**\n * Provides access to the TransferMAPoolSimulationClient 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 `_TransferMAPoolSimulation` property, ensuring that trade simulation operations\n * use a consistent client configuration and state.\n *\n * @returns {TransferMAPoolSimulationClient} An instance of TransferMAPoolSimulationClient for trade simulation operations.\n * @memberof ApiClient\n * @example\n * // Access the transfer from MA to Pool simulation client from the ApiClient\n * const transferMAPoolSimulationClient = ApiClient.transferMAPoolSimulation;\n */\n\n public static get transferMAPoolSimulation(): TransferMAPoolSimulationClient {\n return ApiClient.getInstance()._transferMAPoolSimulation;\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 /**\n * Gets the current instance of the OwnerClient from the ApiClient.\n *\n * This static getter allows access to the OwnerClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the OwnerClient directly, bypassing the need to manually access the internal `_owner` property of the ApiClient instance.\n *\n * @returns {OwnerClient} The OwnerClient instance currently held by the ApiClient.\n * @example\n * // Assuming ApiClient and OwnerClient are properly set up\n * const ownerClient = ApiClient.tokens;\n */\n public static get owner(): OwnerClient {\n return ApiClient.getInstance()._owner;\n }\n\n /**\n * Gets the current instance of the ConditionalOrdersClient from the ApiClient.\n *\n * This static getter allows access to the ConditionalOrdersClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ConditionalOrdersClient directly, bypassing the need to manually access the internal `_conditionalOrders` property of the ApiClient instance.\n *\n * @returns {ConditionalOrdersClient} The ConditionalOrdersClient instance currently held by the ApiClient.\n */\n public static get conditionalOrders(): ConditionalOrdersClient {\n return ApiClient.getInstance()._conditionalOrders;\n }\n\n /**\n * Gets the current instance of the LotteryClient from the ApiClient.\n *\n * This static getter allows access to the LotteryClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the LotteryClient directly, bypassing the need to manually access the internal `_lottery` property of the ApiClient instance.\n *\n * @returns {LotteryClient} The LotteryClient instance currently held by the ApiClient.\n */\n public static get lottery(): LotteryClient {\n return ApiClient.getInstance()._lottery;\n }\n\n /**\n * Gets the current instance of the ReferralClient from the ApiClient.\n *\n * This static getter allows access to the ReferralClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the ReferralClient directly, bypassing the need to manually access the internal `_referral` property of the ApiClient instance.\n *\n * @returns {ReferralClient} The ReferralClient instance currently held by the ApiClient.\n */\n public static get referral(): ReferralClient {\n return ApiClient.getInstance()._referral;\n }\n\n /**\n * Gets the current instance of the RageTradeClient from the ApiClient.\n *\n * This static getter allows access to the RageTradeClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the RageTradeClient directly, bypassing the need to manually access the internal `_rageTrade` property of the ApiClient instance.\n *\n * @returns {RageTradeClient} The RageTradeClient instance currently held by the ApiClient.\n */\n\n public static get rageTrade(): RageTradeClient {\n return ApiClient.getInstance()._rageTrade;\n }\n\n /**\n * Gets the current instance of the AuthClient from the ApiClient.\n *\n * This static getter allows access to the AuthClient instance managed within the ApiClient's singleton instance. It is a convenience method for retrieving the AuthClient directly, bypassing the need to manually access the internal `_auth` property of the ApiClient instance.\n *\n * @returns {AuthClient} The AuthClient instance currently held by the ApiClient.\n */\n public static get auth(): AuthClient {\n return ApiClient.getInstance()._auth;\n }\n}\n"]}
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LOTTERY_CONFIGS = void 0;
|
|
4
4
|
exports.LOTTERY_CONFIGS = {
|
|
5
|
-
local: {
|
|
6
|
-
address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
7
|
-
marginAccountId: 6888,
|
|
8
|
-
},
|
|
9
5
|
production: {
|
|
10
6
|
address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
11
7
|
marginAccountId: 20092,
|
|
@@ -14,9 +10,17 @@ exports.LOTTERY_CONFIGS = {
|
|
|
14
10
|
address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
15
11
|
marginAccountId: 20092,
|
|
16
12
|
},
|
|
13
|
+
localmainnet: {
|
|
14
|
+
address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
15
|
+
marginAccountId: 20092,
|
|
16
|
+
},
|
|
17
17
|
test: {
|
|
18
18
|
address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
19
19
|
marginAccountId: 6888,
|
|
20
20
|
},
|
|
21
|
+
localtestnet: {
|
|
22
|
+
address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
23
|
+
marginAccountId: 6888,
|
|
24
|
+
},
|
|
21
25
|
};
|
|
22
26
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/modules/lottery/constants.ts"],"names":[],"mappings":";;;AAOa,QAAA,eAAe,GAA8C;IACxE,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"/","sources":["clients/modules/lottery/constants.ts"],"names":[],"mappings":";;;AAOa,QAAA,eAAe,GAA8C;IACxE,UAAU,EAAE;QACV,OAAO,EAAE,4CAA4C;QACrD,eAAe,EAAE,KAAK;KACvB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,4CAA4C;QACrD,eAAe,EAAE,KAAK;KACvB;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,4CAA4C;QACrD,eAAe,EAAE,KAAK;KACvB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,4CAA4C;QACrD,eAAe,EAAE,IAAI;KACtB;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,4CAA4C;QACrD,eAAe,EAAE,IAAI;KACtB;CACF,CAAC","sourcesContent":["import { MarginAccountEntity, ServiceEnvironment } from '@reyaxyz/common';\n\ntype LotteryConfig = {\n address: string;\n marginAccountId: MarginAccountEntity['id'];\n};\n\nexport const LOTTERY_CONFIGS: Record<ServiceEnvironment, LotteryConfig> = {\n production: {\n address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',\n marginAccountId: 20092,\n },\n staging: {\n address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',\n marginAccountId: 20092,\n },\n localmainnet: {\n address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',\n marginAccountId: 20092,\n },\n test: {\n address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',\n marginAccountId: 6888,\n },\n localtestnet: {\n address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',\n marginAccountId: 6888,\n },\n};\n"]}
|
|
@@ -57,7 +57,7 @@ var SocketClient = /** @class */ (function () {
|
|
|
57
57
|
this.onOpenCallback = config.onOpen;
|
|
58
58
|
this.onCloseCallback = config.onClose;
|
|
59
59
|
this.onMessageCallback = config.onMessage;
|
|
60
|
-
this.url = (common_1.
|
|
60
|
+
this.url = (0, common_1.getApiClientConfig)(config.environment).webSocketEndpoint;
|
|
61
61
|
}
|
|
62
62
|
SocketClient.prototype.connect = function () {
|
|
63
63
|
this.ws = new isomorphic_ws_1.default(this.url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-client.js","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gEAAwD;AAExD,0CAOyB;AAEzB,IAAK,oBAIJ;AAJD,WAAK,oBAAoB;IACvB,qCAAa,CAAA;IACb,+CAAuB,CAAA;IACvB,mDAA2B,CAAA;AAC7B,CAAC,EAJI,oBAAoB,KAApB,oBAAoB,QAIxB;AAED,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,iDAA+B,CAAA;IAC/B,qDAAmC,CAAA;IACnC,+CAA6B,CAAA;AAC/B,CAAC,EANW,cAAc,8BAAd,cAAc,QAMzB;AAED,IAAY,oB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OAAO,GAAG,cAAc,CAAC,eAAe,CAAC;QAC/C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,GAAG;SACR,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IACH,mBAAC;AAAD,CAAC,AAvQD,IAuQC;AAvQY,oCAAY","sourcesContent":["import WebSocket, { MessageEvent } from 'isomorphic-ws';\n\nimport {\n API_CLIENT_CONFIGS,\n Candle,\n CandlesResolution,\n MarketEntity,\n ServiceConfig,\n StorkSignedPayload,\n} from '@reyaxyz/common';\n\nenum OutgoingMessageTypes {\n PING = 'ping',\n SUBSCRIBE = 'subscribe',\n UNSUBSCRIBE = 'unsubscribe',\n}\n\nexport enum SocketChannels {\n CANDLES = 'candles',\n PRICES = 'prices',\n FUNDING_RATES = 'funding-rates',\n MARKETS_UPDATES = 'markets-updates',\n SPOT_CANDLES = 'spot-candles',\n}\n\nexport enum IncomingMessageTypes {\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n ERROR = 'error',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport enum OutgoingMessageType {\n ERROR = 'error',\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n UNSUBSCRIBED = 'unsubscribed',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport interface OutgoingMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n}\nexport interface SocketMessage {\n message_id: number;\n connection_id: string;\n type: OutgoingMessageType;\n channel?: SocketChannels;\n contents?: unknown;\n id?: string;\n}\n\nexport interface CandleMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.CANDLES;\n id: string;\n contents: {\n candles: Candle[];\n };\n}\n\nexport interface PricesMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.PRICES;\n id: string;\n contents: {\n signedPrice: StorkSignedPayload;\n poolPrice: string;\n spotPrice: string;\n marketId: number | null;\n assetPairId: string;\n };\n}\n\nexport interface MarketsUpdateMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.MARKETS_UPDATES;\n id: string;\n contents: MarketEntity[];\n}\n\nexport interface FundingRateMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.FUNDING_RATES;\n id: string;\n contents: { timestamp: number; value: string; assetsPair: string };\n}\n\nexport interface SocketClientConfig {\n environment: ServiceConfig['environment'];\n onOpen: () => void;\n onClose: () => void;\n onMessage: (event: SocketMessage) => void;\n}\n\nexport class SocketClient {\n private url: string;\n private ws?: WebSocket;\n private onOpenCallback?: () => void;\n private onCloseCallback?: () => void;\n private onMessageCallback?: (event: SocketMessage) => void;\n private pingInterval: number = 30_000;\n private lastMessageTime: number = Date.now();\n private pingIntervalId?: NodeJS.Timeout;\n constructor(config: SocketClientConfig) {\n this.onOpenCallback = config.onOpen;\n this.onCloseCallback = config.onClose;\n this.onMessageCallback = config.onMessage;\n this.url = (\n API_CLIENT_CONFIGS[config.environment] || API_CLIENT_CONFIGS['test']\n ).webSocketEndpoint;\n }\n\n connect(): void {\n this.ws = new WebSocket(this.url);\n this.ws.addEventListener('open', this.handleOpen.bind(this));\n this.ws.addEventListener('close', this.handleClose.bind(this));\n this.ws.addEventListener('message', this.handleMessage.bind(this));\n }\n\n /**\n * @description Close the websocket connection.\n *\n */\n close(): void {\n this.ws?.close();\n this.ws = undefined;\n }\n\n /**\n * @description Send data to the websocket connection.\n *\n */\n send(data: string): void {\n this.ws?.send(data);\n }\n\n private handleOpen(): void {\n if (this.onOpenCallback) {\n this.onOpenCallback();\n }\n this.restartPingInterval();\n }\n\n private handleClose(): void {\n if (this.onCloseCallback) {\n this.onCloseCallback();\n }\n clearInterval(this.pingIntervalId);\n }\n\n private handleMessage(event: MessageEvent): void {\n if (event.data === 'PING') {\n this.send('PONG');\n } else {\n this.lastMessageTime = Date.now();\n try {\n const parsedMessage: SocketMessage = JSON.parse(event.data as string);\n if (typeof this.onMessageCallback === 'function') {\n this.onMessageCallback(parsedMessage);\n }\n } catch (error) {\n console.error('Error parsing message', error);\n }\n }\n this.restartPingInterval();\n }\n\n private restartPingInterval(): void {\n clearInterval(this.pingIntervalId);\n this.pingIntervalId = setInterval(() => {\n const elapsedTime = Date.now() - this.lastMessageTime;\n if (elapsedTime > this.pingInterval) {\n const message = {\n type: OutgoingMessageTypes.PING,\n };\n this.send(JSON.stringify(message));\n }\n }, this.pingInterval);\n }\n\n /**\n * @description Set callback when the socket is opened.\n *\n */\n set onOpen(callback: () => void) {\n this.onOpenCallback = callback;\n }\n\n /**\n * @description Set callback when the socket is closed.\n *\n */\n set onClose(callback: () => void) {\n this.onCloseCallback = callback;\n }\n\n /**\n * @description Set callback when the socket receives a message.\n *\n */\n set onMessage(callback: (event: SocketMessage) => void) {\n this.onMessageCallback = callback;\n }\n\n getReadyState() {\n return this.ws?.readyState;\n }\n\n /**\n * @description Send a subscribe message to the websocket connection.\n *\n */\n subscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.SUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n\n /**\n * @description Send an unsubscribe message to the websocket connection.\n *\n */\n unsubscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.UNSUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n /**\n * @description Subscribe to candles channel\n * for a specific market and resolution.\n *\n */\n subscribeToCandles(\n marketTicker: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${marketTicker}/${resolution}`,\n batched: true,\n };\n this.subscribe(channel, params);\n }\n\n subscribeToSpotCandles(\n marketTicker: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.SPOT_CANDLES;\n const params = {\n id: `${marketTicker}/${resolution}`,\n batched: true,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from candles channel\n * for a specific market and resolution.\n */\n unsubscribeFromCandles(market: string, resolution: CandlesResolution): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${market}/${resolution}`,\n };\n this.unsubscribe(channel, params);\n }\n\n unsubscribeFromSpotCandles(\n market: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.SPOT_CANDLES;\n const params = {\n id: `${market}/${resolution}`,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to prices channel\n * for a specific assets pair.\n *\n */\n subscribeToPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from prices channel\n * for a specific market and resolution.\n */\n unsubscribeFromPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to funding rate channel\n * for a specific assets pair.\n *\n */\n subscribeToFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from funding rate channel\n * for a specific market and resolution.\n */\n unsubscribeFromFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to markets updates channel\n *\n */\n subscribeToMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from markets updates channel\n */\n unsubscribeFromMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.unsubscribe(channel, params);\n }\n}\n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AkB;QAC3C,IAAM,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC;QAC7C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,UAAU;SACf,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,gDAAyB,GAAzB;QACE,IAAM,OAAO,GAAG,cAAc,CAAC,eAAe,CAAC;QAC/C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,GAAG;SACR,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,oDAA6B,GAA7B;QACE,IAAM,OAAO,GAAG,cAAc,CAAC,eAAe,CAAC;QAC/C,IAAM,MAAM,GAAG;YACb,EAAE,EAAE,GAAG;SACR,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IACH,mBAAC;AAAD,CAAC,AArQD,IAqQC;AArQY,oCAAY","sourcesContent":["import WebSocket, { MessageEvent } from 'isomorphic-ws';\n\nimport {\n Candle,\n CandlesResolution,\n getApiClientConfig,\n MarketEntity,\n ServiceConfig,\n StorkSignedPayload,\n} from '@reyaxyz/common';\n\nenum OutgoingMessageTypes {\n PING = 'ping',\n SUBSCRIBE = 'subscribe',\n UNSUBSCRIBE = 'unsubscribe',\n}\n\nexport enum SocketChannels {\n CANDLES = 'candles',\n PRICES = 'prices',\n FUNDING_RATES = 'funding-rates',\n MARKETS_UPDATES = 'markets-updates',\n SPOT_CANDLES = 'spot-candles',\n}\n\nexport enum IncomingMessageTypes {\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n ERROR = 'error',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport enum OutgoingMessageType {\n ERROR = 'error',\n CONNECTED = 'connected',\n SUBSCRIBED = 'subscribed',\n UNSUBSCRIBED = 'unsubscribed',\n CHANNEL_DATA = 'channel_data',\n CHANNEL_BATCH_DATA = 'channel_batch_data',\n PONG = 'pong',\n}\nexport interface OutgoingMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n}\nexport interface SocketMessage {\n message_id: number;\n connection_id: string;\n type: OutgoingMessageType;\n channel?: SocketChannels;\n contents?: unknown;\n id?: string;\n}\n\nexport interface CandleMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.CANDLES;\n id: string;\n contents: {\n candles: Candle[];\n };\n}\n\nexport interface PricesMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.PRICES;\n id: string;\n contents: {\n signedPrice: StorkSignedPayload;\n poolPrice: string;\n spotPrice: string;\n marketId: number | null;\n assetPairId: string;\n };\n}\n\nexport interface MarketsUpdateMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.MARKETS_UPDATES;\n id: string;\n contents: MarketEntity[];\n}\n\nexport interface FundingRateMessage extends SocketMessage {\n type: OutgoingMessageType;\n connection_id: string;\n message_id: number;\n channel: SocketChannels.FUNDING_RATES;\n id: string;\n contents: { timestamp: number; value: string; assetsPair: string };\n}\n\nexport interface SocketClientConfig {\n environment: ServiceConfig['environment'];\n onOpen: () => void;\n onClose: () => void;\n onMessage: (event: SocketMessage) => void;\n}\n\nexport class SocketClient {\n private url: string;\n private ws?: WebSocket;\n private onOpenCallback?: () => void;\n private onCloseCallback?: () => void;\n private onMessageCallback?: (event: SocketMessage) => void;\n private pingInterval: number = 30_000;\n private lastMessageTime: number = Date.now();\n private pingIntervalId?: NodeJS.Timeout;\n constructor(config: SocketClientConfig) {\n this.onOpenCallback = config.onOpen;\n this.onCloseCallback = config.onClose;\n this.onMessageCallback = config.onMessage;\n this.url = getApiClientConfig(config.environment).webSocketEndpoint;\n }\n\n connect(): void {\n this.ws = new WebSocket(this.url);\n this.ws.addEventListener('open', this.handleOpen.bind(this));\n this.ws.addEventListener('close', this.handleClose.bind(this));\n this.ws.addEventListener('message', this.handleMessage.bind(this));\n }\n\n /**\n * @description Close the websocket connection.\n *\n */\n close(): void {\n this.ws?.close();\n this.ws = undefined;\n }\n\n /**\n * @description Send data to the websocket connection.\n *\n */\n send(data: string): void {\n this.ws?.send(data);\n }\n\n private handleOpen(): void {\n if (this.onOpenCallback) {\n this.onOpenCallback();\n }\n this.restartPingInterval();\n }\n\n private handleClose(): void {\n if (this.onCloseCallback) {\n this.onCloseCallback();\n }\n clearInterval(this.pingIntervalId);\n }\n\n private handleMessage(event: MessageEvent): void {\n if (event.data === 'PING') {\n this.send('PONG');\n } else {\n this.lastMessageTime = Date.now();\n try {\n const parsedMessage: SocketMessage = JSON.parse(event.data as string);\n if (typeof this.onMessageCallback === 'function') {\n this.onMessageCallback(parsedMessage);\n }\n } catch (error) {\n console.error('Error parsing message', error);\n }\n }\n this.restartPingInterval();\n }\n\n private restartPingInterval(): void {\n clearInterval(this.pingIntervalId);\n this.pingIntervalId = setInterval(() => {\n const elapsedTime = Date.now() - this.lastMessageTime;\n if (elapsedTime > this.pingInterval) {\n const message = {\n type: OutgoingMessageTypes.PING,\n };\n this.send(JSON.stringify(message));\n }\n }, this.pingInterval);\n }\n\n /**\n * @description Set callback when the socket is opened.\n *\n */\n set onOpen(callback: () => void) {\n this.onOpenCallback = callback;\n }\n\n /**\n * @description Set callback when the socket is closed.\n *\n */\n set onClose(callback: () => void) {\n this.onCloseCallback = callback;\n }\n\n /**\n * @description Set callback when the socket receives a message.\n *\n */\n set onMessage(callback: (event: SocketMessage) => void) {\n this.onMessageCallback = callback;\n }\n\n getReadyState() {\n return this.ws?.readyState;\n }\n\n /**\n * @description Send a subscribe message to the websocket connection.\n *\n */\n subscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.SUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n\n /**\n * @description Send an unsubscribe message to the websocket connection.\n *\n */\n unsubscribe(channel: string, params?: object): void {\n const message = {\n type: OutgoingMessageTypes.UNSUBSCRIBE,\n channel,\n ...params,\n };\n this.send(JSON.stringify(message));\n }\n /**\n * @description Subscribe to candles channel\n * for a specific market and resolution.\n *\n */\n subscribeToCandles(\n marketTicker: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${marketTicker}/${resolution}`,\n batched: true,\n };\n this.subscribe(channel, params);\n }\n\n subscribeToSpotCandles(\n marketTicker: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.SPOT_CANDLES;\n const params = {\n id: `${marketTicker}/${resolution}`,\n batched: true,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from candles channel\n * for a specific market and resolution.\n */\n unsubscribeFromCandles(market: string, resolution: CandlesResolution): void {\n const channel = SocketChannels.CANDLES;\n const params = {\n id: `${market}/${resolution}`,\n };\n this.unsubscribe(channel, params);\n }\n\n unsubscribeFromSpotCandles(\n market: string,\n resolution: CandlesResolution,\n ): void {\n const channel = SocketChannels.SPOT_CANDLES;\n const params = {\n id: `${market}/${resolution}`,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to prices channel\n * for a specific assets pair.\n *\n */\n subscribeToPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from prices channel\n * for a specific market and resolution.\n */\n unsubscribeFromPrices(assetsPair: string): void {\n const channel = SocketChannels.PRICES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to funding rate channel\n * for a specific assets pair.\n *\n */\n subscribeToFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from funding rate channel\n * for a specific market and resolution.\n */\n unsubscribeFromFundingRate(assetsPair: string): void {\n const channel = SocketChannels.FUNDING_RATES;\n const params = {\n id: assetsPair,\n };\n this.unsubscribe(channel, params);\n }\n\n /**\n * @description Subscribe to markets updates channel\n *\n */\n subscribeToMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.subscribe(channel, params);\n }\n\n /**\n * @description Unsubscribe from markets updates channel\n */\n unsubscribeFromMarketsUpdates(): void {\n const channel = SocketChannels.MARKETS_UPDATES;\n const params = {\n id: '1',\n };\n this.unsubscribe(channel, params);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"/","sources":["clients/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AACzB,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;AAC5C,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,8BAA8B,MAAM,sCAAsC,CAAC;AAClF,OAAO,iCAAiC,MAAM,0CAA0C,CAAC;AACzF,OAAO,4BAA4B,MAAM,qCAAqC,CAAC;AAC/E,OAAO,kCAAkC,MAAM,2CAA2C,CAAC;AAC3F,OAAO,0BAA0B,MAAM,kCAAkC,CAAC;AAC1E,OAAO,mCAAmC,MAAM,4CAA4C,CAAC;AAC7F,OAAO,wCAAwC,MAAM,kDAAkD,CAAC;AACxG,OAAO,8BAA8B,MAAM,uCAAuC,CAAC;AACnF,OAAO,0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BAA8B,CAE3E;IAED;;;;;;;;;OASG;IACH,WAAkB,EAAE,IAAI,QAAQ,CAE/B;IAED;;;;;;;;;OASG;IACH,WAAkB,MAAM,IAAI,YAAY,CAEvC;IAED;;;;;;;;;OASG;IACH,WAAkB,KAAK,IAAI,WAAW,CAErC;IAED;;;;;;OAMG;IACH,WAAkB,iBAAiB,IAAI,uBAAuB,CAE7D;IAED;;;;;;OAMG;IACH,WAAkB,OAAO,IAAI,aAAa,CAEzC;IAED;;;;;;OAMG;IACH,WAAkB,QAAQ,IAAI,cAAc,CAE3C;IAED;;;;;;OAMG;IAEH,WAAkB,SAAS,IAAI,eAAe,CAE7C;IAED;;;;;;OAMG;IACH,WAAkB,IAAI,IAAI,UAAU,CAEnC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAqBrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-client.d.ts","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"socket-client.d.ts","sourceRoot":"/","sources":["clients/socket-client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EACN,iBAAiB,EAEjB,YAAY,EACZ,aAAa,EACb,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAQzB,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;CAC9B;AAED,oBAAY,oBAAoB;IAC9B,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;IACzC,IAAI,SAAS;CACd;AACD,oBAAY,mBAAmB;IAC7B,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;IACzC,IAAI,SAAS;CACd;AACD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,IAAI,EAAE,mBAAmB,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC;IAChC,EAAE,EAAE,MAAM,CAAC;I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M,EAAE,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAQ3E,0BAA0B,CACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,iBAAiB,GAC5B,IAAI;IAQP;;;;OAIG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQ3C;;;OAGG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQ/C;;;;OAIG;IACH,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQhD;;;OAGG;IACH,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAQpD;;;OAGG;IACH,yBAAyB,IAAI,IAAI;IAQjC;;OAEG;IACH,6BAA6B,IAAI,IAAI;CAOtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.151.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.
|
|
36
|
+
"@reyaxyz/common": "0.266.0",
|
|
37
37
|
"@simplewebauthn/types": "^10.0.0",
|
|
38
38
|
"axios": "^1.6.2",
|
|
39
39
|
"bignumber.js": "^9.1.2",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"ws": "^8.16.0"
|
|
43
43
|
},
|
|
44
44
|
"packageManager": "pnpm@8.3.1",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "7ee2c0eb88765d361b8ac049b0640ec75ec58424",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@reyaxyz/database": "0.120.
|
|
47
|
+
"@reyaxyz/database": "0.120.4"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
API_CLIENT_CONFIGS,
|
|
3
2
|
ServiceConfig,
|
|
4
3
|
ReyaChainId,
|
|
4
|
+
getApiClientConfig,
|
|
5
5
|
} from '@reyaxyz/common';
|
|
6
6
|
import MarketsClient from './modules/markets';
|
|
7
7
|
import AccountClient from './modules/account';
|
|
@@ -31,7 +31,7 @@ import RageTradeClient from './modules/rage-trade';
|
|
|
31
31
|
*/
|
|
32
32
|
export class ApiClient {
|
|
33
33
|
private static instance: ApiClient;
|
|
34
|
-
private static config: ServiceConfig =
|
|
34
|
+
private static config: ServiceConfig = getApiClientConfig('test');
|
|
35
35
|
private readonly _markets: MarketsClient;
|
|
36
36
|
private readonly _account: AccountClient;
|
|
37
37
|
private readonly _lp: LpClient;
|
|
@@ -114,8 +114,7 @@ export class ApiClient {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
public static configure(environment: ServiceConfig['environment']): void {
|
|
117
|
-
ApiClient.config =
|
|
118
|
-
API_CLIENT_CONFIGS[environment] || API_CLIENT_CONFIGS['test'];
|
|
117
|
+
ApiClient.config = getApiClientConfig(environment);
|
|
119
118
|
ApiClient.instance = new ApiClient();
|
|
120
119
|
}
|
|
121
120
|
|
|
@@ -6,10 +6,6 @@ type LotteryConfig = {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const LOTTERY_CONFIGS: Record<ServiceEnvironment, LotteryConfig> = {
|
|
9
|
-
local: {
|
|
10
|
-
address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
11
|
-
marginAccountId: 6888,
|
|
12
|
-
},
|
|
13
9
|
production: {
|
|
14
10
|
address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
15
11
|
marginAccountId: 20092,
|
|
@@ -18,8 +14,16 @@ export const LOTTERY_CONFIGS: Record<ServiceEnvironment, LotteryConfig> = {
|
|
|
18
14
|
address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
19
15
|
marginAccountId: 20092,
|
|
20
16
|
},
|
|
17
|
+
localmainnet: {
|
|
18
|
+
address: '0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
19
|
+
marginAccountId: 20092,
|
|
20
|
+
},
|
|
21
21
|
test: {
|
|
22
22
|
address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
23
23
|
marginAccountId: 6888,
|
|
24
24
|
},
|
|
25
|
+
localtestnet: {
|
|
26
|
+
address: '0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
27
|
+
marginAccountId: 6888,
|
|
28
|
+
},
|
|
25
29
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import WebSocket, { MessageEvent } from 'isomorphic-ws';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
API_CLIENT_CONFIGS,
|
|
5
4
|
Candle,
|
|
6
5
|
CandlesResolution,
|
|
6
|
+
getApiClientConfig,
|
|
7
7
|
MarketEntity,
|
|
8
8
|
ServiceConfig,
|
|
9
9
|
StorkSignedPayload,
|
|
@@ -118,9 +118,7 @@ export class SocketClient {
|
|
|
118
118
|
this.onOpenCallback = config.onOpen;
|
|
119
119
|
this.onCloseCallback = config.onClose;
|
|
120
120
|
this.onMessageCallback = config.onMessage;
|
|
121
|
-
this.url = (
|
|
122
|
-
API_CLIENT_CONFIGS[config.environment] || API_CLIENT_CONFIGS['test']
|
|
123
|
-
).webSocketEndpoint;
|
|
121
|
+
this.url = getApiClientConfig(config.environment).webSocketEndpoint;
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
connect(): void {
|