@nexex/cli
Version:
40 lines • 1.57 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("ethers/utils");
const MarketBase_1 = __importDefault(require("../../MarketBase"));
class MarketCancel extends MarketBase_1.default {
async run() {
const { flags, args: { orderHash, amount } } = this.parse(MarketCancel);
const obClient = this.initObClient(flags);
const [walletAddr, _, order] = await Promise.all([
this.readWalletAddr(),
this.initApi(),
obClient.queryOrder(orderHash)
]);
if (walletAddr.toLowerCase() !== order.signedOrder.maker.toLowerCase()) {
console.log('not maker of order');
this.exit(1);
}
const wallet = await this.readWallet();
let cancelAmount = amount ? utils_1.parseEther(amount) : undefined;
const tx = await this.dex.exchange.cancelOrder(wallet.connect(this.dex.eth), order.signedOrder, cancelAmount);
await tx.wait();
console.log(`cancel ${orderHash} success`);
this.exit(0);
}
}
MarketCancel.description = 'describe the command here';
MarketCancel.examples = [
`$ nexex-cli hello
hello world from ./src/hello.ts!
`
];
MarketCancel.flags = {
...MarketBase_1.default.flags
};
MarketCancel.args = [{ name: 'orderHash', required: true }, { name: 'amount' }];
exports.default = MarketCancel;
//# sourceMappingURL=cancel.js.map