@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/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
declare module '@solana/web3.js' {
|
|
3
3
|
import {Buffer} from 'buffer';
|
|
4
|
-
import
|
|
4
|
+
import * as nodeFetch from 'node-fetch';
|
|
5
5
|
|
|
6
6
|
export class Struct {
|
|
7
7
|
constructor(properties: any);
|
|
@@ -179,6 +179,11 @@ declare module '@solana/web3.js' {
|
|
|
179
179
|
getSlotsInEpoch(epoch: number): number;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
export function export_default(
|
|
183
|
+
input: nodeFetch.RequestInfo,
|
|
184
|
+
init?: nodeFetch.RequestInit,
|
|
185
|
+
): Promise<nodeFetch.Response>;
|
|
186
|
+
|
|
182
187
|
/**
|
|
183
188
|
* Calculator for transaction fees.
|
|
184
189
|
*/
|
|
@@ -1444,13 +1449,17 @@ declare module '@solana/web3.js' {
|
|
|
1444
1449
|
export type HttpHeaders = {
|
|
1445
1450
|
[header: string]: string;
|
|
1446
1451
|
};
|
|
1452
|
+
/**
|
|
1453
|
+
* The type of the JavaScript `fetch()` API
|
|
1454
|
+
*/
|
|
1455
|
+
export type FetchFn = typeof export_default;
|
|
1447
1456
|
/**
|
|
1448
1457
|
* A callback used to augment the outgoing HTTP request
|
|
1449
1458
|
*/
|
|
1450
1459
|
export type FetchMiddleware = (
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
fetch: (
|
|
1460
|
+
info: Parameters<FetchFn>[0],
|
|
1461
|
+
init: Parameters<FetchFn>[1],
|
|
1462
|
+
fetch: (...a: Parameters<FetchFn>) => void,
|
|
1454
1463
|
) => void;
|
|
1455
1464
|
/**
|
|
1456
1465
|
* Configuration for instantiating a Connection
|
|
@@ -1463,7 +1472,7 @@ declare module '@solana/web3.js' {
|
|
|
1463
1472
|
/** Optional HTTP headers object */
|
|
1464
1473
|
httpHeaders?: HttpHeaders;
|
|
1465
1474
|
/** Optional custom fetch function */
|
|
1466
|
-
fetch?:
|
|
1475
|
+
fetch?: FetchFn;
|
|
1467
1476
|
/** Optional fetch middleware callback */
|
|
1468
1477
|
fetchMiddleware?: FetchMiddleware;
|
|
1469
1478
|
/** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
|
package/lib/index.esm.js
CHANGED
|
@@ -4,13 +4,14 @@ import BN from 'bn.js';
|
|
|
4
4
|
import bs58 from 'bs58';
|
|
5
5
|
import { serialize, deserialize, deserializeUnchecked } from 'borsh';
|
|
6
6
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
7
|
+
import { blob } from '@solana/buffer-layout';
|
|
8
|
+
import { toBigIntLE, toBufferLE } from 'bigint-buffer';
|
|
9
9
|
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
|
|
10
10
|
import { Client } from 'rpc-websockets';
|
|
11
11
|
import RpcClient from 'jayson/lib/client/browser';
|
|
12
12
|
import http from 'http';
|
|
13
13
|
import https from 'https';
|
|
14
|
+
import * as nodeFetch from 'node-fetch';
|
|
14
15
|
import secp256k1 from 'secp256k1';
|
|
15
16
|
import sha3 from 'js-sha3';
|
|
16
17
|
|
|
@@ -44,43 +45,52 @@ var inherits$1 = {exports: {}};
|
|
|
44
45
|
|
|
45
46
|
var inherits_browser = {exports: {}};
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
48
|
+
var hasRequiredInherits_browser;
|
|
49
|
+
|
|
50
|
+
function requireInherits_browser () {
|
|
51
|
+
if (hasRequiredInherits_browser) return inherits_browser.exports;
|
|
52
|
+
hasRequiredInherits_browser = 1;
|
|
53
|
+
if (typeof Object.create === 'function') {
|
|
54
|
+
// implementation from standard node.js 'util' module
|
|
55
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
56
|
+
if (superCtor) {
|
|
57
|
+
ctor.super_ = superCtor;
|
|
58
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
59
|
+
constructor: {
|
|
60
|
+
value: ctor,
|
|
61
|
+
enumerable: false,
|
|
62
|
+
writable: true,
|
|
63
|
+
configurable: true
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
// old school shim for old browsers
|
|
70
|
+
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
71
|
+
if (superCtor) {
|
|
72
|
+
ctor.super_ = superCtor;
|
|
73
|
+
var TempCtor = function () {};
|
|
74
|
+
TempCtor.prototype = superCtor.prototype;
|
|
75
|
+
ctor.prototype = new TempCtor();
|
|
76
|
+
ctor.prototype.constructor = ctor;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return inherits_browser.exports;
|
|
73
81
|
}
|
|
74
82
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
(function (module) {
|
|
84
|
+
try {
|
|
85
|
+
var util = require('util');
|
|
86
|
+
/* istanbul ignore next */
|
|
87
|
+
if (typeof util.inherits !== 'function') throw '';
|
|
88
|
+
module.exports = util.inherits;
|
|
89
|
+
} catch (e) {
|
|
90
|
+
/* istanbul ignore next */
|
|
91
|
+
module.exports = requireInherits_browser();
|
|
92
|
+
}
|
|
93
|
+
} (inherits$1));
|
|
84
94
|
|
|
85
95
|
var assert$5 = minimalisticAssert;
|
|
86
96
|
var inherits = inherits$1.exports;
|
|
@@ -1272,22 +1282,22 @@ Hmac.prototype.digest = function digest(enc) {
|
|
|
1272
1282
|
};
|
|
1273
1283
|
|
|
1274
1284
|
(function (exports) {
|
|
1275
|
-
var hash = exports;
|
|
1276
|
-
|
|
1277
|
-
hash.utils = utils$9;
|
|
1278
|
-
hash.common = common$5;
|
|
1279
|
-
hash.sha = sha;
|
|
1280
|
-
hash.ripemd = ripemd;
|
|
1281
|
-
hash.hmac = hmac;
|
|
1282
|
-
|
|
1283
|
-
// Proxy hash functions to the main object
|
|
1284
|
-
hash.sha1 = hash.sha.sha1;
|
|
1285
|
-
hash.sha256 = hash.sha.sha256;
|
|
1286
|
-
hash.sha224 = hash.sha.sha224;
|
|
1287
|
-
hash.sha384 = hash.sha.sha384;
|
|
1288
|
-
hash.sha512 = hash.sha.sha512;
|
|
1289
|
-
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1290
|
-
}(hash$1));
|
|
1285
|
+
var hash = exports;
|
|
1286
|
+
|
|
1287
|
+
hash.utils = utils$9;
|
|
1288
|
+
hash.common = common$5;
|
|
1289
|
+
hash.sha = sha;
|
|
1290
|
+
hash.ripemd = ripemd;
|
|
1291
|
+
hash.hmac = hmac;
|
|
1292
|
+
|
|
1293
|
+
// Proxy hash functions to the main object
|
|
1294
|
+
hash.sha1 = hash.sha.sha1;
|
|
1295
|
+
hash.sha256 = hash.sha.sha256;
|
|
1296
|
+
hash.sha224 = hash.sha.sha224;
|
|
1297
|
+
hash.sha384 = hash.sha.sha384;
|
|
1298
|
+
hash.sha512 = hash.sha.sha512;
|
|
1299
|
+
hash.ripemd160 = hash.ripemd.ripemd160;
|
|
1300
|
+
} (hash$1));
|
|
1291
1301
|
|
|
1292
1302
|
var hash = hash$1;
|
|
1293
1303
|
|
|
@@ -2582,13 +2592,6 @@ class Transaction {
|
|
|
2582
2592
|
isSigner: false,
|
|
2583
2593
|
isWritable: false
|
|
2584
2594
|
});
|
|
2585
|
-
}); // Sort. Prioritizing first by signer, then by writable
|
|
2586
|
-
|
|
2587
|
-
accountMetas.sort(function (x, y) {
|
|
2588
|
-
const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
|
|
2589
|
-
const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
|
|
2590
|
-
const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
|
|
2591
|
-
return checkSigner || checkWritable;
|
|
2592
2595
|
}); // Cull duplicate account metas
|
|
2593
2596
|
|
|
2594
2597
|
const uniqueMetas = [];
|
|
@@ -2600,9 +2603,17 @@ class Transaction {
|
|
|
2600
2603
|
|
|
2601
2604
|
if (uniqueIndex > -1) {
|
|
2602
2605
|
uniqueMetas[uniqueIndex].isWritable = uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;
|
|
2606
|
+
uniqueMetas[uniqueIndex].isSigner = uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;
|
|
2603
2607
|
} else {
|
|
2604
2608
|
uniqueMetas.push(accountMeta);
|
|
2605
2609
|
}
|
|
2610
|
+
}); // Sort. Prioritizing first by signer, then by writable
|
|
2611
|
+
|
|
2612
|
+
uniqueMetas.sort(function (x, y) {
|
|
2613
|
+
const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
|
|
2614
|
+
const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
|
|
2615
|
+
const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
|
|
2616
|
+
return checkSigner || checkWritable;
|
|
2606
2617
|
}); // Move fee payer to the front
|
|
2607
2618
|
|
|
2608
2619
|
const feePayerIndex = uniqueMetas.findIndex(x => {
|
|
@@ -3184,6 +3195,38 @@ class NonceAccount {
|
|
|
3184
3195
|
|
|
3185
3196
|
}
|
|
3186
3197
|
|
|
3198
|
+
const encodeDecode = layout => {
|
|
3199
|
+
const decode = layout.decode.bind(layout);
|
|
3200
|
+
const encode = layout.encode.bind(layout);
|
|
3201
|
+
return {
|
|
3202
|
+
decode,
|
|
3203
|
+
encode
|
|
3204
|
+
};
|
|
3205
|
+
};
|
|
3206
|
+
|
|
3207
|
+
const bigInt = length => property => {
|
|
3208
|
+
const layout = blob(length, property);
|
|
3209
|
+
const {
|
|
3210
|
+
encode,
|
|
3211
|
+
decode
|
|
3212
|
+
} = encodeDecode(layout);
|
|
3213
|
+
const bigIntLayout = layout;
|
|
3214
|
+
|
|
3215
|
+
bigIntLayout.decode = (buffer, offset) => {
|
|
3216
|
+
const src = decode(buffer, offset);
|
|
3217
|
+
return toBigIntLE(Buffer.from(src));
|
|
3218
|
+
};
|
|
3219
|
+
|
|
3220
|
+
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3221
|
+
const src = toBufferLE(bigInt, length);
|
|
3222
|
+
return encode(src, buffer, offset);
|
|
3223
|
+
};
|
|
3224
|
+
|
|
3225
|
+
return bigIntLayout;
|
|
3226
|
+
};
|
|
3227
|
+
|
|
3228
|
+
const u64 = bigInt(8);
|
|
3229
|
+
|
|
3187
3230
|
/**
|
|
3188
3231
|
* Create account system transaction params
|
|
3189
3232
|
*/
|
|
@@ -4517,6 +4560,11 @@ class SendTransactionError extends Error {
|
|
|
4517
4560
|
|
|
4518
4561
|
}
|
|
4519
4562
|
|
|
4563
|
+
async function fetchImpl (input, init) {
|
|
4564
|
+
const processedInput = typeof input === 'string' && input.slice(0, 2) === '//' ? 'https:' + input : input;
|
|
4565
|
+
return await nodeFetch.default(processedInput, init);
|
|
4566
|
+
}
|
|
4567
|
+
|
|
4520
4568
|
// TODO: These constants should be removed in favor of reading them out of a
|
|
4521
4569
|
// Syscall account
|
|
4522
4570
|
|
|
@@ -4766,7 +4814,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
4766
4814
|
*/
|
|
4767
4815
|
|
|
4768
4816
|
function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4769
|
-
const fetch = customFetch ? customFetch :
|
|
4817
|
+
const fetch = customFetch ? customFetch : fetchImpl;
|
|
4770
4818
|
let agentManager;
|
|
4771
4819
|
|
|
4772
4820
|
{
|
|
@@ -4776,10 +4824,10 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4776
4824
|
let fetchWithMiddleware;
|
|
4777
4825
|
|
|
4778
4826
|
if (fetchMiddleware) {
|
|
4779
|
-
fetchWithMiddleware = async (
|
|
4827
|
+
fetchWithMiddleware = async (info, init) => {
|
|
4780
4828
|
const modifiedFetchArgs = await new Promise((resolve, reject) => {
|
|
4781
4829
|
try {
|
|
4782
|
-
fetchMiddleware(
|
|
4830
|
+
fetchMiddleware(info, init, (modifiedInfo, modifiedInit) => resolve([modifiedInfo, modifiedInit]));
|
|
4783
4831
|
} catch (error) {
|
|
4784
4832
|
reject(error);
|
|
4785
4833
|
}
|