@solana/web3.js 1.34.0 → 1.36.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.
@@ -4824,13 +4824,13 @@ const VersionResult = type({
4824
4824
  const SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({
4825
4825
  err: nullable(union([type({}), string()])),
4826
4826
  logs: nullable(array(string())),
4827
- accounts: optional(nullable(array(type({
4827
+ accounts: optional(nullable(array(nullable(type({
4828
4828
  executable: boolean(),
4829
4829
  owner: string(),
4830
4830
  lamports: number(),
4831
4831
  data: array(string()),
4832
4832
  rentEpoch: optional(number())
4833
- })))),
4833
+ }))))),
4834
4834
  unitsConsumed: optional(number())
4835
4835
  }));
4836
4836
 
@@ -5973,35 +5973,32 @@ class Connection {
5973
5973
  }
5974
5974
  }
5975
5975
  /**
5976
- * Fetch all the account info for multiple accounts specified by an array of public keys
5976
+ * Fetch all the account info for multiple accounts specified by an array of public keys, return with context
5977
5977
  */
5978
5978
 
5979
5979
 
5980
- async getMultipleAccountsInfo(publicKeys, configOrCommitment) {
5980
+ async getMultipleAccountsInfoAndContext(publicKeys, commitment) {
5981
5981
  const keys = publicKeys.map(key => key.toBase58());
5982
- let commitment;
5983
- let encoding = 'base64';
5984
-
5985
- if (configOrCommitment) {
5986
- if (typeof configOrCommitment === 'string') {
5987
- commitment = configOrCommitment;
5988
- encoding = 'base64';
5989
- } else {
5990
- commitment = configOrCommitment.commitment;
5991
- encoding = configOrCommitment.encoding || 'base64';
5992
- }
5993
- }
5994
5982
 
5995
- const args = this._buildArgs([keys], commitment, encoding);
5983
+ const args = this._buildArgs([keys], commitment, 'base64');
5996
5984
 
5997
5985
  const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
5998
- const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(ParsedAccountInfoResult))));
5986
+ const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
5999
5987
 
6000
5988
  if ('error' in res) {
6001
5989
  throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
6002
5990
  }
6003
5991
 
6004
- return res.result.value;
5992
+ return res.result;
5993
+ }
5994
+ /**
5995
+ * Fetch all the account info for multiple accounts specified by an array of public keys
5996
+ */
5997
+
5998
+
5999
+ async getMultipleAccountsInfo(publicKeys, commitment) {
6000
+ const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitment);
6001
+ return res.value;
6005
6002
  }
6006
6003
  /**
6007
6004
  * Returns epoch activation information for a stake account that has been delegated
@@ -8729,30 +8726,22 @@ class StakeProgram {
8729
8726
  });
8730
8727
  }
8731
8728
  /**
8732
- * Generate a Transaction that splits Stake tokens into another stake account
8729
+ * @internal
8733
8730
  */
8734
8731
 
8735
8732
 
8736
- static split(params) {
8733
+ static splitInstruction(params) {
8737
8734
  const {
8738
8735
  stakePubkey,
8739
8736
  authorizedPubkey,
8740
8737
  splitStakePubkey,
8741
8738
  lamports
8742
8739
  } = params;
8743
- const transaction = new Transaction();
8744
- transaction.add(SystemProgram.createAccount({
8745
- fromPubkey: authorizedPubkey,
8746
- newAccountPubkey: splitStakePubkey,
8747
- lamports: 0,
8748
- space: this.space,
8749
- programId: this.programId
8750
- }));
8751
8740
  const type = STAKE_INSTRUCTION_LAYOUTS.Split;
8752
8741
  const data = encodeData(type, {
8753
8742
  lamports
8754
8743
  });
8755
- return transaction.add({
8744
+ return new TransactionInstruction({
8756
8745
  keys: [{
8757
8746
  pubkey: stakePubkey,
8758
8747
  isSigner: false,
@@ -8770,6 +8759,52 @@ class StakeProgram {
8770
8759
  data
8771
8760
  });
8772
8761
  }
8762
+ /**
8763
+ * Generate a Transaction that splits Stake tokens into another stake account
8764
+ */
8765
+
8766
+
8767
+ static split(params) {
8768
+ const transaction = new Transaction();
8769
+ transaction.add(SystemProgram.createAccount({
8770
+ fromPubkey: params.authorizedPubkey,
8771
+ newAccountPubkey: params.splitStakePubkey,
8772
+ lamports: 0,
8773
+ space: this.space,
8774
+ programId: this.programId
8775
+ }));
8776
+ return transaction.add(this.splitInstruction(params));
8777
+ }
8778
+ /**
8779
+ * Generate a Transaction that splits Stake tokens into another account
8780
+ * derived from a base public key and seed
8781
+ */
8782
+
8783
+
8784
+ static splitWithSeed(params) {
8785
+ const {
8786
+ stakePubkey,
8787
+ authorizedPubkey,
8788
+ splitStakePubkey,
8789
+ basePubkey,
8790
+ seed,
8791
+ lamports
8792
+ } = params;
8793
+ const transaction = new Transaction();
8794
+ transaction.add(SystemProgram.allocate({
8795
+ accountPubkey: splitStakePubkey,
8796
+ basePubkey,
8797
+ seed,
8798
+ space: this.space,
8799
+ programId: this.programId
8800
+ }));
8801
+ return transaction.add(this.splitInstruction({
8802
+ stakePubkey,
8803
+ authorizedPubkey,
8804
+ splitStakePubkey,
8805
+ lamports
8806
+ }));
8807
+ }
8773
8808
  /**
8774
8809
  * Generate a Transaction that merges Stake accounts.
8775
8810
  */