Skip to content

Commit f750a7d

Browse files
committed
fix: update missing snake_case names
1 parent a495fd3 commit f750a7d

File tree

10 files changed

+62
-63
lines changed

10 files changed

+62
-63
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ console.log(balanceList);
124124
let clientOrderID = Math.floor(Date.now() / 1000).toString();
125125
// make a spot order
126126
const report = await tradingClient.createSpotOrder({
127-
client_order_id: clientOrderID,
127+
clientOrderId: clientOrderID,
128128
symbol: "EOSETH",
129129
side: "sell",
130130
quantity: "0.01",

lib/client.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ export class Client {
547547
* @param {string} [params.stopPrice] Required for 'stopLimit' and 'stopMarket' orders. stop price of the order
548548
* @param {string} [params.expireTime] Required for orders with timeInForce = GDT
549549
* @param {boolean} [params.strictValidate] Optional. If False, the server rounds half down for tickerSize and quantityIncrement. Example of ETHBTC: tickSize = '0.000001', then price '0.046016' is valid, '0.0460165' is invalid
550-
* @param {boolean} [params.postOnly] Optional. If True, your post_only order causes a match with a pre-existing order as a taker, then the order will be cancelled
550+
* @param {boolean} [params.postOnly] Optional. If True, your postOnly order causes a match with a pre-existing order as a taker, then the order will be cancelled
551551
* @param {string} [params.takeRate] Optional. Liquidity taker fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
552552
* @param {string} [params.makeRate] Optional. Liquidity provider fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
553553
*
@@ -607,7 +607,7 @@ export class Client {
607607
*
608608
* https://api.exchange.cryptomkt.com/#create-new-spot-order-list
609609
*
610-
* @param {string} params.orderListId Order list identifier. If omitted, it will be generated by the system upon order list creation. Must be equal to client_order_id of the first order in the request.
610+
* @param {string} params.orderListId Order list identifier. If omitted, it will be generated by the system upon order list creation. Must be equal to clientOrderId of the first order in the request.
611611
* @param {string} params.contingencyType Order list type.
612612
* @param {OrderRequest[]} params.orders Orders in the list.
613613
* @return A promise that resolves with a list of reports of the created orders
@@ -627,12 +627,12 @@ export class Client {
627627
*
628628
* https://api.exchange.cryptomkt.com/#replace-spot-order
629629
*
630-
* @param {string} clientOrderId client_order_id of the old order
630+
* @param {string} clientOrderId clientOrderId of the old order
631631
* @param {object} params Parameters
632-
* @param {string} params.newClientOrderId client_order_id for the new order.
632+
* @param {string} params.newClientOrderId clientOrderId for the new order.
633633
* @param {string} params.quantity Order quantity.
634634
* @param {string} [params.price] Required if order type is limit, stopLimit, or takeProfitLimit. Order price.
635-
* @param {boolean} [params.strictValidate] Optional. Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.
635+
* @param {boolean} [params.strictValidate] Optional. Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tickSize and quantityIncrement.
636636
*
637637
* @returns the new spot order
638638
*/
@@ -668,7 +668,7 @@ export class Client {
668668
*
669669
* https://api.exchange.cryptomkt.com/#cancel-spot-order
670670
*
671-
* @param {string} clientOrderId the client_order_id of the order to cancel
671+
* @param {string} clientOrderId the clientOrderId of the order to cancel
672672
*
673673
* @return The canceled order
674674
*/
@@ -750,7 +750,7 @@ export class Client {
750750
* https://api.exchange.cryptomkt.com/#spot-trades-history
751751
*
752752
* @param {object} [params]
753-
* @param {string} [params.order_id] Optional. Order unique identifier as assigned by the exchange
753+
* @param {string} [params.orderId] Optional. Order unique identifier as assigned by the exchange
754754
* @param {string} [params.symbol] Optional. Filter trades by symbol
755755
* @param {SORT} [params.sort] Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
756756
* @param {SORT_BY} [params.by] Optional. Sorting type.'timestamp' or 'id'. Default is 'id'
@@ -761,7 +761,7 @@ export class Client {
761761
* @return A list of trades
762762
*/
763763
getSpotTradesHistory(params?: {
764-
order_id?: string;
764+
orderId?: string;
765765
symbol?: string;
766766
sort?: SORT;
767767
by?: SORT_BY;
@@ -828,11 +828,12 @@ export class Client {
828828
* https://api.exchange.cryptomkt.com/#get-deposit-crypto-address
829829
*
830830
* @param {string} currency currency to get the address
831+
* @param {string} [networkCode] Optional. network code
831832
*
832833
* @return the currency address
833834
*/
834-
async getDepositCryptoAddress(currency: string, network_code?: string): Promise<Address> {
835-
const addressList = await this.get(`wallet/crypto/address`, { currency });
835+
async getDepositCryptoAddress(currency: string, networkCode?: string): Promise<Address> {
836+
const addressList = await this.get(`wallet/crypto/address`, { currency, networkCode });
836837
return addressList[0];
837838
}
838839

@@ -843,7 +844,7 @@ export class Client {
843844
* Existing addresses may still receive funds.
844845
* For some tokens (e.g., Ethereum tokens),
845846
* a single address is generated per base currency with additional
846-
* identifiers which differ for each address: payment_id or public_key.
847+
* identifiers which differ for each address: paymentId or publicKey.
847848
* As a result, generating a new address for such a token
848849
* will change the current address for an entire base currency accordingly.
849850
*
@@ -920,9 +921,9 @@ export class Client {
920921
* @param {string} [params.paymentId] Optional.
921922
* @param {boolean} [params.includeFee] Optional. If true then the total spent amount includes fees. Default false
922923
* @param {boolean} [params.autoCommit] Optional. If false then you should commit or rollback transaction in an hour. Used in two phase commit schema. Default true
923-
* @param {USE_OFFCHAIN} [params.use_offchain] Whether the withdrawal may be committed offchain. 'never', 'optionally', 'required'
924+
* @param {USE_OFFCHAIN} [params.useOffchain] Whether the withdrawal may be committed offchain. 'never', 'optionally', 'required'
924925
Accepted values: never, optionally, required
925-
* @param {string} [params.public_comment] Optional. Maximum length is 255.
926+
* @param {string} [params.publicComment] Optional. Maximum length is 255.
926927
*
927928
* @return The transaction id, asigned by the exchange
928929
*/
@@ -1129,9 +1130,9 @@ Accepted values: wallet, spot. Must not be the same as source
11291130
* @param {TRANSACTION_STATUS[]} [params.statuses] Optional. List of statuses to query. valid subtypes are: 'CREATED', 'PENDING', 'FAILED', 'SUCCESS' and 'ROLLED_BACK'
11301131
* @param {string[]} [params.currencies] Optional. List of currencies of the transactions
11311132
* @param {string[]} [params.networks] Optional. List of network codes
1132-
* @param {SORT_BY} [params.orderBy] Optional. Defines the sorting type.'created_at' or 'id'. Default is 'created_at'
1133-
* @param {string} [params.from] Optional. Interval initial value when ordering by 'created_at'. As Datetime
1134-
* @param {string} [params.till] Optional. Interval end value when ordering by 'created_at'. As Datetime
1133+
* @param {SORT_BY} [params.orderBy] Optional. Defines the sorting type.'createdAt' or 'id'. Default is 'createdAt'
1134+
* @param {string} [params.from] Optional. Interval initial value when ordering by 'createdAt'. As Datetime
1135+
* @param {string} [params.till] Optional. Interval end value when ordering by 'createdAt'. As Datetime
11351136
* @param {string} [params.idFrom] Optional. Interval initial value when ordering by id. Min is 0
11361137
* @param {string} [params.idTill] Optional. Interval end value when ordering by id. Min is 0
11371138
* @param {string} [params.sort] Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'.
@@ -1283,9 +1284,7 @@ Accepted values: wallet, spot. Must not be the same as source
12831284
* @return true if the activation was successful
12841285
*/
12851286
async activateSubAccounts(subAccountIds: string[]): Promise<boolean> {
1286-
const response = await this.post("sub-account/activate", {
1287-
sub_account_ids: subAccountIds,
1288-
});
1287+
const response = await this.post("sub-account/activate", { subAccountIds });
12891288
return response["result"];
12901289
}
12911290

@@ -1349,7 +1348,7 @@ Accepted values: wallet, spot. Must not be the same as source
13491348
async changeACLSettings(params: {
13501349
subAccountIds: string[];
13511350
depositAddressGenerationEnabled?: boolean;
1352-
withdraw_enabled?: boolean;
1351+
withdrawEnabled?: boolean;
13531352
description?: string;
13541353
createdAt?: string;
13551354
updatedAt?: string;

lib/httpClient.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ export class HttpClient {
3232
}
3333

3434

35-
private prepareRequest(params_raw: any, method: HTTP_METHOD, publicMethod: boolean, endpoint: string): { url: URL, opts: Map<string, string> } {
36-
if (params_raw === undefined || params_raw === null) {
37-
params_raw = {}
35+
private prepareRequest(paramsRaw: any, method: HTTP_METHOD, publicMethod: boolean, endpoint: string): { url: URL, opts: Map<string, string> } {
36+
if (paramsRaw === undefined || paramsRaw === null) {
37+
paramsRaw = {}
3838
}
3939
let url = new URL(this.apiPath + endpoint);
40-
this.removeNulls(params_raw);
41-
const params: [string, string][] = Object.entries(params_raw)
40+
this.removeNulls(paramsRaw);
41+
const params: [string, string][] = Object.entries(paramsRaw)
4242
.map(([k, v]) => [k, String(v)])
4343
let rawQuery = new URLSearchParams(params);
4444
rawQuery.sort();
@@ -54,7 +54,7 @@ export class HttpClient {
5454
let credentialParams = query
5555
if (method === HTTP_METHOD.POST) {
5656
opts.headers["Content-Type"] = "application/json";
57-
credentialParams = JSON.stringify(params_raw)
57+
credentialParams = JSON.stringify(paramsRaw)
5858
}
5959
if (method === HTTP_METHOD.PATCH) {
6060
opts.headers["Content-Type"] = "application/x-www-form-urlencoded";
@@ -71,8 +71,8 @@ export class HttpClient {
7171
return { url, opts };
7272
}
7373

74-
private removeNulls(params_raw: any) {
75-
Object.keys(params_raw).forEach(key => (params_raw[key] === undefined || params_raw[key] == null) ? delete params_raw[key] : {});
74+
private removeNulls(paramsRaw: any) {
75+
Object.keys(paramsRaw).forEach(key => (paramsRaw[key] === undefined || paramsRaw[key] == null) ? delete paramsRaw[key] : {});
7676
}
7777

7878
private async makeFetch(url: URL, opts: any): Promise<any> {

lib/websocket/authClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { WSClientBase } from "./clientBase";
33

44
interface AuthPayload {
55
type: string
6-
api_key: string
6+
apiKey: string
77
timestamp: number
88
window?: number
99
signature: string
@@ -53,7 +53,7 @@ export class AuthClient extends WSClientBase {
5353
const timestamp = Math.floor(Date.now());
5454
const payload: AuthPayload = {
5555
type: "HS256",
56-
api_key: this.apiKey,
56+
apiKey: this.apiKey,
5757
timestamp: timestamp,
5858
signature: "",
5959
};

lib/websocket/marketDataClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ export class MarketDataClient extends WSClientBase {
555555
*
556556
* @param {function} callback recieves a feed of price rates as a map of them, indexed by currency id, and the type of notification, only DATA
557557
* @param {PRICE_RATE_SPEED} params.speed The speed of the feed. '1s' or '3s'
558-
* @param {string} params.target_currency quote currency of the rate
558+
* @param {string} params.targetCurrency quote currency of the rate
559559
* @param {string} params.currencies Optional. a list of base currencies to get rates. If omitted, subscribe to all currencies
560560
* @return A promise that resolves when subscribed with a list of the successfully subscribed currencies
561561
*/
@@ -569,7 +569,7 @@ export class MarketDataClient extends WSClientBase {
569569
) => any;
570570
params: {
571571
speed: PRICE_RATE_SPEED;
572-
target_currency: string,
572+
targetCurrency: string,
573573
currencies?: string[];
574574
};
575575
}): Promise<string[]> {

lib/websocket/tradingClient.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class TradingClient extends AuthClient {
7575
* @param {TIME_IN_FORCE} [params.timeInForce] Optional. 'GTC', 'IOC', 'FOK', 'Day', 'GTD'. Default to 'GTC'
7676
* @param {string} [params.expireTime] Optional. Required for orders with timeInForce = GDT
7777
* @param {boolean} [params.strictValidate] Optional. If False, the server rounds half down for tickerSize and quantityIncrement. Example of ETHBTC: tickSize = '0.000001', then price '0.046016' is valid, '0.0460165' is invalid
78-
* @param {boolean} [params.postOnly] Optional. If True, your post_only order causes a match with a pre-existing order as a taker, then the order will be cancelled
78+
* @param {boolean} [params.postOnly] Optional. If True, your postOnly order causes a match with a pre-existing order as a taker, then the order will be cancelled
7979
* @param {string} [params.takeRate] Optional. Liquidity taker fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
8080
* @param {string} [params.makeRate] Optional. Liquidity provider fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
8181
* @return A promise that resolves with a report of the new order
@@ -134,7 +134,7 @@ export class TradingClient extends AuthClient {
134134
*
135135
* https://api.exchange.cryptomkt.com/#create-new-spot-order-list-2
136136
*
137-
* @param {string} params.orderListId Order list identifier. If omitted, it will be generated by the system upon order list creation. Must be equal to client_order_id of the first order in the request.
137+
* @param {string} params.orderListId Order list identifier. If omitted, it will be generated by the system upon order list creation. Must be equal to clientOrderId of the first order in the request.
138138
* @param {string} params.contingencyType Order list type.
139139
* @param {OrderRequest[]} params.orders Orders in the list.
140140
* @return A promise that resolves with a list all reports created
@@ -163,7 +163,7 @@ export class TradingClient extends AuthClient {
163163
async cancelSpotOrder(clientOrderId: string): Promise<Report> {
164164
const report = await this.makeRequest<Report>({
165165
method: "spot_cancel_order",
166-
params: { client_order_id: clientOrderId },
166+
params: { clientOrderId },
167167
});
168168
return fromSnakeCaseToCamelCase(report)
169169
}
@@ -177,7 +177,7 @@ export class TradingClient extends AuthClient {
177177
* @param {string} params.newClientOrderId the new client order id for the modified order. must be unique within the trading day
178178
* @param {string} params.quantity new order quantity
179179
* @param {string} params.price new order price
180-
* @param {boolean} [params.strictValidate] price and quantity will be checked for the incrementation with tick size and quantity step. See symbol's tick_size and quantity_increment
180+
* @param {boolean} [params.strictValidate] price and quantity will be checked for the incrementation with tick size and quantity step. See symbol's tickSize and quantityIncrement
181181
* @return A promise that resolves with a report of the modified order
182182
*/
183183
async replaceSpotOrder(params: {

lib/websocket/walletClient.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ export class WalletClient extends AuthClient {
8585
* @param {TRANSACTION_TYPE[]} [params.transactionTypes] Optional. List of types to query. valid types are: 'DEPOSIT', 'WITHDRAW', 'TRANSFER' and 'SWAP'
8686
* @param {TRANSACTION_SUBTYPE[]} [params.transactionSubtyes] Optional. List of subtypes to query. valid subtypes are: 'UNCLASSIFIED', 'BLOCKCHAIN', 'AIRDROP', 'AFFILIATE', 'STAKING', 'BUY_CRYPTO', 'OFFCHAIN', 'FIAT', 'SUB_ACCOUNT', 'WALLET_TO_SPOT', 'SPOT_TO_WALLET', 'WALLET_TO_DERIVATIVES', 'DERIVATIVES_TO_WALLET', 'CHAIN_SWITCH_FROM', 'CHAIN_SWITCH_TO' and 'INSTANT_EXCHANGE'
8787
* @param {TRANSACTION_STATUS[]} [params.transactionStatuses] Optional. List of statuses to query. valid subtypes are: 'CREATED', 'PENDING', 'FAILED', 'SUCCESS' and 'ROLLED_BACK'
88-
* @param {string} [params.from] Optional. Interval initial value when ordering by 'created_at'. As Datetime
89-
* @param {string} [params.till] Optional. Interval end value when ordering by 'created_at'. As Datetime
88+
* @param {string} [params.from] Optional. Interval initial value when ordering by 'createdAt'. As Datetime
89+
* @param {string} [params.till] Optional. Interval end value when ordering by 'createdAt'. As Datetime
9090
* @param {string} [params.idFrom] Optional. Interval initial value when ordering by id. Min is 0
9191
* @param {string} [params.idTill] Optional. Interval end value when ordering by id. Min is 0
92-
* @param {SORT_BY} [params.orderBy] Optional. sorting parameter.'created_at' or 'id'. Default is 'created_at'
92+
* @param {SORT_BY} [params.orderBy] Optional. sorting parameter.'createdAt' or 'id'. Default is 'createdAt'
9393
* @param {SORT} [params.sort] Optional. Sort direction. 'ASC' or 'DESC'. Default is 'DESC'
9494
* @param {number} [params.limit] Optional. Transactions per query. Defaul is 100. Max is 1000
9595
* @param {number} [params.offset] Optional. Default is 0. Max is 100000
@@ -112,11 +112,11 @@ export class WalletClient extends AuthClient {
112112
offset?: number;
113113
groupTransactions?: Boolean;
114114
}): Promise<Transaction[]> {
115-
const clean_params: any = { ...params }
116-
clean_params.currencies = params.currencies?.join(", ")
115+
const cleanParams: any = { ...params }
116+
cleanParams.currencies = params.currencies?.join(", ")
117117
const transactions = await this.makeRequest<Transaction[]>({
118118
method: "get_transactions",
119-
params: clean_params
119+
params: cleanParams
120120
});
121121
return fromSnakeCaseToCamelCase(transactions)
122122
}

test/rest/spotTrading.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,19 @@ describe("spot trading", () => {
157157
this.timeout(0);
158158
await timeout(3 * SECOND)
159159

160-
let order_list_id = Date.now().toString();
160+
let firstOrderId = Date.now().toString();
161161
await client.createNewSpotOrderList({
162-
// order_list_id: order_list_id,
162+
orderListId: firstOrderId,
163163
contingencyType: CONTINGENCY.ALL_OR_NONE,
164164
orders: [
165165
{
166+
clientOrderId: firstOrderId,
166167
symbol: 'EOSETH',
167168
side: SIDE.SELL,
168169
type: ORDER_TYPE.LIMIT,
169170
timeInForce: TIME_IN_FORCE.FOK,
170171
quantity: '0.1',
171172
price: '1000',
172-
// client_order_id: order_list_id
173173
},
174174
{
175175
symbol: 'EOSUSDT',

0 commit comments

Comments
 (0)