@clonegod/ttd-sol-common 2.0.25 → 2.0.26
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.
- package/dist/trade/send/jito.js +55 -7
- package/package.json +1 -1
- package/src/trade/send/jito.ts +29 -12
package/dist/trade/send/jito.js
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.sendBundleWithJitoMultiIps = exports.sendBundleWithJito = exports.getJitoTipAccount = exports.JitoUtils = exports.JITO_TIP_ACCOUNTS = void 0;
|
|
7
|
-
const axios_1 =
|
|
37
|
+
const axios_1 = __importStar(require("axios"));
|
|
38
|
+
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
8
39
|
const http_client_1 = require("./http_client");
|
|
9
40
|
exports.JITO_TIP_ACCOUNTS = [
|
|
10
41
|
"DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh",
|
|
@@ -46,9 +77,10 @@ const getJitoTipAccount = () => {
|
|
|
46
77
|
exports.getJitoTipAccount = getJitoTipAccount;
|
|
47
78
|
JitoUtils.init();
|
|
48
79
|
const sendBundleWithJito = async (mainTx, tipTx) => {
|
|
80
|
+
var _a, _b, _c, _d, _e, _f;
|
|
49
81
|
let url = process.env.JITO_SEND_BUNDLE_URL || 'https://tokyo.mainnet.block-engine.jito.wtf/api/v1/bundles';
|
|
50
82
|
const client = (0, http_client_1.getHttpClient)(url);
|
|
51
|
-
const
|
|
83
|
+
const requestData = {
|
|
52
84
|
jsonrpc: '2.0',
|
|
53
85
|
id: 1,
|
|
54
86
|
method: 'sendBundle',
|
|
@@ -58,8 +90,24 @@ const sendBundleWithJito = async (mainTx, tipTx) => {
|
|
|
58
90
|
"encoding": "base64"
|
|
59
91
|
}
|
|
60
92
|
]
|
|
61
|
-
}
|
|
62
|
-
|
|
93
|
+
};
|
|
94
|
+
try {
|
|
95
|
+
const response = await client.post(url, requestData);
|
|
96
|
+
return response.data.result;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error instanceof axios_1.AxiosError) {
|
|
100
|
+
const method = ((_b = (_a = error.config) === null || _a === void 0 ? void 0 : _a.method) === null || _b === void 0 ? void 0 : _b.toUpperCase()) || '';
|
|
101
|
+
const errorUrl = ((_c = error.config) === null || _c === void 0 ? void 0 : _c.url) || url;
|
|
102
|
+
const errorData = (_d = error.config) === null || _d === void 0 ? void 0 : _d.data;
|
|
103
|
+
const status = (_e = error.response) === null || _e === void 0 ? void 0 : _e.status;
|
|
104
|
+
const statusText = (_f = error.response) === null || _f === void 0 ? void 0 : _f.statusText;
|
|
105
|
+
(0, dist_1.log_warn)(`[sendBundleWithJito] Request failed - method: ${method}, url: ${errorUrl}, status: ${status}, statusText: ${statusText}, data: ${errorData}`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
(0, dist_1.log_warn)(`[sendBundleWithJito] Unexpected error: ${url} - ${error.message}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
63
111
|
};
|
|
64
112
|
exports.sendBundleWithJito = sendBundleWithJito;
|
|
65
113
|
const sendBundleWithJitoMultiIps = async (mainTx, tipTx) => {
|
package/package.json
CHANGED
package/src/trade/send/jito.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Transaction } from "@solana/web3.js";
|
|
2
|
-
import axios from "axios";
|
|
2
|
+
import axios, { AxiosError } from "axios";
|
|
3
|
+
import { log_error, log_warn } from "@clonegod/ttd-core/dist";
|
|
3
4
|
import { getHttpClient } from "./http_client";
|
|
4
5
|
|
|
5
6
|
export const JITO_TIP_ACCOUNTS = [
|
|
@@ -53,7 +54,8 @@ export const sendBundleWithJito = async (mainTx: Transaction, tipTx: Transaction
|
|
|
53
54
|
|
|
54
55
|
// 使用共享的 axios 实例,复用连接池
|
|
55
56
|
const client = getHttpClient(url)
|
|
56
|
-
|
|
57
|
+
|
|
58
|
+
const requestData = {
|
|
57
59
|
jsonrpc: '2.0',
|
|
58
60
|
id: 1,
|
|
59
61
|
method: 'sendBundle',
|
|
@@ -63,16 +65,31 @@ export const sendBundleWithJito = async (mainTx: Transaction, tipTx: Transaction
|
|
|
63
65
|
"encoding": "base64"
|
|
64
66
|
}
|
|
65
67
|
]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const response = await client.post<{ result: string }>(url, requestData)
|
|
72
|
+
// {
|
|
73
|
+
// jsonrpc: '2.0',
|
|
74
|
+
// result: 'e62062b4af6963bb0f67fea429f97e4f4fee59851a4ef65154b9f49b5995b5be', // bundle id
|
|
75
|
+
// id: 1
|
|
76
|
+
// }
|
|
77
|
+
// console.dir(response.data, { depth: null })
|
|
78
|
+
return response.data.result;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if(error instanceof AxiosError) {
|
|
81
|
+
// 提取关键错误信息
|
|
82
|
+
const method = error.config?.method?.toUpperCase() || '';
|
|
83
|
+
const errorUrl = error.config?.url || url;
|
|
84
|
+
const errorData = error.config?.data;
|
|
85
|
+
const status = error.response?.status;
|
|
86
|
+
const statusText = error.response?.statusText;
|
|
87
|
+
|
|
88
|
+
log_warn(`[sendBundleWithJito] Request failed - method: ${method}, url: ${errorUrl}, status: ${status}, statusText: ${statusText}, data: ${errorData}`);
|
|
89
|
+
} else {
|
|
90
|
+
log_warn(`[sendBundleWithJito] Unexpected error: ${url} - ${error.message}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
|