@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.d.ts CHANGED
@@ -2980,6 +2980,16 @@ declare module '@solana/web3.js' {
2980
2980
  nodePubkey: PublicKey;
2981
2981
  voteInit: VoteInit;
2982
2982
  };
2983
+ /**
2984
+ * Authorize instruction params
2985
+ */
2986
+ export type AuthorizeVoteParams = {
2987
+ votePubkey: PublicKey;
2988
+ /** Current vote or withdraw authority, depending on `voteAuthorizationType` */
2989
+ authorizedPubkey: PublicKey;
2990
+ newAuthorizedPubkey: PublicKey;
2991
+ voteAuthorizationType: VoteAuthorizationType;
2992
+ };
2983
2993
  /**
2984
2994
  * Withdraw from vote account transaction params
2985
2995
  */
@@ -3005,6 +3015,12 @@ declare module '@solana/web3.js' {
3005
3015
  static decodeInitializeAccount(
3006
3016
  instruction: TransactionInstruction,
3007
3017
  ): InitializeAccountParams;
3018
+ /**
3019
+ * Decode an authorize instruction and retrieve the instruction params.
3020
+ */
3021
+ static decodeAuthorize(
3022
+ instruction: TransactionInstruction,
3023
+ ): AuthorizeVoteParams;
3008
3024
  /**
3009
3025
  * Decode a withdraw instruction and retrieve the instruction params.
3010
3026
  */
@@ -3015,7 +3031,28 @@ declare module '@solana/web3.js' {
3015
3031
  /**
3016
3032
  * An enumeration of valid VoteInstructionType's
3017
3033
  */
3018
- export type VoteInstructionType = 'InitializeAccount' | 'Withdraw';
3034
+ export type VoteInstructionType =
3035
+ | 'Authorize'
3036
+ | 'InitializeAccount'
3037
+ | 'Withdraw';
3038
+ /**
3039
+ * VoteAuthorize type
3040
+ */
3041
+ export type VoteAuthorizationType = {
3042
+ /** The VoteAuthorize index (from solana-vote-program) */
3043
+ index: number;
3044
+ };
3045
+ /**
3046
+ * An enumeration of valid VoteAuthorization layouts.
3047
+ */
3048
+ export const VoteAuthorizationLayout: Readonly<{
3049
+ Voter: {
3050
+ index: number;
3051
+ };
3052
+ Withdrawer: {
3053
+ index: number;
3054
+ };
3055
+ }>;
3019
3056
  /**
3020
3057
  * Factory class for transactions to interact with the Vote program
3021
3058
  */
@@ -3042,6 +3079,10 @@ declare module '@solana/web3.js' {
3042
3079
  * Generate a transaction that creates a new Vote account.
3043
3080
  */
3044
3081
  static createAccount(params: CreateVoteAccountParams): Transaction;
3082
+ /**
3083
+ * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
3084
+ */
3085
+ static authorize(params: AuthorizeVoteParams): Transaction;
3045
3086
  /**
3046
3087
  * Generate a transaction to withdraw from a Vote account.
3047
3088
  */
package/lib/index.esm.js CHANGED
@@ -8827,6 +8827,27 @@ class VoteInstruction {
8827
8827
  voteInit: new VoteInit(new PublicKey(voteInit.nodePubkey), new PublicKey(voteInit.authorizedVoter), new PublicKey(voteInit.authorizedWithdrawer), voteInit.commission)
8828
8828
  };
8829
8829
  }
8830
+ /**
8831
+ * Decode an authorize instruction and retrieve the instruction params.
8832
+ */
8833
+
8834
+
8835
+ static decodeAuthorize(instruction) {
8836
+ this.checkProgramId(instruction.programId);
8837
+ this.checkKeyLength(instruction.keys, 3);
8838
+ const {
8839
+ newAuthorized,
8840
+ voteAuthorizationType
8841
+ } = decodeData(VOTE_INSTRUCTION_LAYOUTS.Authorize, instruction.data);
8842
+ return {
8843
+ votePubkey: instruction.keys[0].pubkey,
8844
+ authorizedPubkey: instruction.keys[2].pubkey,
8845
+ newAuthorizedPubkey: new PublicKey(newAuthorized),
8846
+ voteAuthorizationType: {
8847
+ index: voteAuthorizationType
8848
+ }
8849
+ };
8850
+ }
8830
8851
  /**
8831
8852
  * Decode a withdraw instruction and retrieve the instruction params.
8832
8853
  */
@@ -8876,11 +8897,30 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
8876
8897
  index: 0,
8877
8898
  layout: BufferLayout.struct([BufferLayout.u32('instruction'), voteInit()])
8878
8899
  },
8900
+ Authorize: {
8901
+ index: 1,
8902
+ layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('newAuthorized'), BufferLayout.u32('voteAuthorizationType')])
8903
+ },
8879
8904
  Withdraw: {
8880
8905
  index: 3,
8881
8906
  layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
8882
8907
  }
8883
8908
  });
8909
+ /**
8910
+ * VoteAuthorize type
8911
+ */
8912
+
8913
+ /**
8914
+ * An enumeration of valid VoteAuthorization layouts.
8915
+ */
8916
+ const VoteAuthorizationLayout = Object.freeze({
8917
+ Voter: {
8918
+ index: 0
8919
+ },
8920
+ Withdrawer: {
8921
+ index: 1
8922
+ }
8923
+ });
8884
8924
  /**
8885
8925
  * Factory class for transactions to interact with the Vote program
8886
8926
  */
@@ -8956,6 +8996,42 @@ class VoteProgram {
8956
8996
  voteInit: params.voteInit
8957
8997
  }));
8958
8998
  }
8999
+ /**
9000
+ * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
9001
+ */
9002
+
9003
+
9004
+ static authorize(params) {
9005
+ const {
9006
+ votePubkey,
9007
+ authorizedPubkey,
9008
+ newAuthorizedPubkey,
9009
+ voteAuthorizationType
9010
+ } = params;
9011
+ const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;
9012
+ const data = encodeData(type, {
9013
+ newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
9014
+ voteAuthorizationType: voteAuthorizationType.index
9015
+ });
9016
+ const keys = [{
9017
+ pubkey: votePubkey,
9018
+ isSigner: false,
9019
+ isWritable: true
9020
+ }, {
9021
+ pubkey: SYSVAR_CLOCK_PUBKEY,
9022
+ isSigner: false,
9023
+ isWritable: false
9024
+ }, {
9025
+ pubkey: authorizedPubkey,
9026
+ isSigner: true,
9027
+ isWritable: false
9028
+ }];
9029
+ return new Transaction().add({
9030
+ keys,
9031
+ programId: this.programId,
9032
+ data
9033
+ });
9034
+ }
8959
9035
  /**
8960
9036
  * Generate a transaction to withdraw from a Vote account.
8961
9037
  */
@@ -9059,5 +9135,5 @@ function clusterApiUrl(cluster, tls) {
9059
9135
 
9060
9136
  const LAMPORTS_PER_SOL = 1000000000;
9061
9137
 
9062
- export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
9138
+ export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
9063
9139
  //# sourceMappingURL=index.esm.js.map