@solana/web3.js 1.90.1 → 1.91.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.cjs.js CHANGED
@@ -858,23 +858,19 @@ class Message {
858
858
  const accountCount = decodeLength(byteArray);
859
859
  let accountKeys = [];
860
860
  for (let i = 0; i < accountCount; i++) {
861
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
862
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
861
+ const account = byteArray.splice(0, PUBLIC_KEY_LENGTH);
863
862
  accountKeys.push(new PublicKey(buffer.Buffer.from(account)));
864
863
  }
865
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
866
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
864
+ const recentBlockhash = byteArray.splice(0, PUBLIC_KEY_LENGTH);
867
865
  const instructionCount = decodeLength(byteArray);
868
866
  let instructions = [];
869
867
  for (let i = 0; i < instructionCount; i++) {
870
868
  const programIdIndex = byteArray.shift();
871
869
  const accountCount = decodeLength(byteArray);
872
- const accounts = byteArray.slice(0, accountCount);
873
- byteArray = byteArray.slice(accountCount);
870
+ const accounts = byteArray.splice(0, accountCount);
874
871
  const dataLength = decodeLength(byteArray);
875
- const dataSlice = byteArray.slice(0, dataLength);
872
+ const dataSlice = byteArray.splice(0, dataLength);
876
873
  const data = bs58__default.default.encode(buffer.Buffer.from(dataSlice));
877
- byteArray = byteArray.slice(dataLength);
878
874
  instructions.push({
879
875
  programIdIndex,
880
876
  accounts,
@@ -1907,8 +1903,7 @@ class Transaction {
1907
1903
  const signatureCount = decodeLength(byteArray);
1908
1904
  let signatures = [];
1909
1905
  for (let i = 0; i < signatureCount; i++) {
1910
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
1911
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
1906
+ const signature = byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES);
1912
1907
  signatures.push(bs58__default.default.encode(buffer.Buffer.from(signature)));
1913
1908
  }
1914
1909
  return Transaction.populate(Message.from(byteArray), signatures);
@@ -8398,7 +8393,7 @@ class Connection {
8398
8393
  /**
8399
8394
  * Deregister an account notification callback
8400
8395
  *
8401
- * @param id client subscription id to deregister
8396
+ * @param clientSubscriptionId client subscription id to deregister
8402
8397
  */
8403
8398
  async removeAccountChangeListener(clientSubscriptionId) {
8404
8399
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');
@@ -8444,7 +8439,7 @@ class Connection {
8444
8439
  /**
8445
8440
  * Deregister an account notification callback
8446
8441
  *
8447
- * @param id client subscription id to deregister
8442
+ * @param clientSubscriptionId client subscription id to deregister
8448
8443
  */
8449
8444
  async removeProgramAccountChangeListener(clientSubscriptionId) {
8450
8445
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');
@@ -8468,7 +8463,7 @@ class Connection {
8468
8463
  /**
8469
8464
  * Deregister a logs callback.
8470
8465
  *
8471
- * @param id client subscription id to deregister.
8466
+ * @param clientSubscriptionId client subscription id to deregister.
8472
8467
  */
8473
8468
  async removeOnLogsListener(clientSubscriptionId) {
8474
8469
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');
@@ -8513,7 +8508,7 @@ class Connection {
8513
8508
  /**
8514
8509
  * Deregister a slot notification callback
8515
8510
  *
8516
- * @param id client subscription id to deregister
8511
+ * @param clientSubscriptionId client subscription id to deregister
8517
8512
  */
8518
8513
  async removeSlotChangeListener(clientSubscriptionId) {
8519
8514
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');
@@ -8548,7 +8543,7 @@ class Connection {
8548
8543
  /**
8549
8544
  * Deregister a slot update notification callback
8550
8545
  *
8551
- * @param id client subscription id to deregister
8546
+ * @param clientSubscriptionId client subscription id to deregister
8552
8547
  */
8553
8548
  async removeSlotUpdateListener(clientSubscriptionId) {
8554
8549
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');
@@ -8698,7 +8693,7 @@ class Connection {
8698
8693
  /**
8699
8694
  * Deregister a signature notification callback
8700
8695
  *
8701
- * @param id client subscription id to deregister
8696
+ * @param clientSubscriptionId client subscription id to deregister
8702
8697
  */
8703
8698
  async removeSignatureListener(clientSubscriptionId) {
8704
8699
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');
@@ -8732,7 +8727,7 @@ class Connection {
8732
8727
  /**
8733
8728
  * Deregister a root notification callback
8734
8729
  *
8735
- * @param id client subscription id to deregister
8730
+ * @param clientSubscriptionId client subscription id to deregister
8736
8731
  */
8737
8732
  async removeRootChangeListener(clientSubscriptionId) {
8738
8733
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');
@@ -10350,6 +10345,10 @@ class VoteInit {
10350
10345
  * Withdraw from vote account transaction params
10351
10346
  */
10352
10347
 
10348
+ /**
10349
+ * Update validator identity (node pubkey) vote account instruction params.
10350
+ */
10351
+
10353
10352
  /**
10354
10353
  * Vote Instruction class
10355
10354
  */
@@ -10496,6 +10495,10 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
10496
10495
  index: 3,
10497
10496
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
10498
10497
  },
10498
+ UpdateValidatorIdentity: {
10499
+ index: 4,
10500
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
10501
+ },
10499
10502
  AuthorizeWithSeed: {
10500
10503
  index: 10,
10501
10504
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), voteAuthorizeWithSeedArgs()])
@@ -10713,10 +10716,41 @@ class VoteProgram {
10713
10716
  */
10714
10717
  static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {
10715
10718
  if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
10716
- throw new Error('Withdraw will leave vote account with insuffcient funds.');
10719
+ throw new Error('Withdraw will leave vote account with insufficient funds.');
10717
10720
  }
10718
10721
  return VoteProgram.withdraw(params);
10719
10722
  }
10723
+
10724
+ /**
10725
+ * Generate a transaction to update the validator identity (node pubkey) of a Vote account.
10726
+ */
10727
+ static updateValidatorIdentity(params) {
10728
+ const {
10729
+ votePubkey,
10730
+ authorizedWithdrawerPubkey,
10731
+ nodePubkey
10732
+ } = params;
10733
+ const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
10734
+ const data = encodeData(type);
10735
+ const keys = [{
10736
+ pubkey: votePubkey,
10737
+ isSigner: false,
10738
+ isWritable: true
10739
+ }, {
10740
+ pubkey: nodePubkey,
10741
+ isSigner: true,
10742
+ isWritable: false
10743
+ }, {
10744
+ pubkey: authorizedWithdrawerPubkey,
10745
+ isSigner: true,
10746
+ isWritable: false
10747
+ }];
10748
+ return new Transaction().add({
10749
+ keys,
10750
+ programId: this.programId,
10751
+ data
10752
+ });
10753
+ }
10720
10754
  }
10721
10755
  VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
10722
10756
  /**
@@ -10728,7 +10762,7 @@ VoteProgram.programId = new PublicKey('Vote1111111111111111111111111111111111111
10728
10762
  *
10729
10763
  * 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
10730
10764
  */
10731
- VoteProgram.space = 3731;
10765
+ VoteProgram.space = 3762;
10732
10766
 
10733
10767
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
10734
10768
 
@@ -10783,10 +10817,8 @@ class ValidatorInfo {
10783
10817
  if (configKeyCount !== 2) return null;
10784
10818
  const configKeys = [];
10785
10819
  for (let i = 0; i < 2; i++) {
10786
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
10787
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
10788
- const isSigner = byteArray.slice(0, 1)[0] === 1;
10789
- byteArray = byteArray.slice(1);
10820
+ const publicKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
10821
+ const isSigner = byteArray.splice(0, 1)[0] === 1;
10790
10822
  configKeys.push({
10791
10823
  publicKey,
10792
10824
  isSigner