@solana/web3.js 0.0.0-next → 0.0.0-pr-29130
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/README.md +24 -25
- package/lib/index.browser.cjs.js +4583 -4238
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +4565 -4238
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +7072 -3604
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +3516 -2420
- package/lib/index.esm.js +7046 -3601
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +22171 -27053
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +8 -33
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +10407 -0
- package/lib/index.native.js.map +1 -0
- package/package.json +36 -36
- package/src/__forks__/browser/fetch-impl.ts +4 -0
- package/src/__forks__/react-native/fetch-impl.ts +4 -0
- package/src/account-data.ts +39 -0
- package/src/account.ts +20 -11
- package/src/bpf-loader.ts +2 -2
- package/src/connection.ts +2303 -635
- package/src/epoch-schedule.ts +1 -1
- package/src/errors.ts +41 -0
- package/src/fee-calculator.ts +2 -0
- package/src/fetch-impl.ts +13 -0
- package/src/index.ts +3 -10
- package/src/keypair.ts +20 -25
- package/src/layout.ts +45 -4
- package/src/loader.ts +3 -3
- package/src/message/account-keys.ts +79 -0
- package/src/message/compiled-keys.ts +165 -0
- package/src/message/index.ts +47 -0
- package/src/{message.ts → message/legacy.ts} +95 -40
- package/src/message/v0.ts +496 -0
- package/src/message/versioned.ts +36 -0
- package/src/nonce-account.ts +8 -4
- package/src/programs/address-lookup-table/index.ts +435 -0
- package/src/programs/address-lookup-table/state.ts +84 -0
- package/src/programs/compute-budget.ts +281 -0
- package/src/{ed25519-program.ts → programs/ed25519.ts} +6 -6
- package/src/programs/index.ts +7 -0
- package/src/{secp256k1-program.ts → programs/secp256k1.ts} +15 -16
- package/src/{stake-program.ts → programs/stake.ts} +7 -7
- package/src/{system-program.ts → programs/system.ts} +55 -18
- package/src/{vote-program.ts → programs/vote.ts} +137 -9
- package/src/publickey.ts +37 -79
- package/src/transaction/constants.ts +12 -0
- package/src/transaction/expiry-custom-errors.ts +48 -0
- package/src/transaction/index.ts +5 -0
- package/src/{transaction.ts → transaction/legacy.ts} +162 -67
- package/src/transaction/message.ts +140 -0
- package/src/transaction/versioned.ts +126 -0
- package/src/{util → utils}/assert.ts +0 -0
- package/src/utils/bigint.ts +43 -0
- package/src/{util → utils}/borsh-schema.ts +0 -0
- package/src/{util → utils}/cluster.ts +0 -0
- package/src/utils/ed25519.ts +46 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/makeWebsocketUrl.ts +26 -0
- package/src/{util → utils}/promise-timeout.ts +0 -0
- package/src/utils/secp256k1.ts +18 -0
- package/src/utils/send-and-confirm-raw-transaction.ts +105 -0
- package/src/utils/send-and-confirm-transaction.ts +98 -0
- package/src/{util → utils}/shortvec-encoding.ts +0 -0
- package/src/{util → utils}/sleep.ts +0 -0
- package/src/{util → utils}/to-buffer.ts +0 -0
- package/src/validator-info.ts +4 -6
- package/src/vote-account.ts +1 -1
- package/src/agent-manager.ts +0 -44
- package/src/util/send-and-confirm-raw-transaction.ts +0 -46
- package/src/util/send-and-confirm-transaction.ts +0 -50
- package/src/util/url.ts +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-pr-29130",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"./lib/index.cjs.js": "./lib/index.browser.cjs.js",
|
|
24
24
|
"./lib/index.esm.js": "./lib/index.browser.esm.js"
|
|
25
25
|
},
|
|
26
|
+
"react-native": "lib/index.native.js",
|
|
26
27
|
"main": "lib/index.cjs.js",
|
|
27
28
|
"module": "lib/index.esm.js",
|
|
28
29
|
"types": "lib/index.d.ts",
|
|
@@ -50,28 +51,28 @@
|
|
|
50
51
|
"pretty": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
|
|
51
52
|
"pretty:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
|
|
52
53
|
"re": "semantic-release --repository-url git@github.com:solana-labs/solana-web3.js.git",
|
|
53
|
-
"test": "
|
|
54
|
-
"test:cover": "
|
|
54
|
+
"test": "cross-env NODE_ENV=test TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha --require esm './test/**/*.test.ts'",
|
|
55
|
+
"test:cover": "nyc --reporter=lcov npm run test",
|
|
55
56
|
"test:live": "TEST_LIVE=1 npm run test",
|
|
56
57
|
"test:live-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health test:live"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"@babel/runtime": "^7.12.5",
|
|
60
|
-
"@
|
|
61
|
+
"@noble/ed25519": "^1.7.0",
|
|
62
|
+
"@noble/hashes": "^1.1.2",
|
|
63
|
+
"@noble/secp256k1": "^1.6.3",
|
|
61
64
|
"@solana/buffer-layout": "^4.0.0",
|
|
65
|
+
"agentkeepalive": "^4.2.1",
|
|
66
|
+
"bigint-buffer": "^1.1.5",
|
|
62
67
|
"bn.js": "^5.0.0",
|
|
63
68
|
"borsh": "^0.7.0",
|
|
64
69
|
"bs58": "^4.0.1",
|
|
65
70
|
"buffer": "6.0.1",
|
|
66
|
-
"cross-fetch": "^3.1.4",
|
|
67
71
|
"fast-stable-stringify": "^1.0.0",
|
|
68
72
|
"jayson": "^3.4.4",
|
|
69
|
-
"
|
|
70
|
-
"rpc-websockets": "^7.
|
|
71
|
-
"
|
|
72
|
-
"sinon-chai": "^3.7.0",
|
|
73
|
-
"superstruct": "^0.14.2",
|
|
74
|
-
"tweetnacl": "^1.0.0"
|
|
73
|
+
"node-fetch": "2",
|
|
74
|
+
"rpc-websockets": "^7.5.0",
|
|
75
|
+
"superstruct": "^0.14.2"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
78
|
"@babel/core": "^7.12.13",
|
|
@@ -79,60 +80,59 @@
|
|
|
79
80
|
"@babel/plugin-transform-runtime": "^7.12.10",
|
|
80
81
|
"@babel/preset-env": "^7.12.11",
|
|
81
82
|
"@babel/preset-typescript": "^7.12.16",
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
84
|
-
"@commitlint/travis-cli": "^16.2.3",
|
|
85
|
-
"@rollup/plugin-alias": "^3.1.2",
|
|
83
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
84
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
86
85
|
"@rollup/plugin-babel": "^5.2.3",
|
|
87
|
-
"@rollup/plugin-commonjs": "^
|
|
86
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
88
87
|
"@rollup/plugin-json": "^4.1.0",
|
|
89
88
|
"@rollup/plugin-multi-entry": "^4.0.0",
|
|
90
89
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
91
|
-
"@rollup/plugin-replace": "^
|
|
92
|
-
"@solana/spl-token": "^0.
|
|
90
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
91
|
+
"@solana/spl-token": "^0.2.0",
|
|
93
92
|
"@types/bn.js": "^5.1.0",
|
|
94
93
|
"@types/bs58": "^4.0.1",
|
|
95
94
|
"@types/chai": "^4.2.15",
|
|
96
95
|
"@types/chai-as-promised": "^7.1.3",
|
|
97
96
|
"@types/express-serve-static-core": "^4.17.21",
|
|
98
|
-
"@types/mocha": "^
|
|
97
|
+
"@types/mocha": "^10.0.0",
|
|
99
98
|
"@types/mz": "^2.7.3",
|
|
100
|
-
"@types/node": "^
|
|
101
|
-
"@types/
|
|
99
|
+
"@types/node": "^18.11.10",
|
|
100
|
+
"@types/node-fetch": "2",
|
|
102
101
|
"@types/sinon": "^10.0.0",
|
|
103
102
|
"@types/sinon-chai": "^3.2.8",
|
|
104
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
105
|
-
"@typescript-eslint/parser": "^
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
104
|
+
"@typescript-eslint/parser": "^5.40.1",
|
|
106
105
|
"chai": "^4.3.0",
|
|
107
106
|
"chai-as-promised": "^7.1.1",
|
|
108
107
|
"codecov": "^3.0.4",
|
|
109
108
|
"cross-env": "7.0.3",
|
|
110
|
-
"eslint": "^
|
|
111
|
-
"eslint-config-prettier": "^8.
|
|
112
|
-
"eslint-plugin-import": "2.
|
|
113
|
-
"eslint-plugin-mocha": "^
|
|
114
|
-
"eslint-plugin-prettier": "^4.
|
|
109
|
+
"eslint": "^8.25.0",
|
|
110
|
+
"eslint-config-prettier": "^8.5.0",
|
|
111
|
+
"eslint-plugin-import": "^2.26.0",
|
|
112
|
+
"eslint-plugin-mocha": "^10.1.0",
|
|
113
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
115
114
|
"esm": "^3.2.25",
|
|
116
|
-
"
|
|
117
|
-
"mocha": "^8.2.1",
|
|
115
|
+
"mocha": "^10.1.0",
|
|
118
116
|
"mockttp": "^2.0.1",
|
|
119
117
|
"mz": "^2.7.0",
|
|
118
|
+
"node-abort-controller": "^3.0.1",
|
|
120
119
|
"npm-run-all": "^4.1.5",
|
|
121
120
|
"nyc": "^15.1.0",
|
|
122
121
|
"prettier": "^2.3.0",
|
|
123
|
-
"puppeteer": "^12.0.0",
|
|
124
122
|
"rimraf": "3.0.2",
|
|
125
|
-
"rollup": "2.
|
|
123
|
+
"rollup": "2.70.2",
|
|
126
124
|
"rollup-plugin-dts": "^4.0.0",
|
|
127
125
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
128
126
|
"rollup-plugin-terser": "^7.0.2",
|
|
129
|
-
"semantic-release": "^
|
|
130
|
-
"sinon": "^
|
|
127
|
+
"semantic-release": "^19.0.3",
|
|
128
|
+
"sinon": "^13.0.2",
|
|
129
|
+
"sinon-chai": "^3.7.0",
|
|
131
130
|
"start-server-and-test": "^1.12.0",
|
|
131
|
+
"ts-mocha": "^10.0.0",
|
|
132
132
|
"ts-node": "^10.0.0",
|
|
133
133
|
"tslib": "^2.1.0",
|
|
134
|
-
"typedoc": "^0.
|
|
135
|
-
"typescript": "^4.
|
|
134
|
+
"typedoc": "^0.23",
|
|
135
|
+
"typescript": "^4.9"
|
|
136
136
|
},
|
|
137
137
|
"engines": {
|
|
138
138
|
"node": ">=12.20.0"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as BufferLayout from '@solana/buffer-layout';
|
|
2
|
+
|
|
3
|
+
export interface IAccountStateData {
|
|
4
|
+
readonly typeIndex: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export type AccountType<TInputData extends IAccountStateData> = {
|
|
11
|
+
/** The account type index (from solana upstream program) */
|
|
12
|
+
index: number;
|
|
13
|
+
/** The BufferLayout to use to build data */
|
|
14
|
+
layout: BufferLayout.Layout<TInputData>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Decode account data buffer using an AccountType
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function decodeData<TAccountStateData extends IAccountStateData>(
|
|
22
|
+
type: AccountType<TAccountStateData>,
|
|
23
|
+
data: Uint8Array,
|
|
24
|
+
): TAccountStateData {
|
|
25
|
+
let decoded: TAccountStateData;
|
|
26
|
+
try {
|
|
27
|
+
decoded = type.layout.decode(data);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
throw new Error('invalid instruction; ' + err);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (decoded.typeIndex !== type.index) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`invalid account data; account type mismatch ${decoded.typeIndex} != ${type.index}`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return decoded;
|
|
39
|
+
}
|
package/src/account.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {SignKeyPair as KeyPair} from 'tweetnacl';
|
|
3
|
-
import type {Buffer} from 'buffer';
|
|
1
|
+
import {Buffer} from 'buffer';
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import {generatePrivateKey, getPublicKey} from './utils/ed25519';
|
|
4
|
+
import {toBuffer} from './utils/to-buffer';
|
|
6
5
|
import {PublicKey} from './publickey';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -12,7 +11,9 @@ import {PublicKey} from './publickey';
|
|
|
12
11
|
*/
|
|
13
12
|
export class Account {
|
|
14
13
|
/** @internal */
|
|
15
|
-
|
|
14
|
+
private _publicKey: Buffer;
|
|
15
|
+
/** @internal */
|
|
16
|
+
private _secretKey: Buffer;
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Create a new Account object
|
|
@@ -22,11 +23,17 @@ export class Account {
|
|
|
22
23
|
*
|
|
23
24
|
* @param secretKey Secret key for the account
|
|
24
25
|
*/
|
|
25
|
-
constructor(secretKey?:
|
|
26
|
+
constructor(secretKey?: Uint8Array | Array<number>) {
|
|
26
27
|
if (secretKey) {
|
|
27
|
-
|
|
28
|
+
const secretKeyBuffer = toBuffer(secretKey);
|
|
29
|
+
if (secretKey.length !== 64) {
|
|
30
|
+
throw new Error('bad secret key size');
|
|
31
|
+
}
|
|
32
|
+
this._publicKey = secretKeyBuffer.slice(32, 64);
|
|
33
|
+
this._secretKey = secretKeyBuffer.slice(0, 32);
|
|
28
34
|
} else {
|
|
29
|
-
this.
|
|
35
|
+
this._secretKey = toBuffer(generatePrivateKey());
|
|
36
|
+
this._publicKey = toBuffer(getPublicKey(this._secretKey));
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
|
|
@@ -34,13 +41,15 @@ export class Account {
|
|
|
34
41
|
* The public key for this account
|
|
35
42
|
*/
|
|
36
43
|
get publicKey(): PublicKey {
|
|
37
|
-
return new PublicKey(this.
|
|
44
|
+
return new PublicKey(this._publicKey);
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
/**
|
|
41
|
-
* The **unencrypted** secret key for this account
|
|
48
|
+
* The **unencrypted** secret key for this account. The first 32 bytes
|
|
49
|
+
* is the private scalar and the last 32 bytes is the public key.
|
|
50
|
+
* Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
|
|
42
51
|
*/
|
|
43
52
|
get secretKey(): Buffer {
|
|
44
|
-
return
|
|
53
|
+
return Buffer.concat([this._secretKey, this._publicKey], 64);
|
|
45
54
|
}
|
|
46
55
|
}
|
package/src/bpf-loader.ts
CHANGED
|
@@ -24,12 +24,12 @@ export class BpfLoader {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Load a
|
|
27
|
+
* Load a SBF program
|
|
28
28
|
*
|
|
29
29
|
* @param connection The connection to use
|
|
30
30
|
* @param payer Account that will pay program loading fees
|
|
31
31
|
* @param program Account to load the program into
|
|
32
|
-
* @param elf The entire ELF containing the
|
|
32
|
+
* @param elf The entire ELF containing the SBF program
|
|
33
33
|
* @param loaderProgramId The program id of the BPF loader to use
|
|
34
34
|
* @return true if program was loaded successfully, false if program was already loaded
|
|
35
35
|
*/
|