@solana/web3.js 1.33.1 → 1.34.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
@@ -8862,6 +8862,27 @@ class VoteInstruction {
8862
8862
  voteInit: new VoteInit(new PublicKey(voteInit.nodePubkey), new PublicKey(voteInit.authorizedVoter), new PublicKey(voteInit.authorizedWithdrawer), voteInit.commission)
8863
8863
  };
8864
8864
  }
8865
+ /**
8866
+ * Decode an authorize instruction and retrieve the instruction params.
8867
+ */
8868
+
8869
+
8870
+ static decodeAuthorize(instruction) {
8871
+ this.checkProgramId(instruction.programId);
8872
+ this.checkKeyLength(instruction.keys, 3);
8873
+ const {
8874
+ newAuthorized,
8875
+ voteAuthorizationType
8876
+ } = decodeData(VOTE_INSTRUCTION_LAYOUTS.Authorize, instruction.data);
8877
+ return {
8878
+ votePubkey: instruction.keys[0].pubkey,
8879
+ authorizedPubkey: instruction.keys[2].pubkey,
8880
+ newAuthorizedPubkey: new PublicKey(newAuthorized),
8881
+ voteAuthorizationType: {
8882
+ index: voteAuthorizationType
8883
+ }
8884
+ };
8885
+ }
8865
8886
  /**
8866
8887
  * Decode a withdraw instruction and retrieve the instruction params.
8867
8888
  */
@@ -8911,11 +8932,30 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
8911
8932
  index: 0,
8912
8933
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), voteInit()])
8913
8934
  },
8935
+ Authorize: {
8936
+ index: 1,
8937
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), publicKey('newAuthorized'), BufferLayout__namespace.u32('voteAuthorizationType')])
8938
+ },
8914
8939
  Withdraw: {
8915
8940
  index: 3,
8916
8941
  layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
8917
8942
  }
8918
8943
  });
8944
+ /**
8945
+ * VoteAuthorize type
8946
+ */
8947
+
8948
+ /**
8949
+ * An enumeration of valid VoteAuthorization layouts.
8950
+ */
8951
+ const VoteAuthorizationLayout = Object.freeze({
8952
+ Voter: {
8953
+ index: 0
8954
+ },
8955
+ Withdrawer: {
8956
+ index: 1
8957
+ }
8958
+ });
8919
8959
  /**
8920
8960
  * Factory class for transactions to interact with the Vote program
8921
8961
  */
@@ -8991,6 +9031,42 @@ class VoteProgram {
8991
9031
  voteInit: params.voteInit
8992
9032
  }));
8993
9033
  }
9034
+ /**
9035
+ * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
9036
+ */
9037
+
9038
+
9039
+ static authorize(params) {
9040
+ const {
9041
+ votePubkey,
9042
+ authorizedPubkey,
9043
+ newAuthorizedPubkey,
9044
+ voteAuthorizationType
9045
+ } = params;
9046
+ const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;
9047
+ const data = encodeData(type, {
9048
+ newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
9049
+ voteAuthorizationType: voteAuthorizationType.index
9050
+ });
9051
+ const keys = [{
9052
+ pubkey: votePubkey,
9053
+ isSigner: false,
9054
+ isWritable: true
9055
+ }, {
9056
+ pubkey: SYSVAR_CLOCK_PUBKEY,
9057
+ isSigner: false,
9058
+ isWritable: false
9059
+ }, {
9060
+ pubkey: authorizedPubkey,
9061
+ isSigner: true,
9062
+ isWritable: false
9063
+ }];
9064
+ return new Transaction().add({
9065
+ keys,
9066
+ programId: this.programId,
9067
+ data
9068
+ });
9069
+ }
8994
9070
  /**
8995
9071
  * Generate a transaction to withdraw from a Vote account.
8996
9072
  */
@@ -9142,6 +9218,7 @@ exports.VALIDATOR_INFO_KEY = VALIDATOR_INFO_KEY;
9142
9218
  exports.VOTE_PROGRAM_ID = VOTE_PROGRAM_ID;
9143
9219
  exports.ValidatorInfo = ValidatorInfo;
9144
9220
  exports.VoteAccount = VoteAccount;
9221
+ exports.VoteAuthorizationLayout = VoteAuthorizationLayout;
9145
9222
  exports.VoteInit = VoteInit;
9146
9223
  exports.VoteInstruction = VoteInstruction;
9147
9224
  exports.VoteProgram = VoteProgram;