@solana/web3.js 1.41.4 → 1.41.7

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
@@ -8,7 +8,8 @@ var BN = require('bn.js');
8
8
  var bs58 = require('bs58');
9
9
  var borsh = require('borsh');
10
10
  var BufferLayout = require('@solana/buffer-layout');
11
- var fetch = require('cross-fetch');
11
+ var bufferLayoutUtils = require('@solana/buffer-layout-utils');
12
+ var crossFetch = require('cross-fetch');
12
13
  var superstruct = require('superstruct');
13
14
  var rpcWebsockets = require('rpc-websockets');
14
15
  var RpcClient = require('jayson/lib/client/browser');
@@ -41,7 +42,7 @@ var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
41
42
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
42
43
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
43
44
  var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
44
- var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
45
+ var crossFetch__default = /*#__PURE__*/_interopDefaultLegacy(crossFetch);
45
46
  var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
46
47
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
47
48
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
@@ -2533,11 +2534,7 @@ class Transaction {
2533
2534
 
2534
2535
 
2535
2536
  compileMessage() {
2536
- if (this._message) {
2537
- if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
2538
- throw new Error('Transaction message mutated after being populated from Message');
2539
- }
2540
-
2537
+ if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) {
2541
2538
  return this._message;
2542
2539
  }
2543
2540
 
@@ -3111,106 +3108,6 @@ function sleep(ms) {
3111
3108
  return new Promise(resolve => setTimeout(resolve, ms));
3112
3109
  }
3113
3110
 
3114
- const encodeDecode = (layout) => {
3115
- const decode = layout.decode.bind(layout);
3116
- const encode = layout.encode.bind(layout);
3117
- return { decode, encode };
3118
- };
3119
-
3120
- var node = {};
3121
-
3122
- Object.defineProperty(node, "__esModule", { value: true });
3123
- let converter;
3124
- {
3125
- try {
3126
- converter = require('bindings')('bigint_buffer');
3127
- }
3128
- catch (e) {
3129
- console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
3130
- }
3131
- }
3132
- /**
3133
- * Convert a little-endian buffer into a BigInt.
3134
- * @param buf The little-endian buffer to convert
3135
- * @returns A BigInt with the little-endian representation of buf.
3136
- */
3137
- function toBigIntLE(buf) {
3138
- if (converter === undefined) {
3139
- const reversed = Buffer.from(buf);
3140
- reversed.reverse();
3141
- const hex = reversed.toString('hex');
3142
- if (hex.length === 0) {
3143
- return BigInt(0);
3144
- }
3145
- return BigInt(`0x${hex}`);
3146
- }
3147
- return converter.toBigInt(buf, false);
3148
- }
3149
- var toBigIntLE_1 = node.toBigIntLE = toBigIntLE;
3150
- /**
3151
- * Convert a big-endian buffer into a BigInt
3152
- * @param buf The big-endian buffer to convert.
3153
- * @returns A BigInt with the big-endian representation of buf.
3154
- */
3155
- function toBigIntBE(buf) {
3156
- if (converter === undefined) {
3157
- const hex = buf.toString('hex');
3158
- if (hex.length === 0) {
3159
- return BigInt(0);
3160
- }
3161
- return BigInt(`0x${hex}`);
3162
- }
3163
- return converter.toBigInt(buf, true);
3164
- }
3165
- node.toBigIntBE = toBigIntBE;
3166
- /**
3167
- * Convert a BigInt to a little-endian buffer.
3168
- * @param num The BigInt to convert.
3169
- * @param width The number of bytes that the resulting buffer should be.
3170
- * @returns A little-endian buffer representation of num.
3171
- */
3172
- function toBufferLE(num, width) {
3173
- if (converter === undefined) {
3174
- const hex = num.toString(16);
3175
- const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
3176
- buffer.reverse();
3177
- return buffer;
3178
- }
3179
- // Allocation is done here, since it is slower using napi in C
3180
- return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
3181
- }
3182
- var toBufferLE_1 = node.toBufferLE = toBufferLE;
3183
- /**
3184
- * Convert a BigInt to a big-endian buffer.
3185
- * @param num The BigInt to convert.
3186
- * @param width The number of bytes that the resulting buffer should be.
3187
- * @returns A big-endian buffer representation of num.
3188
- */
3189
- function toBufferBE(num, width) {
3190
- if (converter === undefined) {
3191
- const hex = num.toString(16);
3192
- return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
3193
- }
3194
- return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
3195
- }
3196
- node.toBufferBE = toBufferBE;
3197
-
3198
- const bigInt = (length) => (property) => {
3199
- const layout = BufferLayout.blob(length, property);
3200
- const { encode, decode } = encodeDecode(layout);
3201
- const bigIntLayout = layout;
3202
- bigIntLayout.decode = (buffer, offset) => {
3203
- const src = decode(buffer, offset);
3204
- return toBigIntLE_1(Buffer.from(src));
3205
- };
3206
- bigIntLayout.encode = (bigInt, buffer, offset) => {
3207
- const src = toBufferLE_1(bigInt, length);
3208
- return encode(src, buffer, offset);
3209
- };
3210
- return bigIntLayout;
3211
- };
3212
- const u64 = bigInt(8);
3213
-
3214
3111
  /**
3215
3112
  * Populate a buffer of instruction data using an InstructionType
3216
3113
  * @internal
@@ -3600,7 +3497,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
3600
3497
  },
3601
3498
  Transfer: {
3602
3499
  index: 2,
3603
- layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports')])
3500
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), bufferLayoutUtils.u64('lamports')])
3604
3501
  },
3605
3502
  CreateWithSeed: {
3606
3503
  index: 3,
@@ -3636,7 +3533,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
3636
3533
  },
3637
3534
  TransferWithSeed: {
3638
3535
  index: 11,
3639
- layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
3536
+ layout: BufferLayout__namespace.struct([BufferLayout__namespace.u32('instruction'), bufferLayoutUtils.u64('lamports'), rustString('seed'), publicKey('programId')])
3640
3537
  }
3641
3538
  });
3642
3539
  /**
@@ -4811,7 +4708,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
4811
4708
  */
4812
4709
 
4813
4710
  function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
4814
- const fetch = customFetch ? customFetch : fetch__default["default"];
4711
+ const fetch = customFetch ? customFetch : crossFetch__default["default"];
4815
4712
  let agentManager;
4816
4713
 
4817
4714
  {
@@ -7986,7 +7883,7 @@ class Connection {
7986
7883
 
7987
7884
  try {
7988
7885
  this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
7989
- } catch {// Already removed.
7886
+ } catch (_err) {// Already removed.
7990
7887
  }
7991
7888
  }
7992
7889
  },
@@ -8028,7 +7925,7 @@ class Connection {
8028
7925
 
8029
7926
  try {
8030
7927
  this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
8031
- } catch {// Already removed.
7928
+ } catch (_err) {// Already removed.
8032
7929
  }
8033
7930
  },
8034
7931
  method: 'signatureSubscribe',