fix tests and incorrect v5 endpoint

This commit is contained in:
tiagosiebler
2023-02-21 12:31:40 +00:00
parent 860e2561a1
commit bf602c8d58
6 changed files with 94 additions and 80 deletions

View File

@@ -76,6 +76,7 @@ export const API_ERROR_CODE = {
CONTRACT_RISK_LIMIT_INFO_NOT_EXISTS: 140031,
CONTRACT_SET_LEVERAGE_NOT_MODIFIED: 140043,
SUB_USER_NOT_FOUND: 141009,
SPOT_LEVERAGE_TOKEN_INSUFFICIENT_BALANCE: 175006,
SPOT_LEVERAGE_TOKEN_ORDER_NOT_FOUND: 175007,
SPOT_MARGIN_NOT_ENABLED: 176008,
SPOT_MARGIN_QUESTIONNAIRE_NOT_SUBMIT: 176037,

View File

@@ -738,7 +738,7 @@ export class RestClientV5 extends BaseRestClient {
* Once the mmp triggered, you can unfreeze the account via this endpoint
*/
resetMMP(baseCoin: string): Promise<APIResponseV3<undefined>> {
return this.postPrivate('/v5/account/mmp-modify', { baseCoin });
return this.postPrivate('/v5/account/mmp-reset', { baseCoin });
}
/**

View File

@@ -62,7 +62,7 @@ interface UnsignedRequest<T> {
paramsWithSign: T;
}
type SignMethod = 'keyInBody' | 'usdc';
type SignMethod = 'v2auth' | 'v5auth';
export default abstract class BaseRestClient {
private timeOffset: number | null = null;
@@ -233,7 +233,7 @@ export default abstract class BaseRestClient {
const signResult = await this.prepareSignParams(
method,
'usdc',
'v5auth',
params,
isPublicApi
);
@@ -245,11 +245,9 @@ export default abstract class BaseRestClient {
options.headers['X-BAPI-RECV-WINDOW'] = signResult.recvWindow;
if (method === 'GET') {
// const serialisedParams = signResult.serializedParams;
return {
...options,
params: signResult.originalParams,
// url: url + (serialisedParams ? '?' + serialisedParams : ''),
};
}
@@ -261,7 +259,7 @@ export default abstract class BaseRestClient {
const signResult = await this.prepareSignParams(
method,
'keyInBody',
'v2auth',
params,
isPublicApi
);
@@ -376,7 +374,7 @@ export default abstract class BaseRestClient {
res.recvWindow = recvWindow;
// usdc is different for some reason
if (signMethod === 'usdc') {
if (signMethod === 'v5auth') {
const sortProperties = false;
const signRequestParams =
method === 'GET'
@@ -397,7 +395,7 @@ export default abstract class BaseRestClient {
}
// spot/v2 derivatives
if (signMethod === 'keyInBody') {
if (signMethod === 'v2auth') {
res.originalParams.api_key = key;
res.originalParams.timestamp = timestamp;