@solana/web3.js 1.33.0 → 1.34.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/lib/index.cjs.js CHANGED
@@ -8835,6 +8835,27 @@ class VoteInstruction {
8835
8835
  voteInit: new VoteInit(new PublicKey(voteInit.nodePubkey), new PublicKey(voteInit.authorizedVoter), new PublicKey(voteInit.authorizedWithdrawer), voteInit.commission)
8836
8836
  };
8837
8837
  }
8838
+ /**
8839
+ * Decode an authorize instruction and retrieve the instruction params.
8840
+ */
8841
+
8842
+
8843
+ static decodeAuthorize(instruction) {
8844
+ this.checkProgramId(instruction.programId);
8845
+ this.checkKeyLength(instruction.keys, 3);
8846
+ const {
8847
+ newAuthorized,
8848
+ voteAuthorizationType
8849
+ } = decodeData(VOTE_INSTRUCTION_LAYOUTS.Authorize, instruction.data);
8850
+ return {
8851
+ votePubkey: instruction.keys[0].pubkey,
8852
+ authorizedPubkey: instruction.keys[2].pubkey,
8853
+ newAuthorizedPubkey: new PublicKey(newAuthorized),
8854
+ voteAuthorizationType: {
8855
+ index: voteAuthorizationType
8856
+ }
8857
+ };
8858
+ }
8838
8859
  /**
8839
8860
  * Decode a withdraw instruction and retrieve the instruction params.
8840
8861
  */
@@ -8884,11 +8905,30 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
8884
8905
  index: 0,
8885
8906
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), voteInit()])
8886
8907
  },
8908
+ Authorize: {
8909
+ index: 1,
8910
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('newAuthorized'), BufferLayout__namespace.u32('voteAuthorizationType')])
8911
+ },
8887
8912
  Withdraw: {
8888
8913
  index: 3,
8889
8914
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
8890
8915
  }
8891
8916
  });
8917
+ /**
8918
+ * VoteAuthorize type
8919
+ */
8920
+
8921
+ /**
8922
+ * An enumeration of valid VoteAuthorization layouts.
8923
+ */
8924
+ const VoteAuthorizationLayout = Object.freeze({
8925
+ Voter: {
8926
+ index: 0
8927
+ },
8928
+ Withdrawer: {
8929
+ index: 1
8930
+ }
8931
+ });
8892
8932
  /**
8893
8933
  * Factory class for transactions to interact with the Vote program
8894
8934
  */
@@ -8964,6 +9004,42 @@ class VoteProgram {
8964
9004
  voteInit: params.voteInit
8965
9005
  }));
8966
9006
  }
9007
+ /**
9008
+ * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
9009
+ */
9010
+
9011
+
9012
+ static authorize(params) {
9013
+ const {
9014
+ votePubkey,
9015
+ authorizedPubkey,
9016
+ newAuthorizedPubkey,
9017
+ voteAuthorizationType
9018
+ } = params;
9019
+ const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;
9020
+ const data = encodeData(type, {
9021
+ newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
9022
+ voteAuthorizationType: voteAuthorizationType.index
9023
+ });
9024
+ const keys = [{
9025
+ pubkey: votePubkey,
9026
+ isSigner: false,
9027
+ isWritable: true
9028
+ }, {
9029
+ pubkey: SYSVAR_CLOCK_PUBKEY,
9030
+ isSigner: false,
9031
+ isWritable: false
9032
+ }, {
9033
+ pubkey: authorizedPubkey,
9034
+ isSigner: true,
9035
+ isWritable: false
9036
+ }];
9037
+ return new Transaction().add({
9038
+ keys,
9039
+ programId: this.programId,
9040
+ data
9041
+ });
9042
+ }
8967
9043
  /**
8968
9044
  * Generate a transaction to withdraw from a Vote account.
8969
9045
  */
@@ -9115,6 +9191,7 @@ exports.VALIDATOR_INFO_KEY = VALIDATOR_INFO_KEY;
9115
9191
  exports.VOTE_PROGRAM_ID = VOTE_PROGRAM_ID;
9116
9192
  exports.ValidatorInfo = ValidatorInfo;
9117
9193
  exports.VoteAccount = VoteAccount;
9194
+ exports.VoteAuthorizationLayout = VoteAuthorizationLayout;
9118
9195
  exports.VoteInit = VoteInit;
9119
9196
  exports.VoteInstruction = VoteInstruction;
9120
9197
  exports.VoteProgram = VoteProgram;