chore(): run trailing comma linter, disable noisy test while in discussion with bybit
This commit is contained in:
@@ -31,6 +31,7 @@ if (
|
|||||||
method: response.config.method,
|
method: response.config.method,
|
||||||
data: response.config.data,
|
data: response.config.data,
|
||||||
headers: response.config.headers,
|
headers: response.config.headers,
|
||||||
|
params: response.config.params,
|
||||||
},
|
},
|
||||||
response: {
|
response: {
|
||||||
status: response.status,
|
status: response.status,
|
||||||
@@ -101,7 +102,7 @@ export default abstract class BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
restOptions: RestClientOptions = {},
|
restOptions: RestClientOptions = {},
|
||||||
networkOptions: AxiosRequestConfig = {}
|
networkOptions: AxiosRequestConfig = {},
|
||||||
) {
|
) {
|
||||||
this.clientType = this.getClientType();
|
this.clientType = this.getClientType();
|
||||||
|
|
||||||
@@ -134,7 +135,7 @@ export default abstract class BaseRestClient {
|
|||||||
|
|
||||||
if (this.key && !this.secret) {
|
if (this.key && !this.secret) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'API Key & Secret are both required for private endpoints'
|
'API Key & Secret are both required for private endpoints',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,21 +173,21 @@ export default abstract class BaseRestClient {
|
|||||||
method: Method,
|
method: Method,
|
||||||
signMethod: SignMethod,
|
signMethod: SignMethod,
|
||||||
params?: TParams,
|
params?: TParams,
|
||||||
isPublicApi?: true
|
isPublicApi?: true,
|
||||||
): Promise<UnsignedRequest<TParams>>;
|
): Promise<UnsignedRequest<TParams>>;
|
||||||
|
|
||||||
private async prepareSignParams<TParams = any>(
|
private async prepareSignParams<TParams = any>(
|
||||||
method: Method,
|
method: Method,
|
||||||
signMethod: SignMethod,
|
signMethod: SignMethod,
|
||||||
params?: TParams,
|
params?: TParams,
|
||||||
isPublicApi?: false | undefined
|
isPublicApi?: false | undefined,
|
||||||
): Promise<SignedRequest<TParams>>;
|
): Promise<SignedRequest<TParams>>;
|
||||||
|
|
||||||
private async prepareSignParams<TParams extends SignedRequestContext = any>(
|
private async prepareSignParams<TParams extends SignedRequestContext = any>(
|
||||||
method: Method,
|
method: Method,
|
||||||
signMethod: SignMethod,
|
signMethod: SignMethod,
|
||||||
params?: TParams,
|
params?: TParams,
|
||||||
isPublicApi?: boolean
|
isPublicApi?: boolean,
|
||||||
) {
|
) {
|
||||||
if (isPublicApi) {
|
if (isPublicApi) {
|
||||||
return {
|
return {
|
||||||
@@ -211,7 +212,7 @@ export default abstract class BaseRestClient {
|
|||||||
method: Method,
|
method: Method,
|
||||||
url: string,
|
url: string,
|
||||||
params?: any,
|
params?: any,
|
||||||
isPublicApi?: boolean
|
isPublicApi?: boolean,
|
||||||
): Promise<AxiosRequestConfig> {
|
): Promise<AxiosRequestConfig> {
|
||||||
const options: AxiosRequestConfig = {
|
const options: AxiosRequestConfig = {
|
||||||
...this.globalRequestOptions,
|
...this.globalRequestOptions,
|
||||||
@@ -238,7 +239,7 @@ export default abstract class BaseRestClient {
|
|||||||
method,
|
method,
|
||||||
'v5auth',
|
'v5auth',
|
||||||
params,
|
params,
|
||||||
isPublicApi
|
isPublicApi,
|
||||||
);
|
);
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
@@ -269,7 +270,7 @@ export default abstract class BaseRestClient {
|
|||||||
method,
|
method,
|
||||||
'v2auth',
|
'v2auth',
|
||||||
params,
|
params,
|
||||||
isPublicApi
|
isPublicApi,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (method === 'GET' || this.isSpotV1Client()) {
|
if (method === 'GET' || this.isSpotV1Client()) {
|
||||||
@@ -292,11 +293,11 @@ export default abstract class BaseRestClient {
|
|||||||
method: Method,
|
method: Method,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
params?: any,
|
params?: any,
|
||||||
isPublicApi?: boolean
|
isPublicApi?: boolean,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
// Sanity check to make sure it's only ever prefixed by one forward slash
|
// Sanity check to make sure it's only ever prefixed by one forward slash
|
||||||
const requestUrl = [this.baseUrl, endpoint].join(
|
const requestUrl = [this.baseUrl, endpoint].join(
|
||||||
endpoint.startsWith('/') ? '' : '/'
|
endpoint.startsWith('/') ? '' : '/',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Build a request and handle signature process
|
// Build a request and handle signature process
|
||||||
@@ -304,7 +305,7 @@ export default abstract class BaseRestClient {
|
|||||||
method,
|
method,
|
||||||
requestUrl,
|
requestUrl,
|
||||||
params,
|
params,
|
||||||
isPublicApi
|
isPublicApi,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Dispatch request
|
// Dispatch request
|
||||||
@@ -355,7 +356,7 @@ export default abstract class BaseRestClient {
|
|||||||
private async signRequest<T extends SignedRequestContext | {} = {}>(
|
private async signRequest<T extends SignedRequestContext | {} = {}>(
|
||||||
data: T,
|
data: T,
|
||||||
method: Method,
|
method: Method,
|
||||||
signMethod: SignMethod
|
signMethod: SignMethod,
|
||||||
): Promise<SignedRequest<T>> {
|
): Promise<SignedRequest<T>> {
|
||||||
const timestamp = Date.now() + (this.timeOffset || 0);
|
const timestamp = Date.now() + (this.timeOffset || 0);
|
||||||
|
|
||||||
@@ -390,7 +391,7 @@ export default abstract class BaseRestClient {
|
|||||||
res.originalParams,
|
res.originalParams,
|
||||||
strictParamValidation,
|
strictParamValidation,
|
||||||
sortProperties,
|
sortProperties,
|
||||||
encodeSerialisedValues
|
encodeSerialisedValues,
|
||||||
)
|
)
|
||||||
: JSON.stringify(res.originalParams);
|
: JSON.stringify(res.originalParams);
|
||||||
|
|
||||||
@@ -426,7 +427,7 @@ export default abstract class BaseRestClient {
|
|||||||
res.originalParams,
|
res.originalParams,
|
||||||
strictParamValidation,
|
strictParamValidation,
|
||||||
sortProperties,
|
sortProperties,
|
||||||
encodeValues
|
encodeValues,
|
||||||
);
|
);
|
||||||
res.sign = await signMessage(res.serializedParams, this.secret);
|
res.sign = await signMessage(res.serializedParams, this.secret);
|
||||||
|
|
||||||
@@ -473,7 +474,7 @@ export default abstract class BaseRestClient {
|
|||||||
|
|
||||||
if (!serverTime || isNaN(serverTime)) {
|
if (!serverTime || isNaN(serverTime)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`fetchServerTime() returned non-number: "${serverTime}" typeof(${typeof serverTime})`
|
`fetchServerTime() returned non-number: "${serverTime}" typeof(${typeof serverTime})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
describe('Trade APIs', () => {
|
describe('Trade APIs', () => {
|
||||||
it('getActiveOrders()', async () => {
|
it('getActiveOrders()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getActiveOrders({ category: 'linear', settleCoin })
|
await api.getActiveOrders({ category: 'linear', settleCoin }),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
});
|
});
|
||||||
@@ -36,11 +36,12 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('getHistoricOrders()', async () => {
|
it('getHistoricOrders()', async () => {
|
||||||
expect(await api.getHistoricOrders({ category: 'linear' })).toMatchObject(
|
expect(await api.getHistoricOrders({ category: 'linear' })).toMatchObject(
|
||||||
{ ...successResponseObjectV3() }
|
{ ...successResponseObjectV3() },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getSpotBorrowCheck()', async () => {
|
// 10016 system errors - reached out to bybit on 13th April 2023
|
||||||
|
it.skip('getSpotBorrowCheck()', async () => {
|
||||||
expect(await api.getSpotBorrowCheck(linearSymbol, 'Buy')).toMatchObject({
|
expect(await api.getSpotBorrowCheck(linearSymbol, 'Buy')).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
});
|
});
|
||||||
@@ -50,7 +51,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
describe('Position APIs', () => {
|
describe('Position APIs', () => {
|
||||||
it('getPositionInfo()', async () => {
|
it('getPositionInfo()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getPositionInfo({ category: 'linear', settleCoin })
|
await api.getPositionInfo({ category: 'linear', settleCoin }),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
});
|
});
|
||||||
@@ -58,7 +59,10 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('getExecutionList()', async () => {
|
it('getExecutionList()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getExecutionList({ category: 'linear', symbol: linearSymbol })
|
await api.getExecutionList({
|
||||||
|
category: 'linear',
|
||||||
|
symbol: linearSymbol,
|
||||||
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
});
|
});
|
||||||
@@ -66,7 +70,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('getClosedPnL()', async () => {
|
it('getClosedPnL()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getClosedPnL({ category: 'linear', symbol: linearSymbol })
|
await api.getClosedPnL({ category: 'linear', symbol: linearSymbol }),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
});
|
});
|
||||||
@@ -76,7 +80,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
describe('Account APIs', () => {
|
describe('Account APIs', () => {
|
||||||
it('getWalletBalance()', async () => {
|
it('getWalletBalance()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getWalletBalance({ accountType: 'CONTRACT' })
|
await api.getWalletBalance({ accountType: 'CONTRACT' }),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({ ...successResponseObjectV3() });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,13 +142,13 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('getDeliveryRecord()', async () => {
|
it('getDeliveryRecord()', async () => {
|
||||||
expect(await api.getDeliveryRecord({ category: 'option' })).toMatchObject(
|
expect(await api.getDeliveryRecord({ category: 'option' })).toMatchObject(
|
||||||
{ ...successResponseObjectV3() }
|
{ ...successResponseObjectV3() },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getSettlementRecords()', async () => {
|
it('getSettlementRecords()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getSettlementRecords({ category: 'linear' })
|
await api.getSettlementRecords({ category: 'linear' }),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({ ...successResponseObjectV3() });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -156,19 +160,19 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('getAllCoinsBalance()', async () => {
|
it('getAllCoinsBalance()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getAllCoinsBalance({ accountType: 'SPOT' })
|
await api.getAllCoinsBalance({ accountType: 'SPOT' }),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({ ...successResponseObjectV3() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getCoinBalance()', async () => {
|
it('getCoinBalance()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getCoinBalance({ accountType: 'SPOT', coin: settleCoin })
|
await api.getCoinBalance({ accountType: 'SPOT', coin: settleCoin }),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({ ...successResponseObjectV3() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getTransferableCoinList()', async () => {
|
it('getTransferableCoinList()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getTransferableCoinList('SPOT', 'CONTRACT')
|
await api.getTransferableCoinList('SPOT', 'CONTRACT'),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({ ...successResponseObjectV3() });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -204,7 +208,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('getSubAccountDepositRecords()', async () => {
|
it('getSubAccountDepositRecords()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getSubAccountDepositRecords({ subMemberId: 'fakeid' })
|
await api.getSubAccountDepositRecords({ subMemberId: 'fakeid' }),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
// ...successResponseObjectV3(),
|
// ...successResponseObjectV3(),
|
||||||
// Expected, since sub account ID is fake
|
// Expected, since sub account ID is fake
|
||||||
@@ -220,7 +224,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('querySubMemberAddress()', async () => {
|
it('querySubMemberAddress()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.querySubMemberAddress(settleCoin, 'TRC20', 'fakeid')
|
await api.querySubMemberAddress(settleCoin, 'TRC20', 'fakeid'),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
// ...successResponseObjectV3(),
|
// ...successResponseObjectV3(),
|
||||||
// Expected, since sub account ID is fake
|
// Expected, since sub account ID is fake
|
||||||
|
|||||||
Reference in New Issue
Block a user