@clonegod/ttd-sui-common 1.0.73 → 1.0.75

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.
@@ -37,6 +37,7 @@ exports.GrpcConnection = void 0;
37
37
  const grpc = __importStar(require("@grpc/grpc-js"));
38
38
  const protoLoader = __importStar(require("@grpc/proto-loader"));
39
39
  const path = __importStar(require("path"));
40
+ const dist_1 = require("@clonegod/ttd-core/dist");
40
41
  class GrpcConnection {
41
42
  constructor(grpc_endpoint, grpc_token) {
42
43
  this.channel = null;
@@ -69,7 +70,7 @@ class GrpcConnection {
69
70
  'grpc.http2.max_header_list_size': 16384,
70
71
  'grpc.http2.initial_window_size': 65535,
71
72
  });
72
- console.log(`create gRPC channel, endpoint= ${this.endpoint}`);
73
+ (0, dist_1.log_info)(`======> create grpc channel, endpoint= ${this.endpoint}`);
73
74
  }
74
75
  return this.channel;
75
76
  }
@@ -1,5 +1,5 @@
1
1
  import { QuoteResultType } from "@clonegod/ttd-core";
2
- import { AbastrcatTrade, AppConfig, TradeContext } from "@clonegod/ttd-core/dist";
2
+ import { AbastrcatTrade, AppConfig, CHAIN_ID, TradeContext } from "@clonegod/ttd-core/dist";
3
3
  import { SuiClient } from "@mysten/sui/client";
4
4
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
5
5
  import { Transaction } from '@mysten/sui/transactions';
@@ -7,6 +7,7 @@ import { PoolObjectInfo, SuiGrpcClient, SuiTxSender } from '../index';
7
7
  import { SimpleRedisClient } from '../redis';
8
8
  export declare abstract class AbstractSuiDexTradePlus extends AbastrcatTrade {
9
9
  protected appConfig: AppConfig;
10
+ chain_id: CHAIN_ID.SUI;
10
11
  protected group_wallets: Ed25519Keypair[];
11
12
  protected wallet: Ed25519Keypair;
12
13
  protected walletMode: 'single' | 'multi';
@@ -34,6 +35,7 @@ export declare abstract class AbstractSuiDexTradePlus extends AbastrcatTrade {
34
35
  protected getObjectInfo(objectId: string): Promise<PoolObjectInfo | null>;
35
36
  protected compareBigIntBalance(a: any, b: any): number;
36
37
  protected mergeTokenObjects(tx: Transaction, primaryCoin: any, objectsToMerge: any[], tokenSymbol: string): void;
38
+ protected try_refresh_wallet_objects(wallet: string, txid: string, try_times?: number, try_delay_ms?: number): void;
37
39
  abstract execute(context: TradeContext, retryCount?: number): Promise<string>;
38
40
  protected abstract initConfigs(): Promise<void>;
39
41
  }
@@ -316,5 +316,15 @@ class AbstractSuiDexTradePlus extends dist_1.AbastrcatTrade {
316
316
  tx.mergeCoins(primaryCoin, other_objects);
317
317
  (0, dist_1.log_info)(`✅ ${tokenSymbol} 进行对象合并,涉及 ${other_objects.length} 个对象`);
318
318
  }
319
+ try_refresh_wallet_objects(wallet, txid, try_times = 2, try_delay_ms = 300) {
320
+ setTimeout(() => {
321
+ for (let i = 1; i <= try_times; i++) {
322
+ setTimeout(() => {
323
+ let group_id = this.appConfig.trade_runtime.group.id;
324
+ this.appConfig.arb_cache.redis_event_publisher.publish_wallet_raw_tx_event(group_id, wallet, { group_id, wallet, txid, remark: 'PRE_REFRESH_OBJECTS' });
325
+ }, i * try_delay_ms);
326
+ }
327
+ }, 0);
328
+ }
319
329
  }
320
330
  exports.AbstractSuiDexTradePlus = AbstractSuiDexTradePlus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sui-common",
3
- "version": "1.0.73",
3
+ "version": "1.0.75",
4
4
  "description": "Sui common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",