@solana/web3.js 1.74.0 → 2.0.0-experimental.1b52291

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.
Files changed (102) hide show
  1. package/README.md +55 -112
  2. package/dist/index.browser.cjs +77 -0
  3. package/dist/index.browser.cjs.map +1 -0
  4. package/dist/index.browser.js +68 -0
  5. package/dist/index.browser.js.map +1 -0
  6. package/dist/index.development.js +539 -0
  7. package/dist/index.development.js.map +1 -0
  8. package/dist/index.native.js +70 -0
  9. package/dist/index.native.js.map +1 -0
  10. package/dist/index.node.cjs +79 -0
  11. package/dist/index.node.cjs.map +1 -0
  12. package/dist/index.node.js +70 -0
  13. package/dist/index.node.js.map +1 -0
  14. package/dist/index.production.min.js +13 -0
  15. package/dist/types/index.d.ts +4 -0
  16. package/dist/types/index.d.ts.map +1 -0
  17. package/dist/types/rpc-default-config.d.ts +3 -0
  18. package/dist/types/rpc-default-config.d.ts.map +1 -0
  19. package/dist/types/rpc-integer-overflow-error.d.ts +8 -0
  20. package/dist/types/rpc-integer-overflow-error.d.ts.map +1 -0
  21. package/dist/types/rpc-transport.d.ts +4 -0
  22. package/dist/types/rpc-transport.d.ts.map +1 -0
  23. package/dist/types/rpc.d.ts +5 -0
  24. package/dist/types/rpc.d.ts.map +1 -0
  25. package/package.json +86 -113
  26. package/lib/index.browser.cjs.js +0 -9485
  27. package/lib/index.browser.cjs.js.map +0 -1
  28. package/lib/index.browser.esm.js +0 -9379
  29. package/lib/index.browser.esm.js.map +0 -1
  30. package/lib/index.cjs.js +0 -12009
  31. package/lib/index.cjs.js.map +0 -1
  32. package/lib/index.d.ts +0 -3865
  33. package/lib/index.esm.js +0 -11896
  34. package/lib/index.esm.js.map +0 -1
  35. package/lib/index.iife.js +0 -24568
  36. package/lib/index.iife.js.map +0 -1
  37. package/lib/index.iife.min.js +0 -13
  38. package/lib/index.iife.min.js.map +0 -1
  39. package/lib/index.native.js +0 -9485
  40. package/lib/index.native.js.map +0 -1
  41. package/src/__forks__/browser/fetch-impl.ts +0 -4
  42. package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
  43. package/src/__forks__/react-native/fetch-impl.ts +0 -4
  44. package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
  45. package/src/account-data.ts +0 -39
  46. package/src/account.ts +0 -55
  47. package/src/blockhash.ts +0 -4
  48. package/src/bpf-loader-deprecated.ts +0 -5
  49. package/src/bpf-loader.ts +0 -45
  50. package/src/connection.ts +0 -6678
  51. package/src/epoch-schedule.ts +0 -102
  52. package/src/errors.ts +0 -50
  53. package/src/fee-calculator.ts +0 -18
  54. package/src/fetch-impl.ts +0 -13
  55. package/src/index.ts +0 -24
  56. package/src/instruction.ts +0 -58
  57. package/src/keypair.ts +0 -93
  58. package/src/layout.ts +0 -188
  59. package/src/loader.ts +0 -236
  60. package/src/message/account-keys.ts +0 -79
  61. package/src/message/compiled-keys.ts +0 -165
  62. package/src/message/index.ts +0 -47
  63. package/src/message/legacy.ts +0 -326
  64. package/src/message/v0.ts +0 -496
  65. package/src/message/versioned.ts +0 -36
  66. package/src/nonce-account.ts +0 -82
  67. package/src/programs/address-lookup-table/index.ts +0 -435
  68. package/src/programs/address-lookup-table/state.ts +0 -84
  69. package/src/programs/compute-budget.ts +0 -281
  70. package/src/programs/ed25519.ts +0 -157
  71. package/src/programs/index.ts +0 -7
  72. package/src/programs/secp256k1.ts +0 -228
  73. package/src/programs/stake.ts +0 -935
  74. package/src/programs/system.ts +0 -1048
  75. package/src/programs/vote.ts +0 -541
  76. package/src/publickey.ts +0 -259
  77. package/src/rpc-websocket-factory.ts +0 -4
  78. package/src/rpc-websocket.ts +0 -79
  79. package/src/sysvar.ts +0 -37
  80. package/src/timing.ts +0 -23
  81. package/src/transaction/constants.ts +0 -12
  82. package/src/transaction/expiry-custom-errors.ts +0 -48
  83. package/src/transaction/index.ts +0 -5
  84. package/src/transaction/legacy.ts +0 -908
  85. package/src/transaction/message.ts +0 -140
  86. package/src/transaction/versioned.ts +0 -126
  87. package/src/utils/assert.ts +0 -8
  88. package/src/utils/bigint.ts +0 -43
  89. package/src/utils/borsh-schema.ts +0 -38
  90. package/src/utils/cluster.ts +0 -31
  91. package/src/utils/ed25519.ts +0 -46
  92. package/src/utils/index.ts +0 -5
  93. package/src/utils/makeWebsocketUrl.ts +0 -26
  94. package/src/utils/promise-timeout.ts +0 -14
  95. package/src/utils/secp256k1.ts +0 -18
  96. package/src/utils/send-and-confirm-raw-transaction.ts +0 -102
  97. package/src/utils/send-and-confirm-transaction.ts +0 -98
  98. package/src/utils/shortvec-encoding.ts +0 -28
  99. package/src/utils/sleep.ts +0 -4
  100. package/src/utils/to-buffer.ts +0 -11
  101. package/src/validator-info.ts +0 -104
  102. package/src/vote-account.ts +0 -236
@@ -1,541 +0,0 @@
1
- import * as BufferLayout from '@solana/buffer-layout';
2
-
3
- import {
4
- encodeData,
5
- decodeData,
6
- InstructionType,
7
- IInstructionInputData,
8
- } from '../instruction';
9
- import * as Layout from '../layout';
10
- import {PublicKey} from '../publickey';
11
- import {SystemProgram} from './system';
12
- import {SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY} from '../sysvar';
13
- import {Transaction, TransactionInstruction} from '../transaction';
14
- import {toBuffer} from '../utils/to-buffer';
15
-
16
- /**
17
- * Vote account info
18
- */
19
- export class VoteInit {
20
- nodePubkey: PublicKey;
21
- authorizedVoter: PublicKey;
22
- authorizedWithdrawer: PublicKey;
23
- commission: number; /** [0, 100] */
24
-
25
- constructor(
26
- nodePubkey: PublicKey,
27
- authorizedVoter: PublicKey,
28
- authorizedWithdrawer: PublicKey,
29
- commission: number,
30
- ) {
31
- this.nodePubkey = nodePubkey;
32
- this.authorizedVoter = authorizedVoter;
33
- this.authorizedWithdrawer = authorizedWithdrawer;
34
- this.commission = commission;
35
- }
36
- }
37
-
38
- /**
39
- * Create vote account transaction params
40
- */
41
- export type CreateVoteAccountParams = {
42
- fromPubkey: PublicKey;
43
- votePubkey: PublicKey;
44
- voteInit: VoteInit;
45
- lamports: number;
46
- };
47
-
48
- /**
49
- * InitializeAccount instruction params
50
- */
51
- export type InitializeAccountParams = {
52
- votePubkey: PublicKey;
53
- nodePubkey: PublicKey;
54
- voteInit: VoteInit;
55
- };
56
-
57
- /**
58
- * Authorize instruction params
59
- */
60
- export type AuthorizeVoteParams = {
61
- votePubkey: PublicKey;
62
- /** Current vote or withdraw authority, depending on `voteAuthorizationType` */
63
- authorizedPubkey: PublicKey;
64
- newAuthorizedPubkey: PublicKey;
65
- voteAuthorizationType: VoteAuthorizationType;
66
- };
67
-
68
- /**
69
- * AuthorizeWithSeed instruction params
70
- */
71
- export type AuthorizeVoteWithSeedParams = {
72
- currentAuthorityDerivedKeyBasePubkey: PublicKey;
73
- currentAuthorityDerivedKeyOwnerPubkey: PublicKey;
74
- currentAuthorityDerivedKeySeed: string;
75
- newAuthorizedPubkey: PublicKey;
76
- voteAuthorizationType: VoteAuthorizationType;
77
- votePubkey: PublicKey;
78
- };
79
-
80
- /**
81
- * Withdraw from vote account transaction params
82
- */
83
- export type WithdrawFromVoteAccountParams = {
84
- votePubkey: PublicKey;
85
- authorizedWithdrawerPubkey: PublicKey;
86
- lamports: number;
87
- toPubkey: PublicKey;
88
- };
89
-
90
- /**
91
- * Vote Instruction class
92
- */
93
- export class VoteInstruction {
94
- /**
95
- * @internal
96
- */
97
- constructor() {}
98
-
99
- /**
100
- * Decode a vote instruction and retrieve the instruction type.
101
- */
102
- static decodeInstructionType(
103
- instruction: TransactionInstruction,
104
- ): VoteInstructionType {
105
- this.checkProgramId(instruction.programId);
106
-
107
- const instructionTypeLayout = BufferLayout.u32('instruction');
108
- const typeIndex = instructionTypeLayout.decode(instruction.data);
109
-
110
- let type: VoteInstructionType | undefined;
111
- for (const [ixType, layout] of Object.entries(VOTE_INSTRUCTION_LAYOUTS)) {
112
- if (layout.index == typeIndex) {
113
- type = ixType as VoteInstructionType;
114
- break;
115
- }
116
- }
117
-
118
- if (!type) {
119
- throw new Error('Instruction type incorrect; not a VoteInstruction');
120
- }
121
-
122
- return type;
123
- }
124
-
125
- /**
126
- * Decode an initialize vote instruction and retrieve the instruction params.
127
- */
128
- static decodeInitializeAccount(
129
- instruction: TransactionInstruction,
130
- ): InitializeAccountParams {
131
- this.checkProgramId(instruction.programId);
132
- this.checkKeyLength(instruction.keys, 4);
133
-
134
- const {voteInit} = decodeData(
135
- VOTE_INSTRUCTION_LAYOUTS.InitializeAccount,
136
- instruction.data,
137
- );
138
-
139
- return {
140
- votePubkey: instruction.keys[0].pubkey,
141
- nodePubkey: instruction.keys[3].pubkey,
142
- voteInit: new VoteInit(
143
- new PublicKey(voteInit.nodePubkey),
144
- new PublicKey(voteInit.authorizedVoter),
145
- new PublicKey(voteInit.authorizedWithdrawer),
146
- voteInit.commission,
147
- ),
148
- };
149
- }
150
-
151
- /**
152
- * Decode an authorize instruction and retrieve the instruction params.
153
- */
154
- static decodeAuthorize(
155
- instruction: TransactionInstruction,
156
- ): AuthorizeVoteParams {
157
- this.checkProgramId(instruction.programId);
158
- this.checkKeyLength(instruction.keys, 3);
159
-
160
- const {newAuthorized, voteAuthorizationType} = decodeData(
161
- VOTE_INSTRUCTION_LAYOUTS.Authorize,
162
- instruction.data,
163
- );
164
-
165
- return {
166
- votePubkey: instruction.keys[0].pubkey,
167
- authorizedPubkey: instruction.keys[2].pubkey,
168
- newAuthorizedPubkey: new PublicKey(newAuthorized),
169
- voteAuthorizationType: {
170
- index: voteAuthorizationType,
171
- },
172
- };
173
- }
174
-
175
- /**
176
- * Decode an authorize instruction and retrieve the instruction params.
177
- */
178
- static decodeAuthorizeWithSeed(
179
- instruction: TransactionInstruction,
180
- ): AuthorizeVoteWithSeedParams {
181
- this.checkProgramId(instruction.programId);
182
- this.checkKeyLength(instruction.keys, 3);
183
-
184
- const {
185
- voteAuthorizeWithSeedArgs: {
186
- currentAuthorityDerivedKeyOwnerPubkey,
187
- currentAuthorityDerivedKeySeed,
188
- newAuthorized,
189
- voteAuthorizationType,
190
- },
191
- } = decodeData(
192
- VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed,
193
- instruction.data,
194
- );
195
-
196
- return {
197
- currentAuthorityDerivedKeyBasePubkey: instruction.keys[2].pubkey,
198
- currentAuthorityDerivedKeyOwnerPubkey: new PublicKey(
199
- currentAuthorityDerivedKeyOwnerPubkey,
200
- ),
201
- currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,
202
- newAuthorizedPubkey: new PublicKey(newAuthorized),
203
- voteAuthorizationType: {
204
- index: voteAuthorizationType,
205
- },
206
- votePubkey: instruction.keys[0].pubkey,
207
- };
208
- }
209
-
210
- /**
211
- * Decode a withdraw instruction and retrieve the instruction params.
212
- */
213
- static decodeWithdraw(
214
- instruction: TransactionInstruction,
215
- ): WithdrawFromVoteAccountParams {
216
- this.checkProgramId(instruction.programId);
217
- this.checkKeyLength(instruction.keys, 3);
218
-
219
- const {lamports} = decodeData(
220
- VOTE_INSTRUCTION_LAYOUTS.Withdraw,
221
- instruction.data,
222
- );
223
-
224
- return {
225
- votePubkey: instruction.keys[0].pubkey,
226
- authorizedWithdrawerPubkey: instruction.keys[2].pubkey,
227
- lamports,
228
- toPubkey: instruction.keys[1].pubkey,
229
- };
230
- }
231
-
232
- /**
233
- * @internal
234
- */
235
- static checkProgramId(programId: PublicKey) {
236
- if (!programId.equals(VoteProgram.programId)) {
237
- throw new Error('invalid instruction; programId is not VoteProgram');
238
- }
239
- }
240
-
241
- /**
242
- * @internal
243
- */
244
- static checkKeyLength(keys: Array<any>, expectedLength: number) {
245
- if (keys.length < expectedLength) {
246
- throw new Error(
247
- `invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`,
248
- );
249
- }
250
- }
251
- }
252
-
253
- /**
254
- * An enumeration of valid VoteInstructionType's
255
- */
256
- export type VoteInstructionType =
257
- // FIXME
258
- // It would be preferable for this type to be `keyof VoteInstructionInputData`
259
- // but Typedoc does not transpile `keyof` expressions.
260
- // See https://github.com/TypeStrong/typedoc/issues/1894
261
- 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw';
262
-
263
- /** @internal */
264
- export type VoteAuthorizeWithSeedArgs = Readonly<{
265
- currentAuthorityDerivedKeyOwnerPubkey: Uint8Array;
266
- currentAuthorityDerivedKeySeed: string;
267
- newAuthorized: Uint8Array;
268
- voteAuthorizationType: number;
269
- }>;
270
- type VoteInstructionInputData = {
271
- Authorize: IInstructionInputData & {
272
- newAuthorized: Uint8Array;
273
- voteAuthorizationType: number;
274
- };
275
- AuthorizeWithSeed: IInstructionInputData & {
276
- voteAuthorizeWithSeedArgs: VoteAuthorizeWithSeedArgs;
277
- };
278
- InitializeAccount: IInstructionInputData & {
279
- voteInit: Readonly<{
280
- authorizedVoter: Uint8Array;
281
- authorizedWithdrawer: Uint8Array;
282
- commission: number;
283
- nodePubkey: Uint8Array;
284
- }>;
285
- };
286
- Withdraw: IInstructionInputData & {
287
- lamports: number;
288
- };
289
- };
290
-
291
- const VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{
292
- [Instruction in VoteInstructionType]: InstructionType<
293
- VoteInstructionInputData[Instruction]
294
- >;
295
- }>({
296
- InitializeAccount: {
297
- index: 0,
298
- layout: BufferLayout.struct<VoteInstructionInputData['InitializeAccount']>([
299
- BufferLayout.u32('instruction'),
300
- Layout.voteInit(),
301
- ]),
302
- },
303
- Authorize: {
304
- index: 1,
305
- layout: BufferLayout.struct<VoteInstructionInputData['Authorize']>([
306
- BufferLayout.u32('instruction'),
307
- Layout.publicKey('newAuthorized'),
308
- BufferLayout.u32('voteAuthorizationType'),
309
- ]),
310
- },
311
- Withdraw: {
312
- index: 3,
313
- layout: BufferLayout.struct<VoteInstructionInputData['Withdraw']>([
314
- BufferLayout.u32('instruction'),
315
- BufferLayout.ns64('lamports'),
316
- ]),
317
- },
318
- AuthorizeWithSeed: {
319
- index: 10,
320
- layout: BufferLayout.struct<VoteInstructionInputData['AuthorizeWithSeed']>([
321
- BufferLayout.u32('instruction'),
322
- Layout.voteAuthorizeWithSeedArgs(),
323
- ]),
324
- },
325
- });
326
-
327
- /**
328
- * VoteAuthorize type
329
- */
330
- export type VoteAuthorizationType = {
331
- /** The VoteAuthorize index (from solana-vote-program) */
332
- index: number;
333
- };
334
-
335
- /**
336
- * An enumeration of valid VoteAuthorization layouts.
337
- */
338
- export const VoteAuthorizationLayout = Object.freeze({
339
- Voter: {
340
- index: 0,
341
- },
342
- Withdrawer: {
343
- index: 1,
344
- },
345
- });
346
-
347
- /**
348
- * Factory class for transactions to interact with the Vote program
349
- */
350
- export class VoteProgram {
351
- /**
352
- * @internal
353
- */
354
- constructor() {}
355
-
356
- /**
357
- * Public key that identifies the Vote program
358
- */
359
- static programId: PublicKey = new PublicKey(
360
- 'Vote111111111111111111111111111111111111111',
361
- );
362
-
363
- /**
364
- * Max space of a Vote account
365
- *
366
- * This is generated from the solana-vote-program VoteState struct as
367
- * `VoteState::size_of()`:
368
- * https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of
369
- */
370
- static space: number = 3731;
371
-
372
- /**
373
- * Generate an Initialize instruction.
374
- */
375
- static initializeAccount(
376
- params: InitializeAccountParams,
377
- ): TransactionInstruction {
378
- const {votePubkey, nodePubkey, voteInit} = params;
379
- const type = VOTE_INSTRUCTION_LAYOUTS.InitializeAccount;
380
- const data = encodeData(type, {
381
- voteInit: {
382
- nodePubkey: toBuffer(voteInit.nodePubkey.toBuffer()),
383
- authorizedVoter: toBuffer(voteInit.authorizedVoter.toBuffer()),
384
- authorizedWithdrawer: toBuffer(
385
- voteInit.authorizedWithdrawer.toBuffer(),
386
- ),
387
- commission: voteInit.commission,
388
- },
389
- });
390
- const instructionData = {
391
- keys: [
392
- {pubkey: votePubkey, isSigner: false, isWritable: true},
393
- {pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},
394
- {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
395
- {pubkey: nodePubkey, isSigner: true, isWritable: false},
396
- ],
397
- programId: this.programId,
398
- data,
399
- };
400
- return new TransactionInstruction(instructionData);
401
- }
402
-
403
- /**
404
- * Generate a transaction that creates a new Vote account.
405
- */
406
- static createAccount(params: CreateVoteAccountParams): Transaction {
407
- const transaction = new Transaction();
408
- transaction.add(
409
- SystemProgram.createAccount({
410
- fromPubkey: params.fromPubkey,
411
- newAccountPubkey: params.votePubkey,
412
- lamports: params.lamports,
413
- space: this.space,
414
- programId: this.programId,
415
- }),
416
- );
417
-
418
- return transaction.add(
419
- this.initializeAccount({
420
- votePubkey: params.votePubkey,
421
- nodePubkey: params.voteInit.nodePubkey,
422
- voteInit: params.voteInit,
423
- }),
424
- );
425
- }
426
-
427
- /**
428
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
429
- */
430
- static authorize(params: AuthorizeVoteParams): Transaction {
431
- const {
432
- votePubkey,
433
- authorizedPubkey,
434
- newAuthorizedPubkey,
435
- voteAuthorizationType,
436
- } = params;
437
-
438
- const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;
439
- const data = encodeData(type, {
440
- newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
441
- voteAuthorizationType: voteAuthorizationType.index,
442
- });
443
-
444
- const keys = [
445
- {pubkey: votePubkey, isSigner: false, isWritable: true},
446
- {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
447
- {pubkey: authorizedPubkey, isSigner: true, isWritable: false},
448
- ];
449
-
450
- return new Transaction().add({
451
- keys,
452
- programId: this.programId,
453
- data,
454
- });
455
- }
456
-
457
- /**
458
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account
459
- * where the current Voter or Withdrawer authority is a derived key.
460
- */
461
- static authorizeWithSeed(params: AuthorizeVoteWithSeedParams): Transaction {
462
- const {
463
- currentAuthorityDerivedKeyBasePubkey,
464
- currentAuthorityDerivedKeyOwnerPubkey,
465
- currentAuthorityDerivedKeySeed,
466
- newAuthorizedPubkey,
467
- voteAuthorizationType,
468
- votePubkey,
469
- } = params;
470
-
471
- const type = VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;
472
- const data = encodeData(type, {
473
- voteAuthorizeWithSeedArgs: {
474
- currentAuthorityDerivedKeyOwnerPubkey: toBuffer(
475
- currentAuthorityDerivedKeyOwnerPubkey.toBuffer(),
476
- ),
477
- currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,
478
- newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
479
- voteAuthorizationType: voteAuthorizationType.index,
480
- },
481
- });
482
-
483
- const keys = [
484
- {pubkey: votePubkey, isSigner: false, isWritable: true},
485
- {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
486
- {
487
- pubkey: currentAuthorityDerivedKeyBasePubkey,
488
- isSigner: true,
489
- isWritable: false,
490
- },
491
- ];
492
-
493
- return new Transaction().add({
494
- keys,
495
- programId: this.programId,
496
- data,
497
- });
498
- }
499
-
500
- /**
501
- * Generate a transaction to withdraw from a Vote account.
502
- */
503
- static withdraw(params: WithdrawFromVoteAccountParams): Transaction {
504
- const {votePubkey, authorizedWithdrawerPubkey, lamports, toPubkey} = params;
505
- const type = VOTE_INSTRUCTION_LAYOUTS.Withdraw;
506
- const data = encodeData(type, {lamports});
507
-
508
- const keys = [
509
- {pubkey: votePubkey, isSigner: false, isWritable: true},
510
- {pubkey: toPubkey, isSigner: false, isWritable: true},
511
- {pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},
512
- ];
513
-
514
- return new Transaction().add({
515
- keys,
516
- programId: this.programId,
517
- data,
518
- });
519
- }
520
-
521
- /**
522
- * Generate a transaction to withdraw safely from a Vote account.
523
- *
524
- * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
525
- * checks that the withdraw amount will not exceed the specified balance while leaving enough left
526
- * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
527
- * `withdraw` method directly.
528
- */
529
- static safeWithdraw(
530
- params: WithdrawFromVoteAccountParams,
531
- currentVoteAccountBalance: number,
532
- rentExemptMinimum: number,
533
- ): Transaction {
534
- if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
535
- throw new Error(
536
- 'Withdraw will leave vote account with insuffcient funds.',
537
- );
538
- }
539
- return VoteProgram.withdraw(params);
540
- }
541
- }