@dydxprotocol/v4-client-js 0.35.0 → 0.36.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/__native__/__ios__/v4-native-client.js +1026 -3963
- package/__native__/__ios__/v4-native-client.js.map +1 -0
- package/__tests__/modules/client/MarketsEndpoints.test.ts +1 -15
- package/__tests__/modules/client/UtilityEndpoints.test.ts +29 -0
- package/build/__tests__/modules/client/MarketsEndpoints.test.js +2 -14
- package/build/__tests__/modules/client/UtilityEndpoints.test.d.ts +1 -0
- package/build/__tests__/modules/client/UtilityEndpoints.test.js +28 -0
- package/build/examples/markets_endpoints.d.ts +1 -1
- package/build/examples/markets_endpoints.js +2 -28
- package/build/examples/utility_endpoints.d.ts +4 -0
- package/build/examples/utility_endpoints.js +41 -0
- package/build/src/clients/indexer-client.d.ts +6 -0
- package/build/src/clients/indexer-client.js +9 -1
- package/build/src/clients/modules/markets.d.ts +0 -2
- package/build/src/clients/modules/markets.js +1 -9
- package/build/src/clients/modules/utility.d.ts +20 -0
- package/build/src/clients/modules/utility.js +35 -0
- package/build/src/clients/types.d.ts +11 -0
- package/build/src/clients/types.js +1 -1
- package/build/src/network_optimizer.js +1 -1
- package/build/src/types.d.ts +0 -11
- package/build/src/types.js +2 -10
- package/examples/markets_endpoints.ts +1 -27
- package/examples/utility_endpoints.ts +41 -0
- package/package.json +1 -1
- package/src/clients/indexer-client.ts +10 -0
- package/src/clients/modules/markets.ts +0 -10
- package/src/clients/modules/utility.ts +32 -0
- package/src/clients/types.ts +15 -0
- package/src/network_optimizer.ts +1 -1
- package/src/types.ts +0 -14
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ComplianceResponse, HeightResponse, TimeResponse } from '../types';
|
|
2
|
+
import RestClient from './rest';
|
|
3
|
+
|
|
4
|
+
export default class UtilityClient extends RestClient {
|
|
5
|
+
/**
|
|
6
|
+
* @description Get the current time of the Indexer
|
|
7
|
+
* @returns {TimeResponse} isoString and epoch
|
|
8
|
+
*/
|
|
9
|
+
async getTime(): Promise<TimeResponse> {
|
|
10
|
+
const uri = '/v4/time';
|
|
11
|
+
return this.get(uri);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @description Get the block height of the most recent block processed by the Indexer
|
|
16
|
+
* @returns {HeightResponse} block height and time
|
|
17
|
+
*/
|
|
18
|
+
async getHeight(): Promise<HeightResponse> {
|
|
19
|
+
const uri = '/v4/height';
|
|
20
|
+
return this.get(uri);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @description Screen an address to see if it is restricted
|
|
25
|
+
* @param {string} address evm or dydx address
|
|
26
|
+
* @returns {ComplianceResponse} whether the specified address is restricted
|
|
27
|
+
*/
|
|
28
|
+
async screen(address: string): Promise<ComplianceResponse> {
|
|
29
|
+
const uri = '/v4/screen';
|
|
30
|
+
return this.get(uri, { address });
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/clients/types.ts
CHANGED
|
@@ -70,4 +70,19 @@ export type BroadcastMode = (
|
|
|
70
70
|
Method.BroadcastTxAsync | Method.BroadcastTxSync | Method.BroadcastTxCommit
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
+
// ------ Utility Endpoint Responses ------ //
|
|
74
|
+
export interface TimeResponse {
|
|
75
|
+
iso: string;
|
|
76
|
+
epoch: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface HeightResponse {
|
|
80
|
+
height: number;
|
|
81
|
+
time: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface ComplianceResponse {
|
|
85
|
+
restricted: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
73
88
|
export * from './modules/proto-includes';
|
package/src/network_optimizer.ts
CHANGED
|
@@ -89,7 +89,7 @@ export class NetworkOptimizer {
|
|
|
89
89
|
const responses = (await Promise.all(
|
|
90
90
|
clients
|
|
91
91
|
.map(async (client) => {
|
|
92
|
-
const block = await client.
|
|
92
|
+
const block = await client.utility.getHeight();
|
|
93
93
|
const response = new PingResponse(+block.height);
|
|
94
94
|
return {
|
|
95
95
|
endpoint: client.config.restEndpoint,
|
package/src/types.ts
CHANGED
|
@@ -42,17 +42,3 @@ export interface Options {
|
|
|
42
42
|
export enum ClobPairId {
|
|
43
43
|
PERPETUAL_PAIR_BTC_USD = 0,
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
export enum MarketId {
|
|
47
|
-
PERPETUAL_PRICE_BTC_USD = 0,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export enum PerpetualId {
|
|
51
|
-
PERPETUAL_BTC_USD = 0,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface FaucetRequest {
|
|
55
|
-
address: string;
|
|
56
|
-
subaccountNumber: number;
|
|
57
|
-
amount: number;
|
|
58
|
-
}
|