@solana/web3.js 1.90.0 → 1.91.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.browser.cjs.js +64 -14
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +64 -14
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +64 -14
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +24 -12
- package/lib/index.esm.js +64 -14
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +474 -93
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +8 -7
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +64 -14
- package/lib/index.native.js.map +1 -1
- package/package.json +5 -62
- package/src/connection.ts +7 -7
- package/src/programs/stake.ts +22 -5
- package/src/programs/vote.ts +46 -3
package/lib/index.d.ts
CHANGED
|
@@ -844,8 +844,8 @@ export class StakeProgram {
|
|
|
844
844
|
* Max space of a Stake account
|
|
845
845
|
*
|
|
846
846
|
* This is generated from the solana-stake-program StakeState struct as
|
|
847
|
-
* `
|
|
848
|
-
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.
|
|
847
|
+
* `StakeStateV2::size_of()`:
|
|
848
|
+
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
|
|
849
849
|
*/
|
|
850
850
|
static space: number;
|
|
851
851
|
/**
|
|
@@ -880,12 +880,12 @@ export class StakeProgram {
|
|
|
880
880
|
/**
|
|
881
881
|
* Generate a Transaction that splits Stake tokens into another stake account
|
|
882
882
|
*/
|
|
883
|
-
static split(params: SplitStakeParams): Transaction;
|
|
883
|
+
static split(params: SplitStakeParams, rentExemptReserve: number): Transaction;
|
|
884
884
|
/**
|
|
885
885
|
* Generate a Transaction that splits Stake tokens into another account
|
|
886
886
|
* derived from a base public key and seed
|
|
887
887
|
*/
|
|
888
|
-
static splitWithSeed(params: SplitStakeWithSeedParams): Transaction;
|
|
888
|
+
static splitWithSeed(params: SplitStakeWithSeedParams, rentExemptReserve?: number): Transaction;
|
|
889
889
|
/**
|
|
890
890
|
* Generate a Transaction that merges Stake accounts.
|
|
891
891
|
*/
|
|
@@ -1274,6 +1274,14 @@ type WithdrawFromVoteAccountParams = {
|
|
|
1274
1274
|
lamports: number;
|
|
1275
1275
|
toPubkey: PublicKey;
|
|
1276
1276
|
};
|
|
1277
|
+
/**
|
|
1278
|
+
* Update validator identity (node pubkey) vote account instruction params.
|
|
1279
|
+
*/
|
|
1280
|
+
type UpdateValidatorIdentityParams = {
|
|
1281
|
+
votePubkey: PublicKey;
|
|
1282
|
+
authorizedWithdrawerPubkey: PublicKey;
|
|
1283
|
+
nodePubkey: PublicKey;
|
|
1284
|
+
};
|
|
1277
1285
|
/**
|
|
1278
1286
|
* Vote Instruction class
|
|
1279
1287
|
*/
|
|
@@ -1302,7 +1310,7 @@ export class VoteInstruction {
|
|
|
1302
1310
|
/**
|
|
1303
1311
|
* An enumeration of valid VoteInstructionType's
|
|
1304
1312
|
*/
|
|
1305
|
-
type VoteInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw';
|
|
1313
|
+
type VoteInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw' | 'UpdateValidatorIdentity';
|
|
1306
1314
|
/**
|
|
1307
1315
|
* VoteAuthorize type
|
|
1308
1316
|
*/
|
|
@@ -1369,6 +1377,10 @@ export class VoteProgram {
|
|
|
1369
1377
|
* `withdraw` method directly.
|
|
1370
1378
|
*/
|
|
1371
1379
|
static safeWithdraw(params: WithdrawFromVoteAccountParams, currentVoteAccountBalance: number, rentExemptMinimum: number): Transaction;
|
|
1380
|
+
/**
|
|
1381
|
+
* Generate a transaction to update the validator identity (node pubkey) of a Vote account.
|
|
1382
|
+
*/
|
|
1383
|
+
static updateValidatorIdentity(params: UpdateValidatorIdentityParams): Transaction;
|
|
1372
1384
|
}
|
|
1373
1385
|
|
|
1374
1386
|
/**
|
|
@@ -3611,7 +3623,7 @@ export class Connection {
|
|
|
3611
3623
|
/**
|
|
3612
3624
|
* Deregister an account notification callback
|
|
3613
3625
|
*
|
|
3614
|
-
* @param
|
|
3626
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
3615
3627
|
*/
|
|
3616
3628
|
removeAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
|
|
3617
3629
|
/**
|
|
@@ -3628,7 +3640,7 @@ export class Connection {
|
|
|
3628
3640
|
/**
|
|
3629
3641
|
* Deregister an account notification callback
|
|
3630
3642
|
*
|
|
3631
|
-
* @param
|
|
3643
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
3632
3644
|
*/
|
|
3633
3645
|
removeProgramAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
|
|
3634
3646
|
/**
|
|
@@ -3638,7 +3650,7 @@ export class Connection {
|
|
|
3638
3650
|
/**
|
|
3639
3651
|
* Deregister a logs callback.
|
|
3640
3652
|
*
|
|
3641
|
-
* @param
|
|
3653
|
+
* @param clientSubscriptionId client subscription id to deregister.
|
|
3642
3654
|
*/
|
|
3643
3655
|
removeOnLogsListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
|
|
3644
3656
|
/**
|
|
@@ -3651,7 +3663,7 @@ export class Connection {
|
|
|
3651
3663
|
/**
|
|
3652
3664
|
* Deregister a slot notification callback
|
|
3653
3665
|
*
|
|
3654
|
-
* @param
|
|
3666
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
3655
3667
|
*/
|
|
3656
3668
|
removeSlotChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
|
|
3657
3669
|
/**
|
|
@@ -3665,7 +3677,7 @@ export class Connection {
|
|
|
3665
3677
|
/**
|
|
3666
3678
|
* Deregister a slot update notification callback
|
|
3667
3679
|
*
|
|
3668
|
-
* @param
|
|
3680
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
3669
3681
|
*/
|
|
3670
3682
|
removeSlotUpdateListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
|
|
3671
3683
|
_buildArgs(args: Array<any>, override?: Commitment, encoding?: 'jsonParsed' | 'base64', extra?: any): Array<any>;
|
|
@@ -3692,7 +3704,7 @@ export class Connection {
|
|
|
3692
3704
|
/**
|
|
3693
3705
|
* Deregister a signature notification callback
|
|
3694
3706
|
*
|
|
3695
|
-
* @param
|
|
3707
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
3696
3708
|
*/
|
|
3697
3709
|
removeSignatureListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
|
|
3698
3710
|
/**
|
|
@@ -3705,7 +3717,7 @@ export class Connection {
|
|
|
3705
3717
|
/**
|
|
3706
3718
|
* Deregister a root notification callback
|
|
3707
3719
|
*
|
|
3708
|
-
* @param
|
|
3720
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
3709
3721
|
*/
|
|
3710
3722
|
removeRootChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
|
|
3711
3723
|
}
|
package/lib/index.esm.js
CHANGED
|
@@ -8366,7 +8366,7 @@ class Connection {
|
|
|
8366
8366
|
/**
|
|
8367
8367
|
* Deregister an account notification callback
|
|
8368
8368
|
*
|
|
8369
|
-
* @param
|
|
8369
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8370
8370
|
*/
|
|
8371
8371
|
async removeAccountChangeListener(clientSubscriptionId) {
|
|
8372
8372
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');
|
|
@@ -8412,7 +8412,7 @@ class Connection {
|
|
|
8412
8412
|
/**
|
|
8413
8413
|
* Deregister an account notification callback
|
|
8414
8414
|
*
|
|
8415
|
-
* @param
|
|
8415
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8416
8416
|
*/
|
|
8417
8417
|
async removeProgramAccountChangeListener(clientSubscriptionId) {
|
|
8418
8418
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');
|
|
@@ -8436,7 +8436,7 @@ class Connection {
|
|
|
8436
8436
|
/**
|
|
8437
8437
|
* Deregister a logs callback.
|
|
8438
8438
|
*
|
|
8439
|
-
* @param
|
|
8439
|
+
* @param clientSubscriptionId client subscription id to deregister.
|
|
8440
8440
|
*/
|
|
8441
8441
|
async removeOnLogsListener(clientSubscriptionId) {
|
|
8442
8442
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');
|
|
@@ -8481,7 +8481,7 @@ class Connection {
|
|
|
8481
8481
|
/**
|
|
8482
8482
|
* Deregister a slot notification callback
|
|
8483
8483
|
*
|
|
8484
|
-
* @param
|
|
8484
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8485
8485
|
*/
|
|
8486
8486
|
async removeSlotChangeListener(clientSubscriptionId) {
|
|
8487
8487
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');
|
|
@@ -8516,7 +8516,7 @@ class Connection {
|
|
|
8516
8516
|
/**
|
|
8517
8517
|
* Deregister a slot update notification callback
|
|
8518
8518
|
*
|
|
8519
|
-
* @param
|
|
8519
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8520
8520
|
*/
|
|
8521
8521
|
async removeSlotUpdateListener(clientSubscriptionId) {
|
|
8522
8522
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');
|
|
@@ -8666,7 +8666,7 @@ class Connection {
|
|
|
8666
8666
|
/**
|
|
8667
8667
|
* Deregister a signature notification callback
|
|
8668
8668
|
*
|
|
8669
|
-
* @param
|
|
8669
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8670
8670
|
*/
|
|
8671
8671
|
async removeSignatureListener(clientSubscriptionId) {
|
|
8672
8672
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');
|
|
@@ -8700,7 +8700,7 @@ class Connection {
|
|
|
8700
8700
|
/**
|
|
8701
8701
|
* Deregister a root notification callback
|
|
8702
8702
|
*
|
|
8703
|
-
* @param
|
|
8703
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8704
8704
|
*/
|
|
8705
8705
|
async removeRootChangeListener(clientSubscriptionId) {
|
|
8706
8706
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');
|
|
@@ -10101,12 +10101,14 @@ class StakeProgram {
|
|
|
10101
10101
|
/**
|
|
10102
10102
|
* Generate a Transaction that splits Stake tokens into another stake account
|
|
10103
10103
|
*/
|
|
10104
|
-
static split(params
|
|
10104
|
+
static split(params,
|
|
10105
|
+
// Compute the cost of allocating the new stake account in lamports
|
|
10106
|
+
rentExemptReserve) {
|
|
10105
10107
|
const transaction = new Transaction();
|
|
10106
10108
|
transaction.add(SystemProgram.createAccount({
|
|
10107
10109
|
fromPubkey: params.authorizedPubkey,
|
|
10108
10110
|
newAccountPubkey: params.splitStakePubkey,
|
|
10109
|
-
lamports:
|
|
10111
|
+
lamports: rentExemptReserve,
|
|
10110
10112
|
space: this.space,
|
|
10111
10113
|
programId: this.programId
|
|
10112
10114
|
}));
|
|
@@ -10117,7 +10119,9 @@ class StakeProgram {
|
|
|
10117
10119
|
* Generate a Transaction that splits Stake tokens into another account
|
|
10118
10120
|
* derived from a base public key and seed
|
|
10119
10121
|
*/
|
|
10120
|
-
static splitWithSeed(params
|
|
10122
|
+
static splitWithSeed(params,
|
|
10123
|
+
// If this stake account is new, compute the cost of allocating it in lamports
|
|
10124
|
+
rentExemptReserve) {
|
|
10121
10125
|
const {
|
|
10122
10126
|
stakePubkey,
|
|
10123
10127
|
authorizedPubkey,
|
|
@@ -10134,6 +10138,13 @@ class StakeProgram {
|
|
|
10134
10138
|
space: this.space,
|
|
10135
10139
|
programId: this.programId
|
|
10136
10140
|
}));
|
|
10141
|
+
if (rentExemptReserve && rentExemptReserve > 0) {
|
|
10142
|
+
transaction.add(SystemProgram.transfer({
|
|
10143
|
+
fromPubkey: params.authorizedPubkey,
|
|
10144
|
+
toPubkey: splitStakePubkey,
|
|
10145
|
+
lamports: rentExemptReserve
|
|
10146
|
+
}));
|
|
10147
|
+
}
|
|
10137
10148
|
return transaction.add(this.splitInstruction({
|
|
10138
10149
|
stakePubkey,
|
|
10139
10150
|
authorizedPubkey,
|
|
@@ -10264,8 +10275,8 @@ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111
|
|
|
10264
10275
|
* Max space of a Stake account
|
|
10265
10276
|
*
|
|
10266
10277
|
* This is generated from the solana-stake-program StakeState struct as
|
|
10267
|
-
* `
|
|
10268
|
-
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.
|
|
10278
|
+
* `StakeStateV2::size_of()`:
|
|
10279
|
+
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
|
|
10269
10280
|
*/
|
|
10270
10281
|
StakeProgram.space = 200;
|
|
10271
10282
|
|
|
@@ -10307,6 +10318,10 @@ class VoteInit {
|
|
|
10307
10318
|
* Withdraw from vote account transaction params
|
|
10308
10319
|
*/
|
|
10309
10320
|
|
|
10321
|
+
/**
|
|
10322
|
+
* Update validator identity (node pubkey) vote account instruction params.
|
|
10323
|
+
*/
|
|
10324
|
+
|
|
10310
10325
|
/**
|
|
10311
10326
|
* Vote Instruction class
|
|
10312
10327
|
*/
|
|
@@ -10453,6 +10468,10 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
10453
10468
|
index: 3,
|
|
10454
10469
|
layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
|
|
10455
10470
|
},
|
|
10471
|
+
UpdateValidatorIdentity: {
|
|
10472
|
+
index: 4,
|
|
10473
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction')])
|
|
10474
|
+
},
|
|
10456
10475
|
AuthorizeWithSeed: {
|
|
10457
10476
|
index: 10,
|
|
10458
10477
|
layout: BufferLayout.struct([BufferLayout.u32('instruction'), voteAuthorizeWithSeedArgs()])
|
|
@@ -10670,10 +10689,41 @@ class VoteProgram {
|
|
|
10670
10689
|
*/
|
|
10671
10690
|
static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {
|
|
10672
10691
|
if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
|
|
10673
|
-
throw new Error('Withdraw will leave vote account with
|
|
10692
|
+
throw new Error('Withdraw will leave vote account with insufficient funds.');
|
|
10674
10693
|
}
|
|
10675
10694
|
return VoteProgram.withdraw(params);
|
|
10676
10695
|
}
|
|
10696
|
+
|
|
10697
|
+
/**
|
|
10698
|
+
* Generate a transaction to update the validator identity (node pubkey) of a Vote account.
|
|
10699
|
+
*/
|
|
10700
|
+
static updateValidatorIdentity(params) {
|
|
10701
|
+
const {
|
|
10702
|
+
votePubkey,
|
|
10703
|
+
authorizedWithdrawerPubkey,
|
|
10704
|
+
nodePubkey
|
|
10705
|
+
} = params;
|
|
10706
|
+
const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
|
|
10707
|
+
const data = encodeData(type);
|
|
10708
|
+
const keys = [{
|
|
10709
|
+
pubkey: votePubkey,
|
|
10710
|
+
isSigner: false,
|
|
10711
|
+
isWritable: true
|
|
10712
|
+
}, {
|
|
10713
|
+
pubkey: nodePubkey,
|
|
10714
|
+
isSigner: true,
|
|
10715
|
+
isWritable: false
|
|
10716
|
+
}, {
|
|
10717
|
+
pubkey: authorizedWithdrawerPubkey,
|
|
10718
|
+
isSigner: true,
|
|
10719
|
+
isWritable: false
|
|
10720
|
+
}];
|
|
10721
|
+
return new Transaction().add({
|
|
10722
|
+
keys,
|
|
10723
|
+
programId: this.programId,
|
|
10724
|
+
data
|
|
10725
|
+
});
|
|
10726
|
+
}
|
|
10677
10727
|
}
|
|
10678
10728
|
VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
|
|
10679
10729
|
/**
|
|
@@ -10685,7 +10735,7 @@ VoteProgram.programId = new PublicKey('Vote1111111111111111111111111111111111111
|
|
|
10685
10735
|
*
|
|
10686
10736
|
* 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
|
|
10687
10737
|
*/
|
|
10688
|
-
VoteProgram.space =
|
|
10738
|
+
VoteProgram.space = 3762;
|
|
10689
10739
|
|
|
10690
10740
|
const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
|
|
10691
10741
|
|