@clonegod/ttd-core 2.0.34 → 2.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import BN from 'bn.js';
2
2
  import Decimal from 'decimal.js';
3
3
  import fs from "fs";
4
- import { ArbCache, StandardPoolInfoType, StandardTokenInfoType, TokenPriceWithAmountType, TradeCommandLineArgs, TradeResponseType, UniqueOrderbookIdType } from '../types';
4
+ import { ArbCache, StandardPoolInfoType, StandardTokenInfoType, TokenPriceWithAmountType, TradeCommandLineArgs, TradeResponseType, UniqueOrderbookIdType, WalletInfoType } from '../types';
5
5
  import * as cache from './cache';
6
6
  export * from './analyze';
7
7
  export * from './app_config';
@@ -201,6 +201,7 @@ export declare function load_wallet(group_id: string, only_pubkey?: boolean): {
201
201
  public_key: string;
202
202
  private_key: string;
203
203
  };
204
+ export declare function load_wallet_multi(group_ids: string[], only_pubkey?: boolean): WalletInfoType[];
204
205
  export declare const success: (data: any) => {
205
206
  code: number;
206
207
  msg: string;
package/dist/index.js CHANGED
@@ -72,6 +72,7 @@ exports.mkdirSync = mkdirSync;
72
72
  exports.getServerInfo = getServerInfo;
73
73
  exports.getIPAddress = getIPAddress;
74
74
  exports.load_wallet = load_wallet;
75
+ exports.load_wallet_multi = load_wallet_multi;
75
76
  exports.chunkArray = chunkArray;
76
77
  require('dotenv').config();
77
78
  const bn_js_1 = __importDefault(require("bn.js"));
@@ -630,6 +631,32 @@ function load_wallet(group_id, only_pubkey = true) {
630
631
  }
631
632
  return wallet;
632
633
  }
634
+ function load_wallet_multi(group_ids, only_pubkey = true) {
635
+ if (!group_ids || group_ids.length < 1) {
636
+ throw new Error('Invalid param: group_ids is empty or null !');
637
+ }
638
+ let wallet_dir = process.env.WALLET_DIR;
639
+ if (!wallet_dir) {
640
+ wallet_dir = path_1.default.join((0, exports.home_dir)(), 'data', 'keypairs');
641
+ }
642
+ let wallets = [];
643
+ for (let group_id of group_ids) {
644
+ let file_path = path_1.default.join(wallet_dir, `${group_id}.json`);
645
+ log_info(`Load wallet, group_id=${group_id}, file_path=${file_path}`);
646
+ let wallet = readFile(file_path, true, false);
647
+ if (only_pubkey) {
648
+ wallets.push({
649
+ public_key: wallet.public_key,
650
+ private_key: ''
651
+ });
652
+ }
653
+ else {
654
+ wallets.push(wallet);
655
+ }
656
+ }
657
+ return wallets;
658
+ }
659
+ console.log(load_wallet_multi(['BSC-DEV', 'BSC-DEV2'], false));
633
660
  const success = (data) => {
634
661
  return {
635
662
  code: 200,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "2.0.34",
3
+ "version": "2.0.35",
4
4
  "description": "Common types and utilities for trading systems - use `npm run push` to publish",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",