@solana/web3.js 1.78.0 → 1.78.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.78.0",
3
+ "version": "1.78.2",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -54,24 +54,24 @@
54
54
  "test:unit:node": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'"
55
55
  },
56
56
  "dependencies": {
57
- "@babel/runtime": "^7.22.3",
57
+ "@babel/runtime": "^7.22.6",
58
58
  "@noble/curves": "^1.0.0",
59
59
  "@noble/hashes": "^1.3.0",
60
60
  "@solana/buffer-layout": "^4.0.0",
61
61
  "agentkeepalive": "^4.2.1",
62
62
  "bigint-buffer": "^1.1.5",
63
- "bn.js": "^5.0.0",
63
+ "bn.js": "^5.2.1",
64
64
  "borsh": "^0.7.0",
65
65
  "bs58": "^4.0.1",
66
66
  "buffer": "6.0.3",
67
67
  "fast-stable-stringify": "^1.0.0",
68
68
  "jayson": "^4.1.0",
69
- "node-fetch": "^2.6.11",
69
+ "node-fetch": "^2.6.12",
70
70
  "rpc-websockets": "^7.5.1",
71
71
  "superstruct": "^0.14.2"
72
72
  },
73
73
  "devDependencies": {
74
- "@babel/core": "^7.12.13",
74
+ "@babel/core": "^7.22.9",
75
75
  "@babel/plugin-proposal-class-properties": "^7.12.1",
76
76
  "@babel/plugin-proposal-private-methods": "^7.18.6",
77
77
  "@babel/plugin-transform-runtime": "^7.12.10",
@@ -82,50 +82,50 @@
82
82
  "@rollup/plugin-commonjs": "^25.0.0",
83
83
  "@rollup/plugin-json": "^6.0.0",
84
84
  "@rollup/plugin-multi-entry": "^6.0.0",
85
- "@rollup/plugin-node-resolve": "^15.0.1",
85
+ "@rollup/plugin-node-resolve": "^15.1.0",
86
86
  "@rollup/plugin-replace": "^5.0.2",
87
87
  "@rollup/plugin-terser": "^0.4.3",
88
- "@solana/spl-token": "^0.3.7",
89
- "@types/bn.js": "^5.1.0",
88
+ "@solana/spl-token": "^0.3.8",
89
+ "@types/bn.js": "^5.1.1",
90
90
  "@types/bs58": "^4.0.1",
91
91
  "@types/chai": "^4.3.5",
92
92
  "@types/chai-as-promised": "^7.1.3",
93
93
  "@types/express-serve-static-core": "^4.17.35",
94
- "@types/mocha": "^10.0.0",
95
- "@types/mz": "^2.7.3",
96
- "@types/node": "^18.11.10",
94
+ "@types/mocha": "^10.0.1",
95
+ "@types/mz": "^2.7.4",
96
+ "@types/node": "^20.4.4",
97
97
  "@types/node-fetch": "2",
98
98
  "@types/sinon": "^10.0.0",
99
99
  "@types/sinon-chai": "^3.2.8",
100
- "@typescript-eslint/eslint-plugin": "^5.57.1",
101
- "@typescript-eslint/parser": "^5.57.1",
100
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
101
+ "@typescript-eslint/parser": "^6.0.0",
102
102
  "chai": "^4.3.7",
103
103
  "chai-as-promised": "^7.1.1",
104
104
  "cross-env": "7.0.3",
105
- "eslint": "^8.37.0",
106
- "eslint-config-prettier": "^8.8.0",
105
+ "eslint": "^8.45.0",
106
+ "eslint-config-prettier": "^8.9.0",
107
107
  "eslint-plugin-import": "^2.26.0",
108
108
  "eslint-plugin-mocha": "^10.1.0",
109
109
  "eslint-plugin-prettier": "^4.2.1",
110
110
  "esm": "^3.2.25",
111
- "mocha": "^10.1.0",
112
- "mockttp": "^3.7.5",
111
+ "mocha": "^10.2.0",
112
+ "mockttp": "^3.9.1",
113
113
  "mz": "^2.7.0",
114
114
  "node-abort-controller": "^3.0.1",
115
115
  "prettier": "^2.8.8",
116
116
  "rimraf": "5.0.1",
117
- "rollup": "^3.20.2",
117
+ "rollup": "^3.26.2",
118
118
  "rollup-plugin-dts": "^5.3.0",
119
119
  "rollup-plugin-node-polyfills": "^0.2.1",
120
- "semantic-release": "^19.0.3",
120
+ "semantic-release": "^21.0.7",
121
121
  "sinon": "^15.1.0",
122
122
  "sinon-chai": "^3.7.0",
123
123
  "start-server-and-test": "^2.0.0",
124
124
  "ts-mocha": "^10.0.0",
125
- "ts-node": "^10.0.0",
125
+ "ts-node": "^10.9.1",
126
126
  "tsconfig": "workspace:*",
127
127
  "tslib": "^2.5.2",
128
- "typedoc": "^0.23.28",
129
- "typescript": "^5.0.4"
128
+ "typedoc": "^0.24.8",
129
+ "typescript": "^5.1.6"
130
130
  }
131
131
  }
package/src/connection.ts CHANGED
@@ -31,7 +31,7 @@ import {JSONRPCError} from 'jayson';
31
31
 
32
32
  import {EpochSchedule} from './epoch-schedule';
33
33
  import {SendTransactionError, SolanaJSONRPCError} from './errors';
34
- import fetchImpl, {Response} from './fetch-impl';
34
+ import fetchImpl from './fetch-impl';
35
35
  import {DurableNonce, NonceAccount} from './nonce-account';
36
36
  import {PublicKey} from './publickey';
37
37
  import {Signer} from './keypair';
@@ -4547,7 +4547,7 @@ export class Connection {
4547
4547
  config?: GetRecentPrioritizationFeesConfig,
4548
4548
  ): Promise<RecentPrioritizationFees[]> {
4549
4549
  const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());
4550
- const args = this._buildArgs(accounts?.length ? [accounts] : []);
4550
+ const args = accounts?.length ? [accounts] : [];
4551
4551
  const unsafeRes = await this._rpcRequest(
4552
4552
  'getRecentPrioritizationFees',
4553
4553
  args,
package/src/fetch-impl.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import * as nodeFetch from 'node-fetch';
2
2
 
3
- export * from 'node-fetch';
4
- export default async function (
5
- input: nodeFetch.RequestInfo,
6
- init?: nodeFetch.RequestInit,
7
- ): Promise<nodeFetch.Response> {
8
- const processedInput =
9
- typeof input === 'string' && input.slice(0, 2) === '//'
10
- ? 'https:' + input
11
- : input;
12
- return await nodeFetch.default(processedInput, init);
13
- }
3
+ export default (typeof globalThis.fetch === 'function'
4
+ ? // The Fetch API is supported experimentally in Node 17.5+ and natively in Node 18+.
5
+ globalThis.fetch
6
+ : // Otherwise use the polyfill.
7
+ async function (
8
+ input: nodeFetch.RequestInfo,
9
+ init?: nodeFetch.RequestInit,
10
+ ): Promise<nodeFetch.Response> {
11
+ const processedInput =
12
+ typeof input === 'string' && input.slice(0, 2) === '//'
13
+ ? 'https:' + input
14
+ : input;
15
+ return await nodeFetch.default(processedInput, init);
16
+ }) as typeof globalThis.fetch;
package/src/keypair.ts CHANGED
@@ -19,7 +19,7 @@ export class Keypair {
19
19
  * Create a new keypair instance.
20
20
  * Generate random keypair if no {@link Ed25519Keypair} is provided.
21
21
  *
22
- * @param keypair ed25519 keypair
22
+ * @param {Ed25519Keypair} keypair ed25519 keypair
23
23
  */
24
24
  constructor(keypair?: Ed25519Keypair) {
25
25
  this._keypair = keypair ?? generateKeypair();
@@ -27,6 +27,8 @@ export class Keypair {
27
27
 
28
28
  /**
29
29
  * Generate a new random keypair
30
+ *
31
+ * @returns {Keypair} Keypair
30
32
  */
31
33
  static generate(): Keypair {
32
34
  return new Keypair(generateKeypair());
@@ -42,7 +44,9 @@ export class Keypair {
42
44
  * @throws error if the provided secret key is invalid and validation is not skipped.
43
45
  *
44
46
  * @param secretKey secret key byte array
45
- * @param options: skip secret key validation
47
+ * @param options skip secret key validation
48
+ *
49
+ * @returns {Keypair} Keypair
46
50
  */
47
51
  static fromSecretKey(
48
52
  secretKey: Uint8Array,
@@ -68,6 +72,8 @@ export class Keypair {
68
72
  * Generate a keypair from a 32 byte seed.
69
73
  *
70
74
  * @param seed seed byte array
75
+ *
76
+ * @returns {Keypair} Keypair
71
77
  */
72
78
  static fromSeed(seed: Uint8Array): Keypair {
73
79
  const publicKey = getPublicKey(seed);
@@ -79,6 +85,8 @@ export class Keypair {
79
85
 
80
86
  /**
81
87
  * The public key for this keypair
88
+ *
89
+ * @returns {PublicKey} PublicKey
82
90
  */
83
91
  get publicKey(): PublicKey {
84
92
  return new PublicKey(this._keypair.publicKey);
@@ -86,6 +94,7 @@ export class Keypair {
86
94
 
87
95
  /**
88
96
  * The raw secret key for this keypair
97
+ * @returns {Uint8Array} Secret key in an array of Uint8 bytes
89
98
  */
90
99
  get secretKey(): Uint8Array {
91
100
  return new Uint8Array(this._keypair.secretKey);
@@ -209,6 +209,8 @@ export class Transaction {
209
209
 
210
210
  /**
211
211
  * The first (payer) Transaction signature
212
+ *
213
+ * @returns {Buffer | null} Buffer of payer's signature
212
214
  */
213
215
  get signature(): Buffer | null {
214
216
  if (this.signatures.length > 0) {
@@ -335,6 +337,8 @@ export class Transaction {
335
337
 
336
338
  /**
337
339
  * Add one or more instructions to this Transaction
340
+ *
341
+ * @param {Array< Transaction | TransactionInstruction | TransactionInstructionCtorFields >} items - Instructions to add to the Transaction
338
342
  */
339
343
  add(
340
344
  ...items: Array<
@@ -464,7 +468,7 @@ export class Transaction {
464
468
  ignorePunctuation: false,
465
469
  numeric: false,
466
470
  caseFirst: 'lower',
467
- };
471
+ } as Intl.CollatorOptions;
468
472
  return x.pubkey
469
473
  .toBase58()
470
474
  .localeCompare(y.pubkey.toBase58(), 'en', options);
@@ -594,6 +598,10 @@ export class Transaction {
594
598
 
595
599
  /**
596
600
  * Get the estimated fee associated with a transaction
601
+ *
602
+ * @param {Connection} connection Connection to RPC Endpoint.
603
+ *
604
+ * @returns {Promise<number | null>} The estimated fee for the transaction
597
605
  */
598
606
  async getEstimatedFee(connection: Connection): Promise<number | null> {
599
607
  return (await connection.getFeeForMessage(this.compileMessage())).value;
@@ -641,6 +649,8 @@ export class Transaction {
641
649
  * rejected.
642
650
  *
643
651
  * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
652
+ *
653
+ * @param {Array<Signer>} signers Array of signers that will sign the transaction
644
654
  */
645
655
  sign(...signers: Array<Signer>) {
646
656
  if (signers.length === 0) {
@@ -675,6 +685,8 @@ export class Transaction {
675
685
  * instructions.
676
686
  *
677
687
  * All the caveats from the `sign` method apply to `partialSign`
688
+ *
689
+ * @param {Array<Signer>} signers Array of signers that will sign the transaction
678
690
  */
679
691
  partialSign(...signers: Array<Signer>) {
680
692
  if (signers.length === 0) {
@@ -713,6 +725,9 @@ export class Transaction {
713
725
  * Add an externally created signature to a transaction. The public key
714
726
  * must correspond to either the fee payer or a signer account in the transaction
715
727
  * instructions.
728
+ *
729
+ * @param {PublicKey} pubkey Public key that will be added to the transaction.
730
+ * @param {Buffer} signature An externally created signature to add to the transaction.
716
731
  */
717
732
  addSignature(pubkey: PublicKey, signature: Buffer) {
718
733
  this._compile(); // Ensure signatures array is populated
@@ -739,6 +754,8 @@ export class Transaction {
739
754
  * Verify signatures of a Transaction
740
755
  * Optional parameter specifies if we're expecting a fully signed Transaction or a partially signed one.
741
756
  * If no boolean is provided, we expect a fully signed Transaction by default.
757
+ *
758
+ * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction
742
759
  */
743
760
  verifySignatures(requireAllSignatures?: boolean): boolean {
744
761
  return this._verifySignatures(
@@ -770,6 +787,10 @@ export class Transaction {
770
787
 
771
788
  /**
772
789
  * Serialize the Transaction in the wire format.
790
+ *
791
+ * @param {Buffer} [config] Config of transaction.
792
+ *
793
+ * @returns {Buffer} Signature of transaction in wire format.
773
794
  */
774
795
  serialize(config?: SerializeConfig): Buffer {
775
796
  const {requireAllSignatures, verifySignatures} = Object.assign(
@@ -849,6 +870,10 @@ export class Transaction {
849
870
 
850
871
  /**
851
872
  * Parse a wire transaction into a Transaction object.
873
+ *
874
+ * @param {Buffer | Uint8Array | Array<number>} buffer Signature of wire Transaction
875
+ *
876
+ * @returns {Transaction} Transaction associated with the signature
852
877
  */
853
878
  static from(buffer: Buffer | Uint8Array | Array<number>): Transaction {
854
879
  // Slice up wire data
@@ -867,6 +892,11 @@ export class Transaction {
867
892
 
868
893
  /**
869
894
  * Populate Transaction object from message and signatures
895
+ *
896
+ * @param {Message} message Message of transaction
897
+ * @param {Array<string>} signatures List of signatures to assign to the transaction
898
+ *
899
+ * @returns {Transaction} The populated Transaction
870
900
  */
871
901
  static populate(
872
902
  message: Message,
@@ -15,6 +15,10 @@ export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
15
15
 
16
16
  /**
17
17
  * Retrieves the RPC API URL for the specified cluster
18
+ * @param {Cluster} [cluster="devnet"] - The cluster name of the RPC API URL to use. Possible options: 'devnet' | 'testnet' | 'mainnet-beta'
19
+ * @param {boolean} [tls="http"] - Use TLS when connecting to cluster.
20
+ *
21
+ * @returns {string} URL string of the RPC endpoint
18
22
  */
19
23
  export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string {
20
24
  const key = tls === false ? 'http' : 'https';