@clonegod/ttd-core 2.0.10 → 2.0.12

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.
@@ -28,7 +28,6 @@ class AppConfig extends events_1.default {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  this.arb_cache = (0, __1.getArbCache)(this.env_args);
30
30
  yield this.arb_cache.init();
31
- this.arb_cache.listen_trade_result(this);
32
31
  let common_service_config = yield this.arb_cache.get_common_service();
33
32
  if ((0, __1.isEmpty)(common_service_config)) {
34
33
  throw new Error(`get_common_service from cache failed! read from cache=${(0, __1.to_json_str)(common_service_config)}`);
@@ -24,6 +24,7 @@ class TradeAppConfig extends app_config_1.AppConfig {
24
24
  });
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
26
  yield _super.init.call(this);
27
+ this.arb_cache.listen_trade_result(this);
27
28
  });
28
29
  }
29
30
  init_trade_runtime() {
@@ -1,4 +1,5 @@
1
1
  import { AppConfig } from './app_config';
2
2
  export * from './env_args';
3
3
  export * from './app_config';
4
+ export * from './app_trade_config';
4
5
  export declare const getGlobalAppConfig: () => AppConfig;
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.getGlobalAppConfig = void 0;
18
18
  __exportStar(require("./env_args"), exports);
19
19
  __exportStar(require("./app_config"), exports);
20
+ __exportStar(require("./app_trade_config"), exports);
20
21
  const getGlobalAppConfig = () => {
21
22
  let app_config = global.app_config;
22
23
  if (!app_config) {
@@ -39,6 +39,10 @@ class ArbCache {
39
39
  ]);
40
40
  this.redis_event_publisher = (0, index_1.getArbEventPublisher)(this);
41
41
  (0, index_1.mkdirSync)(path_1.default.join('config', this.chain_id, 'bak').toLowerCase(), true);
42
+ yield Promise.all([
43
+ this.get_token_list_no_cache(),
44
+ this.get_pool_list_no_cache()
45
+ ]);
42
46
  if (((_a = process.env.APP_NAME) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'config-center') {
43
47
  yield this.init_configs();
44
48
  }
@@ -16,7 +16,9 @@ export declare abstract class AbstractTransactionResultCheck {
16
16
  intervalId: any;
17
17
  check_count: number;
18
18
  trade_result_already_processed: boolean;
19
- constructor(env_args: EnvArgs, event_emitter: EventEmitter, context: TradeContext, txid: string);
19
+ constructor(env_args: EnvArgs, event_emitter: EventEmitter);
20
+ set_context(context: TradeContext): this;
21
+ set_txid(txid: string): this;
20
22
  init_tx_status(): this;
21
23
  check(): Promise<void>;
22
24
  abstract check_tx_result_interval(): void;
@@ -12,19 +12,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AbstractTransactionResultCheck = void 0;
13
13
  const __1 = require("..");
14
14
  class AbstractTransactionResultCheck {
15
- constructor(env_args, event_emitter, context, txid) {
15
+ constructor(env_args, event_emitter) {
16
16
  this.env_args = env_args;
17
17
  this.event_emitter = event_emitter;
18
+ this.check_count = 0;
19
+ this.trade_result_already_processed = false;
20
+ }
21
+ set_context(context) {
18
22
  this.context = context;
19
23
  this.group_id = context.group_id;
20
24
  this.wallet = context.trade_runtime.wallet.public_key;
21
- this.txid = txid;
22
25
  this.price_msg = context.price_msg;
23
26
  this.order_msg = context.order_msg;
24
27
  this.pool_info = context.pool_info;
25
28
  this.trace_id = context.order_msg.order_trace_id;
26
- this.check_count = 0;
27
- this.trade_result_already_processed = false;
29
+ return this;
30
+ }
31
+ set_txid(txid) {
32
+ this.txid = txid;
33
+ return this;
28
34
  }
29
35
  init_tx_status() {
30
36
  let empty_trade_result = JSON.parse(JSON.stringify({
@@ -94,7 +94,7 @@ const handle_order_message = (trade_appconfig, trade_instance, tx_result_checker
94
94
  txid
95
95
  };
96
96
  global.event_emitter = trade_appconfig;
97
- tx_result_checker.init_tx_status().check();
97
+ tx_result_checker.set_context(context).set_txid(txid).init_tx_status().check();
98
98
  trade_appconfig.subscribe_wallet_raw_txn_event();
99
99
  }
100
100
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
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",