@solana/web3.js 1.12.1 → 1.13.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/module.flow.js CHANGED
@@ -172,10 +172,25 @@ declare module "@solana/web3.js" {
172
172
  secretKey: Uint8Array;
173
173
  }
174
174
 
175
+ /**
176
+ * Ed25519 Keypair
177
+ */
178
+ declare interface Ed25519Keypair {
179
+ publicKey: Uint8Array;
180
+ secretKey: Uint8Array;
181
+ }
182
+
175
183
  /**
176
184
  * An account keypair used for signing transactions.
177
185
  */
178
186
  declare export class Keypair {
187
+ /**
188
+ * Create a new keypair instance.
189
+ * Generate random keypair if no {@link Ed25519Keypair} is provided.
190
+ * @param keypair ed25519 keypair
191
+ */
192
+ constructor(keypair?: Ed25519Keypair): this;
193
+
179
194
  /**
180
195
  * Generate a new random keypair
181
196
  */
@@ -2151,9 +2166,7 @@ blockhash: Blockhash,
2151
2166
  feeCalculator: FeeCalculator,...
2152
2167
  }>>}
2153
2168
  */
2154
- getRecentBlockhashAndContext(
2155
- commitment?: Commitment
2156
- ): Promise<
2169
+ getRecentBlockhashAndContext(commitment?: Commitment): Promise<
2157
2170
  RpcResponseAndContext<{
2158
2171
  blockhash: Blockhash,
2159
2172
  feeCalculator: FeeCalculator,
@@ -2182,9 +2195,7 @@ blockhash: Blockhash,
2182
2195
  feeCalculator: FeeCalculator,...
2183
2196
  }>}
2184
2197
  */
2185
- getRecentBlockhash(
2186
- commitment?: Commitment
2187
- ): Promise<{
2198
+ getRecentBlockhash(commitment?: Commitment): Promise<{
2188
2199
  blockhash: Blockhash,
2189
2200
  feeCalculator: FeeCalculator,
2190
2201
  ...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.12.1",
3
+ "version": "1.13.1",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -87,7 +87,7 @@
87
87
  "cross-env": "7.0.3",
88
88
  "eslint": "^7.19.0",
89
89
  "eslint-config-prettier": "^8.0.0",
90
- "eslint-plugin-import": "2.22.1",
90
+ "eslint-plugin-import": "2.23.3",
91
91
  "eslint-plugin-mocha": "^8.0.0",
92
92
  "eslint-plugin-prettier": "^3.0.0",
93
93
  "esm": "^3.2.25",
@@ -100,16 +100,16 @@
100
100
  "mz": "^2.7.0",
101
101
  "npm-run-all": "^4.1.5",
102
102
  "nyc": "^15.1.0",
103
- "prettier": "^2.0.0",
103
+ "prettier": "^2.3.0",
104
104
  "rimraf": "3.0.2",
105
- "rollup": "2.47.0",
105
+ "rollup": "2.49.0",
106
106
  "rollup-plugin-dts": "^3.0.1",
107
107
  "rollup-plugin-node-polyfills": "^0.2.1",
108
108
  "rollup-plugin-terser": "^7.0.2",
109
109
  "semantic-release": "^17.0.2",
110
- "sinon": "^10.0.0",
110
+ "sinon": "^11.0.0",
111
111
  "start-server-and-test": "^1.12.0",
112
- "ts-node": "^9.1.1",
112
+ "ts-node": "^10.0.0",
113
113
  "tslib": "^2.1.0",
114
114
  "typedoc": "^0.20.31",
115
115
  "typescript": "^4.1.5"
package/src/connection.ts CHANGED
@@ -3020,9 +3020,8 @@ export class Connection {
3020
3020
  'finalized',
3021
3021
  );
3022
3022
  if (block.signatures.length > 0) {
3023
- options.until = block.signatures[
3024
- block.signatures.length - 1
3025
- ].toString();
3023
+ options.until =
3024
+ block.signatures[block.signatures.length - 1].toString();
3026
3025
  }
3027
3026
  } catch (err) {
3028
3027
  if (err.message.includes('skipped')) {
@@ -3043,9 +3042,8 @@ export class Connection {
3043
3042
  try {
3044
3043
  const block = await this.getConfirmedBlockSignatures(endSlot);
3045
3044
  if (block.signatures.length > 0) {
3046
- options.before = block.signatures[
3047
- block.signatures.length - 1
3048
- ].toString();
3045
+ options.before =
3046
+ block.signatures[block.signatures.length - 1].toString();
3049
3047
  }
3050
3048
  } catch (err) {
3051
3049
  if (err.message.includes('skipped')) {
package/src/keypair.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as nacl from 'tweetnacl';
2
- import type {SignKeyPair} from 'tweetnacl';
3
2
 
4
3
  import {PublicKey} from './publickey';
5
4
 
@@ -11,18 +10,33 @@ export interface Signer {
11
10
  secretKey: Uint8Array;
12
11
  }
13
12
 
13
+ /**
14
+ * Ed25519 Keypair
15
+ */
16
+ export interface Ed25519Keypair {
17
+ publicKey: Uint8Array;
18
+ secretKey: Uint8Array;
19
+ }
20
+
14
21
  /**
15
22
  * An account keypair used for signing transactions.
16
23
  */
17
24
  export class Keypair {
25
+ private _keypair: Ed25519Keypair;
26
+
18
27
  /**
19
- * @internal
20
- *
21
- * Create a new keypair instance from a {@link SignKeyPair}.
28
+ * Create a new keypair instance.
29
+ * Generate random keypair if no {@link Ed25519Keypair} is provided.
22
30
  *
23
31
  * @param keypair ed25519 keypair
24
32
  */
25
- constructor(private keypair: SignKeyPair) {}
33
+ constructor(keypair?: Ed25519Keypair) {
34
+ if (keypair) {
35
+ this._keypair = keypair;
36
+ } else {
37
+ this._keypair = nacl.sign.keyPair();
38
+ }
39
+ }
26
40
 
27
41
  /**
28
42
  * Generate a new random keypair
@@ -72,13 +86,13 @@ export class Keypair {
72
86
  * The public key for this keypair
73
87
  */
74
88
  get publicKey(): PublicKey {
75
- return new PublicKey(this.keypair.publicKey);
89
+ return new PublicKey(this._keypair.publicKey);
76
90
  }
77
91
 
78
92
  /**
79
93
  * The raw secret key for this keypair
80
94
  */
81
95
  get secretKey(): Uint8Array {
82
- return this.keypair.secretKey;
96
+ return this._keypair.secretKey;
83
97
  }
84
98
  }
package/src/publickey.ts CHANGED
@@ -247,22 +247,8 @@ function is_on_curve(p: any) {
247
247
  }
248
248
  let gf1 = naclLowLevel.gf([1]);
249
249
  let I = naclLowLevel.gf([
250
- 0xa0b0,
251
- 0x4a0e,
252
- 0x1b27,
253
- 0xc4ee,
254
- 0xe478,
255
- 0xad2f,
256
- 0x1806,
257
- 0x2f43,
258
- 0xd7a7,
259
- 0x3dfb,
260
- 0x0099,
261
- 0x2b4d,
262
- 0xdf0b,
263
- 0x4fc1,
264
- 0x2480,
265
- 0x2b83,
250
+ 0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7,
251
+ 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83,
266
252
  ]);
267
253
  function neq25519(a: any, b: any) {
268
254
  var c = new Uint8Array(32),
@@ -710,13 +710,8 @@ export class StakeProgram {
710
710
  * Generate a Transaction that withdraws deactivated Stake tokens.
711
711
  */
712
712
  static withdraw(params: WithdrawStakeParams): Transaction {
713
- const {
714
- stakePubkey,
715
- authorizedPubkey,
716
- toPubkey,
717
- lamports,
718
- custodianPubkey,
719
- } = params;
713
+ const {stakePubkey, authorizedPubkey, toPubkey, lamports, custodianPubkey} =
714
+ params;
720
715
  const type = STAKE_INSTRUCTION_LAYOUTS.Withdraw;
721
716
  const data = encodeData(type, {lamports});
722
717