@solana/web3.js 1.30.2 → 1.30.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
@@ -14019,6 +14019,36 @@ var solanaWeb3 = (function (exports) {
14019
14019
  }
14020
14020
  }
14021
14021
 
14022
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
14023
+ /**
14024
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
14025
+ */
14026
+
14027
+ function guardedShift(byteArray) {
14028
+ if (byteArray.length === 0) {
14029
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14030
+ }
14031
+
14032
+ return byteArray.shift();
14033
+ }
14034
+ /**
14035
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
14036
+ * the array.
14037
+ */
14038
+
14039
+ function guardedSplice(byteArray, ...args) {
14040
+ var _args$;
14041
+
14042
+ const [start] = args;
14043
+
14044
+ if (args.length === 2 // Implies that `deleteCount` was supplied
14045
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
14046
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14047
+ }
14048
+
14049
+ return byteArray.splice(...args);
14050
+ }
14051
+
14022
14052
  /**
14023
14053
  * The message header, identifying signed and read-only account
14024
14054
  */
@@ -14117,32 +14147,28 @@ var solanaWeb3 = (function (exports) {
14117
14147
  static from(buffer$1) {
14118
14148
  // Slice up wire data
14119
14149
  let byteArray = [...buffer$1];
14120
- const numRequiredSignatures = byteArray.shift();
14121
- const numReadonlySignedAccounts = byteArray.shift();
14122
- const numReadonlyUnsignedAccounts = byteArray.shift();
14150
+ const numRequiredSignatures = guardedShift(byteArray);
14151
+ const numReadonlySignedAccounts = guardedShift(byteArray);
14152
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
14123
14153
  const accountCount = decodeLength(byteArray);
14124
14154
  let accountKeys = [];
14125
14155
 
14126
14156
  for (let i = 0; i < accountCount; i++) {
14127
- const account = byteArray.slice(0, PUBKEY_LENGTH);
14128
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14157
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14129
14158
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
14130
14159
  }
14131
14160
 
14132
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
14133
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14161
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14134
14162
  const instructionCount = decodeLength(byteArray);
14135
14163
  let instructions = [];
14136
14164
 
14137
14165
  for (let i = 0; i < instructionCount; i++) {
14138
- const programIdIndex = byteArray.shift();
14166
+ const programIdIndex = guardedShift(byteArray);
14139
14167
  const accountCount = decodeLength(byteArray);
14140
- const accounts = byteArray.slice(0, accountCount);
14141
- byteArray = byteArray.slice(accountCount);
14168
+ const accounts = guardedSplice(byteArray, 0, accountCount);
14142
14169
  const dataLength = decodeLength(byteArray);
14143
- const dataSlice = byteArray.slice(0, dataLength);
14170
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
14144
14171
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
14145
- byteArray = byteArray.slice(dataLength);
14146
14172
  instructions.push({
14147
14173
  programIdIndex,
14148
14174
  accounts,
@@ -14171,6 +14197,10 @@ var solanaWeb3 = (function (exports) {
14171
14197
  }
14172
14198
  }
14173
14199
 
14200
+ /**
14201
+ * Transaction signature as base-58 encoded string
14202
+ */
14203
+
14174
14204
  /**
14175
14205
  * Default (empty) signature
14176
14206
  *
@@ -14756,8 +14786,7 @@ var solanaWeb3 = (function (exports) {
14756
14786
  let signatures = [];
14757
14787
 
14758
14788
  for (let i = 0; i < signatureCount; i++) {
14759
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
14760
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
14789
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
14761
14790
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14762
14791
  }
14763
14792
 
@@ -28722,10 +28751,8 @@ var solanaWeb3 = (function (exports) {
28722
28751
  const configKeys = [];
28723
28752
 
28724
28753
  for (let i = 0; i < 2; i++) {
28725
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
28726
- byteArray = byteArray.slice(PUBKEY_LENGTH);
28727
- const isSigner = byteArray.slice(0, 1)[0] === 1;
28728
- byteArray = byteArray.slice(1);
28754
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
28755
+ const isSigner = guardedShift(byteArray) === 1;
28729
28756
  configKeys.push({
28730
28757
  publicKey,
28731
28758
  isSigner