@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.d.ts CHANGED
@@ -1274,6 +1274,14 @@ type WithdrawFromVoteAccountParams = {
1274
1274
  lamports: number;
1275
1275
  toPubkey: PublicKey;
1276
1276
  };
1277
+ /**
1278
+ * Update validator identity (node pubkey) vote account instruction params.
1279
+ */
1280
+ type UpdateValidatorIdentityParams = {
1281
+ votePubkey: PublicKey;
1282
+ authorizedWithdrawerPubkey: PublicKey;
1283
+ nodePubkey: PublicKey;
1284
+ };
1277
1285
  /**
1278
1286
  * Vote Instruction class
1279
1287
  */
@@ -1302,7 +1310,7 @@ export class VoteInstruction {
1302
1310
  /**
1303
1311
  * An enumeration of valid VoteInstructionType's
1304
1312
  */
1305
- type VoteInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw';
1313
+ type VoteInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw' | 'UpdateValidatorIdentity';
1306
1314
  /**
1307
1315
  * VoteAuthorize type
1308
1316
  */
@@ -1369,6 +1377,10 @@ export class VoteProgram {
1369
1377
  * `withdraw` method directly.
1370
1378
  */
1371
1379
  static safeWithdraw(params: WithdrawFromVoteAccountParams, currentVoteAccountBalance: number, rentExemptMinimum: number): Transaction;
1380
+ /**
1381
+ * Generate a transaction to update the validator identity (node pubkey) of a Vote account.
1382
+ */
1383
+ static updateValidatorIdentity(params: UpdateValidatorIdentityParams): Transaction;
1372
1384
  }
1373
1385
 
1374
1386
  /**
@@ -3611,7 +3623,7 @@ export class Connection {
3611
3623
  /**
3612
3624
  * Deregister an account notification callback
3613
3625
  *
3614
- * @param id client subscription id to deregister
3626
+ * @param clientSubscriptionId client subscription id to deregister
3615
3627
  */
3616
3628
  removeAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3617
3629
  /**
@@ -3628,7 +3640,7 @@ export class Connection {
3628
3640
  /**
3629
3641
  * Deregister an account notification callback
3630
3642
  *
3631
- * @param id client subscription id to deregister
3643
+ * @param clientSubscriptionId client subscription id to deregister
3632
3644
  */
3633
3645
  removeProgramAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3634
3646
  /**
@@ -3638,7 +3650,7 @@ export class Connection {
3638
3650
  /**
3639
3651
  * Deregister a logs callback.
3640
3652
  *
3641
- * @param id client subscription id to deregister.
3653
+ * @param clientSubscriptionId client subscription id to deregister.
3642
3654
  */
3643
3655
  removeOnLogsListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3644
3656
  /**
@@ -3651,7 +3663,7 @@ export class Connection {
3651
3663
  /**
3652
3664
  * Deregister a slot notification callback
3653
3665
  *
3654
- * @param id client subscription id to deregister
3666
+ * @param clientSubscriptionId client subscription id to deregister
3655
3667
  */
3656
3668
  removeSlotChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3657
3669
  /**
@@ -3665,7 +3677,7 @@ export class Connection {
3665
3677
  /**
3666
3678
  * Deregister a slot update notification callback
3667
3679
  *
3668
- * @param id client subscription id to deregister
3680
+ * @param clientSubscriptionId client subscription id to deregister
3669
3681
  */
3670
3682
  removeSlotUpdateListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3671
3683
  _buildArgs(args: Array<any>, override?: Commitment, encoding?: 'jsonParsed' | 'base64', extra?: any): Array<any>;
@@ -3692,7 +3704,7 @@ export class Connection {
3692
3704
  /**
3693
3705
  * Deregister a signature notification callback
3694
3706
  *
3695
- * @param id client subscription id to deregister
3707
+ * @param clientSubscriptionId client subscription id to deregister
3696
3708
  */
3697
3709
  removeSignatureListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3698
3710
  /**
@@ -3705,7 +3717,7 @@ export class Connection {
3705
3717
  /**
3706
3718
  * Deregister a root notification callback
3707
3719
  *
3708
- * @param id client subscription id to deregister
3720
+ * @param clientSubscriptionId client subscription id to deregister
3709
3721
  */
3710
3722
  removeRootChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3711
3723
  }
package/lib/index.esm.js CHANGED
@@ -826,23 +826,19 @@ class Message {
826
826
  const accountCount = decodeLength(byteArray);
827
827
  let accountKeys = [];
828
828
  for (let i = 0; i < accountCount; i++) {
829
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
830
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
829
+ const account = byteArray.splice(0, PUBLIC_KEY_LENGTH);
831
830
  accountKeys.push(new PublicKey(Buffer.from(account)));
832
831
  }
833
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
834
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
832
+ const recentBlockhash = byteArray.splice(0, PUBLIC_KEY_LENGTH);
835
833
  const instructionCount = decodeLength(byteArray);
836
834
  let instructions = [];
837
835
  for (let i = 0; i < instructionCount; i++) {
838
836
  const programIdIndex = byteArray.shift();
839
837
  const accountCount = decodeLength(byteArray);
840
- const accounts = byteArray.slice(0, accountCount);
841
- byteArray = byteArray.slice(accountCount);
838
+ const accounts = byteArray.splice(0, accountCount);
842
839
  const dataLength = decodeLength(byteArray);
843
- const dataSlice = byteArray.slice(0, dataLength);
840
+ const dataSlice = byteArray.splice(0, dataLength);
844
841
  const data = bs58.encode(Buffer.from(dataSlice));
845
- byteArray = byteArray.slice(dataLength);
846
842
  instructions.push({
847
843
  programIdIndex,
848
844
  accounts,
@@ -1875,8 +1871,7 @@ class Transaction {
1875
1871
  const signatureCount = decodeLength(byteArray);
1876
1872
  let signatures = [];
1877
1873
  for (let i = 0; i < signatureCount; i++) {
1878
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
1879
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
1874
+ const signature = byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES);
1880
1875
  signatures.push(bs58.encode(Buffer.from(signature)));
1881
1876
  }
1882
1877
  return Transaction.populate(Message.from(byteArray), signatures);
@@ -8366,7 +8361,7 @@ class Connection {
8366
8361
  /**
8367
8362
  * Deregister an account notification callback
8368
8363
  *
8369
- * @param id client subscription id to deregister
8364
+ * @param clientSubscriptionId client subscription id to deregister
8370
8365
  */
8371
8366
  async removeAccountChangeListener(clientSubscriptionId) {
8372
8367
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');
@@ -8412,7 +8407,7 @@ class Connection {
8412
8407
  /**
8413
8408
  * Deregister an account notification callback
8414
8409
  *
8415
- * @param id client subscription id to deregister
8410
+ * @param clientSubscriptionId client subscription id to deregister
8416
8411
  */
8417
8412
  async removeProgramAccountChangeListener(clientSubscriptionId) {
8418
8413
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');
@@ -8436,7 +8431,7 @@ class Connection {
8436
8431
  /**
8437
8432
  * Deregister a logs callback.
8438
8433
  *
8439
- * @param id client subscription id to deregister.
8434
+ * @param clientSubscriptionId client subscription id to deregister.
8440
8435
  */
8441
8436
  async removeOnLogsListener(clientSubscriptionId) {
8442
8437
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');
@@ -8481,7 +8476,7 @@ class Connection {
8481
8476
  /**
8482
8477
  * Deregister a slot notification callback
8483
8478
  *
8484
- * @param id client subscription id to deregister
8479
+ * @param clientSubscriptionId client subscription id to deregister
8485
8480
  */
8486
8481
  async removeSlotChangeListener(clientSubscriptionId) {
8487
8482
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');
@@ -8516,7 +8511,7 @@ class Connection {
8516
8511
  /**
8517
8512
  * Deregister a slot update notification callback
8518
8513
  *
8519
- * @param id client subscription id to deregister
8514
+ * @param clientSubscriptionId client subscription id to deregister
8520
8515
  */
8521
8516
  async removeSlotUpdateListener(clientSubscriptionId) {
8522
8517
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');
@@ -8666,7 +8661,7 @@ class Connection {
8666
8661
  /**
8667
8662
  * Deregister a signature notification callback
8668
8663
  *
8669
- * @param id client subscription id to deregister
8664
+ * @param clientSubscriptionId client subscription id to deregister
8670
8665
  */
8671
8666
  async removeSignatureListener(clientSubscriptionId) {
8672
8667
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');
@@ -8700,7 +8695,7 @@ class Connection {
8700
8695
  /**
8701
8696
  * Deregister a root notification callback
8702
8697
  *
8703
- * @param id client subscription id to deregister
8698
+ * @param clientSubscriptionId client subscription id to deregister
8704
8699
  */
8705
8700
  async removeRootChangeListener(clientSubscriptionId) {
8706
8701
  await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');
@@ -10318,6 +10313,10 @@ class VoteInit {
10318
10313
  * Withdraw from vote account transaction params
10319
10314
  */
10320
10315
 
10316
+ /**
10317
+ * Update validator identity (node pubkey) vote account instruction params.
10318
+ */
10319
+
10321
10320
  /**
10322
10321
  * Vote Instruction class
10323
10322
  */
@@ -10464,6 +10463,10 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
10464
10463
  index: 3,
10465
10464
  layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
10466
10465
  },
10466
+ UpdateValidatorIdentity: {
10467
+ index: 4,
10468
+ layout: BufferLayout.struct([BufferLayout.u32('instruction')])
10469
+ },
10467
10470
  AuthorizeWithSeed: {
10468
10471
  index: 10,
10469
10472
  layout: BufferLayout.struct([BufferLayout.u32('instruction'), voteAuthorizeWithSeedArgs()])
@@ -10681,10 +10684,41 @@ class VoteProgram {
10681
10684
  */
10682
10685
  static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {
10683
10686
  if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
10684
- throw new Error('Withdraw will leave vote account with insuffcient funds.');
10687
+ throw new Error('Withdraw will leave vote account with insufficient funds.');
10685
10688
  }
10686
10689
  return VoteProgram.withdraw(params);
10687
10690
  }
10691
+
10692
+ /**
10693
+ * Generate a transaction to update the validator identity (node pubkey) of a Vote account.
10694
+ */
10695
+ static updateValidatorIdentity(params) {
10696
+ const {
10697
+ votePubkey,
10698
+ authorizedWithdrawerPubkey,
10699
+ nodePubkey
10700
+ } = params;
10701
+ const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
10702
+ const data = encodeData(type);
10703
+ const keys = [{
10704
+ pubkey: votePubkey,
10705
+ isSigner: false,
10706
+ isWritable: true
10707
+ }, {
10708
+ pubkey: nodePubkey,
10709
+ isSigner: true,
10710
+ isWritable: false
10711
+ }, {
10712
+ pubkey: authorizedWithdrawerPubkey,
10713
+ isSigner: true,
10714
+ isWritable: false
10715
+ }];
10716
+ return new Transaction().add({
10717
+ keys,
10718
+ programId: this.programId,
10719
+ data
10720
+ });
10721
+ }
10688
10722
  }
10689
10723
  VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
10690
10724
  /**
@@ -10696,7 +10730,7 @@ VoteProgram.programId = new PublicKey('Vote1111111111111111111111111111111111111
10696
10730
  *
10697
10731
  * 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
10698
10732
  */
10699
- VoteProgram.space = 3731;
10733
+ VoteProgram.space = 3762;
10700
10734
 
10701
10735
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
10702
10736
 
@@ -10751,10 +10785,8 @@ class ValidatorInfo {
10751
10785
  if (configKeyCount !== 2) return null;
10752
10786
  const configKeys = [];
10753
10787
  for (let i = 0; i < 2; i++) {
10754
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
10755
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
10756
- const isSigner = byteArray.slice(0, 1)[0] === 1;
10757
- byteArray = byteArray.slice(1);
10788
+ const publicKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
10789
+ const isSigner = byteArray.splice(0, 1)[0] === 1;
10758
10790
  configKeys.push({
10759
10791
  publicKey,
10760
10792
  isSigner