@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.esm.js
CHANGED
|
@@ -2353,9 +2353,17 @@ function assert (condition, message) {
|
|
|
2353
2353
|
}
|
|
2354
2354
|
}
|
|
2355
2355
|
|
|
2356
|
+
let TransactionStatus;
|
|
2356
2357
|
/**
|
|
2357
2358
|
* Default (empty) signature
|
|
2358
2359
|
*/
|
|
2360
|
+
|
|
2361
|
+
(function (TransactionStatus) {
|
|
2362
|
+
TransactionStatus[TransactionStatus["BLOCKHEIGHT_EXCEEDED"] = 0] = "BLOCKHEIGHT_EXCEEDED";
|
|
2363
|
+
TransactionStatus[TransactionStatus["PROCESSED"] = 1] = "PROCESSED";
|
|
2364
|
+
TransactionStatus[TransactionStatus["TIMED_OUT"] = 2] = "TIMED_OUT";
|
|
2365
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
|
2366
|
+
|
|
2359
2367
|
const DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2360
2368
|
/**
|
|
2361
2369
|
* Account metadata used to define instructions
|
|
@@ -2446,10 +2454,23 @@ class Transaction {
|
|
|
2446
2454
|
this.feePayer = void 0;
|
|
2447
2455
|
this.instructions = [];
|
|
2448
2456
|
this.recentBlockhash = void 0;
|
|
2457
|
+
this.lastValidBlockHeight = void 0;
|
|
2449
2458
|
this.nonceInfo = void 0;
|
|
2450
2459
|
this._message = void 0;
|
|
2451
2460
|
this._json = void 0;
|
|
2452
|
-
|
|
2461
|
+
|
|
2462
|
+
if (!opts) {
|
|
2463
|
+
return;
|
|
2464
|
+
} else if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {
|
|
2465
|
+
const newOpts = opts;
|
|
2466
|
+
Object.assign(this, newOpts);
|
|
2467
|
+
this.recentBlockhash = newOpts.blockhash;
|
|
2468
|
+
this.lastValidBlockHeight = newOpts.lastValidBlockHeight;
|
|
2469
|
+
} else {
|
|
2470
|
+
const oldOpts = opts;
|
|
2471
|
+
Object.assign(this, oldOpts);
|
|
2472
|
+
this.recentBlockhash = oldOpts.recentBlockhash;
|
|
2473
|
+
}
|
|
2453
2474
|
}
|
|
2454
2475
|
/**
|
|
2455
2476
|
* @internal
|
|
@@ -2784,8 +2805,6 @@ class Transaction {
|
|
|
2784
2805
|
const message = this._compile();
|
|
2785
2806
|
|
|
2786
2807
|
this._partialSign(message, ...uniqueSigners);
|
|
2787
|
-
|
|
2788
|
-
this._verifySignatures(message.serialize(), true);
|
|
2789
2808
|
}
|
|
2790
2809
|
/**
|
|
2791
2810
|
* Partially sign a transaction with the specified accounts. All accounts must
|
|
@@ -3059,7 +3078,11 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
3059
3078
|
maxRetries: options.maxRetries
|
|
3060
3079
|
};
|
|
3061
3080
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
3062
|
-
const status = (await connection.confirmTransaction(
|
|
3081
|
+
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
3082
|
+
signature: signature,
|
|
3083
|
+
blockhash: transaction.recentBlockhash,
|
|
3084
|
+
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
3085
|
+
}, options && options.commitment)).value : (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
3063
3086
|
|
|
3064
3087
|
if (status.err) {
|
|
3065
3088
|
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
@@ -4139,6 +4162,34 @@ class ComputeBudgetInstruction {
|
|
|
4139
4162
|
bytes
|
|
4140
4163
|
};
|
|
4141
4164
|
}
|
|
4165
|
+
/**
|
|
4166
|
+
* Decode set compute unit limit compute budget instruction and retrieve the instruction params.
|
|
4167
|
+
*/
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
static decodeSetComputeUnitLimit(instruction) {
|
|
4171
|
+
this.checkProgramId(instruction.programId);
|
|
4172
|
+
const {
|
|
4173
|
+
units
|
|
4174
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit, instruction.data);
|
|
4175
|
+
return {
|
|
4176
|
+
units
|
|
4177
|
+
};
|
|
4178
|
+
}
|
|
4179
|
+
/**
|
|
4180
|
+
* Decode set compute unit price compute budget instruction and retrieve the instruction params.
|
|
4181
|
+
*/
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
static decodeSetComputeUnitPrice(instruction) {
|
|
4185
|
+
this.checkProgramId(instruction.programId);
|
|
4186
|
+
const {
|
|
4187
|
+
microLamports
|
|
4188
|
+
} = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice, instruction.data);
|
|
4189
|
+
return {
|
|
4190
|
+
microLamports
|
|
4191
|
+
};
|
|
4192
|
+
}
|
|
4142
4193
|
/**
|
|
4143
4194
|
* @internal
|
|
4144
4195
|
*/
|
|
@@ -4167,6 +4218,14 @@ const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
4167
4218
|
RequestHeapFrame: {
|
|
4168
4219
|
index: 1,
|
|
4169
4220
|
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('bytes')])
|
|
4221
|
+
},
|
|
4222
|
+
SetComputeUnitLimit: {
|
|
4223
|
+
index: 2,
|
|
4224
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('units')])
|
|
4225
|
+
},
|
|
4226
|
+
SetComputeUnitPrice: {
|
|
4227
|
+
index: 3,
|
|
4228
|
+
layout: BufferLayout.struct([BufferLayout.u8('instruction'), u64('microLamports')])
|
|
4170
4229
|
}
|
|
4171
4230
|
});
|
|
4172
4231
|
/**
|
|
@@ -4203,6 +4262,28 @@ class ComputeBudgetProgram {
|
|
|
4203
4262
|
});
|
|
4204
4263
|
}
|
|
4205
4264
|
|
|
4265
|
+
static setComputeUnitLimit(params) {
|
|
4266
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit;
|
|
4267
|
+
const data = encodeData(type, params);
|
|
4268
|
+
return new TransactionInstruction({
|
|
4269
|
+
keys: [],
|
|
4270
|
+
programId: this.programId,
|
|
4271
|
+
data
|
|
4272
|
+
});
|
|
4273
|
+
}
|
|
4274
|
+
|
|
4275
|
+
static setComputeUnitPrice(params) {
|
|
4276
|
+
const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice;
|
|
4277
|
+
const data = encodeData(type, {
|
|
4278
|
+
microLamports: BigInt(params.microLamports)
|
|
4279
|
+
});
|
|
4280
|
+
return new TransactionInstruction({
|
|
4281
|
+
keys: [],
|
|
4282
|
+
programId: this.programId,
|
|
4283
|
+
data
|
|
4284
|
+
});
|
|
4285
|
+
}
|
|
4286
|
+
|
|
4206
4287
|
}
|
|
4207
4288
|
ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
|
|
4208
4289
|
|
|
@@ -4459,16 +4540,28 @@ const NUM_SLOTS_PER_SECOND = NUM_TICKS_PER_SECOND / DEFAULT_TICKS_PER_SLOT;
|
|
|
4459
4540
|
|
|
4460
4541
|
const MS_PER_SLOT = 1000 / NUM_SLOTS_PER_SECOND;
|
|
4461
4542
|
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4543
|
+
class TransactionExpiredBlockheightExceededError extends Error {
|
|
4544
|
+
constructor(signature) {
|
|
4545
|
+
super(`Signature ${signature} has expired: block height exceeded.`);
|
|
4546
|
+
this.signature = void 0;
|
|
4547
|
+
this.signature = signature;
|
|
4548
|
+
}
|
|
4549
|
+
|
|
4550
|
+
}
|
|
4551
|
+
Object.defineProperty(TransactionExpiredBlockheightExceededError.prototype, 'name', {
|
|
4552
|
+
value: 'TransactionExpiredBlockheightExceededError'
|
|
4553
|
+
});
|
|
4554
|
+
class TransactionExpiredTimeoutError extends Error {
|
|
4555
|
+
constructor(signature, timeoutSeconds) {
|
|
4556
|
+
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.`);
|
|
4557
|
+
this.signature = void 0;
|
|
4558
|
+
this.signature = signature;
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4471
4561
|
}
|
|
4562
|
+
Object.defineProperty(TransactionExpiredTimeoutError.prototype, 'name', {
|
|
4563
|
+
value: 'TransactionExpiredTimeoutError'
|
|
4564
|
+
});
|
|
4472
4565
|
|
|
4473
4566
|
function makeWebsocketUrl(endpoint) {
|
|
4474
4567
|
let url = new URL(endpoint);
|
|
@@ -5463,7 +5556,7 @@ class Connection {
|
|
|
5463
5556
|
this._disableBlockhashCaching = false;
|
|
5464
5557
|
this._pollingBlockhash = false;
|
|
5465
5558
|
this._blockhashInfo = {
|
|
5466
|
-
|
|
5559
|
+
latestBlockhash: null,
|
|
5467
5560
|
lastFetch: 0,
|
|
5468
5561
|
transactionSignatures: [],
|
|
5469
5562
|
simulatedSignatures: []
|
|
@@ -5944,67 +6037,124 @@ class Connection {
|
|
|
5944
6037
|
|
|
5945
6038
|
return res.result;
|
|
5946
6039
|
}
|
|
5947
|
-
/**
|
|
5948
|
-
* Confirm the transaction identified by the specified signature.
|
|
5949
|
-
*/
|
|
5950
6040
|
|
|
6041
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
6042
|
+
async confirmTransaction(strategy, commitment) {
|
|
6043
|
+
let rawSignature;
|
|
6044
|
+
|
|
6045
|
+
if (typeof strategy == 'string') {
|
|
6046
|
+
rawSignature = strategy;
|
|
6047
|
+
} else {
|
|
6048
|
+
const config = strategy;
|
|
6049
|
+
rawSignature = config.signature;
|
|
6050
|
+
}
|
|
5951
6051
|
|
|
5952
|
-
async confirmTransaction(signature, commitment) {
|
|
5953
6052
|
let decodedSignature;
|
|
5954
6053
|
|
|
5955
6054
|
try {
|
|
5956
|
-
decodedSignature = bs58.decode(
|
|
6055
|
+
decodedSignature = bs58.decode(rawSignature);
|
|
5957
6056
|
} catch (err) {
|
|
5958
|
-
throw new Error('signature must be base58 encoded: ' +
|
|
6057
|
+
throw new Error('signature must be base58 encoded: ' + rawSignature);
|
|
5959
6058
|
}
|
|
5960
6059
|
|
|
5961
6060
|
assert(decodedSignature.length === 64, 'signature has invalid length');
|
|
5962
|
-
const start = Date.now();
|
|
5963
6061
|
const subscriptionCommitment = commitment || this.commitment;
|
|
6062
|
+
let timeoutId;
|
|
5964
6063
|
let subscriptionId;
|
|
5965
|
-
let
|
|
5966
|
-
const
|
|
6064
|
+
let done = false;
|
|
6065
|
+
const confirmationPromise = new Promise((resolve, reject) => {
|
|
5967
6066
|
try {
|
|
5968
|
-
subscriptionId = this.onSignature(
|
|
6067
|
+
subscriptionId = this.onSignature(rawSignature, (result, context) => {
|
|
5969
6068
|
subscriptionId = undefined;
|
|
5970
|
-
response = {
|
|
6069
|
+
const response = {
|
|
5971
6070
|
context,
|
|
5972
6071
|
value: result
|
|
5973
6072
|
};
|
|
5974
|
-
|
|
6073
|
+
done = true;
|
|
6074
|
+
resolve({
|
|
6075
|
+
__type: TransactionStatus.PROCESSED,
|
|
6076
|
+
response
|
|
6077
|
+
});
|
|
5975
6078
|
}, subscriptionCommitment);
|
|
5976
6079
|
} catch (err) {
|
|
5977
6080
|
reject(err);
|
|
5978
6081
|
}
|
|
5979
6082
|
});
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
6083
|
+
|
|
6084
|
+
const checkBlockHeight = async () => {
|
|
6085
|
+
try {
|
|
6086
|
+
const blockHeight = await this.getBlockHeight(commitment);
|
|
6087
|
+
return blockHeight;
|
|
6088
|
+
} catch (_e) {
|
|
6089
|
+
return -1;
|
|
6090
|
+
}
|
|
6091
|
+
};
|
|
6092
|
+
|
|
6093
|
+
const expiryPromise = new Promise(resolve => {
|
|
6094
|
+
if (typeof strategy === 'string') {
|
|
6095
|
+
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
6096
|
+
|
|
6097
|
+
switch (subscriptionCommitment) {
|
|
6098
|
+
case 'processed':
|
|
6099
|
+
case 'recent':
|
|
6100
|
+
case 'single':
|
|
6101
|
+
case 'confirmed':
|
|
6102
|
+
case 'singleGossip':
|
|
6103
|
+
{
|
|
6104
|
+
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
|
6105
|
+
break;
|
|
6106
|
+
}
|
|
5991
6107
|
}
|
|
5992
|
-
|
|
6108
|
+
|
|
6109
|
+
timeoutId = setTimeout(() => resolve({
|
|
6110
|
+
__type: TransactionStatus.TIMED_OUT,
|
|
6111
|
+
timeoutMs
|
|
6112
|
+
}), timeoutMs);
|
|
6113
|
+
} else {
|
|
6114
|
+
let config = strategy;
|
|
6115
|
+
|
|
6116
|
+
(async () => {
|
|
6117
|
+
let currentBlockHeight = await checkBlockHeight();
|
|
6118
|
+
if (done) return;
|
|
6119
|
+
|
|
6120
|
+
while (currentBlockHeight <= config.lastValidBlockHeight) {
|
|
6121
|
+
await sleep(1000);
|
|
6122
|
+
if (done) return;
|
|
6123
|
+
currentBlockHeight = await checkBlockHeight();
|
|
6124
|
+
if (done) return;
|
|
6125
|
+
}
|
|
6126
|
+
|
|
6127
|
+
resolve({
|
|
6128
|
+
__type: TransactionStatus.BLOCKHEIGHT_EXCEEDED
|
|
6129
|
+
});
|
|
6130
|
+
})();
|
|
6131
|
+
}
|
|
6132
|
+
});
|
|
6133
|
+
let result;
|
|
5993
6134
|
|
|
5994
6135
|
try {
|
|
5995
|
-
await
|
|
6136
|
+
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
6137
|
+
|
|
6138
|
+
switch (outcome.__type) {
|
|
6139
|
+
case TransactionStatus.BLOCKHEIGHT_EXCEEDED:
|
|
6140
|
+
throw new TransactionExpiredBlockheightExceededError(rawSignature);
|
|
6141
|
+
|
|
6142
|
+
case TransactionStatus.PROCESSED:
|
|
6143
|
+
result = outcome.response;
|
|
6144
|
+
break;
|
|
6145
|
+
|
|
6146
|
+
case TransactionStatus.TIMED_OUT:
|
|
6147
|
+
throw new TransactionExpiredTimeoutError(rawSignature, outcome.timeoutMs / 1000);
|
|
6148
|
+
}
|
|
5996
6149
|
} finally {
|
|
6150
|
+
clearTimeout(timeoutId);
|
|
6151
|
+
|
|
5997
6152
|
if (subscriptionId) {
|
|
5998
6153
|
this.removeSignatureListener(subscriptionId);
|
|
5999
6154
|
}
|
|
6000
6155
|
}
|
|
6001
6156
|
|
|
6002
|
-
|
|
6003
|
-
const duration = (Date.now() - start) / 1000;
|
|
6004
|
-
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.`);
|
|
6005
|
-
}
|
|
6006
|
-
|
|
6007
|
-
return response;
|
|
6157
|
+
return result;
|
|
6008
6158
|
}
|
|
6009
6159
|
/**
|
|
6010
6160
|
* Return the list of nodes that are currently participating in the cluster
|
|
@@ -6369,7 +6519,7 @@ class Connection {
|
|
|
6369
6519
|
}
|
|
6370
6520
|
/**
|
|
6371
6521
|
* Fetch the latest blockhash from the cluster
|
|
6372
|
-
* @return {Promise<
|
|
6522
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6373
6523
|
*/
|
|
6374
6524
|
|
|
6375
6525
|
|
|
@@ -6383,7 +6533,7 @@ class Connection {
|
|
|
6383
6533
|
}
|
|
6384
6534
|
/**
|
|
6385
6535
|
* Fetch the latest blockhash from the cluster
|
|
6386
|
-
* @return {Promise<
|
|
6536
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6387
6537
|
*/
|
|
6388
6538
|
|
|
6389
6539
|
|
|
@@ -6966,7 +7116,7 @@ class Connection {
|
|
|
6966
7116
|
*/
|
|
6967
7117
|
|
|
6968
7118
|
|
|
6969
|
-
async
|
|
7119
|
+
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
6970
7120
|
if (!disableCache) {
|
|
6971
7121
|
// Wait for polling to finish
|
|
6972
7122
|
while (this._pollingBlockhash) {
|
|
@@ -6977,8 +7127,8 @@ class Connection {
|
|
|
6977
7127
|
|
|
6978
7128
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
6979
7129
|
|
|
6980
|
-
if (this._blockhashInfo.
|
|
6981
|
-
return this._blockhashInfo.
|
|
7130
|
+
if (this._blockhashInfo.latestBlockhash !== null && !expired) {
|
|
7131
|
+
return this._blockhashInfo.latestBlockhash;
|
|
6982
7132
|
}
|
|
6983
7133
|
}
|
|
6984
7134
|
|
|
@@ -6994,20 +7144,20 @@ class Connection {
|
|
|
6994
7144
|
|
|
6995
7145
|
try {
|
|
6996
7146
|
const startTime = Date.now();
|
|
7147
|
+
const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;
|
|
7148
|
+
const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;
|
|
6997
7149
|
|
|
6998
7150
|
for (let i = 0; i < 50; i++) {
|
|
6999
|
-
const
|
|
7000
|
-
blockhash
|
|
7001
|
-
} = await this.getRecentBlockhash('finalized');
|
|
7151
|
+
const latestBlockhash = await this.getLatestBlockhash('finalized');
|
|
7002
7152
|
|
|
7003
|
-
if (
|
|
7153
|
+
if (cachedBlockhash !== latestBlockhash.blockhash) {
|
|
7004
7154
|
this._blockhashInfo = {
|
|
7005
|
-
|
|
7155
|
+
latestBlockhash,
|
|
7006
7156
|
lastFetch: Date.now(),
|
|
7007
7157
|
transactionSignatures: [],
|
|
7008
7158
|
simulatedSignatures: []
|
|
7009
7159
|
};
|
|
7010
|
-
return
|
|
7160
|
+
return latestBlockhash;
|
|
7011
7161
|
} // Sleep for approximately half a slot
|
|
7012
7162
|
|
|
7013
7163
|
|
|
@@ -7029,13 +7179,11 @@ class Connection {
|
|
|
7029
7179
|
|
|
7030
7180
|
if (transactionOrMessage instanceof Transaction) {
|
|
7031
7181
|
let originalTx = transactionOrMessage;
|
|
7032
|
-
transaction = new Transaction(
|
|
7033
|
-
|
|
7034
|
-
nonceInfo: originalTx.nonceInfo,
|
|
7035
|
-
feePayer: originalTx.feePayer,
|
|
7036
|
-
signatures: [...originalTx.signatures]
|
|
7037
|
-
});
|
|
7182
|
+
transaction = new Transaction();
|
|
7183
|
+
transaction.feePayer = originalTx.feePayer;
|
|
7038
7184
|
transaction.instructions = transactionOrMessage.instructions;
|
|
7185
|
+
transaction.nonceInfo = originalTx.nonceInfo;
|
|
7186
|
+
transaction.signatures = originalTx.signatures;
|
|
7039
7187
|
} else {
|
|
7040
7188
|
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
7041
7189
|
|
|
@@ -7048,7 +7196,9 @@ class Connection {
|
|
|
7048
7196
|
let disableCache = this._disableBlockhashCaching;
|
|
7049
7197
|
|
|
7050
7198
|
for (;;) {
|
|
7051
|
-
|
|
7199
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7200
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7201
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7052
7202
|
if (!signers) break;
|
|
7053
7203
|
transaction.sign(...signers);
|
|
7054
7204
|
|
|
@@ -7132,7 +7282,9 @@ class Connection {
|
|
|
7132
7282
|
let disableCache = this._disableBlockhashCaching;
|
|
7133
7283
|
|
|
7134
7284
|
for (;;) {
|
|
7135
|
-
|
|
7285
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7286
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7287
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7136
7288
|
transaction.sign(...signers);
|
|
7137
7289
|
|
|
7138
7290
|
if (!transaction.signature) {
|
|
@@ -9573,16 +9725,36 @@ VoteProgram.space = 3731;
|
|
|
9573
9725
|
*
|
|
9574
9726
|
* @param {Connection} connection
|
|
9575
9727
|
* @param {Buffer} rawTransaction
|
|
9728
|
+
* @param {BlockheightBasedTransactionConfirmationStrategy} confirmationStrategy
|
|
9576
9729
|
* @param {ConfirmOptions} [options]
|
|
9577
9730
|
* @returns {Promise<TransactionSignature>}
|
|
9578
9731
|
*/
|
|
9579
|
-
|
|
9732
|
+
|
|
9733
|
+
/**
|
|
9734
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
9735
|
+
* is no longer supported and will be removed in a future version.
|
|
9736
|
+
*/
|
|
9737
|
+
// eslint-disable-next-line no-redeclare
|
|
9738
|
+
// eslint-disable-next-line no-redeclare
|
|
9739
|
+
async function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {
|
|
9740
|
+
let confirmationStrategy;
|
|
9741
|
+
let options;
|
|
9742
|
+
|
|
9743
|
+
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
9744
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
9745
|
+
options = maybeConfirmOptions;
|
|
9746
|
+
} else {
|
|
9747
|
+
options = confirmationStrategyOrConfirmOptions;
|
|
9748
|
+
}
|
|
9749
|
+
|
|
9580
9750
|
const sendOptions = options && {
|
|
9581
9751
|
skipPreflight: options.skipPreflight,
|
|
9582
9752
|
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9583
9753
|
};
|
|
9584
9754
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9585
|
-
const
|
|
9755
|
+
const commitment = options && options.commitment;
|
|
9756
|
+
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
9757
|
+
const status = (await confirmationPromise).value;
|
|
9586
9758
|
|
|
9587
9759
|
if (status.err) {
|
|
9588
9760
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
@@ -9629,5 +9801,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
9629
9801
|
|
|
9630
9802
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
9631
9803
|
|
|
9632
|
-
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 };
|
|
9804
|
+
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 };
|
|
9633
9805
|
//# sourceMappingURL=index.esm.js.map
|