Merge pull request #234 from tiagosiebler/typeendpoint

v3.5.2: feat() add missing v5 internal deposit records endpoint. fix(#233) return type for v5 wallet balance endpoint, fix(#232) timestamp resolution for v5 fetch time endpoint
This commit is contained in:
Tiago
2023-03-03 16:35:16 +00:00
committed by GitHub
7 changed files with 53 additions and 6 deletions

View File

@@ -24,5 +24,6 @@ module.exports = {
lines: 50, lines: 50,
statements: -10 statements: -10
} }
} },
testTimeout: 1000 * 15
}; };

View File

@@ -1,6 +1,6 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "3.5.1", "version": "3.5.2",
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -57,6 +57,7 @@ import {
GetIndexPriceKlineParamsV5, GetIndexPriceKlineParamsV5,
GetInstrumentsInfoParamsV5, GetInstrumentsInfoParamsV5,
GetInsuranceParamsV5, GetInsuranceParamsV5,
GetInternalDepositRecordParamsV5,
GetInternalTransferParamsV5, GetInternalTransferParamsV5,
GetKlineParamsV5, GetKlineParamsV5,
GetMarkPriceKlineParamsV5, GetMarkPriceKlineParamsV5,
@@ -77,6 +78,7 @@ import {
HistoricalVolatilityV5, HistoricalVolatilityV5,
InstrumentInfoResponseV5, InstrumentInfoResponseV5,
InsuranceResponseV5, InsuranceResponseV5,
InternalDepositRecordV5,
InternalTransferRecordV5, InternalTransferRecordV5,
LeverageTokenInfoV5, LeverageTokenInfoV5,
LeveragedTokenMarketResultV5, LeveragedTokenMarketResultV5,
@@ -139,7 +141,7 @@ export class RestClientV5 extends BaseRestClient {
async fetchServerTime(): Promise<number> { async fetchServerTime(): Promise<number> {
const res = await this.getServerTime(); const res = await this.getServerTime();
return Number(res.time); return Number(res.time) / 1000;
} }
getServerTime(): Promise< getServerTime(): Promise<
@@ -637,7 +639,7 @@ export class RestClientV5 extends BaseRestClient {
*/ */
getWalletBalance( getWalletBalance(
params: GetWalletBalanceParamsV5 params: GetWalletBalanceParamsV5
): Promise<APIResponseV3WithTime<WalletBalanceV5>> { ): Promise<APIResponseV3WithTime<{ list: WalletBalanceV5[] }>> {
return this.getPrivate('/v5/account/wallet-balance', params); return this.getPrivate('/v5/account/wallet-balance', params);
} }
@@ -982,6 +984,23 @@ export class RestClientV5 extends BaseRestClient {
return this.getPrivate('/v5/asset/deposit/query-sub-member-record', params); return this.getPrivate('/v5/asset/deposit/query-sub-member-record', params);
} }
/**
* Get Internal Deposit Records (across Bybit)
* Query deposit records through Bybit platform
*
* RULES
* The maximum difference between the start time and the end time is 30 days.
* Support to get deposit records by Master or Sub Member Api Key
*/
getInternalDepositRecords(params?: GetInternalDepositRecordParamsV5): Promise<
APIResponseV3WithTime<{
rows: InternalDepositRecordV5[];
nextPageCursor: string;
}>
> {
return this.getPrivate('/v5/asset/deposit/query-internal-record', params);
}
/** /**
* Query the deposit address information of MASTER account. * Query the deposit address information of MASTER account.
*/ */

View File

@@ -95,6 +95,14 @@ export interface GetSubAccountDepositRecordParamsV5 {
cursor?: string; cursor?: string;
} }
export interface GetInternalDepositRecordParamsV5 {
startTime?: number;
endTime?: number;
coin?: string;
cursor?: string;
limit?: number;
}
export interface GetWithdrawalRecordsParamsV5 { export interface GetWithdrawalRecordsParamsV5 {
withdrawID?: string; withdrawID?: string;
coin?: string; coin?: string;

View File

@@ -115,6 +115,16 @@ export interface DepositRecordV5 {
blockHash: string; blockHash: string;
} }
export interface InternalDepositRecordV5 {
id: string;
type: 1;
coin: string;
amount: string;
status: 1 | 2 | 3;
address: string;
createdTime: string;
}
export interface DepositAddressChainV5 { export interface DepositAddressChainV5 {
chainType: string; chainType: string;
addressDeposit: string; addressDeposit: string;

View File

@@ -81,7 +81,11 @@ export default abstract class BaseRestClient {
private clientType: RestClientType; private clientType: RestClientType;
/** Function that calls exchange API to query & resolve server time, used by time sync, disabled by default */ /**
* Function that calls exchange API to query & resolve server time, used by time sync, disabled by default.
*
* Note: this should always return server time in seconds
*/
abstract fetchServerTime(): Promise<number>; abstract fetchServerTime(): Promise<number>;
/** Defines the client type (affecting how requests & signatures behave) */ /** Defines the client type (affecting how requests & signatures behave) */

View File

@@ -11,7 +11,12 @@ export interface RestClientOptions {
/** Override the max size of the request window (in ms) */ /** Override the max size of the request window (in ms) */
recv_window?: number; recv_window?: number;
/** Disabled by default. This can help on machines with consistent latency problems. */ /**
* Disabled by default.
* This can help on machines with consistent latency problems.
*
* Note: this feature is not recommended as one slow request can cause problems
*/
enable_time_sync?: boolean; enable_time_sync?: boolean;
/** How often to sync time drift with bybit servers */ /** How often to sync time drift with bybit servers */