From 2f1870827e23ce50c977d0b8d83ebdc01bd73719 Mon Sep 17 00:00:00 2001 From: Dmitri Karpovich Date: Fri, 6 Dec 2024 01:26:35 +0100 Subject: [PATCH] [gateio] Simplify signature generation --- xchange-gateio-v4/src/test/resources/rest/sign.js | 3 ++- .../src/test/resources/rest/spot.http | 14 +++++++------- .../src/test/resources/rest/wallet.http | 4 ++-- .../src/test/resources/rest/withdraw.http | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/xchange-gateio-v4/src/test/resources/rest/sign.js b/xchange-gateio-v4/src/test/resources/rest/sign.js index 3f84077e02d..45db56c28e1 100644 --- a/xchange-gateio-v4/src/test/resources/rest/sign.js +++ b/xchange-gateio-v4/src/test/resources/rest/sign.js @@ -1,4 +1,5 @@ -export function gen_sign(method, request) { +export function gen_sign(request) { + const method = request.method const pattern = RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?"); const url = request.url.tryGetSubstituted(); const matches = url.match(pattern); diff --git a/xchange-gateio-v4/src/test/resources/rest/spot.http b/xchange-gateio-v4/src/test/resources/rest/spot.http index a6fb2ad4795..b60aeb41e6c 100644 --- a/xchange-gateio-v4/src/test/resources/rest/spot.http +++ b/xchange-gateio-v4/src/test/resources/rest/spot.http @@ -1,7 +1,7 @@ ### List personal trading history < {% import {gen_sign} from 'sign.js' - gen_sign("GET", request); + gen_sign(request); %} GET {{api_v4}}/spot/my_trades @@ -14,7 +14,7 @@ Content-Type: application/json ### List spot accounts < {% import {gen_sign} from 'sign.js' - gen_sign("GET", request); + gen_sign(request); %} GET {{api_v4}}/spot/accounts @@ -27,7 +27,7 @@ Content-Type: application/json ### Query account book < {% import {gen_sign} from 'sign.js' - gen_sign("GET", request); + gen_sign(request); %} GET {{api_v4}}/spot/account_book @@ -40,7 +40,7 @@ Content-Type: application/json ### List orders < {% import {gen_sign} from 'sign.js' - gen_sign("GET", request); + gen_sign(request); %} GET {{api_v4}}/spot/orders?currency_pair=VAI_USDT&status=finished @@ -53,7 +53,7 @@ Content-Type: application/json ### Create an order < {% import {gen_sign} from 'sign.js' - gen_sign("POST", request); + gen_sign(request); %} POST {{api_v4}}/spot/orders @@ -74,7 +74,7 @@ Content-Type: application/json ### Cancel a single order < {% import {gen_sign} from 'sign.js' - gen_sign("DELETE", request); + gen_sign(request); %} DELETE {{api_v4}}/spot/orders/123456?currency_pair=BTC_USDT @@ -87,7 +87,7 @@ Content-Type: application/json ### Get a single order < {% import {gen_sign} from 'sign.js' - gen_sign("GET", request); + gen_sign(request); %} GET {{api_v4}}/spot/orders/745504484392?currency_pair=BTC_USDT diff --git a/xchange-gateio-v4/src/test/resources/rest/wallet.http b/xchange-gateio-v4/src/test/resources/rest/wallet.http index f267392faa5..de5798c007f 100644 --- a/xchange-gateio-v4/src/test/resources/rest/wallet.http +++ b/xchange-gateio-v4/src/test/resources/rest/wallet.http @@ -1,7 +1,7 @@ ### Retrieve withdrawal status < {% import {gen_sign} from 'sign.js' - gen_sign("GET", request); + gen_sign(request); %} GET {{api_v4}}/wallet/withdraw_status?currency=usdt @@ -14,7 +14,7 @@ Content-Type: application/json ### Retrieve transfer records between main and sub accounts < {% import {gen_sign} from 'sign.js' - gen_sign("GET", request); + gen_sign(request); %} GET {{api_v4}}/wallet/sub_account_transfers diff --git a/xchange-gateio-v4/src/test/resources/rest/withdraw.http b/xchange-gateio-v4/src/test/resources/rest/withdraw.http index 081f29c2976..8574564114e 100644 --- a/xchange-gateio-v4/src/test/resources/rest/withdraw.http +++ b/xchange-gateio-v4/src/test/resources/rest/withdraw.http @@ -1,7 +1,7 @@ ### Withdraw < {% import {gen_sign} from 'sign.js' - gen_sign("POST", request); + gen_sign(request); %} POST {{api_v4}}/withdrawals