@clonegod/ttd-sui-common 1.0.48 → 1.0.50

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.
@@ -7,6 +7,7 @@ export declare class TransactionResultChecker extends AbstractTransactionResultC
7
7
  transactionParser: SuiTransactionParser;
8
8
  leadgerService: LedgerService;
9
9
  constructor(env_args: EnvArgs, event_emitter: EventEmitter, wallet_address: string, ledgerService: LedgerService);
10
+ private isValidTransactionResult;
10
11
  check_tx_result_interval(): Promise<void>;
11
12
  on_subscibe_transaction(): void;
12
13
  private processTransactionResult;
@@ -20,6 +20,12 @@ class TransactionResultChecker extends trade_1.AbstractTransactionResultCheck {
20
20
  this.transactionParser = new sui_tx_parser_1.SuiTransactionParser(wallet_address);
21
21
  this.leadgerService = ledgerService;
22
22
  }
23
+ isValidTransactionResult(txReceipt) {
24
+ var _a, _b, _c, _d;
25
+ const success = (_c = (_b = (_a = txReceipt.transaction) === null || _a === void 0 ? void 0 : _a.effects) === null || _b === void 0 ? void 0 : _b.status) === null || _c === void 0 ? void 0 : _c.success;
26
+ const balance_changes = (_d = txReceipt.transaction) === null || _d === void 0 ? void 0 : _d.balance_changes;
27
+ return !success || (success && balance_changes && balance_changes.length > 0);
28
+ }
23
29
  check_tx_result_interval() {
24
30
  return __awaiter(this, void 0, void 0, function* () {
25
31
  const check_start_time = Date.now();
@@ -40,8 +46,10 @@ class TransactionResultChecker extends trade_1.AbstractTransactionResultCheck {
40
46
  txReceipt['transaction']['signatures'] = [];
41
47
  txReceipt = (0, index_1.decodeBytes)(txReceipt);
42
48
  (0, dist_1.log_info)(`Received transaction result via polling: ${this.txid}`);
43
- clearInterval(intervalId);
44
- yield this.processTransactionResult(txReceipt, 'interval');
49
+ if (this.isValidTransactionResult(txReceipt)) {
50
+ clearInterval(intervalId);
51
+ yield this.processTransactionResult(txReceipt, 'interval');
52
+ }
45
53
  }
46
54
  else {
47
55
  clearInterval(intervalId);
@@ -57,7 +65,6 @@ class TransactionResultChecker extends trade_1.AbstractTransactionResultCheck {
57
65
  }
58
66
  on_subscibe_transaction() {
59
67
  this.event_emitter.once(`SUI_TX_RESULT_${this.txid}`, (response) => __awaiter(this, void 0, void 0, function* () {
60
- var _a, _b, _c, _d, _e;
61
68
  (0, dist_1.log_info)(`receive tx result notification, txid=${this.txid}`);
62
69
  if (response.transaction) {
63
70
  this.processTransactionResult(response, 'grpc');
@@ -71,15 +78,12 @@ class TransactionResultChecker extends trade_1.AbstractTransactionResultCheck {
71
78
  console.log('txReceipt is empty', txReceipt);
72
79
  continue;
73
80
  }
74
- const success = (_c = (_b = (_a = txReceipt.transaction) === null || _a === void 0 ? void 0 : _a.effects) === null || _b === void 0 ? void 0 : _b.status) === null || _c === void 0 ? void 0 : _c.success;
75
- const balance_changes = (_e = (_d = txReceipt.transaction) === null || _d === void 0 ? void 0 : _d.balance_changes) === null || _e === void 0 ? void 0 : _e.length;
76
- const isValidResult = !success || (success && balance_changes.length > 0);
77
- if (isValidResult) {
81
+ if (this.isValidTransactionResult(txReceipt)) {
78
82
  this.processTransactionResult(txReceipt, 'grpc2');
79
83
  break;
80
84
  }
81
85
  else {
82
- (0, dist_1.log_warn)(`re-fetch tx result by ledgerService failed, i=${i}, txid=${this.txid}`);
86
+ (0, dist_1.log_warn)(`re-fetch tx result by ledgerService failed, i=${i}, txid=${this.txid}, retry soon...`);
83
87
  console.dir(txReceipt, { depth: 4 });
84
88
  }
85
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sui-common",
3
- "version": "1.0.48",
3
+ "version": "1.0.50",
4
4
  "description": "Sui common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",