@solana/web3.js 1.7.2 → 1.8.1
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.esm.js +20 -79
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +21 -84
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/index.esm.js +20 -83
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +27191 -27247
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +23 -23
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +7 -0
- package/package.json +1 -1
- package/src/connection.ts +19 -0
package/lib/index.cjs.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
5
|
var nacl = require('tweetnacl');
|
|
7
6
|
var buffer = require('buffer');
|
|
7
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
8
8
|
var BN = require('bn.js');
|
|
9
9
|
var bs58 = require('bs58');
|
|
10
10
|
var cryptoHash = require('crypto-hash');
|
|
@@ -42,9 +42,9 @@ function _interopNamespace(e) {
|
|
|
42
42
|
return Object.freeze(n);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
46
45
|
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
47
46
|
var nacl__namespace = /*#__PURE__*/_interopNamespace(nacl);
|
|
47
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
48
48
|
var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
|
|
49
49
|
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
50
50
|
var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
|
|
@@ -82,8 +82,6 @@ class PublicKey {
|
|
|
82
82
|
* @param value ed25519 public key as buffer or base-58 encoded string
|
|
83
83
|
*/
|
|
84
84
|
constructor(value) {
|
|
85
|
-
_defineProperty__default['default'](this, "_bn", void 0);
|
|
86
|
-
|
|
87
85
|
if (typeof value === 'string') {
|
|
88
86
|
// assume base 58 encoding by default
|
|
89
87
|
const decoded = bs58__default['default'].decode(value);
|
|
@@ -291,8 +289,6 @@ class Account {
|
|
|
291
289
|
* @param secretKey Secret key for the account
|
|
292
290
|
*/
|
|
293
291
|
constructor(secretKey) {
|
|
294
|
-
_defineProperty__default['default'](this, "_keypair", void 0);
|
|
295
|
-
|
|
296
292
|
if (secretKey) {
|
|
297
293
|
this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
|
|
298
294
|
} else {
|
|
@@ -457,14 +453,6 @@ const PUBKEY_LENGTH = 32;
|
|
|
457
453
|
|
|
458
454
|
class Message {
|
|
459
455
|
constructor(args) {
|
|
460
|
-
_defineProperty__default['default'](this, "header", void 0);
|
|
461
|
-
|
|
462
|
-
_defineProperty__default['default'](this, "accountKeys", void 0);
|
|
463
|
-
|
|
464
|
-
_defineProperty__default['default'](this, "recentBlockhash", void 0);
|
|
465
|
-
|
|
466
|
-
_defineProperty__default['default'](this, "instructions", void 0);
|
|
467
|
-
|
|
468
456
|
this.header = args.header;
|
|
469
457
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
470
458
|
this.recentBlockhash = args.recentBlockhash;
|
|
@@ -615,10 +603,6 @@ class TransactionInstruction {
|
|
|
615
603
|
* Program input
|
|
616
604
|
*/
|
|
617
605
|
constructor(opts) {
|
|
618
|
-
_defineProperty__default['default'](this, "keys", void 0);
|
|
619
|
-
|
|
620
|
-
_defineProperty__default['default'](this, "programId", void 0);
|
|
621
|
-
|
|
622
606
|
_defineProperty__default['default'](this, "data", buffer.Buffer.alloc(0));
|
|
623
607
|
|
|
624
608
|
this.programId = opts.programId;
|
|
@@ -664,14 +648,8 @@ class Transaction {
|
|
|
664
648
|
constructor(opts) {
|
|
665
649
|
_defineProperty__default['default'](this, "signatures", []);
|
|
666
650
|
|
|
667
|
-
_defineProperty__default['default'](this, "feePayer", void 0);
|
|
668
|
-
|
|
669
651
|
_defineProperty__default['default'](this, "instructions", []);
|
|
670
652
|
|
|
671
|
-
_defineProperty__default['default'](this, "recentBlockhash", void 0);
|
|
672
|
-
|
|
673
|
-
_defineProperty__default['default'](this, "nonceInfo", void 0);
|
|
674
|
-
|
|
675
653
|
opts && Object.assign(this, opts);
|
|
676
654
|
}
|
|
677
655
|
/**
|
|
@@ -1322,12 +1300,6 @@ class NonceAccount {
|
|
|
1322
1300
|
* @internal
|
|
1323
1301
|
*/
|
|
1324
1302
|
constructor(args) {
|
|
1325
|
-
_defineProperty__default['default'](this, "authorizedPubkey", void 0);
|
|
1326
|
-
|
|
1327
|
-
_defineProperty__default['default'](this, "nonce", void 0);
|
|
1328
|
-
|
|
1329
|
-
_defineProperty__default['default'](this, "feeCalculator", void 0);
|
|
1330
|
-
|
|
1331
1303
|
this.authorizedPubkey = args.authorizedPubkey;
|
|
1332
1304
|
this.nonce = args.nonce;
|
|
1333
1305
|
this.feeCalculator = args.feeCalculator;
|
|
@@ -2282,14 +2254,10 @@ class AgentManager {
|
|
|
2282
2254
|
}
|
|
2283
2255
|
|
|
2284
2256
|
constructor(useHttps) {
|
|
2285
|
-
_defineProperty__default['default'](this, "_agent", void 0);
|
|
2286
|
-
|
|
2287
2257
|
_defineProperty__default['default'](this, "_activeRequests", 0);
|
|
2288
2258
|
|
|
2289
2259
|
_defineProperty__default['default'](this, "_destroyTimeout", null);
|
|
2290
2260
|
|
|
2291
|
-
_defineProperty__default['default'](this, "_useHttps", void 0);
|
|
2292
|
-
|
|
2293
2261
|
this._useHttps = useHttps === true;
|
|
2294
2262
|
this._agent = AgentManager._newAgent(this._useHttps);
|
|
2295
2263
|
}
|
|
@@ -3180,8 +3148,6 @@ class Connection {
|
|
|
3180
3148
|
|
|
3181
3149
|
/** @internal */
|
|
3182
3150
|
|
|
3183
|
-
/** @internal */
|
|
3184
|
-
|
|
3185
3151
|
/**
|
|
3186
3152
|
* Establish a JSON RPC connection
|
|
3187
3153
|
*
|
|
@@ -3189,18 +3155,6 @@ class Connection {
|
|
|
3189
3155
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
3190
3156
|
*/
|
|
3191
3157
|
constructor(endpoint, commitmentOrConfig) {
|
|
3192
|
-
_defineProperty__default['default'](this, "_commitment", void 0);
|
|
3193
|
-
|
|
3194
|
-
_defineProperty__default['default'](this, "_rpcEndpoint", void 0);
|
|
3195
|
-
|
|
3196
|
-
_defineProperty__default['default'](this, "_rpcClient", void 0);
|
|
3197
|
-
|
|
3198
|
-
_defineProperty__default['default'](this, "_rpcRequest", void 0);
|
|
3199
|
-
|
|
3200
|
-
_defineProperty__default['default'](this, "_rpcBatchRequest", void 0);
|
|
3201
|
-
|
|
3202
|
-
_defineProperty__default['default'](this, "_rpcWebSocket", void 0);
|
|
3203
|
-
|
|
3204
3158
|
_defineProperty__default['default'](this, "_rpcWebSocketConnected", false);
|
|
3205
3159
|
|
|
3206
3160
|
_defineProperty__default['default'](this, "_rpcWebSocketHeartbeat", null);
|
|
@@ -3211,8 +3165,6 @@ class Connection {
|
|
|
3211
3165
|
|
|
3212
3166
|
_defineProperty__default['default'](this, "_pollingBlockhash", false);
|
|
3213
3167
|
|
|
3214
|
-
_defineProperty__default['default'](this, "_blockhashInfo", void 0);
|
|
3215
|
-
|
|
3216
3168
|
_defineProperty__default['default'](this, "_accountChangeSubscriptionCounter", 0);
|
|
3217
3169
|
|
|
3218
3170
|
_defineProperty__default['default'](this, "_accountChangeSubscriptions", {});
|
|
@@ -3794,6 +3746,25 @@ class Connection {
|
|
|
3794
3746
|
|
|
3795
3747
|
return res.result;
|
|
3796
3748
|
}
|
|
3749
|
+
/**
|
|
3750
|
+
* Fetch `limit` number of slot leaders starting from `startSlot`
|
|
3751
|
+
*
|
|
3752
|
+
* @param startSlot fetch slot leaders starting from this slot
|
|
3753
|
+
* @param limit number of slot leaders to return
|
|
3754
|
+
*/
|
|
3755
|
+
|
|
3756
|
+
|
|
3757
|
+
async getSlotLeaders(startSlot, limit) {
|
|
3758
|
+
const args = [startSlot, limit];
|
|
3759
|
+
const unsafeRes = await this._rpcRequest('getSlotLeaders', args);
|
|
3760
|
+
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(PublicKeyFromString)));
|
|
3761
|
+
|
|
3762
|
+
if ('error' in res) {
|
|
3763
|
+
throw new Error('failed to get slot leaders: ' + res.error.message);
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
return res.result;
|
|
3767
|
+
}
|
|
3797
3768
|
/**
|
|
3798
3769
|
* Fetch the current status of a signature
|
|
3799
3770
|
*/
|
|
@@ -5144,10 +5115,6 @@ class Authorized {
|
|
|
5144
5115
|
* @param withdrawer the withdraw authority
|
|
5145
5116
|
*/
|
|
5146
5117
|
constructor(staker, withdrawer) {
|
|
5147
|
-
_defineProperty__default['default'](this, "staker", void 0);
|
|
5148
|
-
|
|
5149
|
-
_defineProperty__default['default'](this, "withdrawer", void 0);
|
|
5150
|
-
|
|
5151
5118
|
this.staker = staker;
|
|
5152
5119
|
this.withdrawer = withdrawer;
|
|
5153
5120
|
}
|
|
@@ -5168,12 +5135,6 @@ class Lockup {
|
|
|
5168
5135
|
* Create a new Lockup object
|
|
5169
5136
|
*/
|
|
5170
5137
|
constructor(unixTimestamp, epoch, custodian) {
|
|
5171
|
-
_defineProperty__default['default'](this, "unixTimestamp", void 0);
|
|
5172
|
-
|
|
5173
|
-
_defineProperty__default['default'](this, "epoch", void 0);
|
|
5174
|
-
|
|
5175
|
-
_defineProperty__default['default'](this, "custodian", void 0);
|
|
5176
|
-
|
|
5177
5138
|
this.unixTimestamp = unixTimestamp;
|
|
5178
5139
|
this.epoch = epoch;
|
|
5179
5140
|
this.custodian = custodian;
|
|
@@ -5999,10 +5960,6 @@ class ValidatorInfo {
|
|
|
5999
5960
|
* @param info validator information
|
|
6000
5961
|
*/
|
|
6001
5962
|
constructor(key, info) {
|
|
6002
|
-
_defineProperty__default['default'](this, "key", void 0);
|
|
6003
|
-
|
|
6004
|
-
_defineProperty__default['default'](this, "info", void 0);
|
|
6005
|
-
|
|
6006
5963
|
this.key = key;
|
|
6007
5964
|
this.info = info;
|
|
6008
5965
|
}
|
|
@@ -6064,26 +6021,6 @@ class VoteAccount {
|
|
|
6064
6021
|
* @internal
|
|
6065
6022
|
*/
|
|
6066
6023
|
constructor(args) {
|
|
6067
|
-
_defineProperty__default['default'](this, "nodePubkey", void 0);
|
|
6068
|
-
|
|
6069
|
-
_defineProperty__default['default'](this, "authorizedVoterPubkey", void 0);
|
|
6070
|
-
|
|
6071
|
-
_defineProperty__default['default'](this, "authorizedWithdrawerPubkey", void 0);
|
|
6072
|
-
|
|
6073
|
-
_defineProperty__default['default'](this, "commission", void 0);
|
|
6074
|
-
|
|
6075
|
-
_defineProperty__default['default'](this, "votes", void 0);
|
|
6076
|
-
|
|
6077
|
-
_defineProperty__default['default'](this, "rootSlot", void 0);
|
|
6078
|
-
|
|
6079
|
-
_defineProperty__default['default'](this, "epoch", void 0);
|
|
6080
|
-
|
|
6081
|
-
_defineProperty__default['default'](this, "credits", void 0);
|
|
6082
|
-
|
|
6083
|
-
_defineProperty__default['default'](this, "lastEpochCredits", void 0);
|
|
6084
|
-
|
|
6085
|
-
_defineProperty__default['default'](this, "epochCredits", void 0);
|
|
6086
|
-
|
|
6087
6024
|
this.nodePubkey = args.nodePubkey;
|
|
6088
6025
|
this.authorizedVoterPubkey = args.authorizedVoterPubkey;
|
|
6089
6026
|
this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
|