xud
Version:
Exchange Union Daemon
47 lines • 2.26 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handler = exports.builder = exports.describe = exports.command = void 0;
const xudrpc_pb_1 = require("../../proto/xudrpc_pb");
const command_1 = require("../command");
exports.command = 'addpair <pair_id|base_currency> [quote_currency]';
exports.describe = 'add a trading pair';
exports.builder = (argv) => argv
.positional('pair_id', {
description: 'the pair ticker id or base currency',
type: 'string',
})
.positional('quote_currency', {
description: 'the currency used to quote a price',
type: 'string',
})
.example('$0 addpair LTC/BTC', 'add the LTC/BTC trading pair by ticker id')
.example('$0 addpair LTC BTC', 'add the LTC/BTC trading pair by currencies');
exports.handler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
const request = new xudrpc_pb_1.AddPairRequest();
let baseCurrency;
let quoteCurrency;
if (argv.base_currency && argv.quote_currency) {
baseCurrency = argv.base_currency;
quoteCurrency = argv.quote_currency;
}
else {
[baseCurrency, quoteCurrency] = argv.pair_id.split('/');
if (!baseCurrency || !quoteCurrency) {
console.error(`${argv.pair_id} is not a valid pair`);
process.exit(1);
}
}
request.setBaseCurrency(baseCurrency.toUpperCase());
request.setQuoteCurrency(quoteCurrency.toUpperCase());
(yield command_1.loadXudClient(argv)).addPair(request, command_1.callback(argv));
});
//# sourceMappingURL=addpair.js.map