@solana/web3.js 1.16.0 → 1.16.2

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
@@ -11888,6 +11888,36 @@ var solanaWeb3 = (function (exports) {
11888
11888
  }
11889
11889
  }
11890
11890
 
11891
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
11892
+ /**
11893
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
11894
+ */
11895
+
11896
+ function guardedShift(byteArray) {
11897
+ if (byteArray.length === 0) {
11898
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11899
+ }
11900
+
11901
+ return byteArray.shift();
11902
+ }
11903
+ /**
11904
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
11905
+ * the array.
11906
+ */
11907
+
11908
+ function guardedSplice(byteArray, ...args) {
11909
+ var _args$;
11910
+
11911
+ const [start] = args;
11912
+
11913
+ if (args.length === 2 // Implies that `deleteCount` was supplied
11914
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
11915
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
11916
+ }
11917
+
11918
+ return byteArray.splice(...args);
11919
+ }
11920
+
11891
11921
  /**
11892
11922
  * The message header, identifying signed and read-only account
11893
11923
  */
@@ -11972,32 +12002,28 @@ var solanaWeb3 = (function (exports) {
11972
12002
  static from(buffer$1) {
11973
12003
  // Slice up wire data
11974
12004
  let byteArray = [...buffer$1];
11975
- const numRequiredSignatures = byteArray.shift();
11976
- const numReadonlySignedAccounts = byteArray.shift();
11977
- const numReadonlyUnsignedAccounts = byteArray.shift();
12005
+ const numRequiredSignatures = guardedShift(byteArray);
12006
+ const numReadonlySignedAccounts = guardedShift(byteArray);
12007
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
11978
12008
  const accountCount = decodeLength(byteArray);
11979
12009
  let accountKeys = [];
11980
12010
 
11981
12011
  for (let i = 0; i < accountCount; i++) {
11982
- const account = byteArray.slice(0, PUBKEY_LENGTH);
11983
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12012
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
11984
12013
  accountKeys.push(bs58.encode(buffer.Buffer.from(account)));
11985
12014
  }
11986
12015
 
11987
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
11988
- byteArray = byteArray.slice(PUBKEY_LENGTH);
12016
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
11989
12017
  const instructionCount = decodeLength(byteArray);
11990
12018
  let instructions = [];
11991
12019
 
11992
12020
  for (let i = 0; i < instructionCount; i++) {
11993
- const programIdIndex = byteArray.shift();
12021
+ const programIdIndex = guardedShift(byteArray);
11994
12022
  const accountCount = decodeLength(byteArray);
11995
- const accounts = byteArray.slice(0, accountCount);
11996
- byteArray = byteArray.slice(accountCount);
12023
+ const accounts = guardedSplice(byteArray, 0, accountCount);
11997
12024
  const dataLength = decodeLength(byteArray);
11998
- const dataSlice = byteArray.slice(0, dataLength);
12025
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
11999
12026
  const data = bs58.encode(buffer.Buffer.from(dataSlice));
12000
- byteArray = byteArray.slice(dataLength);
12001
12027
  instructions.push({
12002
12028
  programIdIndex,
12003
12029
  accounts,
@@ -12020,6 +12046,10 @@ var solanaWeb3 = (function (exports) {
12020
12046
 
12021
12047
  }
12022
12048
 
12049
+ /**
12050
+ * Transaction signature as base-58 encoded string
12051
+ */
12052
+
12023
12053
  /**
12024
12054
  * Default (empty) signature
12025
12055
  *
@@ -12161,7 +12191,7 @@ var solanaWeb3 = (function (exports) {
12161
12191
  }
12162
12192
 
12163
12193
  if (this.instructions.length < 1) {
12164
- throw new Error('No instructions provided');
12194
+ console.warn('No instructions provided');
12165
12195
  }
12166
12196
 
12167
12197
  let feePayer;
@@ -12613,8 +12643,7 @@ var solanaWeb3 = (function (exports) {
12613
12643
  let signatures = [];
12614
12644
 
12615
12645
  for (let i = 0; i < signatureCount; i++) {
12616
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
12617
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
12646
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
12618
12647
  signatures.push(bs58.encode(buffer.Buffer.from(signature)));
12619
12648
  }
12620
12649
 
@@ -22112,9 +22141,6 @@ var solanaWeb3 = (function (exports) {
22112
22141
  "minimalistic-assert": "^1.0.1",
22113
22142
  "minimalistic-crypto-utils": "^1.0.1"
22114
22143
  };
22115
- var _resolved = "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz";
22116
- var _integrity = "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==";
22117
- var _from = "elliptic@6.5.4";
22118
22144
  var require$$0 = {
22119
22145
  name: name,
22120
22146
  version: version,
@@ -22129,10 +22155,7 @@ var solanaWeb3 = (function (exports) {
22129
22155
  bugs: bugs,
22130
22156
  homepage: homepage,
22131
22157
  devDependencies: devDependencies,
22132
- dependencies: dependencies,
22133
- _resolved: _resolved,
22134
- _integrity: _integrity,
22135
- _from: _from
22158
+ dependencies: dependencies
22136
22159
  };
22137
22160
 
22138
22161
  var utils$m = {};
@@ -28776,10 +28799,8 @@ var solanaWeb3 = (function (exports) {
28776
28799
  const configKeys = [];
28777
28800
 
28778
28801
  for (let i = 0; i < 2; i++) {
28779
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
28780
- byteArray = byteArray.slice(PUBKEY_LENGTH);
28781
- const isSigner = byteArray.slice(0, 1)[0] === 1;
28782
- byteArray = byteArray.slice(1);
28802
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
28803
+ const isSigner = guardedShift(byteArray) === 1;
28783
28804
  configKeys.push({
28784
28805
  publicKey,
28785
28806
  isSigner