@solana/web3.js 1.36.0 → 1.37.2

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.
@@ -1,6 +1,11 @@
1
1
  import * as BufferLayout from '@solana/buffer-layout';
2
2
 
3
- import {encodeData, decodeData, InstructionType} from './instruction';
3
+ import {
4
+ encodeData,
5
+ decodeData,
6
+ InstructionType,
7
+ IInstructionInputData,
8
+ } from './instruction';
4
9
  import * as Layout from './layout';
5
10
  import {PublicKey} from './publickey';
6
11
  import {SystemProgram} from './system-program';
@@ -202,23 +207,45 @@ export class VoteInstruction {
202
207
  * An enumeration of valid VoteInstructionType's
203
208
  */
204
209
  export type VoteInstructionType =
205
- | 'Authorize'
206
- | 'InitializeAccount'
207
- | 'Withdraw';
210
+ // FIXME
211
+ // It would be preferable for this type to be `keyof VoteInstructionInputData`
212
+ // but Typedoc does not transpile `keyof` expressions.
213
+ // See https://github.com/TypeStrong/typedoc/issues/1894
214
+ 'Authorize' | 'InitializeAccount' | 'Withdraw';
215
+
216
+ type VoteInstructionInputData = {
217
+ Authorize: IInstructionInputData & {
218
+ newAuthorized: Uint8Array;
219
+ voteAuthorizationType: number;
220
+ };
221
+ InitializeAccount: IInstructionInputData & {
222
+ voteInit: Readonly<{
223
+ authorizedVoter: Uint8Array;
224
+ authorizedWithdrawer: Uint8Array;
225
+ commission: number;
226
+ nodePubkey: Uint8Array;
227
+ }>;
228
+ };
229
+ Withdraw: IInstructionInputData & {
230
+ lamports: number;
231
+ };
232
+ };
208
233
 
209
- const VOTE_INSTRUCTION_LAYOUTS: {
210
- [type in VoteInstructionType]: InstructionType;
211
- } = Object.freeze({
234
+ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{
235
+ [Instruction in VoteInstructionType]: InstructionType<
236
+ VoteInstructionInputData[Instruction]
237
+ >;
238
+ }>({
212
239
  InitializeAccount: {
213
240
  index: 0,
214
- layout: BufferLayout.struct([
241
+ layout: BufferLayout.struct<VoteInstructionInputData['InitializeAccount']>([
215
242
  BufferLayout.u32('instruction'),
216
243
  Layout.voteInit(),
217
244
  ]),
218
245
  },
219
246
  Authorize: {
220
247
  index: 1,
221
- layout: BufferLayout.struct([
248
+ layout: BufferLayout.struct<VoteInstructionInputData['Authorize']>([
222
249
  BufferLayout.u32('instruction'),
223
250
  Layout.publicKey('newAuthorized'),
224
251
  BufferLayout.u32('voteAuthorizationType'),
@@ -226,7 +253,7 @@ const VOTE_INSTRUCTION_LAYOUTS: {
226
253
  },
227
254
  Withdraw: {
228
255
  index: 3,
229
- layout: BufferLayout.struct([
256
+ layout: BufferLayout.struct<VoteInstructionInputData['Withdraw']>([
230
257
  BufferLayout.u32('instruction'),
231
258
  BufferLayout.ns64('lamports'),
232
259
  ]),