@solana/web3.js 1.15.0 → 1.15.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
@@ -11880,6 +11880,36 @@ var solanaWeb3 = (function (exports) {
11880
11880
  }
11881
11881
  }
11882
11882
 
11883
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11884
+ /**
11885
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11886
+ */
11887
+
11888
+ function guardedShift(byteArray) {
11889
+ if (byteArray.length === 0) {
11890
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11891
+ }
11892
+
11893
+ return byteArray.shift();
11894
+ }
11895
+ /**
11896
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11897
+ * the array.
11898
+ */
11899
+
11900
+ function guardedSplice(byteArray, ...args) {
11901
+ var _args$;
11902
+
11903
+ const [start] = args;
11904
+
11905
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11906
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
11907
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11908
+ }
11909
+
11910
+ return byteArray.splice(...args);
11911
+ }
11912
+
11883
11913
  /**
11884
11914
  * The message header, identifying signed and read-only account
11885
11915
  */
@@ -11956,32 +11986,28 @@ var solanaWeb3 = (function (exports) {
11956
11986
  static from(buffer$1) {
11957
11987
  // Slice up wire data
11958
11988
  let byteArray = [...buffer$1];
11959
- const numRequiredSignatures = byteArray.shift();
11960
- const numReadonlySignedAccounts = byteArray.shift();
11961
- const numReadonlyUnsignedAccounts = byteArray.shift();
11989
+ const numRequiredSignatures = guardedShift(byteArray);
11990
+ const numReadonlySignedAccounts = guardedShift(byteArray);
11991
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11962
11992
  const accountCount = decodeLength(byteArray);
11963
11993
  let accountKeys = [];
11964
11994
 
11965
11995
  for (let i = 0; i < accountCount; i++) {
11966
- const account = byteArray.slice(0, PUBKEY_LENGTH);
11967
- byteArray = byteArray.slice(PUBKEY_LENGTH);
11996
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
11968
11997
  accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
11969
11998
  }
11970
11999
 
11971
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
11972
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12000
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
11973
12001
  const instructionCount = decodeLength(byteArray);
11974
12002
  let instructions = [];
11975
12003
 
11976
12004
  for (let i = 0; i < instructionCount; i++) {
11977
- const programIdIndex = byteArray.shift();
12005
+ const programIdIndex = guardedShift(byteArray);
11978
12006
  const accountCount = decodeLength(byteArray);
11979
- const accounts = byteArray.slice(0, accountCount);
11980
- byteArray = byteArray.slice(accountCount);
12007
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11981
12008
  const dataLength = decodeLength(byteArray);
11982
- const dataSlice = byteArray.slice(0, dataLength);
12009
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11983
12010
  const data = bs58.encode(buffer.Buffer.from(dataSlice));
11984
- byteArray = byteArray.slice(dataLength);
11985
12011
  instructions.push({
11986
12012
  programIdIndex,
11987
12013
  accounts,
@@ -12004,6 +12030,10 @@ var solanaWeb3 = (function (exports) {
12004
12030
 
12005
12031
  }
12006
12032
 
12033
+ /**
12034
+ * Transaction signature as base-58 encoded string
12035
+ */
12036
+
12007
12037
  /**
12008
12038
  * Default (empty) signature
12009
12039
  *
@@ -12587,8 +12617,7 @@ var solanaWeb3 = (function (exports) {
12587
12617
  let signatures = [];
12588
12618
 
12589
12619
  for (let i = 0; i < signatureCount; i++) {
12590
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
12591
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
12620
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
12592
12621
  signatures.push(bs58.encode(buffer.Buffer.from(signature)));
12593
12622
  }
12594
12623
 
@@ -22054,9 +22083,6 @@ var solanaWeb3 = (function (exports) {
22054
22083
  "minimalistic-assert": "^1.0.1",
22055
22084
  "minimalistic-crypto-utils": "^1.0.1"
22056
22085
  };
22057
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
22058
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
22059
- var _from = "elliptic@6.5.4";
22060
22086
  var require$$0 = {
22061
22087
  name: name,
22062
22088
  version: version,
@@ -22071,10 +22097,7 @@ var solanaWeb3 = (function (exports) {
22071
22097
  bugs: bugs,
22072
22098
  homepage: homepage,
22073
22099
  devDependencies: devDependencies,
22074
- dependencies: dependencies,
22075
- _resolved: _resolved,
22076
- _integrity: _integrity,
22077
- _from: _from
22100
+ dependencies: dependencies
22078
22101
  };
22079
22102
 
22080
22103
  var utils$m = {};
@@ -28714,10 +28737,8 @@ var solanaWeb3 = (function (exports) {
28714
28737
  const configKeys = [];
28715
28738
 
28716
28739
  for (let i = 0; i < 2; i++) {
28717
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
28718
- byteArray = byteArray.slice(PUBKEY_LENGTH);
28719
- const isSigner = byteArray.slice(0, 1)[0] === 1;
28720
- byteArray = byteArray.slice(1);
28740
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
28741
+ const isSigner = guardedShift(byteArray) === 1;
28721
28742
  configKeys.push({
28722
28743
  publicKey,
28723
28744
  isSigner