@clonegod/ttd-sol-common 2.0.26 → 2.0.27

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.
@@ -0,0 +1,2 @@
1
+ import { Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ export declare function getSignature(transaction: Transaction | VersionedTransaction): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getSignature = getSignature;
7
+ const bs58_1 = __importDefault(require("bs58"));
8
+ function getSignature(transaction) {
9
+ const signature = 'signature' in transaction ? transaction.signature : transaction.signatures[0];
10
+ if (!signature) {
11
+ throw new Error('Missing transaction signature, the transaction was not signed by the fee payer');
12
+ }
13
+ let txid = bs58_1.default.encode(signature);
14
+ return txid;
15
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './constants';
2
2
  export * from './get_wallet_token_account';
3
3
  export * from './subscribe_account_update';
4
+ export * from './get_signature';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants"), exports);
18
18
  __exportStar(require("./get_wallet_token_account"), exports);
19
19
  __exportStar(require("./subscribe_account_update"), exports);
20
+ __exportStar(require("./get_signature"), exports);
@@ -34,8 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.sendBundleWithJitoMultiIps = exports.sendBundleWithJito = exports.getJitoTipAccount = exports.JitoUtils = exports.JITO_TIP_ACCOUNTS = void 0;
37
- const axios_1 = __importStar(require("axios"));
38
37
  const dist_1 = require("@clonegod/ttd-core/dist");
38
+ const axios_1 = __importStar(require("axios"));
39
+ const common_1 = require("../../common");
39
40
  const http_client_1 = require("./http_client");
40
41
  exports.JITO_TIP_ACCOUNTS = [
41
42
  "DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh",
@@ -115,7 +116,7 @@ const sendBundleWithJitoMultiIps = async (mainTx, tipTx) => {
115
116
  let urls = ips.map(ip => `http://${ip}:10429/solana/send_tx`);
116
117
  const body = {
117
118
  trace_id: '',
118
- txid: Buffer.from(mainTx.serialize()).toString('base64'),
119
+ txid: (0, common_1.getSignature)(mainTx),
119
120
  encoding: 'base64',
120
121
  encoded_tx: [tipTx, mainTx].map(tx => Buffer.from(tx.serialize()).toString('base64')).join(','),
121
122
  max_retry: 3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "2.0.26",
3
+ "version": "2.0.27",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -0,0 +1,12 @@
1
+ import bs58 from 'bs58'
2
+ import { Transaction, VersionedTransaction } from '@solana/web3.js'
3
+
4
+ export function getSignature(transaction: Transaction | VersionedTransaction): string {
5
+ const signature = 'signature' in transaction ? transaction.signature : transaction.signatures[0]
6
+ if (!signature) {
7
+ throw new Error('Missing transaction signature, the transaction was not signed by the fee payer')
8
+ }
9
+ let txid = bs58.encode(signature)
10
+
11
+ return txid
12
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './constants'
2
2
  export * from './get_wallet_token_account'
3
3
  export * from './subscribe_account_update'
4
+ export * from './get_signature'
@@ -1,6 +1,7 @@
1
+ import { log_warn } from "@clonegod/ttd-core/dist";
1
2
  import { Transaction } from "@solana/web3.js";
2
3
  import axios, { AxiosError } from "axios";
3
- import { log_error, log_warn } from "@clonegod/ttd-core/dist";
4
+ import { getSignature } from "../../common";
4
5
  import { getHttpClient } from "./http_client";
5
6
 
6
7
  export const JITO_TIP_ACCOUNTS = [
@@ -99,7 +100,7 @@ export const sendBundleWithJitoMultiIps = async (mainTx: Transaction, tipTx: Tra
99
100
 
100
101
  const body = {
101
102
  trace_id: '',
102
- txid: Buffer.from(mainTx.serialize()).toString('base64'),
103
+ txid: getSignature(mainTx),
103
104
  encoding: 'base64', // base64
104
105
  encoded_tx: [tipTx, mainTx].map(tx => Buffer.from(tx.serialize()).toString('base64')).join(','), // main tx
105
106
  max_retry: 3