Skip to content

Commit 2474636

Browse files
committed
refactor: simplifies some one argument method calls. fix: websocket tests
1 parent 3eff315 commit 2474636

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

lib/websocket/tradingClient.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,11 @@ export class TradingClient extends AuthClient {
215215
*
216216
* https://api.exchange.cryptomkt.com/#get-spot-trading-balance-2
217217
*
218-
* @param {string} params.currency The currency code to query the balance
218+
* @param {string} currency The currency code to query the balance
219219
* @return A promise that resolves with the spot trading balance of a currency
220220
*/
221-
async getSpotTradingBalance(params: {
222-
currency: string;
223-
}): Promise<Balance> {
224-
return this.makeRequest<Balance>({ method: "spot_balance", params });
221+
async getSpotTradingBalance(currency: string): Promise<Balance> {
222+
return this.makeRequest<Balance>({ method: "spot_balance", params: { currency } });
225223
}
226224

227225
/**
@@ -240,13 +238,11 @@ export class TradingClient extends AuthClient {
240238
*
241239
* https://api.exchange.cryptomkt.com/#get-spot-fee
242240
*
243-
* @param {string} params.symbol The symbol of the commission rate
241+
* @param {string} symbol The symbol of the commission rate
244242
* @return A promise that resolves with the commission rate of a symbol
245243
*/
246-
async getSpotFee(params: {
247-
symbol: string;
248-
}): Promise<Commission> {
249-
return this.makeRequest<Commission>({ method: "spot_fee", params });
244+
async getSpotFee(symbol: string): Promise<Commission> {
245+
return this.makeRequest<Commission>({ method: "spot_fee", params: { symbol } });
250246
}
251247

252248
///////////////////

test/websocket/trading.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ describe("TradingClient", () => {
2828
it("gets only one", async function () {
2929
this.timeout(0);
3030
await wsclient.connect();
31-
const balance = await wsclient.getSpotTradingBalanceOfCurrency({
32-
currency: "EOS",
33-
});
31+
const balance = await wsclient.getSpotTradingBalance("EOS");
3432
expect(goodBalance(balance)).to.be.true
3533
});
3634
});
@@ -94,7 +92,7 @@ describe("TradingClient", () => {
9492
it("gets a commission list", async function () {
9593
this.timeout(0);
9694
await wsclient.connect();
97-
const commissions = await wsclient.getSpotCommissions();
95+
const commissions = await wsclient.getSpotFees();
9896
expect(commissions.length).to.be.greaterThanOrEqual(1);
9997
const allGood = commissions.map(goodTradingCommission).every(Boolean)
10098
expect(allGood).to.be.true
@@ -103,9 +101,7 @@ describe("TradingClient", () => {
103101
it("gets only one", async function () {
104102
this.timeout(0);
105103
await wsclient.connect();
106-
const commission = await wsclient.getSpotCommissionOfSymbol({
107-
symbol: "EOSETH",
108-
});
104+
const commission = await wsclient.getSpotFee("EOSETH");
109105
expect(goodTradingCommission(commission)).to.be.true
110106
});
111107
});

test/websocket/wallet.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("WalletClient", function () {
2626
it("gets only one balance", async function () {
2727
this.timeout(0);
2828
await wsclient.connect();
29-
const balance = await wsclient.getWalletBalanceOfCurrency("EOS");
29+
const balance = await wsclient.getWalletBalance("EOS");
3030
expect(goodBalance(balance)).to.be.true
3131
});
3232
});

0 commit comments

Comments
 (0)