@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.browser.cjs.js +47 -62
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +12 -23
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +61 -76
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +12 -23
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +3106 -1753
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +12 -5
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +47 -62
- package/lib/index.native.js.map +1 -1
- package/package.json +12 -13
- package/src/utils/ed25519.ts +6 -9
- package/src/utils/secp256k1.ts +7 -14
package/lib/index.esm.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
|
-
import {
|
|
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 {
|
|
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.
|
|
42
|
+
const getPublicKey = ed25519.getPublicKey;
|
|
46
43
|
function isOnCurve(publicKey) {
|
|
47
44
|
try {
|
|
48
|
-
ed25519.
|
|
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.
|
|
55
|
-
const verify = ed25519.
|
|
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
|
|
613
|
-
keyMeta.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 =
|
|
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
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
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
|
|