@solana/web3.js 1.36.0 → 1.36.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
@@ -14030,6 +14030,36 @@ var solanaWeb3 = (function (exports) {
14030
14030
  }
14031
14031
  }
14032
14032
 
14033
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
14034
+ /**
14035
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
14036
+ */
14037
+
14038
+ function guardedShift(byteArray) {
14039
+ if (byteArray.length === 0) {
14040
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14041
+ }
14042
+
14043
+ return byteArray.shift();
14044
+ }
14045
+ /**
14046
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
14047
+ * the array.
14048
+ */
14049
+
14050
+ function guardedSplice(byteArray, ...args) {
14051
+ var _args$;
14052
+
14053
+ const [start] = args;
14054
+
14055
+ if (args.length === 2 // Implies that `deleteCount` was supplied
14056
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
14057
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
14058
+ }
14059
+
14060
+ return byteArray.splice(...args);
14061
+ }
14062
+
14033
14063
  /**
14034
14064
  * The message header, identifying signed and read-only account
14035
14065
  */
@@ -14128,32 +14158,28 @@ var solanaWeb3 = (function (exports) {
14128
14158
  static from(buffer$1) {
14129
14159
  // Slice up wire data
14130
14160
  let byteArray = [...buffer$1];
14131
- const numRequiredSignatures = byteArray.shift();
14132
- const numReadonlySignedAccounts = byteArray.shift();
14133
- const numReadonlyUnsignedAccounts = byteArray.shift();
14161
+ const numRequiredSignatures = guardedShift(byteArray);
14162
+ const numReadonlySignedAccounts = guardedShift(byteArray);
14163
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
14134
14164
  const accountCount = decodeLength(byteArray);
14135
14165
  let accountKeys = [];
14136
14166
 
14137
14167
  for (let i = 0; i < accountCount; i++) {
14138
- const account = byteArray.slice(0, PUBKEY_LENGTH);
14139
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14168
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14140
14169
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
14141
14170
  }
14142
14171
 
14143
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
14144
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14172
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
14145
14173
  const instructionCount = decodeLength(byteArray);
14146
14174
  let instructions = [];
14147
14175
 
14148
14176
  for (let i = 0; i < instructionCount; i++) {
14149
- const programIdIndex = byteArray.shift();
14177
+ const programIdIndex = guardedShift(byteArray);
14150
14178
  const accountCount = decodeLength(byteArray);
14151
- const accounts = byteArray.slice(0, accountCount);
14152
- byteArray = byteArray.slice(accountCount);
14179
+ const accounts = guardedSplice(byteArray, 0, accountCount);
14153
14180
  const dataLength = decodeLength(byteArray);
14154
- const dataSlice = byteArray.slice(0, dataLength);
14181
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
14155
14182
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
14156
- byteArray = byteArray.slice(dataLength);
14157
14183
  instructions.push({
14158
14184
  programIdIndex,
14159
14185
  accounts,
@@ -14182,6 +14208,10 @@ var solanaWeb3 = (function (exports) {
14182
14208
  }
14183
14209
  }
14184
14210
 
14211
+ /**
14212
+ * Transaction signature as base-58 encoded string
14213
+ */
14214
+
14185
14215
  /**
14186
14216
  * Default (empty) signature
14187
14217
  *
@@ -14768,8 +14798,7 @@ var solanaWeb3 = (function (exports) {
14768
14798
  let signatures = [];
14769
14799
 
14770
14800
  for (let i = 0; i < signatureCount; i++) {
14771
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
14772
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
14801
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
14773
14802
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14774
14803
  }
14775
14804
 
@@ -28995,10 +29024,8 @@ var solanaWeb3 = (function (exports) {
28995
29024
  const configKeys = [];
28996
29025
 
28997
29026
  for (let i = 0; i < 2; i++) {
28998
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
28999
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29000
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29001
- byteArray = byteArray.slice(1);
29027
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29028
+ const isSigner = guardedShift(byteArray) === 1;
29002
29029
  configKeys.push({
29003
29030
  publicKey,
29004
29031
  isSigner