@solana/web3.js 1.14.0 → 1.14.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
 
@@ -22040,9 +22069,6 @@ var solanaWeb3 = (function (exports) {
22040
22069
  "minimalistic-assert": "^1.0.1",
22041
22070
  "minimalistic-crypto-utils": "^1.0.1"
22042
22071
  };
22043
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
22044
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
22045
- var _from = "elliptic@6.5.4";
22046
22072
  var require$$0 = {
22047
22073
  name: name,
22048
22074
  version: version,
@@ -22057,10 +22083,7 @@ var solanaWeb3 = (function (exports) {
22057
22083
  bugs: bugs,
22058
22084
  homepage: homepage,
22059
22085
  devDependencies: devDependencies,
22060
- dependencies: dependencies,
22061
- _resolved: _resolved,
22062
- _integrity: _integrity,
22063
- _from: _from
22086
+ dependencies: dependencies
22064
22087
  };
22065
22088
 
22066
22089
  var utils$m = {};
@@ -28700,10 +28723,8 @@ var solanaWeb3 = (function (exports) {
28700
28723
  const configKeys = [];
28701
28724
 
28702
28725
  for (let i = 0; i < 2; i++) {
28703
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
28704
- byteArray = byteArray.slice(PUBKEY_LENGTH);
28705
- const isSigner = byteArray.slice(0, 1)[0] === 1;
28706
- byteArray = byteArray.slice(1);
28726
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
28727
+ const isSigner = guardedShift(byteArray) === 1;
28707
28728
  configKeys.push({
28708
28729
  publicKey,
28709
28730
  isSigner