@solana/web3.js 1.45.1 → 1.46.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.iife.js CHANGED
@@ -14793,7 +14793,8 @@ var solanaWeb3 = (function (exports) {
14793
14793
  const sendOptions = options && {
14794
14794
  skipPreflight: options.skipPreflight,
14795
14795
  preflightCommitment: options.preflightCommitment || options.commitment,
14796
- maxRetries: options.maxRetries
14796
+ maxRetries: options.maxRetries,
14797
+ minContextSlot: options.minContextSlot
14797
14798
  };
14798
14799
  const signature = await connection.sendTransaction(transaction, signers, sendOptions);
14799
14800
  const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
@@ -19470,9 +19471,32 @@ var solanaWeb3 = (function (exports) {
19470
19471
  * https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
19471
19472
  */
19472
19473
 
19474
+ /** @internal */
19475
+ function extractCommitmentFromConfig(commitmentOrConfig) {
19476
+ let commitment;
19477
+ let config;
19478
+
19479
+ if (typeof commitmentOrConfig === 'string') {
19480
+ commitment = commitmentOrConfig;
19481
+ } else if (commitmentOrConfig) {
19482
+ const {
19483
+ commitment: specifiedCommitment,
19484
+ ...specifiedConfig
19485
+ } = commitmentOrConfig;
19486
+ commitment = specifiedCommitment;
19487
+ config = specifiedConfig;
19488
+ }
19489
+
19490
+ return {
19491
+ commitment,
19492
+ config
19493
+ };
19494
+ }
19473
19495
  /**
19474
19496
  * @internal
19475
19497
  */
19498
+
19499
+
19476
19500
  function createRpcResult(result) {
19477
19501
  return union([type({
19478
19502
  jsonrpc: literal('2.0'),
@@ -20339,7 +20363,7 @@ var solanaWeb3 = (function (exports) {
20339
20363
 
20340
20364
  /** @internal */
20341
20365
  const COMMON_HTTP_HEADERS = {
20342
- 'solana-client': `js/${(_process$env$npm_pack = "1.45.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
20366
+ 'solana-client': `js/${(_process$env$npm_pack = "1.46.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
20343
20367
  };
20344
20368
  /**
20345
20369
  * A connection to a fullnode JSON RPC endpoint
@@ -20509,8 +20533,16 @@ var solanaWeb3 = (function (exports) {
20509
20533
  */
20510
20534
 
20511
20535
 
20512
- async getBalanceAndContext(publicKey, commitment) {
20513
- const args = this._buildArgs([publicKey.toBase58()], commitment);
20536
+ async getBalanceAndContext(publicKey, commitmentOrConfig) {
20537
+ /** @internal */
20538
+ const {
20539
+ commitment,
20540
+ config
20541
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20542
+
20543
+ const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
20544
+ /* encoding */
20545
+ , config);
20514
20546
 
20515
20547
  const unsafeRes = await this._rpcRequest('getBalance', args);
20516
20548
  const res = create(unsafeRes, jsonRpcResultAndContext(number()));
@@ -20526,8 +20558,8 @@ var solanaWeb3 = (function (exports) {
20526
20558
  */
20527
20559
 
20528
20560
 
20529
- async getBalance(publicKey, commitment) {
20530
- return await this.getBalanceAndContext(publicKey, commitment).then(x => x.value).catch(e => {
20561
+ async getBalance(publicKey, commitmentOrConfig) {
20562
+ return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
20531
20563
  throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
20532
20564
  });
20533
20565
  }
@@ -20649,7 +20681,11 @@ var solanaWeb3 = (function (exports) {
20649
20681
  */
20650
20682
 
20651
20683
 
20652
- async getTokenAccountsByOwner(ownerAddress, filter, commitment) {
20684
+ async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
20685
+ const {
20686
+ commitment,
20687
+ config
20688
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20653
20689
  let _args = [ownerAddress.toBase58()];
20654
20690
 
20655
20691
  if ('mint' in filter) {
@@ -20662,7 +20698,7 @@ var solanaWeb3 = (function (exports) {
20662
20698
  });
20663
20699
  }
20664
20700
 
20665
- const args = this._buildArgs(_args, commitment, 'base64');
20701
+ const args = this._buildArgs(_args, commitment, 'base64', config);
20666
20702
 
20667
20703
  const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
20668
20704
  const res = create(unsafeRes, GetTokenAccountsByOwner);
@@ -20746,8 +20782,13 @@ var solanaWeb3 = (function (exports) {
20746
20782
  */
20747
20783
 
20748
20784
 
20749
- async getAccountInfoAndContext(publicKey, commitment) {
20750
- const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64');
20785
+ async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
20786
+ const {
20787
+ commitment,
20788
+ config
20789
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20790
+
20791
+ const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
20751
20792
 
20752
20793
  const unsafeRes = await this._rpcRequest('getAccountInfo', args);
20753
20794
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));
@@ -20780,9 +20821,9 @@ var solanaWeb3 = (function (exports) {
20780
20821
  */
20781
20822
 
20782
20823
 
20783
- async getAccountInfo(publicKey, commitment) {
20824
+ async getAccountInfo(publicKey, commitmentOrConfig) {
20784
20825
  try {
20785
- const res = await this.getAccountInfoAndContext(publicKey, commitment);
20826
+ const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
20786
20827
  return res.value;
20787
20828
  } catch (e) {
20788
20829
  throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
@@ -20793,10 +20834,14 @@ var solanaWeb3 = (function (exports) {
20793
20834
  */
20794
20835
 
20795
20836
 
20796
- async getMultipleAccountsInfoAndContext(publicKeys, commitment) {
20837
+ async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
20838
+ const {
20839
+ commitment,
20840
+ config
20841
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20797
20842
  const keys = publicKeys.map(key => key.toBase58());
20798
20843
 
20799
- const args = this._buildArgs([keys], commitment, 'base64');
20844
+ const args = this._buildArgs([keys], commitment, 'base64', config);
20800
20845
 
20801
20846
  const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
20802
20847
  const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
@@ -20812,8 +20857,8 @@ var solanaWeb3 = (function (exports) {
20812
20857
  */
20813
20858
 
20814
20859
 
20815
- async getMultipleAccountsInfo(publicKeys, commitment) {
20816
- const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitment);
20860
+ async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
20861
+ const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
20817
20862
  return res.value;
20818
20863
  }
20819
20864
  /**
@@ -20821,10 +20866,17 @@ var solanaWeb3 = (function (exports) {
20821
20866
  */
20822
20867
 
20823
20868
 
20824
- async getStakeActivation(publicKey, commitment, epoch) {
20825
- const args = this._buildArgs([publicKey.toBase58()], commitment, undefined, epoch !== undefined ? {
20826
- epoch
20827
- } : undefined);
20869
+ async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
20870
+ const {
20871
+ commitment,
20872
+ config
20873
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20874
+
20875
+ const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
20876
+ /* encoding */
20877
+ , { ...config,
20878
+ epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
20879
+ });
20828
20880
 
20829
20881
  const unsafeRes = await this._rpcRequest('getStakeActivation', args);
20830
20882
  const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
@@ -20843,28 +20895,16 @@ var solanaWeb3 = (function (exports) {
20843
20895
 
20844
20896
 
20845
20897
  async getProgramAccounts(programId, configOrCommitment) {
20846
- const extra = {};
20847
- let commitment;
20848
- let encoding;
20849
-
20850
- if (configOrCommitment) {
20851
- if (typeof configOrCommitment === 'string') {
20852
- commitment = configOrCommitment;
20853
- } else {
20854
- commitment = configOrCommitment.commitment;
20855
- encoding = configOrCommitment.encoding;
20856
-
20857
- if (configOrCommitment.dataSlice) {
20858
- extra.dataSlice = configOrCommitment.dataSlice;
20859
- }
20860
-
20861
- if (configOrCommitment.filters) {
20862
- extra.filters = configOrCommitment.filters;
20863
- }
20864
- }
20865
- }
20898
+ const {
20899
+ commitment,
20900
+ config
20901
+ } = extractCommitmentFromConfig(configOrCommitment);
20902
+ const {
20903
+ encoding,
20904
+ ...configWithoutEncoding
20905
+ } = config || {};
20866
20906
 
20867
- const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', extra);
20907
+ const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
20868
20908
 
20869
20909
  const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
20870
20910
  const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
@@ -20883,22 +20923,12 @@ var solanaWeb3 = (function (exports) {
20883
20923
 
20884
20924
 
20885
20925
  async getParsedProgramAccounts(programId, configOrCommitment) {
20886
- const extra = {};
20887
- let commitment;
20888
-
20889
- if (configOrCommitment) {
20890
- if (typeof configOrCommitment === 'string') {
20891
- commitment = configOrCommitment;
20892
- } else {
20893
- commitment = configOrCommitment.commitment;
20894
-
20895
- if (configOrCommitment.filters) {
20896
- extra.filters = configOrCommitment.filters;
20897
- }
20898
- }
20899
- }
20926
+ const {
20927
+ commitment,
20928
+ config
20929
+ } = extractCommitmentFromConfig(configOrCommitment);
20900
20930
 
20901
- const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', extra);
20931
+ const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
20902
20932
 
20903
20933
  const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
20904
20934
  const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));
@@ -21065,8 +21095,15 @@ var solanaWeb3 = (function (exports) {
21065
21095
  */
21066
21096
 
21067
21097
 
21068
- async getSlot(commitment) {
21069
- const args = this._buildArgs([], commitment);
21098
+ async getSlot(commitmentOrConfig) {
21099
+ const {
21100
+ commitment,
21101
+ config
21102
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21103
+
21104
+ const args = this._buildArgs([], commitment, undefined
21105
+ /* encoding */
21106
+ , config);
21070
21107
 
21071
21108
  const unsafeRes = await this._rpcRequest('getSlot', args);
21072
21109
  const res = create(unsafeRes, jsonRpcResult(number()));
@@ -21082,8 +21119,15 @@ var solanaWeb3 = (function (exports) {
21082
21119
  */
21083
21120
 
21084
21121
 
21085
- async getSlotLeader(commitment) {
21086
- const args = this._buildArgs([], commitment);
21122
+ async getSlotLeader(commitmentOrConfig) {
21123
+ const {
21124
+ commitment,
21125
+ config
21126
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21127
+
21128
+ const args = this._buildArgs([], commitment, undefined
21129
+ /* encoding */
21130
+ , config);
21087
21131
 
21088
21132
  const unsafeRes = await this._rpcRequest('getSlotLeader', args);
21089
21133
  const res = create(unsafeRes, jsonRpcResult(string()));
@@ -21156,8 +21200,15 @@ var solanaWeb3 = (function (exports) {
21156
21200
  */
21157
21201
 
21158
21202
 
21159
- async getTransactionCount(commitment) {
21160
- const args = this._buildArgs([], commitment);
21203
+ async getTransactionCount(commitmentOrConfig) {
21204
+ const {
21205
+ commitment,
21206
+ config
21207
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21208
+
21209
+ const args = this._buildArgs([], commitment, undefined
21210
+ /* encoding */
21211
+ , config);
21161
21212
 
21162
21213
  const unsafeRes = await this._rpcRequest('getTransactionCount', args);
21163
21214
  const res = create(unsafeRes, jsonRpcResult(number()));
@@ -21204,9 +21255,16 @@ var solanaWeb3 = (function (exports) {
21204
21255
  */
21205
21256
 
21206
21257
 
21207
- async getInflationReward(addresses, epoch, commitment) {
21208
- const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined, {
21209
- epoch
21258
+ async getInflationReward(addresses, epoch, commitmentOrConfig) {
21259
+ const {
21260
+ commitment,
21261
+ config
21262
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21263
+
21264
+ const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
21265
+ /* encoding */
21266
+ , { ...config,
21267
+ epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
21210
21268
  });
21211
21269
 
21212
21270
  const unsafeRes = await this._rpcRequest('getInflationReward', args);
@@ -21223,8 +21281,15 @@ var solanaWeb3 = (function (exports) {
21223
21281
  */
21224
21282
 
21225
21283
 
21226
- async getEpochInfo(commitment) {
21227
- const args = this._buildArgs([], commitment);
21284
+ async getEpochInfo(commitmentOrConfig) {
21285
+ const {
21286
+ commitment,
21287
+ config
21288
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21289
+
21290
+ const args = this._buildArgs([], commitment, undefined
21291
+ /* encoding */
21292
+ , config);
21228
21293
 
21229
21294
  const unsafeRes = await this._rpcRequest('getEpochInfo', args);
21230
21295
  const res = create(unsafeRes, GetEpochInfoRpcResult);
@@ -21395,9 +21460,9 @@ var solanaWeb3 = (function (exports) {
21395
21460
  */
21396
21461
 
21397
21462
 
21398
- async getLatestBlockhash(commitment) {
21463
+ async getLatestBlockhash(commitmentOrConfig) {
21399
21464
  try {
21400
- const res = await this.getLatestBlockhashAndContext(commitment);
21465
+ const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
21401
21466
  return res.value;
21402
21467
  } catch (e) {
21403
21468
  throw new Error('failed to get recent blockhash: ' + e);
@@ -21409,8 +21474,15 @@ var solanaWeb3 = (function (exports) {
21409
21474
  */
21410
21475
 
21411
21476
 
21412
- async getLatestBlockhashAndContext(commitment) {
21413
- const args = this._buildArgs([], commitment);
21477
+ async getLatestBlockhashAndContext(commitmentOrConfig) {
21478
+ const {
21479
+ commitment,
21480
+ config
21481
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21482
+
21483
+ const args = this._buildArgs([], commitment, undefined
21484
+ /* encoding */
21485
+ , config);
21414
21486
 
21415
21487
  const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
21416
21488
  const res = create(unsafeRes, GetLatestBlockhashRpcResult);
@@ -21488,8 +21560,15 @@ var solanaWeb3 = (function (exports) {
21488
21560
  */
21489
21561
 
21490
21562
 
21491
- async getBlockHeight(commitment) {
21492
- const args = this._buildArgs([], commitment);
21563
+ async getBlockHeight(commitmentOrConfig) {
21564
+ const {
21565
+ commitment,
21566
+ config
21567
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21568
+
21569
+ const args = this._buildArgs([], commitment, undefined
21570
+ /* encoding */
21571
+ , config);
21493
21572
 
21494
21573
  const unsafeRes = await this._rpcRequest('getBlockHeight', args);
21495
21574
  const res = create(unsafeRes, jsonRpcResult(number()));
@@ -22218,6 +22297,10 @@ var solanaWeb3 = (function (exports) {
22218
22297
  config.maxRetries = options.maxRetries;
22219
22298
  }
22220
22299
 
22300
+ if (options && options.minContextSlot != null) {
22301
+ config.minContextSlot = options.minContextSlot;
22302
+ }
22303
+
22221
22304
  if (skipPreflight) {
22222
22305
  config.skipPreflight = skipPreflight;
22223
22306
  }
@@ -30218,7 +30301,8 @@ var solanaWeb3 = (function (exports) {
30218
30301
 
30219
30302
  const sendOptions = options && {
30220
30303
  skipPreflight: options.skipPreflight,
30221
- preflightCommitment: options.preflightCommitment || options.commitment
30304
+ preflightCommitment: options.preflightCommitment || options.commitment,
30305
+ minContextSlot: options.minContextSlot
30222
30306
  };
30223
30307
  const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
30224
30308
  const commitment = options && options.commitment;