@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.91.0",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
"build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
|
|
44
44
|
"clean": "rimraf ./doc ./declarations ./lib",
|
|
45
45
|
"dev": "cross-env NODE_ENV=development rollup -c --watch",
|
|
46
|
-
"
|
|
46
|
+
"prepublishOnly": "pnpm pkg delete devDependencies",
|
|
47
|
+
"publish-impl": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
48
|
+
"publish-packages": "pnpm publish-impl",
|
|
47
49
|
"test:lint": "eslint src/ test/ --ext .js,.ts",
|
|
48
50
|
"test:lint:fix": "eslint src/ test/ --fix --ext .js,.ts",
|
|
49
51
|
"test:live": "TEST_LIVE=1 pnpm run test:unit:node",
|
|
@@ -56,7 +58,7 @@
|
|
|
56
58
|
"dependencies": {
|
|
57
59
|
"@babel/runtime": "^7.23.4",
|
|
58
60
|
"@noble/curves": "^1.2.0",
|
|
59
|
-
"@noble/hashes": "^1.3.
|
|
61
|
+
"@noble/hashes": "^1.3.3",
|
|
60
62
|
"@solana/buffer-layout": "^4.0.1",
|
|
61
63
|
"agentkeepalive": "^4.5.0",
|
|
62
64
|
"bigint-buffer": "^1.1.5",
|
|
@@ -69,64 +71,5 @@
|
|
|
69
71
|
"node-fetch": "^2.7.0",
|
|
70
72
|
"rpc-websockets": "^7.5.1",
|
|
71
73
|
"superstruct": "^0.14.2"
|
|
72
|
-
},
|
|
73
|
-
"devDependencies": {
|
|
74
|
-
"@babel/core": "^7.23.7",
|
|
75
|
-
"@babel/plugin-transform-class-properties": "^7.23.3",
|
|
76
|
-
"@babel/plugin-transform-private-methods": "^7.23.3",
|
|
77
|
-
"@babel/plugin-transform-private-property-in-object": "^7.23.4",
|
|
78
|
-
"@babel/plugin-transform-runtime": "^7.23.7",
|
|
79
|
-
"@babel/preset-env": "^7.23.3",
|
|
80
|
-
"@babel/preset-typescript": "^7.23.3",
|
|
81
|
-
"@rollup/plugin-alias": "^4.0.3",
|
|
82
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
83
|
-
"@rollup/plugin-commonjs": "^25.0.4",
|
|
84
|
-
"@rollup/plugin-json": "^6.0.1",
|
|
85
|
-
"@rollup/plugin-multi-entry": "^6.0.0",
|
|
86
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
87
|
-
"@rollup/plugin-replace": "^5.0.2",
|
|
88
|
-
"@rollup/plugin-terser": "^0.4.3",
|
|
89
|
-
"@solana/spl-token": "^0.4.0",
|
|
90
|
-
"@types/bn.js": "^5.1.1",
|
|
91
|
-
"@types/bs58": "^4.0.1",
|
|
92
|
-
"@types/chai": "^4.3.5",
|
|
93
|
-
"@types/chai-as-promised": "^7.1.8",
|
|
94
|
-
"@types/express-serve-static-core": "^4.17.41",
|
|
95
|
-
"@types/mocha": "^10.0.6",
|
|
96
|
-
"@types/mz": "^2.7.4",
|
|
97
|
-
"@types/node": "18.11.19",
|
|
98
|
-
"@types/node-fetch": "2",
|
|
99
|
-
"@types/sinon": "^10.0.16",
|
|
100
|
-
"@types/sinon-chai": "^3.2.12",
|
|
101
|
-
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
|
102
|
-
"@typescript-eslint/parser": "^6.3.0",
|
|
103
|
-
"chai": "^4.3.7",
|
|
104
|
-
"chai-as-promised": "^7.1.1",
|
|
105
|
-
"cross-env": "7.0.3",
|
|
106
|
-
"eslint": "^8.45.0",
|
|
107
|
-
"eslint-config-prettier": "^9.1.0",
|
|
108
|
-
"eslint-plugin-import": "^2.29.0",
|
|
109
|
-
"eslint-plugin-mocha": "^10.1.0",
|
|
110
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
111
|
-
"esm": "^3.2.25",
|
|
112
|
-
"mocha": "^10.2.0",
|
|
113
|
-
"mockttp": "^3.10.0",
|
|
114
|
-
"mz": "^2.7.0",
|
|
115
|
-
"node-abort-controller": "^3.0.1",
|
|
116
|
-
"prettier": "^3.1",
|
|
117
|
-
"rimraf": "5.0.5",
|
|
118
|
-
"rollup": "^4.7.0",
|
|
119
|
-
"rollup-plugin-dts": "^6.1.0",
|
|
120
|
-
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
121
|
-
"semantic-release": "^21.0.7",
|
|
122
|
-
"sinon": "^15.2.0",
|
|
123
|
-
"sinon-chai": "^3.7.0",
|
|
124
|
-
"start-server-and-test": "^2.0.0",
|
|
125
|
-
"ts-mocha": "^10.0.0",
|
|
126
|
-
"ts-node": "^10.9.1",
|
|
127
|
-
"tsconfig": "workspace:*",
|
|
128
|
-
"tslib": "^2.6.2",
|
|
129
|
-
"typedoc": "^0.25.4",
|
|
130
|
-
"typescript": "^5.1.6"
|
|
131
74
|
}
|
|
132
75
|
}
|
package/src/connection.ts
CHANGED
|
@@ -6355,7 +6355,7 @@ export class Connection {
|
|
|
6355
6355
|
/**
|
|
6356
6356
|
* Deregister an account notification callback
|
|
6357
6357
|
*
|
|
6358
|
-
* @param
|
|
6358
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
6359
6359
|
*/
|
|
6360
6360
|
async removeAccountChangeListener(
|
|
6361
6361
|
clientSubscriptionId: ClientSubscriptionId,
|
|
@@ -6418,7 +6418,7 @@ export class Connection {
|
|
|
6418
6418
|
/**
|
|
6419
6419
|
* Deregister an account notification callback
|
|
6420
6420
|
*
|
|
6421
|
-
* @param
|
|
6421
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
6422
6422
|
*/
|
|
6423
6423
|
async removeProgramAccountChangeListener(
|
|
6424
6424
|
clientSubscriptionId: ClientSubscriptionId,
|
|
@@ -6454,7 +6454,7 @@ export class Connection {
|
|
|
6454
6454
|
/**
|
|
6455
6455
|
* Deregister a logs callback.
|
|
6456
6456
|
*
|
|
6457
|
-
* @param
|
|
6457
|
+
* @param clientSubscriptionId client subscription id to deregister.
|
|
6458
6458
|
*/
|
|
6459
6459
|
async removeOnLogsListener(
|
|
6460
6460
|
clientSubscriptionId: ClientSubscriptionId,
|
|
@@ -6501,7 +6501,7 @@ export class Connection {
|
|
|
6501
6501
|
/**
|
|
6502
6502
|
* Deregister a slot notification callback
|
|
6503
6503
|
*
|
|
6504
|
-
* @param
|
|
6504
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
6505
6505
|
*/
|
|
6506
6506
|
async removeSlotChangeListener(
|
|
6507
6507
|
clientSubscriptionId: ClientSubscriptionId,
|
|
@@ -6544,7 +6544,7 @@ export class Connection {
|
|
|
6544
6544
|
/**
|
|
6545
6545
|
* Deregister a slot update notification callback
|
|
6546
6546
|
*
|
|
6547
|
-
* @param
|
|
6547
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
6548
6548
|
*/
|
|
6549
6549
|
async removeSlotUpdateListener(
|
|
6550
6550
|
clientSubscriptionId: ClientSubscriptionId,
|
|
@@ -6743,7 +6743,7 @@ export class Connection {
|
|
|
6743
6743
|
/**
|
|
6744
6744
|
* Deregister a signature notification callback
|
|
6745
6745
|
*
|
|
6746
|
-
* @param
|
|
6746
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
6747
6747
|
*/
|
|
6748
6748
|
async removeSignatureListener(
|
|
6749
6749
|
clientSubscriptionId: ClientSubscriptionId,
|
|
@@ -6782,7 +6782,7 @@ export class Connection {
|
|
|
6782
6782
|
/**
|
|
6783
6783
|
* Deregister a root notification callback
|
|
6784
6784
|
*
|
|
6785
|
-
* @param
|
|
6785
|
+
* @param clientSubscriptionId client subscription id to deregister
|
|
6786
6786
|
*/
|
|
6787
6787
|
async removeRootChangeListener(
|
|
6788
6788
|
clientSubscriptionId: ClientSubscriptionId,
|
package/src/programs/stake.ts
CHANGED
|
@@ -601,8 +601,8 @@ export class StakeProgram {
|
|
|
601
601
|
* Max space of a Stake account
|
|
602
602
|
*
|
|
603
603
|
* This is generated from the solana-stake-program StakeState struct as
|
|
604
|
-
* `
|
|
605
|
-
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.
|
|
604
|
+
* `StakeStateV2::size_of()`:
|
|
605
|
+
* https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html
|
|
606
606
|
*/
|
|
607
607
|
static space: number = 200;
|
|
608
608
|
|
|
@@ -808,13 +808,17 @@ export class StakeProgram {
|
|
|
808
808
|
/**
|
|
809
809
|
* Generate a Transaction that splits Stake tokens into another stake account
|
|
810
810
|
*/
|
|
811
|
-
static split(
|
|
811
|
+
static split(
|
|
812
|
+
params: SplitStakeParams,
|
|
813
|
+
// Compute the cost of allocating the new stake account in lamports
|
|
814
|
+
rentExemptReserve: number,
|
|
815
|
+
): Transaction {
|
|
812
816
|
const transaction = new Transaction();
|
|
813
817
|
transaction.add(
|
|
814
818
|
SystemProgram.createAccount({
|
|
815
819
|
fromPubkey: params.authorizedPubkey,
|
|
816
820
|
newAccountPubkey: params.splitStakePubkey,
|
|
817
|
-
lamports:
|
|
821
|
+
lamports: rentExemptReserve,
|
|
818
822
|
space: this.space,
|
|
819
823
|
programId: this.programId,
|
|
820
824
|
}),
|
|
@@ -826,7 +830,11 @@ export class StakeProgram {
|
|
|
826
830
|
* Generate a Transaction that splits Stake tokens into another account
|
|
827
831
|
* derived from a base public key and seed
|
|
828
832
|
*/
|
|
829
|
-
static splitWithSeed(
|
|
833
|
+
static splitWithSeed(
|
|
834
|
+
params: SplitStakeWithSeedParams,
|
|
835
|
+
// If this stake account is new, compute the cost of allocating it in lamports
|
|
836
|
+
rentExemptReserve?: number,
|
|
837
|
+
): Transaction {
|
|
830
838
|
const {
|
|
831
839
|
stakePubkey,
|
|
832
840
|
authorizedPubkey,
|
|
@@ -845,6 +853,15 @@ export class StakeProgram {
|
|
|
845
853
|
programId: this.programId,
|
|
846
854
|
}),
|
|
847
855
|
);
|
|
856
|
+
if (rentExemptReserve && rentExemptReserve > 0) {
|
|
857
|
+
transaction.add(
|
|
858
|
+
SystemProgram.transfer({
|
|
859
|
+
fromPubkey: params.authorizedPubkey,
|
|
860
|
+
toPubkey: splitStakePubkey,
|
|
861
|
+
lamports: rentExemptReserve,
|
|
862
|
+
}),
|
|
863
|
+
);
|
|
864
|
+
}
|
|
848
865
|
return transaction.add(
|
|
849
866
|
this.splitInstruction({
|
|
850
867
|
stakePubkey,
|
package/src/programs/vote.ts
CHANGED
|
@@ -87,6 +87,15 @@ export type WithdrawFromVoteAccountParams = {
|
|
|
87
87
|
toPubkey: PublicKey;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Update validator identity (node pubkey) vote account instruction params.
|
|
92
|
+
*/
|
|
93
|
+
export type UpdateValidatorIdentityParams = {
|
|
94
|
+
votePubkey: PublicKey;
|
|
95
|
+
authorizedWithdrawerPubkey: PublicKey;
|
|
96
|
+
nodePubkey: PublicKey;
|
|
97
|
+
};
|
|
98
|
+
|
|
90
99
|
/**
|
|
91
100
|
* Vote Instruction class
|
|
92
101
|
*/
|
|
@@ -258,7 +267,11 @@ export type VoteInstructionType =
|
|
|
258
267
|
// It would be preferable for this type to be `keyof VoteInstructionInputData`
|
|
259
268
|
// but Typedoc does not transpile `keyof` expressions.
|
|
260
269
|
// See https://github.com/TypeStrong/typedoc/issues/1894
|
|
261
|
-
|
|
270
|
+
| 'Authorize'
|
|
271
|
+
| 'AuthorizeWithSeed'
|
|
272
|
+
| 'InitializeAccount'
|
|
273
|
+
| 'Withdraw'
|
|
274
|
+
| 'UpdateValidatorIdentity';
|
|
262
275
|
|
|
263
276
|
/** @internal */
|
|
264
277
|
export type VoteAuthorizeWithSeedArgs = Readonly<{
|
|
@@ -286,6 +299,7 @@ type VoteInstructionInputData = {
|
|
|
286
299
|
Withdraw: IInstructionInputData & {
|
|
287
300
|
lamports: number;
|
|
288
301
|
};
|
|
302
|
+
UpdateValidatorIdentity: IInstructionInputData;
|
|
289
303
|
};
|
|
290
304
|
|
|
291
305
|
const VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{
|
|
@@ -315,6 +329,12 @@ const VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{
|
|
|
315
329
|
BufferLayout.ns64('lamports'),
|
|
316
330
|
]),
|
|
317
331
|
},
|
|
332
|
+
UpdateValidatorIdentity: {
|
|
333
|
+
index: 4,
|
|
334
|
+
layout: BufferLayout.struct<
|
|
335
|
+
VoteInstructionInputData['UpdateValidatorIdentity']
|
|
336
|
+
>([BufferLayout.u32('instruction')]),
|
|
337
|
+
},
|
|
318
338
|
AuthorizeWithSeed: {
|
|
319
339
|
index: 10,
|
|
320
340
|
layout: BufferLayout.struct<VoteInstructionInputData['AuthorizeWithSeed']>([
|
|
@@ -369,7 +389,7 @@ export class VoteProgram {
|
|
|
369
389
|
*
|
|
370
390
|
* 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
391
|
*/
|
|
372
|
-
static space: number =
|
|
392
|
+
static space: number = 3762;
|
|
373
393
|
|
|
374
394
|
/**
|
|
375
395
|
* Generate an Initialize instruction.
|
|
@@ -535,9 +555,32 @@ export class VoteProgram {
|
|
|
535
555
|
): Transaction {
|
|
536
556
|
if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {
|
|
537
557
|
throw new Error(
|
|
538
|
-
'Withdraw will leave vote account with
|
|
558
|
+
'Withdraw will leave vote account with insufficient funds.',
|
|
539
559
|
);
|
|
540
560
|
}
|
|
541
561
|
return VoteProgram.withdraw(params);
|
|
542
562
|
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Generate a transaction to update the validator identity (node pubkey) of a Vote account.
|
|
566
|
+
*/
|
|
567
|
+
static updateValidatorIdentity(
|
|
568
|
+
params: UpdateValidatorIdentityParams,
|
|
569
|
+
): Transaction {
|
|
570
|
+
const {votePubkey, authorizedWithdrawerPubkey, nodePubkey} = params;
|
|
571
|
+
const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;
|
|
572
|
+
const data = encodeData(type);
|
|
573
|
+
|
|
574
|
+
const keys = [
|
|
575
|
+
{pubkey: votePubkey, isSigner: false, isWritable: true},
|
|
576
|
+
{pubkey: nodePubkey, isSigner: true, isWritable: false},
|
|
577
|
+
{pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},
|
|
578
|
+
];
|
|
579
|
+
|
|
580
|
+
return new Transaction().add({
|
|
581
|
+
keys,
|
|
582
|
+
programId: this.programId,
|
|
583
|
+
data,
|
|
584
|
+
});
|
|
585
|
+
}
|
|
543
586
|
}
|