@clonegod/ttd-sol-common 1.0.118 → 1.0.119
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,10 +576,10 @@ 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
584
|
(0, dist_1.log_info)(`sendJitoBundle finish`, {
|
|
585
585
|
jitoApiUrl,
|
|
@@ -593,7 +593,7 @@ class RpcClient {
|
|
|
593
593
|
const startTime = Date.now();
|
|
594
594
|
while (Date.now() - startTime < timeout) {
|
|
595
595
|
const bundleStatuses = yield this.getBundleStatuses([bundleId], jitoApiUrl);
|
|
596
|
-
(0, dist_1.
|
|
596
|
+
(0, dist_1.log_debug)(`getBundleStatuses success`, {
|
|
597
597
|
txid,
|
|
598
598
|
bundleId,
|
|
599
599
|
jitoApiUrl,
|
|
@@ -664,7 +664,7 @@ class RpcClient {
|
|
|
664
664
|
rawTransaction = Buffer.from(transaction.serialize()).toString('base64');
|
|
665
665
|
}
|
|
666
666
|
else {
|
|
667
|
-
rawTransaction = transaction.serialize().toString('base64');
|
|
667
|
+
rawTransaction = transaction.serialize({ verifySignatures: false }).toString('base64');
|
|
668
668
|
}
|
|
669
669
|
try {
|
|
670
670
|
const url = `${this.connection.rpcEndpoint}`;
|
|
@@ -701,7 +701,7 @@ class RpcClient {
|
|
|
701
701
|
const { transaction, blockhash } = yield this.createSmartTransactionWithTip(solana_trade_runtime, instructions, signers, lookupTables, tipAmount, feePayer);
|
|
702
702
|
let txid = (0, get_signature_1.getSignature)(transaction);
|
|
703
703
|
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
704
|
-
const serializedTransaction = bs58_1.default.encode(transaction.serialize());
|
|
704
|
+
const serializedTransaction = bs58_1.default.encode(transaction.serialize({ verifySignatures: false }));
|
|
705
705
|
let jitoApiUrl = `${types_1.JITO_API_URLS[region]}/api/v1/bundles`;
|
|
706
706
|
(0, dist_1.log_info)('sendSmartTransactionWithTipMixed, start');
|
|
707
707
|
this.sendTransaction(transaction);
|
|
@@ -743,16 +743,24 @@ class RpcClient {
|
|
|
743
743
|
return txid;
|
|
744
744
|
});
|
|
745
745
|
}
|
|
746
|
-
sendJitoTransaction(
|
|
747
|
-
return __awaiter(this,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
746
|
+
sendJitoTransaction(serializedTransaction_1, jitoApiUrl_1) {
|
|
747
|
+
return __awaiter(this, arguments, void 0, function* (serializedTransaction, jitoApiUrl, encoding = 'base64') {
|
|
748
|
+
let start = Date.now();
|
|
749
|
+
let params;
|
|
750
|
+
if (encoding === 'base64') {
|
|
751
|
+
params = [serializedTransaction, { encoding }];
|
|
752
|
+
}
|
|
753
|
+
else if (encoding === 'bs58') {
|
|
754
|
+
params = [serializedTransaction];
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
throw new Error('Invalid type of encoding:' + encoding);
|
|
758
|
+
}
|
|
751
759
|
const response = yield axios_1.default.post(jitoApiUrl, {
|
|
752
760
|
jsonrpc: '2.0',
|
|
753
761
|
id: 1,
|
|
754
762
|
method: 'sendTransaction',
|
|
755
|
-
params
|
|
763
|
+
params,
|
|
756
764
|
}, {
|
|
757
765
|
headers: { 'Content-Type': 'application/json' },
|
|
758
766
|
});
|
|
@@ -762,7 +770,9 @@ class RpcClient {
|
|
|
762
770
|
let bundleId = response.headers['x-bundle-id'];
|
|
763
771
|
(0, dist_1.log_info)('sendJitoTransaction finish', {
|
|
764
772
|
jitoApiUrl,
|
|
765
|
-
|
|
773
|
+
encoding,
|
|
774
|
+
bundleId,
|
|
775
|
+
take: (Date.now() - start) + 'ms'
|
|
766
776
|
});
|
|
767
777
|
return bundleId;
|
|
768
778
|
});
|
|
@@ -844,5 +854,19 @@ class RpcClient {
|
|
|
844
854
|
}
|
|
845
855
|
});
|
|
846
856
|
}
|
|
857
|
+
send_tx_to_all_jito_region(serializedTransaction, encoding) {
|
|
858
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
859
|
+
let jito_block_engine_urls = [
|
|
860
|
+
`${types_1.JITO_API_URLS['Default']}/api/v1/transactions?bundleOnly=true`,
|
|
861
|
+
`${types_1.JITO_API_URLS['NY']}/api/v1/transactions?bundleOnly=true`,
|
|
862
|
+
`${types_1.JITO_API_URLS['Amsterdam']}/api/v1/transactions?bundleOnly=true`,
|
|
863
|
+
`${types_1.JITO_API_URLS['Frankfurt']}/api/v1/transactions?bundleOnly=true`,
|
|
864
|
+
`${types_1.JITO_API_URLS['Tokyo']}/api/v1/transactions?bundleOnly=true`,
|
|
865
|
+
`${types_1.JITO_API_URLS['Slc']}/api/v1/transactions?bundleOnly=true`,
|
|
866
|
+
];
|
|
867
|
+
let bundle_id = yield Promise.race(jito_block_engine_urls.map(address => this.sendJitoTransaction(serializedTransaction, address, encoding)));
|
|
868
|
+
return bundle_id;
|
|
869
|
+
});
|
|
870
|
+
}
|
|
847
871
|
}
|
|
848
872
|
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;
|