UNPKG

@fleupold/dex-contracts

Version:

Contracts for dFusion multi-token batch auction exchange

41 lines (40 loc) 1.82 kB
"use strict"; 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 }); const util_1 = require("./util"); function parseArgs() { const args = process.argv.slice(4); const index = args.indexOf("--network"); if (index > -1) { args.splice(index, 2); } return args; } module.exports = (callback) => __awaiter(void 0, void 0, void 0, function* () { try { const args = parseArgs(); if (args.length < 1) { callback("Error: This script requires arguments - <functionName> [..args]"); } const [functionName, ...arg] = args; const exchange = yield util_1.getBatchExchange(artifacts); const info = yield exchange.contract.methods[functionName](...arg).call(); // Note that this script is intended to be used for bash scripting and // one would usually grep for the results of this execution. Thus, // the raw output is printed rather than include irrelevant log details. // eslint-disable-next-line no-console console.log(info); callback(); } catch (error) { callback(error); } });