@fleupold/dex-contracts
Version:
Contracts for dFusion multi-token batch auction exchange
33 lines (32 loc) • 1.01 kB
JavaScript
import { factory } from "../src/logging";
const log = factory.getLogger("scripts.cancel_order");
const BatchExchange = artifacts.require("BatchExchange");
const argv = require("yargs")
.option("accountId", {
describe: "Account index of the order placer",
})
.option("orderIds", {
type: "string",
describe: "Order IDs to be canceled",
coerce: (str) => {
return str.split(",").map((o) => parseInt(o));
},
})
.demand(["accountId", "orderIds"])
.help(false)
.version(false).argv;
module.exports = async (callback) => {
try {
const accounts = await web3.eth.getAccounts();
log.info(`Using account ${accounts[argv.accountId]}`);
const instance = await BatchExchange.deployed();
await instance.cancelOrders(argv.orderIds, {
from: accounts[argv.accountId],
});
log.info(`Successfully cancelled orders with ID ${argv.orderIds}`);
callback();
}
catch (error) {
callback(error);
}
};