@meshtrade/api-web 1.33.0 → 1.34.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/dist/meshtrade/market_data/price/v1/price_pb.d.ts +12 -6
- package/dist/meshtrade/market_data/price/v1/service_pb.d.ts +16 -3
- package/dist/meshtrade/market_data/price/v1/service_pb.js +4 -1
- package/dist/meshtrade/trading/limit_order/v1/index.d.ts +1 -0
- package/dist/meshtrade/trading/limit_order/v1/index.js +1 -0
- package/dist/meshtrade/trading/limit_order/v1/limit_order_pb.d.ts +24 -16
- package/dist/meshtrade/trading/limit_order/v1/limit_order_pb.js +17 -17
- package/dist/meshtrade/trading/limit_order/v1/limit_order_state.d.ts +14 -0
- package/dist/meshtrade/trading/limit_order/v1/limit_order_state.js +64 -0
- package/package.json +1 -1
|
@@ -9,35 +9,41 @@ import type { Message } from "@bufbuild/protobuf";
|
|
|
9
9
|
export declare const file_meshtrade_market_data_price_v1_price: GenFile;
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Price represents a market price quote for a token pair.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Provides the mid-market price for a base token denominated in a quote token,
|
|
15
|
+
* along with the timestamp when the price was observed.
|
|
16
16
|
*
|
|
17
17
|
* @generated from message meshtrade.market_data.price.v1.Price
|
|
18
18
|
*/
|
|
19
19
|
export type Price = Message<"meshtrade.market_data.price.v1.Price"> & {
|
|
20
20
|
/**
|
|
21
|
+
*
|
|
22
|
+
* The base token for which the price is quoted.
|
|
23
|
+
* This is the token being priced (e.g., BTC in a BTC/USD pair).
|
|
24
|
+
*
|
|
21
25
|
* @generated from field: meshtrade.type.v1.Token base_token = 1;
|
|
22
26
|
*/
|
|
23
27
|
baseToken?: Token;
|
|
24
28
|
/**
|
|
25
29
|
*
|
|
26
|
-
*
|
|
30
|
+
* The quote token in which the price is denominated.
|
|
31
|
+
* This is the unit of measurement for the price (e.g., USD in a BTC/USD pair).
|
|
27
32
|
*
|
|
28
33
|
* @generated from field: meshtrade.type.v1.Token quote_token = 2;
|
|
29
34
|
*/
|
|
30
35
|
quoteToken?: Token;
|
|
31
36
|
/**
|
|
32
37
|
*
|
|
33
|
-
*
|
|
38
|
+
* The mid-market price of the base token in quote token units.
|
|
39
|
+
* Represents the midpoint between the best bid and best ask prices.
|
|
34
40
|
*
|
|
35
41
|
* @generated from field: meshtrade.type.v1.Decimal mid_price = 3;
|
|
36
42
|
*/
|
|
37
43
|
midPrice?: Decimal;
|
|
38
44
|
/**
|
|
39
45
|
*
|
|
40
|
-
*
|
|
46
|
+
* Timestamp when this price was observed or calculated.
|
|
41
47
|
*
|
|
42
48
|
* @generated from field: google.protobuf.Timestamp time = 4;
|
|
43
49
|
*/
|
|
@@ -7,19 +7,24 @@ import type { Message } from "@bufbuild/protobuf";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const file_meshtrade_market_data_price_v1_service: GenFile;
|
|
9
9
|
/**
|
|
10
|
+
*
|
|
11
|
+
* Request to retrieve the current price for a token pair.
|
|
12
|
+
*
|
|
10
13
|
* @generated from message meshtrade.market_data.price.v1.GetCurrentPriceByTokenPairRequest
|
|
11
14
|
*/
|
|
12
15
|
export type GetCurrentPriceByTokenPairRequest = Message<"meshtrade.market_data.price.v1.GetCurrentPriceByTokenPairRequest"> & {
|
|
13
16
|
/**
|
|
14
17
|
*
|
|
15
|
-
*
|
|
18
|
+
* The base token for which a price is required.
|
|
19
|
+
* This is the token being priced (e.g., BTC in a BTC/USD pair).
|
|
16
20
|
*
|
|
17
21
|
* @generated from field: meshtrade.type.v1.Token base_token = 1;
|
|
18
22
|
*/
|
|
19
23
|
baseToken?: Token;
|
|
20
24
|
/**
|
|
21
25
|
*
|
|
22
|
-
*
|
|
26
|
+
* The quote token in which the price should be denominated.
|
|
27
|
+
* This is the unit of measurement for the price (e.g., USD in a BTC/USD pair).
|
|
23
28
|
*
|
|
24
29
|
* @generated from field: meshtrade.type.v1.Token quote_token = 2;
|
|
25
30
|
*/
|
|
@@ -32,12 +37,20 @@ export type GetCurrentPriceByTokenPairRequest = Message<"meshtrade.market_data.p
|
|
|
32
37
|
export declare const GetCurrentPriceByTokenPairRequestSchema: GenMessage<GetCurrentPriceByTokenPairRequest>;
|
|
33
38
|
/**
|
|
34
39
|
*
|
|
35
|
-
* PriceService provides
|
|
40
|
+
* PriceService provides market data pricing information.
|
|
41
|
+
*
|
|
42
|
+
* This service enables retrieval of current market prices for token pairs,
|
|
43
|
+
* supporting trading decisions and portfolio valuation.
|
|
36
44
|
*
|
|
37
45
|
* @generated from service meshtrade.market_data.price.v1.PriceService
|
|
38
46
|
*/
|
|
39
47
|
export declare const PriceService: GenService<{
|
|
40
48
|
/**
|
|
49
|
+
*
|
|
50
|
+
* Retrieves the current price for a specified token pair.
|
|
51
|
+
*
|
|
52
|
+
* Returns the mid-market price for the base token denominated in the quote token.
|
|
53
|
+
*
|
|
41
54
|
* @generated from rpc meshtrade.market_data.price.v1.PriceService.GetCurrentPriceByTokenPair
|
|
42
55
|
*/
|
|
43
56
|
getCurrentPriceByTokenPair: {
|
|
@@ -20,7 +20,10 @@ exports.file_meshtrade_market_data_price_v1_service = (0, codegenv2_1.fileDesc)(
|
|
|
20
20
|
exports.GetCurrentPriceByTokenPairRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_meshtrade_market_data_price_v1_service, 0);
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
|
-
* PriceService provides
|
|
23
|
+
* PriceService provides market data pricing information.
|
|
24
|
+
*
|
|
25
|
+
* This service enables retrieval of current market prices for token pairs,
|
|
26
|
+
* supporting trading decisions and portfolio valuation.
|
|
24
27
|
*
|
|
25
28
|
* @generated from service meshtrade.market_data.price.v1.PriceService
|
|
26
29
|
*/
|
|
@@ -42,3 +42,4 @@ __exportStar(require("./service_web_meshts"), exports);
|
|
|
42
42
|
// export * from "./my_custom_module";
|
|
43
43
|
// export { MyCustomClass } from "./another_module";
|
|
44
44
|
// ===================================================================
|
|
45
|
+
__exportStar(require("./limit_order_state"), exports);
|
|
@@ -119,6 +119,14 @@ export type LimitOrder = Message<"meshtrade.trading.limit_order.v1.LimitOrder">
|
|
|
119
119
|
* @generated from field: meshtrade.trading.limit_order.v1.LimitOrderState state = 12;
|
|
120
120
|
*/
|
|
121
121
|
state: LimitOrderState;
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* Number is an incrementing unique identifier that users use to identify an order.
|
|
125
|
+
* This is a system-generated value, not the native exchange order number.
|
|
126
|
+
*
|
|
127
|
+
* @generated from field: string number = 13;
|
|
128
|
+
*/
|
|
129
|
+
number: string;
|
|
122
130
|
};
|
|
123
131
|
/**
|
|
124
132
|
* Describes the message meshtrade.trading.limit_order.v1.LimitOrder.
|
|
@@ -165,51 +173,51 @@ export declare enum LimitOrderState {
|
|
|
165
173
|
/**
|
|
166
174
|
* Unspecified status.
|
|
167
175
|
*
|
|
168
|
-
* @generated from enum value:
|
|
176
|
+
* @generated from enum value: LIMIT_ORDER_STATE_UNSPECIFIED = 0;
|
|
169
177
|
*/
|
|
170
|
-
|
|
178
|
+
UNSPECIFIED = 0,
|
|
171
179
|
/**
|
|
172
180
|
* Submission transaction in progress.
|
|
173
181
|
*
|
|
174
|
-
* @generated from enum value:
|
|
182
|
+
* @generated from enum value: LIMIT_ORDER_STATE_SUBMISSION_IN_PROGRESS = 1;
|
|
175
183
|
*/
|
|
176
|
-
|
|
184
|
+
SUBMISSION_IN_PROGRESS = 1,
|
|
177
185
|
/**
|
|
178
186
|
* Submission failed.
|
|
179
187
|
*
|
|
180
|
-
* @generated from enum value:
|
|
188
|
+
* @generated from enum value: LIMIT_ORDER_STATE_SUBMISSION_FAILED = 2;
|
|
181
189
|
*/
|
|
182
|
-
|
|
190
|
+
SUBMISSION_FAILED = 2,
|
|
183
191
|
/**
|
|
184
192
|
* Order is open on the ledger.
|
|
185
193
|
*
|
|
186
|
-
* @generated from enum value:
|
|
194
|
+
* @generated from enum value: LIMIT_ORDER_STATE_OPEN = 3;
|
|
187
195
|
*/
|
|
188
|
-
|
|
196
|
+
OPEN = 3,
|
|
189
197
|
/**
|
|
190
198
|
* Completion in progress.
|
|
191
199
|
*
|
|
192
|
-
* @generated from enum value:
|
|
200
|
+
* @generated from enum value: LIMIT_ORDER_STATE_COMPLETE_IN_PROGRESS = 4;
|
|
193
201
|
*/
|
|
194
|
-
|
|
202
|
+
COMPLETE_IN_PROGRESS = 4,
|
|
195
203
|
/**
|
|
196
204
|
* Order completed (fully filled).
|
|
197
205
|
*
|
|
198
|
-
* @generated from enum value:
|
|
206
|
+
* @generated from enum value: LIMIT_ORDER_STATE_COMPLETE = 5;
|
|
199
207
|
*/
|
|
200
|
-
|
|
208
|
+
COMPLETE = 5,
|
|
201
209
|
/**
|
|
202
210
|
* Cancellation in progress.
|
|
203
211
|
*
|
|
204
|
-
* @generated from enum value:
|
|
212
|
+
* @generated from enum value: LIMIT_ORDER_STATE_CANCELLATION_IN_PROGRESS = 6;
|
|
205
213
|
*/
|
|
206
|
-
|
|
214
|
+
CANCELLATION_IN_PROGRESS = 6,
|
|
207
215
|
/**
|
|
208
216
|
* Order cancelled.
|
|
209
217
|
*
|
|
210
|
-
* @generated from enum value:
|
|
218
|
+
* @generated from enum value: LIMIT_ORDER_STATE_CANCELLED = 7;
|
|
211
219
|
*/
|
|
212
|
-
|
|
220
|
+
CANCELLED = 7
|
|
213
221
|
}
|
|
214
222
|
/**
|
|
215
223
|
* Describes the enum meshtrade.trading.limit_order.v1.LimitOrderState.
|
|
@@ -10,7 +10,7 @@ const amount_pb_1 = require("../../../type/v1/amount_pb");
|
|
|
10
10
|
/**
|
|
11
11
|
* Describes the file meshtrade/trading/limit_order/v1/limit_order.proto.
|
|
12
12
|
*/
|
|
13
|
-
exports.file_meshtrade_trading_limit_order_v1_limit_order = (0, codegenv2_1.fileDesc)("
|
|
13
|
+
exports.file_meshtrade_trading_limit_order_v1_limit_order = (0, codegenv2_1.fileDesc)("CjJtZXNodHJhZGUvdHJhZGluZy9saW1pdF9vcmRlci92MS9saW1pdF9vcmRlci5wcm90bxIgbWVzaHRyYWRlLnRyYWRpbmcubGltaXRfb3JkZXIudjEi5wYKCkxpbWl0T3JkZXISwgEKBG5hbWUYASABKAlCswG6SK8BugGrAQoUbmFtZS5mb3JtYXQub3B0aW9uYWwSOW5hbWUgbXVzdCBiZSBlbXB0eSBvciBpbiB0aGUgZm9ybWF0IGxpbWl0X29yZGVycy97VUxJRHYyfRpYc2l6ZSh0aGlzKSA9PSAwIHx8IHRoaXMubWF0Y2hlcygnXmxpbWl0X29yZGVycy9bMDEyMzQ1Njc4OUFCQ0RFRkdISktNTlBRUlNUVldYWVpdezI2fSQnKRJLCgVvd25lchgCIAEoCUI8ukg5yAEBcjQyL15ncm91cHMvWzAxMjM0NTY3ODlBQkNERUZHSEpLTU5QUVJTVFZXWFlaXXsyNn0kmAEhEk4KBm93bmVycxgDIAMoCUI+ukg7kgE4IjZyNDIvXmdyb3Vwcy9bMDEyMzQ1Njc4OUFCQ0RFRkdISktNTlBRUlNUVldYWVpdezI2fSSYASESTwoHYWNjb3VudBgFIAEoCUI+ukg7yAEBcjYyMV5hY2NvdW50cy9bMDEyMzQ1Njc4OUFCQ0RFRkdISktNTlBRUlNUVldYWVpdezI2fSSYASMSJAoSZXh0ZXJuYWxfcmVmZXJlbmNlGAYgASgJQgi6SAVyAxjIARJKCgRzaWRlGAcgASgOMjAubWVzaHRyYWRlLnRyYWRpbmcubGltaXRfb3JkZXIudjEuTGltaXRPcmRlclNpZGVCCrpIB4IBBBABIAASNgoLbGltaXRfcHJpY2UYCCABKAsyGS5tZXNodHJhZGUudHlwZS52MS5BbW91bnRCBrpIA8gBARIzCghxdWFudGl0eRgJIAEoCzIZLm1lc2h0cmFkZS50eXBlLnYxLkFtb3VudEIGukgDyAEBEi0KCmZpbGxfcHJpY2UYCiABKAsyGS5tZXNodHJhZGUudHlwZS52MS5BbW91bnQSMgoPZmlsbGVkX3F1YW50aXR5GAsgASgLMhkubWVzaHRyYWRlLnR5cGUudjEuQW1vdW50EkAKBXN0YXRlGAwgASgOMjEubWVzaHRyYWRlLnRyYWRpbmcubGltaXRfb3JkZXIudjEuTGltaXRPcmRlclN0YXRlEg4KBm51bWJlchgNIAEoCUoECAQQBVIMZGlzcGxheV9uYW1lKmcKDkxpbWl0T3JkZXJTaWRlEiAKHExJTUlUX09SREVSX1NJREVfVU5TUEVDSUZJRUQQABIYChRMSU1JVF9PUkRFUl9TSURFX0JVWRABEhkKFUxJTUlUX09SREVSX1NJREVfU0VMTBACKsQCCg9MaW1pdE9yZGVyU3RhdGUSIQodTElNSVRfT1JERVJfU1RBVEVfVU5TUEVDSUZJRUQQABIsCihMSU1JVF9PUkRFUl9TVEFURV9TVUJNSVNTSU9OX0lOX1BST0dSRVNTEAESJwojTElNSVRfT1JERVJfU1RBVEVfU1VCTUlTU0lPTl9GQUlMRUQQAhIaChZMSU1JVF9PUkRFUl9TVEFURV9PUEVOEAMSKgomTElNSVRfT1JERVJfU1RBVEVfQ09NUExFVEVfSU5fUFJPR1JFU1MQBBIeChpMSU1JVF9PUkRFUl9TVEFURV9DT01QTEVURRAFEi4KKkxJTUlUX09SREVSX1NUQVRFX0NBTkNFTExBVElPTl9JTl9QUk9HUkVTUxAGEh8KG0xJTUlUX09SREVSX1NUQVRFX0NBTkNFTExFRBAHQmwKJ2NvLm1lc2h0cmFkZS5hcGkudHJhZGluZy5saW1pdF9vcmRlci52MVpBZ2l0aHViLmNvbS9tZXNodHJhZGUvYXBpL2dvL3RyYWRpbmcvbGltaXRfb3JkZXIvdjE7bGltaXRfb3JkZXJfdjFiBnByb3RvMw", [validate_pb_1.file_buf_validate_validate, amount_pb_1.file_meshtrade_type_v1_amount]);
|
|
14
14
|
/**
|
|
15
15
|
* Describes the message meshtrade.trading.limit_order.v1.LimitOrder.
|
|
16
16
|
* Use `create(LimitOrderSchema)` to create a new message.
|
|
@@ -58,51 +58,51 @@ var LimitOrderState;
|
|
|
58
58
|
/**
|
|
59
59
|
* Unspecified status.
|
|
60
60
|
*
|
|
61
|
-
* @generated from enum value:
|
|
61
|
+
* @generated from enum value: LIMIT_ORDER_STATE_UNSPECIFIED = 0;
|
|
62
62
|
*/
|
|
63
|
-
LimitOrderState[LimitOrderState["
|
|
63
|
+
LimitOrderState[LimitOrderState["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
64
64
|
/**
|
|
65
65
|
* Submission transaction in progress.
|
|
66
66
|
*
|
|
67
|
-
* @generated from enum value:
|
|
67
|
+
* @generated from enum value: LIMIT_ORDER_STATE_SUBMISSION_IN_PROGRESS = 1;
|
|
68
68
|
*/
|
|
69
|
-
LimitOrderState[LimitOrderState["
|
|
69
|
+
LimitOrderState[LimitOrderState["SUBMISSION_IN_PROGRESS"] = 1] = "SUBMISSION_IN_PROGRESS";
|
|
70
70
|
/**
|
|
71
71
|
* Submission failed.
|
|
72
72
|
*
|
|
73
|
-
* @generated from enum value:
|
|
73
|
+
* @generated from enum value: LIMIT_ORDER_STATE_SUBMISSION_FAILED = 2;
|
|
74
74
|
*/
|
|
75
|
-
LimitOrderState[LimitOrderState["
|
|
75
|
+
LimitOrderState[LimitOrderState["SUBMISSION_FAILED"] = 2] = "SUBMISSION_FAILED";
|
|
76
76
|
/**
|
|
77
77
|
* Order is open on the ledger.
|
|
78
78
|
*
|
|
79
|
-
* @generated from enum value:
|
|
79
|
+
* @generated from enum value: LIMIT_ORDER_STATE_OPEN = 3;
|
|
80
80
|
*/
|
|
81
|
-
LimitOrderState[LimitOrderState["
|
|
81
|
+
LimitOrderState[LimitOrderState["OPEN"] = 3] = "OPEN";
|
|
82
82
|
/**
|
|
83
83
|
* Completion in progress.
|
|
84
84
|
*
|
|
85
|
-
* @generated from enum value:
|
|
85
|
+
* @generated from enum value: LIMIT_ORDER_STATE_COMPLETE_IN_PROGRESS = 4;
|
|
86
86
|
*/
|
|
87
|
-
LimitOrderState[LimitOrderState["
|
|
87
|
+
LimitOrderState[LimitOrderState["COMPLETE_IN_PROGRESS"] = 4] = "COMPLETE_IN_PROGRESS";
|
|
88
88
|
/**
|
|
89
89
|
* Order completed (fully filled).
|
|
90
90
|
*
|
|
91
|
-
* @generated from enum value:
|
|
91
|
+
* @generated from enum value: LIMIT_ORDER_STATE_COMPLETE = 5;
|
|
92
92
|
*/
|
|
93
|
-
LimitOrderState[LimitOrderState["
|
|
93
|
+
LimitOrderState[LimitOrderState["COMPLETE"] = 5] = "COMPLETE";
|
|
94
94
|
/**
|
|
95
95
|
* Cancellation in progress.
|
|
96
96
|
*
|
|
97
|
-
* @generated from enum value:
|
|
97
|
+
* @generated from enum value: LIMIT_ORDER_STATE_CANCELLATION_IN_PROGRESS = 6;
|
|
98
98
|
*/
|
|
99
|
-
LimitOrderState[LimitOrderState["
|
|
99
|
+
LimitOrderState[LimitOrderState["CANCELLATION_IN_PROGRESS"] = 6] = "CANCELLATION_IN_PROGRESS";
|
|
100
100
|
/**
|
|
101
101
|
* Order cancelled.
|
|
102
102
|
*
|
|
103
|
-
* @generated from enum value:
|
|
103
|
+
* @generated from enum value: LIMIT_ORDER_STATE_CANCELLED = 7;
|
|
104
104
|
*/
|
|
105
|
-
LimitOrderState[LimitOrderState["
|
|
105
|
+
LimitOrderState[LimitOrderState["CANCELLED"] = 7] = "CANCELLED";
|
|
106
106
|
})(LimitOrderState || (exports.LimitOrderState = LimitOrderState = {}));
|
|
107
107
|
/**
|
|
108
108
|
* Describes the enum meshtrade.trading.limit_order.v1.LimitOrderState.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LimitOrderState } from "./limit_order_pb";
|
|
2
|
+
export declare const allLimitOrderStates: LimitOrderState[];
|
|
3
|
+
/**
|
|
4
|
+
* Converts a LimitOrderState enum instance to a custom string representation.
|
|
5
|
+
* @param {LimitOrderState} limitOrderState - The limitOrderState to convert.
|
|
6
|
+
* @returns {string} The custom string representation of the limitOrderState.
|
|
7
|
+
*/
|
|
8
|
+
export declare function limitOrderStateToString(limitOrderState: LimitOrderState): string;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a custom string representation to a LimitOrderState enum instance.
|
|
11
|
+
* @param {string} limitOrderStateStr - The custom string representation of the limitOrderState.
|
|
12
|
+
* @returns {LimitOrderState} The corresponding LimitOrderState enum instance.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stringToLimitOrderState(limitOrderStateStr: string): LimitOrderState;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allLimitOrderStates = void 0;
|
|
4
|
+
exports.limitOrderStateToString = limitOrderStateToString;
|
|
5
|
+
exports.stringToLimitOrderState = stringToLimitOrderState;
|
|
6
|
+
const limit_order_pb_1 = require("./limit_order_pb");
|
|
7
|
+
// Get all limitOrderStates as enum values
|
|
8
|
+
exports.allLimitOrderStates = Object.values(limit_order_pb_1.LimitOrderState).filter((value) => typeof value === "number");
|
|
9
|
+
// Define explicit mappings between LimitOrderState enums and custom string representations
|
|
10
|
+
const stateToStringMapping = {
|
|
11
|
+
[limit_order_pb_1.LimitOrderState.UNSPECIFIED]: "-",
|
|
12
|
+
[limit_order_pb_1.LimitOrderState.SUBMISSION_IN_PROGRESS]: "Submission in Progress",
|
|
13
|
+
[limit_order_pb_1.LimitOrderState.SUBMISSION_FAILED]: "Submission Failed",
|
|
14
|
+
[limit_order_pb_1.LimitOrderState.OPEN]: "Open",
|
|
15
|
+
[limit_order_pb_1.LimitOrderState.COMPLETE_IN_PROGRESS]: "Complete in Progress",
|
|
16
|
+
[limit_order_pb_1.LimitOrderState.COMPLETE]: "Complete",
|
|
17
|
+
[limit_order_pb_1.LimitOrderState.CANCELLATION_IN_PROGRESS]: "Cancellation in Progress",
|
|
18
|
+
[limit_order_pb_1.LimitOrderState.CANCELLED]: "Cancelled",
|
|
19
|
+
};
|
|
20
|
+
// Reverse mapping from string to LimitOrderState enum
|
|
21
|
+
const stringToLimitOrderStateMapping = {};
|
|
22
|
+
for (const [key, value] of Object.entries(stateToStringMapping)) {
|
|
23
|
+
stringToLimitOrderStateMapping[value] = Number(key);
|
|
24
|
+
}
|
|
25
|
+
class UnsupportedLimitOrderStateError extends Error {
|
|
26
|
+
constructor(limitOrderState) {
|
|
27
|
+
const message = `Unsupported LimitOrderState: ${limitOrderState}`;
|
|
28
|
+
super(message);
|
|
29
|
+
this.limitOrderState = limitOrderState;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts a LimitOrderState enum instance to a custom string representation.
|
|
34
|
+
* @param {LimitOrderState} limitOrderState - The limitOrderState to convert.
|
|
35
|
+
* @returns {string} The custom string representation of the limitOrderState.
|
|
36
|
+
*/
|
|
37
|
+
function limitOrderStateToString(limitOrderState) {
|
|
38
|
+
if (limitOrderState in stateToStringMapping) {
|
|
39
|
+
return stateToStringMapping[limitOrderState];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new UnsupportedLimitOrderStateError(limitOrderState);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class UnsupportedLimitOrderStateStringError extends Error {
|
|
46
|
+
constructor(limitOrderStateStr) {
|
|
47
|
+
const message = `Unsupported limitOrderState string: ${limitOrderStateStr}`;
|
|
48
|
+
super(message);
|
|
49
|
+
this.limitOrderStateStr = limitOrderStateStr;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Converts a custom string representation to a LimitOrderState enum instance.
|
|
54
|
+
* @param {string} limitOrderStateStr - The custom string representation of the limitOrderState.
|
|
55
|
+
* @returns {LimitOrderState} The corresponding LimitOrderState enum instance.
|
|
56
|
+
*/
|
|
57
|
+
function stringToLimitOrderState(limitOrderStateStr) {
|
|
58
|
+
if (limitOrderStateStr in stringToLimitOrderStateMapping) {
|
|
59
|
+
return stringToLimitOrderStateMapping[limitOrderStateStr];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new UnsupportedLimitOrderStateStringError(limitOrderStateStr);
|
|
63
|
+
}
|
|
64
|
+
}
|