@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/lib/index.iife.js CHANGED
@@ -14044,6 +14044,26 @@ var solanaWeb3 = (function (exports) {
14044
14044
  this.data = opts.data;
14045
14045
  }
14046
14046
  }
14047
+ /**
14048
+ * @internal
14049
+ */
14050
+
14051
+
14052
+ toJSON() {
14053
+ return {
14054
+ keys: this.keys.map(({
14055
+ pubkey,
14056
+ isSigner,
14057
+ isWritable
14058
+ }) => ({
14059
+ pubkey: pubkey.toJSON(),
14060
+ isSigner,
14061
+ isWritable
14062
+ })),
14063
+ programId: this.programId.toJSON(),
14064
+ data: [...this.data]
14065
+ };
14066
+ }
14047
14067
 
14048
14068
  }
14049
14069
  /**
@@ -14083,8 +14103,33 @@ var solanaWeb3 = (function (exports) {
14083
14103
  this.instructions = [];
14084
14104
  this.recentBlockhash = void 0;
14085
14105
  this.nonceInfo = void 0;
14106
+ this._message = void 0;
14107
+ this._json = void 0;
14086
14108
  opts && Object.assign(this, opts);
14087
14109
  }
14110
+ /**
14111
+ * @internal
14112
+ */
14113
+
14114
+
14115
+ toJSON() {
14116
+ return {
14117
+ recentBlockhash: this.recentBlockhash || null,
14118
+ feePayer: this.feePayer ? this.feePayer.toJSON() : null,
14119
+ nonceInfo: this.nonceInfo ? {
14120
+ nonce: this.nonceInfo.nonce,
14121
+ nonceInstruction: this.nonceInfo.nonceInstruction.toJSON()
14122
+ } : null,
14123
+ instructions: this.instructions.map(instruction => instruction.toJSON()),
14124
+ signatures: this.signatures.map(({
14125
+ publicKey,
14126
+ signature
14127
+ }) => ({
14128
+ publicKey: publicKey.toJSON(),
14129
+ signature: signature ? [...signature] : null
14130
+ }))
14131
+ };
14132
+ }
14088
14133
  /**
14089
14134
  * Add one or more instructions to this Transaction
14090
14135
  */
@@ -14112,6 +14157,14 @@ var solanaWeb3 = (function (exports) {
14112
14157
 
14113
14158
 
14114
14159
  compileMessage() {
14160
+ if (this._message) {
14161
+ if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
14162
+ throw new Error('Transaction mutated after being populated from Message');
14163
+ }
14164
+
14165
+ return this._message;
14166
+ }
14167
+
14115
14168
  const {
14116
14169
  nonceInfo
14117
14170
  } = this;
@@ -14633,6 +14686,8 @@ var solanaWeb3 = (function (exports) {
14633
14686
  data: bs58$1.decode(instruction.data)
14634
14687
  }));
14635
14688
  });
14689
+ transaction._message = message;
14690
+ transaction._json = transaction.toJSON();
14636
14691
  return transaction;
14637
14692
  }
14638
14693
 
@@ -16242,7 +16297,7 @@ var solanaWeb3 = (function (exports) {
16242
16297
  module.exports = exports;
16243
16298
  }(browserPonyfill, browserPonyfill.exports));
16244
16299
 
16245
- var fetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
16300
+ var crossFetch = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfill.exports);
16246
16301
 
16247
16302
  /**
16248
16303
  * A `StructFailure` represents a single specific failure in validation.
@@ -20190,7 +20245,8 @@ var solanaWeb3 = (function (exports) {
20190
20245
  * A performance sample
20191
20246
  */
20192
20247
 
20193
- function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
20248
+ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
20249
+ const fetch = customFetch ? customFetch : crossFetch;
20194
20250
 
20195
20251
  let fetchWithMiddleware;
20196
20252
 
@@ -20992,6 +21048,7 @@ var solanaWeb3 = (function (exports) {
20992
21048
  const useHttps = url.protocol === 'https:';
20993
21049
  let wsEndpoint;
20994
21050
  let httpHeaders;
21051
+ let fetch;
20995
21052
  let fetchMiddleware;
20996
21053
  let disableRetryOnRateLimit;
20997
21054
 
@@ -21002,13 +21059,14 @@ var solanaWeb3 = (function (exports) {
21002
21059
  this._confirmTransactionInitialTimeout = commitmentOrConfig.confirmTransactionInitialTimeout;
21003
21060
  wsEndpoint = commitmentOrConfig.wsEndpoint;
21004
21061
  httpHeaders = commitmentOrConfig.httpHeaders;
21062
+ fetch = commitmentOrConfig.fetch;
21005
21063
  fetchMiddleware = commitmentOrConfig.fetchMiddleware;
21006
21064
  disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
21007
21065
  }
21008
21066
 
21009
21067
  this._rpcEndpoint = endpoint;
21010
21068
  this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
21011
- this._rpcClient = createRpcClient(url.toString(), useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit);
21069
+ this._rpcClient = createRpcClient(url.toString(), useHttps, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
21012
21070
  this._rpcRequest = createRpcRequest(this._rpcClient);
21013
21071
  this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
21014
21072
  this._rpcWebSocket = new Client_1(this._rpcWsEndpoint, {
@@ -22523,7 +22581,9 @@ var solanaWeb3 = (function (exports) {
22523
22581
  });
22524
22582
  transaction.instructions = transactionOrMessage.instructions;
22525
22583
  } else {
22526
- transaction = Transaction.populate(transactionOrMessage);
22584
+ transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
22585
+
22586
+ transaction._message = transaction._json = undefined;
22527
22587
  }
22528
22588
 
22529
22589
  if (transaction.nonceInfo && signers) {