@solana/web3.js 1.37.1 → 1.37.3

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
@@ -13845,6 +13845,36 @@ var solanaWeb3 = (function (exports) {
13845
13845
  }
13846
13846
  }
13847
13847
 
13848
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
13849
+ /**
13850
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
13851
+ */
13852
+
13853
+ function guardedShift(byteArray) {
13854
+ if (byteArray.length === 0) {
13855
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13856
+ }
13857
+
13858
+ return byteArray.shift();
13859
+ }
13860
+ /**
13861
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
13862
+ * the array.
13863
+ */
13864
+
13865
+ function guardedSplice(byteArray, ...args) {
13866
+ var _args$;
13867
+
13868
+ const [start] = args;
13869
+
13870
+ if (args.length === 2 // Implies that `deleteCount` was supplied
13871
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
13872
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
13873
+ }
13874
+
13875
+ return byteArray.splice(...args);
13876
+ }
13877
+
13848
13878
  /**
13849
13879
  * The message header, identifying signed and read-only account
13850
13880
  */
@@ -13943,32 +13973,28 @@ var solanaWeb3 = (function (exports) {
13943
13973
  static from(buffer$1) {
13944
13974
  // Slice up wire data
13945
13975
  let byteArray = [...buffer$1];
13946
- const numRequiredSignatures = byteArray.shift();
13947
- const numReadonlySignedAccounts = byteArray.shift();
13948
- const numReadonlyUnsignedAccounts = byteArray.shift();
13976
+ const numRequiredSignatures = guardedShift(byteArray);
13977
+ const numReadonlySignedAccounts = guardedShift(byteArray);
13978
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
13949
13979
  const accountCount = decodeLength(byteArray);
13950
13980
  let accountKeys = [];
13951
13981
 
13952
13982
  for (let i = 0; i < accountCount; i++) {
13953
- const account = byteArray.slice(0, PUBKEY_LENGTH);
13954
- byteArray = byteArray.slice(PUBKEY_LENGTH);
13983
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13955
13984
  accountKeys.push(bs58$1.encode(buffer.Buffer.from(account)));
13956
13985
  }
13957
13986
 
13958
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
13959
- byteArray = byteArray.slice(PUBKEY_LENGTH);
13987
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
13960
13988
  const instructionCount = decodeLength(byteArray);
13961
13989
  let instructions = [];
13962
13990
 
13963
13991
  for (let i = 0; i < instructionCount; i++) {
13964
- const programIdIndex = byteArray.shift();
13992
+ const programIdIndex = guardedShift(byteArray);
13965
13993
  const accountCount = decodeLength(byteArray);
13966
- const accounts = byteArray.slice(0, accountCount);
13967
- byteArray = byteArray.slice(accountCount);
13994
+ const accounts = guardedSplice(byteArray, 0, accountCount);
13968
13995
  const dataLength = decodeLength(byteArray);
13969
- const dataSlice = byteArray.slice(0, dataLength);
13996
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
13970
13997
  const data = bs58$1.encode(buffer.Buffer.from(dataSlice));
13971
- byteArray = byteArray.slice(dataLength);
13972
13998
  instructions.push({
13973
13999
  programIdIndex,
13974
14000
  accounts,
@@ -13997,6 +14023,10 @@ var solanaWeb3 = (function (exports) {
13997
14023
  }
13998
14024
  }
13999
14025
 
14026
+ /**
14027
+ * Transaction signature as base-58 encoded string
14028
+ */
14029
+
14000
14030
  /**
14001
14031
  * Default (empty) signature
14002
14032
  *
@@ -14591,8 +14621,7 @@ var solanaWeb3 = (function (exports) {
14591
14621
  let signatures = [];
14592
14622
 
14593
14623
  for (let i = 0; i < signatureCount; i++) {
14594
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
14595
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
14624
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
14596
14625
  signatures.push(bs58$1.encode(buffer.Buffer.from(signature)));
14597
14626
  }
14598
14627
 
@@ -22514,7 +22543,14 @@ var solanaWeb3 = (function (exports) {
22514
22543
  let transaction;
22515
22544
 
22516
22545
  if (transactionOrMessage instanceof Transaction) {
22517
- transaction = transactionOrMessage;
22546
+ let originalTx = transactionOrMessage;
22547
+ transaction = new Transaction({
22548
+ recentBlockhash: originalTx.recentBlockhash,
22549
+ nonceInfo: originalTx.nonceInfo,
22550
+ feePayer: originalTx.feePayer,
22551
+ signatures: [...originalTx.signatures]
22552
+ });
22553
+ transaction.instructions = transactionOrMessage.instructions;
22518
22554
  } else {
22519
22555
  transaction = Transaction.populate(transactionOrMessage);
22520
22556
  }
@@ -22787,6 +22823,7 @@ var solanaWeb3 = (function (exports) {
22787
22823
 
22788
22824
  _resetSubscriptions() {
22789
22825
  Object.values(this._accountChangeSubscriptions).forEach(s => s.subscriptionId = null);
22826
+ Object.values(this._logsSubscriptions).forEach(s => s.subscriptionId = null);
22790
22827
  Object.values(this._programAccountChangeSubscriptions).forEach(s => s.subscriptionId = null);
22791
22828
  Object.values(this._rootSubscriptions).forEach(s => s.subscriptionId = null);
22792
22829
  Object.values(this._signatureSubscriptions).forEach(s => s.subscriptionId = null);
@@ -29342,10 +29379,8 @@ var solanaWeb3 = (function (exports) {
29342
29379
  const configKeys = [];
29343
29380
 
29344
29381
  for (let i = 0; i < 2; i++) {
29345
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
29346
- byteArray = byteArray.slice(PUBKEY_LENGTH);
29347
- const isSigner = byteArray.slice(0, 1)[0] === 1;
29348
- byteArray = byteArray.slice(1);
29382
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
29383
+ const isSigner = guardedShift(byteArray) === 1;
29349
29384
  configKeys.push({
29350
29385
  publicKey,
29351
29386
  isSigner