@solana/web3.js 1.41.9 → 1.43.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/lib/index.browser.cjs.js +238 -66
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +239 -67
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +238 -66
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +101 -24
- package/lib/index.esm.js +239 -67
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +238 -66
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +1 -1
- package/src/compute-budget.ts +92 -3
- package/src/connection.ts +157 -65
- package/src/transaction.ts +54 -7
- package/src/util/send-and-confirm-raw-transaction.ts +52 -7
- package/src/util/send-and-confirm-transaction.ts +19 -6
- package/src/util/tx-expiry-custom-errors.ts +35 -0
package/lib/index.browser.esm.js
CHANGED
|
@@ -2344,9 +2344,17 @@ function assert (condition, message) {
|
|
|
2344
2344
|
}
|
|
2345
2345
|
}
|
|
2346
2346
|
|
|
2347
|
+
let TransactionStatus;
|
|
2347
2348
|
/**
|
|
2348
2349
|
* Default (empty) signature
|
|
2349
2350
|
*/
|
|
2351
|
+
|
|
2352
|
+
(function (TransactionStatus) {
|
|
2353
|
+
TransactionStatus[TransactionStatus["BLOCKHEIGHT_EXCEEDED"] = 0] = "BLOCKHEIGHT_EXCEEDED";
|
|
2354
|
+
TransactionStatus[TransactionStatus["PROCESSED"] = 1] = "PROCESSED";
|
|
2355
|
+
TransactionStatus[TransactionStatus["TIMED_OUT"] = 2] = "TIMED_OUT";
|
|
2356
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
|
2357
|
+
|
|
2350
2358
|
const DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2351
2359
|
/**
|
|
2352
2360
|
* Account metadata used to define instructions
|
|
@@ -2437,10 +2445,23 @@ class Transaction {
|
|
|
2437
2445
|
this.feePayer = void 0;
|
|
2438
2446
|
this.instructions = [];
|
|
2439
2447
|
this.recentBlockhash = void 0;
|
|
2448
|
+
this.lastValidBlockHeight = void 0;
|
|
2440
2449
|
this.nonceInfo = void 0;
|
|
2441
2450
|
this._message = void 0;
|
|
2442
2451
|
this._json = void 0;
|
|
2443
|
-
|
|
2452
|
+
|
|
2453
|
+
if (!opts) {
|
|
2454
|
+
return;
|
|
2455
|
+
} else if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {
|
|
2456
|
+
const newOpts = opts;
|
|
2457
|
+
Object.assign(this, newOpts);
|
|
2458
|
+
this.recentBlockhash = newOpts.blockhash;
|
|
2459
|
+
this.lastValidBlockHeight = newOpts.lastValidBlockHeight;
|
|
2460
|
+
} else {
|
|
2461
|
+
const oldOpts = opts;
|
|
2462
|
+
Object.assign(this, oldOpts);
|
|
2463
|
+
this.recentBlockhash = oldOpts.recentBlockhash;
|
|
2464
|
+
}
|
|
2444
2465
|
}
|
|
2445
2466
|
/**
|
|
2446
2467
|
* @internal
|
|
@@ -2775,8 +2796,6 @@ class Transaction {
|
|
|
2775
2796
|
const message = this._compile();
|
|
2776
2797
|
|
|
2777
2798
|
this._partialSign(message, ...uniqueSigners);
|
|
2778
|
-
|
|
2779
|
-
this._verifySignatures(message.serialize(), true);
|
|
2780
2799
|
}
|
|
2781
2800
|
/**
|
|
2782
2801
|
* Partially sign a transaction with the specified accounts. All accounts must
|
|
@@ -3050,7 +3069,11 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
3050
3069
|
maxRetries: options.maxRetries
|
|
3051
3070
|
};
|
|
3052
3071
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
3053
|
-
const status = (await connection.confirmTransaction(
|
|
3072
|
+
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
3073
|
+
signature: signature,
|
|
3074
|
+
blockhash: transaction.recentBlockhash,
|
|
3075
|
+
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
3076
|
+
}, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
3054
3077
|
|
|
3055
3078
|
if (status.err) {
|
|
3056
3079
|
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
@@ -4130,6 +4153,34 @@ class ComputeBudgetInstruction {
|
|
|
4130
4153
|
bytes
|
|
4131
4154
|
};
|
|
4132
4155
|
}
|
|
4156
|
+
/**
|
|
4157
|
+
* Decode set compute unit limit compute budget instruction and retrieve the instruction params.
|
|
4158
|
+
*/
|
|
4159
|
+
|
|
4160
|
+
|
|
4161
|
+
static decodeSetComputeUnitLimit(instruction) {
|
|
4162
|
+
this.checkProgramId(instruction.programId);
|
|
4163
|
+
const {
|
|
4164
|
+
units
|
|
4165
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit, instruction.data);
|
|
4166
|
+
return {
|
|
4167
|
+
units
|
|
4168
|
+
};
|
|
4169
|
+
}
|
|
4170
|
+
/**
|
|
4171
|
+
* Decode set compute unit price compute budget instruction and retrieve the instruction params.
|
|
4172
|
+
*/
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
static decodeSetComputeUnitPrice(instruction) {
|
|
4176
|
+
this.checkProgramId(instruction.programId);
|
|
4177
|
+
const {
|
|
4178
|
+
microLamports
|
|
4179
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice, instruction.data);
|
|
4180
|
+
return {
|
|
4181
|
+
microLamports
|
|
4182
|
+
};
|
|
4183
|
+
}
|
|
4133
4184
|
/**
|
|
4134
4185
|
* @internal
|
|
4135
4186
|
*/
|
|
@@ -4158,6 +4209,14 @@ const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
4158
4209
|
RequestHeapFrame: {
|
|
4159
4210
|
index: 1,
|
|
4160
4211
|
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('bytes')])
|
|
4212
|
+
},
|
|
4213
|
+
SetComputeUnitLimit: {
|
|
4214
|
+
index: 2,
|
|
4215
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('units')])
|
|
4216
|
+
},
|
|
4217
|
+
SetComputeUnitPrice: {
|
|
4218
|
+
index: 3,
|
|
4219
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), u64('microLamports')])
|
|
4161
4220
|
}
|
|
4162
4221
|
});
|
|
4163
4222
|
/**
|
|
@@ -4194,6 +4253,28 @@ class ComputeBudgetProgram {
|
|
|
4194
4253
|
});
|
|
4195
4254
|
}
|
|
4196
4255
|
|
|
4256
|
+
static setComputeUnitLimit(params) {
|
|
4257
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit;
|
|
4258
|
+
const data = encodeData(type, params);
|
|
4259
|
+
return new TransactionInstruction({
|
|
4260
|
+
keys: [],
|
|
4261
|
+
programId: this.programId,
|
|
4262
|
+
data
|
|
4263
|
+
});
|
|
4264
|
+
}
|
|
4265
|
+
|
|
4266
|
+
static setComputeUnitPrice(params) {
|
|
4267
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice;
|
|
4268
|
+
const data = encodeData(type, {
|
|
4269
|
+
microLamports: BigInt(params.microLamports)
|
|
4270
|
+
});
|
|
4271
|
+
return new TransactionInstruction({
|
|
4272
|
+
keys: [],
|
|
4273
|
+
programId: this.programId,
|
|
4274
|
+
data
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
|
|
4197
4278
|
}
|
|
4198
4279
|
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4199
4280
|
|
|
@@ -4962,16 +5043,28 @@ const NUM_SLOTS_PER_SECOND = NUM_TICKS_PER_SECOND / DEFAULT_TICKS_PER_SLOT;
|
|
|
4962
5043
|
|
|
4963
5044
|
const MS_PER_SLOT = 1000 / NUM_SLOTS_PER_SECOND;
|
|
4964
5045
|
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
5046
|
+
class TransactionExpiredBlockheightExceededError extends Error {
|
|
5047
|
+
constructor(signature) {
|
|
5048
|
+
super(`Signature ${signature} has expired: block height exceeded.`);
|
|
5049
|
+
this.signature = void 0;
|
|
5050
|
+
this.signature = signature;
|
|
5051
|
+
}
|
|
5052
|
+
|
|
5053
|
+
}
|
|
5054
|
+
Object.defineProperty(TransactionExpiredBlockheightExceededError.prototype, 'name', {
|
|
5055
|
+
value: 'TransactionExpiredBlockheightExceededError'
|
|
5056
|
+
});
|
|
5057
|
+
class TransactionExpiredTimeoutError extends Error {
|
|
5058
|
+
constructor(signature, timeoutSeconds) {
|
|
5059
|
+
super(`Transaction was not confirmed in ${timeoutSeconds.toFixed(2)} seconds. It is ` + 'unknown if it succeeded or failed. Check signature ' + `${signature} using the Solana Explorer or CLI tools.`);
|
|
5060
|
+
this.signature = void 0;
|
|
5061
|
+
this.signature = signature;
|
|
5062
|
+
}
|
|
5063
|
+
|
|
4974
5064
|
}
|
|
5065
|
+
Object.defineProperty(TransactionExpiredTimeoutError.prototype, 'name', {
|
|
5066
|
+
value: 'TransactionExpiredTimeoutError'
|
|
5067
|
+
});
|
|
4975
5068
|
|
|
4976
5069
|
function makeWebsocketUrl(endpoint) {
|
|
4977
5070
|
let url = new URL(endpoint);
|
|
@@ -5960,7 +6053,7 @@ class Connection {
|
|
|
5960
6053
|
this._disableBlockhashCaching = false;
|
|
5961
6054
|
this._pollingBlockhash = false;
|
|
5962
6055
|
this._blockhashInfo = {
|
|
5963
|
-
|
|
6056
|
+
latestBlockhash: null,
|
|
5964
6057
|
lastFetch: 0,
|
|
5965
6058
|
transactionSignatures: [],
|
|
5966
6059
|
simulatedSignatures: []
|
|
@@ -6441,67 +6534,124 @@ class Connection {
|
|
|
6441
6534
|
|
|
6442
6535
|
return res.result;
|
|
6443
6536
|
}
|
|
6444
|
-
/**
|
|
6445
|
-
* Confirm the transaction identified by the specified signature.
|
|
6446
|
-
*/
|
|
6447
6537
|
|
|
6538
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
6539
|
+
async confirmTransaction(strategy, commitment) {
|
|
6540
|
+
let rawSignature;
|
|
6541
|
+
|
|
6542
|
+
if (typeof strategy == 'string') {
|
|
6543
|
+
rawSignature = strategy;
|
|
6544
|
+
} else {
|
|
6545
|
+
const config = strategy;
|
|
6546
|
+
rawSignature = config.signature;
|
|
6547
|
+
}
|
|
6448
6548
|
|
|
6449
|
-
async confirmTransaction(signature, commitment) {
|
|
6450
6549
|
let decodedSignature;
|
|
6451
6550
|
|
|
6452
6551
|
try {
|
|
6453
|
-
decodedSignature = bs58.decode(
|
|
6552
|
+
decodedSignature = bs58.decode(rawSignature);
|
|
6454
6553
|
} catch (err) {
|
|
6455
|
-
throw new Error('signature must be base58 encoded: ' +
|
|
6554
|
+
throw new Error('signature must be base58 encoded: ' + rawSignature);
|
|
6456
6555
|
}
|
|
6457
6556
|
|
|
6458
6557
|
assert(decodedSignature.length === 64, 'signature has invalid length');
|
|
6459
|
-
const start = Date.now();
|
|
6460
6558
|
const subscriptionCommitment = commitment || this.commitment;
|
|
6559
|
+
let timeoutId;
|
|
6461
6560
|
let subscriptionId;
|
|
6462
|
-
let
|
|
6463
|
-
const
|
|
6561
|
+
let done = false;
|
|
6562
|
+
const confirmationPromise = new Promise((resolve, reject) => {
|
|
6464
6563
|
try {
|
|
6465
|
-
subscriptionId = this.onSignature(
|
|
6564
|
+
subscriptionId = this.onSignature(rawSignature, (result, context) => {
|
|
6466
6565
|
subscriptionId = undefined;
|
|
6467
|
-
response = {
|
|
6566
|
+
const response = {
|
|
6468
6567
|
context,
|
|
6469
6568
|
value: result
|
|
6470
6569
|
};
|
|
6471
|
-
|
|
6570
|
+
done = true;
|
|
6571
|
+
resolve({
|
|
6572
|
+
__type: TransactionStatus.PROCESSED,
|
|
6573
|
+
response
|
|
6574
|
+
});
|
|
6472
6575
|
}, subscriptionCommitment);
|
|
6473
6576
|
} catch (err) {
|
|
6474
6577
|
reject(err);
|
|
6475
6578
|
}
|
|
6476
6579
|
});
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6580
|
+
|
|
6581
|
+
const checkBlockHeight = async () => {
|
|
6582
|
+
try {
|
|
6583
|
+
const blockHeight = await this.getBlockHeight(commitment);
|
|
6584
|
+
return blockHeight;
|
|
6585
|
+
} catch (_e) {
|
|
6586
|
+
return -1;
|
|
6587
|
+
}
|
|
6588
|
+
};
|
|
6589
|
+
|
|
6590
|
+
const expiryPromise = new Promise(resolve => {
|
|
6591
|
+
if (typeof strategy === 'string') {
|
|
6592
|
+
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
6593
|
+
|
|
6594
|
+
switch (subscriptionCommitment) {
|
|
6595
|
+
case 'processed':
|
|
6596
|
+
case 'recent':
|
|
6597
|
+
case 'single':
|
|
6598
|
+
case 'confirmed':
|
|
6599
|
+
case 'singleGossip':
|
|
6600
|
+
{
|
|
6601
|
+
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
|
6602
|
+
break;
|
|
6603
|
+
}
|
|
6488
6604
|
}
|
|
6489
|
-
|
|
6605
|
+
|
|
6606
|
+
timeoutId = setTimeout(() => resolve({
|
|
6607
|
+
__type: TransactionStatus.TIMED_OUT,
|
|
6608
|
+
timeoutMs
|
|
6609
|
+
}), timeoutMs);
|
|
6610
|
+
} else {
|
|
6611
|
+
let config = strategy;
|
|
6612
|
+
|
|
6613
|
+
(async () => {
|
|
6614
|
+
let currentBlockHeight = await checkBlockHeight();
|
|
6615
|
+
if (done) return;
|
|
6616
|
+
|
|
6617
|
+
while (currentBlockHeight <= config.lastValidBlockHeight) {
|
|
6618
|
+
await sleep(1000);
|
|
6619
|
+
if (done) return;
|
|
6620
|
+
currentBlockHeight = await checkBlockHeight();
|
|
6621
|
+
if (done) return;
|
|
6622
|
+
}
|
|
6623
|
+
|
|
6624
|
+
resolve({
|
|
6625
|
+
__type: TransactionStatus.BLOCKHEIGHT_EXCEEDED
|
|
6626
|
+
});
|
|
6627
|
+
})();
|
|
6628
|
+
}
|
|
6629
|
+
});
|
|
6630
|
+
let result;
|
|
6490
6631
|
|
|
6491
6632
|
try {
|
|
6492
|
-
await
|
|
6633
|
+
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
6634
|
+
|
|
6635
|
+
switch (outcome.__type) {
|
|
6636
|
+
case TransactionStatus.BLOCKHEIGHT_EXCEEDED:
|
|
6637
|
+
throw new TransactionExpiredBlockheightExceededError(rawSignature);
|
|
6638
|
+
|
|
6639
|
+
case TransactionStatus.PROCESSED:
|
|
6640
|
+
result = outcome.response;
|
|
6641
|
+
break;
|
|
6642
|
+
|
|
6643
|
+
case TransactionStatus.TIMED_OUT:
|
|
6644
|
+
throw new TransactionExpiredTimeoutError(rawSignature, outcome.timeoutMs / 1000);
|
|
6645
|
+
}
|
|
6493
6646
|
} finally {
|
|
6647
|
+
clearTimeout(timeoutId);
|
|
6648
|
+
|
|
6494
6649
|
if (subscriptionId) {
|
|
6495
6650
|
this.removeSignatureListener(subscriptionId);
|
|
6496
6651
|
}
|
|
6497
6652
|
}
|
|
6498
6653
|
|
|
6499
|
-
|
|
6500
|
-
const duration = (Date.now() - start) / 1000;
|
|
6501
|
-
throw new Error(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`);
|
|
6502
|
-
}
|
|
6503
|
-
|
|
6504
|
-
return response;
|
|
6654
|
+
return result;
|
|
6505
6655
|
}
|
|
6506
6656
|
/**
|
|
6507
6657
|
* Return the list of nodes that are currently participating in the cluster
|
|
@@ -6866,7 +7016,7 @@ class Connection {
|
|
|
6866
7016
|
}
|
|
6867
7017
|
/**
|
|
6868
7018
|
* Fetch the latest blockhash from the cluster
|
|
6869
|
-
* @return {Promise<
|
|
7019
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6870
7020
|
*/
|
|
6871
7021
|
|
|
6872
7022
|
|
|
@@ -6880,7 +7030,7 @@ class Connection {
|
|
|
6880
7030
|
}
|
|
6881
7031
|
/**
|
|
6882
7032
|
* Fetch the latest blockhash from the cluster
|
|
6883
|
-
* @return {Promise<
|
|
7033
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6884
7034
|
*/
|
|
6885
7035
|
|
|
6886
7036
|
|
|
@@ -7463,7 +7613,7 @@ class Connection {
|
|
|
7463
7613
|
*/
|
|
7464
7614
|
|
|
7465
7615
|
|
|
7466
|
-
async
|
|
7616
|
+
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
7467
7617
|
if (!disableCache) {
|
|
7468
7618
|
// Wait for polling to finish
|
|
7469
7619
|
while (this._pollingBlockhash) {
|
|
@@ -7474,8 +7624,8 @@ class Connection {
|
|
|
7474
7624
|
|
|
7475
7625
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
7476
7626
|
|
|
7477
|
-
if (this._blockhashInfo.
|
|
7478
|
-
return this._blockhashInfo.
|
|
7627
|
+
if (this._blockhashInfo.latestBlockhash !== null && !expired) {
|
|
7628
|
+
return this._blockhashInfo.latestBlockhash;
|
|
7479
7629
|
}
|
|
7480
7630
|
}
|
|
7481
7631
|
|
|
@@ -7491,20 +7641,20 @@ class Connection {
|
|
|
7491
7641
|
|
|
7492
7642
|
try {
|
|
7493
7643
|
const startTime = Date.now();
|
|
7644
|
+
const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;
|
|
7645
|
+
const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;
|
|
7494
7646
|
|
|
7495
7647
|
for (let i = 0; i < 50; i++) {
|
|
7496
|
-
const
|
|
7497
|
-
blockhash
|
|
7498
|
-
} = await this.getRecentBlockhash('finalized');
|
|
7648
|
+
const latestBlockhash = await this.getLatestBlockhash('finalized');
|
|
7499
7649
|
|
|
7500
|
-
if (
|
|
7650
|
+
if (cachedBlockhash !== latestBlockhash.blockhash) {
|
|
7501
7651
|
this._blockhashInfo = {
|
|
7502
|
-
|
|
7652
|
+
latestBlockhash,
|
|
7503
7653
|
lastFetch: Date.now(),
|
|
7504
7654
|
transactionSignatures: [],
|
|
7505
7655
|
simulatedSignatures: []
|
|
7506
7656
|
};
|
|
7507
|
-
return
|
|
7657
|
+
return latestBlockhash;
|
|
7508
7658
|
} // Sleep for approximately half a slot
|
|
7509
7659
|
|
|
7510
7660
|
|
|
@@ -7526,13 +7676,11 @@ class Connection {
|
|
|
7526
7676
|
|
|
7527
7677
|
if (transactionOrMessage instanceof Transaction) {
|
|
7528
7678
|
let originalTx = transactionOrMessage;
|
|
7529
|
-
transaction = new Transaction(
|
|
7530
|
-
|
|
7531
|
-
nonceInfo: originalTx.nonceInfo,
|
|
7532
|
-
feePayer: originalTx.feePayer,
|
|
7533
|
-
signatures: [...originalTx.signatures]
|
|
7534
|
-
});
|
|
7679
|
+
transaction = new Transaction();
|
|
7680
|
+
transaction.feePayer = originalTx.feePayer;
|
|
7535
7681
|
transaction.instructions = transactionOrMessage.instructions;
|
|
7682
|
+
transaction.nonceInfo = originalTx.nonceInfo;
|
|
7683
|
+
transaction.signatures = originalTx.signatures;
|
|
7536
7684
|
} else {
|
|
7537
7685
|
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
7538
7686
|
|
|
@@ -7545,7 +7693,9 @@ class Connection {
|
|
|
7545
7693
|
let disableCache = this._disableBlockhashCaching;
|
|
7546
7694
|
|
|
7547
7695
|
for (;;) {
|
|
7548
|
-
|
|
7696
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7697
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7698
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7549
7699
|
if (!signers) break;
|
|
7550
7700
|
transaction.sign(...signers);
|
|
7551
7701
|
|
|
@@ -7629,7 +7779,9 @@ class Connection {
|
|
|
7629
7779
|
let disableCache = this._disableBlockhashCaching;
|
|
7630
7780
|
|
|
7631
7781
|
for (;;) {
|
|
7632
|
-
|
|
7782
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7783
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7784
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7633
7785
|
transaction.sign(...signers);
|
|
7634
7786
|
|
|
7635
7787
|
if (!transaction.signature) {
|
|
@@ -10070,16 +10222,36 @@ VoteProgram.space = 3731;
|
|
|
10070
10222
|
*
|
|
10071
10223
|
* @param {Connection} connection
|
|
10072
10224
|
* @param {Buffer} rawTransaction
|
|
10225
|
+
* @param {BlockheightBasedTransactionConfirmationStrategy} confirmationStrategy
|
|
10073
10226
|
* @param {ConfirmOptions} [options]
|
|
10074
10227
|
* @returns {Promise<TransactionSignature>}
|
|
10075
10228
|
*/
|
|
10076
|
-
|
|
10229
|
+
|
|
10230
|
+
/**
|
|
10231
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
10232
|
+
* is no longer supported and will be removed in a future version.
|
|
10233
|
+
*/
|
|
10234
|
+
// eslint-disable-next-line no-redeclare
|
|
10235
|
+
// eslint-disable-next-line no-redeclare
|
|
10236
|
+
async function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {
|
|
10237
|
+
let confirmationStrategy;
|
|
10238
|
+
let options;
|
|
10239
|
+
|
|
10240
|
+
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
10241
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
10242
|
+
options = maybeConfirmOptions;
|
|
10243
|
+
} else {
|
|
10244
|
+
options = confirmationStrategyOrConfirmOptions;
|
|
10245
|
+
}
|
|
10246
|
+
|
|
10077
10247
|
const sendOptions = options && {
|
|
10078
10248
|
skipPreflight: options.skipPreflight,
|
|
10079
10249
|
preflightCommitment: options.preflightCommitment || options.commitment
|
|
10080
10250
|
};
|
|
10081
10251
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
10082
|
-
const
|
|
10252
|
+
const commitment = options && options.commitment;
|
|
10253
|
+
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
10254
|
+
const status = (await confirmationPromise).value;
|
|
10083
10255
|
|
|
10084
10256
|
if (status.err) {
|
|
10085
10257
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
@@ -10126,5 +10298,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
10126
10298
|
|
|
10127
10299
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
10128
10300
|
|
|
10129
|
-
export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
10301
|
+
export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, TransactionStatus, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
10130
10302
|
//# sourceMappingURL=index.browser.esm.js.map
|