@solana/web3.js 1.44.2 → 1.44.4

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
@@ -13878,6 +13878,36 @@ var solanaWeb3 = (function (exports) {
13878
13878
  }
13879
13879
  }
13880
13880
 
13881
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
13882
+ /**
13883
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
13884
+ */
13885
+
13886
+ function guardedShift(byteArray) {
13887
+ if (byteArray.length === 0) {
13888
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13889
+ }
13890
+
13891
+ return byteArray.shift();
13892
+ }
13893
+ /**
13894
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
13895
+ * the array.
13896
+ */
13897
+
13898
+ function guardedSplice(byteArray, ...args) {
13899
+ var _args$;
13900
+
13901
+ const [start] = args;
13902
+
13903
+ if (args.length === 2 // Implies that `deleteCount` was supplied
13904
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
13905
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13906
+ }
13907
+
13908
+ return byteArray.splice(...args);
13909
+ }
13910
+
13881
13911
  /**
13882
13912
  * The message header, identifying signed and read-only account
13883
13913
  */
@@ -13976,32 +14006,28 @@ var solanaWeb3 = (function (exports) {
13976
14006
  static from(buffer$1) {
13977
14007
  // Slice up wire data
13978
14008
  let byteArray = [...buffer$1];
13979
- const numRequiredSignatures = byteArray.shift();
13980
- const numReadonlySignedAccounts = byteArray.shift();
13981
- const numReadonlyUnsignedAccounts = byteArray.shift();
14009
+ const numRequiredSignatures = guardedShift(byteArray);
14010
+ const numReadonlySignedAccounts = guardedShift(byteArray);
14011
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
13982
14012
  const accountCount = decodeLength(byteArray);
13983
14013
  let accountKeys = [];
13984
14014
 
13985
14015
  for (let i = 0; i < accountCount; i++) {
13986
- const account = byteArray.slice(0, PUBKEY_LENGTH);
13987
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14016
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13988
14017
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
13989
14018
  }
13990
14019
 
13991
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
13992
- byteArray = byteArray.slice(PUBKEY_LENGTH);
14020
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13993
14021
  const instructionCount = decodeLength(byteArray);
13994
14022
  let instructions = [];
13995
14023
 
13996
14024
  for (let i = 0; i < instructionCount; i++) {
13997
- const programIdIndex = byteArray.shift();
14025
+ const programIdIndex = guardedShift(byteArray);
13998
14026
  const accountCount = decodeLength(byteArray);
13999
- const accounts = byteArray.slice(0, accountCount);
14000
- byteArray = byteArray.slice(accountCount);
14027
+ const accounts = guardedSplice(byteArray, 0, accountCount);
14001
14028
  const dataLength = decodeLength(byteArray);
14002
- const dataSlice = byteArray.slice(0, dataLength);
14029
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
14003
14030
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
14004
- byteArray = byteArray.slice(dataLength);
14005
14031
  instructions.push({
14006
14032
  programIdIndex,
14007
14033
  accounts,
@@ -14030,6 +14056,10 @@ var solanaWeb3 = (function (exports) {
14030
14056
  }
14031
14057
  }
14032
14058
 
14059
+ /**
14060
+ * Transaction signature as base-58 encoded string
14061
+ */
14062
+
14033
14063
  exports.TransactionStatus = void 0;
14034
14064
  /**
14035
14065
  * Default (empty) signature
@@ -14201,24 +14231,27 @@ var solanaWeb3 = (function (exports) {
14201
14231
  return this._message;
14202
14232
  }
14203
14233
 
14204
- const {
14205
- nonceInfo
14206
- } = this;
14234
+ let recentBlockhash;
14235
+ let instructions;
14207
14236
 
14208
- if (nonceInfo && this.instructions[0] != nonceInfo.nonceInstruction) {
14209
- this.recentBlockhash = nonceInfo.nonce;
14210
- this.instructions.unshift(nonceInfo.nonceInstruction);
14211
- }
14237
+ if (this.nonceInfo) {
14238
+ recentBlockhash = this.nonceInfo.nonce;
14212
14239
 
14213
- const {
14214
- recentBlockhash
14215
- } = this;
14240
+ if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
14241
+ instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
14242
+ } else {
14243
+ instructions = this.instructions;
14244
+ }
14245
+ } else {
14246
+ recentBlockhash = this.recentBlockhash;
14247
+ instructions = this.instructions;
14248
+ }
14216
14249
 
14217
14250
  if (!recentBlockhash) {
14218
14251
  throw new Error('Transaction recentBlockhash required');
14219
14252
  }
14220
14253
 
14221
- if (this.instructions.length < 1) {
14254
+ if (instructions.length < 1) {
14222
14255
  console.warn('No instructions provided');
14223
14256
  }
14224
14257
 
@@ -14233,15 +14266,15 @@ var solanaWeb3 = (function (exports) {
14233
14266
  throw new Error('Transaction fee payer required');
14234
14267
  }
14235
14268
 
14236
- for (let i = 0; i < this.instructions.length; i++) {
14237
- if (this.instructions[i].programId === undefined) {
14269
+ for (let i = 0; i < instructions.length; i++) {
14270
+ if (instructions[i].programId === undefined) {
14238
14271
  throw new Error(`Transaction instruction index ${i} has undefined program id`);
14239
14272
  }
14240
14273
  }
14241
14274
 
14242
14275
  const programIds = [];
14243
14276
  const accountMetas = [];
14244
- this.instructions.forEach(instruction => {
14277
+ instructions.forEach(instruction => {
14245
14278
  instruction.keys.forEach(accountMeta => {
14246
14279
  accountMetas.push({ ...accountMeta
14247
14280
  });
@@ -14351,7 +14384,7 @@ var solanaWeb3 = (function (exports) {
14351
14384
  }
14352
14385
  });
14353
14386
  const accountKeys = signedKeys.concat(unsignedKeys);
14354
- const instructions = this.instructions.map(instruction => {
14387
+ const compiledInstructions = instructions.map(instruction => {
14355
14388
  const {
14356
14389
  data,
14357
14390
  programId
@@ -14362,7 +14395,7 @@ var solanaWeb3 = (function (exports) {
14362
14395
  data: bs58$1.encode(data)
14363
14396
  };
14364
14397
  });
14365
- instructions.forEach(instruction => {
14398
+ compiledInstructions.forEach(instruction => {
14366
14399
  assert$c(instruction.programIdIndex >= 0);
14367
14400
  instruction.accounts.forEach(keyIndex => assert$c(keyIndex >= 0));
14368
14401
  });
@@ -14374,7 +14407,7 @@ var solanaWeb3 = (function (exports) {
14374
14407
  },
14375
14408
  accountKeys,
14376
14409
  recentBlockhash,
14377
- instructions
14410
+ instructions: compiledInstructions
14378
14411
  });
14379
14412
  }
14380
14413
  /**
@@ -14687,8 +14720,7 @@ var solanaWeb3 = (function (exports) {
14687
14720
  let signatures = [];
14688
14721
 
14689
14722
  for (let i = 0; i < signatureCount; i++) {
14690
- const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
14691
- byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
14723
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);
14692
14724
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14693
14725
  }
14694
14726
 
@@ -29706,10 +29738,8 @@ var solanaWeb3 = (function (exports) {
29706
29738
  const configKeys = [];
29707
29739
 
29708
29740
  for (let i = 0; i < 2; i++) {
29709
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
29710
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29711
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29712
- byteArray = byteArray.slice(1);
29741
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29742
+ const isSigner = guardedShift(byteArray) === 1;
29713
29743
  configKeys.push({
29714
29744
  publicKey,
29715
29745
  isSigner