@clonegod/ttd-sui-common 2.0.1 → 2.0.2

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.
@@ -10,7 +10,6 @@ class SuiDexEnvArgs extends sui_env_args_1.SuiEnvArgs {
10
10
  this.dex_id = (cfg.dex_id || '').toUpperCase();
11
11
  this.rpc_endpoint = cfg.rpc_endpoint;
12
12
  this.ws_endpoint = cfg.ws_endpoint;
13
- this.grpc_endpoint = cfg.grpc_endpoint;
14
13
  this.pair = cfg.pair ?? '';
15
14
  this.group_id = cfg.group_id ?? '';
16
15
  this.quote_pool_address = cfg.quote_pool_address;
@@ -11,6 +11,8 @@ class SuiEnvArgs extends dist_1.EnvArgs {
11
11
  this.server_id = cfg.server_id ?? '';
12
12
  this.redis_host = cfg.redis_host;
13
13
  this.redis_port = String(cfg.redis_port);
14
+ this.grpc_endpoint = cfg.grpc_endpoint;
15
+ this.grpc_token = cfg.grpc_token ?? '';
14
16
  this.server_ip_list = cfg.server_ip_list ?? '';
15
17
  this.ip_exclude_prefix = cfg.ip_exclude_prefix ?? '';
16
18
  this.config_center_host = cfg.config_center_host;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SuiGrpcClient = void 0;
4
+ const dist_1 = require("@clonegod/ttd-core/dist");
4
5
  const grpc_connection_1 = require("./grpc-connection");
5
6
  const ledger_service_1 = require("./ledger-service");
6
7
  const state_service_1 = require("./state-service");
@@ -13,7 +14,11 @@ class SuiGrpcClient {
13
14
  this.init();
14
15
  }
15
16
  init() {
16
- const grpcClient = grpc_connection_1.GrpcConnection.getInstance(process.env.SUI_GRPC_ENDPOINT, process.env.SUI_GRPC_TOKEN);
17
+ const { grpc_endpoint, grpc_token } = (0, dist_1.getCoreEnv)();
18
+ if (!grpc_endpoint || !grpc_token) {
19
+ throw new Error('GRPC_ENDPOINT / GRPC_TOKEN 未配置(SuiGrpcClient 需 gRPC 端点)');
20
+ }
21
+ const grpcClient = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
17
22
  this.ledgerService = new ledger_service_1.LedgerService(grpcClient);
18
23
  this.transactionService = new transaction_service_1.TransactionService(grpcClient);
19
24
  this.stateService = new state_service_1.StateService(grpcClient);
package/dist/test/test.js CHANGED
@@ -49,10 +49,10 @@ const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
49
49
  });
50
50
  const suiProto = grpc.loadPackageDefinition(packageDefinition);
51
51
  const LedgerService = suiProto.sui.rpc.v2.LedgerService;
52
- const endpoint = process.env.SUI_GRPC_ENDPOINT;
53
- const token = process.env.SUI_GRPC_TOKEN;
52
+ const endpoint = process.env.GRPC_ENDPOINT;
53
+ const token = process.env.GRPC_TOKEN;
54
54
  if (!endpoint || !token) {
55
- throw new Error('SUI_GRPC_ENDPOINT and SUI_GRPC_TOKEN must be set');
55
+ throw new Error('GRPC_ENDPOINT and GRPC_TOKEN must be set');
56
56
  }
57
57
  const client = new LedgerService(endpoint, grpc.credentials.createSsl(), {
58
58
  'grpc.keepalive_time_ms': 30000,
@@ -5,8 +5,8 @@ const fs_1 = require("fs");
5
5
  const grpc_connection_1 = require("../grpc/grpc-connection");
6
6
  const subscription_service_1 = require("../grpc/subscription-service");
7
7
  const utils_1 = require("../utils");
8
- const grpc_endpoint = process.env.SUI_GRPC_ENDPOINT;
9
- const grpc_token = process.env.SUI_GRPC_TOKEN;
8
+ const grpc_endpoint = process.env.GRPC_ENDPOINT;
9
+ const grpc_token = process.env.GRPC_TOKEN;
10
10
  const test_subscribe_checkpoints = async () => {
11
11
  const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
12
12
  const subscriptionService = new subscription_service_1.SubscriptionService(connection);
@@ -4,8 +4,8 @@ const dist_1 = require("@clonegod/ttd-core/dist");
4
4
  const grpc_connection_1 = require("../grpc/grpc-connection");
5
5
  const ledger_service_1 = require("../grpc/ledger-service");
6
6
  const state_service_1 = require("../grpc/state-service");
7
- const grpc_endpoint = process.env.SUI_GRPC_ENDPOINT;
8
- const grpc_token = process.env.SUI_GRPC_TOKEN;
7
+ const grpc_endpoint = process.env.GRPC_ENDPOINT;
8
+ const grpc_token = process.env.GRPC_TOKEN;
9
9
  const test_get_service_info = async () => {
10
10
  const connection = grpc_connection_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
11
11
  const ledgerService = new ledger_service_1.LedgerService(connection);
@@ -23,10 +23,11 @@ const GRPC_CLIENT_OPTIONS = {
23
23
  'grpc.max_reconnect_backoff_ms': 30000,
24
24
  };
25
25
  function buildGrpcCore(opts = {}) {
26
- const endpoint = opts.endpoint ?? process.env.SUI_GRPC_ENDPOINT;
27
- const token = opts.token ?? process.env.SUI_GRPC_TOKEN;
26
+ const coreEnv = (0, dist_1.getCoreEnv)();
27
+ const endpoint = opts.endpoint ?? coreEnv.grpc_endpoint;
28
+ const token = opts.token ?? coreEnv.grpc_token;
28
29
  if (!endpoint)
29
- throw new Error('SUI_GRPC_ENDPOINT 未配置(集中执行器需 gRPC 端点)');
30
+ throw new Error('GRPC_ENDPOINT 未配置(集中执行器需 gRPC 端点)');
30
31
  const transport = new grpc_transport_1.GrpcTransport({
31
32
  host: endpoint,
32
33
  channelCredentials: grpc_js_1.ChannelCredentials.createSsl(),
@@ -9,8 +9,8 @@ const sui_tx_parser_1 = require("../parse/sui_tx_parser");
9
9
  const index_1 = require("../../index");
10
10
  const index_2 = require("../../index");
11
11
  async function test_get_tx_result() {
12
- const grpc_endpoint = process.env.SUI_GRPC_ENDPOINT || '';
13
- const grpc_token = process.env.SUI_GRPC_TOKEN || '';
12
+ const grpc_endpoint = process.env.GRPC_ENDPOINT || '';
13
+ const grpc_token = process.env.GRPC_TOKEN || '';
14
14
  const grpcConnection = index_1.GrpcConnection.getInstance(grpc_endpoint, grpc_token);
15
15
  const ledgerService = new index_1.LedgerService(grpcConnection);
16
16
  let wallet_address = '0x6367c8755b8c39cab7305bfa75cb17d050508d2e55f6862a7682377ad6d46ee7';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sui-common",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Sui common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",