@solana/web3.js 1.55.0 → 1.55.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
@@ -11010,6 +11010,44 @@ var solanaWeb3 = (function (exports) {
11010
11010
  }
11011
11011
  }
11012
11012
 
11013
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11014
+ /**
11015
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11016
+ */
11017
+
11018
+ function guardedShift(byteArray) {
11019
+ if (byteArray.length === 0) {
11020
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11021
+ }
11022
+
11023
+ return byteArray.shift();
11024
+ }
11025
+ /**
11026
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11027
+ * the array.
11028
+ */
11029
+
11030
+ function guardedSplice(byteArray, ...args) {
11031
+ var _args$;
11032
+
11033
+ const [start] = args;
11034
+
11035
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11036
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
11037
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11038
+ }
11039
+
11040
+ return byteArray.splice(...args);
11041
+ }
11042
+
11043
+ /**
11044
+ * An instruction to execute by a program
11045
+ *
11046
+ * @property {number} programIdIndex
11047
+ * @property {number[]} accounts
11048
+ * @property {string} data
11049
+ */
11050
+
11013
11051
  /**
11014
11052
  * List of instructions to be processed atomically
11015
11053
  */
@@ -11122,37 +11160,33 @@ var solanaWeb3 = (function (exports) {
11122
11160
  static from(buffer$1) {
11123
11161
  // Slice up wire data
11124
11162
  let byteArray = [...buffer$1];
11125
- const numRequiredSignatures = byteArray.shift();
11163
+ const numRequiredSignatures = guardedShift(byteArray);
11126
11164
 
11127
11165
  if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {
11128
11166
  throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');
11129
11167
  }
11130
11168
 
11131
- const numReadonlySignedAccounts = byteArray.shift();
11132
- const numReadonlyUnsignedAccounts = byteArray.shift();
11169
+ const numReadonlySignedAccounts = guardedShift(byteArray);
11170
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11133
11171
  const accountCount = decodeLength(byteArray);
11134
11172
  let accountKeys = [];
11135
11173
 
11136
11174
  for (let i = 0; i < accountCount; i++) {
11137
- const account = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11138
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11175
+ const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11139
11176
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
11140
11177
  }
11141
11178
 
11142
- const recentBlockhash = byteArray.slice(0, PUBLIC_KEY_LENGTH);
11143
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
11179
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);
11144
11180
  const instructionCount = decodeLength(byteArray);
11145
11181
  let instructions = [];
11146
11182
 
11147
11183
  for (let i = 0; i < instructionCount; i++) {
11148
- const programIdIndex = byteArray.shift();
11184
+ const programIdIndex = guardedShift(byteArray);
11149
11185
  const accountCount = decodeLength(byteArray);
11150
- const accounts = byteArray.slice(0, accountCount);
11151
- byteArray = byteArray.slice(accountCount);
11186
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11152
11187
  const dataLength = decodeLength(byteArray);
11153
- const dataSlice = byteArray.slice(0, dataLength);
11188
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11154
11189
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
11155
- byteArray = byteArray.slice(dataLength);
11156
11190
  instructions.push({
11157
11191
  programIdIndex,
11158
11192
  accounts,
@@ -11275,33 +11309,33 @@ var solanaWeb3 = (function (exports) {
11275
11309
 
11276
11310
  static deserialize(serializedMessage) {
11277
11311
  let byteArray = [...serializedMessage];
11278
- const prefix = byteArray.shift();
11312
+ const prefix = guardedShift(byteArray);
11279
11313
  const maskedPrefix = prefix & VERSION_PREFIX_MASK;
11280
11314
  assert$1(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);
11281
11315
  const version = maskedPrefix;
11282
11316
  assert$1(version === 0, `Expected versioned message with version 0 but found version ${version}`);
11283
11317
  const header = {
11284
- numRequiredSignatures: byteArray.shift(),
11285
- numReadonlySignedAccounts: byteArray.shift(),
11286
- numReadonlyUnsignedAccounts: byteArray.shift()
11318
+ numRequiredSignatures: guardedShift(byteArray),
11319
+ numReadonlySignedAccounts: guardedShift(byteArray),
11320
+ numReadonlyUnsignedAccounts: guardedShift(byteArray)
11287
11321
  };
11288
11322
  const staticAccountKeys = [];
11289
11323
  const staticAccountKeysLength = decodeLength(byteArray);
11290
11324
 
11291
11325
  for (let i = 0; i < staticAccountKeysLength; i++) {
11292
- staticAccountKeys.push(new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH)));
11326
+ staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));
11293
11327
  }
11294
11328
 
11295
- const recentBlockhash = bs58$1.encode(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11329
+ const recentBlockhash = bs58$1.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11296
11330
  const instructionCount = decodeLength(byteArray);
11297
11331
  const compiledInstructions = [];
11298
11332
 
11299
11333
  for (let i = 0; i < instructionCount; i++) {
11300
- const programIdIndex = byteArray.shift();
11334
+ const programIdIndex = guardedShift(byteArray);
11301
11335
  const accountKeyIndexesLength = decodeLength(byteArray);
11302
- const accountKeyIndexes = byteArray.splice(0, accountKeyIndexesLength);
11336
+ const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);
11303
11337
  const dataLength = decodeLength(byteArray);
11304
- const data = new Uint8Array(byteArray.splice(0, dataLength));
11338
+ const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));
11305
11339
  compiledInstructions.push({
11306
11340
  programIdIndex,
11307
11341
  accountKeyIndexes,
@@ -11313,11 +11347,11 @@ var solanaWeb3 = (function (exports) {
11313
11347
  const addressTableLookups = [];
11314
11348
 
11315
11349
  for (let i = 0; i < addressTableLookupsCount; i++) {
11316
- const accountKey = new PublicKey(byteArray.splice(0, PUBLIC_KEY_LENGTH));
11350
+ const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
11317
11351
  const writableIndexesLength = decodeLength(byteArray);
11318
- const writableIndexes = byteArray.splice(0, writableIndexesLength);
11352
+ const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);
11319
11353
  const readonlyIndexesLength = decodeLength(byteArray);
11320
- const readonlyIndexes = byteArray.splice(0, readonlyIndexesLength);
11354
+ const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);
11321
11355
  addressTableLookups.push({
11322
11356
  accountKey,
11323
11357
  writableIndexes,
@@ -12048,8 +12082,7 @@ var solanaWeb3 = (function (exports) {
12048
12082
  let signatures = [];
12049
12083
 
12050
12084
  for (let i = 0; i < signatureCount; i++) {
12051
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
12052
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
12085
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
12053
12086
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
12054
12087
  }
12055
12088
 
@@ -12141,7 +12174,7 @@ var solanaWeb3 = (function (exports) {
12141
12174
  const signaturesLength = decodeLength(byteArray);
12142
12175
 
12143
12176
  for (let i = 0; i < signaturesLength; i++) {
12144
- signatures.push(new Uint8Array(byteArray.splice(0, SIGNATURE_LENGTH_IN_BYTES)));
12177
+ signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));
12145
12178
  }
12146
12179
 
12147
12180
  const message = VersionedMessage.deserialize(new Uint8Array(byteArray));
@@ -17670,7 +17703,7 @@ var solanaWeb3 = (function (exports) {
17670
17703
 
17671
17704
  /** @internal */
17672
17705
  const COMMON_HTTP_HEADERS = {
17673
- 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
17706
+ 'solana-client': `js/${(_process$env$npm_pack = "1.55.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
17674
17707
  };
17675
17708
  /**
17676
17709
  * A connection to a fullnode JSON RPC endpoint
@@ -24096,10 +24129,8 @@ var solanaWeb3 = (function (exports) {
24096
24129
  const configKeys = [];
24097
24130
 
24098
24131
  for (let i = 0; i < 2; i++) {
24099
- const publicKey = new PublicKey(byteArray.slice(0, PUBLIC_KEY_LENGTH));
24100
- byteArray = byteArray.slice(PUBLIC_KEY_LENGTH);
24101
- const isSigner = byteArray.slice(0, 1)[0] === 1;
24102
- byteArray = byteArray.slice(1);
24132
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));
24133
+ const isSigner = guardedShift(byteArray) === 1;
24103
24134
  configKeys.push({
24104
24135
  publicKey,
24105
24136
  isSigner