@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.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
@@ -8800,6 +8800,27 @@ class VoteInstruction {
8800
8800
  voteInit: new VoteInit(new PublicKey(voteInit.nodePubkey), new PublicKey(voteInit.authorizedVoter), new PublicKey(voteInit.authorizedWithdrawer), voteInit.commission)
8801
8801
  };
8802
8802
  }
8803
+ /**
8804
+ * Decode an authorize instruction and retrieve the instruction params.
8805
+ */
8806
+
8807
+
8808
+ static decodeAuthorize(instruction) {
8809
+ this.checkProgramId(instruction.programId);
8810
+ this.checkKeyLength(instruction.keys, 3);
8811
+ const {
8812
+ newAuthorized,
8813
+ voteAuthorizationType
8814
+ } = decodeData(VOTE_INSTRUCTION_LAYOUTS.Authorize, instruction.data);
8815
+ return {
8816
+ votePubkey: instruction.keys[0].pubkey,
8817
+ authorizedPubkey: instruction.keys[2].pubkey,
8818
+ newAuthorizedPubkey: new PublicKey(newAuthorized),
8819
+ voteAuthorizationType: {
8820
+ index: voteAuthorizationType
8821
+ }
8822
+ };
8823
+ }
8803
8824
  /**
8804
8825
  * Decode a withdraw instruction and retrieve the instruction params.
8805
8826
  */
@@ -8849,11 +8870,30 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
8849
8870
  index: 0,
8850
8871
  layout: BufferLayout.struct([BufferLayout.u32('instruction'), voteInit()])
8851
8872
  },
8873
+ Authorize: {
8874
+ index: 1,
8875
+ layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('newAuthorized'), BufferLayout.u32('voteAuthorizationType')])
8876
+ },
8852
8877
  Withdraw: {
8853
8878
  index: 3,
8854
8879
  layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
8855
8880
  }
8856
8881
  });
8882
+ /**
8883
+ * VoteAuthorize type
8884
+ */
8885
+
8886
+ /**
8887
+ * An enumeration of valid VoteAuthorization layouts.
8888
+ */
8889
+ const VoteAuthorizationLayout = Object.freeze({
8890
+ Voter: {
8891
+ index: 0
8892
+ },
8893
+ Withdrawer: {
8894
+ index: 1
8895
+ }
8896
+ });
8857
8897
  /**
8858
8898
  * Factory class for transactions to interact with the Vote program
8859
8899
  */
@@ -8929,6 +8969,42 @@ class VoteProgram {
8929
8969
  voteInit: params.voteInit
8930
8970
  }));
8931
8971
  }
8972
+ /**
8973
+ * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
8974
+ */
8975
+
8976
+
8977
+ static authorize(params) {
8978
+ const {
8979
+ votePubkey,
8980
+ authorizedPubkey,
8981
+ newAuthorizedPubkey,
8982
+ voteAuthorizationType
8983
+ } = params;
8984
+ const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;
8985
+ const data = encodeData(type, {
8986
+ newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
8987
+ voteAuthorizationType: voteAuthorizationType.index
8988
+ });
8989
+ const keys = [{
8990
+ pubkey: votePubkey,
8991
+ isSigner: false,
8992
+ isWritable: true
8993
+ }, {
8994
+ pubkey: SYSVAR_CLOCK_PUBKEY,
8995
+ isSigner: false,
8996
+ isWritable: false
8997
+ }, {
8998
+ pubkey: authorizedPubkey,
8999
+ isSigner: true,
9000
+ isWritable: false
9001
+ }];
9002
+ return new Transaction().add({
9003
+ keys,
9004
+ programId: this.programId,
9005
+ data
9006
+ });
9007
+ }
8932
9008
  /**
8933
9009
  * Generate a transaction to withdraw from a Vote account.
8934
9010
  */
@@ -9032,5 +9108,5 @@ function clusterApiUrl(cluster, tls) {
9032
9108
 
9033
9109
  const LAMPORTS_PER_SOL = 1000000000;
9034
9110
 
9035
- 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 };
9111
+ 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 };
9036
9112
  //# sourceMappingURL=index.esm.js.map