Skip to content

Commit

Permalink
#20 code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ceres3idoo committed Feb 25, 2019
1 parent 3b232dd commit 1749d4f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/cli/tws/get-balance.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const logger = require('../../logger')

const { getTradingWalletBalanceCommand } = require('../../commands/commandList')
const { getBalanceCommand } = require('../../commands/commandList')

module.exports = {
describe: getTradingWalletBalanceCommand.constructor.description,
builder: getTradingWalletBalanceCommand.getBuilderArgsDetails(),
handler: async argv => logger.show(await getTradingWalletBalanceCommand.executeAsync(argv)),
describe: getBalanceCommand.constructor.description,
builder: getBalanceCommand.getBuilderArgsDetails(),
handler: async argv => logger.show(await getBalanceCommand.executeAsync(argv)),
}
8 changes: 4 additions & 4 deletions src/commands/GetBalanceCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ class GetBalanceCommand extends ABaseCommand {
* It executes the command after the validation step.
*
* @param {Object} params
* @param {String} params.from The personal wallet address (EOA).
* @param {String} params.to The trading wallet address.
* @param {String} params.token The token wallet address.
* @param {String} params.from The personal wallet address (EOA).
* @param {String} params.to The trading wallet address.
* @param {String} params.token The token wallet address.
* @param {String} params.privateKeyFilePath The EOA private key.
* @param {String} params.draft The draft. If set to true it shows the TransactionObjectDraft.
* @param {String} params.draft The draft. If set to true it shows the TransactionObjectDraft.
*/
async doExecuteAsync({ from, to, token, privateKeyFilePath, draft }) {
let personalWalletAddressRetrived = _.cloneDeep(from)
Expand Down
12 changes: 6 additions & 6 deletions src/commands/commandList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const DepositEthCommandValidator = require('../validators/DepositEthCommandValid
const GetAddressCommand = require('../commands/GetAddressCommand')
const GetAddressCommandValidator = require('../validators/GetAddressCommandValidator')

const GetTradingWalletBalanceCommand = require('../commands/GetBalanceCommand')
const GetTradingWalletBalanceCommandValidator = require('../validators/GetTradingWalletBalanceCommandValidator')
const GetBalanceCommand = require('../commands/GetBalanceCommand')
const GetBalanceCommandValidator = require('../validators/GetBalanceCommandValidator')

const logger = require('../logger')
const OrderSignCommand = require('../commands/OrderSignCommand')
Expand All @@ -22,7 +22,7 @@ const createWalletCommandValidator = new CreateWalletCommandValidator(logger)
const depositEthCommandValidator = new DepositEthCommandValidator(logger)
const getAddressCommandValidator = new GetAddressCommandValidator(logger)

const getTradingWalletBalanceCommandValidator = new GetTradingWalletBalanceCommandValidator(logger)
const getBalanceCommandValidator = new GetBalanceCommandValidator(logger)

const orderSignCommandValidator = new OrderSignCommandValidator(logger)
const withdrawCommandValidator = new WithdrawCommandValidator(logger)
Expand All @@ -36,8 +36,8 @@ const tradingWalletService = TradingWalletServiceBuilder.build()
const getAddressCommand = new GetAddressCommand(logger, tradingWalletService,
getAddressCommandValidator, privateKeyService, privateKeyValidator)

const getTradingWalletBalanceCommand = new GetTradingWalletBalanceCommand(logger, tradingWalletService,
getTradingWalletBalanceCommandValidator, privateKeyService, privateKeyValidator)
const getBalanceCommand = new GetBalanceCommand(logger, tradingWalletService,
getBalanceCommandValidator, privateKeyService, privateKeyValidator)

const createWalletCommand = new CreateWalletCommand(logger, tradingWalletService,
createWalletCommandValidator, privateKeyService, privateKeyValidator)
Expand All @@ -55,7 +55,7 @@ module.exports = {
createWalletCommand,
depositEthCommand,
getAddressCommand,
getTradingWalletBalanceCommand,
getBalanceCommand,
signCommand,
withdrawCommand,
}
2 changes: 1 addition & 1 deletion src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const commandList = require('./commandList')
const CreateWalletCommand = require('./CreateWalletCommand')
const DepositEthCommand = require('./DepositEthCommand')
const GetAddressCommand = require('./GetAddressCommand')
const GetTradingWalletBalanceCommand = require('./GetTradingWalletBalanceCommand')
const GetTradingWalletBalanceCommand = require('./GetBalanceCommand')
const OrderSignCommand = require('./OrderSignCommand')

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const withdrawSchema = customJoiValidator.object()
draft: customJoiValidator.boolean(),
})

class GetTradingWalletBalanceCommandValidator extends BaseValidator {
class GetBalanceCommandValidator extends BaseValidator {
getBalance(getBalanceData) {
return this.constructor.validate(getBalanceData, withdrawSchema)
}
}

module.exports = GetTradingWalletBalanceCommandValidator
module.exports = GetBalanceCommandValidator
10 changes: 5 additions & 5 deletions tests/unit/commands/getTradingWalletBalanceCommand.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ const logger = require('../../../src/logger')
const TradingWalletServiceBuilder = require('../../../src/factories/TradingWalletServiceBuilder')
const PrivateKeyValidator = require('../../../src/validators/PrivateKeyValidator')

const GetTradingWalletBalanceCommandValidator = require('../../../src/validators/GetTradingWalletBalanceCommandValidator')
const GetTradingWalletBalanceCommand = require('../../../src/commands/GetBalanceCommand')
const GetBalanceCommandValidator = require('../../../src/validators/GetBalanceCommandValidator')
const GetBalanceCommand = require('../../../src/commands/GetBalanceCommand')

const getTradingWalletBalanceCommandValidator = new GetTradingWalletBalanceCommandValidator(logger)
const getBalanceCommandValidator = new GetBalanceCommandValidator(logger)

const tradingWalletService = TradingWalletServiceBuilder.build()

const privateKeyValidator = new PrivateKeyValidator(logger)
const privateKeyService = new PrivateKeyService(logger)

const getTradingWalletBalanceCommand = new GetTradingWalletBalanceCommand(logger, tradingWalletService,
getTradingWalletBalanceCommandValidator, privateKeyService, privateKeyValidator)
const getTradingWalletBalanceCommand = new GetBalanceCommand(logger, tradingWalletService,
getBalanceCommandValidator, privateKeyService, privateKeyValidator)

afterEach(() => {
sandbox.restore()
Expand Down

0 comments on commit 1749d4f

Please sign in to comment.