@debridge-finance/solana-utils 2.2.0 → 2.3.0
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/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction,
|
|
1
|
+
import { Transaction, VersionedTransaction, MessageV0, PublicKey } from '@solana/web3.js';
|
|
2
2
|
|
|
3
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
4
|
|
|
@@ -7589,12 +7589,14 @@ function sendWithRetries(connection, serialized, lastValidBlockHeight, timesToSe
|
|
|
7589
7589
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7590
7590
|
const txId = yield connection.sendRawTransaction(serialized, {
|
|
7591
7591
|
skipPreflight: true,
|
|
7592
|
+
maxRetries: 1000,
|
|
7592
7593
|
});
|
|
7593
7594
|
let blockheight = yield connection.getBlockHeight();
|
|
7594
7595
|
let sent = 0;
|
|
7595
7596
|
while (blockheight < lastValidBlockHeight && sent < timesToSend) {
|
|
7596
7597
|
yield connection.sendRawTransaction(serialized, {
|
|
7597
7598
|
skipPreflight: true,
|
|
7599
|
+
maxRetries: 1000,
|
|
7598
7600
|
});
|
|
7599
7601
|
yield sleep(300);
|
|
7600
7602
|
blockheight = yield connection.getBlockHeight();
|
|
@@ -7620,7 +7622,7 @@ function sendAll(connection, wallet, transactions, signers, waitBetweenSend, ski
|
|
|
7620
7622
|
var _a;
|
|
7621
7623
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7622
7624
|
if (convertIntoTxV0) {
|
|
7623
|
-
const fakeBlockHash = "
|
|
7625
|
+
const fakeBlockHash = "1".repeat(32);
|
|
7624
7626
|
transactions = transactions.map((tx) => txToV0(tx, wallet.publicKey, fakeBlockHash));
|
|
7625
7627
|
}
|
|
7626
7628
|
let txIds = [];
|
|
@@ -7636,13 +7638,12 @@ function sendAll(connection, wallet, transactions, signers, waitBetweenSend, ski
|
|
|
7636
7638
|
else {
|
|
7637
7639
|
tx.recentBlockhash = blockhash;
|
|
7638
7640
|
tx.feePayer = wallet.publicKey;
|
|
7639
|
-
|
|
7640
|
-
txV0 = new VersionedTransaction(new MessageV0({ addressTableLookups: [], compiledInstructions: [], header: message.header, recentBlockhash: blockhash, staticAccountKeys: message.accountKeys }));
|
|
7641
|
+
txV0 = new VersionedTransaction(MessageV0.compile({ addressLookupTableAccounts: [], instructions: tx.instructions, recentBlockhash: blockhash, payerKey: tx.feePayer }));
|
|
7641
7642
|
}
|
|
7642
7643
|
if (!skipPreflight) {
|
|
7643
7644
|
const simulationResult = yield connection.simulateTransaction(txV0, { sigVerify: false, replaceRecentBlockhash: true, commitment: "confirmed" });
|
|
7644
7645
|
if (simulationResult.value.err !== null) {
|
|
7645
|
-
throw new Error(`Tx simulation Error! Transaction message dump: ${buffer.Buffer.from(
|
|
7646
|
+
throw new Error(`Tx simulation Error! Transaction message dump: ${buffer.Buffer.from(txV0.serialize()).toString("base64")}\n Error: ${JSON.stringify(simulationResult.value.err)}, logs:\n ${(_b = simulationResult.value.logs) === null || _b === void 0 ? void 0 : _b.join("\n")}`);
|
|
7646
7647
|
}
|
|
7647
7648
|
}
|
|
7648
7649
|
})));
|
|
@@ -7667,14 +7668,13 @@ function sendAll(connection, wallet, transactions, signers, waitBetweenSend, ski
|
|
|
7667
7668
|
else {
|
|
7668
7669
|
tx.recentBlockhash = blockhash;
|
|
7669
7670
|
tx.feePayer = wallet.publicKey;
|
|
7670
|
-
|
|
7671
|
-
txV0 = new VersionedTransaction(new MessageV0({ addressTableLookups: [], compiledInstructions: [], header: message.header, recentBlockhash: blockhash, staticAccountKeys: message.accountKeys }));
|
|
7671
|
+
txV0 = new VersionedTransaction(MessageV0.compile({ addressLookupTableAccounts: [], instructions: tx.instructions, recentBlockhash: blockhash, payerKey: tx.feePayer }));
|
|
7672
7672
|
}
|
|
7673
7673
|
const signed = yield wallet.signTransaction(tx, signers && signers.length > i ? signers[i] : undefined);
|
|
7674
7674
|
if (!skipPreflight) {
|
|
7675
7675
|
const simulationResult = yield connection.simulateTransaction(txV0, { sigVerify: false, replaceRecentBlockhash: true, commitment: "confirmed" });
|
|
7676
7676
|
if (simulationResult.value.err !== null) {
|
|
7677
|
-
throw new Error(`Tx simulation Error! Transaction message dump: ${buffer.Buffer.from(
|
|
7677
|
+
throw new Error(`Tx simulation Error! Transaction message dump: ${buffer.Buffer.from(txV0.serialize()).toString("base64")}\n Error: ${JSON.stringify(simulationResult.value.err)}, logs:\n ${(_a = simulationResult.value.logs) === null || _a === void 0 ? void 0 : _a.join("\n")}`);
|
|
7678
7678
|
}
|
|
7679
7679
|
}
|
|
7680
7680
|
const serialized = buffer.Buffer.from(signed.serialize());
|