|
@@ -1,48 +1,7 @@
|
|
-import { Options, Proposals, IApplicant, IVote } from "../types";
|
|
|
|
|
|
+import { IApplicant, IVote } from "../types";
|
|
import moment from "moment";
|
|
import moment from "moment";
|
|
|
|
|
|
-export const parseArgs = (args: string[]): Options => {
|
|
|
|
- const inArgs = (term: string): boolean => {
|
|
|
|
- return args.find((a) => a.search(term) > -1) ? true : false;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const options: Options = {
|
|
|
|
- verbose: inArgs("--verbose") ? 2 : inArgs("--quiet") ? 0 : 1,
|
|
|
|
- channel: inArgs("--channel"),
|
|
|
|
- council: inArgs("--council"),
|
|
|
|
- forum: inArgs("--forum"),
|
|
|
|
- proposals: inArgs("--proposals"),
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- if (options.verbose > 1) console.debug("args", args, "\noptions", options);
|
|
|
|
- return options;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-export const printStatus = (
|
|
|
|
- opts: Options,
|
|
|
|
- data: {
|
|
|
|
- block: number;
|
|
|
|
- cats: number[];
|
|
|
|
- chain: string;
|
|
|
|
- posts: number[];
|
|
|
|
- proposals: Proposals;
|
|
|
|
- threads: number[];
|
|
|
|
- }
|
|
|
|
-): void => {
|
|
|
|
- if (opts.verbose < 1) return;
|
|
|
|
-
|
|
|
|
- const { block, chain, proposals, cats, posts, threads } = data;
|
|
|
|
- const date = formatTime();
|
|
|
|
- let message = `[${date}] Chain:${chain} Block:${block} `;
|
|
|
|
-
|
|
|
|
- if (opts.forum)
|
|
|
|
- message += `Post:${posts[1]} Cat:${cats[1]} Thread:${threads[1]} `;
|
|
|
|
-
|
|
|
|
- if (opts.proposals)
|
|
|
|
- message += `Proposals:${proposals.current} (Active:${proposals.active.length} Pending:${proposals.executing.length}) `;
|
|
|
|
-
|
|
|
|
- console.log(message);
|
|
|
|
-};
|
|
|
|
|
|
+export const mJoy = (mJoy: number) => (mJoy / 1000000).toFixed(2);
|
|
|
|
|
|
// time
|
|
// time
|
|
export const formatDate = (time?: number) => {
|
|
export const formatDate = (time?: number) => {
|