@clonegod/ttd-sol-common 2.0.9 → 2.0.11

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.
@@ -20,6 +20,7 @@ export declare class TransactionResultChecker extends AbstractTransactionResultC
20
20
  trade_result_already_processed: boolean;
21
21
  connection: Connection;
22
22
  constructor(env_args: any, event_emitter: EventEmitter);
23
+ set_context(context: TradeContext): this;
23
24
  init_tx_status(): this;
24
25
  check(): Promise<void>;
25
26
  on_subscibe_transaction(): void;
@@ -23,9 +23,14 @@ class TransactionResultChecker extends dist_1.AbstractTransactionResultCheck {
23
23
  commitment: common_1.COMMITMENT_LEVEL.CONFIRMED,
24
24
  });
25
25
  this.check_count = 0;
26
- this.transactionParser = new tx_result_parse_1.TransactionResultParser(this.env_args, new web3_js_1.PublicKey(this.wallet), this.event_emitter);
26
+ this.transactionParser = null;
27
27
  this.trade_result_already_processed = false;
28
28
  }
29
+ set_context(context) {
30
+ super.set_context(context);
31
+ this.transactionParser = new tx_result_parse_1.TransactionResultParser(this.env_args, new web3_js_1.PublicKey(this.wallet), this.event_emitter);
32
+ return this;
33
+ }
29
34
  init_tx_status() {
30
35
  let empty_trade_result = JSON.parse(JSON.stringify({
31
36
  group_id: this.context.group_id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "push": "npm run build && npm publish"
14
14
  },
15
15
  "dependencies": {
16
- "@clonegod/ttd-core": "2.1.3",
16
+ "@clonegod/ttd-core": "2.1.4",
17
17
  "@solana/web3.js": "1.91.6",
18
18
  "rpc-websockets": "7.10.0",
19
19
  "axios": "^1.2.3",
@@ -43,10 +43,21 @@ export class TransactionResultChecker extends AbstractTransactionResultCheck {
43
43
  })
44
44
 
45
45
  this.check_count = 0
46
- this.transactionParser = new TransactionResultParser(this.env_args, new PublicKey(this.wallet), this.event_emitter)
46
+ // transactionParser 将在 set_context() 中创建,因为此时 wallet 还未初始化
47
+ this.transactionParser = null as any
47
48
  this.trade_result_already_processed = false
48
49
  }
49
50
 
51
+ /**
52
+ * 重写 set_context,在设置 wallet 后创建 transactionParser
53
+ */
54
+ set_context(context: TradeContext) {
55
+ super.set_context(context)
56
+ // 在 wallet 被设置后,创建 transactionParser
57
+ this.transactionParser = new TransactionResultParser(this.env_args, new PublicKey(this.wallet), this.event_emitter)
58
+ return this
59
+ }
60
+
50
61
  /**
51
62
  * set trade initial status: PROCESSING
52
63
  */