@dydxprotocol/v4-client-js 1.1.13 → 1.1.14

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 (150) 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 +2640 -797
  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 +3 -0
  67. package/build/src/clients/modules/post.js +34 -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.js +4 -7
  75. package/build/src/clients/noble-client.js +1 -1
  76. package/build/src/clients/socket-client.js +1 -1
  77. package/build/src/clients/subaccount.js +1 -1
  78. package/build/src/clients/types.d.ts +1 -1
  79. package/build/src/clients/types.js +1 -1
  80. package/build/src/clients/validator-client.d.ts +12 -12
  81. package/build/src/clients/validator-client.js +13 -13
  82. package/build/src/lib/errors.js +1 -1
  83. package/build/src/lib/onboarding.js +1 -1
  84. package/build/src/lib/utils.js +3 -3
  85. package/build/src/lib/validation.js +5 -4
  86. package/build/src/network_optimizer.js +10 -11
  87. package/build/src/types.d.ts +1 -1
  88. package/build/src/types.js +1 -1
  89. package/examples/account_endpoints.ts +5 -4
  90. package/examples/composite_example.ts +12 -7
  91. package/examples/constants.ts +10 -4
  92. package/examples/faucet_endpoint.ts +5 -4
  93. package/examples/human_readable_orders.json +85 -85
  94. package/examples/human_readable_short_term_orders.json +41 -41
  95. package/examples/long_term_order_cancel_example.ts +11 -6
  96. package/examples/markets_endpoints.ts +5 -4
  97. package/examples/native_examples.ts +8 -7
  98. package/examples/noble_example.ts +11 -23
  99. package/examples/optimal_node.ts +4 -14
  100. package/examples/raw_orders.json +128 -128
  101. package/examples/short_term_order_cancel_example.ts +7 -8
  102. package/examples/short_term_order_composite_example.ts +7 -8
  103. package/examples/test.ts +12 -7
  104. package/examples/transfer_example_deposit.ts +6 -9
  105. package/examples/transfer_example_send.ts +2 -10
  106. package/examples/transfer_example_subaccount_transfer.ts +6 -11
  107. package/examples/transfer_example_withdraw.ts +6 -9
  108. package/examples/transfer_example_withdraw_other.ts +1 -5
  109. package/examples/utility_endpoints.ts +5 -4
  110. package/examples/validator_get_example.ts +19 -10
  111. package/examples/validator_post_example.ts +7 -9
  112. package/examples/wallet_address.ts +6 -5
  113. package/examples/websocket_example.ts +5 -1
  114. package/package.json +4 -1
  115. package/src/clients/composite-client.ts +272 -329
  116. package/src/clients/constants.ts +38 -26
  117. package/src/clients/faucet-client.ts +5 -8
  118. package/src/clients/helpers/chain-helpers.ts +10 -6
  119. package/src/clients/helpers/request-helpers.ts +6 -5
  120. package/src/clients/indexer-client.ts +34 -34
  121. package/src/clients/lib/axios/axiosRequest.ts +4 -7
  122. package/src/clients/lib/axios/errors.ts +16 -21
  123. package/src/clients/lib/cctpProto.ts +655 -387
  124. package/src/clients/lib/errors.ts +8 -17
  125. package/src/clients/modules/account.ts +4 -12
  126. package/src/clients/modules/composer.ts +61 -20
  127. package/src/clients/modules/get.ts +71 -89
  128. package/src/clients/modules/local-wallet.ts +41 -56
  129. package/src/clients/modules/post.ts +664 -634
  130. package/src/clients/modules/proto-includes.ts +1 -0
  131. package/src/clients/modules/rest.ts +23 -26
  132. package/src/clients/modules/signer.ts +8 -22
  133. package/src/clients/modules/tendermintClient.ts +13 -36
  134. package/src/clients/native.ts +73 -139
  135. package/src/clients/noble-client.ts +1 -5
  136. package/src/clients/socket-client.ts +216 -216
  137. package/src/clients/subaccount.ts +16 -16
  138. package/src/clients/types.ts +14 -10
  139. package/src/clients/validator-client.ts +14 -16
  140. package/src/codegen/helpers.ts +149 -150
  141. package/src/codegen/index.ts +4 -5
  142. package/src/lib/errors.ts +3 -9
  143. package/src/lib/onboarding.ts +7 -2
  144. package/src/lib/utils.ts +5 -12
  145. package/src/lib/validation.ts +21 -19
  146. package/src/network_optimizer.ts +78 -65
  147. package/src/types.ts +5 -6
  148. package/tasks.json +15 -15
  149. package/tsconfig.eslint.json +1 -4
  150. package/tsconfig.json +2 -6
@@ -1,17 +1,17 @@
1
1
  /**
2
- * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
- * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
- * and run the transpile command or yarn proto command to regenerate this bundle.
5
- */
2
+ * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
+ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
+ * and run the transpile command or yarn proto command to regenerate this bundle.
5
+ */
6
6
 
7
- import * as _m0 from "protobufjs/minimal";
7
+ import * as _m0 from 'protobufjs/minimal';
8
8
  import Long from 'long';
9
9
 
10
10
  // @ts-ignore
11
11
  if (_m0.util.Long !== Long) {
12
- _m0.util.Long = (Long as any);
12
+ _m0.util.Long = Long as any;
13
13
 
14
- _m0.configure();
14
+ _m0.configure();
15
15
  }
16
16
 
17
17
  export { Long };
@@ -20,204 +20,203 @@ declare var self: any | undefined;
20
20
  declare var window: any | undefined;
21
21
  declare var global: any | undefined;
22
22
  var globalThis: any = (() => {
23
- if (typeof globalThis !== 'undefined') return globalThis;
24
- if (typeof self !== 'undefined') return self;
25
- if (typeof window !== 'undefined') return window;
26
- if (typeof global !== 'undefined') return global;
27
- throw 'Unable to locate global object';
23
+ if (typeof globalThis !== 'undefined') return globalThis;
24
+ if (typeof self !== 'undefined') return self;
25
+ if (typeof window !== 'undefined') return window;
26
+ if (typeof global !== 'undefined') return global;
27
+ throw 'Unable to locate global object';
28
28
  })();
29
29
 
30
30
  const atob: (b64: string) => string =
31
- globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
31
+ globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
32
32
 
33
33
  export function bytesFromBase64(b64: string): Uint8Array {
34
- const bin = atob(b64);
35
- const arr = new Uint8Array(bin.length);
36
- for (let i = 0; i < bin.length; ++i) {
37
- arr[i] = bin.charCodeAt(i);
38
- }
39
- return arr;
34
+ const bin = atob(b64);
35
+ const arr = new Uint8Array(bin.length);
36
+ for (let i = 0; i < bin.length; ++i) {
37
+ arr[i] = bin.charCodeAt(i);
38
+ }
39
+ return arr;
40
40
  }
41
41
 
42
42
  const btoa: (bin: string) => string =
43
- globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
43
+ globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
44
44
 
45
45
  export function base64FromBytes(arr: Uint8Array): string {
46
- const bin: string[] = [];
47
- arr.forEach((byte) => {
48
- bin.push(String.fromCharCode(byte));
49
- });
50
- return btoa(bin.join(''));
46
+ const bin: string[] = [];
47
+ arr.forEach((byte) => {
48
+ bin.push(String.fromCharCode(byte));
49
+ });
50
+ return btoa(bin.join(''));
51
51
  }
52
52
 
53
53
  export interface AminoHeight {
54
- readonly revision_number?: string;
55
- readonly revision_height?: string;
56
- };
54
+ readonly revision_number?: string;
55
+ readonly revision_height?: string;
56
+ }
57
57
 
58
58
  export function omitDefault<T extends string | number | Long>(input: T): T | undefined {
59
- if (typeof input === "string") {
60
- return input === "" ? undefined : input;
61
- }
59
+ if (typeof input === 'string') {
60
+ return input === '' ? undefined : input;
61
+ }
62
62
 
63
- if (typeof input === "number") {
64
- return input === 0 ? undefined : input;
65
- }
63
+ if (typeof input === 'number') {
64
+ return input === 0 ? undefined : input;
65
+ }
66
66
 
67
- if (Long.isLong(input)) {
68
- return input.isZero() ? undefined : input;
69
- }
67
+ if (Long.isLong(input)) {
68
+ return input.isZero() ? undefined : input;
69
+ }
70
70
 
71
- throw new Error(`Got unsupported type ${typeof input}`);
72
- };
71
+ throw new Error(`Got unsupported type ${typeof input}`);
72
+ }
73
73
 
74
74
  interface Duration {
75
- /**
76
- * Signed seconds of the span of time. Must be from -315,576,000,000
77
- * to +315,576,000,000 inclusive. Note: these bounds are computed from:
78
- * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
79
- */
80
- seconds: Long;
81
- /**
82
- * Signed fractions of a second at nanosecond resolution of the span
83
- * of time. Durations less than one second are represented with a 0
84
- * `seconds` field and a positive or negative `nanos` field. For durations
85
- * of one second or more, a non-zero value for the `nanos` field must be
86
- * of the same sign as the `seconds` field. Must be from -999,999,999
87
- * to +999,999,999 inclusive.
88
- */
89
-
90
- nanos: number;
75
+ /**
76
+ * Signed seconds of the span of time. Must be from -315,576,000,000
77
+ * to +315,576,000,000 inclusive. Note: these bounds are computed from:
78
+ * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
79
+ */
80
+ seconds: Long;
81
+ /**
82
+ * Signed fractions of a second at nanosecond resolution of the span
83
+ * of time. Durations less than one second are represented with a 0
84
+ * `seconds` field and a positive or negative `nanos` field. For durations
85
+ * of one second or more, a non-zero value for the `nanos` field must be
86
+ * of the same sign as the `seconds` field. Must be from -999,999,999
87
+ * to +999,999,999 inclusive.
88
+ */
89
+
90
+ nanos: number;
91
91
  }
92
92
 
93
93
  export function toDuration(duration: string): Duration {
94
- return {
95
- seconds: Long.fromNumber(Math.floor(parseInt(duration) / 1000000000)),
96
- nanos: parseInt(duration) % 1000000000
97
- };
98
- };
94
+ return {
95
+ seconds: Long.fromNumber(Math.floor(parseInt(duration) / 1000000000)),
96
+ nanos: parseInt(duration) % 1000000000,
97
+ };
98
+ }
99
99
 
100
100
  export function fromDuration(duration: Duration): string {
101
- return (parseInt(duration.seconds.toString()) * 1000000000 + duration.nanos).toString();
102
- };
101
+ return (parseInt(duration.seconds.toString()) * 1000000000 + duration.nanos).toString();
102
+ }
103
103
 
104
104
  export function isSet(value: any): boolean {
105
- return value !== null && value !== undefined;
106
- };
105
+ return value !== null && value !== undefined;
106
+ }
107
107
 
108
108
  export function isObject(value: any): boolean {
109
- return typeof value === 'object' && value !== null;
110
- };
109
+ return typeof value === 'object' && value !== null;
110
+ }
111
111
 
112
112
  export interface PageRequest {
113
- key: Uint8Array;
114
- offset: Long;
115
- limit: Long;
116
- countTotal: boolean;
117
- reverse: boolean;
118
- };
113
+ key: Uint8Array;
114
+ offset: Long;
115
+ limit: Long;
116
+ countTotal: boolean;
117
+ reverse: boolean;
118
+ }
119
119
 
120
120
  export interface PageRequestParams {
121
- "pagination.key"?: string;
122
- "pagination.offset"?: string;
123
- "pagination.limit"?: string;
124
- "pagination.count_total"?: boolean;
125
- "pagination.reverse"?: boolean;
126
- };
121
+ 'pagination.key'?: string;
122
+ 'pagination.offset'?: string;
123
+ 'pagination.limit'?: string;
124
+ 'pagination.count_total'?: boolean;
125
+ 'pagination.reverse'?: boolean;
126
+ }
127
127
 
128
128
  export interface Params {
129
- params: PageRequestParams;
130
- };
129
+ params: PageRequestParams;
130
+ }
131
131
 
132
132
  export const setPaginationParams = (options: Params, pagination?: PageRequest) => {
133
+ if (!pagination) {
134
+ return options;
135
+ }
133
136
 
134
- if (!pagination) {
135
- return options;
136
- }
137
-
138
- if (typeof pagination?.countTotal !== "undefined") {
139
- options.params['pagination.count_total'] = pagination.countTotal;
140
- }
141
- if (typeof pagination?.key !== "undefined") {
142
- // String to Uint8Array
143
- // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
144
-
145
- // Uint8Array to String
146
- options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
147
- }
148
- if (typeof pagination?.limit !== "undefined") {
149
- options.params["pagination.limit"] = pagination.limit.toString()
150
- }
151
- if (typeof pagination?.offset !== "undefined") {
152
- options.params["pagination.offset"] = pagination.offset.toString()
153
- }
154
- if (typeof pagination?.reverse !== "undefined") {
155
- options.params['pagination.reverse'] = pagination.reverse;
156
- }
137
+ if (typeof pagination?.countTotal !== 'undefined') {
138
+ options.params['pagination.count_total'] = pagination.countTotal;
139
+ }
140
+ if (typeof pagination?.key !== 'undefined') {
141
+ // String to Uint8Array
142
+ // let uint8arr = new Uint8Array(Buffer.from(data,'base64'));
157
143
 
158
- return options;
144
+ // Uint8Array to String
145
+ options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64');
146
+ }
147
+ if (typeof pagination?.limit !== 'undefined') {
148
+ options.params['pagination.limit'] = pagination.limit.toString();
149
+ }
150
+ if (typeof pagination?.offset !== 'undefined') {
151
+ options.params['pagination.offset'] = pagination.offset.toString();
152
+ }
153
+ if (typeof pagination?.reverse !== 'undefined') {
154
+ options.params['pagination.reverse'] = pagination.reverse;
155
+ }
156
+
157
+ return options;
159
158
  };
160
159
 
161
160
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
162
161
 
163
162
  export type DeepPartial<T> = T extends Builtin
164
- ? T
165
- : T extends Long
163
+ ? T
164
+ : T extends Long
166
165
  ? string | number | Long
167
166
  : T extends Array<infer U>
168
- ? Array<DeepPartial<U>>
169
- : T extends ReadonlyArray<infer U>
170
- ? ReadonlyArray<DeepPartial<U>>
171
- : T extends {}
172
- ? { [K in keyof T]?: DeepPartial<T[K]> }
173
- : Partial<T>;
167
+ ? Array<DeepPartial<U>>
168
+ : T extends ReadonlyArray<infer U>
169
+ ? ReadonlyArray<DeepPartial<U>>
170
+ : T extends {}
171
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
172
+ : Partial<T>;
174
173
 
175
174
  type KeysOfUnion<T> = T extends T ? keyof T : never;
176
175
  export type Exact<P, I extends P> = P extends Builtin
177
- ? P
178
- : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
176
+ ? P
177
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
179
178
 
180
179
  export interface Rpc {
181
- request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
182
- };
180
+ request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
181
+ }
183
182
 
184
183
  interface Timestamp {
185
- /**
186
- * Represents seconds of UTC time since Unix epoch
187
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
188
- * 9999-12-31T23:59:59Z inclusive.
189
- */
190
- seconds: Long;
191
- /**
192
- * Non-negative fractions of a second at nanosecond resolution. Negative
193
- * second values with fractions must still have non-negative nanos values
194
- * that count forward in time. Must be from 0 to 999,999,999
195
- * inclusive.
196
- */
197
-
198
- nanos: number;
184
+ /**
185
+ * Represents seconds of UTC time since Unix epoch
186
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
187
+ * 9999-12-31T23:59:59Z inclusive.
188
+ */
189
+ seconds: Long;
190
+ /**
191
+ * Non-negative fractions of a second at nanosecond resolution. Negative
192
+ * second values with fractions must still have non-negative nanos values
193
+ * that count forward in time. Must be from 0 to 999,999,999
194
+ * inclusive.
195
+ */
196
+
197
+ nanos: number;
199
198
  }
200
199
 
201
200
  export function toTimestamp(date: Date): Timestamp {
202
- const seconds = numberToLong(date.getTime() / 1_000);
203
- const nanos = date.getTime() % 1000 * 1000000;
204
- return {
205
- seconds,
206
- nanos
207
- };
208
- };
201
+ const seconds = numberToLong(date.getTime() / 1_000);
202
+ const nanos = (date.getTime() % 1000) * 1000000;
203
+ return {
204
+ seconds,
205
+ nanos,
206
+ };
207
+ }
209
208
 
210
209
  export function fromTimestamp(t: Timestamp): Date {
211
- let millis = t.seconds.toNumber() * 1000;
212
- millis += t.nanos / 1000000;
213
- return new Date(millis);
214
- };
210
+ let millis = t.seconds.toNumber() * 1000;
211
+ millis += t.nanos / 1000000;
212
+ return new Date(millis);
213
+ }
215
214
 
216
215
  const fromJSON = (object: any): Timestamp => {
217
- return {
218
- seconds: isSet(object.seconds) ? Long.fromString(object.seconds) : Long.ZERO,
219
- nanos: isSet(object.nanos) ? Number(object.nanos) : 0
220
- };
216
+ return {
217
+ seconds: isSet(object.seconds) ? Long.fromString(object.seconds) : Long.ZERO,
218
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
219
+ };
221
220
  };
222
221
 
223
222
  const timestampFromJSON = (object: any): Timestamp => {
@@ -225,18 +224,18 @@ const timestampFromJSON = (object: any): Timestamp => {
225
224
  seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO,
226
225
  nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
227
226
  };
228
- }
229
-
227
+ };
228
+
230
229
  export function fromJsonTimestamp(o: any): Timestamp {
231
230
  if (o instanceof Date) {
232
231
  return toTimestamp(o);
233
- } else if (typeof o === "string") {
232
+ } else if (typeof o === 'string') {
234
233
  return toTimestamp(new Date(o));
235
234
  } else {
236
235
  return timestampFromJSON(o);
237
236
  }
238
237
  }
239
-
238
+
240
239
  function numberToLong(number: number) {
241
- return Long.fromNumber(number);
240
+ return Long.fromNumber(number);
242
241
  }
@@ -1,6 +1,5 @@
1
1
  /**
2
- * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
- * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
- * and run the transpile command or yarn proto command to regenerate this bundle.
5
- */
6
-
2
+ * This file and any referenced files were automatically generated by @osmonauts/telescope@0.80.0
3
+ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
4
+ * and run the transpile command or yarn proto command to regenerate this bundle.
5
+ */
package/src/lib/errors.ts CHANGED
@@ -1,13 +1,10 @@
1
- import {
2
- BroadcastTxSyncResponse,
3
- } from '@cosmjs/tendermint-rpc/build/tendermint37';
1
+ import { BroadcastTxSyncResponse } from '@cosmjs/tendermint-rpc/build/tendermint37';
4
2
 
5
3
  /**
6
4
  * An edge-case was hit in the client that should never have been reached.
7
5
  */
8
6
  export class UnexpectedClientError extends Error {
9
- constructor(
10
- ) {
7
+ constructor() {
11
8
  super('An unexpected error occurred on the client');
12
9
  this.name = 'UnexpectedClientError';
13
10
  }
@@ -21,10 +18,7 @@ export class BroadcastErrorObject extends Error {
21
18
  code: number;
22
19
  codespace?: string;
23
20
 
24
- constructor(
25
- message: string,
26
- result: BroadcastTxSyncResponse,
27
- ) {
21
+ constructor(message: string, result: BroadcastTxSyncResponse) {
28
22
  super(message);
29
23
  this.name = 'BroadcastError';
30
24
  this.result = result;
@@ -18,7 +18,10 @@ import { stripHexPrefix } from './helpers';
18
18
  *
19
19
  * @returns Mnemonic and priv/pub keys
20
20
  */
21
- export const exportMnemonicAndPrivateKey = (entropy: Uint8Array, path: string = "m/44'/118'/0'/0/0"): {
21
+ export const exportMnemonicAndPrivateKey = (
22
+ entropy: Uint8Array,
23
+ path: string = "m/44'/118'/0'/0/0",
24
+ ): {
22
25
  mnemonic: string;
23
26
  privateKey: Uint8Array | null;
24
27
  publicKey: Uint8Array | null;
@@ -45,7 +48,9 @@ export const exportMnemonicAndPrivateKey = (entropy: Uint8Array, path: string =
45
48
  *
46
49
  * @returns Mnemonic and Public/Private HD keys
47
50
  */
48
- export const deriveHDKeyFromEthereumSignature = (signature: string): {
51
+ export const deriveHDKeyFromEthereumSignature = (
52
+ signature: string,
53
+ ): {
49
54
  mnemonic: string;
50
55
  privateKey: Uint8Array | null;
51
56
  publicKey: Uint8Array | null;
package/src/lib/utils.ts CHANGED
@@ -3,9 +3,7 @@ import { MAX_UINT_32 } from '../clients/constants';
3
3
  /**
4
4
  * Returns a random integer value between 0 and (n-1).
5
5
  */
6
- export function randomInt(
7
- n: number,
8
- ): number {
6
+ export function randomInt(n: number): number {
9
7
  return Math.floor(Math.random() * n);
10
8
  }
11
9
 
@@ -20,19 +18,17 @@ export function generateRandomClientId(): number {
20
18
  * Deterministically generate a valid clientId from an arbitrary string by performing a
21
19
  * quick hashing function on the string.
22
20
  */
23
- export function clientIdFromString(
24
- input: string,
25
- ): number {
21
+ export function clientIdFromString(input: string): number {
26
22
  let hash: number = 0;
27
23
  if (input.length === 0) return hash;
28
24
  for (let i = 0; i < input.length; i++) {
29
- hash = ((hash << 5) - hash) + input.charCodeAt(i); // eslint-disable-line no-bitwise
25
+ hash = (hash << 5) - hash + input.charCodeAt(i); // eslint-disable-line no-bitwise
30
26
  hash |= 0; // eslint-disable-line no-bitwise
31
27
  }
32
28
 
33
29
  // Bitwise operators covert the value to a 32-bit integer.
34
30
  // We must coerce this into a 32-bit unsigned integer.
35
- return hash + (2 ** 31);
31
+ return hash + 2 ** 31;
36
32
  }
37
33
 
38
34
  /**
@@ -61,9 +57,6 @@ export function getGovAddNewMarketTitle(ticker: string): string {
61
57
  * @param delayBlocks number of blocks to wait before activating the market.
62
58
  * @returns summary for the gov proposal.
63
59
  */
64
- export function getGovAddNewMarketSummary(
65
- ticker: string,
66
- delayBlocks: number,
67
- ): string {
60
+ export function getGovAddNewMarketSummary(ticker: string, delayBlocks: number): string {
68
61
  return `Add the x/prices, x/perpetuals and x/clob parameters needed for a ${ticker} perpetual market. Create the market in INITIALIZING status and transition it to ACTIVE status after ${delayBlocks} blocks.`;
69
62
  }
@@ -2,12 +2,7 @@ import { decode } from 'bech32';
2
2
  import Long from 'long';
3
3
 
4
4
  import { MAX_SUBACCOUNT_NUMBER, MAX_UINT_32 } from '../clients/constants';
5
- import {
6
- Transfer,
7
- OrderFlags,
8
- ICancelOrder,
9
- IPlaceOrder,
10
- } from '../clients/types';
5
+ import { Transfer, OrderFlags, ICancelOrder, IPlaceOrder } from '../clients/types';
11
6
  import { UserError } from './errors';
12
7
 
13
8
  /**
@@ -36,7 +31,9 @@ export function validatePlaceOrderMessage(
36
31
  return new UserError(`goodTilBlock: ${order.goodTilBlock} is not a valid uint32 or is 0`);
37
32
  }
38
33
  if (isStatefulOrder(order.orderFlags) && !verifyGoodTilBlockTime(order.goodTilBlockTime)) {
39
- return new UserError(`goodTilBlockTime: ${order.goodTilBlockTime} is not a valid uint32 or is 0`);
34
+ return new UserError(
35
+ `goodTilBlockTime: ${order.goodTilBlockTime} is not a valid uint32 or is 0`,
36
+ );
40
37
  }
41
38
 
42
39
  return undefined;
@@ -57,13 +54,19 @@ export function validateCancelOrderMessage(
57
54
  return new UserError(`goodTilBlock: ${order.goodTilBlock} is not a valid uint32 or is 0`);
58
55
  }
59
56
  if (!isStatefulOrder(order.orderFlags) && order.goodTilBlockTime !== undefined) {
60
- return new UserError(`goodTilBlockTime is ${order.goodTilBlockTime}, but should not be set for non-stateful orders`);
57
+ return new UserError(
58
+ `goodTilBlockTime is ${order.goodTilBlockTime}, but should not be set for non-stateful orders`,
59
+ );
61
60
  }
62
61
  if (isStatefulOrder(order.orderFlags) && !verifyGoodTilBlockTime(order.goodTilBlockTime)) {
63
- return new UserError(`goodTilBlockTime: ${order.goodTilBlockTime} is not a valid uint32 or is 0`);
62
+ return new UserError(
63
+ `goodTilBlockTime: ${order.goodTilBlockTime} is not a valid uint32 or is 0`,
64
+ );
64
65
  }
65
66
  if (isStatefulOrder(order.orderFlags) && order.goodTilBlock !== undefined) {
66
- return new UserError(`goodTilBlock is ${order.goodTilBlock}, but should not be set for stateful orders`);
67
+ return new UserError(
68
+ `goodTilBlock is ${order.goodTilBlock}, but should not be set for stateful orders`,
69
+ );
67
70
  }
68
71
  if (!verifySubaccountNumber(subaccountNumber)) {
69
72
  return new UserError(
@@ -90,14 +93,10 @@ export function validateTransferMessage(transfer: Transfer): UserError | undefin
90
93
  );
91
94
  }
92
95
  if (transfer.assetId !== 0) {
93
- return new UserError(
94
- `asset id: ${transfer.assetId} not supported`,
95
- );
96
+ return new UserError(`asset id: ${transfer.assetId} not supported`);
96
97
  }
97
98
  if (transfer.amount.lessThanOrEqual(Long.ZERO)) {
98
- return new UserError(
99
- `amount: ${transfer.amount} cannot be <= 0`,
100
- );
99
+ return new UserError(`amount: ${transfer.amount} cannot be <= 0`);
101
100
  }
102
101
 
103
102
  const addressError: Error | undefined = verifyIsBech32(transfer.recipient!!.owner);
@@ -132,8 +131,11 @@ function verifyNumberIsUint32(num: number): boolean {
132
131
  }
133
132
 
134
133
  export function verifyOrderFlags(orderFlags: OrderFlags): boolean {
135
- return orderFlags === OrderFlags.SHORT_TERM ||
136
- orderFlags === OrderFlags.LONG_TERM || orderFlags === OrderFlags.CONDITIONAL;
134
+ return (
135
+ orderFlags === OrderFlags.SHORT_TERM ||
136
+ orderFlags === OrderFlags.LONG_TERM ||
137
+ orderFlags === OrderFlags.CONDITIONAL
138
+ );
137
139
  }
138
140
 
139
141
  export function isStatefulOrder(orderFlags: OrderFlags): boolean {
@@ -152,5 +154,5 @@ function verifyIsBech32(address: string): Error | undefined {
152
154
 
153
155
  export function isValidAddress(address: string): boolean {
154
156
  // An address is valid if it starts with `dydx1` and is Bech32 format.
155
- return address.startsWith('dydx1') && (verifyIsBech32(address) === undefined);
157
+ return address.startsWith('dydx1') && verifyIsBech32(address) === undefined;
156
158
  }