@clonegod/ttd-sol-common 1.0.116 → 1.0.117

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.
@@ -51,5 +51,5 @@ export declare class RpcClient {
51
51
  sendSmartTransactionWithTipMixed(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, region?: JitoRegion, feePayer?: Signer, lastValidBlockHeightOffset?: number): Promise<string>;
52
52
  sendJitoTransaction(serializedTransaction: string, jitoApiUrl: string): Promise<string>;
53
53
  get_last_blockhash_slot(connections: Connection[]): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
54
- check_bundle_result(bundle_id: string, timeoutMs?: number): Promise<void>;
54
+ try_get_bundle_failed_result(txid: string, bundle_id: string, timeoutMs?: number): Promise<void>;
55
55
  }
@@ -19,6 +19,7 @@ const axios_1 = __importDefault(require("axios"));
19
19
  const types_1 = require("./types");
20
20
  const get_signature_1 = require("../send_tx/get_signature");
21
21
  const dist_1 = require("@clonegod/ttd-common/dist");
22
+ const common_1 = require("../common");
22
23
  const jito_1 = require("../jito");
23
24
  class RpcClient {
24
25
  constructor(connection, id) {
@@ -579,7 +580,7 @@ class RpcClient {
579
580
  let jitoApiUrl = `${types_1.JITO_API_URLS[region]}/api/v1/bundles`;
580
581
  this.sendJitoTransaction(serializedTransaction, `${types_1.JITO_API_URLS['Default']}/api/v1/transactions?bundleOnly=true`);
581
582
  const bundleId = yield this.sendJitoBundle([serializedTransaction], jitoApiUrl);
582
- this.check_bundle_result(bundleId);
583
+ this.try_get_bundle_failed_result(txid, bundleId);
583
584
  (0, dist_1.log_info)(`sendJitoBundle finish`, {
584
585
  jitoApiUrl,
585
586
  txid,
@@ -797,19 +798,47 @@ class RpcClient {
797
798
  return last_blockhash_slot;
798
799
  });
799
800
  }
800
- check_bundle_result(bundle_id_1) {
801
- return __awaiter(this, arguments, void 0, function* (bundle_id, timeoutMs = 10000) {
801
+ try_get_bundle_failed_result(txid_1, bundle_id_1) {
802
+ return __awaiter(this, arguments, void 0, function* (txid, bundle_id, timeoutMs = 90000) {
803
+ let url = `https://bundles.jito.wtf/api/v1/bundles/get_bundle_error/${bundle_id}`;
804
+ let check_interval = parseInt(process.env.CHECK_BUNDLE_ERROR_INTERVAL_MILLS || '7000');
802
805
  let start = Date.now();
803
806
  while (Date.now() - start < timeoutMs) {
804
807
  try {
805
- let rs = yield fetch(`https://bundles.jito.wtf/api/v1/bundles/get_bundle_error/${bundle_id}`);
806
- let jsonObj = yield rs.json();
807
- console.log('get_bundle_error, res=', jsonObj);
808
+ let rs = yield (yield fetch(url)).json();
809
+ if (rs && rs.length > 0) {
810
+ (0, dist_1.log_warn)('get_bundle_error, res=', { url, txid, check_interval, timeoutMs, rs });
811
+ let appConfig = global.appConfig;
812
+ let mock_tx_obj = {
813
+ params: {
814
+ result: {
815
+ signature: txid,
816
+ slot: -1,
817
+ transaction: {
818
+ transaction: {
819
+ signatures: [txid]
820
+ },
821
+ version: 0,
822
+ meta: {
823
+ err: JSON.stringify(rs),
824
+ logMessages: []
825
+ }
826
+ }
827
+ }
828
+ }
829
+ };
830
+ appConfig.emit(common_1.LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION + '#' + txid, JSON.stringify(mock_tx_obj));
831
+ break;
832
+ }
833
+ else {
834
+ (0, dist_1.log_debug)('get_bundle_error, res=', { url, check_interval, rs });
835
+ }
808
836
  }
809
837
  catch (err) {
810
838
  console.error('get_bundle_error, error!', err);
839
+ break;
811
840
  }
812
- yield new Promise(resolve => setTimeout(resolve, 1000));
841
+ yield new Promise(resolve => setTimeout(resolve, check_interval));
813
842
  }
814
843
  });
815
844
  }
@@ -59,11 +59,9 @@ const try_lock_order_msg = (appConfig, order_msg) => __awaiter(void 0, void 0, v
59
59
  exports.try_lock_order_msg = try_lock_order_msg;
60
60
  const handle_order_message = (appConfig, trade, message) => __awaiter(void 0, void 0, void 0, function* () {
61
61
  (0, dist_1.new_line)(3);
62
- setTimeout(() => {
63
- console.log(`=================================================================================`);
64
- console.log(`| NEW ORDER MESSAGE |`);
65
- console.log(`=================================================================================`);
66
- }, 0);
62
+ console.log(`=================================================================================`);
63
+ console.log(`| NEW ORDER MESSAGE |`);
64
+ console.log(`=================================================================================`);
67
65
  (0, dist_1.log_info)(`handle_order_message, on message: `, message);
68
66
  let order_event_message = JSON.parse(message);
69
67
  if (dist_1.LOG.debug) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.116",
3
+ "version": "1.0.117",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",