@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.cjs.js
CHANGED
|
@@ -8398,7 +8398,7 @@ class Connection {
|
|
|
8398
8398
|
/**
|
|
8399
8399
|
* Deregister an account notification callback
|
|
8400
8400
|
*
|
|
8401
|
-
* @param
|
|
8401
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8402
8402
|
*/
|
|
8403
8403
|
async removeAccountChangeListener(clientSubscriptionId) {
|
|
8404
8404
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');
|
|
@@ -8444,7 +8444,7 @@ class Connection {
|
|
|
8444
8444
|
/**
|
|
8445
8445
|
* Deregister an account notification callback
|
|
8446
8446
|
*
|
|
8447
|
-
* @param
|
|
8447
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8448
8448
|
*/
|
|
8449
8449
|
async removeProgramAccountChangeListener(clientSubscriptionId) {
|
|
8450
8450
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');
|
|
@@ -8468,7 +8468,7 @@ class Connection {
|
|
|
8468
8468
|
/**
|
|
8469
8469
|
* Deregister a logs callback.
|
|
8470
8470
|
*
|
|
8471
|
-
* @param
|
|
8471
|
+
* @param clientSubscriptionId client subscription id to deregister.
|
|
8472
8472
|
*/
|
|
8473
8473
|
async removeOnLogsListener(clientSubscriptionId) {
|
|
8474
8474
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');
|
|
@@ -8513,7 +8513,7 @@ class Connection {
|
|
|
8513
8513
|
/**
|
|
8514
8514
|
* Deregister a slot notification callback
|
|
8515
8515
|
*
|
|
8516
|
-
* @param
|
|
8516
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8517
8517
|
*/
|
|
8518
8518
|
async removeSlotChangeListener(clientSubscriptionId) {
|
|
8519
8519
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');
|
|
@@ -8548,7 +8548,7 @@ class Connection {
|
|
|
8548
8548
|
/**
|
|
8549
8549
|
* Deregister a slot update notification callback
|
|
8550
8550
|
*
|
|
8551
|
-
* @param
|
|
8551
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8552
8552
|
*/
|
|
8553
8553
|
async removeSlotUpdateListener(clientSubscriptionId) {
|
|
8554
8554
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');
|
|
@@ -8698,7 +8698,7 @@ class Connection {
|
|
|
8698
8698
|
/**
|
|
8699
8699
|
* Deregister a signature notification callback
|
|
8700
8700
|
*
|
|
8701
|
-
* @param
|
|
8701
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8702
8702
|
*/
|
|
8703
8703
|
async removeSignatureListener(clientSubscriptionId) {
|
|
8704
8704
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');
|
|
@@ -8732,7 +8732,7 @@ class Connection {
|
|
|
8732
8732
|
/**
|
|
8733
8733
|
* Deregister a root notification callback
|
|
8734
8734
|
*
|
|
8735
|
-
* @param
|
|
8735
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8736
8736
|
*/
|
|
8737
8737
|
async removeRootChangeListener(clientSubscriptionId) {
|
|
8738
8738
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');
|
|
@@ -10133,12 +10133,14 @@ class StakeProgram {
|
|
|
10133
10133
|
/**
|
|
10134
10134
|
* Generate a Transaction that splits Stake tokens into another stake account
|
|
10135
10135
|
*/
|
|
10136
|
-
static split(params
|
|
10136
|
+
static split(params,
|
|
10137
|
+
// Compute the cost of allocating the new stake account in lamports
|
|
10138
|
+
rentExemptReserve) {
|
|
10137
10139
|
const transaction = new Transaction();
|
|
10138
10140
|
transaction.add(SystemProgram.createAccount({
|
|
10139
10141
|
fromPubkey: params.authorizedPubkey,
|
|
10140
10142
|
newAccountPubkey: params.splitStakePubkey,
|
|
10141
|
-
lamports:
|
|
10143
|
+
lamports: rentExemptReserve,
|
|
10142
10144
|
space: this.space,
|
|
10143
10145
|
programId: this.programId
|
|
10144
10146
|
}));
|
|
@@ -10149,7 +10151,9 @@ class StakeProgram {
|
|
|
10149
10151
|
* Generate a Transaction that splits Stake tokens into another account
|
|
10150
10152
|
* derived from a base public key and seed
|
|
10151
10153
|
*/
|
|
10152
|
-
static splitWithSeed(params
|
|
10154
|
+
static splitWithSeed(params,
|
|
10155
|
+
// If this stake account is new, compute the cost of allocating it in lamports
|
|
10156
|
+
rentExemptReserve) {
|
|
10153
10157
|
const {
|
|
10154
10158
|
stakePubkey,
|
|
10155
10159
|
authorizedPubkey,
|
|
@@ -10166,6 +10170,13 @@ class StakeProgram {
|
|
|
10166
10170
|
space: this.space,
|
|
10167
10171
|
programId: this.programId
|
|
10168
10172
|
}));
|
|
10173
|
+
if (rentExemptReserve && rentExemptReserve > 0) {
|
|
10174
|
+
transaction.add(SystemProgram.transfer({
|
|
10175
|
+
fromPubkey: params.authorizedPubkey,
|
|
10176
|
+
toPubkey: splitStakePubkey,
|
|
10177
|
+
lamports: rentExemptReserve
|
|
10178
|
+
}));
|
|
10179
|
+
}
|
|
10169
10180
|
return transaction.add(this.splitInstruction({
|
|
10170
10181
|
stakePubkey,
|
|
10171
10182
|
authorizedPubkey,
|
|
@@ -10296,8 +10307,8 @@ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111
|
|
|
10296
10307
|
* Max space of a Stake account
|
|
10297
10308
|
*
|
|
10298
10309
|
* This is generated from the solana-stake-program StakeState struct as
|
|
10299
|
-
* `
|
|
10300
|
-
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.
|
|
10310
|
+
* `StakeStateV2::size_of()`:
|
|
10311
|
+
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
|
|
10301
10312
|
*/
|
|
10302
10313
|
StakeProgram.space = 200;
|
|
10303
10314
|
|
|
@@ -10339,6 +10350,10 @@ class VoteInit {
|
|
|
10339
10350
|
* Withdraw from vote account transaction params
|
|
10340
10351
|
*/
|
|
10341
10352
|
|
|
10353
|
+
/**
|
|
10354
|
+
* Update validator identity (node pubkey) vote account instruction params.
|
|
10355
|
+
*/
|
|
10356
|
+
|
|
10342
10357
|
/**
|
|
10343
10358
|
* Vote Instruction class
|
|
10344
10359
|
*/
|
|
@@ -10485,6 +10500,10 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
10485
10500
|
index: 3,
|
|
10486
10501
|
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), BufferLayout__namespace.ns64('lamports')])
|
|
10487
10502
|
},
|
|
10503
|
+
UpdateValidatorIdentity: {
|
|
10504
|
+
index: 4,
|
|
10505
|
+
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction')])
|
|
10506
|
+
},
|
|
10488
10507
|
AuthorizeWithSeed: {
|
|
10489
10508
|
index: 10,
|
|
10490
10509
|
layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), voteAuthorizeWithSeedArgs()])
|
|
@@ -10702,10 +10721,41 @@ class VoteProgram {
|
|
|
10702
10721
|
*/
|
|
10703
10722
|
static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {
|
|
10704
10723
|
if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
|
|
10705
|
-
throw new Error('Withdraw will leave vote account with
|
|
10724
|
+
throw new Error('Withdraw will leave vote account with insufficient funds.');
|
|
10706
10725
|
}
|
|
10707
10726
|
return VoteProgram.withdraw(params);
|
|
10708
10727
|
}
|
|
10728
|
+
|
|
10729
|
+
/**
|
|
10730
|
+
* Generate a transaction to update the validator identity (node pubkey) of a Vote account.
|
|
10731
|
+
*/
|
|
10732
|
+
static updateValidatorIdentity(params) {
|
|
10733
|
+
const {
|
|
10734
|
+
votePubkey,
|
|
10735
|
+
authorizedWithdrawerPubkey,
|
|
10736
|
+
nodePubkey
|
|
10737
|
+
} = params;
|
|
10738
|
+
const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
|
|
10739
|
+
const data = encodeData(type);
|
|
10740
|
+
const keys = [{
|
|
10741
|
+
pubkey: votePubkey,
|
|
10742
|
+
isSigner: false,
|
|
10743
|
+
isWritable: true
|
|
10744
|
+
}, {
|
|
10745
|
+
pubkey: nodePubkey,
|
|
10746
|
+
isSigner: true,
|
|
10747
|
+
isWritable: false
|
|
10748
|
+
}, {
|
|
10749
|
+
pubkey: authorizedWithdrawerPubkey,
|
|
10750
|
+
isSigner: true,
|
|
10751
|
+
isWritable: false
|
|
10752
|
+
}];
|
|
10753
|
+
return new Transaction().add({
|
|
10754
|
+
keys,
|
|
10755
|
+
programId: this.programId,
|
|
10756
|
+
data
|
|
10757
|
+
});
|
|
10758
|
+
}
|
|
10709
10759
|
}
|
|
10710
10760
|
VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
|
|
10711
10761
|
/**
|
|
@@ -10717,7 +10767,7 @@ VoteProgram.programId = new PublicKey('Vote1111111111111111111111111111111111111
|
|
|
10717
10767
|
*
|
|
10718
10768
|
* 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
|
|
10719
10769
|
*/
|
|
10720
|
-
VoteProgram.space =
|
|
10770
|
+
VoteProgram.space = 3762;
|
|
10721
10771
|
|
|
10722
10772
|
const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
|
|
10723
10773
|
|