@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.
@@ -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';
@@ -13,8 +12,7 @@ import RpcClient from 'jayson/lib/client/browser';
13
12
  import RpcWebSocketCommonClient from 'rpc-websockets/dist/lib/client';
14
13
  import createRpc from 'rpc-websockets/dist/lib/client/websocket.browser';
15
14
  import { keccak_256 } from '@noble/hashes/sha3';
16
- import { hmac } from '@noble/hashes/hmac';
17
- import * as secp256k1 from '@noble/secp256k1';
15
+ import { secp256k1 } from '@noble/curves/secp256k1';
18
16
 
19
17
  /**
20
18
  * A 64 byte secret key, the first 32 bytes of which is the
@@ -22,7 +20,6 @@ import * as secp256k1 from '@noble/secp256k1';
22
20
  * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
23
21
  */
24
22
 
25
- ed25519.utils.sha512Sync = (...m) => sha512(ed25519.utils.concatBytes(...m));
26
23
  const generatePrivateKey = ed25519.utils.randomPrivateKey;
27
24
  const generateKeypair = () => {
28
25
  const privateScalar = ed25519.utils.randomPrivateKey();
@@ -35,17 +32,17 @@ const generateKeypair = () => {
35
32
  secretKey
36
33
  };
37
34
  };
38
- const getPublicKey = ed25519.sync.getPublicKey;
35
+ const getPublicKey = ed25519.getPublicKey;
39
36
  function isOnCurve(publicKey) {
40
37
  try {
41
- ed25519.Point.fromHex(publicKey, true /* strict */);
38
+ ed25519.ExtendedPoint.fromHex(publicKey);
42
39
  return true;
43
40
  } catch {
44
41
  return false;
45
42
  }
46
43
  }
47
- const sign = (message, secretKey) => ed25519.sync.sign(message, secretKey.slice(0, 32));
48
- const verify = ed25519.sync.verify;
44
+ const sign = (message, secretKey) => ed25519.sign(message, secretKey.slice(0, 32));
45
+ const verify = ed25519.verify;
49
46
 
50
47
  const toBuffer = arr => {
51
48
  if (Buffer.isBuffer(arr)) {
@@ -602,8 +599,8 @@ class CompiledKeys {
602
599
  getOrInsertDefault(ix.programId).isInvoked = true;
603
600
  for (const accountMeta of ix.keys) {
604
601
  const keyMeta = getOrInsertDefault(accountMeta.pubkey);
605
- keyMeta.isSigner || (keyMeta.isSigner = accountMeta.isSigner);
606
- keyMeta.isWritable || (keyMeta.isWritable = accountMeta.isWritable);
602
+ keyMeta.isSigner ||= accountMeta.isSigner;
603
+ keyMeta.isWritable ||= accountMeta.isWritable;
607
604
  }
608
605
  }
609
606
  return new CompiledKeys(payer, keyMetaMap);
@@ -6637,12 +6634,11 @@ class Connection {
6637
6634
  * @internal
6638
6635
  */
6639
6636
  _onSubscriptionStateChange(clientSubscriptionId, callback) {
6640
- var _this$_subscriptionSt;
6641
6637
  const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
6642
6638
  if (hash == null) {
6643
6639
  return () => {};
6644
6640
  }
6645
- const stateChangeCallbacks = (_this$_subscriptionSt = this._subscriptionStateChangeCallbacksByHash)[hash] || (_this$_subscriptionSt[hash] = new Set());
6641
+ const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
6646
6642
  stateChangeCallbacks.add(callback);
6647
6643
  return () => {
6648
6644
  stateChangeCallbacks.delete(callback);
@@ -7870,17 +7866,10 @@ class Ed25519Program {
7870
7866
  }
7871
7867
  Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7872
7868
 
7873
- // Supply a synchronous hashing algorithm to make this
7874
- // library interoperable with the synchronous APIs in web3.js.
7875
- secp256k1.utils.hmacSha256Sync = (key, ...msgs) => {
7876
- const h = hmac.create(sha256, key);
7877
- msgs.forEach(msg => h.update(msg));
7878
- return h.digest();
7869
+ const ecdsaSign = (msgHash, privKey) => {
7870
+ const signature = secp256k1.sign(msgHash, privKey);
7871
+ return [signature.toCompactRawBytes(), signature.recovery];
7879
7872
  };
7880
- const ecdsaSign = (msgHash, privKey) => secp256k1.signSync(msgHash, privKey, {
7881
- der: false,
7882
- recovered: true
7883
- });
7884
7873
  secp256k1.utils.isValidPrivateKey;
7885
7874
  const publicKeyCreate = secp256k1.getPublicKey;
7886
7875