@clonegod/ttd-sol-common 1.0.118 → 1.0.120
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.
|
@@ -49,7 +49,8 @@ export declare class RpcClient {
|
|
|
49
49
|
getTokenAccounts(params: DAS.GetTokenAccountsRequest): Promise<DAS.GetTokenAccountsResponse>;
|
|
50
50
|
sendTransaction(transaction: Transaction | VersionedTransaction, options?: HeliusSendOptions): Promise<TransactionSignature>;
|
|
51
51
|
sendSmartTransactionWithTipMixed(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, region?: JitoRegion, feePayer?: Signer, lastValidBlockHeightOffset?: number): Promise<string>;
|
|
52
|
-
sendJitoTransaction(serializedTransaction: string, jitoApiUrl: string): Promise<string>;
|
|
52
|
+
sendJitoTransaction(serializedTransaction: string, jitoApiUrl: string, encoding?: string): Promise<string>;
|
|
53
53
|
get_last_blockhash_slot(connections: Connection[]): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
|
|
54
54
|
try_get_bundle_failed_result(txid: string, bundle_id: string, timeoutMs?: number): Promise<void>;
|
|
55
|
+
send_tx_to_all_jito_region(serializedTransaction: string, encoding: string): Promise<string>;
|
|
55
56
|
}
|
|
@@ -485,7 +485,7 @@ class RpcClient {
|
|
|
485
485
|
let error;
|
|
486
486
|
do {
|
|
487
487
|
try {
|
|
488
|
-
const signature = yield this.connection.sendRawTransaction(transaction.serialize(), Object.assign({ maxRetries: 3, preflightCommitment: 'confirmed', skipPreflight: sendOptions.skipPreflight, minContextSlot }, sendOptions));
|
|
488
|
+
const signature = yield this.connection.sendRawTransaction(transaction.serialize({ verifySignatures: false }), Object.assign({ maxRetries: 3, preflightCommitment: 'confirmed', skipPreflight: sendOptions.skipPreflight, minContextSlot }, sendOptions));
|
|
489
489
|
const abortSignal = AbortSignal.timeout(15000);
|
|
490
490
|
yield this.connection.confirmTransaction({
|
|
491
491
|
abortSignal,
|
|
@@ -576,16 +576,11 @@ class RpcClient {
|
|
|
576
576
|
const { transaction, blockhash } = yield this.createSmartTransactionWithTip(solana_trade_runtime, instructions, signers, lookupTables, tipAmount, feePayer);
|
|
577
577
|
let txid = (0, get_signature_1.getSignature)(transaction);
|
|
578
578
|
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
579
|
-
const
|
|
579
|
+
const encoding = 'base64';
|
|
580
|
+
const serializedTransaction = transaction.serialize({ verifySignatures: false }).toString(encoding);
|
|
580
581
|
let jitoApiUrl = `${types_1.JITO_API_URLS[region]}/api/v1/bundles`;
|
|
581
|
-
this.
|
|
582
|
-
const bundleId = yield this.sendJitoBundle([serializedTransaction], jitoApiUrl);
|
|
582
|
+
const bundleId = yield this.send_tx_to_all_jito_region(serializedTransaction, encoding);
|
|
583
583
|
this.try_get_bundle_failed_result(txid, bundleId);
|
|
584
|
-
(0, dist_1.log_info)(`sendJitoBundle finish`, {
|
|
585
|
-
jitoApiUrl,
|
|
586
|
-
txid,
|
|
587
|
-
bundleId
|
|
588
|
-
});
|
|
589
584
|
const currentBlockHeight = yield solana_trade_runtime.connection.getBlockHeight();
|
|
590
585
|
const lastValidBlockHeight = Math.min(blockhash.lastValidBlockHeight, currentBlockHeight + lastValidBlockHeightOffset);
|
|
591
586
|
const timeout = 10000;
|
|
@@ -593,7 +588,7 @@ class RpcClient {
|
|
|
593
588
|
const startTime = Date.now();
|
|
594
589
|
while (Date.now() - startTime < timeout) {
|
|
595
590
|
const bundleStatuses = yield this.getBundleStatuses([bundleId], jitoApiUrl);
|
|
596
|
-
(0, dist_1.
|
|
591
|
+
(0, dist_1.log_debug)(`getBundleStatuses success`, {
|
|
597
592
|
txid,
|
|
598
593
|
bundleId,
|
|
599
594
|
jitoApiUrl,
|
|
@@ -664,7 +659,7 @@ class RpcClient {
|
|
|
664
659
|
rawTransaction = Buffer.from(transaction.serialize()).toString('base64');
|
|
665
660
|
}
|
|
666
661
|
else {
|
|
667
|
-
rawTransaction = transaction.serialize().toString('base64');
|
|
662
|
+
rawTransaction = transaction.serialize({ verifySignatures: false }).toString('base64');
|
|
668
663
|
}
|
|
669
664
|
try {
|
|
670
665
|
const url = `${this.connection.rpcEndpoint}`;
|
|
@@ -701,7 +696,7 @@ class RpcClient {
|
|
|
701
696
|
const { transaction, blockhash } = yield this.createSmartTransactionWithTip(solana_trade_runtime, instructions, signers, lookupTables, tipAmount, feePayer);
|
|
702
697
|
let txid = (0, get_signature_1.getSignature)(transaction);
|
|
703
698
|
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
704
|
-
const serializedTransaction = bs58_1.default.encode(transaction.serialize());
|
|
699
|
+
const serializedTransaction = bs58_1.default.encode(transaction.serialize({ verifySignatures: false }));
|
|
705
700
|
let jitoApiUrl = `${types_1.JITO_API_URLS[region]}/api/v1/bundles`;
|
|
706
701
|
(0, dist_1.log_info)('sendSmartTransactionWithTipMixed, start');
|
|
707
702
|
this.sendTransaction(transaction);
|
|
@@ -743,16 +738,24 @@ class RpcClient {
|
|
|
743
738
|
return txid;
|
|
744
739
|
});
|
|
745
740
|
}
|
|
746
|
-
sendJitoTransaction(
|
|
747
|
-
return __awaiter(this,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
741
|
+
sendJitoTransaction(serializedTransaction_1, jitoApiUrl_1) {
|
|
742
|
+
return __awaiter(this, arguments, void 0, function* (serializedTransaction, jitoApiUrl, encoding = 'base64') {
|
|
743
|
+
let start = Date.now();
|
|
744
|
+
let params;
|
|
745
|
+
if (encoding === 'base64') {
|
|
746
|
+
params = [serializedTransaction, { encoding }];
|
|
747
|
+
}
|
|
748
|
+
else if (encoding === 'bs58') {
|
|
749
|
+
params = [serializedTransaction];
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
throw new Error('Invalid type of encoding:' + encoding);
|
|
753
|
+
}
|
|
751
754
|
const response = yield axios_1.default.post(jitoApiUrl, {
|
|
752
755
|
jsonrpc: '2.0',
|
|
753
756
|
id: 1,
|
|
754
757
|
method: 'sendTransaction',
|
|
755
|
-
params
|
|
758
|
+
params,
|
|
756
759
|
}, {
|
|
757
760
|
headers: { 'Content-Type': 'application/json' },
|
|
758
761
|
});
|
|
@@ -762,7 +765,9 @@ class RpcClient {
|
|
|
762
765
|
let bundleId = response.headers['x-bundle-id'];
|
|
763
766
|
(0, dist_1.log_info)('sendJitoTransaction finish', {
|
|
764
767
|
jitoApiUrl,
|
|
765
|
-
|
|
768
|
+
encoding,
|
|
769
|
+
bundleId,
|
|
770
|
+
take: (Date.now() - start) + 'ms'
|
|
766
771
|
});
|
|
767
772
|
return bundleId;
|
|
768
773
|
});
|
|
@@ -844,5 +849,19 @@ class RpcClient {
|
|
|
844
849
|
}
|
|
845
850
|
});
|
|
846
851
|
}
|
|
852
|
+
send_tx_to_all_jito_region(serializedTransaction, encoding) {
|
|
853
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
854
|
+
let jito_block_engine_urls = [
|
|
855
|
+
`${types_1.JITO_API_URLS['Default']}/api/v1/transactions?bundleOnly=true`,
|
|
856
|
+
`${types_1.JITO_API_URLS['NY']}/api/v1/transactions?bundleOnly=true`,
|
|
857
|
+
`${types_1.JITO_API_URLS['Amsterdam']}/api/v1/transactions?bundleOnly=true`,
|
|
858
|
+
`${types_1.JITO_API_URLS['Frankfurt']}/api/v1/transactions?bundleOnly=true`,
|
|
859
|
+
`${types_1.JITO_API_URLS['Tokyo']}/api/v1/transactions?bundleOnly=true`,
|
|
860
|
+
`${types_1.JITO_API_URLS['Slc']}/api/v1/transactions?bundleOnly=true`,
|
|
861
|
+
];
|
|
862
|
+
let bundle_id = yield Promise.race(jito_block_engine_urls.map(address => this.sendJitoTransaction(serializedTransaction, address, encoding)));
|
|
863
|
+
return bundle_id;
|
|
864
|
+
});
|
|
865
|
+
}
|
|
847
866
|
}
|
|
848
867
|
exports.RpcClient = RpcClient;
|
|
@@ -602,4 +602,5 @@ exports.JITO_API_URLS = {
|
|
|
602
602
|
Amsterdam: 'https://amsterdam.mainnet.block-engine.jito.wtf',
|
|
603
603
|
Frankfurt: 'https://frankfurt.mainnet.block-engine.jito.wtf',
|
|
604
604
|
Tokyo: 'https://tokyo.mainnet.block-engine.jito.wtf',
|
|
605
|
+
Slc: 'https://slc.mainnet.block-engine.jito.wtf'
|
|
605
606
|
};
|
|
@@ -293,7 +293,7 @@ export interface GetPriorityFeeEstimateResponse {
|
|
|
293
293
|
priorityFeeEstimate?: number;
|
|
294
294
|
priorityFeeLevels?: MicroLamportPriorityFeeLevels;
|
|
295
295
|
}
|
|
296
|
-
export type JitoRegion = 'Default' | 'NY' | 'Amsterdam' | 'Frankfurt' | 'Tokyo';
|
|
296
|
+
export type JitoRegion = 'Default' | 'NY' | 'Amsterdam' | 'Frankfurt' | 'Tokyo' | 'Slc';
|
|
297
297
|
export type PollTransactionOptions = {
|
|
298
298
|
confirmationStatuses?: TransactionConfirmationStatus[];
|
|
299
299
|
timeout?: number;
|
|
@@ -84,8 +84,8 @@ class TransactionResultChecker {
|
|
|
84
84
|
check_tx_result_interval() {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
86
|
const check_start_time = Date.now();
|
|
87
|
-
const check_interval = parseInt(process.env.CHECK_TX_RESULT_INTERVAL_MILLS || '
|
|
88
|
-
const check_timeout = parseInt(process.env.CHECK_TX_RESULT_TIMEOUT_MILLS || '
|
|
87
|
+
const check_interval = parseInt(process.env.CHECK_TX_RESULT_INTERVAL_MILLS || '2000');
|
|
88
|
+
const check_timeout = parseInt(process.env.CHECK_TX_RESULT_TIMEOUT_MILLS || '10000');
|
|
89
89
|
const intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
this.check_count += 1;
|
|
91
91
|
(0, dist_1.log_info)(`check transaction start: seq=[${this.check_count}], txhash= ${this.txid}, trace_id=${this.trace_id}`);
|