Skip to content

Commit

Permalink
feat: removeorder output changed to a more meaningful message (#1526)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsercano committed Oct 23, 2020
1 parent 8d10df0 commit d65e593
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/cli/commands/removeorder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Arguments, Argv } from 'yargs';
import { RemoveOrderRequest } from '../../proto/xudrpc_pb';
import { RemoveOrderRequest, RemoveOrderResponse } from '../../proto/xudrpc_pb';
import { callback, loadXudClient } from '../command';
import { coinsToSats } from '../utils';

Expand All @@ -18,11 +18,19 @@ export const builder = (argv: Argv) => argv
.example('$0 removeorder 79d2cd30-8a26-11ea-90cf-439fb244cf44', 'remove an order by id')
.example('$0 removeorder 79d2cd30-8a26-11ea-90cf-439fb244cf44 0.1', 'remove 0.1 quantity from an order by id');

const displayOutput = (orderId: string, removeOrderResponse: RemoveOrderResponse.AsObject) => {
if (removeOrderResponse.quantityOnHold === 0) {
console.log(`Order ${orderId} successfully removed.`);
} else {
console.log(`Order ${orderId} partially removed, remaining quantity on hold: ${removeOrderResponse.quantityOnHold}`);
}
};

export const handler = async (argv: Arguments<any>) => {
const request = new RemoveOrderRequest();
request.setOrderId(argv.order_id);
if (argv.quantity) {
request.setQuantity(coinsToSats(argv.quantity));
}
(await loadXudClient(argv)).removeOrder(request, callback(argv));
(await loadXudClient(argv)).removeOrder(request, callback(argv, displayOutput.bind(undefined, argv.order_id)));
};

0 comments on commit d65e593

Please sign in to comment.