@debridge-finance/solana-utils 2.0.0 → 2.2.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 +19 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/helpers.js +18 -6
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/esm/helpers.js +18 -5
- package/dist/esm/helpers.js.map +1 -1
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/helpers.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -7501,6 +7501,20 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
7501
7501
|
});
|
|
7502
7502
|
}
|
|
7503
7503
|
|
|
7504
|
+
function getAccountInfo(connection, account) {
|
|
7505
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7506
|
+
const info = yield connection.getAccountInfo(account);
|
|
7507
|
+
if (info) {
|
|
7508
|
+
// alchemy bug fix
|
|
7509
|
+
if (info.lamports === 0 && info.rentEpoch === 0)
|
|
7510
|
+
return null;
|
|
7511
|
+
return info;
|
|
7512
|
+
}
|
|
7513
|
+
else {
|
|
7514
|
+
return null;
|
|
7515
|
+
}
|
|
7516
|
+
});
|
|
7517
|
+
}
|
|
7504
7518
|
function hexToBuffer(data, align) {
|
|
7505
7519
|
if (!data.startsWith("0x"))
|
|
7506
7520
|
throw new Error("[hexToBuffer]: string must start with 0x");
|
|
@@ -7571,13 +7585,12 @@ class Wallet {
|
|
|
7571
7585
|
});
|
|
7572
7586
|
}
|
|
7573
7587
|
}
|
|
7574
|
-
function sendWithRetries(connection, serialized, lastValidBlockHeight) {
|
|
7588
|
+
function sendWithRetries(connection, serialized, lastValidBlockHeight, timesToSend = 5) {
|
|
7575
7589
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7576
7590
|
const txId = yield connection.sendRawTransaction(serialized, {
|
|
7577
7591
|
skipPreflight: true,
|
|
7578
7592
|
});
|
|
7579
7593
|
let blockheight = yield connection.getBlockHeight();
|
|
7580
|
-
const timesToSend = 5;
|
|
7581
7594
|
let sent = 0;
|
|
7582
7595
|
while (blockheight < lastValidBlockHeight && sent < timesToSend) {
|
|
7583
7596
|
yield connection.sendRawTransaction(serialized, {
|
|
@@ -7603,7 +7616,7 @@ function txToV0(transaction, payer, blockhash) {
|
|
|
7603
7616
|
return new VersionedTransaction(v0Message);
|
|
7604
7617
|
}
|
|
7605
7618
|
}
|
|
7606
|
-
function sendAll(connection, wallet, transactions, signers, waitBetweenSend, skipPreflight = false, debug = false, convertIntoTxV0 = true) {
|
|
7619
|
+
function sendAll(connection, wallet, transactions, signers, waitBetweenSend, skipPreflight = false, debug = false, convertIntoTxV0 = true, rpcCalls = 5) {
|
|
7607
7620
|
var _a;
|
|
7608
7621
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7609
7622
|
if (convertIntoTxV0) {
|
|
@@ -7639,7 +7652,7 @@ function sendAll(connection, wallet, transactions, signers, waitBetweenSend, ski
|
|
|
7639
7652
|
const serialized = buffer.Buffer.from(signedTx.serialize());
|
|
7640
7653
|
if (debug)
|
|
7641
7654
|
console.debug(serialized.toString("base64"));
|
|
7642
|
-
return sendWithRetries(connection, serialized, lastValidBlockHeight);
|
|
7655
|
+
return sendWithRetries(connection, serialized, lastValidBlockHeight, rpcCalls);
|
|
7643
7656
|
}));
|
|
7644
7657
|
}
|
|
7645
7658
|
else {
|
|
@@ -7667,7 +7680,7 @@ function sendAll(connection, wallet, transactions, signers, waitBetweenSend, ski
|
|
|
7667
7680
|
const serialized = buffer.Buffer.from(signed.serialize());
|
|
7668
7681
|
if (debug)
|
|
7669
7682
|
console.debug(serialized.toString("base64"));
|
|
7670
|
-
txIds.push(yield sendWithRetries(connection, serialized, lastValidBlockHeight));
|
|
7683
|
+
txIds.push(yield sendWithRetries(connection, serialized, lastValidBlockHeight, rpcCalls));
|
|
7671
7684
|
yield sleep(waitBetweenSend);
|
|
7672
7685
|
}
|
|
7673
7686
|
}
|
|
@@ -7677,6 +7690,7 @@ function sendAll(connection, wallet, transactions, signers, waitBetweenSend, ski
|
|
|
7677
7690
|
|
|
7678
7691
|
var helpers = /*#__PURE__*/Object.freeze({
|
|
7679
7692
|
__proto__: null,
|
|
7693
|
+
getAccountInfo: getAccountInfo,
|
|
7680
7694
|
hexToBuffer: hexToBuffer,
|
|
7681
7695
|
bufferToHex: bufferToHex,
|
|
7682
7696
|
sleep: sleep,
|