@solana/web3.js 1.43.0 → 1.43.3
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 +65 -597
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +63 -594
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +114 -67
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +14 -5
- package/lib/index.esm.js +111 -63
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +26021 -26079
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +6 -4
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +8 -7
- package/src/__forks__/browser/fetch-impl.ts +4 -0
- package/src/compute-budget.ts +1 -1
- package/src/connection.ts +17 -14
- package/src/fetch-impl.ts +13 -0
- package/src/system-program.ts +1 -1
- package/src/transaction.ts +13 -11
- package/src/util/bigint.ts +43 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3.js",
|
|
3
|
-
"version": "1.43.
|
|
3
|
+
"version": "1.43.3",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -59,15 +59,15 @@
|
|
|
59
59
|
"@babel/runtime": "^7.12.5",
|
|
60
60
|
"@ethersproject/sha2": "^5.5.0",
|
|
61
61
|
"@solana/buffer-layout": "^4.0.0",
|
|
62
|
-
"
|
|
62
|
+
"bigint-buffer": "^1.1.5",
|
|
63
63
|
"bn.js": "^5.0.0",
|
|
64
64
|
"borsh": "^0.7.0",
|
|
65
65
|
"bs58": "^4.0.1",
|
|
66
66
|
"buffer": "6.0.1",
|
|
67
|
-
"cross-fetch": "^3.1.4",
|
|
68
67
|
"fast-stable-stringify": "^1.0.0",
|
|
69
68
|
"jayson": "^3.4.4",
|
|
70
69
|
"js-sha3": "^0.8.0",
|
|
70
|
+
"node-fetch": "2",
|
|
71
71
|
"rpc-websockets": "^7.4.2",
|
|
72
72
|
"secp256k1": "^4.0.2",
|
|
73
73
|
"superstruct": "^0.14.2",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"@babel/preset-typescript": "^7.12.16",
|
|
82
82
|
"@babel/register": "^7.12.13",
|
|
83
83
|
"@commitlint/config-conventional": "^15.0.0",
|
|
84
|
-
"@commitlint/travis-cli": "^
|
|
85
|
-
"@rollup/plugin-alias": "^3.1.
|
|
84
|
+
"@commitlint/travis-cli": "^17.0.0",
|
|
85
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
86
86
|
"@rollup/plugin-babel": "^5.2.3",
|
|
87
|
-
"@rollup/plugin-commonjs": "^
|
|
87
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
88
88
|
"@rollup/plugin-json": "^4.1.0",
|
|
89
89
|
"@rollup/plugin-multi-entry": "^4.0.0",
|
|
90
90
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"@types/mocha": "^9.0.0",
|
|
99
99
|
"@types/mz": "^2.7.3",
|
|
100
100
|
"@types/node": "^17.0.24",
|
|
101
|
+
"@types/node-fetch": "2",
|
|
101
102
|
"@types/secp256k1": "^4.0.1",
|
|
102
103
|
"@types/sinon": "^10.0.0",
|
|
103
104
|
"@types/sinon-chai": "^3.2.8",
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"eslint": "^7.19.0",
|
|
111
112
|
"eslint-config-prettier": "^8.0.0",
|
|
112
113
|
"eslint-plugin-import": "2.26.0",
|
|
113
|
-
"eslint-plugin-mocha": "^
|
|
114
|
+
"eslint-plugin-mocha": "^10.0.4",
|
|
114
115
|
"eslint-plugin-prettier": "^4.0.0",
|
|
115
116
|
"esm": "^3.2.25",
|
|
116
117
|
"http-server": "^14.0.0",
|
package/src/compute-budget.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
2
|
-
import {u64} from '@solana/buffer-layout-utils';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
encodeData,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
} from './instruction';
|
|
10
9
|
import {PublicKey} from './publickey';
|
|
11
10
|
import {TransactionInstruction} from './transaction';
|
|
11
|
+
import {u64} from './util/bigint';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Compute Budget Instruction class
|
package/src/connection.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import bs58 from 'bs58';
|
|
2
2
|
import {Buffer} from 'buffer';
|
|
3
|
-
import crossFetch from 'cross-fetch';
|
|
4
3
|
// @ts-ignore
|
|
5
4
|
import fastStableStringify from 'fast-stable-stringify';
|
|
6
5
|
import {
|
|
@@ -28,6 +27,7 @@ import RpcClient from 'jayson/lib/client/browser';
|
|
|
28
27
|
import {AgentManager} from './agent-manager';
|
|
29
28
|
import {EpochSchedule} from './epoch-schedule';
|
|
30
29
|
import {SendTransactionError} from './errors';
|
|
30
|
+
import fetchImpl, {Response} from './fetch-impl';
|
|
31
31
|
import {NonceAccount} from './nonce-account';
|
|
32
32
|
import {PublicKey} from './publickey';
|
|
33
33
|
import {Signer} from './keypair';
|
|
@@ -955,27 +955,25 @@ function createRpcClient(
|
|
|
955
955
|
url: string,
|
|
956
956
|
useHttps: boolean,
|
|
957
957
|
httpHeaders?: HttpHeaders,
|
|
958
|
-
customFetch?:
|
|
958
|
+
customFetch?: FetchFn,
|
|
959
959
|
fetchMiddleware?: FetchMiddleware,
|
|
960
960
|
disableRetryOnRateLimit?: boolean,
|
|
961
961
|
): RpcClient {
|
|
962
|
-
const fetch = customFetch ? customFetch :
|
|
962
|
+
const fetch = customFetch ? customFetch : fetchImpl;
|
|
963
963
|
let agentManager: AgentManager | undefined;
|
|
964
964
|
if (!process.env.BROWSER) {
|
|
965
965
|
agentManager = new AgentManager(useHttps);
|
|
966
966
|
}
|
|
967
967
|
|
|
968
|
-
let fetchWithMiddleware:
|
|
969
|
-
| ((url: string, options: any) => Promise<Response>)
|
|
970
|
-
| undefined;
|
|
968
|
+
let fetchWithMiddleware: FetchFn | undefined;
|
|
971
969
|
|
|
972
970
|
if (fetchMiddleware) {
|
|
973
|
-
fetchWithMiddleware = async (
|
|
974
|
-
const modifiedFetchArgs = await new Promise<
|
|
971
|
+
fetchWithMiddleware = async (info, init) => {
|
|
972
|
+
const modifiedFetchArgs = await new Promise<Parameters<FetchFn>>(
|
|
975
973
|
(resolve, reject) => {
|
|
976
974
|
try {
|
|
977
|
-
fetchMiddleware(
|
|
978
|
-
resolve([
|
|
975
|
+
fetchMiddleware(info, init, (modifiedInfo, modifiedInit) =>
|
|
976
|
+
resolve([modifiedInfo, modifiedInit]),
|
|
979
977
|
);
|
|
980
978
|
} catch (error) {
|
|
981
979
|
reject(error);
|
|
@@ -2162,13 +2160,18 @@ export type ConfirmedSignatureInfo = {
|
|
|
2162
2160
|
*/
|
|
2163
2161
|
export type HttpHeaders = {[header: string]: string};
|
|
2164
2162
|
|
|
2163
|
+
/**
|
|
2164
|
+
* The type of the JavaScript `fetch()` API
|
|
2165
|
+
*/
|
|
2166
|
+
export type FetchFn = typeof fetchImpl;
|
|
2167
|
+
|
|
2165
2168
|
/**
|
|
2166
2169
|
* A callback used to augment the outgoing HTTP request
|
|
2167
2170
|
*/
|
|
2168
2171
|
export type FetchMiddleware = (
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
fetch: (
|
|
2172
|
+
info: Parameters<FetchFn>[0],
|
|
2173
|
+
init: Parameters<FetchFn>[1],
|
|
2174
|
+
fetch: (...a: Parameters<FetchFn>) => void,
|
|
2172
2175
|
) => void;
|
|
2173
2176
|
|
|
2174
2177
|
/**
|
|
@@ -2182,7 +2185,7 @@ export type ConnectionConfig = {
|
|
|
2182
2185
|
/** Optional HTTP headers object */
|
|
2183
2186
|
httpHeaders?: HttpHeaders;
|
|
2184
2187
|
/** Optional custom fetch function */
|
|
2185
|
-
fetch?:
|
|
2188
|
+
fetch?: FetchFn;
|
|
2186
2189
|
/** Optional fetch middleware callback */
|
|
2187
2190
|
fetchMiddleware?: FetchMiddleware;
|
|
2188
2191
|
/** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as nodeFetch from 'node-fetch';
|
|
2
|
+
|
|
3
|
+
export * from 'node-fetch';
|
|
4
|
+
export default async function (
|
|
5
|
+
input: nodeFetch.RequestInfo,
|
|
6
|
+
init?: nodeFetch.RequestInit,
|
|
7
|
+
): Promise<nodeFetch.Response> {
|
|
8
|
+
const processedInput =
|
|
9
|
+
typeof input === 'string' && input.slice(0, 2) === '//'
|
|
10
|
+
? 'https:' + input
|
|
11
|
+
: input;
|
|
12
|
+
return await nodeFetch.default(processedInput, init);
|
|
13
|
+
}
|
package/src/system-program.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
2
|
-
import {u64} from '@solana/buffer-layout-utils';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
encodeData,
|
|
@@ -13,6 +12,7 @@ import {PublicKey} from './publickey';
|
|
|
13
12
|
import {SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY} from './sysvar';
|
|
14
13
|
import {Transaction, TransactionInstruction} from './transaction';
|
|
15
14
|
import {toBuffer} from './util/to-buffer';
|
|
15
|
+
import {u64} from './util/bigint';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Create account system transaction params
|
package/src/transaction.ts
CHANGED
|
@@ -376,17 +376,6 @@ export class Transaction {
|
|
|
376
376
|
});
|
|
377
377
|
});
|
|
378
378
|
|
|
379
|
-
// Sort. Prioritizing first by signer, then by writable
|
|
380
|
-
accountMetas.sort(function (x, y) {
|
|
381
|
-
const pubkeySorting = x.pubkey
|
|
382
|
-
.toBase58()
|
|
383
|
-
.localeCompare(y.pubkey.toBase58());
|
|
384
|
-
const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
|
|
385
|
-
const checkWritable =
|
|
386
|
-
x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
|
|
387
|
-
return checkSigner || checkWritable;
|
|
388
|
-
});
|
|
389
|
-
|
|
390
379
|
// Cull duplicate account metas
|
|
391
380
|
const uniqueMetas: AccountMeta[] = [];
|
|
392
381
|
accountMetas.forEach(accountMeta => {
|
|
@@ -397,11 +386,24 @@ export class Transaction {
|
|
|
397
386
|
if (uniqueIndex > -1) {
|
|
398
387
|
uniqueMetas[uniqueIndex].isWritable =
|
|
399
388
|
uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;
|
|
389
|
+
uniqueMetas[uniqueIndex].isSigner =
|
|
390
|
+
uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;
|
|
400
391
|
} else {
|
|
401
392
|
uniqueMetas.push(accountMeta);
|
|
402
393
|
}
|
|
403
394
|
});
|
|
404
395
|
|
|
396
|
+
// Sort. Prioritizing first by signer, then by writable
|
|
397
|
+
uniqueMetas.sort(function (x, y) {
|
|
398
|
+
const pubkeySorting = x.pubkey
|
|
399
|
+
.toBase58()
|
|
400
|
+
.localeCompare(y.pubkey.toBase58());
|
|
401
|
+
const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
|
|
402
|
+
const checkWritable =
|
|
403
|
+
x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
|
|
404
|
+
return checkSigner || checkWritable;
|
|
405
|
+
});
|
|
406
|
+
|
|
405
407
|
// Move fee payer to the front
|
|
406
408
|
const feePayerIndex = uniqueMetas.findIndex(x => {
|
|
407
409
|
return x.pubkey.equals(feePayer);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {Buffer} from 'buffer';
|
|
2
|
+
import {blob, Layout} from '@solana/buffer-layout';
|
|
3
|
+
import {toBigIntLE, toBufferLE} from 'bigint-buffer';
|
|
4
|
+
|
|
5
|
+
interface EncodeDecode<T> {
|
|
6
|
+
decode(buffer: Buffer, offset?: number): T;
|
|
7
|
+
encode(src: T, buffer: Buffer, offset?: number): number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const encodeDecode = <T>(layout: Layout<T>): EncodeDecode<T> => {
|
|
11
|
+
const decode = layout.decode.bind(layout);
|
|
12
|
+
const encode = layout.encode.bind(layout);
|
|
13
|
+
return {decode, encode};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const bigInt =
|
|
17
|
+
(length: number) =>
|
|
18
|
+
(property?: string): Layout<bigint> => {
|
|
19
|
+
const layout = blob(length, property);
|
|
20
|
+
const {encode, decode} = encodeDecode(layout);
|
|
21
|
+
|
|
22
|
+
const bigIntLayout = layout as Layout<unknown> as Layout<bigint>;
|
|
23
|
+
|
|
24
|
+
bigIntLayout.decode = (buffer: Buffer, offset: number) => {
|
|
25
|
+
const src = decode(buffer, offset);
|
|
26
|
+
return toBigIntLE(Buffer.from(src));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
bigIntLayout.encode = (bigInt: bigint, buffer: Buffer, offset: number) => {
|
|
30
|
+
const src = toBufferLE(bigInt, length);
|
|
31
|
+
return encode(src, buffer, offset);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return bigIntLayout;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const u64 = bigInt(8);
|
|
38
|
+
|
|
39
|
+
export const u128 = bigInt(16);
|
|
40
|
+
|
|
41
|
+
export const u192 = bigInt(24);
|
|
42
|
+
|
|
43
|
+
export const u256 = bigInt(32);
|