@solana/web3.js 1.52.0 → 1.52.1

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
@@ -14085,6 +14085,36 @@ var solanaWeb3 = (function (exports) {
14085
14085
  }
14086
14086
  }
14087
14087
 
14088
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
14089
+ /**
14090
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
14091
+ */
14092
+
14093
+ function guardedShift(byteArray) {
14094
+ if (byteArray.length === 0) {
14095
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14096
+ }
14097
+
14098
+ return byteArray.shift();
14099
+ }
14100
+ /**
14101
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
14102
+ * the array.
14103
+ */
14104
+
14105
+ function guardedSplice(byteArray, ...args) {
14106
+ var _args$;
14107
+
14108
+ const [start] = args;
14109
+
14110
+ if (args.length === 2 // Implies that `deleteCount` was supplied
14111
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
14112
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14113
+ }
14114
+
14115
+ return byteArray.splice(...args);
14116
+ }
14117
+
14088
14118
  /**
14089
14119
  * The message header, identifying signed and read-only account
14090
14120
  */
@@ -14183,32 +14213,28 @@ var solanaWeb3 = (function (exports) {
14183
14213
  static from(buffer$1) {
14184
14214
  // Slice up wire data
14185
14215
  let byteArray = [...buffer$1];
14186
- const numRequiredSignatures = byteArray.shift();
14187
- const numReadonlySignedAccounts = byteArray.shift();
14188
- const numReadonlyUnsignedAccounts = byteArray.shift();
14216
+ const numRequiredSignatures = guardedShift(byteArray);
14217
+ const numReadonlySignedAccounts = guardedShift(byteArray);
14218
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
14189
14219
  const accountCount = decodeLength(byteArray);
14190
14220
  let accountKeys = [];
14191
14221
 
14192
14222
  for (let i = 0; i < accountCount; i++) {
14193
- const account = byteArray.slice(0, PUBKEY_LENGTH);
14194
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14223
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14195
14224
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
14196
14225
  }
14197
14226
 
14198
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
14199
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14227
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14200
14228
  const instructionCount = decodeLength(byteArray);
14201
14229
  let instructions = [];
14202
14230
 
14203
14231
  for (let i = 0; i < instructionCount; i++) {
14204
- const programIdIndex = byteArray.shift();
14232
+ const programIdIndex = guardedShift(byteArray);
14205
14233
  const accountCount = decodeLength(byteArray);
14206
- const accounts = byteArray.slice(0, accountCount);
14207
- byteArray = byteArray.slice(accountCount);
14234
+ const accounts = guardedSplice(byteArray, 0, accountCount);
14208
14235
  const dataLength = decodeLength(byteArray);
14209
- const dataSlice = byteArray.slice(0, dataLength);
14236
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
14210
14237
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
14211
- byteArray = byteArray.slice(dataLength);
14212
14238
  instructions.push({
14213
14239
  programIdIndex,
14214
14240
  accounts,
@@ -14237,6 +14263,10 @@ var solanaWeb3 = (function (exports) {
14237
14263
  }
14238
14264
  }
14239
14265
 
14266
+ /**
14267
+ * Transaction signature as base-58 encoded string
14268
+ */
14269
+
14240
14270
  exports.TransactionStatus = void 0;
14241
14271
  /**
14242
14272
  * Default (empty) signature
@@ -14916,8 +14946,7 @@ var solanaWeb3 = (function (exports) {
14916
14946
  let signatures = [];
14917
14947
 
14918
14948
  for (let i = 0; i < signatureCount; i++) {
14919
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
14920
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
14949
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
14921
14950
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14922
14951
  }
14923
14952
 
@@ -20682,7 +20711,7 @@ var solanaWeb3 = (function (exports) {
20682
20711
 
20683
20712
  /** @internal */
20684
20713
  const COMMON_HTTP_HEADERS = {
20685
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
20714
+ 'solana-client': `js/${(_process$env$npm_pack = "1.52.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
20686
20715
  };
20687
20716
  /**
20688
20717
  * A connection to a fullnode JSON RPC endpoint
@@ -30204,10 +30233,8 @@ var solanaWeb3 = (function (exports) {
30204
30233
  const configKeys = [];
30205
30234
 
30206
30235
  for (let i = 0; i < 2; i++) {
30207
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
30208
- byteArray = byteArray.slice(PUBKEY_LENGTH);
30209
- const isSigner = byteArray.slice(0, 1)[0] === 1;
30210
- byteArray = byteArray.slice(1);
30236
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
30237
+ const isSigner = guardedShift(byteArray) === 1;
30211
30238
  configKeys.push({
30212
30239
  publicKey,
30213
30240
  isSigner