@clonegod/ttd-sol-common 1.0.129 → 1.0.131

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.
@@ -42,7 +42,7 @@ export declare class RpcClient {
42
42
  }): Promise<TransactionSignature>;
43
43
  addTipInstruction(instructions: TransactionInstruction[], feePayer: PublicKey, tipAccount: string, tipAmount: number): void;
44
44
  createSmartTransactionWithTip(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, feePayer?: Signer): Promise<SmartTransactionContext>;
45
- sendJitoBundle(serializedTransactions: string[], jitoApiUrl: string): Promise<string>;
45
+ sendJitoBundle(serializedTransactions: string[], encoding: string, jitoApiUrl: string): Promise<string>;
46
46
  getBundleStatuses(bundleIds: string[], jitoApiUrl: string): Promise<any>;
47
47
  sendSmartTransactionWithTip(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, region?: JitoRegion, feePayer?: Signer, lastValidBlockHeightOffset?: number): Promise<string>;
48
48
  getNftEditions(params: DAS.GetNftEditionsRequest): Promise<DAS.GetNftEditionsResponse>;
@@ -525,13 +525,18 @@ class RpcClient {
525
525
  return this.createSmartTransaction(solana_trade_runtime, instructions, signers, lookupTables, feePayer);
526
526
  });
527
527
  }
528
- sendJitoBundle(serializedTransactions, jitoApiUrl) {
528
+ sendJitoBundle(serializedTransactions, encoding, jitoApiUrl) {
529
529
  return __awaiter(this, void 0, void 0, function* () {
530
530
  const response = yield axios_1.default.post(jitoApiUrl, {
531
531
  jsonrpc: '2.0',
532
532
  id: 1,
533
533
  method: 'sendBundle',
534
- params: [serializedTransactions],
534
+ params: [
535
+ serializedTransactions,
536
+ {
537
+ "encoding": encoding
538
+ }
539
+ ]
535
540
  }, {
536
541
  headers: { 'Content-Type': 'application/json' },
537
542
  });
@@ -543,6 +548,9 @@ class RpcClient {
543
548
  }
544
549
  getBundleStatuses(bundleIds, jitoApiUrl) {
545
550
  return __awaiter(this, void 0, void 0, function* () {
551
+ if (!bundleIds || bundleIds.length == 0 || bundleIds[0] == null) {
552
+ return;
553
+ }
546
554
  const response = yield axios_1.default.post(jitoApiUrl, {
547
555
  jsonrpc: '2.0',
548
556
  id: 1,
@@ -573,8 +581,15 @@ class RpcClient {
573
581
  setTimeout(() => __awaiter(this, void 0, void 0, function* () {
574
582
  const encoding = 'base64';
575
583
  const serializedTransaction = transaction.serialize({ verifySignatures: false }).toString(encoding);
576
- let jitoApiUrl = `${types_1.JITO_API_URLS[region]}/api/v1/bundles`;
577
- const bundleId = yield this.send_tx_to_all_jito_region(serializedTransaction, encoding);
584
+ let jito_region = process.env.JITO_REGION || region;
585
+ let jitoApiUrl = `${types_1.JITO_API_URLS[jito_region]}/api/v1/bundles`;
586
+ const bundleId = yield this.sendJitoBundle([serializedTransaction], encoding, jitoApiUrl);
587
+ (0, dist_1.log_info)(`sendJitoBundle`, {
588
+ txid,
589
+ jitoApiUrl,
590
+ encoding,
591
+ bundleId
592
+ });
578
593
  this.try_get_bundle_failed_result(txid, bundleId);
579
594
  const currentBlockHeight = yield solana_trade_runtime.connection.getBlockHeight();
580
595
  const lastValidBlockHeight = Math.min(blockhash.lastValidBlockHeight, currentBlockHeight + lastValidBlockHeightOffset);
@@ -702,11 +717,12 @@ class RpcClient {
702
717
  });
703
718
  const currentBlockHeight = yield solana_trade_runtime.connection.getBlockHeight();
704
719
  const lastValidBlockHeight = Math.min(blockhash.lastValidBlockHeight, currentBlockHeight + lastValidBlockHeightOffset);
705
- const timeout = 10000;
706
- const interval = 5000;
720
+ const timeout = 70000;
721
+ const interval = 10000;
707
722
  const startTime = Date.now();
708
723
  while (Date.now() - startTime < timeout ||
709
724
  (yield this.connection.getBlockHeight()) <= lastValidBlockHeight) {
725
+ yield new Promise((resolve) => setTimeout(resolve, interval));
710
726
  const bundleStatuses = yield this.getBundleStatuses([bundleId], jitoApiUrl);
711
727
  (0, dist_1.log_info)(`getBundleStatuses`, {
712
728
  txid,
@@ -723,7 +739,6 @@ class RpcClient {
723
739
  return bundleStatuses.value[0].transactions[0];
724
740
  }
725
741
  }
726
- yield new Promise((resolve) => setTimeout(resolve, interval));
727
742
  }
728
743
  let err = new Error('Bundle failed to confirm within the timeout period:' + timeout + 'ms');
729
744
  (0, dist_1.log_error)(`Bundle failed to confirm, txid=${txid}`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.129",
3
+ "version": "1.0.131",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "push": "npm run build && npm publish"
14
14
  },
15
15
  "dependencies": {
16
- "@clonegod/ttd-common": "^1.0.167",
16
+ "@clonegod/ttd-common": "^1.0.168",
17
17
  "@irys/sdk": "^0.2.10",
18
18
  "@metaplex-foundation/mpl-token-metadata": "^2.5.2",
19
19
  "@solana/web3.js": "1.91.6",