@solana/web3.js 1.45.0 → 1.46.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 +157 -73
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +157 -73
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +157 -73
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +142 -18
- package/lib/index.esm.js +157 -73
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +157 -73
- 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/package.json +1 -1
- package/src/connection.ts +269 -73
- package/src/util/send-and-confirm-raw-transaction.ts +1 -0
- package/src/util/send-and-confirm-transaction.ts +1 -0
package/lib/index.iife.js
CHANGED
|
@@ -14764,7 +14764,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
14764
14764
|
const sendOptions = options && {
|
|
14765
14765
|
skipPreflight: options.skipPreflight,
|
|
14766
14766
|
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
14767
|
-
maxRetries: options.maxRetries
|
|
14767
|
+
maxRetries: options.maxRetries,
|
|
14768
|
+
minContextSlot: options.minContextSlot
|
|
14768
14769
|
};
|
|
14769
14770
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
14770
14771
|
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
@@ -19441,9 +19442,32 @@ var solanaWeb3 = (function (exports) {
|
|
|
19441
19442
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
19442
19443
|
*/
|
|
19443
19444
|
|
|
19445
|
+
/** @internal */
|
|
19446
|
+
function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
19447
|
+
let commitment;
|
|
19448
|
+
let config;
|
|
19449
|
+
|
|
19450
|
+
if (typeof commitmentOrConfig === 'string') {
|
|
19451
|
+
commitment = commitmentOrConfig;
|
|
19452
|
+
} else if (commitmentOrConfig) {
|
|
19453
|
+
const {
|
|
19454
|
+
commitment: specifiedCommitment,
|
|
19455
|
+
...specifiedConfig
|
|
19456
|
+
} = commitmentOrConfig;
|
|
19457
|
+
commitment = specifiedCommitment;
|
|
19458
|
+
config = specifiedConfig;
|
|
19459
|
+
}
|
|
19460
|
+
|
|
19461
|
+
return {
|
|
19462
|
+
commitment,
|
|
19463
|
+
config
|
|
19464
|
+
};
|
|
19465
|
+
}
|
|
19444
19466
|
/**
|
|
19445
19467
|
* @internal
|
|
19446
19468
|
*/
|
|
19469
|
+
|
|
19470
|
+
|
|
19447
19471
|
function createRpcResult(result) {
|
|
19448
19472
|
return union([type({
|
|
19449
19473
|
jsonrpc: literal('2.0'),
|
|
@@ -20480,8 +20504,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
20480
20504
|
*/
|
|
20481
20505
|
|
|
20482
20506
|
|
|
20483
|
-
async getBalanceAndContext(publicKey,
|
|
20484
|
-
|
|
20507
|
+
async getBalanceAndContext(publicKey, commitmentOrConfig) {
|
|
20508
|
+
/** @internal */
|
|
20509
|
+
const {
|
|
20510
|
+
commitment,
|
|
20511
|
+
config
|
|
20512
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
20513
|
+
|
|
20514
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
20515
|
+
/* encoding */
|
|
20516
|
+
, config);
|
|
20485
20517
|
|
|
20486
20518
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
20487
20519
|
const res = create(unsafeRes, jsonRpcResultAndContext(number()));
|
|
@@ -20497,8 +20529,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
20497
20529
|
*/
|
|
20498
20530
|
|
|
20499
20531
|
|
|
20500
|
-
async getBalance(publicKey,
|
|
20501
|
-
return await this.getBalanceAndContext(publicKey,
|
|
20532
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
20533
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
20502
20534
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
20503
20535
|
});
|
|
20504
20536
|
}
|
|
@@ -20620,7 +20652,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
20620
20652
|
*/
|
|
20621
20653
|
|
|
20622
20654
|
|
|
20623
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
20655
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
20656
|
+
const {
|
|
20657
|
+
commitment,
|
|
20658
|
+
config
|
|
20659
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
20624
20660
|
let _args = [ownerAddress.toBase58()];
|
|
20625
20661
|
|
|
20626
20662
|
if ('mint' in filter) {
|
|
@@ -20633,7 +20669,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
20633
20669
|
});
|
|
20634
20670
|
}
|
|
20635
20671
|
|
|
20636
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
20672
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
20637
20673
|
|
|
20638
20674
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
20639
20675
|
const res = create(unsafeRes, GetTokenAccountsByOwner);
|
|
@@ -20717,8 +20753,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
20717
20753
|
*/
|
|
20718
20754
|
|
|
20719
20755
|
|
|
20720
|
-
async getAccountInfoAndContext(publicKey,
|
|
20721
|
-
const
|
|
20756
|
+
async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
|
|
20757
|
+
const {
|
|
20758
|
+
commitment,
|
|
20759
|
+
config
|
|
20760
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
20761
|
+
|
|
20762
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
|
|
20722
20763
|
|
|
20723
20764
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
20724
20765
|
const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));
|
|
@@ -20751,9 +20792,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
20751
20792
|
*/
|
|
20752
20793
|
|
|
20753
20794
|
|
|
20754
|
-
async getAccountInfo(publicKey,
|
|
20795
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
20755
20796
|
try {
|
|
20756
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
20797
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
20757
20798
|
return res.value;
|
|
20758
20799
|
} catch (e) {
|
|
20759
20800
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -20764,10 +20805,14 @@ var solanaWeb3 = (function (exports) {
|
|
|
20764
20805
|
*/
|
|
20765
20806
|
|
|
20766
20807
|
|
|
20767
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
20808
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
20809
|
+
const {
|
|
20810
|
+
commitment,
|
|
20811
|
+
config
|
|
20812
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
20768
20813
|
const keys = publicKeys.map(key => key.toBase58());
|
|
20769
20814
|
|
|
20770
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
20815
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
20771
20816
|
|
|
20772
20817
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
20773
20818
|
const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
|
|
@@ -20783,8 +20828,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
20783
20828
|
*/
|
|
20784
20829
|
|
|
20785
20830
|
|
|
20786
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
20787
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
20831
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
20832
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
20788
20833
|
return res.value;
|
|
20789
20834
|
}
|
|
20790
20835
|
/**
|
|
@@ -20792,10 +20837,17 @@ var solanaWeb3 = (function (exports) {
|
|
|
20792
20837
|
*/
|
|
20793
20838
|
|
|
20794
20839
|
|
|
20795
|
-
async getStakeActivation(publicKey,
|
|
20796
|
-
const
|
|
20797
|
-
|
|
20798
|
-
|
|
20840
|
+
async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
|
|
20841
|
+
const {
|
|
20842
|
+
commitment,
|
|
20843
|
+
config
|
|
20844
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
20845
|
+
|
|
20846
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
20847
|
+
/* encoding */
|
|
20848
|
+
, { ...config,
|
|
20849
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
20850
|
+
});
|
|
20799
20851
|
|
|
20800
20852
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
20801
20853
|
const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
@@ -20814,28 +20866,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
20814
20866
|
|
|
20815
20867
|
|
|
20816
20868
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
20817
|
-
const
|
|
20818
|
-
|
|
20819
|
-
|
|
20820
|
-
|
|
20821
|
-
|
|
20822
|
-
|
|
20823
|
-
|
|
20824
|
-
|
|
20825
|
-
commitment = configOrCommitment.commitment;
|
|
20826
|
-
encoding = configOrCommitment.encoding;
|
|
20827
|
-
|
|
20828
|
-
if (configOrCommitment.dataSlice) {
|
|
20829
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
20830
|
-
}
|
|
20831
|
-
|
|
20832
|
-
if (configOrCommitment.filters) {
|
|
20833
|
-
extra.filters = configOrCommitment.filters;
|
|
20834
|
-
}
|
|
20835
|
-
}
|
|
20836
|
-
}
|
|
20869
|
+
const {
|
|
20870
|
+
commitment,
|
|
20871
|
+
config
|
|
20872
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
20873
|
+
const {
|
|
20874
|
+
encoding,
|
|
20875
|
+
...configWithoutEncoding
|
|
20876
|
+
} = config || {};
|
|
20837
20877
|
|
|
20838
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
20878
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
20839
20879
|
|
|
20840
20880
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
20841
20881
|
const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
|
|
@@ -20854,22 +20894,12 @@ var solanaWeb3 = (function (exports) {
|
|
|
20854
20894
|
|
|
20855
20895
|
|
|
20856
20896
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
20857
|
-
const
|
|
20858
|
-
|
|
20859
|
-
|
|
20860
|
-
|
|
20861
|
-
if (typeof configOrCommitment === 'string') {
|
|
20862
|
-
commitment = configOrCommitment;
|
|
20863
|
-
} else {
|
|
20864
|
-
commitment = configOrCommitment.commitment;
|
|
20865
|
-
|
|
20866
|
-
if (configOrCommitment.filters) {
|
|
20867
|
-
extra.filters = configOrCommitment.filters;
|
|
20868
|
-
}
|
|
20869
|
-
}
|
|
20870
|
-
}
|
|
20897
|
+
const {
|
|
20898
|
+
commitment,
|
|
20899
|
+
config
|
|
20900
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
20871
20901
|
|
|
20872
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
20902
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
20873
20903
|
|
|
20874
20904
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
20875
20905
|
const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));
|
|
@@ -21036,8 +21066,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21036
21066
|
*/
|
|
21037
21067
|
|
|
21038
21068
|
|
|
21039
|
-
async getSlot(
|
|
21040
|
-
const
|
|
21069
|
+
async getSlot(commitmentOrConfig) {
|
|
21070
|
+
const {
|
|
21071
|
+
commitment,
|
|
21072
|
+
config
|
|
21073
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21074
|
+
|
|
21075
|
+
const args = this._buildArgs([], commitment, undefined
|
|
21076
|
+
/* encoding */
|
|
21077
|
+
, config);
|
|
21041
21078
|
|
|
21042
21079
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
21043
21080
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -21053,8 +21090,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21053
21090
|
*/
|
|
21054
21091
|
|
|
21055
21092
|
|
|
21056
|
-
async getSlotLeader(
|
|
21057
|
-
const
|
|
21093
|
+
async getSlotLeader(commitmentOrConfig) {
|
|
21094
|
+
const {
|
|
21095
|
+
commitment,
|
|
21096
|
+
config
|
|
21097
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21098
|
+
|
|
21099
|
+
const args = this._buildArgs([], commitment, undefined
|
|
21100
|
+
/* encoding */
|
|
21101
|
+
, config);
|
|
21058
21102
|
|
|
21059
21103
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
21060
21104
|
const res = create(unsafeRes, jsonRpcResult(string()));
|
|
@@ -21127,8 +21171,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21127
21171
|
*/
|
|
21128
21172
|
|
|
21129
21173
|
|
|
21130
|
-
async getTransactionCount(
|
|
21131
|
-
const
|
|
21174
|
+
async getTransactionCount(commitmentOrConfig) {
|
|
21175
|
+
const {
|
|
21176
|
+
commitment,
|
|
21177
|
+
config
|
|
21178
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21179
|
+
|
|
21180
|
+
const args = this._buildArgs([], commitment, undefined
|
|
21181
|
+
/* encoding */
|
|
21182
|
+
, config);
|
|
21132
21183
|
|
|
21133
21184
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
21134
21185
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -21175,9 +21226,16 @@ var solanaWeb3 = (function (exports) {
|
|
|
21175
21226
|
*/
|
|
21176
21227
|
|
|
21177
21228
|
|
|
21178
|
-
async getInflationReward(addresses, epoch,
|
|
21179
|
-
const
|
|
21180
|
-
|
|
21229
|
+
async getInflationReward(addresses, epoch, commitmentOrConfig) {
|
|
21230
|
+
const {
|
|
21231
|
+
commitment,
|
|
21232
|
+
config
|
|
21233
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21234
|
+
|
|
21235
|
+
const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
|
|
21236
|
+
/* encoding */
|
|
21237
|
+
, { ...config,
|
|
21238
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
21181
21239
|
});
|
|
21182
21240
|
|
|
21183
21241
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
@@ -21194,8 +21252,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21194
21252
|
*/
|
|
21195
21253
|
|
|
21196
21254
|
|
|
21197
|
-
async getEpochInfo(
|
|
21198
|
-
const
|
|
21255
|
+
async getEpochInfo(commitmentOrConfig) {
|
|
21256
|
+
const {
|
|
21257
|
+
commitment,
|
|
21258
|
+
config
|
|
21259
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21260
|
+
|
|
21261
|
+
const args = this._buildArgs([], commitment, undefined
|
|
21262
|
+
/* encoding */
|
|
21263
|
+
, config);
|
|
21199
21264
|
|
|
21200
21265
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
21201
21266
|
const res = create(unsafeRes, GetEpochInfoRpcResult);
|
|
@@ -21366,9 +21431,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
21366
21431
|
*/
|
|
21367
21432
|
|
|
21368
21433
|
|
|
21369
|
-
async getLatestBlockhash(
|
|
21434
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
21370
21435
|
try {
|
|
21371
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
21436
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
21372
21437
|
return res.value;
|
|
21373
21438
|
} catch (e) {
|
|
21374
21439
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -21380,8 +21445,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21380
21445
|
*/
|
|
21381
21446
|
|
|
21382
21447
|
|
|
21383
|
-
async getLatestBlockhashAndContext(
|
|
21384
|
-
const
|
|
21448
|
+
async getLatestBlockhashAndContext(commitmentOrConfig) {
|
|
21449
|
+
const {
|
|
21450
|
+
commitment,
|
|
21451
|
+
config
|
|
21452
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21453
|
+
|
|
21454
|
+
const args = this._buildArgs([], commitment, undefined
|
|
21455
|
+
/* encoding */
|
|
21456
|
+
, config);
|
|
21385
21457
|
|
|
21386
21458
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
21387
21459
|
const res = create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
@@ -21459,8 +21531,15 @@ var solanaWeb3 = (function (exports) {
|
|
|
21459
21531
|
*/
|
|
21460
21532
|
|
|
21461
21533
|
|
|
21462
|
-
async getBlockHeight(
|
|
21463
|
-
const
|
|
21534
|
+
async getBlockHeight(commitmentOrConfig) {
|
|
21535
|
+
const {
|
|
21536
|
+
commitment,
|
|
21537
|
+
config
|
|
21538
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
21539
|
+
|
|
21540
|
+
const args = this._buildArgs([], commitment, undefined
|
|
21541
|
+
/* encoding */
|
|
21542
|
+
, config);
|
|
21464
21543
|
|
|
21465
21544
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
21466
21545
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -22189,6 +22268,10 @@ var solanaWeb3 = (function (exports) {
|
|
|
22189
22268
|
config.maxRetries = options.maxRetries;
|
|
22190
22269
|
}
|
|
22191
22270
|
|
|
22271
|
+
if (options && options.minContextSlot != null) {
|
|
22272
|
+
config.minContextSlot = options.minContextSlot;
|
|
22273
|
+
}
|
|
22274
|
+
|
|
22192
22275
|
if (skipPreflight) {
|
|
22193
22276
|
config.skipPreflight = skipPreflight;
|
|
22194
22277
|
}
|
|
@@ -30191,7 +30274,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
30191
30274
|
|
|
30192
30275
|
const sendOptions = options && {
|
|
30193
30276
|
skipPreflight: options.skipPreflight,
|
|
30194
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
30277
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
30278
|
+
minContextSlot: options.minContextSlot
|
|
30195
30279
|
};
|
|
30196
30280
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
30197
30281
|
const commitment = options && options.commitment;
|