@dydxprotocol/v4-client-js 1.1.13 → 1.1.15

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.
Files changed (151) hide show
  1. package/.eslintrc.js +3 -5
  2. package/.prettierignore +3 -0
  3. package/.prettierrc.json +6 -0
  4. package/.telescope.json +2 -4
  5. package/.vscode/launch.json +10 -10
  6. package/README.md +3 -1
  7. package/__native__/__ios__/v4-native-client.js +2680 -799
  8. package/__tests__/helpers/constants.ts +10 -8
  9. package/__tests__/lib/helpers.test.ts +22 -23
  10. package/__tests__/lib/util.test.ts +2 -8
  11. package/__tests__/lib/validation.test.ts +23 -26
  12. package/__tests__/modules/client/Transfers.test.ts +4 -19
  13. package/__tests__/modules/client/ValidatorPostEndpoints.test.ts +2 -5
  14. package/__tests__/modules/client/constants.ts +4 -2
  15. package/__tests__/modules/onboarding.test.ts +9 -7
  16. package/build/__tests__/helpers/constants.js +7 -7
  17. package/build/__tests__/lib/helpers.test.js +2 -6
  18. package/build/__tests__/lib/util.test.js +1 -1
  19. package/build/__tests__/lib/validation.test.js +3 -11
  20. package/build/__tests__/modules/client/Transfers.test.js +1 -1
  21. package/build/__tests__/modules/client/ValidatorPostEndpoints.test.js +2 -2
  22. package/build/__tests__/modules/client/constants.js +1 -1
  23. package/build/__tests__/modules/onboarding.test.js +2 -3
  24. package/build/examples/account_endpoints.js +4 -3
  25. package/build/examples/composite_example.js +5 -4
  26. package/build/examples/constants.js +1 -1
  27. package/build/examples/faucet_endpoint.js +4 -3
  28. package/build/examples/long_term_order_cancel_example.js +4 -3
  29. package/build/examples/markets_endpoints.js +4 -3
  30. package/build/examples/native_examples.js +4 -3
  31. package/build/examples/noble_example.js +1 -1
  32. package/build/examples/optimal_node.js +4 -12
  33. package/build/examples/short_term_order_cancel_example.js +4 -3
  34. package/build/examples/short_term_order_composite_example.js +4 -3
  35. package/build/examples/test.js +5 -4
  36. package/build/examples/transfer_example_deposit.js +4 -3
  37. package/build/examples/transfer_example_send.js +1 -1
  38. package/build/examples/transfer_example_subaccount_transfer.js +4 -3
  39. package/build/examples/transfer_example_withdraw.js +4 -3
  40. package/build/examples/transfer_example_withdraw_other.js +1 -1
  41. package/build/examples/utility_endpoints.js +4 -3
  42. package/build/examples/validator_get_example.js +15 -9
  43. package/build/examples/validator_post_example.js +4 -3
  44. package/build/examples/wallet_address.js +5 -4
  45. package/build/examples/websocket_example.js +1 -1
  46. package/build/src/clients/composite-client.d.ts +222 -222
  47. package/build/src/clients/composite-client.js +234 -228
  48. package/build/src/clients/constants.d.ts +3 -0
  49. package/build/src/clients/constants.js +6 -2
  50. package/build/src/clients/faucet-client.d.ts +4 -4
  51. package/build/src/clients/faucet-client.js +5 -5
  52. package/build/src/clients/helpers/chain-helpers.js +1 -1
  53. package/build/src/clients/helpers/request-helpers.js +5 -4
  54. package/build/src/clients/indexer-client.js +1 -1
  55. package/build/src/clients/lib/axios/axiosRequest.js +1 -1
  56. package/build/src/clients/lib/axios/errors.js +1 -1
  57. package/build/src/clients/lib/cctpProto.d.ts +2 -2
  58. package/build/src/clients/lib/cctpProto.js +287 -237
  59. package/build/src/clients/lib/errors.js +1 -1
  60. package/build/src/clients/modules/account.js +1 -1
  61. package/build/src/clients/modules/composer.d.ts +4 -0
  62. package/build/src/clients/modules/composer.js +39 -3
  63. package/build/src/clients/modules/get.d.ts +10 -3
  64. package/build/src/clients/modules/get.js +41 -54
  65. package/build/src/clients/modules/local-wallet.js +1 -1
  66. package/build/src/clients/modules/post.d.ts +6 -0
  67. package/build/src/clients/modules/post.js +50 -18
  68. package/build/src/clients/modules/proto-includes.d.ts +1 -0
  69. package/build/src/clients/modules/proto-includes.js +3 -2
  70. package/build/src/clients/modules/rest.js +1 -1
  71. package/build/src/clients/modules/signer.js +1 -1
  72. package/build/src/clients/modules/tendermintClient.d.ts +5 -5
  73. package/build/src/clients/modules/tendermintClient.js +6 -6
  74. package/build/src/clients/native.d.ts +5 -0
  75. package/build/src/clients/native.js +44 -9
  76. package/build/src/clients/noble-client.js +1 -1
  77. package/build/src/clients/socket-client.js +1 -1
  78. package/build/src/clients/subaccount.js +1 -1
  79. package/build/src/clients/types.d.ts +1 -1
  80. package/build/src/clients/types.js +1 -1
  81. package/build/src/clients/validator-client.d.ts +12 -12
  82. package/build/src/clients/validator-client.js +13 -13
  83. package/build/src/lib/errors.js +1 -1
  84. package/build/src/lib/onboarding.js +1 -1
  85. package/build/src/lib/utils.js +3 -3
  86. package/build/src/lib/validation.js +5 -4
  87. package/build/src/network_optimizer.js +10 -11
  88. package/build/src/types.d.ts +1 -1
  89. package/build/src/types.js +1 -1
  90. package/examples/account_endpoints.ts +5 -4
  91. package/examples/composite_example.ts +12 -7
  92. package/examples/constants.ts +10 -4
  93. package/examples/faucet_endpoint.ts +5 -4
  94. package/examples/human_readable_orders.json +85 -85
  95. package/examples/human_readable_short_term_orders.json +41 -41
  96. package/examples/long_term_order_cancel_example.ts +11 -6
  97. package/examples/markets_endpoints.ts +5 -4
  98. package/examples/native_examples.ts +8 -7
  99. package/examples/noble_example.ts +11 -23
  100. package/examples/optimal_node.ts +4 -14
  101. package/examples/raw_orders.json +128 -128
  102. package/examples/short_term_order_cancel_example.ts +7 -8
  103. package/examples/short_term_order_composite_example.ts +7 -8
  104. package/examples/test.ts +12 -7
  105. package/examples/transfer_example_deposit.ts +6 -9
  106. package/examples/transfer_example_send.ts +2 -10
  107. package/examples/transfer_example_subaccount_transfer.ts +6 -11
  108. package/examples/transfer_example_withdraw.ts +6 -9
  109. package/examples/transfer_example_withdraw_other.ts +1 -5
  110. package/examples/utility_endpoints.ts +5 -4
  111. package/examples/validator_get_example.ts +19 -10
  112. package/examples/validator_post_example.ts +7 -9
  113. package/examples/wallet_address.ts +6 -5
  114. package/examples/websocket_example.ts +5 -1
  115. package/package.json +4 -1
  116. package/src/clients/composite-client.ts +272 -329
  117. package/src/clients/constants.ts +38 -26
  118. package/src/clients/faucet-client.ts +5 -8
  119. package/src/clients/helpers/chain-helpers.ts +10 -6
  120. package/src/clients/helpers/request-helpers.ts +6 -5
  121. package/src/clients/indexer-client.ts +34 -34
  122. package/src/clients/lib/axios/axiosRequest.ts +4 -7
  123. package/src/clients/lib/axios/errors.ts +16 -21
  124. package/src/clients/lib/cctpProto.ts +655 -387
  125. package/src/clients/lib/errors.ts +8 -17
  126. package/src/clients/modules/account.ts +4 -12
  127. package/src/clients/modules/composer.ts +61 -20
  128. package/src/clients/modules/get.ts +71 -89
  129. package/src/clients/modules/local-wallet.ts +41 -56
  130. package/src/clients/modules/post.ts +684 -634
  131. package/src/clients/modules/proto-includes.ts +1 -0
  132. package/src/clients/modules/rest.ts +23 -26
  133. package/src/clients/modules/signer.ts +8 -22
  134. package/src/clients/modules/tendermintClient.ts +13 -36
  135. package/src/clients/native.ts +119 -140
  136. package/src/clients/noble-client.ts +1 -5
  137. package/src/clients/socket-client.ts +216 -216
  138. package/src/clients/subaccount.ts +16 -16
  139. package/src/clients/types.ts +14 -10
  140. package/src/clients/validator-client.ts +14 -16
  141. package/src/codegen/helpers.ts +149 -150
  142. package/src/codegen/index.ts +4 -5
  143. package/src/lib/errors.ts +3 -9
  144. package/src/lib/onboarding.ts +7 -2
  145. package/src/lib/utils.ts +5 -12
  146. package/src/lib/validation.ts +21 -19
  147. package/src/network_optimizer.ts +78 -65
  148. package/src/types.ts +5 -6
  149. package/tasks.json +15 -15
  150. package/tsconfig.eslint.json +1 -4
  151. package/tsconfig.json +2 -6
@@ -35,246 +35,246 @@ export enum CandlesResolution {
35
35
  }
36
36
 
37
37
  export class SocketClient {
38
- private url: string;
39
- private ws?: WebSocket;
40
- private onOpenCallback?: () => void;
41
- private onCloseCallback?: () => void;
42
- private onMessageCallback?: (event: MessageEvent) => void;
43
- private lastMessageTime: number = Date.now();
38
+ private url: string;
39
+ private ws?: WebSocket;
40
+ private onOpenCallback?: () => void;
41
+ private onCloseCallback?: () => void;
42
+ private onMessageCallback?: (event: MessageEvent) => void;
43
+ private lastMessageTime: number = Date.now();
44
44
 
45
- constructor(
46
- config: IndexerConfig,
47
- onOpenCallback: () => void,
48
- onCloseCallback: ()=> void,
49
- onMessageCallback: (event: MessageEvent)=> void,
50
- ) {
51
- this.url = config.websocketEndpoint;
52
- this.onOpenCallback = onOpenCallback;
53
- this.onCloseCallback = onCloseCallback;
54
- this.onMessageCallback = onMessageCallback;
55
- }
45
+ constructor(
46
+ config: IndexerConfig,
47
+ onOpenCallback: () => void,
48
+ onCloseCallback: () => void,
49
+ onMessageCallback: (event: MessageEvent) => void,
50
+ ) {
51
+ this.url = config.websocketEndpoint;
52
+ this.onOpenCallback = onOpenCallback;
53
+ this.onCloseCallback = onCloseCallback;
54
+ this.onMessageCallback = onMessageCallback;
55
+ }
56
56
 
57
- connect(): void {
58
- this.ws = new WebSocket(this.url);
59
- this.ws.addEventListener('open', this.handleOpen.bind(this));
60
- this.ws.addEventListener('close', this.handleClose.bind(this));
61
- this.ws.addEventListener('message', this.handleMessage.bind(this));
62
- }
57
+ connect(): void {
58
+ this.ws = new WebSocket(this.url);
59
+ this.ws.addEventListener('open', this.handleOpen.bind(this));
60
+ this.ws.addEventListener('close', this.handleClose.bind(this));
61
+ this.ws.addEventListener('message', this.handleMessage.bind(this));
62
+ }
63
63
 
64
- /**
65
- * @description Close the websocket connection.
66
- *
67
- */
68
- close(): void {
69
- this.ws?.close();
70
- this.ws = undefined;
71
- }
64
+ /**
65
+ * @description Close the websocket connection.
66
+ *
67
+ */
68
+ close(): void {
69
+ this.ws?.close();
70
+ this.ws = undefined;
71
+ }
72
72
 
73
- /**
74
- * @description Send data to the websocket connection.
75
- *
76
- */
77
- send(data: string): void {
78
- this.ws?.send(data);
79
- }
73
+ /**
74
+ * @description Send data to the websocket connection.
75
+ *
76
+ */
77
+ send(data: string): void {
78
+ this.ws?.send(data);
79
+ }
80
80
 
81
- private handleOpen(): void {
82
- if (this.onOpenCallback) {
83
- this.onOpenCallback();
84
- }
81
+ private handleOpen(): void {
82
+ if (this.onOpenCallback) {
83
+ this.onOpenCallback();
85
84
  }
85
+ }
86
86
 
87
- private handleClose(): void {
88
- if (this.onCloseCallback) {
89
- this.onCloseCallback();
90
- }
87
+ private handleClose(): void {
88
+ if (this.onCloseCallback) {
89
+ this.onCloseCallback();
91
90
  }
91
+ }
92
92
 
93
- private handleMessage(event: MessageEvent): void {
94
- if (event.data === 'PING') {
95
- this.send('PONG');
96
- } else {
97
- this.lastMessageTime = Date.now();
98
- if (this.onMessageCallback) {
99
- this.onMessageCallback(event);
100
- }
93
+ private handleMessage(event: MessageEvent): void {
94
+ if (event.data === 'PING') {
95
+ this.send('PONG');
96
+ } else {
97
+ this.lastMessageTime = Date.now();
98
+ if (this.onMessageCallback) {
99
+ this.onMessageCallback(event);
101
100
  }
102
101
  }
102
+ }
103
103
 
104
- /**
105
- * @description Set callback when the socket is opened.
106
- *
107
- */
108
- set onOpen(callback: () => void) {
109
- this.onOpenCallback = callback;
110
- }
104
+ /**
105
+ * @description Set callback when the socket is opened.
106
+ *
107
+ */
108
+ set onOpen(callback: () => void) {
109
+ this.onOpenCallback = callback;
110
+ }
111
111
 
112
- /**
113
- * @description Set callback when the socket is closed.
114
- *
115
- */
116
- set onClose(callback: () => void) {
117
- this.onCloseCallback = callback;
118
- }
112
+ /**
113
+ * @description Set callback when the socket is closed.
114
+ *
115
+ */
116
+ set onClose(callback: () => void) {
117
+ this.onCloseCallback = callback;
118
+ }
119
119
 
120
- /**
121
- * @description Set callback when the socket receives a message.
122
- *
123
- */
124
- set onMessage(callback: (event: MessageEvent) => void) {
125
- this.onMessageCallback = callback;
126
- }
120
+ /**
121
+ * @description Set callback when the socket receives a message.
122
+ *
123
+ */
124
+ set onMessage(callback: (event: MessageEvent) => void) {
125
+ this.onMessageCallback = callback;
126
+ }
127
127
 
128
- /**
129
- * @description Send a subscribe message to the websocket connection.
130
- *
131
- */
132
- subscribe(channel: string, params?: object): void {
133
- const message = {
134
- type: OutgoingMessageTypes.SUBSCRIBE,
135
- channel,
136
- ...params,
137
- };
138
- this.send(JSON.stringify(message));
139
- }
128
+ /**
129
+ * @description Send a subscribe message to the websocket connection.
130
+ *
131
+ */
132
+ subscribe(channel: string, params?: object): void {
133
+ const message = {
134
+ type: OutgoingMessageTypes.SUBSCRIBE,
135
+ channel,
136
+ ...params,
137
+ };
138
+ this.send(JSON.stringify(message));
139
+ }
140
140
 
141
- /**
142
- * @description Send an unsubscribe message to the websocket connection.
143
- *
144
- */
145
- unsubscribe(channel: string, params?: object): void {
146
- const message = {
147
- type: OutgoingMessageTypes.UNSUBSCRIBE,
148
- channel,
149
- ...params,
150
- };
151
- this.send(JSON.stringify(message));
152
- }
141
+ /**
142
+ * @description Send an unsubscribe message to the websocket connection.
143
+ *
144
+ */
145
+ unsubscribe(channel: string, params?: object): void {
146
+ const message = {
147
+ type: OutgoingMessageTypes.UNSUBSCRIBE,
148
+ channel,
149
+ ...params,
150
+ };
151
+ this.send(JSON.stringify(message));
152
+ }
153
153
 
154
- /**
155
- * @description Subscribe to markets channel.
156
- *
157
- */
158
- subscribeToMarkets(): void {
159
- const channel = SocketChannels.MARKETS;
160
- const params = {
161
- batched: true,
162
- };
163
- this.subscribe(channel, params);
164
- }
154
+ /**
155
+ * @description Subscribe to markets channel.
156
+ *
157
+ */
158
+ subscribeToMarkets(): void {
159
+ const channel = SocketChannels.MARKETS;
160
+ const params = {
161
+ batched: true,
162
+ };
163
+ this.subscribe(channel, params);
164
+ }
165
165
 
166
- /**
167
- * @description Unsubscribe from markets channel
168
- *
169
- */
170
- unsubscribeFromMarkets(): void {
171
- const channel = SocketChannels.MARKETS;
172
- this.unsubscribe(channel);
173
- }
166
+ /**
167
+ * @description Unsubscribe from markets channel
168
+ *
169
+ */
170
+ unsubscribeFromMarkets(): void {
171
+ const channel = SocketChannels.MARKETS;
172
+ this.unsubscribe(channel);
173
+ }
174
174
 
175
- /**
176
- * @description Subscribe to trade channel
177
- * for a specific market.
178
- *
179
- */
180
- subscribeToTrades(market: string): void {
181
- const channel = SocketChannels.TRADES;
182
- const params = {
183
- id: market,
184
- batched: true,
185
- };
186
- this.subscribe(channel, params);
187
- }
175
+ /**
176
+ * @description Subscribe to trade channel
177
+ * for a specific market.
178
+ *
179
+ */
180
+ subscribeToTrades(market: string): void {
181
+ const channel = SocketChannels.TRADES;
182
+ const params = {
183
+ id: market,
184
+ batched: true,
185
+ };
186
+ this.subscribe(channel, params);
187
+ }
188
188
 
189
- /**
190
- * @description Unscribed from trade channel
191
- * for a specific market.
192
- *
193
- */
194
- unsubscribeFromTrades(market: string): void {
195
- const channel = SocketChannels.TRADES;
196
- const params = {
197
- id: market,
198
- };
199
- this.unsubscribe(channel, params);
200
- }
189
+ /**
190
+ * @description Unscribed from trade channel
191
+ * for a specific market.
192
+ *
193
+ */
194
+ unsubscribeFromTrades(market: string): void {
195
+ const channel = SocketChannels.TRADES;
196
+ const params = {
197
+ id: market,
198
+ };
199
+ this.unsubscribe(channel, params);
200
+ }
201
201
 
202
- /**
203
- * @description Subscribe to orderbook channel
204
- * for a specific market.
205
- *
206
- */
207
- subscribeToOrderbook(market: string): void {
208
- const channel = SocketChannels.ORDERBOOK;
209
- const params = {
210
- id: market,
211
- batched: true,
212
- };
213
- this.subscribe(channel, params);
214
- }
202
+ /**
203
+ * @description Subscribe to orderbook channel
204
+ * for a specific market.
205
+ *
206
+ */
207
+ subscribeToOrderbook(market: string): void {
208
+ const channel = SocketChannels.ORDERBOOK;
209
+ const params = {
210
+ id: market,
211
+ batched: true,
212
+ };
213
+ this.subscribe(channel, params);
214
+ }
215
215
 
216
- /**
217
- * @description Unsubscribe from orderbook channel
218
- * for a specific market.
219
- */
220
- unsubscribeFromOrderbook(market: string): void {
221
- const channel = SocketChannels.ORDERBOOK;
222
- const params = {
223
- id: market,
224
- };
225
- this.unsubscribe(channel, params);
226
- }
216
+ /**
217
+ * @description Unsubscribe from orderbook channel
218
+ * for a specific market.
219
+ */
220
+ unsubscribeFromOrderbook(market: string): void {
221
+ const channel = SocketChannels.ORDERBOOK;
222
+ const params = {
223
+ id: market,
224
+ };
225
+ this.unsubscribe(channel, params);
226
+ }
227
227
 
228
- /**
229
- * @description Subscribe to candles channel
230
- * for a specific market and resolution.
231
- *
232
- */
233
- subscribeToCandles(market: string, resolution: CandlesResolution): void {
234
- const channel = SocketChannels.CANDLES;
235
- const params = {
236
- id: `${market}/${resolution}`,
237
- batched: true,
238
- };
239
- this.subscribe(channel, params);
240
- }
228
+ /**
229
+ * @description Subscribe to candles channel
230
+ * for a specific market and resolution.
231
+ *
232
+ */
233
+ subscribeToCandles(market: string, resolution: CandlesResolution): void {
234
+ const channel = SocketChannels.CANDLES;
235
+ const params = {
236
+ id: `${market}/${resolution}`,
237
+ batched: true,
238
+ };
239
+ this.subscribe(channel, params);
240
+ }
241
241
 
242
- /**
243
- * @description Unsubscribe from candles channel
244
- * for a specific market and resolution.
245
- */
246
- unsubscribeFromCandles(market: string, resolution: CandlesResolution): void {
247
- const channel = SocketChannels.CANDLES;
248
- const params = {
249
- id: `${market}/${resolution}`,
250
- };
251
- this.unsubscribe(channel, params);
252
- }
242
+ /**
243
+ * @description Unsubscribe from candles channel
244
+ * for a specific market and resolution.
245
+ */
246
+ unsubscribeFromCandles(market: string, resolution: CandlesResolution): void {
247
+ const channel = SocketChannels.CANDLES;
248
+ const params = {
249
+ id: `${market}/${resolution}`,
250
+ };
251
+ this.unsubscribe(channel, params);
252
+ }
253
253
 
254
- /**
255
- * @description Subscribe to subaccount channel
256
- * for a specific address and subaccount number.
257
- */
258
- subscribeToSubaccount(address: string, subaccountNumber: number): void {
259
- const channel = SocketChannels.SUBACCOUNTS;
260
- const subaccountId = `${address}/${subaccountNumber}`;
261
- const params = {
262
- id: subaccountId,
263
- };
264
- this.subscribe(channel, params);
265
- }
254
+ /**
255
+ * @description Subscribe to subaccount channel
256
+ * for a specific address and subaccount number.
257
+ */
258
+ subscribeToSubaccount(address: string, subaccountNumber: number): void {
259
+ const channel = SocketChannels.SUBACCOUNTS;
260
+ const subaccountId = `${address}/${subaccountNumber}`;
261
+ const params = {
262
+ id: subaccountId,
263
+ };
264
+ this.subscribe(channel, params);
265
+ }
266
266
 
267
- /**
268
- * @description Unsubscribe from subaccount channel
269
- * for a specific address and subaccount number.
270
- *
271
- */
272
- unsubscribeFromSubaccount(address: string, subaccountNumber: number): void {
273
- const channel = SocketChannels.SUBACCOUNTS;
274
- const subaccountId = `${address}/${subaccountNumber}`;
275
- const params = {
276
- id: subaccountId,
277
- };
278
- this.unsubscribe(channel, params);
279
- }
267
+ /**
268
+ * @description Unsubscribe from subaccount channel
269
+ * for a specific address and subaccount number.
270
+ *
271
+ */
272
+ unsubscribeFromSubaccount(address: string, subaccountNumber: number): void {
273
+ const channel = SocketChannels.SUBACCOUNTS;
274
+ const subaccountId = `${address}/${subaccountNumber}`;
275
+ const params = {
276
+ id: subaccountId,
277
+ };
278
+ this.unsubscribe(channel, params);
279
+ }
280
280
  }
@@ -2,24 +2,24 @@ import { MAX_SUBACCOUNT_NUMBER } from './constants';
2
2
  import LocalWallet from './modules/local-wallet';
3
3
 
4
4
  export class SubaccountInfo {
5
- readonly wallet: LocalWallet;
6
- // TODO, change address to Wallet object when implementing validator functions
7
- readonly subaccountNumber: number;
5
+ readonly wallet: LocalWallet;
6
+ // TODO, change address to Wallet object when implementing validator functions
7
+ readonly subaccountNumber: number;
8
8
 
9
- constructor(wallet: LocalWallet, subaccountNumber: number = 0) {
10
- if (subaccountNumber < 0 || subaccountNumber > MAX_SUBACCOUNT_NUMBER) {
11
- throw new Error(`Subaccount number must be between 0 and ${MAX_SUBACCOUNT_NUMBER}`);
12
- }
13
- this.wallet = wallet;
14
- this.subaccountNumber = subaccountNumber;
9
+ constructor(wallet: LocalWallet, subaccountNumber: number = 0) {
10
+ if (subaccountNumber < 0 || subaccountNumber > MAX_SUBACCOUNT_NUMBER) {
11
+ throw new Error(`Subaccount number must be between 0 and ${MAX_SUBACCOUNT_NUMBER}`);
15
12
  }
13
+ this.wallet = wallet;
14
+ this.subaccountNumber = subaccountNumber;
15
+ }
16
16
 
17
- get address(): string {
18
- const address = this.wallet.address;
19
- if (address !== undefined) {
20
- return address;
21
- } else {
22
- throw new Error('Address not set');
23
- }
17
+ get address(): string {
18
+ const address = this.wallet.address;
19
+ if (address !== undefined) {
20
+ return address;
21
+ } else {
22
+ throw new Error('Address not set');
24
23
  }
24
+ }
25
25
  }
@@ -1,6 +1,10 @@
1
1
  import { Coin } from '@cosmjs/proto-signing';
2
2
  import { Method } from '@cosmjs/tendermint-rpc';
3
- import { Order_ConditionType, Order_Side, Order_TimeInForce } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';
3
+ import {
4
+ Order_ConditionType,
5
+ Order_Side,
6
+ Order_TimeInForce,
7
+ } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';
4
8
  import { PerpetualMarketType } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/perpetuals/perpetual';
5
9
  import BigNumber from 'bignumber.js';
6
10
  import Long from 'long';
@@ -36,7 +40,7 @@ export enum OrderFlags {
36
40
 
37
41
  export interface IBasicOrder {
38
42
  clientId: number;
39
- orderFlags: OrderFlags,
43
+ orderFlags: OrderFlags;
40
44
  clobPairId: number;
41
45
  goodTilBlock?: number;
42
46
  goodTilBlockTime?: number;
@@ -46,15 +50,14 @@ export interface IPlaceOrder extends IBasicOrder {
46
50
  side: Order_Side;
47
51
  quantums: Long;
48
52
  subticks: Long;
49
- timeInForce: Order_TimeInForce,
53
+ timeInForce: Order_TimeInForce;
50
54
  reduceOnly: boolean;
51
55
  clientMetadata: number;
52
- conditionType?: Order_ConditionType,
53
- conditionalOrderTriggerSubticks?: Long,
56
+ conditionType?: Order_ConditionType;
57
+ conditionalOrderTriggerSubticks?: Long;
54
58
  }
55
59
 
56
- export interface ICancelOrder extends IBasicOrder {
57
- }
60
+ export interface ICancelOrder extends IBasicOrder {}
58
61
 
59
62
  // How long to wait and how often to check when calling Broadcast with
60
63
  // Method.BroadcastTxCommit
@@ -78,9 +81,10 @@ export interface DenomConfig {
78
81
  // 2. Once the transaction is added to the memPool
79
82
  // 3. Once the transaction is committed to a block
80
83
  // See https://docs.cosmos.network/master/run-node/txs.html for more information
81
- export type BroadcastMode = (
82
- Method.BroadcastTxAsync | Method.BroadcastTxSync | Method.BroadcastTxCommit
83
- );
84
+ export type BroadcastMode =
85
+ | Method.BroadcastTxAsync
86
+ | Method.BroadcastTxSync
87
+ | Method.BroadcastTxCommit;
84
88
 
85
89
  // ------ Utility Endpoint Responses ------ //
86
90
  export interface TimeResponse {
@@ -26,36 +26,34 @@ export class ValidatorClient {
26
26
  private _post?: Post;
27
27
 
28
28
  /**
29
- * @description Connect to a validator client
30
- *
31
- * @returns The validator client
32
- */
29
+ * @description Connect to a validator client
30
+ *
31
+ * @returns The validator client
32
+ */
33
33
  static async connect(config: ValidatorConfig): Promise<ValidatorClient> {
34
34
  const client = new ValidatorClient(config);
35
35
  await client.initialize();
36
36
  return client;
37
37
  }
38
38
 
39
- private constructor(
40
- config: ValidatorConfig,
41
- ) {
39
+ private constructor(config: ValidatorConfig) {
42
40
  this.config = config;
43
41
  }
44
42
 
45
43
  /**
46
- * @description Get the query module, used for retrieving on-chain data.
47
- *
48
- * @returns The query module
49
- */
44
+ * @description Get the query module, used for retrieving on-chain data.
45
+ *
46
+ * @returns The query module
47
+ */
50
48
  get get(): Get {
51
49
  return this._get!;
52
50
  }
53
51
 
54
52
  /**
55
- * @description transaction module, used for sending transactions.
56
- *
57
- * @returns The transaction module
58
- */
53
+ * @description transaction module, used for sending transactions.
54
+ *
55
+ * @returns The transaction module
56
+ */
59
57
  get post(): Post {
60
58
  return this._post!;
61
59
  }
@@ -80,7 +78,7 @@ export class ValidatorClient {
80
78
  broadcastPollIntervalMs: BROADCAST_POLL_INTERVAL_MS,
81
79
  broadcastTimeoutMs: BROADCAST_TIMEOUT_MS,
82
80
  });
83
- const queryClient: (QueryClient & TxExtension) = QueryClient.withExtensions(
81
+ const queryClient: QueryClient & TxExtension = QueryClient.withExtensions(
84
82
  tendermint37Client,
85
83
  setupTxExtension,
86
84
  );