@clonegod/ttd-sol-common 2.0.38 → 2.0.40

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.
@@ -13,7 +13,7 @@ function subscribe_pool_account_update(dex_id, pool_list, callback) {
13
13
  });
14
14
  ws_client.onMessage(((eventData) => {
15
15
  if (!eventData.data) {
16
- (0, dist_1.log_warn)(`[SolanaTradeAppConfig] subscribe_pool_events_from_multiple_providers: no data`, eventData);
16
+ (0, dist_1.log_warn)(`subscribe_pool_account_update: no data`, eventData);
17
17
  }
18
18
  else {
19
19
  callback(eventData);
@@ -0,0 +1,9 @@
1
+ import { AbstractTradeAppConfig } from "@clonegod/ttd-core/dist";
2
+ import { Connection, Keypair } from "@solana/web3.js";
3
+ export declare class SolanaTradeAppConfig extends AbstractTradeAppConfig {
4
+ connection: Connection;
5
+ keypair: Keypair;
6
+ constructor();
7
+ init(): Promise<void>;
8
+ subscribe_wallet_raw_txn_event(): void;
9
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaTradeAppConfig = void 0;
4
+ const dist_1 = require("@clonegod/ttd-core/dist");
5
+ class SolanaTradeAppConfig extends dist_1.AbstractTradeAppConfig {
6
+ constructor() {
7
+ super();
8
+ }
9
+ async init() {
10
+ await super.init();
11
+ this.subscribe_wallet_raw_txn_event();
12
+ (0, dist_1.log_info)('SolanaTradeAppConfig init ...');
13
+ }
14
+ subscribe_wallet_raw_txn_event() {
15
+ const transactionHandler = async (messageStr) => {
16
+ let messageObj = messageStr;
17
+ if (typeof messageStr === 'string') {
18
+ messageObj = JSON.parse(messageStr);
19
+ }
20
+ const tx_id = messageObj.transaction.signature;
21
+ (0, dist_1.log_info)(`Received transaction result via WebSocket: ${tx_id}`);
22
+ this.emit(dist_1.LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION + '#' + tx_id, messageObj);
23
+ };
24
+ const ws_port = process.env.STREAM_WS_TRADE_PORT || 10002;
25
+ const ws = new dist_1.WebSocketClient(`ws://127.0.0.1:${ws_port}`);
26
+ ws.onMessage(transactionHandler);
27
+ ws.connect();
28
+ }
29
+ }
30
+ exports.SolanaTradeAppConfig = SolanaTradeAppConfig;
@@ -0,0 +1 @@
1
+ export * from './SolanaTradeAppConfig';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./SolanaTradeAppConfig"), exports);
@@ -1,6 +1,6 @@
1
1
  export * from './tx_result_check';
2
2
  export * from './tx_result_parse';
3
- export * from './SolanaTradeAppConfig';
3
+ export * from '../config/SolanaTradeAppConfig';
4
4
  export * from './tx_builder';
5
5
  export * from './send';
6
6
  export * from './jito_tip_wallets';
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./tx_result_check"), exports);
18
18
  __exportStar(require("./tx_result_parse"), exports);
19
- __exportStar(require("./SolanaTradeAppConfig"), exports);
19
+ __exportStar(require("../config/SolanaTradeAppConfig"), exports);
20
20
  __exportStar(require("./tx_builder"), exports);
21
21
  __exportStar(require("./send"), exports);
22
22
  __exportStar(require("./jito_tip_wallets"), exports);
@@ -1,6 +1,6 @@
1
1
  import { TradeContext } from "@clonegod/ttd-core/dist";
2
2
  import { Connection, Keypair, Transaction, TransactionInstruction } from "@solana/web3.js";
3
- import { SolanaTradeAppConfig } from "./SolanaTradeAppConfig";
3
+ import { SolanaTradeAppConfig } from "../config/SolanaTradeAppConfig";
4
4
  import { JitoTipWalletManager } from "./jito_tip_wallets";
5
5
  export declare class SolTransactionBuilder {
6
6
  appConfig: SolanaTradeAppConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "2.0.38",
3
+ "version": "2.0.40",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -18,7 +18,7 @@ export function subscribe_pool_account_update(dex_id: DEX_ID, pool_list: Standar
18
18
  })
19
19
  ws_client.onMessage(((eventData: SolanaPoolAccountUpdateEventData): void => {
20
20
  if (!eventData.data) {
21
- log_warn(`[SolanaTradeAppConfig] subscribe_pool_events_from_multiple_providers: no data`, eventData);
21
+ log_warn(`subscribe_pool_account_update: no data`, eventData);
22
22
  } else {
23
23
  callback(eventData);
24
24
  }
@@ -1,4 +1,4 @@
1
- import { AbstractTradeAppConfig, log_info, log_error, WebSocketClient, LOCAL_EVENT_NAME } from "@clonegod/ttd-core/dist";
1
+ import { AbstractTradeAppConfig, LOCAL_EVENT_NAME, log_info, WebSocketClient } from "@clonegod/ttd-core/dist";
2
2
  import { Connection, Keypair } from "@solana/web3.js";
3
3
 
4
4
  export class SolanaTradeAppConfig extends AbstractTradeAppConfig {
@@ -6,12 +6,16 @@ export class SolanaTradeAppConfig extends AbstractTradeAppConfig {
6
6
  // 子类需要设置的属性
7
7
  public connection: Connection;
8
8
  public keypair: Keypair;
9
-
9
+
10
10
  constructor() {
11
11
  super();
12
- this.subscribe_wallet_raw_txn_event();
13
12
  }
14
13
 
14
+ async init() {
15
+ await super.init();
16
+ this.subscribe_wallet_raw_txn_event();
17
+ log_info('SolanaTradeAppConfig init ...');
18
+ }
15
19
 
16
20
  // 订阅 Wallet 在链上发生的tx data
17
21
  subscribe_wallet_raw_txn_event(): void {
@@ -30,7 +34,7 @@ export class SolanaTradeAppConfig extends AbstractTradeAppConfig {
30
34
  };
31
35
 
32
36
  const ws_port = process.env.STREAM_WS_TRADE_PORT || 10002;
33
- const ws = new WebSocketClient(`ws://localhost:${ws_port}`)
37
+ const ws = new WebSocketClient(`ws://127.0.0.1:${ws_port}`)
34
38
  ws.onMessage(transactionHandler);
35
39
  ws.connect();
36
40
 
@@ -39,7 +43,6 @@ export class SolanaTradeAppConfig extends AbstractTradeAppConfig {
39
43
  }
40
44
 
41
45
 
42
-
43
46
  }
44
47
 
45
48
 
@@ -0,0 +1,2 @@
1
+ export * from './SolanaTradeAppConfig';
2
+
@@ -1,6 +1,6 @@
1
1
  export * from './tx_result_check'
2
2
  export * from './tx_result_parse'
3
- export * from './SolanaTradeAppConfig'
3
+ export * from '../config/SolanaTradeAppConfig'
4
4
  export * from './tx_builder'
5
5
  export * from './send'
6
6
  export * from './jito_tip_wallets'
@@ -2,7 +2,7 @@ import { CHAIN_ID, TradeContext } from "@clonegod/ttd-core/dist";
2
2
  import { ComputeBudgetProgram, Connection, Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction, TransactionInstruction } from "@solana/web3.js";
3
3
  import { LAMPORTS_PER_MICRO_LAMPORTS } from "../common";
4
4
  import { SolanaBlockMetaUpdateEvent } from "../types";
5
- import { SolanaTradeAppConfig } from "./SolanaTradeAppConfig";
5
+ import { SolanaTradeAppConfig } from "../config/SolanaTradeAppConfig";
6
6
  import { HELIUS_TIP_ACCOUNTS } from "./send/helius";
7
7
  import { getJitoTipAccount } from "./send/jito";
8
8
  import { JitoTipWalletManager } from "./jito_tip_wallets";