@solana/web3.js 1.37.2 → 1.39.1

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/README.md CHANGED
@@ -94,10 +94,11 @@ Example scripts for the Solana Program Library:
94
94
 
95
95
  - [Token Program Examples](https://github.com/solana-labs/solana-program-library/tree/master/token/js/examples)
96
96
 
97
- ## Flow
97
+ ## Flow Support (Discontinued)
98
98
 
99
- A [Flow library definition](https://flow.org/en/docs/libdefs/) is provided at
100
- https://unpkg.com/@solana/web3.js@latest/module.flow.js.
99
+ Flow types are no longer supported in new releases. The last release with Flow support is v1.37.2 and its
100
+ [Flow library definition](https://flow.org/en/docs/libdefs/) is provided at
101
+ https://unpkg.com/@solana/web3.js@v1.37.2/module.flow.js.
101
102
  Download the file and add the following line under the [libs] section of your project's `.flowconfig` to
102
103
  activate it:
103
104
 
@@ -2391,6 +2391,26 @@ class TransactionInstruction {
2391
2391
  this.data = opts.data;
2392
2392
  }
2393
2393
  }
2394
+ /**
2395
+ * @internal
2396
+ */
2397
+
2398
+
2399
+ toJSON() {
2400
+ return {
2401
+ keys: this.keys.map(({
2402
+ pubkey,
2403
+ isSigner,
2404
+ isWritable
2405
+ }) => ({
2406
+ pubkey: pubkey.toJSON(),
2407
+ isSigner,
2408
+ isWritable
2409
+ })),
2410
+ programId: this.programId.toJSON(),
2411
+ data: [...this.data]
2412
+ };
2413
+ }
2394
2414
 
2395
2415
  }
2396
2416
  /**
@@ -2430,8 +2450,33 @@ class Transaction {
2430
2450
  this.instructions = [];
2431
2451
  this.recentBlockhash = void 0;
2432
2452
  this.nonceInfo = void 0;
2453
+ this._message = void 0;
2454
+ this._json = void 0;
2433
2455
  opts && Object.assign(this, opts);
2434
2456
  }
2457
+ /**
2458
+ * @internal
2459
+ */
2460
+
2461
+
2462
+ toJSON() {
2463
+ return {
2464
+ recentBlockhash: this.recentBlockhash || null,
2465
+ feePayer: this.feePayer ? this.feePayer.toJSON() : null,
2466
+ nonceInfo: this.nonceInfo ? {
2467
+ nonce: this.nonceInfo.nonce,
2468
+ nonceInstruction: this.nonceInfo.nonceInstruction.toJSON()
2469
+ } : null,
2470
+ instructions: this.instructions.map(instruction => instruction.toJSON()),
2471
+ signatures: this.signatures.map(({
2472
+ publicKey,
2473
+ signature
2474
+ }) => ({
2475
+ publicKey: publicKey.toJSON(),
2476
+ signature: signature ? [...signature] : null
2477
+ }))
2478
+ };
2479
+ }
2435
2480
  /**
2436
2481
  * Add one or more instructions to this Transaction
2437
2482
  */
@@ -2459,6 +2504,14 @@ class Transaction {
2459
2504
 
2460
2505
 
2461
2506
  compileMessage() {
2507
+ if (this._message) {
2508
+ if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
2509
+ throw new Error('Transaction mutated after being populated from Message');
2510
+ }
2511
+
2512
+ return this._message;
2513
+ }
2514
+
2462
2515
  const {
2463
2516
  nonceInfo
2464
2517
  } = this;
@@ -2980,6 +3033,8 @@ class Transaction {
2980
3033
  data: bs58__default["default"].decode(instruction.data)
2981
3034
  }));
2982
3035
  });
3036
+ transaction._message = message;
3037
+ transaction._json = transaction.toJSON();
2983
3038
  return transaction;
2984
3039
  }
2985
3040
 
@@ -4589,7 +4644,7 @@ exports.Response = ctx.Response;
4589
4644
  module.exports = exports;
4590
4645
  }(browserPonyfill, browserPonyfill.exports));
4591
4646
 
4592
- var fetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
4647
+ var crossFetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
4593
4648
 
4594
4649
  const MINIMUM_SLOT_PER_EPOCH = 32; // Returns the number of trailing zeros in the binary representation of self.
4595
4650
 
@@ -4926,7 +4981,8 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
4926
4981
  * A performance sample
4927
4982
  */
4928
4983
 
4929
- function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
4984
+ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
4985
+ const fetch = customFetch ? customFetch : crossFetch;
4930
4986
 
4931
4987
  let fetchWithMiddleware;
4932
4988
 
@@ -5728,6 +5784,7 @@ class Connection {
5728
5784
  const useHttps = url.protocol === 'https:';
5729
5785
  let wsEndpoint;
5730
5786
  let httpHeaders;
5787
+ let fetch;
5731
5788
  let fetchMiddleware;
5732
5789
  let disableRetryOnRateLimit;
5733
5790
 
@@ -5738,13 +5795,14 @@ class Connection {
5738
5795
  this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
5739
5796
  wsEndpoint = commitmentOrConfig.wsEndpoint;
5740
5797
  httpHeaders = commitmentOrConfig.httpHeaders;
5798
+ fetch = commitmentOrConfig.fetch;
5741
5799
  fetchMiddleware = commitmentOrConfig.fetchMiddleware;
5742
5800
  disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
5743
5801
  }
5744
5802
 
5745
5803
  this._rpcEndpoint = endpoint;
5746
5804
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
5747
- this._rpcClient = createRpcClient(url.toString(), useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit);
5805
+ this._rpcClient = createRpcClient(url.toString(), useHttps, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
5748
5806
  this._rpcRequest = createRpcRequest(this._rpcClient);
5749
5807
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
5750
5808
  this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {
@@ -7259,7 +7317,9 @@ class Connection {
7259
7317
  });
7260
7318
  transaction.instructions = transactionOrMessage.instructions;
7261
7319
  } else {
7262
- transaction = Transaction.populate(transactionOrMessage);
7320
+ transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
7321
+
7322
+ transaction._message = transaction._json = undefined;
7263
7323
  }
7264
7324
 
7265
7325
  if (transaction.nonceInfo && signers) {