@dydxprotocol/v4-client-js 3.2.0 → 3.3.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/CHANGELOG.md +8 -3
- package/build/cjs/src/clients/lib/axios/types.js +1 -1
- package/build/cjs/src/clients/modules/rest.js +9 -1
- package/build/cjs/src/clients/modules/utility.js +9 -1
- package/build/cjs/src/clients/types.js +1 -1
- package/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/build/esm/src/clients/lib/axios/types.d.ts +5 -0
- package/build/esm/src/clients/lib/axios/types.d.ts.map +1 -1
- package/build/esm/src/clients/lib/axios/types.js +1 -1
- package/build/esm/src/clients/modules/rest.d.ts +1 -0
- package/build/esm/src/clients/modules/rest.d.ts.map +1 -1
- package/build/esm/src/clients/modules/rest.js +9 -1
- package/build/esm/src/clients/modules/utility.d.ts +6 -1
- package/build/esm/src/clients/modules/utility.d.ts.map +1 -1
- package/build/esm/src/clients/modules/utility.js +9 -1
- package/build/esm/src/clients/types.d.ts +2 -0
- package/build/esm/src/clients/types.d.ts.map +1 -1
- package/build/esm/src/clients/types.js +1 -1
- package/build/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/clients/lib/axios/types.ts +7 -0
- package/src/clients/modules/rest.ts +10 -0
- package/src/clients/modules/utility.ts +10 -0
- package/src/clients/types.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type { AxiosResponseHeaders } from 'axios';
|
|
2
|
+
|
|
1
3
|
export enum RequestMethod {
|
|
2
4
|
POST = 'POST',
|
|
3
5
|
PUT = 'PUT',
|
|
4
6
|
GET = 'GET',
|
|
5
7
|
DELETE = 'DELETE',
|
|
6
8
|
}
|
|
9
|
+
|
|
10
|
+
export interface AxiosResponseWithGeoHeaders<Data> {
|
|
11
|
+
data: Data;
|
|
12
|
+
headers: AxiosResponseHeaders;
|
|
13
|
+
}
|
|
@@ -28,6 +28,16 @@ export default class RestClient {
|
|
|
28
28
|
return response.data;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
async getWithResponseHeaders(requestPath: string, params: {} = {}): Promise<Data> {
|
|
32
|
+
const url = `${this.host}${generateQueryPath(requestPath, params)}`;
|
|
33
|
+
const response = await this.axiosInstance.get(url);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
data: response.data,
|
|
37
|
+
headers: response.headers,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
async post(
|
|
32
42
|
requestPath: string,
|
|
33
43
|
params: {} = {},
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
ComplianceResponse,
|
|
3
3
|
ComplianceV2Response,
|
|
4
4
|
HeightResponse,
|
|
5
|
+
HeightResponseWithHeaders,
|
|
5
6
|
TimeResponse,
|
|
6
7
|
} from '../types';
|
|
7
8
|
import RestClient from './rest';
|
|
@@ -25,6 +26,15 @@ export default class UtilityClient extends RestClient {
|
|
|
25
26
|
return this.get(uri);
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @description Get the block height of the most recent block processed by the Indexer
|
|
31
|
+
* @returns {HeightResponse} block height and time
|
|
32
|
+
*/
|
|
33
|
+
async getHeightWithHeaders(): Promise<HeightResponseWithHeaders> {
|
|
34
|
+
const uri = '/v4/height';
|
|
35
|
+
return this.getWithResponseHeaders(uri);
|
|
36
|
+
}
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* @description Screen an address to see if it is restricted
|
|
30
40
|
* @param {string} address evm or dydx address
|
package/src/clients/types.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { PerpetualMarketType } from '@dydxprotocol/v4-proto/src/codegen/dydxprot
|
|
|
9
9
|
import BigNumber from 'bignumber.js';
|
|
10
10
|
import Long from 'long';
|
|
11
11
|
|
|
12
|
+
import { AxiosResponseWithGeoHeaders } from './lib/axios/types';
|
|
13
|
+
|
|
12
14
|
export type Integer = BigNumber;
|
|
13
15
|
|
|
14
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -119,6 +121,8 @@ export interface HeightResponse {
|
|
|
119
121
|
time: string;
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
export type HeightResponseWithHeaders = AxiosResponseWithGeoHeaders<HeightResponse>;
|
|
125
|
+
|
|
122
126
|
export interface ComplianceResponse {
|
|
123
127
|
restricted: boolean;
|
|
124
128
|
reason?: string;
|