@solana/web3.js 1.43.1 → 1.43.4

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.cjs.js CHANGED
@@ -9,12 +9,12 @@ var bs58 = require('bs58');
9
9
  var borsh = require('borsh');
10
10
  var BufferLayout = require('@solana/buffer-layout');
11
11
  var bigintBuffer = require('bigint-buffer');
12
- var crossFetch = require('cross-fetch');
13
12
  var superstruct = require('superstruct');
14
13
  var rpcWebsockets = require('rpc-websockets');
15
14
  var RpcClient = require('jayson/lib/client/browser');
16
15
  var http = require('http');
17
16
  var https = require('https');
17
+ var nodeFetch = require('node-fetch');
18
18
  var secp256k1 = require('secp256k1');
19
19
  var sha3 = require('js-sha3');
20
20
 
@@ -42,10 +42,10 @@ var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
42
42
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
43
43
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
44
44
  var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
45
- var crossFetch__default = /*#__PURE__*/_interopDefaultLegacy(crossFetch);
46
45
  var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
47
46
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
48
47
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
48
+ var nodeFetch__namespace = /*#__PURE__*/_interopNamespace(nodeFetch);
49
49
  var secp256k1__default = /*#__PURE__*/_interopDefaultLegacy(secp256k1);
50
50
  var sha3__default = /*#__PURE__*/_interopDefaultLegacy(sha3);
51
51
 
@@ -79,43 +79,52 @@ var inherits$1 = {exports: {}};
79
79
 
80
80
  var inherits_browser = {exports: {}};
81
81
 
82
- if (typeof Object.create === 'function') {
83
- // implementation from standard node.js 'util' module
84
- inherits_browser.exports = function inherits(ctor, superCtor) {
85
- if (superCtor) {
86
- ctor.super_ = superCtor;
87
- ctor.prototype = Object.create(superCtor.prototype, {
88
- constructor: {
89
- value: ctor,
90
- enumerable: false,
91
- writable: true,
92
- configurable: true
93
- }
94
- });
95
- }
96
- };
97
- } else {
98
- // old school shim for old browsers
99
- inherits_browser.exports = function inherits(ctor, superCtor) {
100
- if (superCtor) {
101
- ctor.super_ = superCtor;
102
- var TempCtor = function () {};
103
- TempCtor.prototype = superCtor.prototype;
104
- ctor.prototype = new TempCtor();
105
- ctor.prototype.constructor = ctor;
106
- }
107
- };
82
+ var hasRequiredInherits_browser;
83
+
84
+ function requireInherits_browser () {
85
+ if (hasRequiredInherits_browser) return inherits_browser.exports;
86
+ hasRequiredInherits_browser = 1;
87
+ if (typeof Object.create === 'function') {
88
+ // implementation from standard node.js 'util' module
89
+ inherits_browser.exports = function inherits(ctor, superCtor) {
90
+ if (superCtor) {
91
+ ctor.super_ = superCtor;
92
+ ctor.prototype = Object.create(superCtor.prototype, {
93
+ constructor: {
94
+ value: ctor,
95
+ enumerable: false,
96
+ writable: true,
97
+ configurable: true
98
+ }
99
+ });
100
+ }
101
+ };
102
+ } else {
103
+ // old school shim for old browsers
104
+ inherits_browser.exports = function inherits(ctor, superCtor) {
105
+ if (superCtor) {
106
+ ctor.super_ = superCtor;
107
+ var TempCtor = function () {};
108
+ TempCtor.prototype = superCtor.prototype;
109
+ ctor.prototype = new TempCtor();
110
+ ctor.prototype.constructor = ctor;
111
+ }
112
+ };
113
+ }
114
+ return inherits_browser.exports;
108
115
  }
109
116
 
110
- try {
111
- var util = require('util');
112
- /* istanbul ignore next */
113
- if (typeof util.inherits !== 'function') throw '';
114
- inherits$1.exports = util.inherits;
115
- } catch (e) {
116
- /* istanbul ignore next */
117
- inherits$1.exports = inherits_browser.exports;
118
- }
117
+ (function (module) {
118
+ try {
119
+ var util = require('util');
120
+ /* istanbul ignore next */
121
+ if (typeof util.inherits !== 'function') throw '';
122
+ module.exports = util.inherits;
123
+ } catch (e) {
124
+ /* istanbul ignore next */
125
+ module.exports = requireInherits_browser();
126
+ }
127
+ } (inherits$1));
119
128
 
120
129
  var assert$5 = minimalisticAssert;
121
130
  var inherits = inherits$1.exports;
@@ -1307,22 +1316,22 @@ Hmac.prototype.digest = function digest(enc) {
1307
1316
  };
1308
1317
 
1309
1318
  (function (exports) {
1310
- var hash = exports;
1311
-
1312
- hash.utils = utils$9;
1313
- hash.common = common$5;
1314
- hash.sha = sha;
1315
- hash.ripemd = ripemd;
1316
- hash.hmac = hmac;
1317
-
1318
- // Proxy hash functions to the main object
1319
- hash.sha1 = hash.sha.sha1;
1320
- hash.sha256 = hash.sha.sha256;
1321
- hash.sha224 = hash.sha.sha224;
1322
- hash.sha384 = hash.sha.sha384;
1323
- hash.sha512 = hash.sha.sha512;
1324
- hash.ripemd160 = hash.ripemd.ripemd160;
1325
- }(hash$1));
1319
+ var hash = exports;
1320
+
1321
+ hash.utils = utils$9;
1322
+ hash.common = common$5;
1323
+ hash.sha = sha;
1324
+ hash.ripemd = ripemd;
1325
+ hash.hmac = hmac;
1326
+
1327
+ // Proxy hash functions to the main object
1328
+ hash.sha1 = hash.sha.sha1;
1329
+ hash.sha256 = hash.sha.sha256;
1330
+ hash.sha224 = hash.sha.sha224;
1331
+ hash.sha384 = hash.sha.sha384;
1332
+ hash.sha512 = hash.sha.sha512;
1333
+ hash.ripemd160 = hash.ripemd.ripemd160;
1334
+ } (hash$1));
1326
1335
 
1327
1336
  var hash = hash$1;
1328
1337
 
@@ -2617,13 +2626,6 @@ class Transaction {
2617
2626
  isSigner: false,
2618
2627
  isWritable: false
2619
2628
  });
2620
- }); // Sort. Prioritizing first by signer, then by writable
2621
-
2622
- accountMetas.sort(function (x, y) {
2623
- const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2624
- const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2625
- const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2626
- return checkSigner || checkWritable;
2627
2629
  }); // Cull duplicate account metas
2628
2630
 
2629
2631
  const uniqueMetas = [];
@@ -2635,9 +2637,25 @@ class Transaction {
2635
2637
 
2636
2638
  if (uniqueIndex > -1) {
2637
2639
  uniqueMetas[uniqueIndex].isWritable = uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;
2640
+ uniqueMetas[uniqueIndex].isSigner = uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;
2638
2641
  } else {
2639
2642
  uniqueMetas.push(accountMeta);
2640
2643
  }
2644
+ }); // Sort. Prioritizing first by signer, then by writable
2645
+
2646
+ uniqueMetas.sort(function (x, y) {
2647
+ if (x.isSigner !== y.isSigner) {
2648
+ // Signers always come before non-signers
2649
+ return x.isSigner ? -1 : 1;
2650
+ }
2651
+
2652
+ if (x.isWritable !== y.isWritable) {
2653
+ // Writable accounts always come before read-only accounts
2654
+ return x.isWritable ? -1 : 1;
2655
+ } // Otherwise, sort by pubkey.
2656
+
2657
+
2658
+ return x.pubkey._bn.cmp(y.pubkey._bn);
2641
2659
  }); // Move fee payer to the front
2642
2660
 
2643
2661
  const feePayerIndex = uniqueMetas.findIndex(x => {
@@ -4584,6 +4602,11 @@ class SendTransactionError extends Error {
4584
4602
 
4585
4603
  }
4586
4604
 
4605
+ async function fetchImpl (input, init) {
4606
+ const processedInput = typeof input === 'string' && input.slice(0, 2) === '//' ? 'https:' + input : input;
4607
+ return await nodeFetch__namespace.default(processedInput, init);
4608
+ }
4609
+
4587
4610
  // TODO: These constants should be removed in favor of reading them out of a
4588
4611
  // Syscall account
4589
4612
 
@@ -4833,7 +4856,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
4833
4856
  */
4834
4857
 
4835
4858
  function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
4836
- const fetch = customFetch ? customFetch : crossFetch__default["default"];
4859
+ const fetch = customFetch ? customFetch : fetchImpl;
4837
4860
  let agentManager;
4838
4861
 
4839
4862
  {
@@ -4843,10 +4866,10 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
4843
4866
  let fetchWithMiddleware;
4844
4867
 
4845
4868
  if (fetchMiddleware) {
4846
- fetchWithMiddleware = async (url, options) => {
4869
+ fetchWithMiddleware = async (info, init) => {
4847
4870
  const modifiedFetchArgs = await new Promise((resolve, reject) => {
4848
4871
  try {
4849
- fetchMiddleware(url, options, (modifiedUrl, modifiedOptions) => resolve([modifiedUrl, modifiedOptions]));
4872
+ fetchMiddleware(info, init, (modifiedInfo, modifiedInit) => resolve([modifiedInfo, modifiedInit]));
4850
4873
  } catch (error) {
4851
4874
  reject(error);
4852
4875
  }