@clonegod/ttd-sui-common 1.0.29 → 1.0.31

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.
@@ -56,18 +56,28 @@ class TransactionResultChecker extends trade_1.AbstractTransactionResultCheck {
56
56
  });
57
57
  }
58
58
  on_subscibe_transaction() {
59
- this.event_emitter.once(`SUI_TX_RESULT_${this.txid}`, (response) => {
59
+ this.event_emitter.once(`SUI_TX_RESULT_${this.txid}`, (response) => __awaiter(this, void 0, void 0, function* () {
60
60
  (0, dist_1.log_info)(`receive tx result notification, txid=${this.txid}`);
61
61
  if (response.transaction) {
62
62
  this.processTransactionResult(response, 'grpc');
63
+ return;
63
64
  }
64
- else {
65
- (0, dist_1.log_warn)(`re-fetch tx result by ledgerService, txid=${this.txid}`);
66
- this.leadgerService.getTransaction(this.txid, ['*']).then((txReceipt) => {
67
- this.processTransactionResult(txReceipt, 'grpc2');
68
- });
65
+ (0, dist_1.log_warn)(`re-fetch tx result by ledgerService start, txid=${this.txid}`);
66
+ for (let i = 1; i <= 6; i++) {
67
+ let txReceipt = null;
68
+ try {
69
+ txReceipt = yield this.leadgerService.getTransaction(this.txid, ['*']);
70
+ if (txReceipt) {
71
+ this.processTransactionResult(txReceipt, 'grpc2');
72
+ break;
73
+ }
74
+ }
75
+ catch (error) {
76
+ (0, dist_1.log_warn)(`re-fetch tx result by ledgerService failed (i=${i}), txid=${this.txid}, error=${error.message}`);
77
+ }
78
+ yield (0, dist_1.sleep)(500);
69
79
  }
70
- });
80
+ }));
71
81
  }
72
82
  processTransactionResult(txReceipt, source) {
73
83
  return __awaiter(this, void 0, void 0, function* () {
@@ -6,5 +6,5 @@ export declare class SuiTxSender {
6
6
  sui_client: SuiClient;
7
7
  grpcClient: SuiGrpcClient;
8
8
  constructor(appConfig: AppConfig, sui_client: SuiClient, grpcClient: SuiGrpcClient);
9
- send_tx: (signedTxBytes: string, signature: string, txDigest: string, send_type?: string, max_retry?: number) => Promise<void>;
9
+ send_tx: (signedTxBytes: string, signature: string, txDigest: string) => Promise<void>;
10
10
  }
@@ -13,42 +13,31 @@ exports.SuiTxSender = void 0;
13
13
  const dist_1 = require("@clonegod/ttd-core/dist");
14
14
  class SuiTxSender {
15
15
  constructor(appConfig, sui_client, grpcClient) {
16
- this.send_tx = (signedTxBytes_1, signature_1, txDigest_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_type = 'grpc', max_retry = 3) {
16
+ this.send_tx = (signedTxBytes, signature, txDigest) => __awaiter(this, void 0, void 0, function* () {
17
17
  const bcsBytes = Buffer.from(signedTxBytes, 'base64');
18
18
  const signatureBytes = Buffer.from(signature, 'base64');
19
- if (send_type.toLowerCase() === 'grpc') {
20
- for (let i = 0; i < max_retry; i++) {
21
- try {
22
- let response = yield this.grpcClient.transactionService.executeTransaction(bcsBytes, signatureBytes);
23
- this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, response);
19
+ try {
20
+ let _response = yield this.sui_client.executeTransactionBlock({
21
+ transactionBlock: signedTxBytes,
22
+ signature: signature,
23
+ options: {
24
+ showEvents: true,
25
+ showBalanceChanges: true,
26
+ showObjectChanges: true,
27
+ showEffects: true
24
28
  }
25
- catch (error) {
26
- (0, dist_1.log_error)(`submit tx to grpc failed`, error);
27
- }
28
- }
29
+ });
30
+ this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, txDigest);
29
31
  }
30
- else if (send_type.toLowerCase() === 'rpc') {
31
- for (let i = 0; i < max_retry; i++) {
32
- try {
33
- let _response = yield this.sui_client.executeTransactionBlock({
34
- transactionBlock: signedTxBytes,
35
- signature: signature,
36
- options: {
37
- showEvents: true,
38
- showBalanceChanges: true,
39
- showObjectChanges: true,
40
- showEffects: true
41
- }
42
- });
43
- this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, txDigest);
44
- }
45
- catch (error) {
46
- (0, dist_1.log_error)(`submit tx to sui_client failed`, error);
47
- }
32
+ catch (error) {
33
+ (0, dist_1.log_error)(`send tx by rpc failed!!! txid=${txDigest}`, error);
34
+ try {
35
+ let response = yield this.grpcClient.transactionService.executeTransaction(bcsBytes, signatureBytes);
36
+ this.appConfig.emit(`SUI_TX_RESULT_${txDigest}`, response);
37
+ }
38
+ catch (error) {
39
+ (0, dist_1.log_error)(`send tx by grpc failed!!! txid=${txDigest}`, error);
48
40
  }
49
- }
50
- else {
51
- throw new Error(`not support send type: ${send_type}`);
52
41
  }
53
42
  });
54
43
  this.appConfig = appConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sui-common",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Sui common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",