@solana/web3.js 1.43.1 → 1.43.2
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 +21 -586
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +21 -586
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +70 -56
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +14 -5
- package/lib/index.esm.js +69 -55
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +18226 -17895
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +4 -4
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +6 -5
- package/src/__forks__/browser/fetch-impl.ts +4 -0
- package/src/connection.ts +17 -14
- package/src/fetch-impl.ts +13 -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.2",
|
|
4
4
|
"description": "Solana Javascript API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -64,10 +64,10 @@
|
|
|
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",
|
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
|
+
}
|