@solana/web3.js 1.74.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 +72 -62
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +37 -23
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +86 -76
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +20 -0
- package/lib/index.esm.js +37 -23
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +3132 -1754
- 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 +72 -62
- package/lib/index.native.js.map +1 -1
- package/package.json +15 -16
- package/src/connection.ts +56 -0
- package/src/utils/ed25519.ts +6 -9
- package/src/utils/secp256k1.ts +7 -14
package/lib/index.browser.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';
|
|
@@ -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 {
|
|
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.
|
|
35
|
+
const getPublicKey = ed25519.getPublicKey;
|
|
39
36
|
function isOnCurve(publicKey) {
|
|
40
37
|
try {
|
|
41
|
-
ed25519.
|
|
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.
|
|
48
|
-
const verify = ed25519.
|
|
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
|
|
606
|
-
keyMeta.isWritable
|
|
602
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
603
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
607
604
|
}
|
|
608
605
|
}
|
|
609
606
|
return new CompiledKeys(payer, keyMetaMap);
|
|
@@ -3504,6 +3501,13 @@ const GetInflationRewardResult = jsonRpcResult(array(nullable(type({
|
|
|
3504
3501
|
postBalance: number(),
|
|
3505
3502
|
commission: optional(nullable(number()))
|
|
3506
3503
|
}))));
|
|
3504
|
+
/**
|
|
3505
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
3506
|
+
*/
|
|
3507
|
+
const GetRecentPrioritizationFeesResult = array(type({
|
|
3508
|
+
slot: number(),
|
|
3509
|
+
prioritizationFee: number()
|
|
3510
|
+
}));
|
|
3507
3511
|
/**
|
|
3508
3512
|
* Expected JSON RPC response for the "getInflationRate" message
|
|
3509
3513
|
*/
|
|
@@ -3705,6 +3709,11 @@ const GetInflationGovernorRpcResult = jsonRpcResult(GetInflationGovernorResult);
|
|
|
3705
3709
|
*/
|
|
3706
3710
|
const GetInflationRateRpcResult = jsonRpcResult(GetInflationRateResult);
|
|
3707
3711
|
|
|
3712
|
+
/**
|
|
3713
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
3714
|
+
*/
|
|
3715
|
+
const GetRecentPrioritizationFeesRpcResult = jsonRpcResult(GetRecentPrioritizationFeesResult);
|
|
3716
|
+
|
|
3708
3717
|
/**
|
|
3709
3718
|
* Expected JSON RPC response for the "getEpochInfo" message
|
|
3710
3719
|
*/
|
|
@@ -5602,6 +5611,19 @@ class Connection {
|
|
|
5602
5611
|
return res.result;
|
|
5603
5612
|
}
|
|
5604
5613
|
|
|
5614
|
+
/**
|
|
5615
|
+
* Fetch a list of prioritization fees from recent blocks.
|
|
5616
|
+
*/
|
|
5617
|
+
async getRecentPrioritizationFees(config) {
|
|
5618
|
+
const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());
|
|
5619
|
+
const args = this._buildArgs(accounts?.length ? [accounts] : []);
|
|
5620
|
+
const unsafeRes = await this._rpcRequest('getRecentPrioritizationFees', args);
|
|
5621
|
+
const res = create(unsafeRes, GetRecentPrioritizationFeesRpcResult);
|
|
5622
|
+
if ('error' in res) {
|
|
5623
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent prioritization fees');
|
|
5624
|
+
}
|
|
5625
|
+
return res.result;
|
|
5626
|
+
}
|
|
5605
5627
|
/**
|
|
5606
5628
|
* Fetch a recent blockhash from the cluster
|
|
5607
5629
|
* @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
|
|
@@ -6612,12 +6634,11 @@ class Connection {
|
|
|
6612
6634
|
* @internal
|
|
6613
6635
|
*/
|
|
6614
6636
|
_onSubscriptionStateChange(clientSubscriptionId, callback) {
|
|
6615
|
-
var _this$_subscriptionSt;
|
|
6616
6637
|
const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];
|
|
6617
6638
|
if (hash == null) {
|
|
6618
6639
|
return () => {};
|
|
6619
6640
|
}
|
|
6620
|
-
const stateChangeCallbacks =
|
|
6641
|
+
const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();
|
|
6621
6642
|
stateChangeCallbacks.add(callback);
|
|
6622
6643
|
return () => {
|
|
6623
6644
|
stateChangeCallbacks.delete(callback);
|
|
@@ -7845,17 +7866,10 @@ class Ed25519Program {
|
|
|
7845
7866
|
}
|
|
7846
7867
|
Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
|
|
7847
7868
|
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
const h = hmac.create(sha256, key);
|
|
7852
|
-
msgs.forEach(msg => h.update(msg));
|
|
7853
|
-
return h.digest();
|
|
7869
|
+
const ecdsaSign = (msgHash, privKey) => {
|
|
7870
|
+
const signature = secp256k1.sign(msgHash, privKey);
|
|
7871
|
+
return [signature.toCompactRawBytes(), signature.recovery];
|
|
7854
7872
|
};
|
|
7855
|
-
const ecdsaSign = (msgHash, privKey) => secp256k1.signSync(msgHash, privKey, {
|
|
7856
|
-
der: false,
|
|
7857
|
-
recovered: true
|
|
7858
|
-
});
|
|
7859
7873
|
secp256k1.utils.isValidPrivateKey;
|
|
7860
7874
|
const publicKeyCreate = secp256k1.getPublicKey;
|
|
7861
7875
|
|