@solana/web3.js 1.78.0 → 2.0.0-development

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 (99) hide show
  1. package/README.md +56 -112
  2. package/dist/index.browser.cjs +158 -0
  3. package/dist/index.browser.cjs.map +1 -0
  4. package/dist/index.browser.js +137 -0
  5. package/dist/index.browser.js.map +1 -0
  6. package/dist/index.development.js +1044 -0
  7. package/dist/index.development.js.map +1 -0
  8. package/dist/index.native.js +139 -0
  9. package/dist/index.native.js.map +1 -0
  10. package/dist/index.node.cjs +158 -0
  11. package/dist/index.node.cjs.map +1 -0
  12. package/dist/index.node.js +139 -0
  13. package/dist/index.node.js.map +1 -0
  14. package/dist/index.production.min.js +25 -0
  15. package/dist/types/index.d.ts +5 -0
  16. package/dist/types/rpc-default-config.d.ts +3 -0
  17. package/dist/types/rpc-integer-overflow-error.d.ts +8 -0
  18. package/dist/types/rpc-request-coalescer.d.ts +5 -0
  19. package/dist/types/rpc-request-deduplication.d.ts +2 -0
  20. package/dist/types/rpc-transport.d.ts +4 -0
  21. package/dist/types/rpc.d.ts +5 -0
  22. package/package.json +86 -111
  23. package/lib/index.browser.cjs.js +0 -10248
  24. package/lib/index.browser.cjs.js.map +0 -1
  25. package/lib/index.browser.esm.js +0 -10145
  26. package/lib/index.browser.esm.js.map +0 -1
  27. package/lib/index.cjs.js +0 -12748
  28. package/lib/index.cjs.js.map +0 -1
  29. package/lib/index.d.ts +0 -3904
  30. package/lib/index.esm.js +0 -12638
  31. package/lib/index.esm.js.map +0 -1
  32. package/lib/index.iife.js +0 -26757
  33. package/lib/index.iife.js.map +0 -1
  34. package/lib/index.iife.min.js +0 -20
  35. package/lib/index.iife.min.js.map +0 -1
  36. package/lib/index.native.js +0 -10248
  37. package/lib/index.native.js.map +0 -1
  38. package/src/__forks__/browser/fetch-impl.ts +0 -4
  39. package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
  40. package/src/__forks__/react-native/fetch-impl.ts +0 -4
  41. package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
  42. package/src/account-data.ts +0 -39
  43. package/src/account.ts +0 -55
  44. package/src/blockhash.ts +0 -4
  45. package/src/bpf-loader-deprecated.ts +0 -5
  46. package/src/bpf-loader.ts +0 -45
  47. package/src/connection.ts +0 -6796
  48. package/src/epoch-schedule.ts +0 -102
  49. package/src/errors.ts +0 -50
  50. package/src/fee-calculator.ts +0 -18
  51. package/src/fetch-impl.ts +0 -13
  52. package/src/index.ts +0 -24
  53. package/src/instruction.ts +0 -58
  54. package/src/keypair.ts +0 -93
  55. package/src/layout.ts +0 -188
  56. package/src/loader.ts +0 -267
  57. package/src/message/account-keys.ts +0 -79
  58. package/src/message/compiled-keys.ts +0 -165
  59. package/src/message/index.ts +0 -47
  60. package/src/message/legacy.ts +0 -326
  61. package/src/message/v0.ts +0 -496
  62. package/src/message/versioned.ts +0 -36
  63. package/src/nonce-account.ts +0 -82
  64. package/src/programs/address-lookup-table/index.ts +0 -435
  65. package/src/programs/address-lookup-table/state.ts +0 -84
  66. package/src/programs/compute-budget.ts +0 -281
  67. package/src/programs/ed25519.ts +0 -157
  68. package/src/programs/index.ts +0 -7
  69. package/src/programs/secp256k1.ts +0 -228
  70. package/src/programs/stake.ts +0 -935
  71. package/src/programs/system.ts +0 -1048
  72. package/src/programs/vote.ts +0 -543
  73. package/src/publickey.ts +0 -259
  74. package/src/rpc-websocket-factory.ts +0 -4
  75. package/src/rpc-websocket.ts +0 -79
  76. package/src/sysvar.ts +0 -37
  77. package/src/timing.ts +0 -23
  78. package/src/transaction/constants.ts +0 -12
  79. package/src/transaction/expiry-custom-errors.ts +0 -48
  80. package/src/transaction/index.ts +0 -5
  81. package/src/transaction/legacy.ts +0 -918
  82. package/src/transaction/message.ts +0 -140
  83. package/src/transaction/versioned.ts +0 -126
  84. package/src/utils/assert.ts +0 -8
  85. package/src/utils/bigint.ts +0 -43
  86. package/src/utils/borsh-schema.ts +0 -38
  87. package/src/utils/cluster.ts +0 -31
  88. package/src/utils/ed25519.ts +0 -43
  89. package/src/utils/index.ts +0 -5
  90. package/src/utils/makeWebsocketUrl.ts +0 -26
  91. package/src/utils/promise-timeout.ts +0 -14
  92. package/src/utils/secp256k1.ts +0 -11
  93. package/src/utils/send-and-confirm-raw-transaction.ts +0 -102
  94. package/src/utils/send-and-confirm-transaction.ts +0 -98
  95. package/src/utils/shortvec-encoding.ts +0 -28
  96. package/src/utils/sleep.ts +0 -4
  97. package/src/utils/to-buffer.ts +0 -11
  98. package/src/validator-info.ts +0 -104
  99. package/src/vote-account.ts +0 -236
@@ -1,543 +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
- * KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342
371
- */
372
- static space: number = process.env.TEST_LIVE ? 3762 : 3731;
373
-
374
- /**
375
- * Generate an Initialize instruction.
376
- */
377
- static initializeAccount(
378
- params: InitializeAccountParams,
379
- ): TransactionInstruction {
380
- const {votePubkey, nodePubkey, voteInit} = params;
381
- const type = VOTE_INSTRUCTION_LAYOUTS.InitializeAccount;
382
- const data = encodeData(type, {
383
- voteInit: {
384
- nodePubkey: toBuffer(voteInit.nodePubkey.toBuffer()),
385
- authorizedVoter: toBuffer(voteInit.authorizedVoter.toBuffer()),
386
- authorizedWithdrawer: toBuffer(
387
- voteInit.authorizedWithdrawer.toBuffer(),
388
- ),
389
- commission: voteInit.commission,
390
- },
391
- });
392
- const instructionData = {
393
- keys: [
394
- {pubkey: votePubkey, isSigner: false, isWritable: true},
395
- {pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},
396
- {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
397
- {pubkey: nodePubkey, isSigner: true, isWritable: false},
398
- ],
399
- programId: this.programId,
400
- data,
401
- };
402
- return new TransactionInstruction(instructionData);
403
- }
404
-
405
- /**
406
- * Generate a transaction that creates a new Vote account.
407
- */
408
- static createAccount(params: CreateVoteAccountParams): Transaction {
409
- const transaction = new Transaction();
410
- transaction.add(
411
- SystemProgram.createAccount({
412
- fromPubkey: params.fromPubkey,
413
- newAccountPubkey: params.votePubkey,
414
- lamports: params.lamports,
415
- space: this.space,
416
- programId: this.programId,
417
- }),
418
- );
419
-
420
- return transaction.add(
421
- this.initializeAccount({
422
- votePubkey: params.votePubkey,
423
- nodePubkey: params.voteInit.nodePubkey,
424
- voteInit: params.voteInit,
425
- }),
426
- );
427
- }
428
-
429
- /**
430
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
431
- */
432
- static authorize(params: AuthorizeVoteParams): Transaction {
433
- const {
434
- votePubkey,
435
- authorizedPubkey,
436
- newAuthorizedPubkey,
437
- voteAuthorizationType,
438
- } = params;
439
-
440
- const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;
441
- const data = encodeData(type, {
442
- newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
443
- voteAuthorizationType: voteAuthorizationType.index,
444
- });
445
-
446
- const keys = [
447
- {pubkey: votePubkey, isSigner: false, isWritable: true},
448
- {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
449
- {pubkey: authorizedPubkey, isSigner: true, isWritable: false},
450
- ];
451
-
452
- return new Transaction().add({
453
- keys,
454
- programId: this.programId,
455
- data,
456
- });
457
- }
458
-
459
- /**
460
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account
461
- * where the current Voter or Withdrawer authority is a derived key.
462
- */
463
- static authorizeWithSeed(params: AuthorizeVoteWithSeedParams): Transaction {
464
- const {
465
- currentAuthorityDerivedKeyBasePubkey,
466
- currentAuthorityDerivedKeyOwnerPubkey,
467
- currentAuthorityDerivedKeySeed,
468
- newAuthorizedPubkey,
469
- voteAuthorizationType,
470
- votePubkey,
471
- } = params;
472
-
473
- const type = VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;
474
- const data = encodeData(type, {
475
- voteAuthorizeWithSeedArgs: {
476
- currentAuthorityDerivedKeyOwnerPubkey: toBuffer(
477
- currentAuthorityDerivedKeyOwnerPubkey.toBuffer(),
478
- ),
479
- currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,
480
- newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),
481
- voteAuthorizationType: voteAuthorizationType.index,
482
- },
483
- });
484
-
485
- const keys = [
486
- {pubkey: votePubkey, isSigner: false, isWritable: true},
487
- {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},
488
- {
489
- pubkey: currentAuthorityDerivedKeyBasePubkey,
490
- isSigner: true,
491
- isWritable: false,
492
- },
493
- ];
494
-
495
- return new Transaction().add({
496
- keys,
497
- programId: this.programId,
498
- data,
499
- });
500
- }
501
-
502
- /**
503
- * Generate a transaction to withdraw from a Vote account.
504
- */
505
- static withdraw(params: WithdrawFromVoteAccountParams): Transaction {
506
- const {votePubkey, authorizedWithdrawerPubkey, lamports, toPubkey} = params;
507
- const type = VOTE_INSTRUCTION_LAYOUTS.Withdraw;
508
- const data = encodeData(type, {lamports});
509
-
510
- const keys = [
511
- {pubkey: votePubkey, isSigner: false, isWritable: true},
512
- {pubkey: toPubkey, isSigner: false, isWritable: true},
513
- {pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},
514
- ];
515
-
516
- return new Transaction().add({
517
- keys,
518
- programId: this.programId,
519
- data,
520
- });
521
- }
522
-
523
- /**
524
- * Generate a transaction to withdraw safely from a Vote account.
525
- *
526
- * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
527
- * checks that the withdraw amount will not exceed the specified balance while leaving enough left
528
- * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
529
- * `withdraw` method directly.
530
- */
531
- static safeWithdraw(
532
- params: WithdrawFromVoteAccountParams,
533
- currentVoteAccountBalance: number,
534
- rentExemptMinimum: number,
535
- ): Transaction {
536
- if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
537
- throw new Error(
538
- 'Withdraw will leave vote account with insuffcient funds.',
539
- );
540
- }
541
- return VoteProgram.withdraw(params);
542
- }
543
- }