Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
478 changes: 239 additions & 239 deletions docs/endpointFunctionList.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gateio-api",
"version": "1.1.4",
"version": "1.1.5",
"description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.",
"scripts": {
"clean": "rm -rf dist/*",
Expand Down
1 change: 1 addition & 0 deletions src/RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ export class RestClient extends BaseRestClient {
*/
getUnifiedAccountInfo(params?: {
currency?: string;
sub_uid?: string;
}): Promise<UnifiedAccountInfo> {
return this.getPrivate('/unified/accounts', params);
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/BaseWSClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { WS_LOGGER_CATEGORY } from '../WebsocketClient.js';
import { DefaultLogger } from './logger.js';
import { isMessageEvent, MessageEventLike } from './requestUtils.js';
import {
safeTerminateWs,
WsTopicRequest,
WsTopicRequestOrStringTopic,
} from './websocket/websocket-util.js';
Expand Down Expand Up @@ -338,7 +339,7 @@ export abstract class BaseWebsocketClient<
const ws = this.getWs(wsKey);
ws?.close();
if (force) {
ws?.terminate();
safeTerminateWs(ws);
}
}

Expand Down Expand Up @@ -509,7 +510,7 @@ export abstract class BaseWebsocketClient<
});
this.clearPongTimer(wsKey);

this.getWs(wsKey)?.terminate();
safeTerminateWs(this.getWs(wsKey), true);
}, this.options.pongTimeout);
}

Expand Down
24 changes: 24 additions & 0 deletions src/lib/websocket/websocket-util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import WebSocket from 'isomorphic-ws';

import { WSAPIRequest } from '../../types/websockets/requests.js';
import {
FuturesWSAPITopic,
Expand Down Expand Up @@ -214,3 +216,25 @@ export function getPrivateOptionsTopics(): string[] {

return [...privateOptionsTopics];
}

/**
* ws.terminate() is undefined in browsers.
* This only works in node.js, not in browsers.
* Does nothing if `ws` is undefined. Does nothing in browsers.
*/
export function safeTerminateWs(
ws?: WebSocket | any,
fallbackToClose?: boolean,
): boolean {
if (!ws) {
return false;
}
if (typeof ws['terminate'] === 'function') {
ws.terminate();
return true;
} else if (fallbackToClose) {
ws.close();
}

return false;
}
2 changes: 1 addition & 1 deletion src/types/request/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export interface GetSpotInsuranceHistoryReq {
export interface GetSpotAutoOrdersReq {
status: 'open' | 'finished';
market?: string;
account?: 'normal' | 'margin' | 'cross_margin';
account?: 'normal' | 'margin' | 'cross_margin' | 'unified';
limit?: number;
offset?: number;
}
Expand Down
3 changes: 3 additions & 0 deletions src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export type GateBaseUrlKey =
export interface CurrencyPair {
id?: string;
base?: string;
base_name?: string;
quote?: string;
quote_name?: string;
fee?: string;
min_base_amount?: string;
min_quote_amount?: string;
Expand All @@ -20,4 +22,5 @@ export interface CurrencyPair {
trade_status?: 'untradable' | 'buyable' | 'sellable' | 'tradable';
sell_start?: number;
buy_start?: number;
type: string;
}
Loading