@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.87.7",
3
+ "version": "1.88.1",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -37,11 +37,11 @@
37
37
  "/src"
38
38
  ],
39
39
  "dependencies": {
40
- "@babel/runtime": "^7.23.2",
40
+ "@babel/runtime": "^7.23.4",
41
41
  "@noble/curves": "^1.2.0",
42
- "@noble/hashes": "^1.3.1",
43
- "@solana/buffer-layout": "^4.0.0",
44
- "agentkeepalive": "^4.3.0",
42
+ "@noble/hashes": "^1.3.2",
43
+ "@solana/buffer-layout": "^4.0.1",
44
+ "agentkeepalive": "^4.5.0",
45
45
  "bigint-buffer": "^1.1.5",
46
46
  "bn.js": "^5.2.1",
47
47
  "borsh": "^0.7.0",
@@ -49,57 +49,57 @@
49
49
  "buffer": "6.0.3",
50
50
  "fast-stable-stringify": "^1.0.0",
51
51
  "jayson": "^4.1.0",
52
- "node-fetch": "^2.6.12",
52
+ "node-fetch": "^2.7.0",
53
53
  "rpc-websockets": "^7.5.1",
54
54
  "superstruct": "^0.14.2"
55
55
  },
56
56
  "devDependencies": {
57
- "@babel/core": "^7.23.2",
58
- "@babel/plugin-transform-class-properties": "^7.22.5",
59
- "@babel/plugin-transform-private-methods": "^7.22.5",
60
- "@babel/plugin-transform-private-property-in-object": "^7.22.11",
61
- "@babel/plugin-transform-runtime": "^7.23.3",
57
+ "@babel/core": "^7.23.3",
58
+ "@babel/plugin-transform-class-properties": "^7.23.3",
59
+ "@babel/plugin-transform-private-methods": "^7.23.3",
60
+ "@babel/plugin-transform-private-property-in-object": "^7.23.4",
61
+ "@babel/plugin-transform-runtime": "^7.23.4",
62
62
  "@babel/preset-env": "^7.23.3",
63
- "@babel/preset-typescript": "^7.23.2",
63
+ "@babel/preset-typescript": "^7.23.3",
64
64
  "@rollup/plugin-alias": "^4.0.3",
65
65
  "@rollup/plugin-babel": "^6.0.4",
66
66
  "@rollup/plugin-commonjs": "^25.0.4",
67
- "@rollup/plugin-json": "^6.0.0",
67
+ "@rollup/plugin-json": "^6.0.1",
68
68
  "@rollup/plugin-multi-entry": "^6.0.0",
69
- "@rollup/plugin-node-resolve": "^15.2.1",
69
+ "@rollup/plugin-node-resolve": "^15.2.3",
70
70
  "@rollup/plugin-replace": "^5.0.2",
71
71
  "@rollup/plugin-terser": "^0.4.3",
72
72
  "@solana/spl-token": "^0.3.8",
73
73
  "@types/bn.js": "^5.1.1",
74
74
  "@types/bs58": "^4.0.1",
75
75
  "@types/chai": "^4.3.5",
76
- "@types/chai-as-promised": "^7.1.3",
77
- "@types/express-serve-static-core": "^4.17.35",
78
- "@types/mocha": "^10.0.1",
76
+ "@types/chai-as-promised": "^7.1.8",
77
+ "@types/express-serve-static-core": "^4.17.41",
78
+ "@types/mocha": "^10.0.6",
79
79
  "@types/mz": "^2.7.4",
80
- "@types/node": "^20.6.0",
80
+ "@types/node": "18.11.19",
81
81
  "@types/node-fetch": "2",
82
82
  "@types/sinon": "^10.0.16",
83
- "@types/sinon-chai": "^3.2.9",
84
- "@typescript-eslint/eslint-plugin": "^6.7.0",
83
+ "@types/sinon-chai": "^3.2.12",
84
+ "@typescript-eslint/eslint-plugin": "^6.13.2",
85
85
  "@typescript-eslint/parser": "^6.3.0",
86
86
  "chai": "^4.3.7",
87
87
  "chai-as-promised": "^7.1.1",
88
88
  "cross-env": "7.0.3",
89
89
  "eslint": "^8.45.0",
90
- "eslint-config-prettier": "^9.0.0",
91
- "eslint-plugin-import": "^2.28.0",
90
+ "eslint-config-prettier": "^9.1.0",
91
+ "eslint-plugin-import": "^2.29.0",
92
92
  "eslint-plugin-mocha": "^10.1.0",
93
- "eslint-plugin-prettier": "^5.0.0",
93
+ "eslint-plugin-prettier": "^5.0.1",
94
94
  "esm": "^3.2.25",
95
95
  "mocha": "^10.2.0",
96
- "mockttp": "^3.9.2",
96
+ "mockttp": "^3.10.0",
97
97
  "mz": "^2.7.0",
98
98
  "node-abort-controller": "^3.0.1",
99
- "prettier": "^2.8",
100
- "rimraf": "5.0.1",
101
- "rollup": "^3.27.2",
102
- "rollup-plugin-dts": "^6.0.1",
99
+ "prettier": "^3.1",
100
+ "rimraf": "5.0.5",
101
+ "rollup": "^4.7.0",
102
+ "rollup-plugin-dts": "^6.1.0",
103
103
  "rollup-plugin-node-polyfills": "^0.2.1",
104
104
  "semantic-release": "^21.0.7",
105
105
  "sinon": "^15.2.0",
@@ -108,7 +108,7 @@
108
108
  "ts-mocha": "^10.0.0",
109
109
  "ts-node": "^10.9.1",
110
110
  "tslib": "^2.6.2",
111
- "typedoc": "^0.24.8",
111
+ "typedoc": "^0.25.4",
112
112
  "typescript": "^5.1.6",
113
113
  "tsconfig": "0.0.0"
114
114
  },
package/src/connection.ts CHANGED
@@ -5711,9 +5711,8 @@ export class Connection {
5711
5711
  } else {
5712
5712
  let disableCache = this._disableBlockhashCaching;
5713
5713
  for (;;) {
5714
- const latestBlockhash = await this._blockhashWithExpiryBlockHeight(
5715
- disableCache,
5716
- );
5714
+ const latestBlockhash =
5715
+ await this._blockhashWithExpiryBlockHeight(disableCache);
5717
5716
  transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
5718
5717
  transaction.recentBlockhash = latestBlockhash.blockhash;
5719
5718
 
@@ -5839,9 +5838,8 @@ export class Connection {
5839
5838
  } else {
5840
5839
  let disableCache = this._disableBlockhashCaching;
5841
5840
  for (;;) {
5842
- const latestBlockhash = await this._blockhashWithExpiryBlockHeight(
5843
- disableCache,
5844
- );
5841
+ const latestBlockhash =
5842
+ await this._blockhashWithExpiryBlockHeight(disableCache);
5845
5843
  transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
5846
5844
  transaction.recentBlockhash = latestBlockhash.blockhash;
5847
5845
  transaction.sign(...signers);
@@ -734,7 +734,7 @@ export class StakeProgram {
734
734
  if (custodianPubkey) {
735
735
  keys.push({
736
736
  pubkey: custodianPubkey,
737
- isSigner: false,
737
+ isSigner: true,
738
738
  isWritable: false,
739
739
  });
740
740
  }
@@ -776,7 +776,7 @@ export class StakeProgram {
776
776
  if (custodianPubkey) {
777
777
  keys.push({
778
778
  pubkey: custodianPubkey,
779
- isSigner: false,
779
+ isSigner: true,
780
780
  isWritable: false,
781
781
  });
782
782
  }
@@ -903,7 +903,7 @@ export class StakeProgram {
903
903
  if (custodianPubkey) {
904
904
  keys.push({
905
905
  pubkey: custodianPubkey,
906
- isSigner: false,
906
+ isSigner: true,
907
907
  isWritable: false,
908
908
  });
909
909
  }
@@ -14,6 +14,12 @@ import type {CompiledInstruction} from '../message';
14
14
  import {sign, verify} from '../utils/ed25519';
15
15
  import {guardedSplice} from '../utils/guarded-array-utils';
16
16
 
17
+ /** @internal */
18
+ type MessageSignednessErrors = {
19
+ invalid?: PublicKey[];
20
+ missing?: PublicKey[];
21
+ };
22
+
17
23
  /**
18
24
  * Transaction signature as base-58 encoded string
19
25
  */
@@ -758,32 +764,34 @@ export class Transaction {
758
764
  *
759
765
  * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction
760
766
  */
761
- verifySignatures(requireAllSignatures?: boolean): boolean {
762
- return this._verifySignatures(
767
+ verifySignatures(requireAllSignatures: boolean = true): boolean {
768
+ const signatureErrors = this._getMessageSignednessErrors(
763
769
  this.serializeMessage(),
764
- requireAllSignatures === undefined ? true : requireAllSignatures,
770
+ requireAllSignatures,
765
771
  );
772
+ return !signatureErrors;
766
773
  }
767
774
 
768
775
  /**
769
776
  * @internal
770
777
  */
771
- _verifySignatures(
772
- signData: Uint8Array,
778
+ _getMessageSignednessErrors(
779
+ message: Uint8Array,
773
780
  requireAllSignatures: boolean,
774
- ): boolean {
781
+ ): MessageSignednessErrors | undefined {
782
+ const errors: MessageSignednessErrors = {};
775
783
  for (const {signature, publicKey} of this.signatures) {
776
784
  if (signature === null) {
777
785
  if (requireAllSignatures) {
778
- return false;
786
+ (errors.missing ||= []).push(publicKey);
779
787
  }
780
788
  } else {
781
- if (!verify(signature, signData, publicKey.toBytes())) {
782
- return false;
789
+ if (!verify(signature, message, publicKey.toBytes())) {
790
+ (errors.invalid ||= []).push(publicKey);
783
791
  }
784
792
  }
785
793
  }
786
- return true;
794
+ return errors.invalid || errors.missing ? errors : undefined;
787
795
  }
788
796
 
789
797
  /**
@@ -800,11 +808,25 @@ export class Transaction {
800
808
  );
801
809
 
802
810
  const signData = this.serializeMessage();
803
- if (
804
- verifySignatures &&
805
- !this._verifySignatures(signData, requireAllSignatures)
806
- ) {
807
- throw new Error('Signature verification failed');
811
+ if (verifySignatures) {
812
+ const sigErrors = this._getMessageSignednessErrors(
813
+ signData,
814
+ requireAllSignatures,
815
+ );
816
+ if (sigErrors) {
817
+ let errorMessage = 'Signature verification failed.';
818
+ if (sigErrors.invalid) {
819
+ errorMessage += `\nInvalid signature for public key${
820
+ sigErrors.invalid.length === 1 ? '' : '(s)'
821
+ } [\`${sigErrors.invalid.map(p => p.toBase58()).join('`, `')}\`].`;
822
+ }
823
+ if (sigErrors.missing) {
824
+ errorMessage += `\nMissing signature for public key${
825
+ sigErrors.missing.length === 1 ? '' : '(s)'
826
+ } [\`${sigErrors.missing.map(p => p.toBase58()).join('`, `')}\`].`;
827
+ }
828
+ throw new Error(errorMessage);
829
+ }
808
830
  }
809
831
 
810
832
  return this._serialize(signData);