@solana/web3.js 1.24.1 → 1.24.3

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
@@ -12416,6 +12416,36 @@ var solanaWeb3 = (function (exports) {
12416
12416
  }
12417
12417
  }
12418
12418
 
12419
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
12420
+ /**
12421
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
12422
+ */
12423
+
12424
+ function guardedShift(byteArray) {
12425
+ if (byteArray.length === 0) {
12426
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12427
+ }
12428
+
12429
+ return byteArray.shift();
12430
+ }
12431
+ /**
12432
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
12433
+ * the array.
12434
+ */
12435
+
12436
+ function guardedSplice(byteArray, ...args) {
12437
+ var _args$;
12438
+
12439
+ const [start] = args;
12440
+
12441
+ if (args.length === 2 // Implies that `deleteCount` was supplied
12442
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
12443
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
12444
+ }
12445
+
12446
+ return byteArray.splice(...args);
12447
+ }
12448
+
12419
12449
  /**
12420
12450
  * The message header, identifying signed and read-only account
12421
12451
  */
@@ -12500,32 +12530,28 @@ var solanaWeb3 = (function (exports) {
12500
12530
  static from(buffer$1) {
12501
12531
  // Slice up wire data
12502
12532
  let byteArray = [...buffer$1];
12503
- const numRequiredSignatures = byteArray.shift();
12504
- const numReadonlySignedAccounts = byteArray.shift();
12505
- const numReadonlyUnsignedAccounts = byteArray.shift();
12533
+ const numRequiredSignatures = guardedShift(byteArray);
12534
+ const numReadonlySignedAccounts = guardedShift(byteArray);
12535
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
12506
12536
  const accountCount = decodeLength(byteArray);
12507
12537
  let accountKeys = [];
12508
12538
 
12509
12539
  for (let i = 0; i < accountCount; i++) {
12510
- const account = byteArray.slice(0, PUBKEY_LENGTH);
12511
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12540
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
12512
12541
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
12513
12542
  }
12514
12543
 
12515
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
12516
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12544
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
12517
12545
  const instructionCount = decodeLength(byteArray);
12518
12546
  let instructions = [];
12519
12547
 
12520
12548
  for (let i = 0; i < instructionCount; i++) {
12521
- const programIdIndex = byteArray.shift();
12549
+ const programIdIndex = guardedShift(byteArray);
12522
12550
  const accountCount = decodeLength(byteArray);
12523
- const accounts = byteArray.slice(0, accountCount);
12524
- byteArray = byteArray.slice(accountCount);
12551
+ const accounts = guardedSplice(byteArray, 0, accountCount);
12525
12552
  const dataLength = decodeLength(byteArray);
12526
- const dataSlice = byteArray.slice(0, dataLength);
12553
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
12527
12554
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
12528
- byteArray = byteArray.slice(dataLength);
12529
12555
  instructions.push({
12530
12556
  programIdIndex,
12531
12557
  accounts,
@@ -12554,6 +12580,10 @@ var solanaWeb3 = (function (exports) {
12554
12580
  }
12555
12581
  }
12556
12582
 
12583
+ /**
12584
+ * Transaction signature as base-58 encoded string
12585
+ */
12586
+
12557
12587
  /**
12558
12588
  * Default (empty) signature
12559
12589
  *
@@ -13147,8 +13177,7 @@ var solanaWeb3 = (function (exports) {
13147
13177
  let signatures = [];
13148
13178
 
13149
13179
  for (let i = 0; i < signatureCount; i++) {
13150
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
13151
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
13180
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
13152
13181
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
13153
13182
  }
13154
13183
 
@@ -16566,6 +16595,20 @@ var solanaWeb3 = (function (exports) {
16566
16595
 
16567
16596
  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; } }
16568
16597
 
16598
+ var __rest = function (s, e) {
16599
+ var t = {};
16600
+
16601
+ for (var p in s) {
16602
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
16603
+ }
16604
+
16605
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16606
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
16607
+ }
16608
+ return t;
16609
+ }; // @ts-ignore
16610
+
16611
+
16569
16612
  var CommonClient = /*#__PURE__*/function (_EventEmitter) {
16570
16613
  (0, _inherits2["default"])(CommonClient, _EventEmitter);
16571
16614
 
@@ -16585,18 +16628,21 @@ var solanaWeb3 = (function (exports) {
16585
16628
 
16586
16629
  var address = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "ws://localhost:8080";
16587
16630
 
16588
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
16589
- _ref$autoconnect = _ref.autoconnect,
16590
- autoconnect = _ref$autoconnect === void 0 ? true : _ref$autoconnect,
16591
- _ref$reconnect = _ref.reconnect,
16592
- reconnect = _ref$reconnect === void 0 ? true : _ref$reconnect,
16593
- _ref$reconnect_interv = _ref.reconnect_interval,
16594
- reconnect_interval = _ref$reconnect_interv === void 0 ? 1000 : _ref$reconnect_interv,
16595
- _ref$max_reconnects = _ref.max_reconnects,
16596
- max_reconnects = _ref$max_reconnects === void 0 ? 5 : _ref$max_reconnects;
16631
+ var _a = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
16597
16632
 
16598
16633
  var generate_request_id = arguments.length > 3 ? arguments[3] : undefined;
16599
16634
  (0, _classCallCheck2["default"])(this, CommonClient);
16635
+
16636
+ var _a$autoconnect = _a.autoconnect,
16637
+ autoconnect = _a$autoconnect === void 0 ? true : _a$autoconnect,
16638
+ _a$reconnect = _a.reconnect,
16639
+ reconnect = _a$reconnect === void 0 ? true : _a$reconnect,
16640
+ _a$reconnect_interval = _a.reconnect_interval,
16641
+ reconnect_interval = _a$reconnect_interval === void 0 ? 1000 : _a$reconnect_interval,
16642
+ _a$max_reconnects = _a.max_reconnects,
16643
+ max_reconnects = _a$max_reconnects === void 0 ? 5 : _a$max_reconnects,
16644
+ rest_options = __rest(_a, ["autoconnect", "reconnect", "reconnect_interval", "max_reconnects"]);
16645
+
16600
16646
  _this = _super.call(this);
16601
16647
  _this.webSocketFactory = webSocketFactory;
16602
16648
  _this.queue = {};
@@ -16607,18 +16653,19 @@ var solanaWeb3 = (function (exports) {
16607
16653
  _this.reconnect = reconnect;
16608
16654
  _this.reconnect_interval = reconnect_interval;
16609
16655
  _this.max_reconnects = max_reconnects;
16656
+ _this.rest_options = rest_options;
16610
16657
  _this.current_reconnects = 0;
16611
16658
 
16612
16659
  _this.generate_request_id = generate_request_id || function () {
16613
16660
  return ++_this.rpc_id;
16614
16661
  };
16615
16662
 
16616
- if (_this.autoconnect) _this._connect(_this.address, {
16663
+ if (_this.autoconnect) _this._connect(_this.address, Object.assign({
16617
16664
  autoconnect: _this.autoconnect,
16618
16665
  reconnect: _this.reconnect,
16619
16666
  reconnect_interval: _this.reconnect_interval,
16620
16667
  max_reconnects: _this.max_reconnects
16621
- });
16668
+ }, _this.rest_options));
16622
16669
  return _this;
16623
16670
  }
16624
16671
  /**
@@ -16633,12 +16680,12 @@ var solanaWeb3 = (function (exports) {
16633
16680
  value: function connect() {
16634
16681
  if (this.socket) return;
16635
16682
 
16636
- this._connect(this.address, {
16683
+ this._connect(this.address, Object.assign({
16637
16684
  autoconnect: this.autoconnect,
16638
16685
  reconnect: this.reconnect,
16639
16686
  reconnect_interval: this.reconnect_interval,
16640
16687
  max_reconnects: this.max_reconnects
16641
- });
16688
+ }, this.rest_options));
16642
16689
  }
16643
16690
  /**
16644
16691
  * Calls a registered RPC method on server.
@@ -16717,6 +16764,9 @@ var solanaWeb3 = (function (exports) {
16717
16764
  throw new Error("authentication failed");
16718
16765
 
16719
16766
  case 5:
16767
+ return _context.abrupt("return", resp);
16768
+
16769
+ case 6:
16720
16770
  case "end":
16721
16771
  return _context.stop();
16722
16772
  }
@@ -16922,8 +16972,8 @@ var solanaWeb3 = (function (exports) {
16922
16972
 
16923
16973
  _this4.current_reconnects = 0;
16924
16974
  });
16925
- this.socket.addEventListener("message", function (_ref2) {
16926
- var message = _ref2.data;
16975
+ this.socket.addEventListener("message", function (_ref) {
16976
+ var message = _ref.data;
16927
16977
  if (message instanceof ArrayBuffer) message = Buffer.from(message).toString();
16928
16978
 
16929
16979
  try {
@@ -16968,9 +17018,9 @@ var solanaWeb3 = (function (exports) {
16968
17018
  this.socket.addEventListener("error", function (error) {
16969
17019
  return _this4.emit("error", error);
16970
17020
  });
16971
- this.socket.addEventListener("close", function (_ref3) {
16972
- var code = _ref3.code,
16973
- reason = _ref3.reason;
17021
+ this.socket.addEventListener("close", function (_ref2) {
17022
+ var code = _ref2.code,
17023
+ reason = _ref2.reason;
16974
17024
  if (_this4.ready) // Delay close event until internal state is updated
16975
17025
  setTimeout(function () {
16976
17026
  return _this4.emit("close", code, reason);
@@ -21802,9 +21852,6 @@ var solanaWeb3 = (function (exports) {
21802
21852
  "minimalistic-assert": "^1.0.1",
21803
21853
  "minimalistic-crypto-utils": "^1.0.1"
21804
21854
  };
21805
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
21806
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
21807
- var _from = "elliptic@6.5.4";
21808
21855
  var require$$0 = {
21809
21856
  name: name,
21810
21857
  version: version,
@@ -21819,10 +21866,7 @@ var solanaWeb3 = (function (exports) {
21819
21866
  bugs: bugs,
21820
21867
  homepage: homepage,
21821
21868
  devDependencies: devDependencies,
21822
- dependencies: dependencies,
21823
- _resolved: _resolved,
21824
- _integrity: _integrity,
21825
- _from: _from
21869
+ dependencies: dependencies
21826
21870
  };
21827
21871
 
21828
21872
  var utils$m = {};
@@ -28482,10 +28526,8 @@ var solanaWeb3 = (function (exports) {
28482
28526
  const configKeys = [];
28483
28527
 
28484
28528
  for (let i = 0; i < 2; i++) {
28485
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
28486
- byteArray = byteArray.slice(PUBKEY_LENGTH);
28487
- const isSigner = byteArray.slice(0, 1)[0] === 1;
28488
- byteArray = byteArray.slice(1);
28529
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
28530
+ const isSigner = guardedShift(byteArray) === 1;
28489
28531
  configKeys.push({
28490
28532
  publicKey,
28491
28533
  isSigner
@@ -28682,6 +28724,7 @@ var solanaWeb3 = (function (exports) {
28682
28724
  exports.SYSVAR_REWARDS_PUBKEY = SYSVAR_REWARDS_PUBKEY;
28683
28725
  exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
28684
28726
  exports.Secp256k1Program = Secp256k1Program;
28727
+ exports.SendTransactionError = SendTransactionError;
28685
28728
  exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
28686
28729
  exports.StakeInstruction = StakeInstruction;
28687
28730
  exports.StakeProgram = StakeProgram;