@solana/web3.js 1.66.5 → 1.67.1
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 +341 -72
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +341 -73
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +341 -72
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +87 -7
- package/lib/index.esm.js +341 -73
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +341 -72
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +341 -72
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -3
- package/src/account.ts +1 -1
- package/src/connection.ts +320 -76
- package/src/message/legacy.ts +4 -4
- package/src/nonce-account.ts +7 -3
- package/src/publickey.ts +6 -2
- package/src/transaction/expiry-custom-errors.ts +13 -0
- package/src/transaction/legacy.ts +39 -3
- package/src/transaction/message.ts +3 -1
- package/src/utils/send-and-confirm-raw-transaction.ts +13 -0
- package/src/utils/send-and-confirm-transaction.ts +39 -18
package/lib/index.iife.js
CHANGED
|
@@ -8352,13 +8352,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
8352
8352
|
this._bn = new BN(value);
|
|
8353
8353
|
}
|
|
8354
8354
|
|
|
8355
|
-
if (this._bn.byteLength() >
|
|
8355
|
+
if (this._bn.byteLength() > PUBLIC_KEY_LENGTH) {
|
|
8356
8356
|
throw new Error(`Invalid public key input`);
|
|
8357
8357
|
}
|
|
8358
8358
|
}
|
|
8359
8359
|
}
|
|
8360
8360
|
/**
|
|
8361
|
-
* Returns a unique PublicKey for tests and benchmarks using
|
|
8361
|
+
* Returns a unique PublicKey for tests and benchmarks using a counter
|
|
8362
8362
|
*/
|
|
8363
8363
|
|
|
8364
8364
|
|
|
@@ -8465,6 +8465,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
8465
8465
|
/**
|
|
8466
8466
|
* Async version of createProgramAddressSync
|
|
8467
8467
|
* For backwards compatibility
|
|
8468
|
+
*
|
|
8469
|
+
* @deprecated Use {@link createProgramAddressSync} instead
|
|
8468
8470
|
*/
|
|
8469
8471
|
|
|
8470
8472
|
/* eslint-disable require-await */
|
|
@@ -8507,6 +8509,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
8507
8509
|
/**
|
|
8508
8510
|
* Async version of findProgramAddressSync
|
|
8509
8511
|
* For backwards compatibility
|
|
8512
|
+
*
|
|
8513
|
+
* @deprecated Use {@link findProgramAddressSync} instead
|
|
8510
8514
|
*/
|
|
8511
8515
|
|
|
8512
8516
|
|
|
@@ -10906,6 +10910,17 @@ var solanaWeb3 = (function (exports) {
|
|
|
10906
10910
|
Object.defineProperty(TransactionExpiredTimeoutError.prototype, 'name', {
|
|
10907
10911
|
value: 'TransactionExpiredTimeoutError'
|
|
10908
10912
|
});
|
|
10913
|
+
class TransactionExpiredNonceInvalidError extends Error {
|
|
10914
|
+
constructor(signature) {
|
|
10915
|
+
super(`Signature ${signature} has expired: the nonce is no longer valid.`);
|
|
10916
|
+
this.signature = void 0;
|
|
10917
|
+
this.signature = signature;
|
|
10918
|
+
}
|
|
10919
|
+
|
|
10920
|
+
}
|
|
10921
|
+
Object.defineProperty(TransactionExpiredNonceInvalidError.prototype, 'name', {
|
|
10922
|
+
value: 'TransactionExpiredNonceInvalidError'
|
|
10923
|
+
});
|
|
10909
10924
|
|
|
10910
10925
|
class MessageAccountKeys {
|
|
10911
10926
|
constructor(staticAccountKeys, accountKeysFromLookups) {
|
|
@@ -11743,6 +11758,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
11743
11758
|
TransactionStatus[TransactionStatus["BLOCKHEIGHT_EXCEEDED"] = 0] = "BLOCKHEIGHT_EXCEEDED";
|
|
11744
11759
|
TransactionStatus[TransactionStatus["PROCESSED"] = 1] = "PROCESSED";
|
|
11745
11760
|
TransactionStatus[TransactionStatus["TIMED_OUT"] = 2] = "TIMED_OUT";
|
|
11761
|
+
TransactionStatus[TransactionStatus["NONCE_INVALID"] = 3] = "NONCE_INVALID";
|
|
11746
11762
|
})(exports.TransactionStatus || (exports.TransactionStatus = {}));
|
|
11747
11763
|
|
|
11748
11764
|
const DEFAULT_SIGNATURE = buffer.Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
@@ -11837,6 +11853,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
11837
11853
|
this.recentBlockhash = void 0;
|
|
11838
11854
|
this.lastValidBlockHeight = void 0;
|
|
11839
11855
|
this.nonceInfo = void 0;
|
|
11856
|
+
this.minNonceContextSlot = void 0;
|
|
11840
11857
|
this._message = void 0;
|
|
11841
11858
|
this._json = void 0;
|
|
11842
11859
|
|
|
@@ -11852,7 +11869,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
11852
11869
|
this.signatures = opts.signatures;
|
|
11853
11870
|
}
|
|
11854
11871
|
|
|
11855
|
-
if (Object.prototype.hasOwnProperty.call(opts, '
|
|
11872
|
+
if (Object.prototype.hasOwnProperty.call(opts, 'nonceInfo')) {
|
|
11873
|
+
const {
|
|
11874
|
+
minContextSlot,
|
|
11875
|
+
nonceInfo
|
|
11876
|
+
} = opts;
|
|
11877
|
+
this.minNonceContextSlot = minContextSlot;
|
|
11878
|
+
this.nonceInfo = nonceInfo;
|
|
11879
|
+
} else if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {
|
|
11856
11880
|
const {
|
|
11857
11881
|
blockhash,
|
|
11858
11882
|
lastValidBlockHeight
|
|
@@ -12485,7 +12509,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
12485
12509
|
} = header;
|
|
12486
12510
|
const numWritableSignedAccounts = numRequiredSignatures - numReadonlySignedAccounts;
|
|
12487
12511
|
assert$1(numWritableSignedAccounts > 0, 'Message header is invalid');
|
|
12488
|
-
const numWritableUnsignedAccounts = message.staticAccountKeys.length - numReadonlyUnsignedAccounts;
|
|
12512
|
+
const numWritableUnsignedAccounts = message.staticAccountKeys.length - numRequiredSignatures - numReadonlyUnsignedAccounts;
|
|
12489
12513
|
assert$1(numWritableUnsignedAccounts >= 0, 'Message header is invalid');
|
|
12490
12514
|
const accountKeys = message.getAccountKeys(args);
|
|
12491
12515
|
const payerKey = accountKeys.get(0);
|
|
@@ -12669,11 +12693,28 @@ var solanaWeb3 = (function (exports) {
|
|
|
12669
12693
|
minContextSlot: options.minContextSlot
|
|
12670
12694
|
};
|
|
12671
12695
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12696
|
+
let status;
|
|
12697
|
+
|
|
12698
|
+
if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
|
|
12699
|
+
status = (await connection.confirmTransaction({
|
|
12700
|
+
signature: signature,
|
|
12701
|
+
blockhash: transaction.recentBlockhash,
|
|
12702
|
+
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
12703
|
+
}, options && options.commitment)).value;
|
|
12704
|
+
} else if (transaction.minNonceContextSlot != null && transaction.nonceInfo != null) {
|
|
12705
|
+
const {
|
|
12706
|
+
nonceInstruction
|
|
12707
|
+
} = transaction.nonceInfo;
|
|
12708
|
+
const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
|
|
12709
|
+
status = (await connection.confirmTransaction({
|
|
12710
|
+
minContextSlot: transaction.minNonceContextSlot,
|
|
12711
|
+
nonceAccountPubkey,
|
|
12712
|
+
nonceValue: transaction.nonceInfo.nonce,
|
|
12713
|
+
signature
|
|
12714
|
+
}, options && options.commitment)).value;
|
|
12715
|
+
} else {
|
|
12716
|
+
status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
12717
|
+
}
|
|
12677
12718
|
|
|
12678
12719
|
if (status.err) {
|
|
12679
12720
|
throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
|
|
@@ -12742,6 +12783,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
12742
12783
|
|
|
12743
12784
|
const NonceAccountLayout = struct([u32('version'), u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), struct([FeeCalculatorLayout], 'feeCalculator')]);
|
|
12744
12785
|
const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;
|
|
12786
|
+
/**
|
|
12787
|
+
* A durable nonce is a 32 byte value encoded as a base58 string.
|
|
12788
|
+
*/
|
|
12745
12789
|
|
|
12746
12790
|
/**
|
|
12747
12791
|
* NonceAccount class
|
|
@@ -17269,10 +17313,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
17269
17313
|
};
|
|
17270
17314
|
}
|
|
17271
17315
|
/**
|
|
17272
|
-
*
|
|
17316
|
+
* A strategy for confirming durable nonce transactions.
|
|
17273
17317
|
*/
|
|
17274
17318
|
|
|
17275
17319
|
|
|
17320
|
+
/**
|
|
17321
|
+
* @internal
|
|
17322
|
+
*/
|
|
17276
17323
|
function createRpcResult(result) {
|
|
17277
17324
|
return union([type({
|
|
17278
17325
|
jsonrpc: literal('2.0'),
|
|
@@ -18836,25 +18883,45 @@ var solanaWeb3 = (function (exports) {
|
|
|
18836
18883
|
}
|
|
18837
18884
|
|
|
18838
18885
|
assert$1(decodedSignature.length === 64, 'signature has invalid length');
|
|
18839
|
-
|
|
18840
|
-
|
|
18886
|
+
|
|
18887
|
+
if (typeof strategy === 'string') {
|
|
18888
|
+
return await this.confirmTransactionUsingLegacyTimeoutStrategy({
|
|
18889
|
+
commitment: commitment || this.commitment,
|
|
18890
|
+
signature: rawSignature
|
|
18891
|
+
});
|
|
18892
|
+
} else if ('lastValidBlockHeight' in strategy) {
|
|
18893
|
+
return await this.confirmTransactionUsingBlockHeightExceedanceStrategy({
|
|
18894
|
+
commitment: commitment || this.commitment,
|
|
18895
|
+
strategy
|
|
18896
|
+
});
|
|
18897
|
+
} else {
|
|
18898
|
+
return await this.confirmTransactionUsingDurableNonceStrategy({
|
|
18899
|
+
commitment: commitment || this.commitment,
|
|
18900
|
+
strategy
|
|
18901
|
+
});
|
|
18902
|
+
}
|
|
18903
|
+
}
|
|
18904
|
+
|
|
18905
|
+
getTransactionConfirmationPromise({
|
|
18906
|
+
commitment,
|
|
18907
|
+
signature
|
|
18908
|
+
}) {
|
|
18841
18909
|
let signatureSubscriptionId;
|
|
18842
18910
|
let disposeSignatureSubscriptionStateChangeObserver;
|
|
18843
18911
|
let done = false;
|
|
18844
18912
|
const confirmationPromise = new Promise((resolve, reject) => {
|
|
18845
18913
|
try {
|
|
18846
|
-
signatureSubscriptionId = this.onSignature(
|
|
18914
|
+
signatureSubscriptionId = this.onSignature(signature, (result, context) => {
|
|
18847
18915
|
signatureSubscriptionId = undefined;
|
|
18848
18916
|
const response = {
|
|
18849
18917
|
context,
|
|
18850
18918
|
value: result
|
|
18851
18919
|
};
|
|
18852
|
-
done = true;
|
|
18853
18920
|
resolve({
|
|
18854
18921
|
__type: exports.TransactionStatus.PROCESSED,
|
|
18855
18922
|
response
|
|
18856
18923
|
});
|
|
18857
|
-
},
|
|
18924
|
+
}, commitment);
|
|
18858
18925
|
const subscriptionSetupPromise = new Promise(resolveSubscriptionSetup => {
|
|
18859
18926
|
if (signatureSubscriptionId == null) {
|
|
18860
18927
|
resolveSubscriptionSetup();
|
|
@@ -18870,7 +18937,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18870
18937
|
(async () => {
|
|
18871
18938
|
await subscriptionSetupPromise;
|
|
18872
18939
|
if (done) return;
|
|
18873
|
-
const response = await this.getSignatureStatus(
|
|
18940
|
+
const response = await this.getSignatureStatus(signature);
|
|
18874
18941
|
if (done) return;
|
|
18875
18942
|
|
|
18876
18943
|
if (response == null) {
|
|
@@ -18889,7 +18956,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
18889
18956
|
if (value !== null && value !== void 0 && value.err) {
|
|
18890
18957
|
reject(value.err);
|
|
18891
18958
|
} else {
|
|
18892
|
-
switch (
|
|
18959
|
+
switch (commitment) {
|
|
18893
18960
|
case 'confirmed':
|
|
18894
18961
|
case 'single':
|
|
18895
18962
|
case 'singleGossip':
|
|
@@ -18931,81 +18998,279 @@ var solanaWeb3 = (function (exports) {
|
|
|
18931
18998
|
reject(err);
|
|
18932
18999
|
}
|
|
18933
19000
|
});
|
|
19001
|
+
|
|
19002
|
+
const abortConfirmation = () => {
|
|
19003
|
+
if (disposeSignatureSubscriptionStateChangeObserver) {
|
|
19004
|
+
disposeSignatureSubscriptionStateChangeObserver();
|
|
19005
|
+
disposeSignatureSubscriptionStateChangeObserver = undefined;
|
|
19006
|
+
}
|
|
19007
|
+
|
|
19008
|
+
if (signatureSubscriptionId) {
|
|
19009
|
+
this.removeSignatureListener(signatureSubscriptionId);
|
|
19010
|
+
signatureSubscriptionId = undefined;
|
|
19011
|
+
}
|
|
19012
|
+
};
|
|
19013
|
+
|
|
19014
|
+
return {
|
|
19015
|
+
abortConfirmation,
|
|
19016
|
+
confirmationPromise
|
|
19017
|
+
};
|
|
19018
|
+
}
|
|
19019
|
+
|
|
19020
|
+
async confirmTransactionUsingBlockHeightExceedanceStrategy({
|
|
19021
|
+
commitment,
|
|
19022
|
+
strategy: {
|
|
19023
|
+
lastValidBlockHeight,
|
|
19024
|
+
signature
|
|
19025
|
+
}
|
|
19026
|
+
}) {
|
|
19027
|
+
let done = false;
|
|
18934
19028
|
const expiryPromise = new Promise(resolve => {
|
|
18935
|
-
|
|
18936
|
-
|
|
18937
|
-
|
|
18938
|
-
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
18942
|
-
|
|
18943
|
-
|
|
18944
|
-
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
19029
|
+
const checkBlockHeight = async () => {
|
|
19030
|
+
try {
|
|
19031
|
+
const blockHeight = await this.getBlockHeight(commitment);
|
|
19032
|
+
return blockHeight;
|
|
19033
|
+
} catch (_e) {
|
|
19034
|
+
return -1;
|
|
19035
|
+
}
|
|
19036
|
+
};
|
|
19037
|
+
|
|
19038
|
+
(async () => {
|
|
19039
|
+
let currentBlockHeight = await checkBlockHeight();
|
|
19040
|
+
if (done) return;
|
|
19041
|
+
|
|
19042
|
+
while (currentBlockHeight <= lastValidBlockHeight) {
|
|
19043
|
+
await sleep(1000);
|
|
19044
|
+
if (done) return;
|
|
19045
|
+
currentBlockHeight = await checkBlockHeight();
|
|
19046
|
+
if (done) return;
|
|
18948
19047
|
}
|
|
18949
19048
|
|
|
18950
|
-
|
|
18951
|
-
__type: exports.TransactionStatus.
|
|
18952
|
-
|
|
18953
|
-
|
|
19049
|
+
resolve({
|
|
19050
|
+
__type: exports.TransactionStatus.BLOCKHEIGHT_EXCEEDED
|
|
19051
|
+
});
|
|
19052
|
+
})();
|
|
19053
|
+
});
|
|
19054
|
+
const {
|
|
19055
|
+
abortConfirmation,
|
|
19056
|
+
confirmationPromise
|
|
19057
|
+
} = this.getTransactionConfirmationPromise({
|
|
19058
|
+
commitment,
|
|
19059
|
+
signature
|
|
19060
|
+
});
|
|
19061
|
+
let result;
|
|
19062
|
+
|
|
19063
|
+
try {
|
|
19064
|
+
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
19065
|
+
|
|
19066
|
+
if (outcome.__type === exports.TransactionStatus.PROCESSED) {
|
|
19067
|
+
result = outcome.response;
|
|
18954
19068
|
} else {
|
|
18955
|
-
|
|
19069
|
+
throw new TransactionExpiredBlockheightExceededError(signature);
|
|
19070
|
+
}
|
|
19071
|
+
} finally {
|
|
19072
|
+
done = true;
|
|
19073
|
+
abortConfirmation();
|
|
19074
|
+
}
|
|
18956
19075
|
|
|
18957
|
-
|
|
18958
|
-
|
|
18959
|
-
const blockHeight = await this.getBlockHeight(commitment);
|
|
18960
|
-
return blockHeight;
|
|
18961
|
-
} catch (_e) {
|
|
18962
|
-
return -1;
|
|
18963
|
-
}
|
|
18964
|
-
};
|
|
19076
|
+
return result;
|
|
19077
|
+
}
|
|
18965
19078
|
|
|
18966
|
-
|
|
18967
|
-
|
|
18968
|
-
|
|
19079
|
+
async confirmTransactionUsingDurableNonceStrategy({
|
|
19080
|
+
commitment,
|
|
19081
|
+
strategy: {
|
|
19082
|
+
minContextSlot,
|
|
19083
|
+
nonceAccountPubkey,
|
|
19084
|
+
nonceValue,
|
|
19085
|
+
signature
|
|
19086
|
+
}
|
|
19087
|
+
}) {
|
|
19088
|
+
let done = false;
|
|
19089
|
+
const expiryPromise = new Promise(resolve => {
|
|
19090
|
+
let currentNonceValue = nonceValue;
|
|
19091
|
+
let lastCheckedSlot = null;
|
|
18969
19092
|
|
|
18970
|
-
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
19093
|
+
const getCurrentNonceValue = async () => {
|
|
19094
|
+
try {
|
|
19095
|
+
const {
|
|
19096
|
+
context,
|
|
19097
|
+
value: nonceAccount
|
|
19098
|
+
} = await this.getNonceAndContext(nonceAccountPubkey, {
|
|
19099
|
+
commitment,
|
|
19100
|
+
minContextSlot
|
|
19101
|
+
});
|
|
19102
|
+
lastCheckedSlot = context.slot;
|
|
19103
|
+
return nonceAccount === null || nonceAccount === void 0 ? void 0 : nonceAccount.nonce;
|
|
19104
|
+
} catch (e) {
|
|
19105
|
+
// If for whatever reason we can't reach/read the nonce
|
|
19106
|
+
// account, just keep using the last-known value.
|
|
19107
|
+
return currentNonceValue;
|
|
19108
|
+
}
|
|
19109
|
+
};
|
|
19110
|
+
|
|
19111
|
+
(async () => {
|
|
19112
|
+
currentNonceValue = await getCurrentNonceValue();
|
|
19113
|
+
if (done) return;
|
|
19114
|
+
|
|
19115
|
+
while (true // eslint-disable-line no-constant-condition
|
|
19116
|
+
) {
|
|
19117
|
+
if (nonceValue !== currentNonceValue) {
|
|
19118
|
+
resolve({
|
|
19119
|
+
__type: exports.TransactionStatus.NONCE_INVALID,
|
|
19120
|
+
slotInWhichNonceDidAdvance: lastCheckedSlot
|
|
19121
|
+
});
|
|
19122
|
+
return;
|
|
18975
19123
|
}
|
|
18976
19124
|
|
|
18977
|
-
|
|
18978
|
-
|
|
18979
|
-
|
|
18980
|
-
|
|
18981
|
-
|
|
19125
|
+
await sleep(2000);
|
|
19126
|
+
if (done) return;
|
|
19127
|
+
currentNonceValue = await getCurrentNonceValue();
|
|
19128
|
+
if (done) return;
|
|
19129
|
+
}
|
|
19130
|
+
})();
|
|
19131
|
+
});
|
|
19132
|
+
const {
|
|
19133
|
+
abortConfirmation,
|
|
19134
|
+
confirmationPromise
|
|
19135
|
+
} = this.getTransactionConfirmationPromise({
|
|
19136
|
+
commitment,
|
|
19137
|
+
signature
|
|
18982
19138
|
});
|
|
18983
19139
|
let result;
|
|
18984
19140
|
|
|
18985
19141
|
try {
|
|
18986
19142
|
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
18987
19143
|
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
19144
|
+
if (outcome.__type === exports.TransactionStatus.PROCESSED) {
|
|
19145
|
+
result = outcome.response;
|
|
19146
|
+
} else {
|
|
19147
|
+
var _signatureStatus;
|
|
19148
|
+
|
|
19149
|
+
// Double check that the transaction is indeed unconfirmed.
|
|
19150
|
+
let signatureStatus;
|
|
19151
|
+
|
|
19152
|
+
while (true // eslint-disable-line no-constant-condition
|
|
19153
|
+
) {
|
|
19154
|
+
var _outcome$slotInWhichN;
|
|
19155
|
+
|
|
19156
|
+
const status = await this.getSignatureStatus(signature);
|
|
19157
|
+
|
|
19158
|
+
if (status == null) {
|
|
19159
|
+
break;
|
|
19160
|
+
}
|
|
18991
19161
|
|
|
18992
|
-
|
|
18993
|
-
|
|
19162
|
+
if (status.context.slot < ((_outcome$slotInWhichN = outcome.slotInWhichNonceDidAdvance) !== null && _outcome$slotInWhichN !== void 0 ? _outcome$slotInWhichN : minContextSlot)) {
|
|
19163
|
+
await sleep(400);
|
|
19164
|
+
continue;
|
|
19165
|
+
}
|
|
19166
|
+
|
|
19167
|
+
signatureStatus = status;
|
|
18994
19168
|
break;
|
|
19169
|
+
}
|
|
19170
|
+
|
|
19171
|
+
if ((_signatureStatus = signatureStatus) !== null && _signatureStatus !== void 0 && _signatureStatus.value) {
|
|
19172
|
+
const commitmentForStatus = commitment || 'finalized';
|
|
19173
|
+
const {
|
|
19174
|
+
confirmationStatus
|
|
19175
|
+
} = signatureStatus.value;
|
|
19176
|
+
|
|
19177
|
+
switch (commitmentForStatus) {
|
|
19178
|
+
case 'processed':
|
|
19179
|
+
case 'recent':
|
|
19180
|
+
if (confirmationStatus !== 'processed' && confirmationStatus !== 'confirmed' && confirmationStatus !== 'finalized') {
|
|
19181
|
+
throw new TransactionExpiredNonceInvalidError(signature);
|
|
19182
|
+
}
|
|
19183
|
+
|
|
19184
|
+
break;
|
|
19185
|
+
|
|
19186
|
+
case 'confirmed':
|
|
19187
|
+
case 'single':
|
|
19188
|
+
case 'singleGossip':
|
|
19189
|
+
if (confirmationStatus !== 'confirmed' && confirmationStatus !== 'finalized') {
|
|
19190
|
+
throw new TransactionExpiredNonceInvalidError(signature);
|
|
19191
|
+
}
|
|
18995
19192
|
|
|
18996
|
-
|
|
18997
|
-
|
|
19193
|
+
break;
|
|
19194
|
+
|
|
19195
|
+
case 'finalized':
|
|
19196
|
+
case 'max':
|
|
19197
|
+
case 'root':
|
|
19198
|
+
if (confirmationStatus !== 'finalized') {
|
|
19199
|
+
throw new TransactionExpiredNonceInvalidError(signature);
|
|
19200
|
+
}
|
|
19201
|
+
|
|
19202
|
+
break;
|
|
19203
|
+
|
|
19204
|
+
default:
|
|
19205
|
+
// Exhaustive switch.
|
|
19206
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19207
|
+
(_ => {})(commitmentForStatus);
|
|
19208
|
+
|
|
19209
|
+
}
|
|
19210
|
+
|
|
19211
|
+
result = {
|
|
19212
|
+
context: signatureStatus.context,
|
|
19213
|
+
value: {
|
|
19214
|
+
err: signatureStatus.value.err
|
|
19215
|
+
}
|
|
19216
|
+
};
|
|
19217
|
+
} else {
|
|
19218
|
+
throw new TransactionExpiredNonceInvalidError(signature);
|
|
19219
|
+
}
|
|
18998
19220
|
}
|
|
18999
19221
|
} finally {
|
|
19000
|
-
|
|
19222
|
+
done = true;
|
|
19223
|
+
abortConfirmation();
|
|
19224
|
+
}
|
|
19001
19225
|
|
|
19002
|
-
|
|
19003
|
-
|
|
19226
|
+
return result;
|
|
19227
|
+
}
|
|
19228
|
+
|
|
19229
|
+
async confirmTransactionUsingLegacyTimeoutStrategy({
|
|
19230
|
+
commitment,
|
|
19231
|
+
signature
|
|
19232
|
+
}) {
|
|
19233
|
+
let timeoutId;
|
|
19234
|
+
const expiryPromise = new Promise(resolve => {
|
|
19235
|
+
let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;
|
|
19236
|
+
|
|
19237
|
+
switch (commitment) {
|
|
19238
|
+
case 'processed':
|
|
19239
|
+
case 'recent':
|
|
19240
|
+
case 'single':
|
|
19241
|
+
case 'confirmed':
|
|
19242
|
+
case 'singleGossip':
|
|
19243
|
+
{
|
|
19244
|
+
timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;
|
|
19245
|
+
break;
|
|
19246
|
+
}
|
|
19004
19247
|
}
|
|
19005
19248
|
|
|
19006
|
-
|
|
19007
|
-
|
|
19249
|
+
timeoutId = setTimeout(() => resolve({
|
|
19250
|
+
__type: exports.TransactionStatus.TIMED_OUT,
|
|
19251
|
+
timeoutMs
|
|
19252
|
+
}), timeoutMs);
|
|
19253
|
+
});
|
|
19254
|
+
const {
|
|
19255
|
+
abortConfirmation,
|
|
19256
|
+
confirmationPromise
|
|
19257
|
+
} = this.getTransactionConfirmationPromise({
|
|
19258
|
+
commitment,
|
|
19259
|
+
signature
|
|
19260
|
+
});
|
|
19261
|
+
let result;
|
|
19262
|
+
|
|
19263
|
+
try {
|
|
19264
|
+
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
19265
|
+
|
|
19266
|
+
if (outcome.__type === exports.TransactionStatus.PROCESSED) {
|
|
19267
|
+
result = outcome.response;
|
|
19268
|
+
} else {
|
|
19269
|
+
throw new TransactionExpiredTimeoutError(signature, outcome.timeoutMs / 1000);
|
|
19008
19270
|
}
|
|
19271
|
+
} finally {
|
|
19272
|
+
clearTimeout(timeoutId);
|
|
19273
|
+
abortConfirmation();
|
|
19009
19274
|
}
|
|
19010
19275
|
|
|
19011
19276
|
return result;
|
|
@@ -20061,11 +20326,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
20061
20326
|
*/
|
|
20062
20327
|
|
|
20063
20328
|
|
|
20064
|
-
async getNonceAndContext(nonceAccount,
|
|
20329
|
+
async getNonceAndContext(nonceAccount, commitmentOrConfig) {
|
|
20065
20330
|
const {
|
|
20066
20331
|
context,
|
|
20067
20332
|
value: accountInfo
|
|
20068
|
-
} = await this.getAccountInfoAndContext(nonceAccount,
|
|
20333
|
+
} = await this.getAccountInfoAndContext(nonceAccount, commitmentOrConfig);
|
|
20069
20334
|
let value = null;
|
|
20070
20335
|
|
|
20071
20336
|
if (accountInfo !== null) {
|
|
@@ -20082,8 +20347,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
20082
20347
|
*/
|
|
20083
20348
|
|
|
20084
20349
|
|
|
20085
|
-
async getNonce(nonceAccount,
|
|
20086
|
-
return await this.getNonceAndContext(nonceAccount,
|
|
20350
|
+
async getNonce(nonceAccount, commitmentOrConfig) {
|
|
20351
|
+
return await this.getNonceAndContext(nonceAccount, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
20087
20352
|
throw new Error('failed to get nonce for account ' + nonceAccount.toBase58() + ': ' + e);
|
|
20088
20353
|
});
|
|
20089
20354
|
}
|
|
@@ -24716,6 +24981,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
24716
24981
|
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
24717
24982
|
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
24718
24983
|
options = maybeConfirmOptions;
|
|
24984
|
+
} else if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'nonceValue')) {
|
|
24985
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
24986
|
+
options = maybeConfirmOptions;
|
|
24719
24987
|
} else {
|
|
24720
24988
|
options = confirmationStrategyOrConfirmOptions;
|
|
24721
24989
|
}
|
|
@@ -24800,6 +25068,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
24800
25068
|
exports.SystemProgram = SystemProgram;
|
|
24801
25069
|
exports.Transaction = Transaction;
|
|
24802
25070
|
exports.TransactionExpiredBlockheightExceededError = TransactionExpiredBlockheightExceededError;
|
|
25071
|
+
exports.TransactionExpiredNonceInvalidError = TransactionExpiredNonceInvalidError;
|
|
24803
25072
|
exports.TransactionExpiredTimeoutError = TransactionExpiredTimeoutError;
|
|
24804
25073
|
exports.TransactionInstruction = TransactionInstruction;
|
|
24805
25074
|
exports.TransactionMessage = TransactionMessage;
|