From fbd9235eb0b46960290b6f2451b79e19f458fd15 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Thu, 13 Apr 2023 12:23:36 +0100 Subject: [PATCH] chore(): run trailing comma linter, disable noisy test while in discussion with bybit --- src/util/BaseRestClient.ts | 31 ++++++++++++++++--------------- test/v5/private.read.test.ts | 32 ++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/util/BaseRestClient.ts b/src/util/BaseRestClient.ts index 5ad441e..ede093c 100644 --- a/src/util/BaseRestClient.ts +++ b/src/util/BaseRestClient.ts @@ -31,6 +31,7 @@ if ( method: response.config.method, data: response.config.data, headers: response.config.headers, + params: response.config.params, }, response: { status: response.status, @@ -101,7 +102,7 @@ export default abstract class BaseRestClient { */ constructor( restOptions: RestClientOptions = {}, - networkOptions: AxiosRequestConfig = {} + networkOptions: AxiosRequestConfig = {}, ) { this.clientType = this.getClientType(); @@ -134,7 +135,7 @@ export default abstract class BaseRestClient { if (this.key && !this.secret) { 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, signMethod: SignMethod, params?: TParams, - isPublicApi?: true + isPublicApi?: true, ): Promise>; private async prepareSignParams( method: Method, signMethod: SignMethod, params?: TParams, - isPublicApi?: false | undefined + isPublicApi?: false | undefined, ): Promise>; private async prepareSignParams( method: Method, signMethod: SignMethod, params?: TParams, - isPublicApi?: boolean + isPublicApi?: boolean, ) { if (isPublicApi) { return { @@ -211,7 +212,7 @@ export default abstract class BaseRestClient { method: Method, url: string, params?: any, - isPublicApi?: boolean + isPublicApi?: boolean, ): Promise { const options: AxiosRequestConfig = { ...this.globalRequestOptions, @@ -238,7 +239,7 @@ export default abstract class BaseRestClient { method, 'v5auth', params, - isPublicApi + isPublicApi, ); const headers = { @@ -269,7 +270,7 @@ export default abstract class BaseRestClient { method, 'v2auth', params, - isPublicApi + isPublicApi, ); if (method === 'GET' || this.isSpotV1Client()) { @@ -292,11 +293,11 @@ export default abstract class BaseRestClient { method: Method, endpoint: string, params?: any, - isPublicApi?: boolean + isPublicApi?: boolean, ): Promise { // Sanity check to make sure it's only ever prefixed by one forward slash const requestUrl = [this.baseUrl, endpoint].join( - endpoint.startsWith('/') ? '' : '/' + endpoint.startsWith('/') ? '' : '/', ); // Build a request and handle signature process @@ -304,7 +305,7 @@ export default abstract class BaseRestClient { method, requestUrl, params, - isPublicApi + isPublicApi, ); // Dispatch request @@ -355,7 +356,7 @@ export default abstract class BaseRestClient { private async signRequest( data: T, method: Method, - signMethod: SignMethod + signMethod: SignMethod, ): Promise> { const timestamp = Date.now() + (this.timeOffset || 0); @@ -390,7 +391,7 @@ export default abstract class BaseRestClient { res.originalParams, strictParamValidation, sortProperties, - encodeSerialisedValues + encodeSerialisedValues, ) : JSON.stringify(res.originalParams); @@ -426,7 +427,7 @@ export default abstract class BaseRestClient { res.originalParams, strictParamValidation, sortProperties, - encodeValues + encodeValues, ); res.sign = await signMessage(res.serializedParams, this.secret); @@ -473,7 +474,7 @@ export default abstract class BaseRestClient { if (!serverTime || isNaN(serverTime)) { throw new Error( - `fetchServerTime() returned non-number: "${serverTime}" typeof(${typeof serverTime})` + `fetchServerTime() returned non-number: "${serverTime}" typeof(${typeof serverTime})`, ); } diff --git a/test/v5/private.read.test.ts b/test/v5/private.read.test.ts index 27fd537..235c7e5 100644 --- a/test/v5/private.read.test.ts +++ b/test/v5/private.read.test.ts @@ -28,7 +28,7 @@ describe('Private READ V5 REST API Endpoints', () => { describe('Trade APIs', () => { it('getActiveOrders()', async () => { expect( - await api.getActiveOrders({ category: 'linear', settleCoin }) + await api.getActiveOrders({ category: 'linear', settleCoin }), ).toMatchObject({ ...successResponseObjectV3(), }); @@ -36,11 +36,12 @@ describe('Private READ V5 REST API Endpoints', () => { it('getHistoricOrders()', async () => { 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({ ...successResponseObjectV3(), }); @@ -50,7 +51,7 @@ describe('Private READ V5 REST API Endpoints', () => { describe('Position APIs', () => { it('getPositionInfo()', async () => { expect( - await api.getPositionInfo({ category: 'linear', settleCoin }) + await api.getPositionInfo({ category: 'linear', settleCoin }), ).toMatchObject({ ...successResponseObjectV3(), }); @@ -58,7 +59,10 @@ describe('Private READ V5 REST API Endpoints', () => { it('getExecutionList()', async () => { expect( - await api.getExecutionList({ category: 'linear', symbol: linearSymbol }) + await api.getExecutionList({ + category: 'linear', + symbol: linearSymbol, + }), ).toMatchObject({ ...successResponseObjectV3(), }); @@ -66,7 +70,7 @@ describe('Private READ V5 REST API Endpoints', () => { it('getClosedPnL()', async () => { expect( - await api.getClosedPnL({ category: 'linear', symbol: linearSymbol }) + await api.getClosedPnL({ category: 'linear', symbol: linearSymbol }), ).toMatchObject({ ...successResponseObjectV3(), }); @@ -76,7 +80,7 @@ describe('Private READ V5 REST API Endpoints', () => { describe('Account APIs', () => { it('getWalletBalance()', async () => { expect( - await api.getWalletBalance({ accountType: 'CONTRACT' }) + await api.getWalletBalance({ accountType: 'CONTRACT' }), ).toMatchObject({ ...successResponseObjectV3() }); }); @@ -138,13 +142,13 @@ describe('Private READ V5 REST API Endpoints', () => { it('getDeliveryRecord()', async () => { expect(await api.getDeliveryRecord({ category: 'option' })).toMatchObject( - { ...successResponseObjectV3() } + { ...successResponseObjectV3() }, ); }); it('getSettlementRecords()', async () => { expect( - await api.getSettlementRecords({ category: 'linear' }) + await api.getSettlementRecords({ category: 'linear' }), ).toMatchObject({ ...successResponseObjectV3() }); }); @@ -156,19 +160,19 @@ describe('Private READ V5 REST API Endpoints', () => { it('getAllCoinsBalance()', async () => { expect( - await api.getAllCoinsBalance({ accountType: 'SPOT' }) + await api.getAllCoinsBalance({ accountType: 'SPOT' }), ).toMatchObject({ ...successResponseObjectV3() }); }); it('getCoinBalance()', async () => { expect( - await api.getCoinBalance({ accountType: 'SPOT', coin: settleCoin }) + await api.getCoinBalance({ accountType: 'SPOT', coin: settleCoin }), ).toMatchObject({ ...successResponseObjectV3() }); }); it('getTransferableCoinList()', async () => { expect( - await api.getTransferableCoinList('SPOT', 'CONTRACT') + await api.getTransferableCoinList('SPOT', 'CONTRACT'), ).toMatchObject({ ...successResponseObjectV3() }); }); @@ -204,7 +208,7 @@ describe('Private READ V5 REST API Endpoints', () => { it('getSubAccountDepositRecords()', async () => { expect( - await api.getSubAccountDepositRecords({ subMemberId: 'fakeid' }) + await api.getSubAccountDepositRecords({ subMemberId: 'fakeid' }), ).toMatchObject({ // ...successResponseObjectV3(), // Expected, since sub account ID is fake @@ -220,7 +224,7 @@ describe('Private READ V5 REST API Endpoints', () => { it('querySubMemberAddress()', async () => { expect( - await api.querySubMemberAddress(settleCoin, 'TRC20', 'fakeid') + await api.querySubMemberAddress(settleCoin, 'TRC20', 'fakeid'), ).toMatchObject({ // ...successResponseObjectV3(), // Expected, since sub account ID is fake