@solana/web3.js 1.36.0 → 1.37.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/lib/index.iife.js CHANGED
@@ -35,7 +35,7 @@ var solanaWeb3 = (function (exports) {
35
35
  'default': _nodeResolve_empty
36
36
  });
37
37
 
38
- var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
38
+ var require$$0$2 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
39
39
 
40
40
  (function (module) {
41
41
  (function(nacl) {
@@ -2416,7 +2416,7 @@ var solanaWeb3 = (function (exports) {
2416
2416
  });
2417
2417
  } else if (typeof commonjsRequire !== 'undefined') {
2418
2418
  // Node.js.
2419
- crypto = require$$0$1;
2419
+ crypto = require$$0$2;
2420
2420
  if (crypto && crypto.randomBytes) {
2421
2421
  nacl.setPRNG(function(x, n) {
2422
2422
  var i, v = crypto.randomBytes(n);
@@ -2561,9 +2561,7 @@ var solanaWeb3 = (function (exports) {
2561
2561
 
2562
2562
  // go through the array every three bytes, we'll deal with trailing stuff later
2563
2563
  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
2564
- parts.push(encodeChunk(
2565
- uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
2566
- ));
2564
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
2567
2565
  }
2568
2566
 
2569
2567
  // pad the end with zeros, but make sure to not forget the extra bytes
@@ -8150,9 +8148,10 @@ var solanaWeb3 = (function (exports) {
8150
8148
 
8151
8149
  var safeBuffer = {exports: {}};
8152
8150
 
8153
- /* eslint-disable node/no-deprecated-api */
8151
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
8154
8152
 
8155
8153
  (function (module, exports) {
8154
+ /* eslint-disable node/no-deprecated-api */
8156
8155
  var buffer$1 = buffer;
8157
8156
  var Buffer = buffer$1.Buffer;
8158
8157
 
@@ -8174,6 +8173,8 @@ var solanaWeb3 = (function (exports) {
8174
8173
  return Buffer(arg, encodingOrOffset, length)
8175
8174
  }
8176
8175
 
8176
+ SafeBuffer.prototype = Object.create(Buffer.prototype);
8177
+
8177
8178
  // Copy static methods from Buffer
8178
8179
  copyProps(Buffer, SafeBuffer);
8179
8180
 
@@ -8216,100 +8217,126 @@ var solanaWeb3 = (function (exports) {
8216
8217
  };
8217
8218
  }(safeBuffer, safeBuffer.exports));
8218
8219
 
8219
- // base-x encoding
8220
- // Forked from https://github.com/cryptocoinjs/bs58
8221
- // Originally written by Mike Hearn for BitcoinJ
8222
- // Copyright (c) 2011 Google Inc
8223
- // Ported to JavaScript by Stefan Thomas
8224
- // Merged Buffer refactorings from base58-native by Stephen Pair
8225
- // Copyright (c) 2013 BitPay Inc
8226
-
8227
- var Buffer$1 = safeBuffer.exports.Buffer;
8228
-
8229
- var baseX = function base (ALPHABET) {
8230
- var ALPHABET_MAP = {};
8220
+ // base-x encoding / decoding
8221
+ // Copyright (c) 2018 base-x contributors
8222
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
8223
+ // Distributed under the MIT software license, see the accompanying
8224
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
8225
+ // @ts-ignore
8226
+ var _Buffer = safeBuffer.exports.Buffer;
8227
+ function base$1 (ALPHABET) {
8228
+ if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
8229
+ var BASE_MAP = new Uint8Array(256);
8230
+ for (var j = 0; j < BASE_MAP.length; j++) {
8231
+ BASE_MAP[j] = 255;
8232
+ }
8233
+ for (var i = 0; i < ALPHABET.length; i++) {
8234
+ var x = ALPHABET.charAt(i);
8235
+ var xc = x.charCodeAt(0);
8236
+ if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
8237
+ BASE_MAP[xc] = i;
8238
+ }
8231
8239
  var BASE = ALPHABET.length;
8232
8240
  var LEADER = ALPHABET.charAt(0);
8233
-
8234
- // pre-compute lookup table
8235
- for (var z = 0; z < ALPHABET.length; z++) {
8236
- var x = ALPHABET.charAt(z);
8237
-
8238
- if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous')
8239
- ALPHABET_MAP[x] = z;
8240
- }
8241
-
8241
+ var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
8242
+ var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
8242
8243
  function encode (source) {
8243
- if (source.length === 0) return ''
8244
-
8245
- var digits = [0];
8246
- for (var i = 0; i < source.length; ++i) {
8247
- for (var j = 0, carry = source[i]; j < digits.length; ++j) {
8248
- carry += digits[j] << 8;
8249
- digits[j] = carry % BASE;
8250
- carry = (carry / BASE) | 0;
8251
- }
8252
-
8253
- while (carry > 0) {
8254
- digits.push(carry % BASE);
8255
- carry = (carry / BASE) | 0;
8256
- }
8257
- }
8258
-
8259
- var string = '';
8260
-
8261
- // deal with leading zeros
8262
- for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER;
8263
- // convert digits to a string
8264
- for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]];
8265
-
8266
- return string
8267
- }
8268
-
8269
- function decodeUnsafe (string) {
8270
- if (typeof string !== 'string') throw new TypeError('Expected String')
8271
- if (string.length === 0) return Buffer$1.allocUnsafe(0)
8272
-
8273
- var bytes = [0];
8274
- for (var i = 0; i < string.length; i++) {
8275
- var value = ALPHABET_MAP[string[i]];
8276
- if (value === undefined) return
8277
-
8278
- for (var j = 0, carry = value; j < bytes.length; ++j) {
8279
- carry += bytes[j] * BASE;
8280
- bytes[j] = carry & 0xff;
8281
- carry >>= 8;
8282
- }
8283
-
8284
- while (carry > 0) {
8285
- bytes.push(carry & 0xff);
8286
- carry >>= 8;
8287
- }
8288
- }
8289
-
8290
- // deal with leading zeros
8291
- for (var k = 0; string[k] === LEADER && k < string.length - 1; ++k) {
8292
- bytes.push(0);
8293
- }
8294
-
8295
- return Buffer$1.from(bytes.reverse())
8244
+ if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source); }
8245
+ if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }
8246
+ if (source.length === 0) { return '' }
8247
+ // Skip & count leading zeroes.
8248
+ var zeroes = 0;
8249
+ var length = 0;
8250
+ var pbegin = 0;
8251
+ var pend = source.length;
8252
+ while (pbegin !== pend && source[pbegin] === 0) {
8253
+ pbegin++;
8254
+ zeroes++;
8255
+ }
8256
+ // Allocate enough space in big-endian base58 representation.
8257
+ var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
8258
+ var b58 = new Uint8Array(size);
8259
+ // Process the bytes.
8260
+ while (pbegin !== pend) {
8261
+ var carry = source[pbegin];
8262
+ // Apply "b58 = b58 * 256 + ch".
8263
+ var i = 0;
8264
+ for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
8265
+ carry += (256 * b58[it1]) >>> 0;
8266
+ b58[it1] = (carry % BASE) >>> 0;
8267
+ carry = (carry / BASE) >>> 0;
8268
+ }
8269
+ if (carry !== 0) { throw new Error('Non-zero carry') }
8270
+ length = i;
8271
+ pbegin++;
8272
+ }
8273
+ // Skip leading zeroes in base58 result.
8274
+ var it2 = size - length;
8275
+ while (it2 !== size && b58[it2] === 0) {
8276
+ it2++;
8277
+ }
8278
+ // Translate the result into a string.
8279
+ var str = LEADER.repeat(zeroes);
8280
+ for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
8281
+ return str
8282
+ }
8283
+ function decodeUnsafe (source) {
8284
+ if (typeof source !== 'string') { throw new TypeError('Expected String') }
8285
+ if (source.length === 0) { return _Buffer.alloc(0) }
8286
+ var psz = 0;
8287
+ // Skip and count leading '1's.
8288
+ var zeroes = 0;
8289
+ var length = 0;
8290
+ while (source[psz] === LEADER) {
8291
+ zeroes++;
8292
+ psz++;
8293
+ }
8294
+ // Allocate enough space in big-endian base256 representation.
8295
+ var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
8296
+ var b256 = new Uint8Array(size);
8297
+ // Process the characters.
8298
+ while (source[psz]) {
8299
+ // Decode character
8300
+ var carry = BASE_MAP[source.charCodeAt(psz)];
8301
+ // Invalid character
8302
+ if (carry === 255) { return }
8303
+ var i = 0;
8304
+ for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
8305
+ carry += (BASE * b256[it3]) >>> 0;
8306
+ b256[it3] = (carry % 256) >>> 0;
8307
+ carry = (carry / 256) >>> 0;
8308
+ }
8309
+ if (carry !== 0) { throw new Error('Non-zero carry') }
8310
+ length = i;
8311
+ psz++;
8312
+ }
8313
+ // Skip leading zeroes in b256.
8314
+ var it4 = size - length;
8315
+ while (it4 !== size && b256[it4] === 0) {
8316
+ it4++;
8317
+ }
8318
+ var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
8319
+ vch.fill(0x00, 0, zeroes);
8320
+ var j = zeroes;
8321
+ while (it4 !== size) {
8322
+ vch[j++] = b256[it4++];
8323
+ }
8324
+ return vch
8296
8325
  }
8297
-
8298
8326
  function decode (string) {
8299
8327
  var buffer = decodeUnsafe(string);
8300
- if (buffer) return buffer
8301
-
8328
+ if (buffer) { return buffer }
8302
8329
  throw new Error('Non-base' + BASE + ' character')
8303
8330
  }
8304
-
8305
8331
  return {
8306
8332
  encode: encode,
8307
8333
  decodeUnsafe: decodeUnsafe,
8308
8334
  decode: decode
8309
8335
  }
8310
- };
8336
+ }
8337
+ var src = base$1;
8311
8338
 
8312
- var basex = baseX;
8339
+ var basex = src;
8313
8340
  var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
8314
8341
 
8315
8342
  var bs58 = basex(ALPHABET);
@@ -8332,34 +8359,38 @@ var solanaWeb3 = (function (exports) {
8332
8359
  throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
8333
8360
  };
8334
8361
 
8335
- var inherits_browser$1 = {exports: {}};
8362
+ var inherits_browser = {exports: {}};
8336
8363
 
8337
8364
  if (typeof Object.create === 'function') {
8338
8365
  // implementation from standard node.js 'util' module
8339
- inherits_browser$1.exports = function inherits(ctor, superCtor) {
8340
- ctor.super_ = superCtor;
8341
- ctor.prototype = Object.create(superCtor.prototype, {
8342
- constructor: {
8343
- value: ctor,
8344
- enumerable: false,
8345
- writable: true,
8346
- configurable: true
8347
- }
8348
- });
8366
+ inherits_browser.exports = function inherits(ctor, superCtor) {
8367
+ if (superCtor) {
8368
+ ctor.super_ = superCtor;
8369
+ ctor.prototype = Object.create(superCtor.prototype, {
8370
+ constructor: {
8371
+ value: ctor,
8372
+ enumerable: false,
8373
+ writable: true,
8374
+ configurable: true
8375
+ }
8376
+ });
8377
+ }
8349
8378
  };
8350
8379
  } else {
8351
8380
  // old school shim for old browsers
8352
- inherits_browser$1.exports = function inherits(ctor, superCtor) {
8353
- ctor.super_ = superCtor;
8354
- var TempCtor = function () {};
8355
- TempCtor.prototype = superCtor.prototype;
8356
- ctor.prototype = new TempCtor();
8357
- ctor.prototype.constructor = ctor;
8381
+ inherits_browser.exports = function inherits(ctor, superCtor) {
8382
+ if (superCtor) {
8383
+ ctor.super_ = superCtor;
8384
+ var TempCtor = function () {};
8385
+ TempCtor.prototype = superCtor.prototype;
8386
+ ctor.prototype = new TempCtor();
8387
+ ctor.prototype.constructor = ctor;
8388
+ }
8358
8389
  };
8359
8390
  }
8360
8391
 
8361
8392
  var assert$h = minimalisticAssert;
8362
- var inherits$4 = inherits_browser$1.exports;
8393
+ var inherits$4 = inherits_browser.exports;
8363
8394
 
8364
8395
  utils$m.inherits = inherits$4;
8365
8396
 
@@ -9396,7 +9427,7 @@ var solanaWeb3 = (function (exports) {
9396
9427
  for (var j = 0; j < 80; j++) {
9397
9428
  var T = sum32(
9398
9429
  rotl32(
9399
- sum32_4(A, f(j, B, C, D), msg[r$1[j] + start], K(j)),
9430
+ sum32_4(A, f$1(j, B, C, D), msg[r$1[j] + start], K(j)),
9400
9431
  s[j]),
9401
9432
  E);
9402
9433
  A = E;
@@ -9406,7 +9437,7 @@ var solanaWeb3 = (function (exports) {
9406
9437
  B = T;
9407
9438
  T = sum32(
9408
9439
  rotl32(
9409
- sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
9440
+ sum32_4(Ah, f$1(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
9410
9441
  sh[j]),
9411
9442
  Eh);
9412
9443
  Ah = Eh;
@@ -9430,7 +9461,7 @@ var solanaWeb3 = (function (exports) {
9430
9461
  return utils$e.split32(this.h, 'little');
9431
9462
  };
9432
9463
 
9433
- function f(j, x, y, z) {
9464
+ function f$1(j, x, y, z) {
9434
9465
  if (j <= 15)
9435
9466
  return x ^ y ^ z;
9436
9467
  else if (j <= 31)
@@ -9567,7 +9598,7 @@ var solanaWeb3 = (function (exports) {
9567
9598
 
9568
9599
  var hash$2 = hash$3;
9569
9600
 
9570
- const version$3 = "logger/5.5.0";
9601
+ const version$4 = "logger/5.6.0";
9571
9602
 
9572
9603
  let _permanentCensorErrors = false;
9573
9604
  let _censorErrors = false;
@@ -9746,6 +9777,40 @@ var solanaWeb3 = (function (exports) {
9746
9777
  messageDetails.push(`code=${code}`);
9747
9778
  messageDetails.push(`version=${this.version}`);
9748
9779
  const reason = message;
9780
+ let url = "";
9781
+ switch (code) {
9782
+ case ErrorCode.NUMERIC_FAULT: {
9783
+ url = "NUMERIC_FAULT";
9784
+ const fault = message;
9785
+ switch (fault) {
9786
+ case "overflow":
9787
+ case "underflow":
9788
+ case "division-by-zero":
9789
+ url += "-" + fault;
9790
+ break;
9791
+ case "negative-power":
9792
+ case "negative-width":
9793
+ url += "-unsupported";
9794
+ break;
9795
+ case "unbound-bitwise-result":
9796
+ url += "-unbound-result";
9797
+ break;
9798
+ }
9799
+ break;
9800
+ }
9801
+ case ErrorCode.CALL_EXCEPTION:
9802
+ case ErrorCode.INSUFFICIENT_FUNDS:
9803
+ case ErrorCode.MISSING_NEW:
9804
+ case ErrorCode.NONCE_EXPIRED:
9805
+ case ErrorCode.REPLACEMENT_UNDERPRICED:
9806
+ case ErrorCode.TRANSACTION_REPLACED:
9807
+ case ErrorCode.UNPREDICTABLE_GAS_LIMIT:
9808
+ url = code;
9809
+ break;
9810
+ }
9811
+ if (url) {
9812
+ message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]";
9813
+ }
9749
9814
  if (messageDetails.length) {
9750
9815
  message += " (" + messageDetails.join(", ") + ")";
9751
9816
  }
@@ -9843,7 +9908,7 @@ var solanaWeb3 = (function (exports) {
9843
9908
  }
9844
9909
  static globalLogger() {
9845
9910
  if (!_globalLogger) {
9846
- _globalLogger = new Logger(version$3);
9911
+ _globalLogger = new Logger(version$4);
9847
9912
  }
9848
9913
  return _globalLogger;
9849
9914
  }
@@ -9879,9 +9944,9 @@ var solanaWeb3 = (function (exports) {
9879
9944
  Logger.errors = ErrorCode;
9880
9945
  Logger.levels = LogLevel;
9881
9946
 
9882
- const version$2 = "bytes/5.5.0";
9947
+ const version$3 = "bytes/5.6.0";
9883
9948
 
9884
- const logger = new Logger(version$2);
9949
+ const logger = new Logger(version$3);
9885
9950
  ///////////////////////////////
9886
9951
  function isHexable(value) {
9887
9952
  return !!(value.toHexString);
@@ -9976,9 +10041,9 @@ var solanaWeb3 = (function (exports) {
9976
10041
  return true;
9977
10042
  }
9978
10043
 
9979
- const version$1 = "sha2/5.5.0";
10044
+ const version$2 = "sha2/5.6.0";
9980
10045
 
9981
- new Logger(version$1);
10046
+ new Logger(version$2);
9982
10047
  function sha256(data) {
9983
10048
  return "0x" + (hash$2.sha256().update(arrayify(data)).digest("hex"));
9984
10049
  }
@@ -10662,11 +10727,11 @@ var solanaWeb3 = (function (exports) {
10662
10727
  const bs58_1 = __importDefault(bs58);
10663
10728
  // TODO: Make sure this polyfill not included when not required
10664
10729
  const encoding = __importStar(encoding_lib);
10665
- const TextDecoder = (typeof commonjsGlobal.TextDecoder !== 'function') ? encoding.TextDecoder : commonjsGlobal.TextDecoder;
10666
- const textDecoder = new TextDecoder('utf-8', { fatal: true });
10730
+ const ResolvedTextDecoder = typeof TextDecoder !== "function" ? encoding.TextDecoder : TextDecoder;
10731
+ const textDecoder = new ResolvedTextDecoder("utf-8", { fatal: true });
10667
10732
  function baseEncode(value) {
10668
- if (typeof (value) === 'string') {
10669
- value = Buffer.from(value, 'utf8');
10733
+ if (typeof value === "string") {
10734
+ value = Buffer.from(value, "utf8");
10670
10735
  }
10671
10736
  return bs58_1.default.encode(Buffer.from(value));
10672
10737
  }
@@ -10685,7 +10750,7 @@ var solanaWeb3 = (function (exports) {
10685
10750
  addToFieldPath(fieldName) {
10686
10751
  this.fieldPath.splice(0, 0, fieldName);
10687
10752
  // NOTE: Modifying message directly as jest doesn't use .toString()
10688
- this.message = this.originalMessage + ': ' + this.fieldPath.join('.');
10753
+ this.message = this.originalMessage + ": " + this.fieldPath.join(".");
10689
10754
  }
10690
10755
  }
10691
10756
  lib$1.BorshError = BorshError;
@@ -10717,28 +10782,32 @@ var solanaWeb3 = (function (exports) {
10717
10782
  }
10718
10783
  writeU64(value) {
10719
10784
  this.maybeResize();
10720
- this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray('le', 8)));
10785
+ this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray("le", 8)));
10721
10786
  }
10722
10787
  writeU128(value) {
10723
10788
  this.maybeResize();
10724
- this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray('le', 16)));
10789
+ this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray("le", 16)));
10725
10790
  }
10726
10791
  writeU256(value) {
10727
10792
  this.maybeResize();
10728
- this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray('le', 32)));
10793
+ this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray("le", 32)));
10729
10794
  }
10730
10795
  writeU512(value) {
10731
10796
  this.maybeResize();
10732
- this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray('le', 64)));
10797
+ this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray("le", 64)));
10733
10798
  }
10734
10799
  writeBuffer(buffer) {
10735
10800
  // Buffer.from is needed as this.buf.subarray can return plain Uint8Array in browser
10736
- this.buf = Buffer.concat([Buffer.from(this.buf.subarray(0, this.length)), buffer, Buffer.alloc(INITIAL_LENGTH)]);
10801
+ this.buf = Buffer.concat([
10802
+ Buffer.from(this.buf.subarray(0, this.length)),
10803
+ buffer,
10804
+ Buffer.alloc(INITIAL_LENGTH),
10805
+ ]);
10737
10806
  this.length += buffer.length;
10738
10807
  }
10739
10808
  writeString(str) {
10740
10809
  this.maybeResize();
10741
- const b = Buffer.from(str, 'utf8');
10810
+ const b = Buffer.from(str, "utf8");
10742
10811
  this.writeU32(b.length);
10743
10812
  this.writeBuffer(b);
10744
10813
  }
@@ -10767,8 +10836,8 @@ var solanaWeb3 = (function (exports) {
10767
10836
  catch (e) {
10768
10837
  if (e instanceof RangeError) {
10769
10838
  const code = e.code;
10770
- if (['ERR_BUFFER_OUT_OF_BOUNDS', 'ERR_OUT_OF_RANGE'].indexOf(code) >= 0) {
10771
- throw new BorshError('Reached the end of buffer when deserializing');
10839
+ if (["ERR_BUFFER_OUT_OF_BOUNDS", "ERR_OUT_OF_RANGE"].indexOf(code) >= 0) {
10840
+ throw new BorshError("Reached the end of buffer when deserializing");
10772
10841
  }
10773
10842
  }
10774
10843
  throw e;
@@ -10797,22 +10866,22 @@ var solanaWeb3 = (function (exports) {
10797
10866
  }
10798
10867
  readU64() {
10799
10868
  const buf = this.readBuffer(8);
10800
- return new bn_js_1.default(buf, 'le');
10869
+ return new bn_js_1.default(buf, "le");
10801
10870
  }
10802
10871
  readU128() {
10803
10872
  const buf = this.readBuffer(16);
10804
- return new bn_js_1.default(buf, 'le');
10873
+ return new bn_js_1.default(buf, "le");
10805
10874
  }
10806
10875
  readU256() {
10807
10876
  const buf = this.readBuffer(32);
10808
- return new bn_js_1.default(buf, 'le');
10877
+ return new bn_js_1.default(buf, "le");
10809
10878
  }
10810
10879
  readU512() {
10811
10880
  const buf = this.readBuffer(64);
10812
- return new bn_js_1.default(buf, 'le');
10881
+ return new bn_js_1.default(buf, "le");
10813
10882
  }
10814
10883
  readBuffer(len) {
10815
- if ((this.offset + len) > this.buf.length) {
10884
+ if (this.offset + len > this.buf.length) {
10816
10885
  throw new BorshError(`Expected buffer length ${len} isn't within bounds`);
10817
10886
  }
10818
10887
  const result = this.buf.slice(this.offset, this.offset + len);
@@ -10879,23 +10948,33 @@ var solanaWeb3 = (function (exports) {
10879
10948
  function serializeField(schema, fieldName, value, fieldType, writer) {
10880
10949
  try {
10881
10950
  // TODO: Handle missing values properly (make sure they never result in just skipped write)
10882
- if (typeof fieldType === 'string') {
10951
+ if (typeof fieldType === "string") {
10883
10952
  writer[`write${capitalizeFirstLetter(fieldType)}`](value);
10884
10953
  }
10885
10954
  else if (fieldType instanceof Array) {
10886
- if (typeof fieldType[0] === 'number') {
10955
+ if (typeof fieldType[0] === "number") {
10887
10956
  if (value.length !== fieldType[0]) {
10888
10957
  throw new BorshError(`Expecting byte array of length ${fieldType[0]}, but got ${value.length} bytes`);
10889
10958
  }
10890
10959
  writer.writeFixedArray(value);
10891
10960
  }
10961
+ else if (fieldType.length === 2 && typeof fieldType[1] === "number") {
10962
+ if (value.length !== fieldType[1]) {
10963
+ throw new BorshError(`Expecting byte array of length ${fieldType[1]}, but got ${value.length} bytes`);
10964
+ }
10965
+ for (let i = 0; i < fieldType[1]; i++) {
10966
+ serializeField(schema, null, value[i], fieldType[0], writer);
10967
+ }
10968
+ }
10892
10969
  else {
10893
- writer.writeArray(value, (item) => { serializeField(schema, fieldName, item, fieldType[0], writer); });
10970
+ writer.writeArray(value, (item) => {
10971
+ serializeField(schema, fieldName, item, fieldType[0], writer);
10972
+ });
10894
10973
  }
10895
10974
  }
10896
10975
  else if (fieldType.kind !== undefined) {
10897
10976
  switch (fieldType.kind) {
10898
- case 'option': {
10977
+ case "option": {
10899
10978
  if (value === null || value === undefined) {
10900
10979
  writer.writeU8(0);
10901
10980
  }
@@ -10905,7 +10984,16 @@ var solanaWeb3 = (function (exports) {
10905
10984
  }
10906
10985
  break;
10907
10986
  }
10908
- default: throw new BorshError(`FieldType ${fieldType} unrecognized`);
10987
+ case "map": {
10988
+ writer.writeU32(value.size);
10989
+ value.forEach((val, key) => {
10990
+ serializeField(schema, fieldName, key, fieldType.key, writer);
10991
+ serializeField(schema, fieldName, val, fieldType.value, writer);
10992
+ });
10993
+ break;
10994
+ }
10995
+ default:
10996
+ throw new BorshError(`FieldType ${fieldType} unrecognized`);
10909
10997
  }
10910
10998
  }
10911
10999
  else {
@@ -10920,16 +11008,20 @@ var solanaWeb3 = (function (exports) {
10920
11008
  }
10921
11009
  }
10922
11010
  function serializeStruct(schema, obj, writer) {
11011
+ if (typeof obj.borshSerialize === "function") {
11012
+ obj.borshSerialize(writer);
11013
+ return;
11014
+ }
10923
11015
  const structSchema = schema.get(obj.constructor);
10924
11016
  if (!structSchema) {
10925
11017
  throw new BorshError(`Class ${obj.constructor.name} is missing in schema`);
10926
11018
  }
10927
- if (structSchema.kind === 'struct') {
11019
+ if (structSchema.kind === "struct") {
10928
11020
  structSchema.fields.map(([fieldName, fieldType]) => {
10929
11021
  serializeField(schema, fieldName, obj[fieldName], fieldType, writer);
10930
11022
  });
10931
11023
  }
10932
- else if (structSchema.kind === 'enum') {
11024
+ else if (structSchema.kind === "enum") {
10933
11025
  const name = obj[structSchema.field];
10934
11026
  for (let idx = 0; idx < structSchema.values.length; ++idx) {
10935
11027
  const [fieldName, fieldType] = structSchema.values[idx];
@@ -10946,30 +11038,49 @@ var solanaWeb3 = (function (exports) {
10946
11038
  }
10947
11039
  /// Serialize given object using schema of the form:
10948
11040
  /// { class_name -> [ [field_name, field_type], .. ], .. }
10949
- function serialize(schema, obj) {
10950
- const writer = new BinaryWriter();
11041
+ function serialize(schema, obj, Writer = BinaryWriter) {
11042
+ const writer = new Writer();
10951
11043
  serializeStruct(schema, obj, writer);
10952
11044
  return writer.toArray();
10953
11045
  }
10954
11046
  var serialize_1 = lib$1.serialize = serialize;
10955
11047
  function deserializeField(schema, fieldName, fieldType, reader) {
10956
11048
  try {
10957
- if (typeof fieldType === 'string') {
11049
+ if (typeof fieldType === "string") {
10958
11050
  return reader[`read${capitalizeFirstLetter(fieldType)}`]();
10959
11051
  }
10960
11052
  if (fieldType instanceof Array) {
10961
- if (typeof fieldType[0] === 'number') {
11053
+ if (typeof fieldType[0] === "number") {
10962
11054
  return reader.readFixedArray(fieldType[0]);
10963
11055
  }
10964
- return reader.readArray(() => deserializeField(schema, fieldName, fieldType[0], reader));
11056
+ else if (typeof fieldType[1] === "number") {
11057
+ const arr = [];
11058
+ for (let i = 0; i < fieldType[1]; i++) {
11059
+ arr.push(deserializeField(schema, null, fieldType[0], reader));
11060
+ }
11061
+ return arr;
11062
+ }
11063
+ else {
11064
+ return reader.readArray(() => deserializeField(schema, fieldName, fieldType[0], reader));
11065
+ }
10965
11066
  }
10966
- if (fieldType.kind === 'option') {
11067
+ if (fieldType.kind === "option") {
10967
11068
  const option = reader.readU8();
10968
11069
  if (option) {
10969
11070
  return deserializeField(schema, fieldName, fieldType.type, reader);
10970
11071
  }
10971
11072
  return undefined;
10972
11073
  }
11074
+ if (fieldType.kind === "map") {
11075
+ let map = new Map();
11076
+ const length = reader.readU32();
11077
+ for (let i = 0; i < length; i++) {
11078
+ const key = deserializeField(schema, fieldName, fieldType.key, reader);
11079
+ const val = deserializeField(schema, fieldName, fieldType.value, reader);
11080
+ map.set(key, val);
11081
+ }
11082
+ return map;
11083
+ }
10973
11084
  return deserializeStruct(schema, fieldType, reader);
10974
11085
  }
10975
11086
  catch (error) {
@@ -10980,18 +11091,21 @@ var solanaWeb3 = (function (exports) {
10980
11091
  }
10981
11092
  }
10982
11093
  function deserializeStruct(schema, classType, reader) {
11094
+ if (typeof classType.borshDeserialize === "function") {
11095
+ return classType.borshDeserialize(reader);
11096
+ }
10983
11097
  const structSchema = schema.get(classType);
10984
11098
  if (!structSchema) {
10985
11099
  throw new BorshError(`Class ${classType.name} is missing in schema`);
10986
11100
  }
10987
- if (structSchema.kind === 'struct') {
11101
+ if (structSchema.kind === "struct") {
10988
11102
  const result = {};
10989
11103
  for (const [fieldName, fieldType] of schema.get(classType).fields) {
10990
11104
  result[fieldName] = deserializeField(schema, fieldName, fieldType, reader);
10991
11105
  }
10992
11106
  return new classType(result);
10993
11107
  }
10994
- if (structSchema.kind === 'enum') {
11108
+ if (structSchema.kind === "enum") {
10995
11109
  const idx = reader.readU8();
10996
11110
  if (idx >= structSchema.values.length) {
10997
11111
  throw new BorshError(`Enum index: ${idx} is out of range`);
@@ -11003,8 +11117,8 @@ var solanaWeb3 = (function (exports) {
11003
11117
  throw new BorshError(`Unexpected schema kind: ${structSchema.kind} for ${classType.constructor.name}`);
11004
11118
  }
11005
11119
  /// Deserializes object from bytes using schema.
11006
- function deserialize(schema, classType, buffer) {
11007
- const reader = new BinaryReader(buffer);
11120
+ function deserialize(schema, classType, buffer, Reader = BinaryReader) {
11121
+ const reader = new Reader(buffer);
11008
11122
  const result = deserializeStruct(schema, classType, reader);
11009
11123
  if (reader.offset < buffer.length) {
11010
11124
  throw new BorshError(`Unexpected ${buffer.length - reader.offset} bytes after deserialized data`);
@@ -11013,8 +11127,8 @@ var solanaWeb3 = (function (exports) {
11013
11127
  }
11014
11128
  var deserialize_1 = lib$1.deserialize = deserialize;
11015
11129
  /// Deserializes object from bytes using schema, without checking the length read
11016
- function deserializeUnchecked(schema, classType, buffer) {
11017
- const reader = new BinaryReader(buffer);
11130
+ function deserializeUnchecked(schema, classType, buffer, Reader = BinaryReader) {
11131
+ const reader = new Reader(buffer);
11018
11132
  return deserializeStruct(schema, classType, reader);
11019
11133
  }
11020
11134
  deserializeUnchecked_1 = lib$1.deserializeUnchecked = deserializeUnchecked;
@@ -11367,25 +11481,10 @@ var solanaWeb3 = (function (exports) {
11367
11481
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11368
11482
  * THE SOFTWARE.
11369
11483
  */
11370
- var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
11371
- var extendStatics = function (d, b) {
11372
- extendStatics = Object.setPrototypeOf ||
11373
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11374
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
11375
- return extendStatics(d, b);
11376
- };
11377
- return function (d, b) {
11378
- if (typeof b !== "function" && b !== null)
11379
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11380
- extendStatics(d, b);
11381
- function __() { this.constructor = d; }
11382
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11383
- };
11384
- })();
11385
- Layout$1.__esModule = true;
11484
+ Object.defineProperty(Layout$1, "__esModule", { value: true });
11386
11485
  Layout$1.s16 = Layout$1.s8 = Layout$1.nu64be = Layout$1.u48be = Layout$1.u40be = Layout$1.u32be = Layout$1.u24be = Layout$1.u16be = nu64 = Layout$1.nu64 = Layout$1.u48 = Layout$1.u40 = u32 = Layout$1.u32 = Layout$1.u24 = u16 = Layout$1.u16 = u8 = Layout$1.u8 = offset = Layout$1.offset = Layout$1.greedy = Layout$1.Constant = Layout$1.UTF8 = Layout$1.CString = Layout$1.Blob = Layout$1.Boolean = Layout$1.BitField = Layout$1.BitStructure = Layout$1.VariantLayout = Layout$1.Union = Layout$1.UnionLayoutDiscriminator = Layout$1.UnionDiscriminator = Layout$1.Structure = Layout$1.Sequence = Layout$1.DoubleBE = Layout$1.Double = Layout$1.FloatBE = Layout$1.Float = Layout$1.NearInt64BE = Layout$1.NearInt64 = Layout$1.NearUInt64BE = Layout$1.NearUInt64 = Layout$1.IntBE = Layout$1.Int = Layout$1.UIntBE = Layout$1.UInt = Layout$1.OffsetLayout = Layout$1.GreedyCount = Layout$1.ExternalLayout = Layout$1.bindConstructorLayout = Layout$1.nameWithProperty = Layout$1.Layout = Layout$1.uint8ArrayToBuffer = Layout$1.checkUint8Array = void 0;
11387
11486
  Layout$1.constant = Layout$1.utf8 = Layout$1.cstr = blob = Layout$1.blob = Layout$1.unionLayoutDiscriminator = Layout$1.union = seq = Layout$1.seq = Layout$1.bits = struct = Layout$1.struct = Layout$1.f64be = Layout$1.f64 = Layout$1.f32be = Layout$1.f32 = Layout$1.ns64be = Layout$1.s48be = Layout$1.s40be = Layout$1.s32be = Layout$1.s24be = Layout$1.s16be = ns64 = Layout$1.ns64 = Layout$1.s48 = Layout$1.s40 = Layout$1.s32 = Layout$1.s24 = void 0;
11388
- var buffer_1 = buffer;
11487
+ const buffer_1 = buffer;
11389
11488
  /* Check if a value is a Uint8Array.
11390
11489
  *
11391
11490
  * @ignore */
@@ -11419,8 +11518,8 @@ var solanaWeb3 = (function (exports) {
11419
11518
  *
11420
11519
  * @abstract
11421
11520
  */
11422
- var Layout = /** @class */ (function () {
11423
- function Layout(span, property) {
11521
+ class Layout {
11522
+ constructor(span, property) {
11424
11523
  if (!Number.isInteger(span)) {
11425
11524
  throw new TypeError('span must be an integer');
11426
11525
  }
@@ -11459,49 +11558,9 @@ var solanaWeb3 = (function (exports) {
11459
11558
  *
11460
11559
  * See {@link bindConstructorLayout}.
11461
11560
  */
11462
- Layout.prototype.makeDestinationObject = function () {
11561
+ makeDestinationObject() {
11463
11562
  return {};
11464
- };
11465
- /**
11466
- * Decode from a Uint8Array into a JavaScript value.
11467
- *
11468
- * @param {Uint8Array} b - the buffer from which encoded data is read.
11469
- *
11470
- * @param {Number} [offset] - the offset at which the encoded data
11471
- * starts. If absent a zero offset is inferred.
11472
- *
11473
- * @returns {(Number|Array|Object)} - the value of the decoded data.
11474
- *
11475
- * @abstract
11476
- */
11477
- Layout.prototype.decode = function (b, offset) {
11478
- throw new Error('Layout is abstract');
11479
- };
11480
- /**
11481
- * Encode a JavaScript value into a Uint8Array.
11482
- *
11483
- * @param {(Number|Array|Object)} src - the value to be encoded into
11484
- * the buffer. The type accepted depends on the (sub-)type of {@link
11485
- * Layout}.
11486
- *
11487
- * @param {Uint8Array} b - the buffer into which encoded data will be
11488
- * written.
11489
- *
11490
- * @param {Number} [offset] - the offset at which the encoded data
11491
- * starts. If absent a zero offset is inferred.
11492
- *
11493
- * @returns {Number} - the number of bytes encoded, including the
11494
- * space skipped for internal padding, but excluding data such as
11495
- * {@link Sequence#count|lengths} when stored {@link
11496
- * ExternalLayout|externally}. This is the adjustment to `offset`
11497
- * producing the offset where data for the next layout would be
11498
- * written.
11499
- *
11500
- * @abstract
11501
- */
11502
- Layout.prototype.encode = function (src, b, offset) {
11503
- throw new Error('Layout is abstract');
11504
- };
11563
+ }
11505
11564
  /**
11506
11565
  * Calculate the span of a specific instance of a layout.
11507
11566
  *
@@ -11518,12 +11577,12 @@ var solanaWeb3 = (function (exports) {
11518
11577
  * @throws {RangeError} - if the length of the value cannot be
11519
11578
  * determined.
11520
11579
  */
11521
- Layout.prototype.getSpan = function (b, offset) {
11580
+ getSpan(b, offset) {
11522
11581
  if (0 > this.span) {
11523
11582
  throw new RangeError('indeterminate span');
11524
11583
  }
11525
11584
  return this.span;
11526
- };
11585
+ }
11527
11586
  /**
11528
11587
  * Replicate the layout using a new property.
11529
11588
  *
@@ -11540,12 +11599,12 @@ var solanaWeb3 = (function (exports) {
11540
11599
  * @returns {Layout} - the copy with {@link Layout#property|property}
11541
11600
  * set to `property`.
11542
11601
  */
11543
- Layout.prototype.replicate = function (property) {
11544
- var rv = Object.create(this.constructor.prototype);
11602
+ replicate(property) {
11603
+ const rv = Object.create(this.constructor.prototype);
11545
11604
  Object.assign(rv, this);
11546
11605
  rv.property = property;
11547
11606
  return rv;
11548
- };
11607
+ }
11549
11608
  /**
11550
11609
  * Create an object from layout properties and an array of values.
11551
11610
  *
@@ -11566,11 +11625,10 @@ var solanaWeb3 = (function (exports) {
11566
11625
  *
11567
11626
  * @return {(Object|undefined)}
11568
11627
  */
11569
- Layout.prototype.fromArray = function (values) {
11628
+ fromArray(values) {
11570
11629
  return undefined;
11571
- };
11572
- return Layout;
11573
- }());
11630
+ }
11631
+ }
11574
11632
  Layout$1.Layout = Layout;
11575
11633
  /* Provide text that carries a name (such as for a function that will
11576
11634
  * be throwing an error) annotated with the property of a given layout
@@ -11611,6 +11669,8 @@ var solanaWeb3 = (function (exports) {
11611
11669
  * @param {Layout} layout - the {@link Layout} instance used to encode
11612
11670
  * instances of `Class`.
11613
11671
  */
11672
+ // `Class` must be a constructor Function, but the assignment of a `layout_` property to it makes it difficult to type
11673
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
11614
11674
  function bindConstructorLayout(Class, layout) {
11615
11675
  if ('function' !== typeof Class) {
11616
11676
  throw new TypeError('Class must be constructor');
@@ -11626,18 +11686,18 @@ var solanaWeb3 = (function (exports) {
11626
11686
  }
11627
11687
  Class.layout_ = layout;
11628
11688
  layout.boundConstructor_ = Class;
11629
- layout.makeDestinationObject = (function () { return new Class(); });
11689
+ layout.makeDestinationObject = (() => new Class());
11630
11690
  Object.defineProperty(Class.prototype, 'encode', {
11631
- value: function (b, offset) {
11691
+ value(b, offset) {
11632
11692
  return layout.encode(this, b, offset);
11633
11693
  },
11634
- writable: true
11694
+ writable: true,
11635
11695
  });
11636
11696
  Object.defineProperty(Class, 'decode', {
11637
- value: function (b, offset) {
11697
+ value(b, offset) {
11638
11698
  return layout.decode(b, offset);
11639
11699
  },
11640
- writable: true
11700
+ writable: true,
11641
11701
  });
11642
11702
  }
11643
11703
  Layout$1.bindConstructorLayout = bindConstructorLayout;
@@ -11662,11 +11722,7 @@ var solanaWeb3 = (function (exports) {
11662
11722
  * @abstract
11663
11723
  * @augments {Layout}
11664
11724
  */
11665
- var ExternalLayout = /** @class */ (function (_super) {
11666
- __extends(ExternalLayout, _super);
11667
- function ExternalLayout() {
11668
- return _super !== null && _super.apply(this, arguments) || this;
11669
- }
11725
+ class ExternalLayout extends Layout {
11670
11726
  /**
11671
11727
  * Return `true` iff the external layout decodes to an unsigned
11672
11728
  * integer layout.
@@ -11678,11 +11734,10 @@ var solanaWeb3 = (function (exports) {
11678
11734
  *
11679
11735
  * @abstract
11680
11736
  */
11681
- ExternalLayout.prototype.isCount = function () {
11737
+ isCount() {
11682
11738
  throw new Error('ExternalLayout is abstract');
11683
- };
11684
- return ExternalLayout;
11685
- }(Layout));
11739
+ }
11740
+ }
11686
11741
  Layout$1.ExternalLayout = ExternalLayout;
11687
11742
  /**
11688
11743
  * An {@link ExternalLayout} that determines its {@link
@@ -11699,42 +11754,32 @@ var solanaWeb3 = (function (exports) {
11699
11754
  *
11700
11755
  * @augments {ExternalLayout}
11701
11756
  */
11702
- var GreedyCount = /** @class */ (function (_super) {
11703
- __extends(GreedyCount, _super);
11704
- function GreedyCount(elementSpan, property) {
11705
- var _this = this;
11706
- if (undefined === elementSpan) {
11707
- elementSpan = 1;
11708
- }
11757
+ class GreedyCount extends ExternalLayout {
11758
+ constructor(elementSpan = 1, property) {
11709
11759
  if ((!Number.isInteger(elementSpan)) || (0 >= elementSpan)) {
11710
11760
  throw new TypeError('elementSpan must be a (positive) integer');
11711
11761
  }
11712
- _this = _super.call(this, -1, property) || this;
11762
+ super(-1, property);
11713
11763
  /** The layout for individual elements of the sequence. The value
11714
11764
  * must be a positive integer. If not provided, the value will be
11715
11765
  * 1. */
11716
- _this.elementSpan = elementSpan;
11717
- return _this;
11766
+ this.elementSpan = elementSpan;
11718
11767
  }
11719
11768
  /** @override */
11720
- GreedyCount.prototype.isCount = function () {
11769
+ isCount() {
11721
11770
  return true;
11722
- };
11771
+ }
11723
11772
  /** @override */
11724
- GreedyCount.prototype.decode = function (b, offset) {
11773
+ decode(b, offset = 0) {
11725
11774
  checkUint8Array(b);
11726
- if (undefined === offset) {
11727
- offset = 0;
11728
- }
11729
- var rem = b.length - offset;
11775
+ const rem = b.length - offset;
11730
11776
  return Math.floor(rem / this.elementSpan);
11731
- };
11777
+ }
11732
11778
  /** @override */
11733
- GreedyCount.prototype.encode = function (src, b, offset) {
11779
+ encode(src, b, offset) {
11734
11780
  return 0;
11735
- };
11736
- return GreedyCount;
11737
- }(ExternalLayout));
11781
+ }
11782
+ }
11738
11783
  Layout$1.GreedyCount = GreedyCount;
11739
11784
  /**
11740
11785
  * An {@link ExternalLayout} that supports accessing a {@link Layout}
@@ -11756,52 +11801,39 @@ var solanaWeb3 = (function (exports) {
11756
11801
  *
11757
11802
  * @augments {Layout}
11758
11803
  */
11759
- var OffsetLayout = /** @class */ (function (_super) {
11760
- __extends(OffsetLayout, _super);
11761
- function OffsetLayout(layout, offset, property) {
11762
- var _this = this;
11804
+ class OffsetLayout extends ExternalLayout {
11805
+ constructor(layout, offset = 0, property) {
11763
11806
  if (!(layout instanceof Layout)) {
11764
11807
  throw new TypeError('layout must be a Layout');
11765
11808
  }
11766
- if (undefined === offset) {
11767
- offset = 0;
11768
- }
11769
- else if (!Number.isInteger(offset)) {
11809
+ if (!Number.isInteger(offset)) {
11770
11810
  throw new TypeError('offset must be integer or undefined');
11771
11811
  }
11772
- _this = _super.call(this, layout.span, property || layout.property) || this;
11812
+ super(layout.span, property || layout.property);
11773
11813
  /** The subordinated layout. */
11774
- _this.layout = layout;
11814
+ this.layout = layout;
11775
11815
  /** The location of {@link OffsetLayout#layout} relative to the
11776
11816
  * start of another layout.
11777
11817
  *
11778
11818
  * The value may be positive or negative, but an error will thrown
11779
11819
  * if at the point of use it goes outside the span of the Uint8Array
11780
11820
  * being accessed. */
11781
- _this.offset = offset;
11782
- return _this;
11821
+ this.offset = offset;
11783
11822
  }
11784
11823
  /** @override */
11785
- OffsetLayout.prototype.isCount = function () {
11824
+ isCount() {
11786
11825
  return ((this.layout instanceof UInt)
11787
11826
  || (this.layout instanceof UIntBE));
11788
- };
11827
+ }
11789
11828
  /** @override */
11790
- OffsetLayout.prototype.decode = function (b, offset) {
11791
- if (undefined === offset) {
11792
- offset = 0;
11793
- }
11829
+ decode(b, offset = 0) {
11794
11830
  return this.layout.decode(b, offset + this.offset);
11795
- };
11831
+ }
11796
11832
  /** @override */
11797
- OffsetLayout.prototype.encode = function (src, b, offset) {
11798
- if (undefined === offset) {
11799
- offset = 0;
11800
- }
11833
+ encode(src, b, offset = 0) {
11801
11834
  return this.layout.encode(src, b, offset + this.offset);
11802
- };
11803
- return OffsetLayout;
11804
- }(ExternalLayout));
11835
+ }
11836
+ }
11805
11837
  Layout$1.OffsetLayout = OffsetLayout;
11806
11838
  /**
11807
11839
  * Represent an unsigned integer in little-endian format.
@@ -11819,32 +11851,23 @@ var solanaWeb3 = (function (exports) {
11819
11851
  *
11820
11852
  * @augments {Layout}
11821
11853
  */
11822
- var UInt = /** @class */ (function (_super) {
11823
- __extends(UInt, _super);
11824
- function UInt(span, property) {
11825
- var _this = _super.call(this, span, property) || this;
11826
- if (6 < _this.span) {
11854
+ class UInt extends Layout {
11855
+ constructor(span, property) {
11856
+ super(span, property);
11857
+ if (6 < this.span) {
11827
11858
  throw new RangeError('span must not exceed 6 bytes');
11828
11859
  }
11829
- return _this;
11830
11860
  }
11831
11861
  /** @override */
11832
- UInt.prototype.decode = function (b, offset) {
11833
- if (undefined === offset) {
11834
- offset = 0;
11835
- }
11862
+ decode(b, offset = 0) {
11836
11863
  return uint8ArrayToBuffer(b).readUIntLE(offset, this.span);
11837
- };
11864
+ }
11838
11865
  /** @override */
11839
- UInt.prototype.encode = function (src, b, offset) {
11840
- if (undefined === offset) {
11841
- offset = 0;
11842
- }
11866
+ encode(src, b, offset = 0) {
11843
11867
  uint8ArrayToBuffer(b).writeUIntLE(src, offset, this.span);
11844
11868
  return this.span;
11845
- };
11846
- return UInt;
11847
- }(Layout));
11869
+ }
11870
+ }
11848
11871
  Layout$1.UInt = UInt;
11849
11872
  /**
11850
11873
  * Represent an unsigned integer in big-endian format.
@@ -11862,32 +11885,23 @@ var solanaWeb3 = (function (exports) {
11862
11885
  *
11863
11886
  * @augments {Layout}
11864
11887
  */
11865
- var UIntBE = /** @class */ (function (_super) {
11866
- __extends(UIntBE, _super);
11867
- function UIntBE(span, property) {
11868
- var _this = _super.call(this, span, property) || this;
11869
- if (6 < _this.span) {
11888
+ class UIntBE extends Layout {
11889
+ constructor(span, property) {
11890
+ super(span, property);
11891
+ if (6 < this.span) {
11870
11892
  throw new RangeError('span must not exceed 6 bytes');
11871
11893
  }
11872
- return _this;
11873
11894
  }
11874
11895
  /** @override */
11875
- UIntBE.prototype.decode = function (b, offset) {
11876
- if (undefined === offset) {
11877
- offset = 0;
11878
- }
11896
+ decode(b, offset = 0) {
11879
11897
  return uint8ArrayToBuffer(b).readUIntBE(offset, this.span);
11880
- };
11898
+ }
11881
11899
  /** @override */
11882
- UIntBE.prototype.encode = function (src, b, offset) {
11883
- if (undefined === offset) {
11884
- offset = 0;
11885
- }
11900
+ encode(src, b, offset = 0) {
11886
11901
  uint8ArrayToBuffer(b).writeUIntBE(src, offset, this.span);
11887
11902
  return this.span;
11888
- };
11889
- return UIntBE;
11890
- }(Layout));
11903
+ }
11904
+ }
11891
11905
  Layout$1.UIntBE = UIntBE;
11892
11906
  /**
11893
11907
  * Represent a signed integer in little-endian format.
@@ -11905,32 +11919,23 @@ var solanaWeb3 = (function (exports) {
11905
11919
  *
11906
11920
  * @augments {Layout}
11907
11921
  */
11908
- var Int = /** @class */ (function (_super) {
11909
- __extends(Int, _super);
11910
- function Int(span, property) {
11911
- var _this = _super.call(this, span, property) || this;
11912
- if (6 < _this.span) {
11922
+ class Int extends Layout {
11923
+ constructor(span, property) {
11924
+ super(span, property);
11925
+ if (6 < this.span) {
11913
11926
  throw new RangeError('span must not exceed 6 bytes');
11914
11927
  }
11915
- return _this;
11916
11928
  }
11917
11929
  /** @override */
11918
- Int.prototype.decode = function (b, offset) {
11919
- if (undefined === offset) {
11920
- offset = 0;
11921
- }
11930
+ decode(b, offset = 0) {
11922
11931
  return uint8ArrayToBuffer(b).readIntLE(offset, this.span);
11923
- };
11932
+ }
11924
11933
  /** @override */
11925
- Int.prototype.encode = function (src, b, offset) {
11926
- if (undefined === offset) {
11927
- offset = 0;
11928
- }
11934
+ encode(src, b, offset = 0) {
11929
11935
  uint8ArrayToBuffer(b).writeIntLE(src, offset, this.span);
11930
11936
  return this.span;
11931
- };
11932
- return Int;
11933
- }(Layout));
11937
+ }
11938
+ }
11934
11939
  Layout$1.Int = Int;
11935
11940
  /**
11936
11941
  * Represent a signed integer in big-endian format.
@@ -11948,40 +11953,31 @@ var solanaWeb3 = (function (exports) {
11948
11953
  *
11949
11954
  * @augments {Layout}
11950
11955
  */
11951
- var IntBE = /** @class */ (function (_super) {
11952
- __extends(IntBE, _super);
11953
- function IntBE(span, property) {
11954
- var _this = _super.call(this, span, property) || this;
11955
- if (6 < _this.span) {
11956
+ class IntBE extends Layout {
11957
+ constructor(span, property) {
11958
+ super(span, property);
11959
+ if (6 < this.span) {
11956
11960
  throw new RangeError('span must not exceed 6 bytes');
11957
11961
  }
11958
- return _this;
11959
11962
  }
11960
11963
  /** @override */
11961
- IntBE.prototype.decode = function (b, offset) {
11962
- if (undefined === offset) {
11963
- offset = 0;
11964
- }
11964
+ decode(b, offset = 0) {
11965
11965
  return uint8ArrayToBuffer(b).readIntBE(offset, this.span);
11966
- };
11966
+ }
11967
11967
  /** @override */
11968
- IntBE.prototype.encode = function (src, b, offset) {
11969
- if (undefined === offset) {
11970
- offset = 0;
11971
- }
11968
+ encode(src, b, offset = 0) {
11972
11969
  uint8ArrayToBuffer(b).writeIntBE(src, offset, this.span);
11973
11970
  return this.span;
11974
- };
11975
- return IntBE;
11976
- }(Layout));
11971
+ }
11972
+ }
11977
11973
  Layout$1.IntBE = IntBE;
11978
- var V2E32 = Math.pow(2, 32);
11974
+ const V2E32 = Math.pow(2, 32);
11979
11975
  /* True modulus high and low 32-bit words, where low word is always
11980
11976
  * non-negative. */
11981
11977
  function divmodInt64(src) {
11982
- var hi32 = Math.floor(src / V2E32);
11983
- var lo32 = src - (hi32 * V2E32);
11984
- return { hi32: hi32, lo32: lo32 };
11978
+ const hi32 = Math.floor(src / V2E32);
11979
+ const lo32 = src - (hi32 * V2E32);
11980
+ return { hi32, lo32 };
11985
11981
  }
11986
11982
  /* Reconstruct Number from quotient and non-negative remainder */
11987
11983
  function roundedInt64(hi32, lo32) {
@@ -11998,34 +11994,26 @@ var solanaWeb3 = (function (exports) {
11998
11994
  *
11999
11995
  * @augments {Layout}
12000
11996
  */
12001
- var NearUInt64 = /** @class */ (function (_super) {
12002
- __extends(NearUInt64, _super);
12003
- function NearUInt64(property) {
12004
- return _super.call(this, 8, property) || this;
11997
+ class NearUInt64 extends Layout {
11998
+ constructor(property) {
11999
+ super(8, property);
12005
12000
  }
12006
12001
  /** @override */
12007
- NearUInt64.prototype.decode = function (b, offset) {
12008
- if (undefined === offset) {
12009
- offset = 0;
12010
- }
12011
- var buffer = uint8ArrayToBuffer(b);
12012
- var lo32 = buffer.readUInt32LE(offset);
12013
- var hi32 = buffer.readUInt32LE(offset + 4);
12002
+ decode(b, offset = 0) {
12003
+ const buffer = uint8ArrayToBuffer(b);
12004
+ const lo32 = buffer.readUInt32LE(offset);
12005
+ const hi32 = buffer.readUInt32LE(offset + 4);
12014
12006
  return roundedInt64(hi32, lo32);
12015
- };
12007
+ }
12016
12008
  /** @override */
12017
- NearUInt64.prototype.encode = function (src, b, offset) {
12018
- if (undefined === offset) {
12019
- offset = 0;
12020
- }
12021
- var split = divmodInt64(src);
12022
- var buffer = uint8ArrayToBuffer(b);
12009
+ encode(src, b, offset = 0) {
12010
+ const split = divmodInt64(src);
12011
+ const buffer = uint8ArrayToBuffer(b);
12023
12012
  buffer.writeUInt32LE(split.lo32, offset);
12024
12013
  buffer.writeUInt32LE(split.hi32, offset + 4);
12025
12014
  return 8;
12026
- };
12027
- return NearUInt64;
12028
- }(Layout));
12015
+ }
12016
+ }
12029
12017
  Layout$1.NearUInt64 = NearUInt64;
12030
12018
  /**
12031
12019
  * Represent an unsigned 64-bit integer in big-endian format when
@@ -12038,34 +12026,26 @@ var solanaWeb3 = (function (exports) {
12038
12026
  *
12039
12027
  * @augments {Layout}
12040
12028
  */
12041
- var NearUInt64BE = /** @class */ (function (_super) {
12042
- __extends(NearUInt64BE, _super);
12043
- function NearUInt64BE(property) {
12044
- return _super.call(this, 8, property) || this;
12029
+ class NearUInt64BE extends Layout {
12030
+ constructor(property) {
12031
+ super(8, property);
12045
12032
  }
12046
12033
  /** @override */
12047
- NearUInt64BE.prototype.decode = function (b, offset) {
12048
- if (undefined === offset) {
12049
- offset = 0;
12050
- }
12051
- var buffer = uint8ArrayToBuffer(b);
12052
- var hi32 = buffer.readUInt32BE(offset);
12053
- var lo32 = buffer.readUInt32BE(offset + 4);
12034
+ decode(b, offset = 0) {
12035
+ const buffer = uint8ArrayToBuffer(b);
12036
+ const hi32 = buffer.readUInt32BE(offset);
12037
+ const lo32 = buffer.readUInt32BE(offset + 4);
12054
12038
  return roundedInt64(hi32, lo32);
12055
- };
12039
+ }
12056
12040
  /** @override */
12057
- NearUInt64BE.prototype.encode = function (src, b, offset) {
12058
- if (undefined === offset) {
12059
- offset = 0;
12060
- }
12061
- var split = divmodInt64(src);
12062
- var buffer = uint8ArrayToBuffer(b);
12041
+ encode(src, b, offset = 0) {
12042
+ const split = divmodInt64(src);
12043
+ const buffer = uint8ArrayToBuffer(b);
12063
12044
  buffer.writeUInt32BE(split.hi32, offset);
12064
12045
  buffer.writeUInt32BE(split.lo32, offset + 4);
12065
12046
  return 8;
12066
- };
12067
- return NearUInt64BE;
12068
- }(Layout));
12047
+ }
12048
+ }
12069
12049
  Layout$1.NearUInt64BE = NearUInt64BE;
12070
12050
  /**
12071
12051
  * Represent a signed 64-bit integer in little-endian format when
@@ -12078,34 +12058,26 @@ var solanaWeb3 = (function (exports) {
12078
12058
  *
12079
12059
  * @augments {Layout}
12080
12060
  */
12081
- var NearInt64 = /** @class */ (function (_super) {
12082
- __extends(NearInt64, _super);
12083
- function NearInt64(property) {
12084
- return _super.call(this, 8, property) || this;
12061
+ class NearInt64 extends Layout {
12062
+ constructor(property) {
12063
+ super(8, property);
12085
12064
  }
12086
12065
  /** @override */
12087
- NearInt64.prototype.decode = function (b, offset) {
12088
- if (undefined === offset) {
12089
- offset = 0;
12090
- }
12091
- var buffer = uint8ArrayToBuffer(b);
12092
- var lo32 = buffer.readUInt32LE(offset);
12093
- var hi32 = buffer.readInt32LE(offset + 4);
12066
+ decode(b, offset = 0) {
12067
+ const buffer = uint8ArrayToBuffer(b);
12068
+ const lo32 = buffer.readUInt32LE(offset);
12069
+ const hi32 = buffer.readInt32LE(offset + 4);
12094
12070
  return roundedInt64(hi32, lo32);
12095
- };
12071
+ }
12096
12072
  /** @override */
12097
- NearInt64.prototype.encode = function (src, b, offset) {
12098
- if (undefined === offset) {
12099
- offset = 0;
12100
- }
12101
- var split = divmodInt64(src);
12102
- var buffer = uint8ArrayToBuffer(b);
12073
+ encode(src, b, offset = 0) {
12074
+ const split = divmodInt64(src);
12075
+ const buffer = uint8ArrayToBuffer(b);
12103
12076
  buffer.writeUInt32LE(split.lo32, offset);
12104
12077
  buffer.writeInt32LE(split.hi32, offset + 4);
12105
12078
  return 8;
12106
- };
12107
- return NearInt64;
12108
- }(Layout));
12079
+ }
12080
+ }
12109
12081
  Layout$1.NearInt64 = NearInt64;
12110
12082
  /**
12111
12083
  * Represent a signed 64-bit integer in big-endian format when
@@ -12118,34 +12090,26 @@ var solanaWeb3 = (function (exports) {
12118
12090
  *
12119
12091
  * @augments {Layout}
12120
12092
  */
12121
- var NearInt64BE = /** @class */ (function (_super) {
12122
- __extends(NearInt64BE, _super);
12123
- function NearInt64BE(property) {
12124
- return _super.call(this, 8, property) || this;
12093
+ class NearInt64BE extends Layout {
12094
+ constructor(property) {
12095
+ super(8, property);
12125
12096
  }
12126
12097
  /** @override */
12127
- NearInt64BE.prototype.decode = function (b, offset) {
12128
- if (undefined === offset) {
12129
- offset = 0;
12130
- }
12131
- var buffer = uint8ArrayToBuffer(b);
12132
- var hi32 = buffer.readInt32BE(offset);
12133
- var lo32 = buffer.readUInt32BE(offset + 4);
12098
+ decode(b, offset = 0) {
12099
+ const buffer = uint8ArrayToBuffer(b);
12100
+ const hi32 = buffer.readInt32BE(offset);
12101
+ const lo32 = buffer.readUInt32BE(offset + 4);
12134
12102
  return roundedInt64(hi32, lo32);
12135
- };
12103
+ }
12136
12104
  /** @override */
12137
- NearInt64BE.prototype.encode = function (src, b, offset) {
12138
- if (undefined === offset) {
12139
- offset = 0;
12140
- }
12141
- var split = divmodInt64(src);
12142
- var buffer = uint8ArrayToBuffer(b);
12105
+ encode(src, b, offset = 0) {
12106
+ const split = divmodInt64(src);
12107
+ const buffer = uint8ArrayToBuffer(b);
12143
12108
  buffer.writeInt32BE(split.hi32, offset);
12144
12109
  buffer.writeUInt32BE(split.lo32, offset + 4);
12145
12110
  return 8;
12146
- };
12147
- return NearInt64BE;
12148
- }(Layout));
12111
+ }
12112
+ }
12149
12113
  Layout$1.NearInt64BE = NearInt64BE;
12150
12114
  /**
12151
12115
  * Represent a 32-bit floating point number in little-endian format.
@@ -12157,28 +12121,20 @@ var solanaWeb3 = (function (exports) {
12157
12121
  *
12158
12122
  * @augments {Layout}
12159
12123
  */
12160
- var Float = /** @class */ (function (_super) {
12161
- __extends(Float, _super);
12162
- function Float(property) {
12163
- return _super.call(this, 4, property) || this;
12124
+ class Float extends Layout {
12125
+ constructor(property) {
12126
+ super(4, property);
12164
12127
  }
12165
12128
  /** @override */
12166
- Float.prototype.decode = function (b, offset) {
12167
- if (undefined === offset) {
12168
- offset = 0;
12169
- }
12129
+ decode(b, offset = 0) {
12170
12130
  return uint8ArrayToBuffer(b).readFloatLE(offset);
12171
- };
12131
+ }
12172
12132
  /** @override */
12173
- Float.prototype.encode = function (src, b, offset) {
12174
- if (undefined === offset) {
12175
- offset = 0;
12176
- }
12133
+ encode(src, b, offset = 0) {
12177
12134
  uint8ArrayToBuffer(b).writeFloatLE(src, offset);
12178
12135
  return 4;
12179
- };
12180
- return Float;
12181
- }(Layout));
12136
+ }
12137
+ }
12182
12138
  Layout$1.Float = Float;
12183
12139
  /**
12184
12140
  * Represent a 32-bit floating point number in big-endian format.
@@ -12190,28 +12146,20 @@ var solanaWeb3 = (function (exports) {
12190
12146
  *
12191
12147
  * @augments {Layout}
12192
12148
  */
12193
- var FloatBE = /** @class */ (function (_super) {
12194
- __extends(FloatBE, _super);
12195
- function FloatBE(property) {
12196
- return _super.call(this, 4, property) || this;
12149
+ class FloatBE extends Layout {
12150
+ constructor(property) {
12151
+ super(4, property);
12197
12152
  }
12198
12153
  /** @override */
12199
- FloatBE.prototype.decode = function (b, offset) {
12200
- if (undefined === offset) {
12201
- offset = 0;
12202
- }
12154
+ decode(b, offset = 0) {
12203
12155
  return uint8ArrayToBuffer(b).readFloatBE(offset);
12204
- };
12156
+ }
12205
12157
  /** @override */
12206
- FloatBE.prototype.encode = function (src, b, offset) {
12207
- if (undefined === offset) {
12208
- offset = 0;
12209
- }
12158
+ encode(src, b, offset = 0) {
12210
12159
  uint8ArrayToBuffer(b).writeFloatBE(src, offset);
12211
12160
  return 4;
12212
- };
12213
- return FloatBE;
12214
- }(Layout));
12161
+ }
12162
+ }
12215
12163
  Layout$1.FloatBE = FloatBE;
12216
12164
  /**
12217
12165
  * Represent a 64-bit floating point number in little-endian format.
@@ -12223,28 +12171,20 @@ var solanaWeb3 = (function (exports) {
12223
12171
  *
12224
12172
  * @augments {Layout}
12225
12173
  */
12226
- var Double = /** @class */ (function (_super) {
12227
- __extends(Double, _super);
12228
- function Double(property) {
12229
- return _super.call(this, 8, property) || this;
12174
+ class Double extends Layout {
12175
+ constructor(property) {
12176
+ super(8, property);
12230
12177
  }
12231
12178
  /** @override */
12232
- Double.prototype.decode = function (b, offset) {
12233
- if (undefined === offset) {
12234
- offset = 0;
12235
- }
12179
+ decode(b, offset = 0) {
12236
12180
  return uint8ArrayToBuffer(b).readDoubleLE(offset);
12237
- };
12181
+ }
12238
12182
  /** @override */
12239
- Double.prototype.encode = function (src, b, offset) {
12240
- if (undefined === offset) {
12241
- offset = 0;
12242
- }
12183
+ encode(src, b, offset = 0) {
12243
12184
  uint8ArrayToBuffer(b).writeDoubleLE(src, offset);
12244
12185
  return 8;
12245
- };
12246
- return Double;
12247
- }(Layout));
12186
+ }
12187
+ }
12248
12188
  Layout$1.Double = Double;
12249
12189
  /**
12250
12190
  * Represent a 64-bit floating point number in big-endian format.
@@ -12256,28 +12196,20 @@ var solanaWeb3 = (function (exports) {
12256
12196
  *
12257
12197
  * @augments {Layout}
12258
12198
  */
12259
- var DoubleBE = /** @class */ (function (_super) {
12260
- __extends(DoubleBE, _super);
12261
- function DoubleBE(property) {
12262
- return _super.call(this, 8, property) || this;
12199
+ class DoubleBE extends Layout {
12200
+ constructor(property) {
12201
+ super(8, property);
12263
12202
  }
12264
12203
  /** @override */
12265
- DoubleBE.prototype.decode = function (b, offset) {
12266
- if (undefined === offset) {
12267
- offset = 0;
12268
- }
12204
+ decode(b, offset = 0) {
12269
12205
  return uint8ArrayToBuffer(b).readDoubleBE(offset);
12270
- };
12206
+ }
12271
12207
  /** @override */
12272
- DoubleBE.prototype.encode = function (src, b, offset) {
12273
- if (undefined === offset) {
12274
- offset = 0;
12275
- }
12208
+ encode(src, b, offset = 0) {
12276
12209
  uint8ArrayToBuffer(b).writeDoubleBE(src, offset);
12277
12210
  return 8;
12278
- };
12279
- return DoubleBE;
12280
- }(Layout));
12211
+ }
12212
+ }
12281
12213
  Layout$1.DoubleBE = DoubleBE;
12282
12214
  /**
12283
12215
  * Represent a contiguous sequence of a specific layout as an Array.
@@ -12296,10 +12228,8 @@ var solanaWeb3 = (function (exports) {
12296
12228
  *
12297
12229
  * @augments {Layout}
12298
12230
  */
12299
- var Sequence = /** @class */ (function (_super) {
12300
- __extends(Sequence, _super);
12301
- function Sequence(elementLayout, count, property) {
12302
- var _this = this;
12231
+ class Sequence extends Layout {
12232
+ constructor(elementLayout, count, property) {
12303
12233
  if (!(elementLayout instanceof Layout)) {
12304
12234
  throw new TypeError('elementLayout must be a Layout');
12305
12235
  }
@@ -12308,32 +12238,28 @@ var solanaWeb3 = (function (exports) {
12308
12238
  throw new TypeError('count must be non-negative integer '
12309
12239
  + 'or an unsigned integer ExternalLayout');
12310
12240
  }
12311
- var span = -1;
12241
+ let span = -1;
12312
12242
  if ((!(count instanceof ExternalLayout))
12313
12243
  && (0 < elementLayout.span)) {
12314
12244
  span = count * elementLayout.span;
12315
12245
  }
12316
- _this = _super.call(this, span, property) || this;
12246
+ super(span, property);
12317
12247
  /** The layout for individual elements of the sequence. */
12318
- _this.elementLayout = elementLayout;
12248
+ this.elementLayout = elementLayout;
12319
12249
  /** The number of elements in the sequence.
12320
12250
  *
12321
12251
  * This will be either a non-negative integer or an instance of
12322
12252
  * {@link ExternalLayout} for which {@link
12323
12253
  * ExternalLayout#isCount|isCount()} is `true`. */
12324
- _this.count = count;
12325
- return _this;
12254
+ this.count = count;
12326
12255
  }
12327
12256
  /** @override */
12328
- Sequence.prototype.getSpan = function (b, offset) {
12257
+ getSpan(b, offset = 0) {
12329
12258
  if (0 <= this.span) {
12330
12259
  return this.span;
12331
12260
  }
12332
- if (undefined === offset) {
12333
- offset = 0;
12334
- }
12335
- var span = 0;
12336
- var count = this.count;
12261
+ let span = 0;
12262
+ let count = this.count;
12337
12263
  if (count instanceof ExternalLayout) {
12338
12264
  count = count.decode(b, offset);
12339
12265
  }
@@ -12341,22 +12267,19 @@ var solanaWeb3 = (function (exports) {
12341
12267
  span = count * this.elementLayout.span;
12342
12268
  }
12343
12269
  else {
12344
- var idx = 0;
12270
+ let idx = 0;
12345
12271
  while (idx < count) {
12346
12272
  span += this.elementLayout.getSpan(b, offset + span);
12347
12273
  ++idx;
12348
12274
  }
12349
12275
  }
12350
12276
  return span;
12351
- };
12277
+ }
12352
12278
  /** @override */
12353
- Sequence.prototype.decode = function (b, offset) {
12354
- if (undefined === offset) {
12355
- offset = 0;
12356
- }
12357
- var rv = [];
12358
- var i = 0;
12359
- var count = this.count;
12279
+ decode(b, offset = 0) {
12280
+ const rv = [];
12281
+ let i = 0;
12282
+ let count = this.count;
12360
12283
  if (count instanceof ExternalLayout) {
12361
12284
  count = count.decode(b, offset);
12362
12285
  }
@@ -12366,7 +12289,7 @@ var solanaWeb3 = (function (exports) {
12366
12289
  i += 1;
12367
12290
  }
12368
12291
  return rv;
12369
- };
12292
+ }
12370
12293
  /** Implement {@link Layout#encode|encode} for {@link Sequence}.
12371
12294
  *
12372
12295
  * **NOTE** If `src` is shorter than {@link Sequence#count|count} then
@@ -12377,21 +12300,17 @@ var solanaWeb3 = (function (exports) {
12377
12300
  * **NOTE** If {@link Layout#count|count} is an instance of {@link
12378
12301
  * ExternalLayout} then the length of `src` will be encoded as the
12379
12302
  * count after `src` is encoded. */
12380
- Sequence.prototype.encode = function (src, b, offset) {
12381
- if (undefined === offset) {
12382
- offset = 0;
12383
- }
12384
- var elo = this.elementLayout;
12385
- var span = src.reduce(function (span, v) {
12303
+ encode(src, b, offset = 0) {
12304
+ const elo = this.elementLayout;
12305
+ const span = src.reduce((span, v) => {
12386
12306
  return span + elo.encode(v, b, offset + span);
12387
12307
  }, 0);
12388
12308
  if (this.count instanceof ExternalLayout) {
12389
12309
  this.count.encode(src.length, b, offset);
12390
12310
  }
12391
12311
  return span;
12392
- };
12393
- return Sequence;
12394
- }(Layout));
12312
+ }
12313
+ }
12395
12314
  Layout$1.Sequence = Sequence;
12396
12315
  /**
12397
12316
  * Represent a contiguous sequence of arbitrary layout elements as an
@@ -12425,12 +12344,10 @@ var solanaWeb3 = (function (exports) {
12425
12344
  *
12426
12345
  * @augments {Layout}
12427
12346
  */
12428
- var Structure = /** @class */ (function (_super) {
12429
- __extends(Structure, _super);
12430
- function Structure(fields, property, decodePrefixes) {
12431
- var _this = this;
12347
+ class Structure extends Layout {
12348
+ constructor(fields, property, decodePrefixes) {
12432
12349
  if (!(Array.isArray(fields)
12433
- && fields.reduce(function (acc, v) { return acc && (v instanceof Layout); }, true))) {
12350
+ && fields.reduce((acc, v) => acc && (v instanceof Layout), true))) {
12434
12351
  throw new TypeError('fields must be array of Layout instances');
12435
12352
  }
12436
12353
  if (('boolean' === typeof property)
@@ -12439,21 +12356,20 @@ var solanaWeb3 = (function (exports) {
12439
12356
  property = undefined;
12440
12357
  }
12441
12358
  /* Verify absence of unnamed variable-length fields. */
12442
- for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
12443
- var fd = fields_1[_i];
12359
+ for (const fd of fields) {
12444
12360
  if ((0 > fd.span)
12445
12361
  && (undefined === fd.property)) {
12446
12362
  throw new Error('fields cannot contain unnamed variable-length layout');
12447
12363
  }
12448
12364
  }
12449
- var span = -1;
12365
+ let span = -1;
12450
12366
  try {
12451
- span = fields.reduce(function (span, fd) { return span + fd.getSpan(); }, 0);
12367
+ span = fields.reduce((span, fd) => span + fd.getSpan(), 0);
12452
12368
  }
12453
12369
  catch (e) {
12454
12370
  // ignore error
12455
12371
  }
12456
- _this = _super.call(this, span, property) || this;
12372
+ super(span, property);
12457
12373
  /** The sequence of {@link Layout} values that comprise the
12458
12374
  * structure.
12459
12375
  *
@@ -12464,7 +12380,7 @@ var solanaWeb3 = (function (exports) {
12464
12380
  * will not be mutated.
12465
12381
  *
12466
12382
  * @type {Layout[]} */
12467
- _this.fields = fields;
12383
+ this.fields = fields;
12468
12384
  /** Control behavior of {@link Layout#decode|decode()} given short
12469
12385
  * buffers.
12470
12386
  *
@@ -12474,21 +12390,17 @@ var solanaWeb3 = (function (exports) {
12474
12390
  * decoding will accept those buffers and leave subsequent fields
12475
12391
  * undefined, as long as the buffer ends at a field boundary.
12476
12392
  * Defaults to `false`. */
12477
- _this.decodePrefixes = !!decodePrefixes;
12478
- return _this;
12393
+ this.decodePrefixes = !!decodePrefixes;
12479
12394
  }
12480
12395
  /** @override */
12481
- Structure.prototype.getSpan = function (b, offset) {
12396
+ getSpan(b, offset = 0) {
12482
12397
  if (0 <= this.span) {
12483
12398
  return this.span;
12484
12399
  }
12485
- if (undefined === offset) {
12486
- offset = 0;
12487
- }
12488
- var span = 0;
12400
+ let span = 0;
12489
12401
  try {
12490
- span = this.fields.reduce(function (span, fd) {
12491
- var fsp = fd.getSpan(b, offset);
12402
+ span = this.fields.reduce((span, fd) => {
12403
+ const fsp = fd.getSpan(b, offset);
12492
12404
  offset += fsp;
12493
12405
  return span + fsp;
12494
12406
  }, 0);
@@ -12497,16 +12409,12 @@ var solanaWeb3 = (function (exports) {
12497
12409
  throw new RangeError('indeterminate span');
12498
12410
  }
12499
12411
  return span;
12500
- };
12412
+ }
12501
12413
  /** @override */
12502
- Structure.prototype.decode = function (b, offset) {
12414
+ decode(b, offset = 0) {
12503
12415
  checkUint8Array(b);
12504
- if (undefined === offset) {
12505
- offset = 0;
12506
- }
12507
- var dest = this.makeDestinationObject();
12508
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
12509
- var fd = _a[_i];
12416
+ const dest = this.makeDestinationObject();
12417
+ for (const fd of this.fields) {
12510
12418
  if (undefined !== fd.property) {
12511
12419
  dest[fd.property] = fd.decode(b, offset);
12512
12420
  }
@@ -12517,25 +12425,21 @@ var solanaWeb3 = (function (exports) {
12517
12425
  }
12518
12426
  }
12519
12427
  return dest;
12520
- };
12428
+ }
12521
12429
  /** Implement {@link Layout#encode|encode} for {@link Structure}.
12522
12430
  *
12523
12431
  * If `src` is missing a property for a member with a defined {@link
12524
12432
  * Layout#property|property} the corresponding region of the buffer is
12525
12433
  * left unmodified. */
12526
- Structure.prototype.encode = function (src, b, offset) {
12527
- if (undefined === offset) {
12528
- offset = 0;
12529
- }
12530
- var firstOffset = offset;
12531
- var lastOffset = 0;
12532
- var lastWrote = 0;
12533
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
12534
- var fd = _a[_i];
12535
- var span = fd.span;
12434
+ encode(src, b, offset = 0) {
12435
+ const firstOffset = offset;
12436
+ let lastOffset = 0;
12437
+ let lastWrote = 0;
12438
+ for (const fd of this.fields) {
12439
+ let span = fd.span;
12536
12440
  lastWrote = (0 < span) ? span : 0;
12537
12441
  if (undefined !== fd.property) {
12538
- var fv = src[fd.property];
12442
+ const fv = src[fd.property];
12539
12443
  if (undefined !== fv) {
12540
12444
  lastWrote = fd.encode(fv, b, offset);
12541
12445
  if (0 > span) {
@@ -12553,19 +12457,18 @@ var solanaWeb3 = (function (exports) {
12553
12457
  * the padding between it and the end of the space reserved for
12554
12458
  * it. */
12555
12459
  return (lastOffset + lastWrote) - firstOffset;
12556
- };
12460
+ }
12557
12461
  /** @override */
12558
- Structure.prototype.fromArray = function (values) {
12559
- var dest = this.makeDestinationObject();
12560
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
12561
- var fd = _a[_i];
12462
+ fromArray(values) {
12463
+ const dest = this.makeDestinationObject();
12464
+ for (const fd of this.fields) {
12562
12465
  if ((undefined !== fd.property)
12563
12466
  && (0 < values.length)) {
12564
12467
  dest[fd.property] = values.shift();
12565
12468
  }
12566
12469
  }
12567
12470
  return dest;
12568
- };
12471
+ }
12569
12472
  /**
12570
12473
  * Get access to the layout of a given property.
12571
12474
  *
@@ -12574,18 +12477,17 @@ var solanaWeb3 = (function (exports) {
12574
12477
  * @return {Layout} - the layout associated with `property`, or
12575
12478
  * undefined if there is no such property.
12576
12479
  */
12577
- Structure.prototype.layoutFor = function (property) {
12480
+ layoutFor(property) {
12578
12481
  if ('string' !== typeof property) {
12579
12482
  throw new TypeError('property must be string');
12580
12483
  }
12581
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
12582
- var fd = _a[_i];
12484
+ for (const fd of this.fields) {
12583
12485
  if (fd.property === property) {
12584
12486
  return fd;
12585
12487
  }
12586
12488
  }
12587
12489
  return undefined;
12588
- };
12490
+ }
12589
12491
  /**
12590
12492
  * Get the offset of a structure member.
12591
12493
  *
@@ -12597,13 +12499,12 @@ var solanaWeb3 = (function (exports) {
12597
12499
  * variable-length structure member a negative number will be
12598
12500
  * returned.
12599
12501
  */
12600
- Structure.prototype.offsetOf = function (property) {
12502
+ offsetOf(property) {
12601
12503
  if ('string' !== typeof property) {
12602
12504
  throw new TypeError('property must be string');
12603
12505
  }
12604
- var offset = 0;
12605
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
12606
- var fd = _a[_i];
12506
+ let offset = 0;
12507
+ for (const fd of this.fields) {
12607
12508
  if (fd.property === property) {
12608
12509
  return offset;
12609
12510
  }
@@ -12615,9 +12516,8 @@ var solanaWeb3 = (function (exports) {
12615
12516
  }
12616
12517
  }
12617
12518
  return undefined;
12618
- };
12619
- return Structure;
12620
- }(Layout));
12519
+ }
12520
+ }
12621
12521
  Layout$1.Structure = Structure;
12622
12522
  /**
12623
12523
  * An object that can provide a {@link
@@ -12633,8 +12533,8 @@ var solanaWeb3 = (function (exports) {
12633
12533
  *
12634
12534
  * @abstract
12635
12535
  */
12636
- var UnionDiscriminator = /** @class */ (function () {
12637
- function UnionDiscriminator(property) {
12536
+ class UnionDiscriminator {
12537
+ constructor(property) {
12638
12538
  /** The {@link Layout#property|property} to be used when the
12639
12539
  * discriminator is referenced in isolation (generally when {@link
12640
12540
  * Union#decode|Union decode} cannot delegate to a specific
@@ -12645,19 +12545,18 @@ var solanaWeb3 = (function (exports) {
12645
12545
  *
12646
12546
  * The implementation of this method need not reference the buffer if
12647
12547
  * variant information is available through other means. */
12648
- UnionDiscriminator.prototype.decode = function (b, offset) {
12548
+ decode(b, offset) {
12649
12549
  throw new Error('UnionDiscriminator is abstract');
12650
- };
12550
+ }
12651
12551
  /** Analog to {@link Layout#decode|Layout encode} for union discriminators.
12652
12552
  *
12653
12553
  * The implementation of this method need not store the value if
12654
12554
  * variant information is maintained through other means. */
12655
- UnionDiscriminator.prototype.encode = function (src, b, offset) {
12555
+ encode(src, b, offset) {
12656
12556
  throw new Error('UnionDiscriminator is abstract');
12657
- };
12658
- return UnionDiscriminator;
12659
- }());
12660
- Layout$1.UnionDiscriminator = UnionDiscriminator;
12557
+ }
12558
+ }
12559
+ Layout$1.UnionDiscriminator = UnionDiscriminator;
12661
12560
  /**
12662
12561
  * An object that can provide a {@link
12663
12562
  * UnionDiscriminator|discriminator API} for {@link Union} using an
@@ -12675,30 +12574,26 @@ var solanaWeb3 = (function (exports) {
12675
12574
  *
12676
12575
  * @augments {UnionDiscriminator}
12677
12576
  */
12678
- var UnionLayoutDiscriminator = /** @class */ (function (_super) {
12679
- __extends(UnionLayoutDiscriminator, _super);
12680
- function UnionLayoutDiscriminator(layout, property) {
12681
- var _this = this;
12577
+ class UnionLayoutDiscriminator extends UnionDiscriminator {
12578
+ constructor(layout, property) {
12682
12579
  if (!((layout instanceof ExternalLayout)
12683
12580
  && layout.isCount())) {
12684
12581
  throw new TypeError('layout must be an unsigned integer ExternalLayout');
12685
12582
  }
12686
- _this = _super.call(this, property || layout.property || 'variant') || this;
12583
+ super(property || layout.property || 'variant');
12687
12584
  /** The {@link ExternalLayout} used to access the discriminator
12688
12585
  * value. */
12689
- _this.layout = layout;
12690
- return _this;
12586
+ this.layout = layout;
12691
12587
  }
12692
12588
  /** Delegate decoding to {@link UnionLayoutDiscriminator#layout|layout}. */
12693
- UnionLayoutDiscriminator.prototype.decode = function (b, offset) {
12589
+ decode(b, offset) {
12694
12590
  return this.layout.decode(b, offset);
12695
- };
12591
+ }
12696
12592
  /** Delegate encoding to {@link UnionLayoutDiscriminator#layout|layout}. */
12697
- UnionLayoutDiscriminator.prototype.encode = function (src, b, offset) {
12593
+ encode(src, b, offset) {
12698
12594
  return this.layout.encode(src, b, offset);
12699
- };
12700
- return UnionLayoutDiscriminator;
12701
- }(UnionDiscriminator));
12595
+ }
12596
+ }
12702
12597
  Layout$1.UnionLayoutDiscriminator = UnionLayoutDiscriminator;
12703
12598
  /**
12704
12599
  * Represent any number of span-compatible layouts.
@@ -12759,14 +12654,11 @@ var solanaWeb3 = (function (exports) {
12759
12654
  *
12760
12655
  * @augments {Layout}
12761
12656
  */
12762
- var Union = /** @class */ (function (_super) {
12763
- __extends(Union, _super);
12764
- function Union(discr, defaultLayout, property) {
12765
- var _this = this;
12766
- var upv = ((discr instanceof UInt)
12767
- || (discr instanceof UIntBE));
12768
- var discriminator;
12769
- if (upv) {
12657
+ class Union extends Layout {
12658
+ constructor(discr, defaultLayout, property) {
12659
+ let discriminator;
12660
+ if ((discr instanceof UInt)
12661
+ || (discr instanceof UIntBE)) {
12770
12662
  discriminator = new UnionLayoutDiscriminator(new OffsetLayout(discr));
12771
12663
  }
12772
12664
  else if ((discr instanceof ExternalLayout)
@@ -12799,14 +12691,15 @@ var solanaWeb3 = (function (exports) {
12799
12691
  * layout. The union spans its default layout, plus any prefix
12800
12692
  * variant layout. By construction both layouts, if present, have
12801
12693
  * non-negative span. */
12802
- var span = -1;
12694
+ let span = -1;
12803
12695
  if (defaultLayout) {
12804
12696
  span = defaultLayout.span;
12805
- if ((0 <= span) && upv) {
12697
+ if ((0 <= span) && ((discr instanceof UInt)
12698
+ || (discr instanceof UIntBE))) {
12806
12699
  span += discriminator.layout.span;
12807
12700
  }
12808
12701
  }
12809
- _this = _super.call(this, span, property) || this;
12702
+ super(span, property);
12810
12703
  /** The interface for the discriminator value in isolation.
12811
12704
  *
12812
12705
  * This a {@link UnionDiscriminator} either passed to the
@@ -12815,13 +12708,14 @@ var solanaWeb3 = (function (exports) {
12815
12708
  * Union#usesPrefixDiscriminator|usesPrefixDiscriminator} will be
12816
12709
  * `true` iff the `discr` parameter was a non-offset {@link
12817
12710
  * Layout} instance. */
12818
- _this.discriminator = discriminator;
12711
+ this.discriminator = discriminator;
12819
12712
  /** `true` if the {@link Union#discriminator|discriminator} is the
12820
12713
  * first field in the union.
12821
12714
  *
12822
12715
  * If `false` the discriminator is obtained from somewhere
12823
12716
  * else. */
12824
- _this.usesPrefixDiscriminator = upv;
12717
+ this.usesPrefixDiscriminator = (discr instanceof UInt)
12718
+ || (discr instanceof UIntBE);
12825
12719
  /** The layout for non-discriminator content when the value of the
12826
12720
  * discriminator is not recognized.
12827
12721
  *
@@ -12829,7 +12723,7 @@ var solanaWeb3 = (function (exports) {
12829
12723
  * structurally equivalent to the second component of {@link
12830
12724
  * Union#layout|layout} but may have a different property
12831
12725
  * name. */
12832
- _this.defaultLayout = defaultLayout;
12726
+ this.defaultLayout = defaultLayout;
12833
12727
  /** A registry of allowed variants.
12834
12728
  *
12835
12729
  * The keys are unsigned integers which should be compatible with
@@ -12840,9 +12734,9 @@ var solanaWeb3 = (function (exports) {
12840
12734
  * **NOTE** The registry remains mutable so that variants can be
12841
12735
  * {@link Union#addVariant|added} at any time. Users should not
12842
12736
  * manipulate the content of this property. */
12843
- _this.registry = {};
12737
+ this.registry = {};
12844
12738
  /* Private variable used when invoking getSourceVariant */
12845
- var boundGetSourceVariant = _this.defaultGetSourceVariant.bind(_this);
12739
+ let boundGetSourceVariant = this.defaultGetSourceVariant.bind(this);
12846
12740
  /** Function to infer the variant selected by a source object.
12847
12741
  *
12848
12742
  * Defaults to {@link
@@ -12856,7 +12750,7 @@ var solanaWeb3 = (function (exports) {
12856
12750
  * @returns {(undefined|VariantLayout)} The default variant
12857
12751
  * (`undefined`) or first registered variant that uses a property
12858
12752
  * available in `src`. */
12859
- _this.getSourceVariant = function (src) {
12753
+ this.getSourceVariant = function (src) {
12860
12754
  return boundGetSourceVariant(src);
12861
12755
  };
12862
12756
  /** Function to override the implementation of {@link
@@ -12872,28 +12766,24 @@ var solanaWeb3 = (function (exports) {
12872
12766
  *
12873
12767
  * @param {Function} gsv - a function that follows the API of
12874
12768
  * {@link Union#defaultGetSourceVariant|defaultGetSourceVariant}. */
12875
- _this.configGetSourceVariant = function (gsv) {
12769
+ this.configGetSourceVariant = function (gsv) {
12876
12770
  boundGetSourceVariant = gsv.bind(this);
12877
12771
  };
12878
- return _this;
12879
12772
  }
12880
12773
  /** @override */
12881
- Union.prototype.getSpan = function (b, offset) {
12774
+ getSpan(b, offset = 0) {
12882
12775
  if (0 <= this.span) {
12883
12776
  return this.span;
12884
12777
  }
12885
- if (undefined === offset) {
12886
- offset = 0;
12887
- }
12888
12778
  /* Default layouts always have non-negative span, so we don't have
12889
12779
  * one and we have to recognize the variant which will in turn
12890
12780
  * determine the span. */
12891
- var vlo = this.getVariant(b, offset);
12781
+ const vlo = this.getVariant(b, offset);
12892
12782
  if (!vlo) {
12893
12783
  throw new Error('unable to determine span for unrecognized variant');
12894
12784
  }
12895
12785
  return vlo.getSpan(b, offset);
12896
- };
12786
+ }
12897
12787
  /**
12898
12788
  * Method to infer a registered Union variant compatible with `src`.
12899
12789
  *
@@ -12923,13 +12813,13 @@ var solanaWeb3 = (function (exports) {
12923
12813
  * @throws {Error} - if `src` cannot be associated with a default or
12924
12814
  * registered variant.
12925
12815
  */
12926
- Union.prototype.defaultGetSourceVariant = function (src) {
12816
+ defaultGetSourceVariant(src) {
12927
12817
  if (Object.prototype.hasOwnProperty.call(src, this.discriminator.property)) {
12928
12818
  if (this.defaultLayout && this.defaultLayout.property
12929
12819
  && Object.prototype.hasOwnProperty.call(src, this.defaultLayout.property)) {
12930
12820
  return undefined;
12931
12821
  }
12932
- var vlo = this.registry[src[this.discriminator.property]];
12822
+ const vlo = this.registry[src[this.discriminator.property]];
12933
12823
  if (vlo
12934
12824
  && ((!vlo.layout)
12935
12825
  || (vlo.property && Object.prototype.hasOwnProperty.call(src, vlo.property)))) {
@@ -12937,69 +12827,67 @@ var solanaWeb3 = (function (exports) {
12937
12827
  }
12938
12828
  }
12939
12829
  else {
12940
- for (var tag in this.registry) {
12941
- var vlo = this.registry[tag];
12830
+ for (const tag in this.registry) {
12831
+ const vlo = this.registry[tag];
12942
12832
  if (vlo.property && Object.prototype.hasOwnProperty.call(src, vlo.property)) {
12943
12833
  return vlo;
12944
12834
  }
12945
12835
  }
12946
12836
  }
12947
12837
  throw new Error('unable to infer src variant');
12948
- };
12838
+ }
12949
12839
  /** Implement {@link Layout#decode|decode} for {@link Union}.
12950
12840
  *
12951
12841
  * If the variant is {@link Union#addVariant|registered} the return
12952
12842
  * value is an instance of that variant, with no explicit
12953
12843
  * discriminator. Otherwise the {@link Union#defaultLayout|default
12954
12844
  * layout} is used to decode the content. */
12955
- Union.prototype.decode = function (b, offset) {
12956
- if (undefined === offset) {
12957
- offset = 0;
12958
- }
12959
- var dest;
12960
- var dlo = this.discriminator;
12961
- var discr = dlo.decode(b, offset);
12962
- var clo = this.registry[discr];
12845
+ decode(b, offset = 0) {
12846
+ let dest;
12847
+ const dlo = this.discriminator;
12848
+ const discr = dlo.decode(b, offset);
12849
+ const clo = this.registry[discr];
12963
12850
  if (undefined === clo) {
12964
- var defaultLayout = this.defaultLayout;
12965
- var contentOffset = 0;
12851
+ const defaultLayout = this.defaultLayout;
12852
+ let contentOffset = 0;
12966
12853
  if (this.usesPrefixDiscriminator) {
12967
12854
  contentOffset = dlo.layout.span;
12968
12855
  }
12969
12856
  dest = this.makeDestinationObject();
12970
12857
  dest[dlo.property] = discr;
12858
+ // defaultLayout.property can be undefined, but this is allowed by buffer-layout
12859
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12971
12860
  dest[defaultLayout.property] = defaultLayout.decode(b, offset + contentOffset);
12972
12861
  }
12973
12862
  else {
12974
12863
  dest = clo.decode(b, offset);
12975
12864
  }
12976
12865
  return dest;
12977
- };
12866
+ }
12978
12867
  /** Implement {@link Layout#encode|encode} for {@link Union}.
12979
12868
  *
12980
12869
  * This API assumes the `src` object is consistent with the union's
12981
12870
  * {@link Union#defaultLayout|default layout}. To encode variants
12982
12871
  * use the appropriate variant-specific {@link VariantLayout#encode}
12983
12872
  * method. */
12984
- Union.prototype.encode = function (src, b, offset) {
12985
- if (undefined === offset) {
12986
- offset = 0;
12987
- }
12988
- var vlo = this.getSourceVariant(src);
12873
+ encode(src, b, offset = 0) {
12874
+ const vlo = this.getSourceVariant(src);
12989
12875
  if (undefined === vlo) {
12990
- var dlo = this.discriminator;
12876
+ const dlo = this.discriminator;
12991
12877
  // this.defaultLayout is not undefined when vlo is undefined
12992
- var clo = this.defaultLayout;
12993
- var contentOffset = 0;
12878
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12879
+ const clo = this.defaultLayout;
12880
+ let contentOffset = 0;
12994
12881
  if (this.usesPrefixDiscriminator) {
12995
12882
  contentOffset = dlo.layout.span;
12996
12883
  }
12997
12884
  dlo.encode(src[dlo.property], b, offset);
12998
12885
  // clo.property is not undefined when vlo is undefined
12886
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12999
12887
  return contentOffset + clo.encode(src[clo.property], b, offset + contentOffset);
13000
12888
  }
13001
12889
  return vlo.encode(src, b, offset);
13002
- };
12890
+ }
13003
12891
  /** Register a new variant structure within a union. The newly
13004
12892
  * created variant is returned.
13005
12893
  *
@@ -13013,11 +12901,11 @@ var solanaWeb3 = (function (exports) {
13013
12901
  * Layout#property|property}.
13014
12902
  *
13015
12903
  * @return {VariantLayout} */
13016
- Union.prototype.addVariant = function (variant, layout, property) {
13017
- var rv = new VariantLayout(this, variant, layout, property);
12904
+ addVariant(variant, layout, property) {
12905
+ const rv = new VariantLayout(this, variant, layout, property);
13018
12906
  this.registry[variant] = rv;
13019
12907
  return rv;
13020
- };
12908
+ }
13021
12909
  /**
13022
12910
  * Get the layout associated with a registered variant.
13023
12911
  *
@@ -13032,21 +12920,17 @@ var solanaWeb3 = (function (exports) {
13032
12920
  *
13033
12921
  * @return {({VariantLayout}|undefined)}
13034
12922
  */
13035
- Union.prototype.getVariant = function (vb, offset) {
13036
- var variant;
12923
+ getVariant(vb, offset = 0) {
12924
+ let variant;
13037
12925
  if (vb instanceof Uint8Array) {
13038
- if (undefined === offset) {
13039
- offset = 0;
13040
- }
13041
12926
  variant = this.discriminator.decode(vb, offset);
13042
12927
  }
13043
12928
  else {
13044
12929
  variant = vb;
13045
12930
  }
13046
12931
  return this.registry[variant];
13047
- };
13048
- return Union;
13049
- }(Layout));
12932
+ }
12933
+ }
13050
12934
  Layout$1.Union = Union;
13051
12935
  /**
13052
12936
  * Represent a specific variant within a containing union.
@@ -13077,10 +12961,8 @@ var solanaWeb3 = (function (exports) {
13077
12961
  *
13078
12962
  * @augments {Layout}
13079
12963
  */
13080
- var VariantLayout = /** @class */ (function (_super) {
13081
- __extends(VariantLayout, _super);
13082
- function VariantLayout(union, variant, layout, property) {
13083
- var _this = this;
12964
+ class VariantLayout extends Layout {
12965
+ constructor(union, variant, layout, property) {
13084
12966
  if (!(union instanceof Union)) {
13085
12967
  throw new TypeError('union must be a Union');
13086
12968
  }
@@ -13105,93 +12987,79 @@ var solanaWeb3 = (function (exports) {
13105
12987
  throw new TypeError('variant must have a String property');
13106
12988
  }
13107
12989
  }
13108
- var span = union.span;
12990
+ let span = union.span;
13109
12991
  if (0 > union.span) {
13110
12992
  span = layout ? layout.span : 0;
13111
12993
  if ((0 <= span) && union.usesPrefixDiscriminator) {
13112
12994
  span += union.discriminator.layout.span;
13113
12995
  }
13114
12996
  }
13115
- _this = _super.call(this, span, property) || this;
12997
+ super(span, property);
13116
12998
  /** The {@link Union} to which this variant belongs. */
13117
- _this.union = union;
12999
+ this.union = union;
13118
13000
  /** The unsigned integral value identifying this variant within
13119
13001
  * the {@link Union#discriminator|discriminator} of the containing
13120
13002
  * union. */
13121
- _this.variant = variant;
13003
+ this.variant = variant;
13122
13004
  /** The {@link Layout} to be used when reading/writing the
13123
13005
  * non-discriminator part of the {@link
13124
13006
  * VariantLayout#union|union}. If `null` the variant carries no
13125
13007
  * data. */
13126
- _this.layout = layout || null;
13127
- return _this;
13008
+ this.layout = layout || null;
13128
13009
  }
13129
13010
  /** @override */
13130
- VariantLayout.prototype.getSpan = function (b, offset) {
13011
+ getSpan(b, offset = 0) {
13131
13012
  if (0 <= this.span) {
13132
13013
  /* Will be equal to the containing union span if that is not
13133
13014
  * variable. */
13134
13015
  return this.span;
13135
13016
  }
13136
- if (undefined === offset) {
13137
- offset = 0;
13138
- }
13139
- var contentOffset = 0;
13017
+ let contentOffset = 0;
13140
13018
  if (this.union.usesPrefixDiscriminator) {
13141
13019
  contentOffset = this.union.discriminator.layout.span;
13142
13020
  }
13143
13021
  /* Span is defined solely by the variant (and prefix discriminator) */
13144
- var span = 0;
13022
+ let span = 0;
13145
13023
  if (this.layout) {
13146
13024
  span = this.layout.getSpan(b, offset + contentOffset);
13147
13025
  }
13148
13026
  return contentOffset + span;
13149
- };
13027
+ }
13150
13028
  /** @override */
13151
- VariantLayout.prototype.decode = function (b, offset) {
13152
- var dest = this.makeDestinationObject();
13153
- if (undefined === offset) {
13154
- offset = 0;
13155
- }
13029
+ decode(b, offset = 0) {
13030
+ const dest = this.makeDestinationObject();
13156
13031
  if (this !== this.union.getVariant(b, offset)) {
13157
13032
  throw new Error('variant mismatch');
13158
13033
  }
13159
- var contentOffset = 0;
13034
+ let contentOffset = 0;
13160
13035
  if (this.union.usesPrefixDiscriminator) {
13161
13036
  contentOffset = this.union.discriminator.layout.span;
13162
13037
  }
13163
- // VariantLayout property is never undefined
13164
- var property = this.property;
13165
13038
  if (this.layout) {
13166
- dest[property] = this.layout.decode(b, offset + contentOffset);
13039
+ dest[this.property] = this.layout.decode(b, offset + contentOffset);
13167
13040
  }
13168
- else if (property) {
13169
- dest[property] = true;
13041
+ else if (this.property) {
13042
+ dest[this.property] = true;
13170
13043
  }
13171
13044
  else if (this.union.usesPrefixDiscriminator) {
13172
13045
  dest[this.union.discriminator.property] = this.variant;
13173
13046
  }
13174
13047
  return dest;
13175
- };
13048
+ }
13176
13049
  /** @override */
13177
- VariantLayout.prototype.encode = function (src, b, offset) {
13178
- if (undefined === offset) {
13179
- offset = 0;
13180
- }
13181
- var contentOffset = 0;
13050
+ encode(src, b, offset = 0) {
13051
+ let contentOffset = 0;
13182
13052
  if (this.union.usesPrefixDiscriminator) {
13183
13053
  contentOffset = this.union.discriminator.layout.span;
13184
13054
  }
13185
- // VariantLayout property is never undefined
13186
- var property = this.property;
13187
13055
  if (this.layout
13188
- && (!Object.prototype.hasOwnProperty.call(src, property))) {
13189
- throw new TypeError('variant lacks property ' + property);
13056
+ && (!Object.prototype.hasOwnProperty.call(src, this.property))) {
13057
+ throw new TypeError('variant lacks property ' + this.property);
13190
13058
  }
13191
13059
  this.union.discriminator.encode(this.variant, b, offset);
13192
- var span = contentOffset;
13060
+ let span = contentOffset;
13193
13061
  if (this.layout) {
13194
- this.layout.encode(src[property], b, offset + contentOffset);
13062
+ this.layout.encode(src[this.property], b, offset + contentOffset);
13195
13063
  span += this.layout.getSpan(b, offset + contentOffset);
13196
13064
  if ((0 <= this.union.span)
13197
13065
  && (span > this.union.span)) {
@@ -13199,17 +13067,16 @@ var solanaWeb3 = (function (exports) {
13199
13067
  }
13200
13068
  }
13201
13069
  return span;
13202
- };
13070
+ }
13203
13071
  /** Delegate {@link Layout#fromArray|fromArray} to {@link
13204
13072
  * VariantLayout#layout|layout}. */
13205
- VariantLayout.prototype.fromArray = function (values) {
13073
+ fromArray(values) {
13206
13074
  if (this.layout) {
13207
13075
  return this.layout.fromArray(values);
13208
13076
  }
13209
13077
  return undefined;
13210
- };
13211
- return VariantLayout;
13212
- }(Layout));
13078
+ }
13079
+ }
13213
13080
  Layout$1.VariantLayout = VariantLayout;
13214
13081
  /** JavaScript chose to define bitwise operations as operating on
13215
13082
  * signed 32-bit values in 2's complement form, meaning any integer
@@ -13254,10 +13121,8 @@ var solanaWeb3 = (function (exports) {
13254
13121
  *
13255
13122
  * @augments {Layout}
13256
13123
  */
13257
- var BitStructure = /** @class */ (function (_super) {
13258
- __extends(BitStructure, _super);
13259
- function BitStructure(word, msb, property) {
13260
- var _this = this;
13124
+ class BitStructure extends Layout {
13125
+ constructor(word, msb, property) {
13261
13126
  if (!((word instanceof UInt)
13262
13127
  || (word instanceof UIntBE))) {
13263
13128
  throw new TypeError('word must be a UInt or UIntBE layout');
@@ -13270,11 +13135,11 @@ var solanaWeb3 = (function (exports) {
13270
13135
  if (4 < word.span) {
13271
13136
  throw new RangeError('word cannot exceed 32 bits');
13272
13137
  }
13273
- _this = _super.call(this, word.span, property) || this;
13138
+ super(word.span, property);
13274
13139
  /** The layout used for the packed value. {@link BitField}
13275
13140
  * instances are packed sequentially depending on {@link
13276
13141
  * BitStructure#msb|msb}. */
13277
- _this.word = word;
13142
+ this.word = word;
13278
13143
  /** Whether the bit sequences are packed starting at the most
13279
13144
  * significant bit growing down (`true`), or the least significant
13280
13145
  * bit growing up (`false`).
@@ -13282,65 +13147,56 @@ var solanaWeb3 = (function (exports) {
13282
13147
  * **NOTE** Regardless of this value, the least significant bit of
13283
13148
  * any {@link BitField} value is the least significant bit of the
13284
13149
  * corresponding section of the packed value. */
13285
- _this.msb = !!msb;
13150
+ this.msb = !!msb;
13286
13151
  /** The sequence of {@link BitField} layouts that comprise the
13287
13152
  * packed structure.
13288
13153
  *
13289
13154
  * **NOTE** The array remains mutable to allow fields to be {@link
13290
13155
  * BitStructure#addField|added} after construction. Users should
13291
13156
  * not manipulate the content of this property.*/
13292
- _this.fields = [];
13157
+ this.fields = [];
13293
13158
  /* Storage for the value. Capture a variable instead of using an
13294
13159
  * instance property because we don't want anything to change the
13295
13160
  * value without going through the mutator. */
13296
- var value = 0;
13297
- _this._packedSetValue = function (v) {
13161
+ let value = 0;
13162
+ this._packedSetValue = function (v) {
13298
13163
  value = fixBitwiseResult(v);
13299
13164
  return this;
13300
13165
  };
13301
- _this._packedGetValue = function () {
13166
+ this._packedGetValue = function () {
13302
13167
  return value;
13303
13168
  };
13304
- return _this;
13305
13169
  }
13306
13170
  /** @override */
13307
- BitStructure.prototype.decode = function (b, offset) {
13308
- var dest = this.makeDestinationObject();
13309
- if (undefined === offset) {
13310
- offset = 0;
13311
- }
13312
- var value = this.word.decode(b, offset);
13171
+ decode(b, offset = 0) {
13172
+ const dest = this.makeDestinationObject();
13173
+ const value = this.word.decode(b, offset);
13313
13174
  this._packedSetValue(value);
13314
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
13315
- var fd = _a[_i];
13175
+ for (const fd of this.fields) {
13316
13176
  if (undefined !== fd.property) {
13317
- dest[fd.property] = fd.decode(value);
13177
+ dest[fd.property] = fd.decode(b);
13318
13178
  }
13319
13179
  }
13320
13180
  return dest;
13321
- };
13181
+ }
13322
13182
  /** Implement {@link Layout#encode|encode} for {@link BitStructure}.
13323
13183
  *
13324
13184
  * If `src` is missing a property for a member with a defined {@link
13325
13185
  * Layout#property|property} the corresponding region of the packed
13326
13186
  * value is left unmodified. Unused bits are also left unmodified. */
13327
- BitStructure.prototype.encode = function (src, b, offset) {
13328
- if (undefined === offset) {
13329
- offset = 0;
13330
- }
13331
- var value = this.word.decode(b, offset);
13187
+ encode(src, b, offset = 0) {
13188
+ const value = this.word.decode(b, offset);
13332
13189
  this._packedSetValue(value);
13333
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
13334
- var fd = _a[_i];
13190
+ for (const fd of this.fields) {
13335
13191
  if (undefined !== fd.property) {
13336
- var fv = src[fd.property];
13192
+ const fv = src[fd.property];
13337
13193
  if (undefined !== fv) {
13338
13194
  fd.encode(fv);
13339
13195
  }
13340
13196
  }
13341
13197
  }
13342
13198
  return this.word.encode(this._packedGetValue(), b, offset);
13343
- };
13199
+ }
13344
13200
  /** Register a new bitfield with a containing bit structure. The
13345
13201
  * resulting bitfield is returned.
13346
13202
  *
@@ -13350,11 +13206,11 @@ var solanaWeb3 = (function (exports) {
13350
13206
  * Layout#property|property}.
13351
13207
  *
13352
13208
  * @return {BitField} */
13353
- BitStructure.prototype.addField = function (bits, property) {
13354
- var bf = new BitField(this, bits, property);
13209
+ addField(bits, property) {
13210
+ const bf = new BitField(this, bits, property);
13355
13211
  this.fields.push(bf);
13356
13212
  return bf;
13357
- };
13213
+ }
13358
13214
  /** As with {@link BitStructure#addField|addField} for single-bit
13359
13215
  * fields with `boolean` value representation.
13360
13216
  *
@@ -13362,13 +13218,14 @@ var solanaWeb3 = (function (exports) {
13362
13218
  * Layout#property|property}.
13363
13219
  *
13364
13220
  * @return {Boolean} */
13365
- BitStructure.prototype.addBoolean = function (property) {
13221
+ // `Boolean` conflicts with the native primitive type
13222
+ // eslint-disable-next-line @typescript-eslint/ban-types
13223
+ addBoolean(property) {
13366
13224
  // This is my Boolean, not the Javascript one.
13367
- // eslint-disable-next-line no-new-wrappers
13368
- var bf = new Boolean$1(this, property);
13225
+ const bf = new Boolean$1(this, property);
13369
13226
  this.fields.push(bf);
13370
13227
  return bf;
13371
- };
13228
+ }
13372
13229
  /**
13373
13230
  * Get access to the bit field for a given property.
13374
13231
  *
@@ -13377,20 +13234,18 @@ var solanaWeb3 = (function (exports) {
13377
13234
  * @return {BitField} - the field associated with `property`, or
13378
13235
  * undefined if there is no such property.
13379
13236
  */
13380
- BitStructure.prototype.fieldFor = function (property) {
13237
+ fieldFor(property) {
13381
13238
  if ('string' !== typeof property) {
13382
13239
  throw new TypeError('property must be string');
13383
13240
  }
13384
- for (var _i = 0, _a = this.fields; _i < _a.length; _i++) {
13385
- var fd = _a[_i];
13241
+ for (const fd of this.fields) {
13386
13242
  if (fd.property === property) {
13387
13243
  return fd;
13388
13244
  }
13389
13245
  }
13390
13246
  return undefined;
13391
- };
13392
- return BitStructure;
13393
- }(Layout));
13247
+ }
13248
+ }
13394
13249
  Layout$1.BitStructure = BitStructure;
13395
13250
  /**
13396
13251
  * Represent a sequence of bits within a {@link BitStructure}.
@@ -13412,16 +13267,16 @@ var solanaWeb3 = (function (exports) {
13412
13267
  * @param {string} [property] - initializer for {@link
13413
13268
  * Layout#property|property}.
13414
13269
  */
13415
- var BitField = /** @class */ (function () {
13416
- function BitField(container, bits, property) {
13270
+ class BitField {
13271
+ constructor(container, bits, property) {
13417
13272
  if (!(container instanceof BitStructure)) {
13418
13273
  throw new TypeError('container must be a BitStructure');
13419
13274
  }
13420
13275
  if ((!Number.isInteger(bits)) || (0 >= bits)) {
13421
13276
  throw new TypeError('bits must be positive integer');
13422
13277
  }
13423
- var totalBits = 8 * container.span;
13424
- var usedBits = container.fields.reduce(function (sum, fd) { return sum + fd.bits; }, 0);
13278
+ const totalBits = 8 * container.span;
13279
+ const usedBits = container.fields.reduce((sum, fd) => sum + fd.bits, 0);
13425
13280
  if ((bits + usedBits) > totalBits) {
13426
13281
  throw new Error('bits too long for span remainder ('
13427
13282
  + (totalBits - usedBits) + ' of '
@@ -13465,30 +13320,30 @@ var solanaWeb3 = (function (exports) {
13465
13320
  }
13466
13321
  /** Store a value into the corresponding subsequence of the containing
13467
13322
  * bit field. */
13468
- BitField.prototype.decode = function (b, offset) {
13469
- var word = this.container._packedGetValue();
13470
- var wordValue = fixBitwiseResult(word & this.wordMask);
13471
- var value = wordValue >>> this.start;
13323
+ decode(b, offset) {
13324
+ const word = this.container._packedGetValue();
13325
+ const wordValue = fixBitwiseResult(word & this.wordMask);
13326
+ const value = wordValue >>> this.start;
13472
13327
  return value;
13473
- };
13328
+ }
13474
13329
  /** Store a value into the corresponding subsequence of the containing
13475
13330
  * bit field.
13476
13331
  *
13477
13332
  * **NOTE** This is not a specialization of {@link
13478
13333
  * Layout#encode|Layout.encode} and there is no return value. */
13479
- BitField.prototype.encode = function (value) {
13480
- if ((!Number.isInteger(value))
13334
+ encode(value) {
13335
+ if ('number' !== typeof value
13336
+ || !Number.isInteger(value)
13481
13337
  || (value !== fixBitwiseResult(value & this.valueMask))) {
13482
13338
  throw new TypeError(nameWithProperty('BitField.encode', this)
13483
13339
  + ' value must be integer not exceeding ' + this.valueMask);
13484
13340
  }
13485
- var word = this.container._packedGetValue();
13486
- var wordValue = fixBitwiseResult(value << this.start);
13341
+ const word = this.container._packedGetValue();
13342
+ const wordValue = fixBitwiseResult(value << this.start);
13487
13343
  this.container._packedSetValue(fixBitwiseResult(word & ~this.wordMask)
13488
13344
  | wordValue);
13489
- };
13490
- return BitField;
13491
- }());
13345
+ }
13346
+ }
13492
13347
  Layout$1.BitField = BitField;
13493
13348
  /**
13494
13349
  * Represent a single bit within a {@link BitStructure} as a
@@ -13507,27 +13362,25 @@ var solanaWeb3 = (function (exports) {
13507
13362
  * @augments {BitField}
13508
13363
  */
13509
13364
  /* eslint-disable no-extend-native */
13510
- var Boolean$1 = /** @class */ (function (_super) {
13511
- __extends(Boolean, _super);
13512
- function Boolean(container, property) {
13513
- return _super.call(this, container, 1, property) || this;
13365
+ class Boolean$1 extends BitField {
13366
+ constructor(container, property) {
13367
+ super(container, 1, property);
13514
13368
  }
13515
13369
  /** Override {@link BitField#decode|decode} for {@link Boolean|Boolean}.
13516
13370
  *
13517
13371
  * @returns {boolean} */
13518
- Boolean.prototype.decode = function (b, offset) {
13519
- return !!BitField.prototype.decode.call(this, b, offset);
13520
- };
13372
+ decode(b, offset) {
13373
+ return !!super.decode(b, offset);
13374
+ }
13521
13375
  /** @override */
13522
- Boolean.prototype.encode = function (value) {
13376
+ encode(value) {
13523
13377
  if ('boolean' === typeof value) {
13524
13378
  // BitField requires integer values
13525
13379
  value = +value;
13526
13380
  }
13527
- return BitField.prototype.encode.call(this, value);
13528
- };
13529
- return Boolean;
13530
- }(BitField));
13381
+ super.encode(value);
13382
+ }
13383
+ }
13531
13384
  Layout$1.Boolean = Boolean$1;
13532
13385
  /* eslint-enable no-extend-native */
13533
13386
  /**
@@ -13544,54 +13397,48 @@ var solanaWeb3 = (function (exports) {
13544
13397
  *
13545
13398
  * @augments {Layout}
13546
13399
  */
13547
- var Blob$1 = /** @class */ (function (_super) {
13548
- __extends(Blob, _super);
13549
- function Blob(length, property) {
13550
- var _this = this;
13400
+ class Blob$1 extends Layout {
13401
+ constructor(length, property) {
13551
13402
  if (!(((length instanceof ExternalLayout) && length.isCount())
13552
13403
  || (Number.isInteger(length) && (0 <= length)))) {
13553
13404
  throw new TypeError('length must be positive integer '
13554
13405
  + 'or an unsigned integer ExternalLayout');
13555
13406
  }
13556
- var span = -1;
13407
+ let span = -1;
13557
13408
  if (!(length instanceof ExternalLayout)) {
13558
13409
  span = length;
13559
13410
  }
13560
- _this = _super.call(this, span, property) || this;
13411
+ super(span, property);
13561
13412
  /** The number of bytes in the blob.
13562
13413
  *
13563
13414
  * This may be a non-negative integer, or an instance of {@link
13564
13415
  * ExternalLayout} that satisfies {@link
13565
13416
  * ExternalLayout#isCount|isCount()}. */
13566
- _this.length = length;
13567
- return _this;
13417
+ this.length = length;
13568
13418
  }
13569
13419
  /** @override */
13570
- Blob.prototype.getSpan = function (b, offset) {
13571
- var span = this.span;
13420
+ getSpan(b, offset) {
13421
+ let span = this.span;
13572
13422
  if (0 > span) {
13573
13423
  span = this.length.decode(b, offset);
13574
13424
  }
13575
13425
  return span;
13576
- };
13426
+ }
13577
13427
  /** @override */
13578
- Blob.prototype.decode = function (b, offset) {
13579
- if (undefined === offset) {
13580
- offset = 0;
13581
- }
13582
- var span = this.span;
13428
+ decode(b, offset = 0) {
13429
+ let span = this.span;
13583
13430
  if (0 > span) {
13584
13431
  span = this.length.decode(b, offset);
13585
13432
  }
13586
13433
  return uint8ArrayToBuffer(b).slice(offset, offset + span);
13587
- };
13434
+ }
13588
13435
  /** Implement {@link Layout#encode|encode} for {@link Blob}.
13589
13436
  *
13590
13437
  * **NOTE** If {@link Layout#count|count} is an instance of {@link
13591
13438
  * ExternalLayout} then the length of `src` will be encoded as the
13592
13439
  * count after `src` is encoded. */
13593
- Blob.prototype.encode = function (src, b, offset) {
13594
- var span = this.length;
13440
+ encode(src, b, offset) {
13441
+ let span = this.length;
13595
13442
  if (this.length instanceof ExternalLayout) {
13596
13443
  span = src.length;
13597
13444
  }
@@ -13602,15 +13449,14 @@ var solanaWeb3 = (function (exports) {
13602
13449
  if ((offset + span) > b.length) {
13603
13450
  throw new RangeError('encoding overruns Uint8Array');
13604
13451
  }
13605
- var srcBuffer = uint8ArrayToBuffer(src);
13452
+ const srcBuffer = uint8ArrayToBuffer(src);
13606
13453
  uint8ArrayToBuffer(b).write(srcBuffer.toString('hex'), offset, span, 'hex');
13607
13454
  if (this.length instanceof ExternalLayout) {
13608
13455
  this.length.encode(span, b, offset);
13609
13456
  }
13610
13457
  return span;
13611
- };
13612
- return Blob;
13613
- }(Layout));
13458
+ }
13459
+ }
13614
13460
  Layout$1.Blob = Blob$1;
13615
13461
  /**
13616
13462
  * Contain a `NUL`-terminated UTF8 string.
@@ -13625,54 +13471,43 @@ var solanaWeb3 = (function (exports) {
13625
13471
  *
13626
13472
  * @augments {Layout}
13627
13473
  */
13628
- var CString = /** @class */ (function (_super) {
13629
- __extends(CString, _super);
13630
- function CString(property) {
13631
- return _super.call(this, -1, property) || this;
13474
+ class CString extends Layout {
13475
+ constructor(property) {
13476
+ super(-1, property);
13632
13477
  }
13633
13478
  /** @override */
13634
- CString.prototype.getSpan = function (b, offset) {
13479
+ getSpan(b, offset = 0) {
13635
13480
  checkUint8Array(b);
13636
- if (undefined === offset) {
13637
- offset = 0;
13638
- }
13639
- var idx = offset;
13481
+ let idx = offset;
13640
13482
  while ((idx < b.length) && (0 !== b[idx])) {
13641
13483
  idx += 1;
13642
13484
  }
13643
13485
  return 1 + idx - offset;
13644
- };
13486
+ }
13645
13487
  /** @override */
13646
- CString.prototype.decode = function (b, offset) {
13647
- if (undefined === offset) {
13648
- offset = 0;
13649
- }
13650
- var span = this.getSpan(b, offset);
13488
+ decode(b, offset = 0) {
13489
+ const span = this.getSpan(b, offset);
13651
13490
  return uint8ArrayToBuffer(b).slice(offset, offset + span - 1).toString('utf-8');
13652
- };
13491
+ }
13653
13492
  /** @override */
13654
- CString.prototype.encode = function (src, b, offset) {
13655
- if (undefined === offset) {
13656
- offset = 0;
13657
- }
13493
+ encode(src, b, offset = 0) {
13658
13494
  /* Must force this to a string, lest it be a number and the
13659
13495
  * "utf8-encoding" below actually allocate a buffer of length
13660
13496
  * src */
13661
13497
  if ('string' !== typeof src) {
13662
- src = src.toString();
13498
+ src = String(src);
13663
13499
  }
13664
- var srcb = buffer_1.Buffer.from(src, 'utf8');
13665
- var span = srcb.length;
13500
+ const srcb = buffer_1.Buffer.from(src, 'utf8');
13501
+ const span = srcb.length;
13666
13502
  if ((offset + span) > b.length) {
13667
13503
  throw new RangeError('encoding overruns Buffer');
13668
13504
  }
13669
- var buffer = uint8ArrayToBuffer(b);
13505
+ const buffer = uint8ArrayToBuffer(b);
13670
13506
  srcb.copy(buffer, offset);
13671
13507
  buffer[offset + span] = 0;
13672
13508
  return span + 1;
13673
- };
13674
- return CString;
13675
- }(Layout));
13509
+ }
13510
+ }
13676
13511
  Layout$1.CString = CString;
13677
13512
  /**
13678
13513
  * Contain a UTF8 string with implicit length.
@@ -13693,10 +13528,8 @@ var solanaWeb3 = (function (exports) {
13693
13528
  *
13694
13529
  * @augments {Layout}
13695
13530
  */
13696
- var UTF8 = /** @class */ (function (_super) {
13697
- __extends(UTF8, _super);
13698
- function UTF8(maxSpan, property) {
13699
- var _this = this;
13531
+ class UTF8 extends Layout {
13532
+ constructor(maxSpan, property) {
13700
13533
  if (('string' === typeof maxSpan) && (undefined === property)) {
13701
13534
  property = maxSpan;
13702
13535
  maxSpan = undefined;
@@ -13707,7 +13540,7 @@ var solanaWeb3 = (function (exports) {
13707
13540
  else if (!Number.isInteger(maxSpan)) {
13708
13541
  throw new TypeError('maxSpan must be an integer');
13709
13542
  }
13710
- _this = _super.call(this, -1, property) || this;
13543
+ super(-1, property);
13711
13544
  /** The maximum span of the layout in bytes.
13712
13545
  *
13713
13546
  * Positive values are generally expected. Zero is abnormal.
@@ -13716,42 +13549,32 @@ var solanaWeb3 = (function (exports) {
13716
13549
  *
13717
13550
  * A negative value indicates that there is no bound on the length
13718
13551
  * of the content. */
13719
- _this.maxSpan = maxSpan;
13720
- return _this;
13552
+ this.maxSpan = maxSpan;
13721
13553
  }
13722
13554
  /** @override */
13723
- UTF8.prototype.getSpan = function (b, offset) {
13555
+ getSpan(b, offset = 0) {
13724
13556
  checkUint8Array(b);
13725
- if (undefined === offset) {
13726
- offset = 0;
13727
- }
13728
13557
  return b.length - offset;
13729
- };
13558
+ }
13730
13559
  /** @override */
13731
- UTF8.prototype.decode = function (b, offset) {
13732
- if (undefined === offset) {
13733
- offset = 0;
13734
- }
13735
- var span = this.getSpan(b, offset);
13560
+ decode(b, offset = 0) {
13561
+ const span = this.getSpan(b, offset);
13736
13562
  if ((0 <= this.maxSpan)
13737
13563
  && (this.maxSpan < span)) {
13738
13564
  throw new RangeError('text length exceeds maxSpan');
13739
13565
  }
13740
13566
  return uint8ArrayToBuffer(b).slice(offset, offset + span).toString('utf-8');
13741
- };
13567
+ }
13742
13568
  /** @override */
13743
- UTF8.prototype.encode = function (src, b, offset) {
13744
- if (undefined === offset) {
13745
- offset = 0;
13746
- }
13569
+ encode(src, b, offset = 0) {
13747
13570
  /* Must force this to a string, lest it be a number and the
13748
13571
  * "utf8-encoding" below actually allocate a buffer of length
13749
13572
  * src */
13750
13573
  if ('string' !== typeof src) {
13751
- src = src.toString();
13574
+ src = String(src);
13752
13575
  }
13753
- var srcb = buffer_1.Buffer.from(src, 'utf8');
13754
- var span = srcb.length;
13576
+ const srcb = buffer_1.Buffer.from(src, 'utf8');
13577
+ const span = srcb.length;
13755
13578
  if ((0 <= this.maxSpan)
13756
13579
  && (this.maxSpan < span)) {
13757
13580
  throw new RangeError('text length exceeds maxSpan');
@@ -13761,9 +13584,8 @@ var solanaWeb3 = (function (exports) {
13761
13584
  }
13762
13585
  srcb.copy(uint8ArrayToBuffer(b), offset);
13763
13586
  return span;
13764
- };
13765
- return UTF8;
13766
- }(Layout));
13587
+ }
13588
+ }
13767
13589
  Layout$1.UTF8 = UTF8;
13768
13590
  /**
13769
13591
  * Contain a constant value.
@@ -13784,10 +13606,9 @@ var solanaWeb3 = (function (exports) {
13784
13606
  *
13785
13607
  * @augments {Layout}
13786
13608
  */
13787
- var Constant = /** @class */ (function (_super) {
13788
- __extends(Constant, _super);
13789
- function Constant(value, property) {
13790
- var _this = _super.call(this, 0, property) || this;
13609
+ class Constant extends Layout {
13610
+ constructor(value, property) {
13611
+ super(0, property);
13791
13612
  /** The value produced by this constant when the layout is {@link
13792
13613
  * Constant#decode|decoded}.
13793
13614
  *
@@ -13797,135 +13618,127 @@ var solanaWeb3 = (function (exports) {
13797
13618
  * **WARNING** If `value` passed in the constructor was not
13798
13619
  * frozen, it is possible for users of decoded values to change
13799
13620
  * the content of the value. */
13800
- _this.value = value;
13801
- return _this;
13621
+ this.value = value;
13802
13622
  }
13803
13623
  /** @override */
13804
- Constant.prototype.decode = function (b, offset) {
13624
+ decode(b, offset) {
13805
13625
  return this.value;
13806
- };
13626
+ }
13807
13627
  /** @override */
13808
- Constant.prototype.encode = function (src, b, offset) {
13628
+ encode(src, b, offset) {
13809
13629
  /* Constants take no space */
13810
13630
  return 0;
13811
- };
13812
- return Constant;
13813
- }(Layout));
13631
+ }
13632
+ }
13814
13633
  Layout$1.Constant = Constant;
13815
13634
  /** Factory for {@link GreedyCount}. */
13816
- Layout$1.greedy = (function (elementSpan, property) { return new GreedyCount(elementSpan, property); });
13635
+ Layout$1.greedy = ((elementSpan, property) => new GreedyCount(elementSpan, property));
13817
13636
  /** Factory for {@link OffsetLayout}. */
13818
- var offset = Layout$1.offset = (function (layout, offset, property) { return new OffsetLayout(layout, offset, property); });
13637
+ var offset = Layout$1.offset = ((layout, offset, property) => new OffsetLayout(layout, offset, property));
13819
13638
  /** Factory for {@link UInt|unsigned int layouts} spanning one
13820
13639
  * byte. */
13821
- var u8 = Layout$1.u8 = (function (property) { return new UInt(1, property); });
13640
+ var u8 = Layout$1.u8 = ((property) => new UInt(1, property));
13822
13641
  /** Factory for {@link UInt|little-endian unsigned int layouts}
13823
13642
  * spanning two bytes. */
13824
- var u16 = Layout$1.u16 = (function (property) { return new UInt(2, property); });
13643
+ var u16 = Layout$1.u16 = ((property) => new UInt(2, property));
13825
13644
  /** Factory for {@link UInt|little-endian unsigned int layouts}
13826
13645
  * spanning three bytes. */
13827
- Layout$1.u24 = (function (property) { return new UInt(3, property); });
13646
+ Layout$1.u24 = ((property) => new UInt(3, property));
13828
13647
  /** Factory for {@link UInt|little-endian unsigned int layouts}
13829
13648
  * spanning four bytes. */
13830
- var u32 = Layout$1.u32 = (function (property) { return new UInt(4, property); });
13649
+ var u32 = Layout$1.u32 = ((property) => new UInt(4, property));
13831
13650
  /** Factory for {@link UInt|little-endian unsigned int layouts}
13832
13651
  * spanning five bytes. */
13833
- Layout$1.u40 = (function (property) { return new UInt(5, property); });
13652
+ Layout$1.u40 = ((property) => new UInt(5, property));
13834
13653
  /** Factory for {@link UInt|little-endian unsigned int layouts}
13835
13654
  * spanning six bytes. */
13836
- Layout$1.u48 = (function (property) { return new UInt(6, property); });
13655
+ Layout$1.u48 = ((property) => new UInt(6, property));
13837
13656
  /** Factory for {@link NearUInt64|little-endian unsigned int
13838
13657
  * layouts} interpreted as Numbers. */
13839
- var nu64 = Layout$1.nu64 = (function (property) { return new NearUInt64(property); });
13658
+ var nu64 = Layout$1.nu64 = ((property) => new NearUInt64(property));
13840
13659
  /** Factory for {@link UInt|big-endian unsigned int layouts}
13841
13660
  * spanning two bytes. */
13842
- Layout$1.u16be = (function (property) { return new UIntBE(2, property); });
13661
+ Layout$1.u16be = ((property) => new UIntBE(2, property));
13843
13662
  /** Factory for {@link UInt|big-endian unsigned int layouts}
13844
13663
  * spanning three bytes. */
13845
- Layout$1.u24be = (function (property) { return new UIntBE(3, property); });
13664
+ Layout$1.u24be = ((property) => new UIntBE(3, property));
13846
13665
  /** Factory for {@link UInt|big-endian unsigned int layouts}
13847
13666
  * spanning four bytes. */
13848
- Layout$1.u32be = (function (property) { return new UIntBE(4, property); });
13667
+ Layout$1.u32be = ((property) => new UIntBE(4, property));
13849
13668
  /** Factory for {@link UInt|big-endian unsigned int layouts}
13850
13669
  * spanning five bytes. */
13851
- Layout$1.u40be = (function (property) { return new UIntBE(5, property); });
13670
+ Layout$1.u40be = ((property) => new UIntBE(5, property));
13852
13671
  /** Factory for {@link UInt|big-endian unsigned int layouts}
13853
13672
  * spanning six bytes. */
13854
- Layout$1.u48be = (function (property) { return new UIntBE(6, property); });
13673
+ Layout$1.u48be = ((property) => new UIntBE(6, property));
13855
13674
  /** Factory for {@link NearUInt64BE|big-endian unsigned int
13856
13675
  * layouts} interpreted as Numbers. */
13857
- Layout$1.nu64be = (function (property) { return new NearUInt64BE(property); });
13676
+ Layout$1.nu64be = ((property) => new NearUInt64BE(property));
13858
13677
  /** Factory for {@link Int|signed int layouts} spanning one
13859
13678
  * byte. */
13860
- Layout$1.s8 = (function (property) { return new Int(1, property); });
13679
+ Layout$1.s8 = ((property) => new Int(1, property));
13861
13680
  /** Factory for {@link Int|little-endian signed int layouts}
13862
13681
  * spanning two bytes. */
13863
- Layout$1.s16 = (function (property) { return new Int(2, property); });
13682
+ Layout$1.s16 = ((property) => new Int(2, property));
13864
13683
  /** Factory for {@link Int|little-endian signed int layouts}
13865
13684
  * spanning three bytes. */
13866
- Layout$1.s24 = (function (property) { return new Int(3, property); });
13685
+ Layout$1.s24 = ((property) => new Int(3, property));
13867
13686
  /** Factory for {@link Int|little-endian signed int layouts}
13868
13687
  * spanning four bytes. */
13869
- Layout$1.s32 = (function (property) { return new Int(4, property); });
13688
+ Layout$1.s32 = ((property) => new Int(4, property));
13870
13689
  /** Factory for {@link Int|little-endian signed int layouts}
13871
13690
  * spanning five bytes. */
13872
- Layout$1.s40 = (function (property) { return new Int(5, property); });
13691
+ Layout$1.s40 = ((property) => new Int(5, property));
13873
13692
  /** Factory for {@link Int|little-endian signed int layouts}
13874
13693
  * spanning six bytes. */
13875
- Layout$1.s48 = (function (property) { return new Int(6, property); });
13694
+ Layout$1.s48 = ((property) => new Int(6, property));
13876
13695
  /** Factory for {@link NearInt64|little-endian signed int layouts}
13877
13696
  * interpreted as Numbers. */
13878
- var ns64 = Layout$1.ns64 = (function (property) { return new NearInt64(property); });
13697
+ var ns64 = Layout$1.ns64 = ((property) => new NearInt64(property));
13879
13698
  /** Factory for {@link Int|big-endian signed int layouts}
13880
13699
  * spanning two bytes. */
13881
- Layout$1.s16be = (function (property) { return new IntBE(2, property); });
13700
+ Layout$1.s16be = ((property) => new IntBE(2, property));
13882
13701
  /** Factory for {@link Int|big-endian signed int layouts}
13883
13702
  * spanning three bytes. */
13884
- Layout$1.s24be = (function (property) { return new IntBE(3, property); });
13703
+ Layout$1.s24be = ((property) => new IntBE(3, property));
13885
13704
  /** Factory for {@link Int|big-endian signed int layouts}
13886
13705
  * spanning four bytes. */
13887
- Layout$1.s32be = (function (property) { return new IntBE(4, property); });
13706
+ Layout$1.s32be = ((property) => new IntBE(4, property));
13888
13707
  /** Factory for {@link Int|big-endian signed int layouts}
13889
13708
  * spanning five bytes. */
13890
- Layout$1.s40be = (function (property) { return new IntBE(5, property); });
13709
+ Layout$1.s40be = ((property) => new IntBE(5, property));
13891
13710
  /** Factory for {@link Int|big-endian signed int layouts}
13892
13711
  * spanning six bytes. */
13893
- Layout$1.s48be = (function (property) { return new IntBE(6, property); });
13712
+ Layout$1.s48be = ((property) => new IntBE(6, property));
13894
13713
  /** Factory for {@link NearInt64BE|big-endian signed int layouts}
13895
13714
  * interpreted as Numbers. */
13896
- Layout$1.ns64be = (function (property) { return new NearInt64BE(property); });
13715
+ Layout$1.ns64be = ((property) => new NearInt64BE(property));
13897
13716
  /** Factory for {@link Float|little-endian 32-bit floating point} values. */
13898
- Layout$1.f32 = (function (property) { return new Float(property); });
13717
+ Layout$1.f32 = ((property) => new Float(property));
13899
13718
  /** Factory for {@link FloatBE|big-endian 32-bit floating point} values. */
13900
- Layout$1.f32be = (function (property) { return new FloatBE(property); });
13719
+ Layout$1.f32be = ((property) => new FloatBE(property));
13901
13720
  /** Factory for {@link Double|little-endian 64-bit floating point} values. */
13902
- Layout$1.f64 = (function (property) { return new Double(property); });
13721
+ Layout$1.f64 = ((property) => new Double(property));
13903
13722
  /** Factory for {@link DoubleBE|big-endian 64-bit floating point} values. */
13904
- Layout$1.f64be = (function (property) { return new DoubleBE(property); });
13723
+ Layout$1.f64be = ((property) => new DoubleBE(property));
13905
13724
  /** Factory for {@link Structure} values. */
13906
- var struct = Layout$1.struct = (function (fields, property, decodePrefixes) {
13907
- return new Structure(fields, property, decodePrefixes);
13908
- });
13725
+ var struct = Layout$1.struct = ((fields, property, decodePrefixes) => new Structure(fields, property, decodePrefixes));
13909
13726
  /** Factory for {@link BitStructure} values. */
13910
- Layout$1.bits = (function (word, msb, property) { return new BitStructure(word, msb, property); });
13727
+ Layout$1.bits = ((word, msb, property) => new BitStructure(word, msb, property));
13911
13728
  /** Factory for {@link Sequence} values. */
13912
- var seq = Layout$1.seq = (function (elementLayout, count, property) {
13913
- return new Sequence(elementLayout, count, property);
13914
- });
13729
+ var seq = Layout$1.seq = ((elementLayout, count, property) => new Sequence(elementLayout, count, property));
13915
13730
  /** Factory for {@link Union} values. */
13916
- Layout$1.union = (function (discr, defaultLayout, property) {
13917
- return new Union(discr, defaultLayout, property);
13918
- });
13731
+ Layout$1.union = ((discr, defaultLayout, property) => new Union(discr, defaultLayout, property));
13919
13732
  /** Factory for {@link UnionLayoutDiscriminator} values. */
13920
- Layout$1.unionLayoutDiscriminator = (function (layout, property) { return new UnionLayoutDiscriminator(layout, property); });
13733
+ Layout$1.unionLayoutDiscriminator = ((layout, property) => new UnionLayoutDiscriminator(layout, property));
13921
13734
  /** Factory for {@link Blob} values. */
13922
- var blob = Layout$1.blob = (function (length, property) { return new Blob$1(length, property); });
13735
+ var blob = Layout$1.blob = ((length, property) => new Blob$1(length, property));
13923
13736
  /** Factory for {@link CString} values. */
13924
- Layout$1.cstr = (function (property) { return new CString(property); });
13737
+ Layout$1.cstr = ((property) => new CString(property));
13925
13738
  /** Factory for {@link UTF8} values. */
13926
- Layout$1.utf8 = (function (maxSpan, property) { return new UTF8(maxSpan, property); });
13739
+ Layout$1.utf8 = ((maxSpan, property) => new UTF8(maxSpan, property));
13927
13740
  /** Factory for {@link Constant} values. */
13928
- Layout$1.constant = (function (value, property) { return new Constant(value, property); });
13741
+ Layout$1.constant = ((value, property) => new Constant(value, property));
13929
13742
 
13930
13743
  /**
13931
13744
  * Layout for a public key
@@ -13934,10 +13747,10 @@ var solanaWeb3 = (function (exports) {
13934
13747
  const publicKey = (property = 'publicKey') => {
13935
13748
  return blob(32, property);
13936
13749
  };
13750
+
13937
13751
  /**
13938
13752
  * Layout for a Rust String type
13939
13753
  */
13940
-
13941
13754
  const rustString = (property = 'string') => {
13942
13755
  const rsl = struct([u32('length'), u32('lengthPadding'), blob(offset(u32(), -8), 'chars')], property);
13943
13756
 
@@ -13945,24 +13758,26 @@ var solanaWeb3 = (function (exports) {
13945
13758
 
13946
13759
  const _encode = rsl.encode.bind(rsl);
13947
13760
 
13948
- rsl.decode = (buffer, offset) => {
13949
- const data = _decode(buffer, offset);
13761
+ const rslShim = rsl;
13762
+
13763
+ rslShim.decode = (b, offset) => {
13764
+ const data = _decode(b, offset);
13950
13765
 
13951
- return data['chars'].toString('utf8');
13766
+ return data['chars'].toString();
13952
13767
  };
13953
13768
 
13954
- rsl.encode = (str, buffer$1, offset) => {
13769
+ rslShim.encode = (str, b, offset) => {
13955
13770
  const data = {
13956
13771
  chars: buffer.Buffer.from(str, 'utf8')
13957
13772
  };
13958
- return _encode(data, buffer$1, offset);
13773
+ return _encode(data, b, offset);
13959
13774
  };
13960
13775
 
13961
- rsl.alloc = str => {
13776
+ rslShim.alloc = str => {
13962
13777
  return u32().span + u32().span + buffer.Buffer.from(str, 'utf8').length;
13963
13778
  };
13964
13779
 
13965
- return rsl;
13780
+ return rslShim;
13966
13781
  };
13967
13782
  /**
13968
13783
  * Layout for an Authorized object
@@ -14082,7 +13897,7 @@ var solanaWeb3 = (function (exports) {
14082
13897
  accounts,
14083
13898
  programIdIndex
14084
13899
  } = instruction;
14085
- const data = bs58$1.decode(instruction.data);
13900
+ const data = Array.from(bs58$1.decode(instruction.data));
14086
13901
  let keyIndicesCount = [];
14087
13902
  encodeLength(keyIndicesCount, accounts.length);
14088
13903
  let dataCount = [];
@@ -14090,7 +13905,7 @@ var solanaWeb3 = (function (exports) {
14090
13905
  return {
14091
13906
  programIdIndex,
14092
13907
  keyIndicesCount: buffer.Buffer.from(keyIndicesCount),
14093
- keyIndices: buffer.Buffer.from(accounts),
13908
+ keyIndices: accounts,
14094
13909
  dataLength: buffer.Buffer.from(dataCount),
14095
13910
  data
14096
13911
  };
@@ -14494,6 +14309,14 @@ var solanaWeb3 = (function (exports) {
14494
14309
  serializeMessage() {
14495
14310
  return this._compile().serialize();
14496
14311
  }
14312
+ /**
14313
+ * Get the estimated fee associated with a transaction
14314
+ */
14315
+
14316
+
14317
+ async getEstimatedFee(connection) {
14318
+ return (await connection.getFeeForMessage(this.compileMessage())).value;
14319
+ }
14497
14320
  /**
14498
14321
  * Specify the public keys which will be used to sign the Transaction.
14499
14322
  * The first signer will be used as the transaction fee payer account.
@@ -14857,10 +14680,6 @@ var solanaWeb3 = (function (exports) {
14857
14680
  return new Promise(resolve => setTimeout(resolve, ms));
14858
14681
  }
14859
14682
 
14860
- /**
14861
- * @internal
14862
- */
14863
-
14864
14683
  /**
14865
14684
  * Populate a buffer of instruction data using an InstructionType
14866
14685
  * @internal
@@ -15660,11 +15479,11 @@ var solanaWeb3 = (function (exports) {
15660
15479
  }
15661
15480
  SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
15662
15481
 
15482
+ // Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the
15663
15483
  // rest of the Transaction fields
15664
15484
  //
15665
15485
  // TODO: replace 300 with a proper constant for the size of the other
15666
15486
  // Transaction fields
15667
-
15668
15487
  const CHUNK_SIZE = PACKET_DATA_SIZE - 300;
15669
15488
  /**
15670
15489
  * Program loader interface
@@ -15772,7 +15591,9 @@ var solanaWeb3 = (function (exports) {
15772
15591
  instruction: 0,
15773
15592
  // Load instruction
15774
15593
  offset: offset$1,
15775
- bytes
15594
+ bytes: bytes,
15595
+ bytesLength: 0,
15596
+ bytesLengthPadding: 0
15776
15597
  }, data);
15777
15598
  const transaction = new Transaction().add({
15778
15599
  keys: [{
@@ -16404,7 +16225,7 @@ var solanaWeb3 = (function (exports) {
16404
16225
 
16405
16226
  return exports;
16406
16227
 
16407
- })({}));
16228
+ }))({});
16408
16229
  })(__self__);
16409
16230
  __self__.fetch.ponyfill = true;
16410
16231
  // Remove "polyfill" property added by whatwg-fetch
@@ -16705,7 +16526,7 @@ var solanaWeb3 = (function (exports) {
16705
16526
 
16706
16527
 
16707
16528
  validate(value, options = {}) {
16708
- return validate(value, this, options);
16529
+ return validate$1(value, this, options);
16709
16530
  }
16710
16531
 
16711
16532
  }
@@ -16714,7 +16535,7 @@ var solanaWeb3 = (function (exports) {
16714
16535
  */
16715
16536
 
16716
16537
  function assert$b(value, struct) {
16717
- const result = validate(value, struct);
16538
+ const result = validate$1(value, struct);
16718
16539
 
16719
16540
  if (result[0]) {
16720
16541
  throw result[0];
@@ -16725,7 +16546,7 @@ var solanaWeb3 = (function (exports) {
16725
16546
  */
16726
16547
 
16727
16548
  function create(value, struct) {
16728
- const result = validate(value, struct, {
16549
+ const result = validate$1(value, struct, {
16729
16550
  coerce: true
16730
16551
  });
16731
16552
 
@@ -16740,7 +16561,7 @@ var solanaWeb3 = (function (exports) {
16740
16561
  */
16741
16562
 
16742
16563
  function mask(value, struct) {
16743
- const result = validate(value, struct, {
16564
+ const result = validate$1(value, struct, {
16744
16565
  coerce: true,
16745
16566
  mask: true
16746
16567
  });
@@ -16756,7 +16577,7 @@ var solanaWeb3 = (function (exports) {
16756
16577
  */
16757
16578
 
16758
16579
  function is(value, struct) {
16759
- const result = validate(value, struct);
16580
+ const result = validate$1(value, struct);
16760
16581
  return !result[0];
16761
16582
  }
16762
16583
  /**
@@ -16764,7 +16585,7 @@ var solanaWeb3 = (function (exports) {
16764
16585
  * value (with potential coercion) if valid.
16765
16586
  */
16766
16587
 
16767
- function validate(value, struct, options = {}) {
16588
+ function validate$1(value, struct, options = {}) {
16768
16589
  const tuples = run(value, struct, options);
16769
16590
  const tuple = shiftIterator(tuples);
16770
16591
 
@@ -17044,8 +16865,7 @@ var solanaWeb3 = (function (exports) {
17044
16865
  };
17045
16866
  }
17046
16867
 
17047
- module.exports = _interopRequireDefault;
17048
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16868
+ module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
17049
16869
  }(interopRequireDefault));
17050
16870
 
17051
16871
  var classCallCheck = {exports: {}};
@@ -17057,8 +16877,7 @@ var solanaWeb3 = (function (exports) {
17057
16877
  }
17058
16878
  }
17059
16879
 
17060
- module.exports = _classCallCheck;
17061
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16880
+ module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
17062
16881
  }(classCallCheck));
17063
16882
 
17064
16883
  var inherits$3 = {exports: {}};
@@ -17070,14 +16889,11 @@ var solanaWeb3 = (function (exports) {
17070
16889
  module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
17071
16890
  o.__proto__ = p;
17072
16891
  return o;
17073
- };
17074
-
17075
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16892
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
17076
16893
  return _setPrototypeOf(o, p);
17077
16894
  }
17078
16895
 
17079
- module.exports = _setPrototypeOf;
17080
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16896
+ module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
17081
16897
  }(setPrototypeOf));
17082
16898
 
17083
16899
  (function (module) {
@@ -17095,11 +16911,13 @@ var solanaWeb3 = (function (exports) {
17095
16911
  configurable: true
17096
16912
  }
17097
16913
  });
16914
+ Object.defineProperty(subClass, "prototype", {
16915
+ writable: false
16916
+ });
17098
16917
  if (superClass) setPrototypeOf$1(subClass, superClass);
17099
16918
  }
17100
16919
 
17101
- module.exports = _inherits;
17102
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16920
+ module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
17103
16921
  }(inherits$3));
17104
16922
 
17105
16923
  var possibleConstructorReturn = {exports: {}};
@@ -17110,25 +16928,14 @@ var solanaWeb3 = (function (exports) {
17110
16928
  function _typeof(obj) {
17111
16929
  "@babel/helpers - typeof";
17112
16930
 
17113
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
17114
- module.exports = _typeof = function _typeof(obj) {
17115
- return typeof obj;
17116
- };
17117
-
17118
- module.exports["default"] = module.exports, module.exports.__esModule = true;
17119
- } else {
17120
- module.exports = _typeof = function _typeof(obj) {
17121
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
17122
- };
17123
-
17124
- module.exports["default"] = module.exports, module.exports.__esModule = true;
17125
- }
17126
-
17127
- return _typeof(obj);
16931
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
16932
+ return typeof obj;
16933
+ } : function (obj) {
16934
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
16935
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
17128
16936
  }
17129
16937
 
17130
- module.exports = _typeof;
17131
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16938
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
17132
16939
  }(_typeof));
17133
16940
 
17134
16941
  var assertThisInitialized = {exports: {}};
@@ -17142,8 +16949,7 @@ var solanaWeb3 = (function (exports) {
17142
16949
  return self;
17143
16950
  }
17144
16951
 
17145
- module.exports = _assertThisInitialized;
17146
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16952
+ module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
17147
16953
  }(assertThisInitialized));
17148
16954
 
17149
16955
  (function (module) {
@@ -17161,8 +16967,7 @@ var solanaWeb3 = (function (exports) {
17161
16967
  return assertThisInitialized$1(self);
17162
16968
  }
17163
16969
 
17164
- module.exports = _possibleConstructorReturn;
17165
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16970
+ module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
17166
16971
  }(possibleConstructorReturn));
17167
16972
 
17168
16973
  var getPrototypeOf = {exports: {}};
@@ -17171,13 +16976,11 @@ var solanaWeb3 = (function (exports) {
17171
16976
  function _getPrototypeOf(o) {
17172
16977
  module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
17173
16978
  return o.__proto__ || Object.getPrototypeOf(o);
17174
- };
17175
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16979
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
17176
16980
  return _getPrototypeOf(o);
17177
16981
  }
17178
16982
 
17179
- module.exports = _getPrototypeOf;
17180
- module.exports["default"] = module.exports, module.exports.__esModule = true;
16983
+ module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
17181
16984
  }(getPrototypeOf));
17182
16985
 
17183
16986
  var websocket_browser = {};
@@ -17198,11 +17001,13 @@ var solanaWeb3 = (function (exports) {
17198
17001
  function _createClass(Constructor, protoProps, staticProps) {
17199
17002
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17200
17003
  if (staticProps) _defineProperties(Constructor, staticProps);
17004
+ Object.defineProperty(Constructor, "prototype", {
17005
+ writable: false
17006
+ });
17201
17007
  return Constructor;
17202
17008
  }
17203
17009
 
17204
- module.exports = _createClass;
17205
- module.exports["default"] = module.exports, module.exports.__esModule = true;
17010
+ module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
17206
17011
  }(createClass));
17207
17012
 
17208
17013
  var eventemitter3 = {exports: {}};
@@ -17762,9 +17567,9 @@ var solanaWeb3 = (function (exports) {
17762
17567
  // This is a polyfill for %IteratorPrototype% for environments that
17763
17568
  // don't natively support it.
17764
17569
  var IteratorPrototype = {};
17765
- IteratorPrototype[iteratorSymbol] = function () {
17570
+ define(IteratorPrototype, iteratorSymbol, function () {
17766
17571
  return this;
17767
- };
17572
+ });
17768
17573
 
17769
17574
  var getProto = Object.getPrototypeOf;
17770
17575
  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
@@ -17778,8 +17583,9 @@ var solanaWeb3 = (function (exports) {
17778
17583
 
17779
17584
  var Gp = GeneratorFunctionPrototype.prototype =
17780
17585
  Generator.prototype = Object.create(IteratorPrototype);
17781
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
17782
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
17586
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
17587
+ define(Gp, "constructor", GeneratorFunctionPrototype);
17588
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
17783
17589
  GeneratorFunction.displayName = define(
17784
17590
  GeneratorFunctionPrototype,
17785
17591
  toStringTagSymbol,
@@ -17893,9 +17699,9 @@ var solanaWeb3 = (function (exports) {
17893
17699
  }
17894
17700
 
17895
17701
  defineIteratorMethods(AsyncIterator.prototype);
17896
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
17702
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
17897
17703
  return this;
17898
- };
17704
+ });
17899
17705
  exports.AsyncIterator = AsyncIterator;
17900
17706
 
17901
17707
  // Note that simple async functions are implemented on top of
@@ -18088,13 +17894,13 @@ var solanaWeb3 = (function (exports) {
18088
17894
  // iterator prototype chain incorrectly implement this, causing the Generator
18089
17895
  // object to not be returned from this call. This ensures that doesn't happen.
18090
17896
  // See https://github.com/facebook/regenerator/issues/274 for more details.
18091
- Gp[iteratorSymbol] = function() {
17897
+ define(Gp, iteratorSymbol, function() {
18092
17898
  return this;
18093
- };
17899
+ });
18094
17900
 
18095
- Gp.toString = function() {
17901
+ define(Gp, "toString", function() {
18096
17902
  return "[object Generator]";
18097
- };
17903
+ });
18098
17904
 
18099
17905
  function pushTryEntry(locs) {
18100
17906
  var entry = { tryLoc: locs[0] };
@@ -18413,14 +18219,19 @@ var solanaWeb3 = (function (exports) {
18413
18219
  } catch (accidentalStrictMode) {
18414
18220
  // This module should not be running in strict mode, so the above
18415
18221
  // assignment should always work unless something is misconfigured. Just
18416
- // in case runtime.js accidentally runs in strict mode, we can escape
18222
+ // in case runtime.js accidentally runs in strict mode, in modern engines
18223
+ // we can explicitly access globalThis. In older engines we can escape
18417
18224
  // strict mode using a global Function call. This could conceivably fail
18418
18225
  // if a Content Security Policy forbids using Function, but in that case
18419
18226
  // the proper solution is to fix the accidental strict mode problem. If
18420
18227
  // you've misconfigured your bundler to force strict mode and applied a
18421
18228
  // CSP to forbid Function, and you're not willing to fix either of those
18422
18229
  // problems, please detail your unique predicament in a GitHub issue.
18423
- Function("r", "regeneratorRuntime = r")(runtime);
18230
+ if (typeof globalThis === "object") {
18231
+ globalThis.regeneratorRuntime = runtime;
18232
+ } else {
18233
+ Function("r", "regeneratorRuntime = r")(runtime);
18234
+ }
18424
18235
  }
18425
18236
  }(runtime));
18426
18237
 
@@ -18465,8 +18276,7 @@ var solanaWeb3 = (function (exports) {
18465
18276
  };
18466
18277
  }
18467
18278
 
18468
- module.exports = _asyncToGenerator;
18469
- module.exports["default"] = module.exports, module.exports.__esModule = true;
18279
+ module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
18470
18280
  }(asyncToGenerator));
18471
18281
 
18472
18282
  /*!
@@ -19081,240 +18891,745 @@ var solanaWeb3 = (function (exports) {
19081
18891
  * @return {Undefined}
19082
18892
  */
19083
18893
 
19084
- }, {
19085
- key: "_connect",
19086
- value: function _connect(address, options) {
19087
- var _this4 = this;
18894
+ }, {
18895
+ key: "_connect",
18896
+ value: function _connect(address, options) {
18897
+ var _this4 = this;
18898
+
18899
+ this.socket = this.webSocketFactory(address, options);
18900
+ this.socket.addEventListener("open", function () {
18901
+ _this4.ready = true;
18902
+
18903
+ _this4.emit("open");
18904
+
18905
+ _this4.current_reconnects = 0;
18906
+ });
18907
+ this.socket.addEventListener("message", function (_ref) {
18908
+ var message = _ref.data;
18909
+ if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
18910
+
18911
+ try {
18912
+ message = _circularJson["default"].parse(message);
18913
+ } catch (error) {
18914
+ return;
18915
+ } // check if any listeners are attached and forward event
18916
+
18917
+
18918
+ if (message.notification && _this4.listeners(message.notification).length) {
18919
+ if (!Object.keys(message.params).length) return _this4.emit(message.notification);
18920
+ var args = [message.notification];
18921
+ if (message.params.constructor === Object) args.push(message.params);else // using for-loop instead of unshift/spread because performance is better
18922
+ for (var i = 0; i < message.params.length; i++) {
18923
+ args.push(message.params[i]);
18924
+ } // run as microtask so that pending queue messages are resolved first
18925
+ // eslint-disable-next-line prefer-spread
18926
+
18927
+ return Promise.resolve().then(function () {
18928
+ _this4.emit.apply(_this4, args);
18929
+ });
18930
+ }
18931
+
18932
+ if (!_this4.queue[message.id]) {
18933
+ // general JSON RPC 2.0 events
18934
+ if (message.method && message.params) {
18935
+ // run as microtask so that pending queue messages are resolved first
18936
+ return Promise.resolve().then(function () {
18937
+ _this4.emit(message.method, message.params);
18938
+ });
18939
+ }
18940
+
18941
+ return;
18942
+ } // reject early since server's response is invalid
18943
+
18944
+
18945
+ if ("error" in message === "result" in message) _this4.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" + " or \"error\", but not both."));
18946
+ if (_this4.queue[message.id].timeout) clearTimeout(_this4.queue[message.id].timeout);
18947
+ if (message.error) _this4.queue[message.id].promise[1](message.error);else _this4.queue[message.id].promise[0](message.result);
18948
+ delete _this4.queue[message.id];
18949
+ });
18950
+ this.socket.addEventListener("error", function (error) {
18951
+ return _this4.emit("error", error);
18952
+ });
18953
+ this.socket.addEventListener("close", function (_ref2) {
18954
+ var code = _ref2.code,
18955
+ reason = _ref2.reason;
18956
+ if (_this4.ready) // Delay close event until internal state is updated
18957
+ setTimeout(function () {
18958
+ return _this4.emit("close", code, reason);
18959
+ }, 0);
18960
+ _this4.ready = false;
18961
+ _this4.socket = undefined;
18962
+ if (code === 1000) return;
18963
+ _this4.current_reconnects++;
18964
+ if (_this4.reconnect && (_this4.max_reconnects > _this4.current_reconnects || _this4.max_reconnects === 0)) setTimeout(function () {
18965
+ return _this4._connect(address, options);
18966
+ }, _this4.reconnect_interval);
18967
+ });
18968
+ }
18969
+ }]);
18970
+ return CommonClient;
18971
+ }(_eventemitter.EventEmitter);
18972
+
18973
+ exports["default"] = CommonClient;
18974
+ }(client));
18975
+
18976
+ var _interopRequireDefault = interopRequireDefault.exports;
18977
+
18978
+ Object.defineProperty(index_browser, "__esModule", {
18979
+ value: true
18980
+ });
18981
+ var Client_1 = index_browser.Client = void 0;
18982
+
18983
+ var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
18984
+
18985
+ var _inherits2 = _interopRequireDefault(inherits$3.exports);
18986
+
18987
+ var _possibleConstructorReturn2 = _interopRequireDefault(possibleConstructorReturn.exports);
18988
+
18989
+ var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf.exports);
18990
+
18991
+ var _websocket = _interopRequireDefault(websocket_browser);
18992
+
18993
+ var _client = _interopRequireDefault(client);
18994
+
18995
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
18996
+
18997
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
18998
+
18999
+ var Client = /*#__PURE__*/function (_CommonClient) {
19000
+ (0, _inherits2["default"])(Client, _CommonClient);
19001
+
19002
+ var _super = _createSuper(Client);
19003
+
19004
+ function Client() {
19005
+ var address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://localhost:8080";
19006
+
19007
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
19008
+ _ref$autoconnect = _ref.autoconnect,
19009
+ autoconnect = _ref$autoconnect === void 0 ? true : _ref$autoconnect,
19010
+ _ref$reconnect = _ref.reconnect,
19011
+ reconnect = _ref$reconnect === void 0 ? true : _ref$reconnect,
19012
+ _ref$reconnect_interv = _ref.reconnect_interval,
19013
+ reconnect_interval = _ref$reconnect_interv === void 0 ? 1000 : _ref$reconnect_interv,
19014
+ _ref$max_reconnects = _ref.max_reconnects,
19015
+ max_reconnects = _ref$max_reconnects === void 0 ? 5 : _ref$max_reconnects;
19016
+
19017
+ var generate_request_id = arguments.length > 2 ? arguments[2] : undefined;
19018
+ (0, _classCallCheck2["default"])(this, Client);
19019
+ return _super.call(this, _websocket["default"], address, {
19020
+ autoconnect: autoconnect,
19021
+ reconnect: reconnect,
19022
+ reconnect_interval: reconnect_interval,
19023
+ max_reconnects: max_reconnects
19024
+ }, generate_request_id);
19025
+ }
19026
+
19027
+ return Client;
19028
+ }(_client["default"]);
19029
+
19030
+ Client_1 = index_browser.Client = Client;
19031
+
19032
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
19033
+ // require the crypto API and do not support built-in fallback to lower quality random number
19034
+ // generators (like Math.random()).
19035
+ var getRandomValues;
19036
+ var rnds8 = new Uint8Array(16);
19037
+ function rng() {
19038
+ // lazy load so that environments that need to polyfill have a chance to do so
19039
+ if (!getRandomValues) {
19040
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
19041
+ // find the complete implementation of crypto (msCrypto) on IE11.
19042
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
19043
+
19044
+ if (!getRandomValues) {
19045
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
19046
+ }
19047
+ }
19048
+
19049
+ return getRandomValues(rnds8);
19050
+ }
19051
+
19052
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
19053
+
19054
+ function validate(uuid) {
19055
+ return typeof uuid === 'string' && REGEX.test(uuid);
19056
+ }
19057
+
19058
+ /**
19059
+ * Convert array of 16 byte values to UUID string format of the form:
19060
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
19061
+ */
19062
+
19063
+ var byteToHex = [];
19064
+
19065
+ for (var i = 0; i < 256; ++i) {
19066
+ byteToHex.push((i + 0x100).toString(16).substr(1));
19067
+ }
19068
+
19069
+ function stringify(arr) {
19070
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
19071
+ // Note: Be careful editing this code! It's been tuned for performance
19072
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
19073
+ var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
19074
+ // of the following:
19075
+ // - One or more input array values don't map to a hex octet (leading to
19076
+ // "undefined" in the uuid)
19077
+ // - Invalid input values for the RFC `version` or `variant` fields
19078
+
19079
+ if (!validate(uuid)) {
19080
+ throw TypeError('Stringified UUID is invalid');
19081
+ }
19082
+
19083
+ return uuid;
19084
+ }
19085
+
19086
+ //
19087
+ // Inspired by https://github.com/LiosK/UUID.js
19088
+ // and http://docs.python.org/library/uuid.html
19089
+
19090
+ var _nodeId;
19091
+
19092
+ var _clockseq; // Previous uuid creation time
19093
+
19094
+
19095
+ var _lastMSecs = 0;
19096
+ var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
19097
+
19098
+ function v1(options, buf, offset) {
19099
+ var i = buf && offset || 0;
19100
+ var b = buf || new Array(16);
19101
+ options = options || {};
19102
+ var node = options.node || _nodeId;
19103
+ var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
19104
+ // specified. We do this lazily to minimize issues related to insufficient
19105
+ // system entropy. See #189
19106
+
19107
+ if (node == null || clockseq == null) {
19108
+ var seedBytes = options.random || (options.rng || rng)();
19109
+
19110
+ if (node == null) {
19111
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
19112
+ node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
19113
+ }
19114
+
19115
+ if (clockseq == null) {
19116
+ // Per 4.2.2, randomize (14 bit) clockseq
19117
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
19118
+ }
19119
+ } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
19120
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
19121
+ // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
19122
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
19123
+
19124
+
19125
+ var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
19126
+ // cycle to simulate higher resolution clock
19127
+
19128
+ var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
19129
+
19130
+ var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
19131
+
19132
+ if (dt < 0 && options.clockseq === undefined) {
19133
+ clockseq = clockseq + 1 & 0x3fff;
19134
+ } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
19135
+ // time interval
19136
+
19137
+
19138
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
19139
+ nsecs = 0;
19140
+ } // Per 4.2.1.2 Throw error if too many uuids are requested
19141
+
19142
+
19143
+ if (nsecs >= 10000) {
19144
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
19145
+ }
19146
+
19147
+ _lastMSecs = msecs;
19148
+ _lastNSecs = nsecs;
19149
+ _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
19150
+
19151
+ msecs += 12219292800000; // `time_low`
19152
+
19153
+ var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
19154
+ b[i++] = tl >>> 24 & 0xff;
19155
+ b[i++] = tl >>> 16 & 0xff;
19156
+ b[i++] = tl >>> 8 & 0xff;
19157
+ b[i++] = tl & 0xff; // `time_mid`
19158
+
19159
+ var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
19160
+ b[i++] = tmh >>> 8 & 0xff;
19161
+ b[i++] = tmh & 0xff; // `time_high_and_version`
19162
+
19163
+ b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
19164
+
19165
+ b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
19166
+
19167
+ b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
19168
+
19169
+ b[i++] = clockseq & 0xff; // `node`
19170
+
19171
+ for (var n = 0; n < 6; ++n) {
19172
+ b[i + n] = node[n];
19173
+ }
19174
+
19175
+ return buf || stringify(b);
19176
+ }
19177
+
19178
+ function parse(uuid) {
19179
+ if (!validate(uuid)) {
19180
+ throw TypeError('Invalid UUID');
19181
+ }
19182
+
19183
+ var v;
19184
+ var arr = new Uint8Array(16); // Parse ########-....-....-....-............
19185
+
19186
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
19187
+ arr[1] = v >>> 16 & 0xff;
19188
+ arr[2] = v >>> 8 & 0xff;
19189
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
19190
+
19191
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
19192
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
19193
+
19194
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
19195
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
19196
+
19197
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
19198
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
19199
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
19200
+
19201
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
19202
+ arr[11] = v / 0x100000000 & 0xff;
19203
+ arr[12] = v >>> 24 & 0xff;
19204
+ arr[13] = v >>> 16 & 0xff;
19205
+ arr[14] = v >>> 8 & 0xff;
19206
+ arr[15] = v & 0xff;
19207
+ return arr;
19208
+ }
19209
+
19210
+ function stringToBytes(str) {
19211
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
19212
+
19213
+ var bytes = [];
19214
+
19215
+ for (var i = 0; i < str.length; ++i) {
19216
+ bytes.push(str.charCodeAt(i));
19217
+ }
19218
+
19219
+ return bytes;
19220
+ }
19221
+
19222
+ var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
19223
+ var URL$1 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
19224
+ function v35 (name, version, hashfunc) {
19225
+ function generateUUID(value, namespace, buf, offset) {
19226
+ if (typeof value === 'string') {
19227
+ value = stringToBytes(value);
19228
+ }
19229
+
19230
+ if (typeof namespace === 'string') {
19231
+ namespace = parse(namespace);
19232
+ }
19233
+
19234
+ if (namespace.length !== 16) {
19235
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
19236
+ } // Compute hash of namespace and value, Per 4.3
19237
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
19238
+ // hashfunc([...namespace, ... value])`
19239
+
19240
+
19241
+ var bytes = new Uint8Array(16 + value.length);
19242
+ bytes.set(namespace);
19243
+ bytes.set(value, namespace.length);
19244
+ bytes = hashfunc(bytes);
19245
+ bytes[6] = bytes[6] & 0x0f | version;
19246
+ bytes[8] = bytes[8] & 0x3f | 0x80;
19247
+
19248
+ if (buf) {
19249
+ offset = offset || 0;
19250
+
19251
+ for (var i = 0; i < 16; ++i) {
19252
+ buf[offset + i] = bytes[i];
19253
+ }
19254
+
19255
+ return buf;
19256
+ }
19257
+
19258
+ return stringify(bytes);
19259
+ } // Function#name is not settable on some platforms (#270)
19260
+
19261
+
19262
+ try {
19263
+ generateUUID.name = name; // eslint-disable-next-line no-empty
19264
+ } catch (err) {} // For CommonJS default export support
19265
+
19266
+
19267
+ generateUUID.DNS = DNS;
19268
+ generateUUID.URL = URL$1;
19269
+ return generateUUID;
19270
+ }
19271
+
19272
+ /*
19273
+ * Browser-compatible JavaScript MD5
19274
+ *
19275
+ * Modification of JavaScript MD5
19276
+ * https://github.com/blueimp/JavaScript-MD5
19277
+ *
19278
+ * Copyright 2011, Sebastian Tschan
19279
+ * https://blueimp.net
19280
+ *
19281
+ * Licensed under the MIT license:
19282
+ * https://opensource.org/licenses/MIT
19283
+ *
19284
+ * Based on
19285
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
19286
+ * Digest Algorithm, as defined in RFC 1321.
19287
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
19288
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
19289
+ * Distributed under the BSD License
19290
+ * See http://pajhome.org.uk/crypt/md5 for more info.
19291
+ */
19292
+ function md5(bytes) {
19293
+ if (typeof bytes === 'string') {
19294
+ var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
19295
+
19296
+ bytes = new Uint8Array(msg.length);
19297
+
19298
+ for (var i = 0; i < msg.length; ++i) {
19299
+ bytes[i] = msg.charCodeAt(i);
19300
+ }
19301
+ }
19302
+
19303
+ return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
19304
+ }
19305
+ /*
19306
+ * Convert an array of little-endian words to an array of bytes
19307
+ */
19308
+
19309
+
19310
+ function md5ToHexEncodedArray(input) {
19311
+ var output = [];
19312
+ var length32 = input.length * 32;
19313
+ var hexTab = '0123456789abcdef';
19314
+
19315
+ for (var i = 0; i < length32; i += 8) {
19316
+ var x = input[i >> 5] >>> i % 32 & 0xff;
19317
+ var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
19318
+ output.push(hex);
19319
+ }
19320
+
19321
+ return output;
19322
+ }
19323
+ /**
19324
+ * Calculate output length with padding and bit length
19325
+ */
19326
+
19088
19327
 
19089
- this.socket = this.webSocketFactory(address, options);
19090
- this.socket.addEventListener("open", function () {
19091
- _this4.ready = true;
19328
+ function getOutputLength(inputLength8) {
19329
+ return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
19330
+ }
19331
+ /*
19332
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
19333
+ */
19092
19334
 
19093
- _this4.emit("open");
19094
19335
 
19095
- _this4.current_reconnects = 0;
19096
- });
19097
- this.socket.addEventListener("message", function (_ref) {
19098
- var message = _ref.data;
19099
- if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
19336
+ function wordsToMd5(x, len) {
19337
+ /* append padding */
19338
+ x[len >> 5] |= 0x80 << len % 32;
19339
+ x[getOutputLength(len) - 1] = len;
19340
+ var a = 1732584193;
19341
+ var b = -271733879;
19342
+ var c = -1732584194;
19343
+ var d = 271733878;
19344
+
19345
+ for (var i = 0; i < x.length; i += 16) {
19346
+ var olda = a;
19347
+ var oldb = b;
19348
+ var oldc = c;
19349
+ var oldd = d;
19350
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
19351
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
19352
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
19353
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
19354
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
19355
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
19356
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
19357
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
19358
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
19359
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
19360
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
19361
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
19362
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
19363
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
19364
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
19365
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
19366
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
19367
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
19368
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
19369
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
19370
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
19371
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
19372
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
19373
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
19374
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
19375
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
19376
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
19377
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
19378
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
19379
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
19380
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
19381
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
19382
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
19383
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
19384
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
19385
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
19386
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
19387
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
19388
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
19389
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
19390
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
19391
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
19392
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
19393
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
19394
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
19395
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
19396
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
19397
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
19398
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
19399
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
19400
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
19401
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
19402
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
19403
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
19404
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
19405
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
19406
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
19407
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
19408
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
19409
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
19410
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
19411
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
19412
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
19413
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
19414
+ a = safeAdd(a, olda);
19415
+ b = safeAdd(b, oldb);
19416
+ c = safeAdd(c, oldc);
19417
+ d = safeAdd(d, oldd);
19418
+ }
19419
+
19420
+ return [a, b, c, d];
19421
+ }
19422
+ /*
19423
+ * Convert an array bytes to an array of little-endian words
19424
+ * Characters >255 have their high-byte silently ignored.
19425
+ */
19100
19426
 
19101
- try {
19102
- message = _circularJson["default"].parse(message);
19103
- } catch (error) {
19104
- return;
19105
- } // check if any listeners are attached and forward event
19106
19427
 
19428
+ function bytesToWords(input) {
19429
+ if (input.length === 0) {
19430
+ return [];
19431
+ }
19107
19432
 
19108
- if (message.notification && _this4.listeners(message.notification).length) {
19109
- if (!Object.keys(message.params).length) return _this4.emit(message.notification);
19110
- var args = [message.notification];
19111
- if (message.params.constructor === Object) args.push(message.params);else // using for-loop instead of unshift/spread because performance is better
19112
- for (var i = 0; i < message.params.length; i++) {
19113
- args.push(message.params[i]);
19114
- } // run as microtask so that pending queue messages are resolved first
19115
- // eslint-disable-next-line prefer-spread
19433
+ var length8 = input.length * 8;
19434
+ var output = new Uint32Array(getOutputLength(length8));
19116
19435
 
19117
- return Promise.resolve().then(function () {
19118
- _this4.emit.apply(_this4, args);
19119
- });
19120
- }
19436
+ for (var i = 0; i < length8; i += 8) {
19437
+ output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
19438
+ }
19121
19439
 
19122
- if (!_this4.queue[message.id]) {
19123
- // general JSON RPC 2.0 events
19124
- if (message.method && message.params) {
19125
- // run as microtask so that pending queue messages are resolved first
19126
- return Promise.resolve().then(function () {
19127
- _this4.emit(message.method, message.params);
19128
- });
19129
- }
19440
+ return output;
19441
+ }
19442
+ /*
19443
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
19444
+ * to work around bugs in some JS interpreters.
19445
+ */
19130
19446
 
19131
- return;
19132
- } // reject early since server's response is invalid
19133
19447
 
19448
+ function safeAdd(x, y) {
19449
+ var lsw = (x & 0xffff) + (y & 0xffff);
19450
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
19451
+ return msw << 16 | lsw & 0xffff;
19452
+ }
19453
+ /*
19454
+ * Bitwise rotate a 32-bit number to the left.
19455
+ */
19134
19456
 
19135
- if ("error" in message === "result" in message) _this4.queue[message.id].promise[1](new Error("Server response malformed. Response must include either \"result\"" + " or \"error\", but not both."));
19136
- if (_this4.queue[message.id].timeout) clearTimeout(_this4.queue[message.id].timeout);
19137
- if (message.error) _this4.queue[message.id].promise[1](message.error);else _this4.queue[message.id].promise[0](message.result);
19138
- delete _this4.queue[message.id];
19139
- });
19140
- this.socket.addEventListener("error", function (error) {
19141
- return _this4.emit("error", error);
19142
- });
19143
- this.socket.addEventListener("close", function (_ref2) {
19144
- var code = _ref2.code,
19145
- reason = _ref2.reason;
19146
- if (_this4.ready) // Delay close event until internal state is updated
19147
- setTimeout(function () {
19148
- return _this4.emit("close", code, reason);
19149
- }, 0);
19150
- _this4.ready = false;
19151
- _this4.socket = undefined;
19152
- if (code === 1000) return;
19153
- _this4.current_reconnects++;
19154
- if (_this4.reconnect && (_this4.max_reconnects > _this4.current_reconnects || _this4.max_reconnects === 0)) setTimeout(function () {
19155
- return _this4._connect(address, options);
19156
- }, _this4.reconnect_interval);
19157
- });
19158
- }
19159
- }]);
19160
- return CommonClient;
19161
- }(_eventemitter.EventEmitter);
19162
19457
 
19163
- exports["default"] = CommonClient;
19164
- }(client));
19458
+ function bitRotateLeft(num, cnt) {
19459
+ return num << cnt | num >>> 32 - cnt;
19460
+ }
19461
+ /*
19462
+ * These functions implement the four basic operations the algorithm uses.
19463
+ */
19165
19464
 
19166
- var _interopRequireDefault = interopRequireDefault.exports;
19167
19465
 
19168
- Object.defineProperty(index_browser, "__esModule", {
19169
- value: true
19170
- });
19171
- var Client_1 = index_browser.Client = void 0;
19466
+ function md5cmn(q, a, b, x, s, t) {
19467
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
19468
+ }
19172
19469
 
19173
- var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
19470
+ function md5ff(a, b, c, d, x, s, t) {
19471
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
19472
+ }
19174
19473
 
19175
- var _inherits2 = _interopRequireDefault(inherits$3.exports);
19474
+ function md5gg(a, b, c, d, x, s, t) {
19475
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
19476
+ }
19176
19477
 
19177
- var _possibleConstructorReturn2 = _interopRequireDefault(possibleConstructorReturn.exports);
19478
+ function md5hh(a, b, c, d, x, s, t) {
19479
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
19480
+ }
19178
19481
 
19179
- var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf.exports);
19482
+ function md5ii(a, b, c, d, x, s, t) {
19483
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
19484
+ }
19180
19485
 
19181
- var _websocket = _interopRequireDefault(websocket_browser);
19486
+ var v3 = v35('v3', 0x30, md5);
19487
+ var v3$1 = v3;
19182
19488
 
19183
- var _client = _interopRequireDefault(client);
19489
+ function v4(options, buf, offset) {
19490
+ options = options || {};
19491
+ var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
19184
19492
 
19185
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
19493
+ rnds[6] = rnds[6] & 0x0f | 0x40;
19494
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
19186
19495
 
19187
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19496
+ if (buf) {
19497
+ offset = offset || 0;
19188
19498
 
19189
- var Client = /*#__PURE__*/function (_CommonClient) {
19190
- (0, _inherits2["default"])(Client, _CommonClient);
19499
+ for (var i = 0; i < 16; ++i) {
19500
+ buf[offset + i] = rnds[i];
19501
+ }
19191
19502
 
19192
- var _super = _createSuper(Client);
19503
+ return buf;
19504
+ }
19193
19505
 
19194
- function Client() {
19195
- var address = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://localhost:8080";
19506
+ return stringify(rnds);
19507
+ }
19196
19508
 
19197
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
19198
- _ref$autoconnect = _ref.autoconnect,
19199
- autoconnect = _ref$autoconnect === void 0 ? true : _ref$autoconnect,
19200
- _ref$reconnect = _ref.reconnect,
19201
- reconnect = _ref$reconnect === void 0 ? true : _ref$reconnect,
19202
- _ref$reconnect_interv = _ref.reconnect_interval,
19203
- reconnect_interval = _ref$reconnect_interv === void 0 ? 1000 : _ref$reconnect_interv,
19204
- _ref$max_reconnects = _ref.max_reconnects,
19205
- max_reconnects = _ref$max_reconnects === void 0 ? 5 : _ref$max_reconnects;
19509
+ // Adapted from Chris Veness' SHA1 code at
19510
+ // http://www.movable-type.co.uk/scripts/sha1.html
19511
+ function f(s, x, y, z) {
19512
+ switch (s) {
19513
+ case 0:
19514
+ return x & y ^ ~x & z;
19206
19515
 
19207
- var generate_request_id = arguments.length > 2 ? arguments[2] : undefined;
19208
- (0, _classCallCheck2["default"])(this, Client);
19209
- return _super.call(this, _websocket["default"], address, {
19210
- autoconnect: autoconnect,
19211
- reconnect: reconnect,
19212
- reconnect_interval: reconnect_interval,
19213
- max_reconnects: max_reconnects
19214
- }, generate_request_id);
19516
+ case 1:
19517
+ return x ^ y ^ z;
19518
+
19519
+ case 2:
19520
+ return x & y ^ x & z ^ y & z;
19521
+
19522
+ case 3:
19523
+ return x ^ y ^ z;
19215
19524
  }
19525
+ }
19216
19526
 
19217
- return Client;
19218
- }(_client["default"]);
19527
+ function ROTL(x, n) {
19528
+ return x << n | x >>> 32 - n;
19529
+ }
19219
19530
 
19220
- Client_1 = index_browser.Client = Client;
19531
+ function sha1(bytes) {
19532
+ var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
19533
+ var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
19221
19534
 
19222
- var rngBrowser = {exports: {}};
19535
+ if (typeof bytes === 'string') {
19536
+ var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
19223
19537
 
19224
- // Unique ID creation requires a high quality random # generator. In the
19225
- // browser this is a little complicated due to unknown quality of Math.random()
19226
- // and inconsistent support for the `crypto` API. We do the best we can via
19227
- // feature-detection
19538
+ bytes = [];
19228
19539
 
19229
- // getRandomValues needs to be invoked in a context where "this" is a Crypto
19230
- // implementation. Also, find the complete implementation of crypto on IE11.
19231
- var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||
19232
- (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));
19540
+ for (var i = 0; i < msg.length; ++i) {
19541
+ bytes.push(msg.charCodeAt(i));
19542
+ }
19543
+ } else if (!Array.isArray(bytes)) {
19544
+ // Convert Array-like to Array
19545
+ bytes = Array.prototype.slice.call(bytes);
19546
+ }
19233
19547
 
19234
- if (getRandomValues) {
19235
- // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
19236
- var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
19548
+ bytes.push(0x80);
19549
+ var l = bytes.length / 4 + 2;
19550
+ var N = Math.ceil(l / 16);
19551
+ var M = new Array(N);
19237
19552
 
19238
- rngBrowser.exports = function whatwgRNG() {
19239
- getRandomValues(rnds8);
19240
- return rnds8;
19241
- };
19242
- } else {
19243
- // Math.random()-based (RNG)
19244
- //
19245
- // If all else fails, use Math.random(). It's fast, but is of unspecified
19246
- // quality.
19247
- var rnds = new Array(16);
19553
+ for (var _i = 0; _i < N; ++_i) {
19554
+ var arr = new Uint32Array(16);
19248
19555
 
19249
- rngBrowser.exports = function mathRNG() {
19250
- for (var i = 0, r; i < 16; i++) {
19251
- if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
19252
- rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
19556
+ for (var j = 0; j < 16; ++j) {
19557
+ arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
19253
19558
  }
19254
19559
 
19255
- return rnds;
19256
- };
19257
- }
19560
+ M[_i] = arr;
19561
+ }
19258
19562
 
19259
- /**
19260
- * Convert array of 16 byte values to UUID string format of the form:
19261
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
19262
- */
19563
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
19564
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
19565
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
19263
19566
 
19264
- var byteToHex = [];
19265
- for (var i = 0; i < 256; ++i) {
19266
- byteToHex[i] = (i + 0x100).toString(16).substr(1);
19267
- }
19567
+ for (var _i2 = 0; _i2 < N; ++_i2) {
19568
+ var W = new Uint32Array(80);
19268
19569
 
19269
- function bytesToUuid$1(buf, offset) {
19270
- var i = offset || 0;
19271
- var bth = byteToHex;
19272
- // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
19273
- return ([
19274
- bth[buf[i++]], bth[buf[i++]],
19275
- bth[buf[i++]], bth[buf[i++]], '-',
19276
- bth[buf[i++]], bth[buf[i++]], '-',
19277
- bth[buf[i++]], bth[buf[i++]], '-',
19278
- bth[buf[i++]], bth[buf[i++]], '-',
19279
- bth[buf[i++]], bth[buf[i++]],
19280
- bth[buf[i++]], bth[buf[i++]],
19281
- bth[buf[i++]], bth[buf[i++]]
19282
- ]).join('');
19283
- }
19570
+ for (var t = 0; t < 16; ++t) {
19571
+ W[t] = M[_i2][t];
19572
+ }
19284
19573
 
19285
- var bytesToUuid_1 = bytesToUuid$1;
19574
+ for (var _t = 16; _t < 80; ++_t) {
19575
+ W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
19576
+ }
19286
19577
 
19287
- var rng = rngBrowser.exports;
19288
- var bytesToUuid = bytesToUuid_1;
19578
+ var a = H[0];
19579
+ var b = H[1];
19580
+ var c = H[2];
19581
+ var d = H[3];
19582
+ var e = H[4];
19289
19583
 
19290
- function v4(options, buf, offset) {
19291
- var i = buf && offset || 0;
19584
+ for (var _t2 = 0; _t2 < 80; ++_t2) {
19585
+ var s = Math.floor(_t2 / 20);
19586
+ var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
19587
+ e = d;
19588
+ d = c;
19589
+ c = ROTL(b, 30) >>> 0;
19590
+ b = a;
19591
+ a = T;
19592
+ }
19292
19593
 
19293
- if (typeof(options) == 'string') {
19294
- buf = options === 'binary' ? new Array(16) : null;
19295
- options = null;
19594
+ H[0] = H[0] + a >>> 0;
19595
+ H[1] = H[1] + b >>> 0;
19596
+ H[2] = H[2] + c >>> 0;
19597
+ H[3] = H[3] + d >>> 0;
19598
+ H[4] = H[4] + e >>> 0;
19296
19599
  }
19297
- options = options || {};
19298
19600
 
19299
- var rnds = options.random || (options.rng || rng)();
19601
+ return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
19602
+ }
19300
19603
 
19301
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
19302
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
19303
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
19604
+ var v5 = v35('v5', 0x50, sha1);
19605
+ var v5$1 = v5;
19304
19606
 
19305
- // Copy bytes to buffer, if provided
19306
- if (buf) {
19307
- for (var ii = 0; ii < 16; ++ii) {
19308
- buf[i + ii] = rnds[ii];
19309
- }
19607
+ var nil = '00000000-0000-0000-0000-000000000000';
19608
+
19609
+ function version$1(uuid) {
19610
+ if (!validate(uuid)) {
19611
+ throw TypeError('Invalid UUID');
19310
19612
  }
19311
19613
 
19312
- return buf || bytesToUuid(rnds);
19614
+ return parseInt(uuid.substr(14, 1), 16);
19313
19615
  }
19314
19616
 
19315
- var v4_1 = v4;
19617
+ var esmBrowser = /*#__PURE__*/Object.freeze({
19618
+ __proto__: null,
19619
+ v1: v1,
19620
+ v3: v3$1,
19621
+ v4: v4,
19622
+ v5: v5$1,
19623
+ NIL: nil,
19624
+ version: version$1,
19625
+ validate: validate,
19626
+ stringify: stringify,
19627
+ parse: parse
19628
+ });
19629
+
19630
+ var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(esmBrowser);
19316
19631
 
19317
- const uuid$1 = v4_1;
19632
+ const uuid$1 = require$$0$1.v4;
19318
19633
 
19319
19634
  /**
19320
19635
  * Generates a JSON-RPC 1.0 or 2.0 request
@@ -19376,7 +19691,7 @@ var solanaWeb3 = (function (exports) {
19376
19691
 
19377
19692
  var generateRequest_1 = generateRequest$1;
19378
19693
 
19379
- const uuid = v4_1;
19694
+ const uuid = require$$0$1.v4;
19380
19695
  const generateRequest = generateRequest_1;
19381
19696
 
19382
19697
  /**
@@ -19861,6 +20176,20 @@ var solanaWeb3 = (function (exports) {
19861
20176
  unitsConsumed: optional(number())
19862
20177
  }));
19863
20178
 
20179
+ /**
20180
+ * Expected JSON RPC response for the "getBlockProduction" message
20181
+ */
20182
+ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
20183
+ byIdentity: record(string(), array(number())),
20184
+ range: type({
20185
+ firstSlot: number(),
20186
+ lastSlot: number()
20187
+ })
20188
+ }));
20189
+ /**
20190
+ * A performance sample
20191
+ */
20192
+
19864
20193
  function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRetryOnRateLimit) {
19865
20194
 
19866
20195
  let fetchWithMiddleware;
@@ -20715,6 +21044,14 @@ var solanaWeb3 = (function (exports) {
20715
21044
  get commitment() {
20716
21045
  return this._commitment;
20717
21046
  }
21047
+ /**
21048
+ * The RPC endpoint
21049
+ */
21050
+
21051
+
21052
+ get rpcEndpoint() {
21053
+ return this._rpcEndpoint;
21054
+ }
20718
21055
  /**
20719
21056
  * Fetch the balance for the specified public key, return with context
20720
21057
  */
@@ -21637,6 +21974,54 @@ var solanaWeb3 = (function (exports) {
21637
21974
  })
21638
21975
  };
21639
21976
  }
21977
+ /*
21978
+ * Returns the current block height of the node
21979
+ */
21980
+
21981
+
21982
+ async getBlockHeight(commitment) {
21983
+ const args = this._buildArgs([], commitment);
21984
+
21985
+ const unsafeRes = await this._rpcRequest('getBlockHeight', args);
21986
+ const res = create(unsafeRes, jsonRpcResult(number()));
21987
+
21988
+ if ('error' in res) {
21989
+ throw new Error('failed to get block height information: ' + res.error.message);
21990
+ }
21991
+
21992
+ return res.result;
21993
+ }
21994
+ /*
21995
+ * Returns recent block production information from the current or previous epoch
21996
+ */
21997
+
21998
+
21999
+ async getBlockProduction(configOrCommitment) {
22000
+ let extra;
22001
+ let commitment;
22002
+
22003
+ if (typeof configOrCommitment === 'string') {
22004
+ commitment = configOrCommitment;
22005
+ } else if (configOrCommitment) {
22006
+ const {
22007
+ commitment: c,
22008
+ ...rest
22009
+ } = configOrCommitment;
22010
+ commitment = c;
22011
+ extra = rest;
22012
+ }
22013
+
22014
+ const args = this._buildArgs([], commitment, 'base64', extra);
22015
+
22016
+ const unsafeRes = await this._rpcRequest('getBlockProduction', args);
22017
+ const res = create(unsafeRes, BlockProductionResponseStruct);
22018
+
22019
+ if ('error' in res) {
22020
+ throw new Error('failed to get block production information: ' + res.error.message);
22021
+ }
22022
+
22023
+ return res.result;
22024
+ }
21640
22025
  /**
21641
22026
  * Fetch a confirmed or finalized transaction from the cluster.
21642
22027
  */
@@ -22129,7 +22514,14 @@ var solanaWeb3 = (function (exports) {
22129
22514
  let transaction;
22130
22515
 
22131
22516
  if (transactionOrMessage instanceof Transaction) {
22132
- transaction = transactionOrMessage;
22517
+ let originalTx = transactionOrMessage;
22518
+ transaction = new Transaction({
22519
+ recentBlockhash: originalTx.recentBlockhash,
22520
+ nonceInfo: originalTx.nonceInfo,
22521
+ feePayer: originalTx.feePayer,
22522
+ signatures: [...originalTx.signatures]
22523
+ });
22524
+ transaction.instructions = transactionOrMessage.instructions;
22133
22525
  } else {
22134
22526
  transaction = Transaction.populate(transactionOrMessage);
22135
22527
  }
@@ -22297,12 +22689,6 @@ var solanaWeb3 = (function (exports) {
22297
22689
 
22298
22690
  if ('data' in res.error) {
22299
22691
  logs = res.error.data.logs;
22300
-
22301
- if (logs && Array.isArray(logs)) {
22302
- const traceIndent = '\n ';
22303
- const logTrace = traceIndent + logs.join(traceIndent);
22304
- console.error(res.error.message, logTrace);
22305
- }
22306
22692
  }
22307
22693
 
22308
22694
  throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
@@ -22408,6 +22794,7 @@ var solanaWeb3 = (function (exports) {
22408
22794
 
22409
22795
  _resetSubscriptions() {
22410
22796
  Object.values(this._accountChangeSubscriptions).forEach(s => s.subscriptionId = null);
22797
+ Object.values(this._logsSubscriptions).forEach(s => s.subscriptionId = null);
22411
22798
  Object.values(this._programAccountChangeSubscriptions).forEach(s => s.subscriptionId = null);
22412
22799
  Object.values(this._rootSubscriptions).forEach(s => s.subscriptionId = null);
22413
22800
  Object.values(this._signatureSubscriptions).forEach(s => s.subscriptionId = null);
@@ -23118,16 +23505,18 @@ var solanaWeb3 = (function (exports) {
23118
23505
  const messageDataOffset = signatureOffset + signature.length;
23119
23506
  const numSignatures = 1;
23120
23507
  const instructionData = buffer.Buffer.alloc(messageDataOffset + message.length);
23508
+ const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
23509
+ : instructionIndex;
23121
23510
  ED25519_INSTRUCTION_LAYOUT.encode({
23122
23511
  numSignatures,
23123
23512
  padding: 0,
23124
23513
  signatureOffset,
23125
- signatureInstructionIndex: instructionIndex,
23514
+ signatureInstructionIndex: index,
23126
23515
  publicKeyOffset,
23127
- publicKeyInstructionIndex: instructionIndex,
23516
+ publicKeyInstructionIndex: index,
23128
23517
  messageDataOffset,
23129
23518
  messageDataSize: message.length,
23130
- messageInstructionIndex: instructionIndex
23519
+ messageInstructionIndex: index
23131
23520
  }, instructionData);
23132
23521
  instructionData.fill(publicKey, publicKeyOffset);
23133
23522
  instructionData.fill(signature, signatureOffset);
@@ -23198,10 +23587,10 @@ var solanaWeb3 = (function (exports) {
23198
23587
  }
23199
23588
 
23200
23589
  }
23590
+
23201
23591
  /**
23202
23592
  * Stake account lockup info
23203
23593
  */
23204
-
23205
23594
  class Lockup {
23206
23595
  /** Unix timestamp of lockup expiration */
23207
23596
 
@@ -23226,10 +23615,6 @@ var solanaWeb3 = (function (exports) {
23226
23615
 
23227
23616
 
23228
23617
  }
23229
- /**
23230
- * Create stake account transaction params
23231
- */
23232
-
23233
23618
  Lockup.default = new Lockup(0, 0, PublicKey.default);
23234
23619
 
23235
23620
  /**
@@ -25002,36 +25387,6 @@ var solanaWeb3 = (function (exports) {
25002
25387
  return r;
25003
25388
  };
25004
25389
 
25005
- var inherits_browser = {exports: {}};
25006
-
25007
- if (typeof Object.create === 'function') {
25008
- // implementation from standard node.js 'util' module
25009
- inherits_browser.exports = function inherits(ctor, superCtor) {
25010
- if (superCtor) {
25011
- ctor.super_ = superCtor;
25012
- ctor.prototype = Object.create(superCtor.prototype, {
25013
- constructor: {
25014
- value: ctor,
25015
- enumerable: false,
25016
- writable: true,
25017
- configurable: true
25018
- }
25019
- });
25020
- }
25021
- };
25022
- } else {
25023
- // old school shim for old browsers
25024
- inherits_browser.exports = function inherits(ctor, superCtor) {
25025
- if (superCtor) {
25026
- ctor.super_ = superCtor;
25027
- var TempCtor = function () {};
25028
- TempCtor.prototype = superCtor.prototype;
25029
- ctor.prototype = new TempCtor();
25030
- ctor.prototype.constructor = ctor;
25031
- }
25032
- };
25033
- }
25034
-
25035
25390
  var utils$9 = utils$c;
25036
25391
  var BN$7 = bn.exports;
25037
25392
  var inherits$2 = inherits_browser.exports;
@@ -29091,8 +29446,8 @@ var solanaWeb3 = (function (exports) {
29091
29446
  }
29092
29447
 
29093
29448
  function parseAuthorizedVoter({
29094
- epoch,
29095
- authorizedVoter
29449
+ authorizedVoter,
29450
+ epoch
29096
29451
  }) {
29097
29452
  return {
29098
29453
  epoch,
@@ -29121,7 +29476,7 @@ var solanaWeb3 = (function (exports) {
29121
29476
  return [];
29122
29477
  }
29123
29478
 
29124
- return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx)];
29479
+ return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx).map(parsePriorVoters)];
29125
29480
  }
29126
29481
 
29127
29482
  /**