@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.76.0",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"compile:js": "cross-env NODE_ENV=production rollup -c",
|
|
42
42
|
"compile:typedefs": "./scripts/typegen.sh",
|
|
43
43
|
"build:fixtures": "set -ex; ./test/fixtures/noop-program/build.sh",
|
|
44
|
-
"clean": "rimraf ./
|
|
44
|
+
"clean": "rimraf ./doc ./declarations ./lib",
|
|
45
45
|
"dev": "cross-env NODE_ENV=development rollup -c --watch",
|
|
46
46
|
"publish-packages": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
47
47
|
"test:lint": "eslint src/ test/ --ext .js,.ts",
|
|
48
48
|
"test:lint:fix": "eslint src/ test/ --fix --ext .js,.ts",
|
|
49
49
|
"test:live": "TEST_LIVE=1 pnpm run test:unit:node",
|
|
50
|
-
"test:live-with-test-validator": "start-server-and-test '
|
|
50
|
+
"test:live-with-test-validator": "start-server-and-test '../../scripts/start-shared-test-validator.sh' http://127.0.0.1:8899/health test:live",
|
|
51
51
|
"test:prettier": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
|
52
52
|
"test:prettier:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
|
53
53
|
"test:typecheck": "tsc --noEmit",
|
|
@@ -55,16 +55,15 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@babel/runtime": "^7.12.5",
|
|
58
|
-
"@noble/
|
|
59
|
-
"@noble/hashes": "^1.
|
|
60
|
-
"@noble/secp256k1": "^1.6.3",
|
|
58
|
+
"@noble/curves": "^1.0.0",
|
|
59
|
+
"@noble/hashes": "^1.3.0",
|
|
61
60
|
"@solana/buffer-layout": "^4.0.0",
|
|
62
61
|
"agentkeepalive": "^4.2.1",
|
|
63
62
|
"bigint-buffer": "^1.1.5",
|
|
64
63
|
"bn.js": "^5.0.0",
|
|
65
64
|
"borsh": "^0.7.0",
|
|
66
65
|
"bs58": "^4.0.1",
|
|
67
|
-
"buffer": "6.0.
|
|
66
|
+
"buffer": "6.0.3",
|
|
68
67
|
"fast-stable-stringify": "^1.0.0",
|
|
69
68
|
"jayson": "^3.4.4",
|
|
70
69
|
"node-fetch": "^2.6.7",
|
|
@@ -84,6 +83,7 @@
|
|
|
84
83
|
"@rollup/plugin-multi-entry": "^6.0.0",
|
|
85
84
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
86
85
|
"@rollup/plugin-replace": "^5.0.2",
|
|
86
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
87
87
|
"@solana/spl-token": "^0.3.7",
|
|
88
88
|
"@types/bn.js": "^5.1.0",
|
|
89
89
|
"@types/bs58": "^4.0.1",
|
|
@@ -96,12 +96,12 @@
|
|
|
96
96
|
"@types/node-fetch": "2",
|
|
97
97
|
"@types/sinon": "^10.0.0",
|
|
98
98
|
"@types/sinon-chai": "^3.2.8",
|
|
99
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
100
|
-
"@typescript-eslint/parser": "^5.
|
|
99
|
+
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
100
|
+
"@typescript-eslint/parser": "^5.57.1",
|
|
101
101
|
"chai": "^4.3.0",
|
|
102
102
|
"chai-as-promised": "^7.1.1",
|
|
103
103
|
"cross-env": "7.0.3",
|
|
104
|
-
"eslint": "^8.
|
|
104
|
+
"eslint": "^8.37.0",
|
|
105
105
|
"eslint-config-prettier": "^8.5.0",
|
|
106
106
|
"eslint-plugin-import": "^2.26.0",
|
|
107
107
|
"eslint-plugin-mocha": "^10.1.0",
|
|
@@ -113,19 +113,18 @@
|
|
|
113
113
|
"node-abort-controller": "^3.0.1",
|
|
114
114
|
"prettier": "^2.3.0",
|
|
115
115
|
"rimraf": "4.1.2",
|
|
116
|
-
"rollup": "
|
|
117
|
-
"rollup-plugin-dts": "^
|
|
116
|
+
"rollup": "^3.20.2",
|
|
117
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
118
118
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
119
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
120
119
|
"semantic-release": "^19.0.3",
|
|
121
120
|
"sinon": "^15.0.1",
|
|
122
121
|
"sinon-chai": "^3.7.0",
|
|
123
|
-
"start-server-and-test": "^
|
|
122
|
+
"start-server-and-test": "^2.0.0",
|
|
124
123
|
"ts-mocha": "^10.0.0",
|
|
125
124
|
"ts-node": "^10.0.0",
|
|
126
125
|
"tsconfig": "workspace:*",
|
|
127
126
|
"tslib": "^2.1.0",
|
|
128
|
-
"typedoc": "^0.23",
|
|
129
|
-
"typescript": "^
|
|
127
|
+
"typedoc": "^0.23.28",
|
|
128
|
+
"typescript": "^5.0.3"
|
|
130
129
|
}
|
|
131
130
|
}
|
package/src/connection.ts
CHANGED
|
@@ -788,6 +788,34 @@ const GetInflationRewardResult = jsonRpcResult(
|
|
|
788
788
|
),
|
|
789
789
|
);
|
|
790
790
|
|
|
791
|
+
export type RecentPrioritizationFees = {
|
|
792
|
+
/** slot in which the fee was observed */
|
|
793
|
+
slot: number;
|
|
794
|
+
/** the per-compute-unit fee paid by at least one successfully landed transaction, specified in increments of 0.000001 lamports*/
|
|
795
|
+
prioritizationFee: number;
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Configuration object for changing `getRecentPrioritizationFees` query behavior
|
|
800
|
+
*/
|
|
801
|
+
export type GetRecentPrioritizationFeesConfig = {
|
|
802
|
+
/**
|
|
803
|
+
* If this parameter is provided, the response will reflect a fee to land a transaction locking
|
|
804
|
+
* all of the provided accounts as writable.
|
|
805
|
+
*/
|
|
806
|
+
lockedWritableAccounts?: PublicKey[];
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
811
|
+
*/
|
|
812
|
+
const GetRecentPrioritizationFeesResult = array(
|
|
813
|
+
pick({
|
|
814
|
+
slot: number(),
|
|
815
|
+
prioritizationFee: number(),
|
|
816
|
+
}),
|
|
817
|
+
);
|
|
818
|
+
|
|
791
819
|
export type InflationRate = {
|
|
792
820
|
/** total inflation */
|
|
793
821
|
total: number;
|
|
@@ -1662,6 +1690,13 @@ const GetInflationGovernorRpcResult = jsonRpcResult(GetInflationGovernorResult);
|
|
|
1662
1690
|
*/
|
|
1663
1691
|
const GetInflationRateRpcResult = jsonRpcResult(GetInflationRateResult);
|
|
1664
1692
|
|
|
1693
|
+
/**
|
|
1694
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
1695
|
+
*/
|
|
1696
|
+
const GetRecentPrioritizationFeesRpcResult = jsonRpcResult(
|
|
1697
|
+
GetRecentPrioritizationFeesResult,
|
|
1698
|
+
);
|
|
1699
|
+
|
|
1665
1700
|
/**
|
|
1666
1701
|
* Expected JSON RPC response for the "getEpochInfo" message
|
|
1667
1702
|
*/
|
|
@@ -4468,6 +4503,27 @@ export class Connection {
|
|
|
4468
4503
|
return res.result;
|
|
4469
4504
|
}
|
|
4470
4505
|
|
|
4506
|
+
/**
|
|
4507
|
+
* Fetch a list of prioritization fees from recent blocks.
|
|
4508
|
+
*/
|
|
4509
|
+
async getRecentPrioritizationFees(
|
|
4510
|
+
config?: GetRecentPrioritizationFeesConfig,
|
|
4511
|
+
): Promise<RecentPrioritizationFees[]> {
|
|
4512
|
+
const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());
|
|
4513
|
+
const args = this._buildArgs(accounts?.length ? [accounts] : []);
|
|
4514
|
+
const unsafeRes = await this._rpcRequest(
|
|
4515
|
+
'getRecentPrioritizationFees',
|
|
4516
|
+
args,
|
|
4517
|
+
);
|
|
4518
|
+
const res = create(unsafeRes, GetRecentPrioritizationFeesRpcResult);
|
|
4519
|
+
if ('error' in res) {
|
|
4520
|
+
throw new SolanaJSONRPCError(
|
|
4521
|
+
res.error,
|
|
4522
|
+
'failed to get recent prioritization fees',
|
|
4523
|
+
);
|
|
4524
|
+
}
|
|
4525
|
+
return res.result;
|
|
4526
|
+
}
|
|
4471
4527
|
/**
|
|
4472
4528
|
* Fetch a recent blockhash from the cluster
|
|
4473
4529
|
* @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
|
package/src/utils/ed25519.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as ed25519 from '@noble/ed25519';
|
|
1
|
+
import {ed25519} from '@noble/curves/ed25519';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* A 64 byte secret key, the first 32 bytes of which is the
|
|
@@ -16,8 +15,6 @@ export interface Ed25519Keypair {
|
|
|
16
15
|
secretKey: Ed25519SecretKey;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
ed25519.utils.sha512Sync = (...m) => sha512(ed25519.utils.concatBytes(...m));
|
|
20
|
-
|
|
21
18
|
export const generatePrivateKey = ed25519.utils.randomPrivateKey;
|
|
22
19
|
export const generateKeypair = (): Ed25519Keypair => {
|
|
23
20
|
const privateScalar = ed25519.utils.randomPrivateKey();
|
|
@@ -30,17 +27,17 @@ export const generateKeypair = (): Ed25519Keypair => {
|
|
|
30
27
|
secretKey,
|
|
31
28
|
};
|
|
32
29
|
};
|
|
33
|
-
export const getPublicKey = ed25519.
|
|
30
|
+
export const getPublicKey = ed25519.getPublicKey;
|
|
34
31
|
export function isOnCurve(publicKey: Uint8Array): boolean {
|
|
35
32
|
try {
|
|
36
|
-
ed25519.
|
|
33
|
+
ed25519.ExtendedPoint.fromHex(publicKey);
|
|
37
34
|
return true;
|
|
38
35
|
} catch {
|
|
39
36
|
return false;
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
export const sign = (
|
|
43
|
-
message: Parameters<typeof ed25519.
|
|
40
|
+
message: Parameters<typeof ed25519.sign>[0],
|
|
44
41
|
secretKey: Ed25519SecretKey,
|
|
45
|
-
) => ed25519.
|
|
46
|
-
export const verify = ed25519.
|
|
42
|
+
) => ed25519.sign(message, secretKey.slice(0, 32));
|
|
43
|
+
export const verify = ed25519.verify;
|
package/src/utils/secp256k1.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {sha256} from '@noble/hashes/sha256';
|
|
3
|
-
import * as secp256k1 from '@noble/secp256k1';
|
|
4
|
-
|
|
5
|
-
// Supply a synchronous hashing algorithm to make this
|
|
6
|
-
// library interoperable with the synchronous APIs in web3.js.
|
|
7
|
-
secp256k1.utils.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {
|
|
8
|
-
const h = hmac.create(sha256, key);
|
|
9
|
-
msgs.forEach(msg => h.update(msg));
|
|
10
|
-
return h.digest();
|
|
11
|
-
};
|
|
1
|
+
import {secp256k1} from '@noble/curves/secp256k1';
|
|
12
2
|
|
|
13
3
|
export const ecdsaSign = (
|
|
14
|
-
msgHash: Parameters<typeof secp256k1.
|
|
15
|
-
privKey: Parameters<typeof secp256k1.
|
|
16
|
-
) =>
|
|
4
|
+
msgHash: Parameters<typeof secp256k1.sign>[0],
|
|
5
|
+
privKey: Parameters<typeof secp256k1.sign>[1],
|
|
6
|
+
) => {
|
|
7
|
+
const signature = secp256k1.sign(msgHash, privKey);
|
|
8
|
+
return [signature.toCompactRawBytes(), signature.recovery!] as const;
|
|
9
|
+
};
|
|
17
10
|
export const isValidPrivateKey = secp256k1.utils.isValidPrivateKey;
|
|
18
11
|
export const publicKeyCreate = secp256k1.getPublicKey;
|