@solana/web3.js 1.90.1 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.90.1",
3
+ "version": "1.91.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
package/src/connection.ts CHANGED
@@ -6355,7 +6355,7 @@ export class Connection {
6355
6355
  /**
6356
6356
  * Deregister an account notification callback
6357
6357
  *
6358
- * @param id client subscription id to deregister
6358
+ * @param clientSubscriptionId client subscription id to deregister
6359
6359
  */
6360
6360
  async removeAccountChangeListener(
6361
6361
  clientSubscriptionId: ClientSubscriptionId,
@@ -6418,7 +6418,7 @@ export class Connection {
6418
6418
  /**
6419
6419
  * Deregister an account notification callback
6420
6420
  *
6421
- * @param id client subscription id to deregister
6421
+ * @param clientSubscriptionId client subscription id to deregister
6422
6422
  */
6423
6423
  async removeProgramAccountChangeListener(
6424
6424
  clientSubscriptionId: ClientSubscriptionId,
@@ -6454,7 +6454,7 @@ export class Connection {
6454
6454
  /**
6455
6455
  * Deregister a logs callback.
6456
6456
  *
6457
- * @param id client subscription id to deregister.
6457
+ * @param clientSubscriptionId client subscription id to deregister.
6458
6458
  */
6459
6459
  async removeOnLogsListener(
6460
6460
  clientSubscriptionId: ClientSubscriptionId,
@@ -6501,7 +6501,7 @@ export class Connection {
6501
6501
  /**
6502
6502
  * Deregister a slot notification callback
6503
6503
  *
6504
- * @param id client subscription id to deregister
6504
+ * @param clientSubscriptionId client subscription id to deregister
6505
6505
  */
6506
6506
  async removeSlotChangeListener(
6507
6507
  clientSubscriptionId: ClientSubscriptionId,
@@ -6544,7 +6544,7 @@ export class Connection {
6544
6544
  /**
6545
6545
  * Deregister a slot update notification callback
6546
6546
  *
6547
- * @param id client subscription id to deregister
6547
+ * @param clientSubscriptionId client subscription id to deregister
6548
6548
  */
6549
6549
  async removeSlotUpdateListener(
6550
6550
  clientSubscriptionId: ClientSubscriptionId,
@@ -6743,7 +6743,7 @@ export class Connection {
6743
6743
  /**
6744
6744
  * Deregister a signature notification callback
6745
6745
  *
6746
- * @param id client subscription id to deregister
6746
+ * @param clientSubscriptionId client subscription id to deregister
6747
6747
  */
6748
6748
  async removeSignatureListener(
6749
6749
  clientSubscriptionId: ClientSubscriptionId,
@@ -6782,7 +6782,7 @@ export class Connection {
6782
6782
  /**
6783
6783
  * Deregister a root notification callback
6784
6784
  *
6785
- * @param id client subscription id to deregister
6785
+ * @param clientSubscriptionId client subscription id to deregister
6786
6786
  */
6787
6787
  async removeRootChangeListener(
6788
6788
  clientSubscriptionId: ClientSubscriptionId,
@@ -87,6 +87,15 @@ export type WithdrawFromVoteAccountParams = {
87
87
  toPubkey: PublicKey;
88
88
  };
89
89
 
90
+ /**
91
+ * Update validator identity (node pubkey) vote account instruction params.
92
+ */
93
+ export type UpdateValidatorIdentityParams = {
94
+ votePubkey: PublicKey;
95
+ authorizedWithdrawerPubkey: PublicKey;
96
+ nodePubkey: PublicKey;
97
+ };
98
+
90
99
  /**
91
100
  * Vote Instruction class
92
101
  */
@@ -258,7 +267,11 @@ export type VoteInstructionType =
258
267
  // It would be preferable for this type to be `keyof VoteInstructionInputData`
259
268
  // but Typedoc does not transpile `keyof` expressions.
260
269
  // See https://github.com/TypeStrong/typedoc/issues/1894
261
- 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw';
270
+ | 'Authorize'
271
+ | 'AuthorizeWithSeed'
272
+ | 'InitializeAccount'
273
+ | 'Withdraw'
274
+ | 'UpdateValidatorIdentity';
262
275
 
263
276
  /** @internal */
264
277
  export type VoteAuthorizeWithSeedArgs = Readonly<{
@@ -286,6 +299,7 @@ type VoteInstructionInputData = {
286
299
  Withdraw: IInstructionInputData & {
287
300
  lamports: number;
288
301
  };
302
+ UpdateValidatorIdentity: IInstructionInputData;
289
303
  };
290
304
 
291
305
  const VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{
@@ -315,6 +329,12 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{
315
329
  BufferLayout.ns64('lamports'),
316
330
  ]),
317
331
  },
332
+ UpdateValidatorIdentity: {
333
+ index: 4,
334
+ layout: BufferLayout.struct<
335
+ VoteInstructionInputData['UpdateValidatorIdentity']
336
+ >([BufferLayout.u32('instruction')]),
337
+ },
318
338
  AuthorizeWithSeed: {
319
339
  index: 10,
320
340
  layout: BufferLayout.struct<VoteInstructionInputData['AuthorizeWithSeed']>([
@@ -369,7 +389,7 @@ export class VoteProgram {
369
389
  *
370
390
  * 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
371
391
  */
372
- static space: number = process.env.TEST_LIVE ? 3762 : 3731;
392
+ static space: number = 3762;
373
393
 
374
394
  /**
375
395
  * Generate an Initialize instruction.
@@ -535,9 +555,32 @@ export class VoteProgram {
535
555
  ): Transaction {
536
556
  if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
537
557
  throw new Error(
538
- 'Withdraw will leave vote account with insuffcient funds.',
558
+ 'Withdraw will leave vote account with insufficient funds.',
539
559
  );
540
560
  }
541
561
  return VoteProgram.withdraw(params);
542
562
  }
563
+
564
+ /**
565
+ * Generate a transaction to update the validator identity (node pubkey) of a Vote account.
566
+ */
567
+ static updateValidatorIdentity(
568
+ params: UpdateValidatorIdentityParams,
569
+ ): Transaction {
570
+ const {votePubkey, authorizedWithdrawerPubkey, nodePubkey} = params;
571
+ const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
572
+ const data = encodeData(type);
573
+
574
+ const keys = [
575
+ {pubkey: votePubkey, isSigner: false, isWritable: true},
576
+ {pubkey: nodePubkey, isSigner: true, isWritable: false},
577
+ {pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},
578
+ ];
579
+
580
+ return new Transaction().add({
581
+ keys,
582
+ programId: this.programId,
583
+ data,
584
+ });
585
+ }
543
586
  }