File tree Expand file tree Collapse file tree 6 files changed +33
-2
lines changed
Expand file tree Collapse file tree 6 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @dydxprotocol/v4-client-js" ,
3- "version" : " 1.3.17 " ,
3+ "version" : " 3.2.1 " ,
44 "description" : " General client library for the new dYdX system (v4 decentralized)" ,
55 "main" : " build/cjs/src/index.js" ,
66 "module" : " build/esm/src/index.js" ,
Original file line number Diff line number Diff line change 1+ import type { AxiosResponseHeaders } from 'axios' ;
2+
13export enum RequestMethod {
24 POST = 'POST' ,
35 PUT = 'PUT' ,
46 GET = 'GET' ,
57 DELETE = 'DELETE' ,
68}
9+
10+ export interface AxiosResponseWithGeoHeaders < Data > {
11+ data : Data ;
12+ headers : AxiosResponseHeaders ;
13+ }
Original file line number Diff line number Diff line change @@ -28,6 +28,16 @@ export default class RestClient {
2828 return response . data ;
2929 }
3030
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+
3141 async post (
3242 requestPath : string ,
3343 params : { } = { } ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type {
22 ComplianceResponse ,
33 ComplianceV2Response ,
44 HeightResponse ,
5+ HeightResponseWithHeaders ,
56 TimeResponse ,
67} from '../types' ;
78import RestClient from './rest' ;
@@ -25,6 +26,15 @@ export default class UtilityClient extends RestClient {
2526 return this . get ( uri ) ;
2627 }
2728
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+
2838 /**
2939 * @description Screen an address to see if it is restricted
3040 * @param {string } address evm or dydx address
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ import { PerpetualMarketType } from '@dydxprotocol/v4-proto/src/codegen/dydxprot
99import BigNumber from 'bignumber.js' ;
1010import Long from 'long' ;
1111
12+ import { AxiosResponseWithGeoHeaders } from './lib/axios/types' ;
13+
1214export type Integer = BigNumber ;
1315
1416// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -119,6 +121,8 @@ export interface HeightResponse {
119121 time : string ;
120122}
121123
124+ export type HeightResponseWithHeaders = AxiosResponseWithGeoHeaders < HeightResponse > ;
125+
122126export interface ComplianceResponse {
123127 restricted : boolean ;
124128 reason ?: string ;
You can’t perform that action at this time.
0 commit comments