@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.browser.esm.js
CHANGED
|
@@ -7673,7 +7673,7 @@ class Connection {
|
|
|
7673
7673
|
/**
|
|
7674
7674
|
* Deregister an account notification callback
|
|
7675
7675
|
*
|
|
7676
|
-
* @param
|
|
7676
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
7677
7677
|
*/
|
|
7678
7678
|
async removeAccountChangeListener(clientSubscriptionId) {
|
|
7679
7679
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');
|
|
@@ -7719,7 +7719,7 @@ class Connection {
|
|
|
7719
7719
|
/**
|
|
7720
7720
|
* Deregister an account notification callback
|
|
7721
7721
|
*
|
|
7722
|
-
* @param
|
|
7722
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
7723
7723
|
*/
|
|
7724
7724
|
async removeProgramAccountChangeListener(clientSubscriptionId) {
|
|
7725
7725
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');
|
|
@@ -7743,7 +7743,7 @@ class Connection {
|
|
|
7743
7743
|
/**
|
|
7744
7744
|
* Deregister a logs callback.
|
|
7745
7745
|
*
|
|
7746
|
-
* @param
|
|
7746
|
+
* @param clientSubscriptionId client subscription id to deregister.
|
|
7747
7747
|
*/
|
|
7748
7748
|
async removeOnLogsListener(clientSubscriptionId) {
|
|
7749
7749
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');
|
|
@@ -7788,7 +7788,7 @@ class Connection {
|
|
|
7788
7788
|
/**
|
|
7789
7789
|
* Deregister a slot notification callback
|
|
7790
7790
|
*
|
|
7791
|
-
* @param
|
|
7791
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
7792
7792
|
*/
|
|
7793
7793
|
async removeSlotChangeListener(clientSubscriptionId) {
|
|
7794
7794
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');
|
|
@@ -7823,7 +7823,7 @@ class Connection {
|
|
|
7823
7823
|
/**
|
|
7824
7824
|
* Deregister a slot update notification callback
|
|
7825
7825
|
*
|
|
7826
|
-
* @param
|
|
7826
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
7827
7827
|
*/
|
|
7828
7828
|
async removeSlotUpdateListener(clientSubscriptionId) {
|
|
7829
7829
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');
|
|
@@ -7973,7 +7973,7 @@ class Connection {
|
|
|
7973
7973
|
/**
|
|
7974
7974
|
* Deregister a signature notification callback
|
|
7975
7975
|
*
|
|
7976
|
-
* @param
|
|
7976
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
7977
7977
|
*/
|
|
7978
7978
|
async removeSignatureListener(clientSubscriptionId) {
|
|
7979
7979
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');
|
|
@@ -8007,7 +8007,7 @@ class Connection {
|
|
|
8007
8007
|
/**
|
|
8008
8008
|
* Deregister a root notification callback
|
|
8009
8009
|
*
|
|
8010
|
-
* @param
|
|
8010
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
8011
8011
|
*/
|
|
8012
8012
|
async removeRootChangeListener(clientSubscriptionId) {
|
|
8013
8013
|
await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');
|
|
@@ -9408,12 +9408,14 @@ class StakeProgram {
|
|
|
9408
9408
|
/**
|
|
9409
9409
|
* Generate a Transaction that splits Stake tokens into another stake account
|
|
9410
9410
|
*/
|
|
9411
|
-
static split(params
|
|
9411
|
+
static split(params,
|
|
9412
|
+
// Compute the cost of allocating the new stake account in lamports
|
|
9413
|
+
rentExemptReserve) {
|
|
9412
9414
|
const transaction = new Transaction();
|
|
9413
9415
|
transaction.add(SystemProgram.createAccount({
|
|
9414
9416
|
fromPubkey: params.authorizedPubkey,
|
|
9415
9417
|
newAccountPubkey: params.splitStakePubkey,
|
|
9416
|
-
lamports:
|
|
9418
|
+
lamports: rentExemptReserve,
|
|
9417
9419
|
space: this.space,
|
|
9418
9420
|
programId: this.programId
|
|
9419
9421
|
}));
|
|
@@ -9424,7 +9426,9 @@ class StakeProgram {
|
|
|
9424
9426
|
* Generate a Transaction that splits Stake tokens into another account
|
|
9425
9427
|
* derived from a base public key and seed
|
|
9426
9428
|
*/
|
|
9427
|
-
static splitWithSeed(params
|
|
9429
|
+
static splitWithSeed(params,
|
|
9430
|
+
// If this stake account is new, compute the cost of allocating it in lamports
|
|
9431
|
+
rentExemptReserve) {
|
|
9428
9432
|
const {
|
|
9429
9433
|
stakePubkey,
|
|
9430
9434
|
authorizedPubkey,
|
|
@@ -9441,6 +9445,13 @@ class StakeProgram {
|
|
|
9441
9445
|
space: this.space,
|
|
9442
9446
|
programId: this.programId
|
|
9443
9447
|
}));
|
|
9448
|
+
if (rentExemptReserve && rentExemptReserve > 0) {
|
|
9449
|
+
transaction.add(SystemProgram.transfer({
|
|
9450
|
+
fromPubkey: params.authorizedPubkey,
|
|
9451
|
+
toPubkey: splitStakePubkey,
|
|
9452
|
+
lamports: rentExemptReserve
|
|
9453
|
+
}));
|
|
9454
|
+
}
|
|
9444
9455
|
return transaction.add(this.splitInstruction({
|
|
9445
9456
|
stakePubkey,
|
|
9446
9457
|
authorizedPubkey,
|
|
@@ -9571,8 +9582,8 @@ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111
|
|
|
9571
9582
|
* Max space of a Stake account
|
|
9572
9583
|
*
|
|
9573
9584
|
* This is generated from the solana-stake-program StakeState struct as
|
|
9574
|
-
* `
|
|
9575
|
-
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.
|
|
9585
|
+
* `StakeStateV2::size_of()`:
|
|
9586
|
+
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
|
|
9576
9587
|
*/
|
|
9577
9588
|
StakeProgram.space = 200;
|
|
9578
9589
|
|
|
@@ -9614,6 +9625,10 @@ class VoteInit {
|
|
|
9614
9625
|
* Withdraw from vote account transaction params
|
|
9615
9626
|
*/
|
|
9616
9627
|
|
|
9628
|
+
/**
|
|
9629
|
+
* Update validator identity (node pubkey) vote account instruction params.
|
|
9630
|
+
*/
|
|
9631
|
+
|
|
9617
9632
|
/**
|
|
9618
9633
|
* Vote Instruction class
|
|
9619
9634
|
*/
|
|
@@ -9760,6 +9775,10 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
9760
9775
|
index: 3,
|
|
9761
9776
|
layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])
|
|
9762
9777
|
},
|
|
9778
|
+
UpdateValidatorIdentity: {
|
|
9779
|
+
index: 4,
|
|
9780
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction')])
|
|
9781
|
+
},
|
|
9763
9782
|
AuthorizeWithSeed: {
|
|
9764
9783
|
index: 10,
|
|
9765
9784
|
layout: BufferLayout.struct([BufferLayout.u32('instruction'), voteAuthorizeWithSeedArgs()])
|
|
@@ -9977,10 +9996,41 @@ class VoteProgram {
|
|
|
9977
9996
|
*/
|
|
9978
9997
|
static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {
|
|
9979
9998
|
if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
|
|
9980
|
-
throw new Error('Withdraw will leave vote account with
|
|
9999
|
+
throw new Error('Withdraw will leave vote account with insufficient funds.');
|
|
9981
10000
|
}
|
|
9982
10001
|
return VoteProgram.withdraw(params);
|
|
9983
10002
|
}
|
|
10003
|
+
|
|
10004
|
+
/**
|
|
10005
|
+
* Generate a transaction to update the validator identity (node pubkey) of a Vote account.
|
|
10006
|
+
*/
|
|
10007
|
+
static updateValidatorIdentity(params) {
|
|
10008
|
+
const {
|
|
10009
|
+
votePubkey,
|
|
10010
|
+
authorizedWithdrawerPubkey,
|
|
10011
|
+
nodePubkey
|
|
10012
|
+
} = params;
|
|
10013
|
+
const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
|
|
10014
|
+
const data = encodeData(type);
|
|
10015
|
+
const keys = [{
|
|
10016
|
+
pubkey: votePubkey,
|
|
10017
|
+
isSigner: false,
|
|
10018
|
+
isWritable: true
|
|
10019
|
+
}, {
|
|
10020
|
+
pubkey: nodePubkey,
|
|
10021
|
+
isSigner: true,
|
|
10022
|
+
isWritable: false
|
|
10023
|
+
}, {
|
|
10024
|
+
pubkey: authorizedWithdrawerPubkey,
|
|
10025
|
+
isSigner: true,
|
|
10026
|
+
isWritable: false
|
|
10027
|
+
}];
|
|
10028
|
+
return new Transaction().add({
|
|
10029
|
+
keys,
|
|
10030
|
+
programId: this.programId,
|
|
10031
|
+
data
|
|
10032
|
+
});
|
|
10033
|
+
}
|
|
9984
10034
|
}
|
|
9985
10035
|
VoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');
|
|
9986
10036
|
/**
|
|
@@ -9992,7 +10042,7 @@ VoteProgram.programId = new PublicKey('Vote1111111111111111111111111111111111111
|
|
|
9992
10042
|
*
|
|
9993
10043
|
* 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
|
|
9994
10044
|
*/
|
|
9995
|
-
VoteProgram.space =
|
|
10045
|
+
VoteProgram.space = 3762;
|
|
9996
10046
|
|
|
9997
10047
|
const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
|
|
9998
10048
|
|