@clonegod/ttd-sol-common 1.0.13 → 1.0.14
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/index.d.ts +2 -1
- package/dist/index.js +30 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,5 +22,6 @@ export declare class HeliusClient {
|
|
|
22
22
|
jito_tip_max: number;
|
|
23
23
|
constructor(signers: Signer[], jito_tip_max?: number);
|
|
24
24
|
send_smart_transaction(instructions: TransactionInstruction[], use_staked_endpint?: boolean): Promise<string>;
|
|
25
|
-
send_transaction_by_jito(instructions: TransactionInstruction[], tipAmount: number
|
|
25
|
+
send_transaction_by_jito(instructions: TransactionInstruction[], tipAmount: number): Promise<TransactionSignature>;
|
|
26
26
|
}
|
|
27
|
+
export declare const get_jito_region: () => JitoRegion;
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.HeliusClient = exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_NAME = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
|
|
15
|
+
exports.get_jito_region = exports.HeliusClient = exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_NAME = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
|
|
16
16
|
const ws_1 = __importDefault(require("ws"));
|
|
17
17
|
const dist_1 = require("@clonegod/ttd-common/dist");
|
|
18
18
|
const helius_sdk_1 = require("helius-sdk");
|
|
@@ -123,8 +123,8 @@ class HeliusClient {
|
|
|
123
123
|
return __awaiter(this, arguments, void 0, function* (instructions, use_staked_endpint = false) {
|
|
124
124
|
(0, dist_1.log_info)(`send_smart_transaction, start`);
|
|
125
125
|
let start_time = Date.now();
|
|
126
|
-
let
|
|
127
|
-
let txid = yield
|
|
126
|
+
let rpc = use_staked_endpint ? this.helius_staked.rpc : this.helius_mainnet.rpc;
|
|
127
|
+
let txid = yield rpc.sendSmartTransaction(instructions, this.signers, [], this.sendOptions);
|
|
128
128
|
(0, dist_1.log_info)(`send_smart_transaction, end`, {
|
|
129
129
|
txid,
|
|
130
130
|
use_staked_endpint,
|
|
@@ -133,14 +133,16 @@ class HeliusClient {
|
|
|
133
133
|
return txid;
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
send_transaction_by_jito(instructions, tipAmount
|
|
136
|
+
send_transaction_by_jito(instructions, tipAmount) {
|
|
137
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
138
|
if (tipAmount > this.jito_tip_max) {
|
|
139
139
|
tipAmount = this.jito_tip_max;
|
|
140
|
+
(0, dist_1.log_warn)(`tipAmount too high!!! reset from ${tipAmount} to ${this.jito_tip_max}`);
|
|
140
141
|
}
|
|
141
142
|
(0, dist_1.log_info)(`send_transaction_by_jito, start`);
|
|
142
143
|
let start_time = Date.now();
|
|
143
|
-
let
|
|
144
|
+
let rpc = this.helius_qn.rpc;
|
|
145
|
+
let txid = yield rpc.sendSmartTransactionWithTip(instructions, this.signers, [], tipAmount, (0, exports.get_jito_region)());
|
|
144
146
|
(0, dist_1.log_info)(`send_transaction_by_jito, end`, {
|
|
145
147
|
txid,
|
|
146
148
|
take_time: Date.now() - start_time
|
|
@@ -150,3 +152,26 @@ class HeliusClient {
|
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
exports.HeliusClient = HeliusClient;
|
|
155
|
+
const get_jito_region = () => {
|
|
156
|
+
let jito_region;
|
|
157
|
+
let server_info = (0, dist_1.getServerInfo)();
|
|
158
|
+
switch (server_info.region) {
|
|
159
|
+
case 'fra':
|
|
160
|
+
jito_region = 'Frankfurt';
|
|
161
|
+
break;
|
|
162
|
+
case 'virginia':
|
|
163
|
+
jito_region = 'NY';
|
|
164
|
+
break;
|
|
165
|
+
case 'jp':
|
|
166
|
+
jito_region = 'Tokyo';
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
jito_region = 'Default';
|
|
170
|
+
}
|
|
171
|
+
(0, dist_1.log_debug)(`get_jito_region`, {
|
|
172
|
+
server_info,
|
|
173
|
+
jito_region
|
|
174
|
+
});
|
|
175
|
+
return jito_region;
|
|
176
|
+
};
|
|
177
|
+
exports.get_jito_region = get_jito_region;
|