@solana/web3.js 1.87.6 → 1.89.0

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.6",
3
+ "version": "1.89.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -54,11 +54,11 @@
54
54
  "test:unit:node": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'"
55
55
  },
56
56
  "dependencies": {
57
- "@babel/runtime": "^7.23.2",
57
+ "@babel/runtime": "^7.23.4",
58
58
  "@noble/curves": "^1.2.0",
59
- "@noble/hashes": "^1.3.1",
60
- "@solana/buffer-layout": "^4.0.0",
61
- "agentkeepalive": "^4.3.0",
59
+ "@noble/hashes": "^1.3.2",
60
+ "@solana/buffer-layout": "^4.0.1",
61
+ "agentkeepalive": "^4.5.0",
62
62
  "bigint-buffer": "^1.1.5",
63
63
  "bn.js": "^5.2.1",
64
64
  "borsh": "^0.7.0",
@@ -66,57 +66,57 @@
66
66
  "buffer": "6.0.3",
67
67
  "fast-stable-stringify": "^1.0.0",
68
68
  "jayson": "^4.1.0",
69
- "node-fetch": "^2.6.12",
69
+ "node-fetch": "^2.7.0",
70
70
  "rpc-websockets": "^7.5.1",
71
71
  "superstruct": "^0.14.2"
72
72
  },
73
73
  "devDependencies": {
74
- "@babel/core": "^7.23.2",
75
- "@babel/plugin-transform-class-properties": "^7.22.5",
76
- "@babel/plugin-transform-private-methods": "^7.22.5",
77
- "@babel/plugin-transform-private-property-in-object": "^7.22.11",
78
- "@babel/plugin-transform-runtime": "^7.23.3",
74
+ "@babel/core": "^7.23.7",
75
+ "@babel/plugin-transform-class-properties": "^7.23.3",
76
+ "@babel/plugin-transform-private-methods": "^7.23.3",
77
+ "@babel/plugin-transform-private-property-in-object": "^7.23.4",
78
+ "@babel/plugin-transform-runtime": "^7.23.7",
79
79
  "@babel/preset-env": "^7.23.3",
80
- "@babel/preset-typescript": "^7.23.2",
80
+ "@babel/preset-typescript": "^7.23.3",
81
81
  "@rollup/plugin-alias": "^4.0.3",
82
82
  "@rollup/plugin-babel": "^6.0.4",
83
83
  "@rollup/plugin-commonjs": "^25.0.4",
84
- "@rollup/plugin-json": "^6.0.0",
84
+ "@rollup/plugin-json": "^6.0.1",
85
85
  "@rollup/plugin-multi-entry": "^6.0.0",
86
- "@rollup/plugin-node-resolve": "^15.2.1",
86
+ "@rollup/plugin-node-resolve": "^15.2.3",
87
87
  "@rollup/plugin-replace": "^5.0.2",
88
88
  "@rollup/plugin-terser": "^0.4.3",
89
89
  "@solana/spl-token": "^0.3.8",
90
90
  "@types/bn.js": "^5.1.1",
91
91
  "@types/bs58": "^4.0.1",
92
92
  "@types/chai": "^4.3.5",
93
- "@types/chai-as-promised": "^7.1.3",
94
- "@types/express-serve-static-core": "^4.17.35",
95
- "@types/mocha": "^10.0.1",
93
+ "@types/chai-as-promised": "^7.1.8",
94
+ "@types/express-serve-static-core": "^4.17.41",
95
+ "@types/mocha": "^10.0.6",
96
96
  "@types/mz": "^2.7.4",
97
- "@types/node": "^20.6.0",
97
+ "@types/node": "18.11.19",
98
98
  "@types/node-fetch": "2",
99
99
  "@types/sinon": "^10.0.16",
100
- "@types/sinon-chai": "^3.2.9",
101
- "@typescript-eslint/eslint-plugin": "^6.7.0",
100
+ "@types/sinon-chai": "^3.2.12",
101
+ "@typescript-eslint/eslint-plugin": "^6.13.2",
102
102
  "@typescript-eslint/parser": "^6.3.0",
103
103
  "chai": "^4.3.7",
104
104
  "chai-as-promised": "^7.1.1",
105
105
  "cross-env": "7.0.3",
106
106
  "eslint": "^8.45.0",
107
- "eslint-config-prettier": "^9.0.0",
108
- "eslint-plugin-import": "^2.28.0",
107
+ "eslint-config-prettier": "^9.1.0",
108
+ "eslint-plugin-import": "^2.29.0",
109
109
  "eslint-plugin-mocha": "^10.1.0",
110
- "eslint-plugin-prettier": "^5.0.0",
110
+ "eslint-plugin-prettier": "^5.0.1",
111
111
  "esm": "^3.2.25",
112
112
  "mocha": "^10.2.0",
113
- "mockttp": "^3.9.2",
113
+ "mockttp": "^3.10.0",
114
114
  "mz": "^2.7.0",
115
115
  "node-abort-controller": "^3.0.1",
116
- "prettier": "^2.8",
117
- "rimraf": "5.0.1",
118
- "rollup": "^3.27.2",
119
- "rollup-plugin-dts": "^6.0.1",
116
+ "prettier": "^3.1",
117
+ "rimraf": "5.0.5",
118
+ "rollup": "^4.7.0",
119
+ "rollup-plugin-dts": "^6.1.0",
120
120
  "rollup-plugin-node-polyfills": "^0.2.1",
121
121
  "semantic-release": "^21.0.7",
122
122
  "sinon": "^15.2.0",
@@ -126,7 +126,7 @@
126
126
  "ts-node": "^10.9.1",
127
127
  "tsconfig": "workspace:*",
128
128
  "tslib": "^2.6.2",
129
- "typedoc": "^0.24.8",
129
+ "typedoc": "^0.25.4",
130
130
  "typescript": "^5.1.6"
131
131
  }
132
132
  }
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
  }
@@ -13,6 +13,12 @@ import type {Blockhash} from '../blockhash';
13
13
  import type {CompiledInstruction} from '../message';
14
14
  import {sign, verify} from '../utils/ed25519';
15
15
 
16
+ /** @internal */
17
+ type MessageSignednessErrors = {
18
+ invalid?: PublicKey[];
19
+ missing?: PublicKey[];
20
+ };
21
+
16
22
  /**
17
23
  * Transaction signature as base-58 encoded string
18
24
  */
@@ -757,32 +763,34 @@ export class Transaction {
757
763
  *
758
764
  * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction
759
765
  */
760
- verifySignatures(requireAllSignatures?: boolean): boolean {
761
- return this._verifySignatures(
766
+ verifySignatures(requireAllSignatures: boolean = true): boolean {
767
+ const signatureErrors = this._getMessageSignednessErrors(
762
768
  this.serializeMessage(),
763
- requireAllSignatures === undefined ? true : requireAllSignatures,
769
+ requireAllSignatures,
764
770
  );
771
+ return !signatureErrors;
765
772
  }
766
773
 
767
774
  /**
768
775
  * @internal
769
776
  */
770
- _verifySignatures(
771
- signData: Uint8Array,
777
+ _getMessageSignednessErrors(
778
+ message: Uint8Array,
772
779
  requireAllSignatures: boolean,
773
- ): boolean {
780
+ ): MessageSignednessErrors | undefined {
781
+ const errors: MessageSignednessErrors = {};
774
782
  for (const {signature, publicKey} of this.signatures) {
775
783
  if (signature === null) {
776
784
  if (requireAllSignatures) {
777
- return false;
785
+ (errors.missing ||= []).push(publicKey);
778
786
  }
779
787
  } else {
780
- if (!verify(signature, signData, publicKey.toBytes())) {
781
- return false;
788
+ if (!verify(signature, message, publicKey.toBytes())) {
789
+ (errors.invalid ||= []).push(publicKey);
782
790
  }
783
791
  }
784
792
  }
785
- return true;
793
+ return errors.invalid || errors.missing ? errors : undefined;
786
794
  }
787
795
 
788
796
  /**
@@ -799,11 +807,25 @@ export class Transaction {
799
807
  );
800
808
 
801
809
  const signData = this.serializeMessage();
802
- if (
803
- verifySignatures &&
804
- !this._verifySignatures(signData, requireAllSignatures)
805
- ) {
806
- throw new Error('Signature verification failed');
810
+ if (verifySignatures) {
811
+ const sigErrors = this._getMessageSignednessErrors(
812
+ signData,
813
+ requireAllSignatures,
814
+ );
815
+ if (sigErrors) {
816
+ let errorMessage = 'Signature verification failed.';
817
+ if (sigErrors.invalid) {
818
+ errorMessage += `\nInvalid signature for public key${
819
+ sigErrors.invalid.length === 1 ? '' : '(s)'
820
+ } [\`${sigErrors.invalid.map(p => p.toBase58()).join('`, `')}\`].`;
821
+ }
822
+ if (sigErrors.missing) {
823
+ errorMessage += `\nMissing signature for public key${
824
+ sigErrors.missing.length === 1 ? '' : '(s)'
825
+ } [\`${sigErrors.missing.map(p => p.toBase58()).join('`, `')}\`].`;
826
+ }
827
+ throw new Error(errorMessage);
828
+ }
807
829
  }
808
830
 
809
831
  return this._serialize(signData);