@solana/web3.js 1.50.0 → 1.50.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
@@ -14083,6 +14083,36 @@ var solanaWeb3 = (function (exports) {
14083
14083
  }
14084
14084
  }
14085
14085
 
14086
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
14087
+ /**
14088
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
14089
+ */
14090
+
14091
+ function guardedShift(byteArray) {
14092
+ if (byteArray.length === 0) {
14093
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14094
+ }
14095
+
14096
+ return byteArray.shift();
14097
+ }
14098
+ /**
14099
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
14100
+ * the array.
14101
+ */
14102
+
14103
+ function guardedSplice(byteArray, ...args) {
14104
+ var _args$;
14105
+
14106
+ const [start] = args;
14107
+
14108
+ if (args.length === 2 // Implies that `deleteCount` was supplied
14109
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
14110
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14111
+ }
14112
+
14113
+ return byteArray.splice(...args);
14114
+ }
14115
+
14086
14116
  /**
14087
14117
  * The message header, identifying signed and read-only account
14088
14118
  */
@@ -14181,32 +14211,28 @@ var solanaWeb3 = (function (exports) {
14181
14211
  static from(buffer$1) {
14182
14212
  // Slice up wire data
14183
14213
  let byteArray = [...buffer$1];
14184
- const numRequiredSignatures = byteArray.shift();
14185
- const numReadonlySignedAccounts = byteArray.shift();
14186
- const numReadonlyUnsignedAccounts = byteArray.shift();
14214
+ const numRequiredSignatures = guardedShift(byteArray);
14215
+ const numReadonlySignedAccounts = guardedShift(byteArray);
14216
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
14187
14217
  const accountCount = decodeLength(byteArray);
14188
14218
  let accountKeys = [];
14189
14219
 
14190
14220
  for (let i = 0; i < accountCount; i++) {
14191
- const account = byteArray.slice(0, PUBKEY_LENGTH);
14192
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14221
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14193
14222
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
14194
14223
  }
14195
14224
 
14196
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
14197
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14225
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14198
14226
  const instructionCount = decodeLength(byteArray);
14199
14227
  let instructions = [];
14200
14228
 
14201
14229
  for (let i = 0; i < instructionCount; i++) {
14202
- const programIdIndex = byteArray.shift();
14230
+ const programIdIndex = guardedShift(byteArray);
14203
14231
  const accountCount = decodeLength(byteArray);
14204
- const accounts = byteArray.slice(0, accountCount);
14205
- byteArray = byteArray.slice(accountCount);
14232
+ const accounts = guardedSplice(byteArray, 0, accountCount);
14206
14233
  const dataLength = decodeLength(byteArray);
14207
- const dataSlice = byteArray.slice(0, dataLength);
14234
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
14208
14235
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
14209
- byteArray = byteArray.slice(dataLength);
14210
14236
  instructions.push({
14211
14237
  programIdIndex,
14212
14238
  accounts,
@@ -14235,6 +14261,10 @@ var solanaWeb3 = (function (exports) {
14235
14261
  }
14236
14262
  }
14237
14263
 
14264
+ /**
14265
+ * Transaction signature as base-58 encoded string
14266
+ */
14267
+
14238
14268
  exports.TransactionStatus = void 0;
14239
14269
  /**
14240
14270
  * Default (empty) signature
@@ -14914,8 +14944,7 @@ var solanaWeb3 = (function (exports) {
14914
14944
  let signatures = [];
14915
14945
 
14916
14946
  for (let i = 0; i < signatureCount; i++) {
14917
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
14918
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
14947
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
14919
14948
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14920
14949
  }
14921
14950
 
@@ -20674,7 +20703,7 @@ var solanaWeb3 = (function (exports) {
20674
20703
 
20675
20704
  /** @internal */
20676
20705
  const COMMON_HTTP_HEADERS = {
20677
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
20706
+ 'solana-client': `js/${(_process$env$npm_pack = "1.50.2") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
20678
20707
  };
20679
20708
  /**
20680
20709
  * A connection to a fullnode JSON RPC endpoint
@@ -22716,6 +22745,11 @@ var solanaWeb3 = (function (exports) {
22716
22745
  this._rpcWebSocketConnected = false;
22717
22746
  this._rpcWebSocketGeneration++;
22718
22747
 
22748
+ if (this._rpcWebSocketIdleTimeout) {
22749
+ clearTimeout(this._rpcWebSocketIdleTimeout);
22750
+ this._rpcWebSocketIdleTimeout = null;
22751
+ }
22752
+
22719
22753
  if (this._rpcWebSocketHeartbeat) {
22720
22754
  clearInterval(this._rpcWebSocketHeartbeat);
22721
22755
  this._rpcWebSocketHeartbeat = null;
@@ -30186,10 +30220,8 @@ var solanaWeb3 = (function (exports) {
30186
30220
  const configKeys = [];
30187
30221
 
30188
30222
  for (let i = 0; i < 2; i++) {
30189
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
30190
- byteArray = byteArray.slice(PUBKEY_LENGTH);
30191
- const isSigner = byteArray.slice(0, 1)[0] === 1;
30192
- byteArray = byteArray.slice(1);
30223
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
30224
+ const isSigner = guardedShift(byteArray) === 1;
30193
30225
  configKeys.push({
30194
30226
  publicKey,
30195
30227
  isSigner