@solana/web3.js 1.75.0 → 1.76.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/lib/index.esm.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Buffer } from 'buffer';
2
- import { sha512 } from '@noble/hashes/sha512';
3
- import * as ed25519 from '@noble/ed25519';
2
+ import { ed25519 } from '@noble/curves/ed25519';
4
3
  import BN from 'bn.js';
5
4
  import bs58 from 'bs58';
6
5
  import { sha256 } from '@noble/hashes/sha256';
@@ -20,8 +19,7 @@ import * as nodeFetch from 'node-fetch';
20
19
  import RpcWebSocketCommonClient from 'rpc-websockets/dist/lib/client';
21
20
  import WebsocketFactory from 'rpc-websockets/dist/lib/client/websocket';
22
21
  import { keccak_256 } from '@noble/hashes/sha3';
23
- import { hmac } from '@noble/hashes/hmac';
24
- import * as secp256k1 from '@noble/secp256k1';
22
+ import { secp256k1 } from '@noble/curves/secp256k1';
25
23
 
26
24
  /**
27
25
  * A 64 byte secret key, the first 32 bytes of which is the
@@ -29,7 +27,6 @@ import * as secp256k1 from '@noble/secp256k1';
29
27
  * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
30
28
  */
31
29
 
32
- ed25519.utils.sha512Sync = (...m) => sha512(ed25519.utils.concatBytes(...m));
33
30
  const generatePrivateKey = ed25519.utils.randomPrivateKey;
34
31
  const generateKeypair = () => {
35
32
  const privateScalar = ed25519.utils.randomPrivateKey();
@@ -42,17 +39,17 @@ const generateKeypair = () => {
42
39
  secretKey
43
40
  };
44
41
  };
45
- const getPublicKey = ed25519.sync.getPublicKey;
42
+ const getPublicKey = ed25519.getPublicKey;
46
43
  function isOnCurve(publicKey) {
47
44
  try {
48
- ed25519.Point.fromHex(publicKey, true /* strict */);
45
+ ed25519.ExtendedPoint.fromHex(publicKey);
49
46
  return true;
50
47
  } catch {
51
48
  return false;
52
49
  }
53
50
  }
54
- const sign = (message, secretKey) => ed25519.sync.sign(message, secretKey.slice(0, 32));
55
- const verify = ed25519.sync.verify;
51
+ const sign = (message, secretKey) => ed25519.sign(message, secretKey.slice(0, 32));
52
+ const verify = ed25519.verify;
56
53
 
57
54
  const toBuffer = arr => {
58
55
  if (Buffer.isBuffer(arr)) {
@@ -609,8 +606,8 @@ class CompiledKeys {
609
606
  getOrInsertDefault(ix.programId).isInvoked = true;
610
607
  for (const accountMeta of ix.keys) {
611
608
  const keyMeta = getOrInsertDefault(accountMeta.pubkey);
612
- keyMeta.isSigner || (keyMeta.isSigner = accountMeta.isSigner);
613
- keyMeta.isWritable || (keyMeta.isWritable = accountMeta.isWritable);
609
+ keyMeta.isSigner ||= accountMeta.isSigner;
610
+ keyMeta.isWritable ||= accountMeta.isWritable;
614
611
  }
615
612
  }
616
613
  return new CompiledKeys(payer, keyMetaMap);
@@ -9154,12 +9151,11 @@ class Connection {
9154
9151
  * @internal
9155
9152
  */
9156
9153
  _onSubscriptionStateChange(clientSubscriptionId, callback) {
9157
- var _this$_subscriptionSt;
9158
9154
  const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
9159
9155
  if (hash == null) {
9160
9156
  return () => {};
9161
9157
  }
9162
- const stateChangeCallbacks = (_this$_subscriptionSt = this._subscriptionStateChangeCallbacksByHash)[hash] || (_this$_subscriptionSt[hash] = new Set());
9158
+ const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
9163
9159
  stateChangeCallbacks.add(callback);
9164
9160
  return () => {
9165
9161
  stateChangeCallbacks.delete(callback);
@@ -10387,17 +10383,10 @@ class Ed25519Program {
10387
10383
  }
10388
10384
  Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
10389
10385
 
10390
- // Supply a synchronous hashing algorithm to make this
10391
- // library interoperable with the synchronous APIs in web3.js.
10392
- secp256k1.utils.hmacSha256Sync = (key, ...msgs) => {
10393
- const h = hmac.create(sha256, key);
10394
- msgs.forEach(msg => h.update(msg));
10395
- return h.digest();
10386
+ const ecdsaSign = (msgHash, privKey) => {
10387
+ const signature = secp256k1.sign(msgHash, privKey);
10388
+ return [signature.toCompactRawBytes(), signature.recovery];
10396
10389
  };
10397
- const ecdsaSign = (msgHash, privKey) => secp256k1.signSync(msgHash, privKey, {
10398
- der: false,
10399
- recovered: true
10400
- });
10401
10390
  secp256k1.utils.isValidPrivateKey;
10402
10391
  const publicKeyCreate = secp256k1.getPublicKey;
10403
10392