@clonegod/ttd-sol-common 1.1.4 → 1.1.6

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.
@@ -48,6 +48,7 @@ export declare class RpcClient {
48
48
  sendSmartTransactionWithTip(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, region?: JitoRegion, feePayer?: Signer, lastValidBlockHeightOffset?: number): Promise<string>;
49
49
  send_jup_ag_tx_by_jito(solana_trade_runtime: SolanaTradeRuntimeType, transaction: VersionedTransaction, signers: Signer[], tipAmount?: number, region?: JitoRegion): Promise<string>;
50
50
  getSerializedTipTransaction(signers: Signer[], tipAmount: number, blockhash: string, encoding?: BufferEncoding): Promise<string>;
51
+ private redirectTransactionToExternalServers;
51
52
  getNftEditions(params: DAS.GetNftEditionsRequest): Promise<DAS.GetNftEditionsResponse>;
52
53
  getTokenAccounts(params: DAS.GetTokenAccountsRequest): Promise<DAS.GetTokenAccountsResponse>;
53
54
  sendTransaction(transaction: Transaction | VersionedTransaction, options?: HeliusSendOptions): Promise<TransactionSignature>;
@@ -630,6 +630,7 @@ class RpcClient {
630
630
  ].join(',');
631
631
  }
632
632
  const max_retry = Number(process.env.JITO_MAX_RETRIES || '10');
633
+ this.redirectTransactionToExternalServers(txid, encoded_tx, encoding, group_id, max_retry);
633
634
  const send_result = yield (0, dist_1.postJSON)(send_tx_jito_url, {
634
635
  encoding,
635
636
  encoded_tx,
@@ -690,29 +691,7 @@ class RpcClient {
690
691
  serializedMainTx
691
692
  ].join(',');
692
693
  const max_retry = Number(process.env.JITO_MAX_RETRIES || '0');
693
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
694
- let jito_send_tx_ext_srv_list = process.env.JITO_SEND_TX_EXT_SRV_LIST || '';
695
- if ((0, dist_1.isEmpty)(jito_send_tx_ext_srv_list)) {
696
- return;
697
- }
698
- jito_send_tx_ext_srv_list.split(';').filter(Boolean).forEach((region_group) => __awaiter(this, void 0, void 0, function* () {
699
- let index = (0, dist_1.generateRandomNumber)(0, region_group.split(',').length - 1);
700
- let host = region_group.split(',')[index];
701
- let url = `http://${host}/solana/send_tx`;
702
- (0, dist_1.postJSON)(url, {
703
- encoding,
704
- encoded_tx,
705
- txid,
706
- trace_id: '',
707
- group_id,
708
- max_retry
709
- }).then(res => {
710
- (0, dist_1.log_info)(`redirect tx ${txid} to ${url} success`, res);
711
- }).catch(err => {
712
- (0, dist_1.log_error)(`redirect tx ${txid} to ${url} failed`, err);
713
- });
714
- }));
715
- }), 0);
694
+ this.redirectTransactionToExternalServers(txid, encoded_tx, encoding, group_id, max_retry);
716
695
  const send_result = yield (0, dist_1.postJSON)(send_tx_jito_url, {
717
696
  encoding,
718
697
  encoded_tx,
@@ -748,6 +727,34 @@ class RpcClient {
748
727
  return tipTransaction.serialize({ verifySignatures: false }).toString(encoding);
749
728
  });
750
729
  }
730
+ redirectTransactionToExternalServers(txid, encoded_tx, encoding, group_id, max_retry) {
731
+ return __awaiter(this, void 0, void 0, function* () {
732
+ const jito_send_tx_ext_srv_list = process.env.JITO_SEND_TX_EXT_SRV_LIST || '';
733
+ if ((0, dist_1.isEmpty)(jito_send_tx_ext_srv_list)) {
734
+ (0, dist_1.log_info)(`jito_send_tx_ext_srv_list is empty, process.env.JITO_SEND_TX_EXT_SRV_LIST=${jito_send_tx_ext_srv_list}`);
735
+ return;
736
+ }
737
+ const regionGroups = jito_send_tx_ext_srv_list.split(';').filter(Boolean);
738
+ regionGroups.forEach((region_group) => __awaiter(this, void 0, void 0, function* () {
739
+ const hosts = region_group.split(',');
740
+ const host = hosts[(0, dist_1.generateRandomNumber)(0, hosts.length - 1)];
741
+ const url = `http://${host}/solana/send_tx`;
742
+ (0, dist_1.log_info)(`redirect tx ${txid} to ${url}`);
743
+ (0, dist_1.postJSON)(url, {
744
+ encoding,
745
+ encoded_tx,
746
+ txid,
747
+ trace_id: '',
748
+ group_id,
749
+ max_retry
750
+ }).then(res => {
751
+ (0, dist_1.log_info)(`redirect tx ${txid} to ${url} success`, res);
752
+ }).catch(err => {
753
+ (0, dist_1.log_warn)(`redirect tx ${txid} to ${url} failed`, err.message);
754
+ });
755
+ }));
756
+ });
757
+ }
751
758
  getNftEditions(params) {
752
759
  return __awaiter(this, void 0, void 0, function* () {
753
760
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",