@clonegod/ttd-sui-common 1.0.71 → 1.0.72

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.
@@ -6,7 +6,7 @@ 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_grpc?: boolean, read_mask_fields?: string[]) => Promise<void>;
9
+ send_tx: (signedTxBytes: string, signature: string, txDigest: string, send_type: "grpc" | "rpc" | "all", read_mask_fields?: string[]) => Promise<void>;
10
10
  private sendTxByGrpc;
11
11
  private sendTxByRpc;
12
12
  }
@@ -13,15 +13,21 @@ 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_grpc = false, read_mask_fields = ['transaction']) {
16
+ this.send_tx = (signedTxBytes_1, signature_1, txDigest_1, send_type_1, ...args_1) => __awaiter(this, [signedTxBytes_1, signature_1, txDigest_1, send_type_1, ...args_1], void 0, function* (signedTxBytes, signature, txDigest, send_type, read_mask_fields = ['transaction']) {
17
17
  const start_time = Date.now();
18
- if (send_grpc) {
18
+ if (send_type === 'grpc') {
19
19
  yield this.sendTxByGrpc(signedTxBytes, signature, txDigest, read_mask_fields);
20
20
  }
21
- else {
21
+ else if (send_type === 'rpc') {
22
22
  yield this.sendTxByRpc(signedTxBytes, signature, txDigest);
23
23
  }
24
- (0, dist_1.log_info)(`send_tx, txid=${txDigest}, send_grpc=${send_grpc}, cost=${Date.now() - start_time}ms`);
24
+ else {
25
+ yield Promise.race([
26
+ this.sendTxByGrpc(signedTxBytes, signature, txDigest, read_mask_fields),
27
+ this.sendTxByRpc(signedTxBytes, signature, txDigest)
28
+ ]);
29
+ }
30
+ (0, dist_1.log_info)(`send_tx, txid=${txDigest}, send_type=${send_type}, cost=${Date.now() - start_time}ms`);
25
31
  });
26
32
  this.appConfig = appConfig;
27
33
  this.sui_client = sui_client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sui-common",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
4
4
  "description": "Sui common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",