@solana/web3.js 1.90.0 → 1.91.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.
@@ -7701,7 +7701,7 @@ class Connection {
7701
7701
  /**
7702
7702
  * Deregister an account notification callback
7703
7703
  *
7704
- * @param id client subscription id to deregister
7704
+ * @param clientSubscriptionId client subscription id to deregister
7705
7705
  */
7706
7706
  async removeAccountChangeListener(clientSubscriptionId) {
7707
7707
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');
@@ -7747,7 +7747,7 @@ class Connection {
7747
7747
  /**
7748
7748
  * Deregister an account notification callback
7749
7749
  *
7750
- * @param id client subscription id to deregister
7750
+ * @param clientSubscriptionId client subscription id to deregister
7751
7751
  */
7752
7752
  async removeProgramAccountChangeListener(clientSubscriptionId) {
7753
7753
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');
@@ -7771,7 +7771,7 @@ class Connection {
7771
7771
  /**
7772
7772
  * Deregister a logs callback.
7773
7773
  *
7774
- * @param id client subscription id to deregister.
7774
+ * @param clientSubscriptionId client subscription id to deregister.
7775
7775
  */
7776
7776
  async removeOnLogsListener(clientSubscriptionId) {
7777
7777
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');
@@ -7816,7 +7816,7 @@ class Connection {
7816
7816
  /**
7817
7817
  * Deregister a slot notification callback
7818
7818
  *
7819
- * @param id client subscription id to deregister
7819
+ * @param clientSubscriptionId client subscription id to deregister
7820
7820
  */
7821
7821
  async removeSlotChangeListener(clientSubscriptionId) {
7822
7822
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');
@@ -7851,7 +7851,7 @@ class Connection {
7851
7851
  /**
7852
7852
  * Deregister a slot update notification callback
7853
7853
  *
7854
- * @param id client subscription id to deregister
7854
+ * @param clientSubscriptionId client subscription id to deregister
7855
7855
  */
7856
7856
  async removeSlotUpdateListener(clientSubscriptionId) {
7857
7857
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');
@@ -8001,7 +8001,7 @@ class Connection {
8001
8001
  /**
8002
8002
  * Deregister a signature notification callback
8003
8003
  *
8004
- * @param id client subscription id to deregister
8004
+ * @param clientSubscriptionId client subscription id to deregister
8005
8005
  */
8006
8006
  async removeSignatureListener(clientSubscriptionId) {
8007
8007
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');
@@ -8035,7 +8035,7 @@ class Connection {
8035
8035
  /**
8036
8036
  * Deregister a root notification callback
8037
8037
  *
8038
- * @param id client subscription id to deregister
8038
+ * @param clientSubscriptionId client subscription id to deregister
8039
8039
  */
8040
8040
  async removeRootChangeListener(clientSubscriptionId) {
8041
8041
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');
@@ -9436,12 +9436,14 @@ class StakeProgram {
9436
9436
  /**
9437
9437
  * Generate a Transaction that splits Stake tokens into another stake account
9438
9438
  */
9439
- static split(params) {
9439
+ static split(params,
9440
+ // Compute the cost of allocating the new stake account in lamports
9441
+ rentExemptReserve) {
9440
9442
  const transaction = new Transaction();
9441
9443
  transaction.add(SystemProgram.createAccount({
9442
9444
  fromPubkey: params.authorizedPubkey,
9443
9445
  newAccountPubkey: params.splitStakePubkey,
9444
- lamports: 0,
9446
+ lamports: rentExemptReserve,
9445
9447
  space: this.space,
9446
9448
  programId: this.programId
9447
9449
  }));
@@ -9452,7 +9454,9 @@ class StakeProgram {
9452
9454
  * Generate a Transaction that splits Stake tokens into another account
9453
9455
  * derived from a base public key and seed
9454
9456
  */
9455
- static splitWithSeed(params) {
9457
+ static splitWithSeed(params,
9458
+ // If this stake account is new, compute the cost of allocating it in lamports
9459
+ rentExemptReserve) {
9456
9460
  const {
9457
9461
  stakePubkey,
9458
9462
  authorizedPubkey,
@@ -9469,6 +9473,13 @@ class StakeProgram {
9469
9473
  space: this.space,
9470
9474
  programId: this.programId
9471
9475
  }));
9476
+ if (rentExemptReserve && rentExemptReserve > 0) {
9477
+ transaction.add(SystemProgram.transfer({
9478
+ fromPubkey: params.authorizedPubkey,
9479
+ toPubkey: splitStakePubkey,
9480
+ lamports: rentExemptReserve
9481
+ }));
9482
+ }
9472
9483
  return transaction.add(this.splitInstruction({
9473
9484
  stakePubkey,
9474
9485
  authorizedPubkey,
@@ -9599,8 +9610,8 @@ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111
9599
9610
  * Max space of a Stake account
9600
9611
  *
9601
9612
  * This is generated from the solana-stake-program StakeState struct as
9602
- * `StakeState::size_of()`:
9603
- * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeState.html
9613
+ * `StakeStateV2::size_of()`:
9614
+ * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
9604
9615
  */
9605
9616
  StakeProgram.space = 200;
9606
9617
 
@@ -9642,6 +9653,10 @@ class VoteInit {
9642
9653
  * Withdraw from vote account transaction params
9643
9654
  */
9644
9655
 
9656
+ /**
9657
+ * Update validator identity (node pubkey) vote account instruction params.
9658
+ */
9659
+
9645
9660
  /**
9646
9661
  * Vote Instruction class
9647
9662
  */
@@ -9788,6 +9803,10 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
9788
9803
  index: 3,
9789
9804
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
9790
9805
  },
9806
+ UpdateValidatorIdentity: {
9807
+ index: 4,
9808
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
9809
+ },
9791
9810
  AuthorizeWithSeed: {
9792
9811
  index: 10,
9793
9812
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), voteAuthorizeWithSeedArgs()])
@@ -10005,10 +10024,41 @@ class VoteProgram {
10005
10024
  */
10006
10025
  static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {
10007
10026
  if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
10008
- throw new Error('Withdraw will leave vote account with insuffcient funds.');
10027
+ throw new Error('Withdraw will leave vote account with insufficient funds.');
10009
10028
  }
10010
10029
  return VoteProgram.withdraw(params);
10011
10030
  }
10031
+
10032
+ /**
10033
+ * Generate a transaction to update the validator identity (node pubkey) of a Vote account.
10034
+ */
10035
+ static updateValidatorIdentity(params) {
10036
+ const {
10037
+ votePubkey,
10038
+ authorizedWithdrawerPubkey,
10039
+ nodePubkey
10040
+ } = params;
10041
+ const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
10042
+ const data = encodeData(type);
10043
+ const keys = [{
10044
+ pubkey: votePubkey,
10045
+ isSigner: false,
10046
+ isWritable: true
10047
+ }, {
10048
+ pubkey: nodePubkey,
10049
+ isSigner: true,
10050
+ isWritable: false
10051
+ }, {
10052
+ pubkey: authorizedWithdrawerPubkey,
10053
+ isSigner: true,
10054
+ isWritable: false
10055
+ }];
10056
+ return new Transaction().add({
10057
+ keys,
10058
+ programId: this.programId,
10059
+ data
10060
+ });
10061
+ }
10012
10062
  }
10013
10063
  VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
10014
10064
  /**
@@ -10020,7 +10070,7 @@ VoteProgram.programId = new PublicKey('Vote1111111111111111111111111111111111111
10020
10070
  *
10021
10071
  * KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342
10022
10072
  */
10023
- VoteProgram.space = 3731;
10073
+ VoteProgram.space = 3762;
10024
10074
 
10025
10075
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
10026
10076