@solana/web3.js 1.87.7 → 1.88.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.
@@ -1145,6 +1145,8 @@ const VersionedMessage = {
1145
1145
  }
1146
1146
  };
1147
1147
 
1148
+ /** @internal */
1149
+
1148
1150
  /**
1149
1151
  * Transaction signature as base-58 encoded string
1150
1152
  */
@@ -1760,29 +1762,31 @@ class Transaction {
1760
1762
  *
1761
1763
  * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction
1762
1764
  */
1763
- verifySignatures(requireAllSignatures) {
1764
- return this._verifySignatures(this.serializeMessage(), requireAllSignatures === undefined ? true : requireAllSignatures);
1765
+ verifySignatures(requireAllSignatures = true) {
1766
+ const signatureErrors = this._getMessageSignednessErrors(this.serializeMessage(), requireAllSignatures);
1767
+ return !signatureErrors;
1765
1768
  }
1766
1769
 
1767
1770
  /**
1768
1771
  * @internal
1769
1772
  */
1770
- _verifySignatures(signData, requireAllSignatures) {
1773
+ _getMessageSignednessErrors(message, requireAllSignatures) {
1774
+ const errors = {};
1771
1775
  for (const {
1772
1776
  signature,
1773
1777
  publicKey
1774
1778
  } of this.signatures) {
1775
1779
  if (signature === null) {
1776
1780
  if (requireAllSignatures) {
1777
- return false;
1781
+ (errors.missing ||= []).push(publicKey);
1778
1782
  }
1779
1783
  } else {
1780
- if (!verify(signature, signData, publicKey.toBytes())) {
1781
- return false;
1784
+ if (!verify(signature, message, publicKey.toBytes())) {
1785
+ (errors.invalid ||= []).push(publicKey);
1782
1786
  }
1783
1787
  }
1784
1788
  }
1785
- return true;
1789
+ return errors.invalid || errors.missing ? errors : undefined;
1786
1790
  }
1787
1791
 
1788
1792
  /**
@@ -1801,8 +1805,18 @@ class Transaction {
1801
1805
  verifySignatures: true
1802
1806
  }, config);
1803
1807
  const signData = this.serializeMessage();
1804
- if (verifySignatures && !this._verifySignatures(signData, requireAllSignatures)) {
1805
- throw new Error('Signature verification failed');
1808
+ if (verifySignatures) {
1809
+ const sigErrors = this._getMessageSignednessErrors(signData, requireAllSignatures);
1810
+ if (sigErrors) {
1811
+ let errorMessage = 'Signature verification failed.';
1812
+ if (sigErrors.invalid) {
1813
+ errorMessage += `\nInvalid signature for public key${sigErrors.invalid.length === 1 ? '' : '(s)'} [\`${sigErrors.invalid.map(p => p.toBase58()).join('`, `')}\`].`;
1814
+ }
1815
+ if (sigErrors.missing) {
1816
+ errorMessage += `\nMissing signature for public key${sigErrors.missing.length === 1 ? '' : '(s)'} [\`${sigErrors.missing.map(p => p.toBase58()).join('`, `')}\`].`;
1817
+ }
1818
+ throw new Error(errorMessage);
1819
+ }
1806
1820
  }
1807
1821
  return this._serialize(signData);
1808
1822
  }
@@ -5070,7 +5084,7 @@ const LogsNotificationResult = type({
5070
5084
 
5071
5085
  /** @internal */
5072
5086
  const COMMON_HTTP_HEADERS = {
5073
- 'solana-client': `js/${"1.87.7" }`
5087
+ 'solana-client': `js/${"1.88.1" }`
5074
5088
  };
5075
5089
 
5076
5090
  /**
@@ -9271,7 +9285,7 @@ class StakeProgram {
9271
9285
  if (custodianPubkey) {
9272
9286
  keys.push({
9273
9287
  pubkey: custodianPubkey,
9274
- isSigner: false,
9288
+ isSigner: true,
9275
9289
  isWritable: false
9276
9290
  });
9277
9291
  }
@@ -9319,7 +9333,7 @@ class StakeProgram {
9319
9333
  if (custodianPubkey) {
9320
9334
  keys.push({
9321
9335
  pubkey: custodianPubkey,
9322
- isSigner: false,
9336
+ isSigner: true,
9323
9337
  isWritable: false
9324
9338
  });
9325
9339
  }
@@ -9484,7 +9498,7 @@ class StakeProgram {
9484
9498
  if (custodianPubkey) {
9485
9499
  keys.push({
9486
9500
  pubkey: custodianPubkey,
9487
- isSigner: false,
9501
+ isSigner: true,
9488
9502
  isWritable: false
9489
9503
  });
9490
9504
  }