@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.d.ts
CHANGED
|
@@ -1277,6 +1277,13 @@ declare module '@solana/web3.js' {
|
|
|
1277
1277
|
* Fetch the current slot leader of the cluster
|
|
1278
1278
|
*/
|
|
1279
1279
|
getSlotLeader(commitment?: Commitment): Promise<string>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Fetch `limit` number of slot leaders starting from `startSlot`
|
|
1282
|
+
*
|
|
1283
|
+
* @param startSlot fetch slot leaders starting from this slot
|
|
1284
|
+
* @param limit number of slot leaders to return
|
|
1285
|
+
*/
|
|
1286
|
+
getSlotLeaders(startSlot: number, limit: number): Promise<Array<PublicKey>>;
|
|
1280
1287
|
/**
|
|
1281
1288
|
* Fetch the current status of a signature
|
|
1282
1289
|
*/
|
package/lib/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import * as nacl from 'tweetnacl';
|
|
3
2
|
import nacl__default from 'tweetnacl';
|
|
4
3
|
import { Buffer } from 'buffer';
|
|
4
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
import bs58 from 'bs58';
|
|
7
7
|
import { sha256 } from 'crypto-hash';
|
|
@@ -44,8 +44,6 @@ class PublicKey {
|
|
|
44
44
|
* @param value ed25519 public key as buffer or base-58 encoded string
|
|
45
45
|
*/
|
|
46
46
|
constructor(value) {
|
|
47
|
-
_defineProperty(this, "_bn", void 0);
|
|
48
|
-
|
|
49
47
|
if (typeof value === 'string') {
|
|
50
48
|
// assume base 58 encoding by default
|
|
51
49
|
const decoded = bs58.decode(value);
|
|
@@ -253,8 +251,6 @@ class Account {
|
|
|
253
251
|
* @param secretKey Secret key for the account
|
|
254
252
|
*/
|
|
255
253
|
constructor(secretKey) {
|
|
256
|
-
_defineProperty(this, "_keypair", void 0);
|
|
257
|
-
|
|
258
254
|
if (secretKey) {
|
|
259
255
|
this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
|
|
260
256
|
} else {
|
|
@@ -419,14 +415,6 @@ const PUBKEY_LENGTH = 32;
|
|
|
419
415
|
|
|
420
416
|
class Message {
|
|
421
417
|
constructor(args) {
|
|
422
|
-
_defineProperty(this, "header", void 0);
|
|
423
|
-
|
|
424
|
-
_defineProperty(this, "accountKeys", void 0);
|
|
425
|
-
|
|
426
|
-
_defineProperty(this, "recentBlockhash", void 0);
|
|
427
|
-
|
|
428
|
-
_defineProperty(this, "instructions", void 0);
|
|
429
|
-
|
|
430
418
|
this.header = args.header;
|
|
431
419
|
this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
|
|
432
420
|
this.recentBlockhash = args.recentBlockhash;
|
|
@@ -577,10 +565,6 @@ class TransactionInstruction {
|
|
|
577
565
|
* Program input
|
|
578
566
|
*/
|
|
579
567
|
constructor(opts) {
|
|
580
|
-
_defineProperty(this, "keys", void 0);
|
|
581
|
-
|
|
582
|
-
_defineProperty(this, "programId", void 0);
|
|
583
|
-
|
|
584
568
|
_defineProperty(this, "data", Buffer.alloc(0));
|
|
585
569
|
|
|
586
570
|
this.programId = opts.programId;
|
|
@@ -626,14 +610,8 @@ class Transaction {
|
|
|
626
610
|
constructor(opts) {
|
|
627
611
|
_defineProperty(this, "signatures", []);
|
|
628
612
|
|
|
629
|
-
_defineProperty(this, "feePayer", void 0);
|
|
630
|
-
|
|
631
613
|
_defineProperty(this, "instructions", []);
|
|
632
614
|
|
|
633
|
-
_defineProperty(this, "recentBlockhash", void 0);
|
|
634
|
-
|
|
635
|
-
_defineProperty(this, "nonceInfo", void 0);
|
|
636
|
-
|
|
637
615
|
opts && Object.assign(this, opts);
|
|
638
616
|
}
|
|
639
617
|
/**
|
|
@@ -1284,12 +1262,6 @@ class NonceAccount {
|
|
|
1284
1262
|
* @internal
|
|
1285
1263
|
*/
|
|
1286
1264
|
constructor(args) {
|
|
1287
|
-
_defineProperty(this, "authorizedPubkey", void 0);
|
|
1288
|
-
|
|
1289
|
-
_defineProperty(this, "nonce", void 0);
|
|
1290
|
-
|
|
1291
|
-
_defineProperty(this, "feeCalculator", void 0);
|
|
1292
|
-
|
|
1293
1265
|
this.authorizedPubkey = args.authorizedPubkey;
|
|
1294
1266
|
this.nonce = args.nonce;
|
|
1295
1267
|
this.feeCalculator = args.feeCalculator;
|
|
@@ -2244,14 +2216,10 @@ class AgentManager {
|
|
|
2244
2216
|
}
|
|
2245
2217
|
|
|
2246
2218
|
constructor(useHttps) {
|
|
2247
|
-
_defineProperty(this, "_agent", void 0);
|
|
2248
|
-
|
|
2249
2219
|
_defineProperty(this, "_activeRequests", 0);
|
|
2250
2220
|
|
|
2251
2221
|
_defineProperty(this, "_destroyTimeout", null);
|
|
2252
2222
|
|
|
2253
|
-
_defineProperty(this, "_useHttps", void 0);
|
|
2254
|
-
|
|
2255
2223
|
this._useHttps = useHttps === true;
|
|
2256
2224
|
this._agent = AgentManager._newAgent(this._useHttps);
|
|
2257
2225
|
}
|
|
@@ -3142,8 +3110,6 @@ class Connection {
|
|
|
3142
3110
|
|
|
3143
3111
|
/** @internal */
|
|
3144
3112
|
|
|
3145
|
-
/** @internal */
|
|
3146
|
-
|
|
3147
3113
|
/**
|
|
3148
3114
|
* Establish a JSON RPC connection
|
|
3149
3115
|
*
|
|
@@ -3151,18 +3117,6 @@ class Connection {
|
|
|
3151
3117
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
3152
3118
|
*/
|
|
3153
3119
|
constructor(endpoint, commitmentOrConfig) {
|
|
3154
|
-
_defineProperty(this, "_commitment", void 0);
|
|
3155
|
-
|
|
3156
|
-
_defineProperty(this, "_rpcEndpoint", void 0);
|
|
3157
|
-
|
|
3158
|
-
_defineProperty(this, "_rpcClient", void 0);
|
|
3159
|
-
|
|
3160
|
-
_defineProperty(this, "_rpcRequest", void 0);
|
|
3161
|
-
|
|
3162
|
-
_defineProperty(this, "_rpcBatchRequest", void 0);
|
|
3163
|
-
|
|
3164
|
-
_defineProperty(this, "_rpcWebSocket", void 0);
|
|
3165
|
-
|
|
3166
3120
|
_defineProperty(this, "_rpcWebSocketConnected", false);
|
|
3167
3121
|
|
|
3168
3122
|
_defineProperty(this, "_rpcWebSocketHeartbeat", null);
|
|
@@ -3173,8 +3127,6 @@ class Connection {
|
|
|
3173
3127
|
|
|
3174
3128
|
_defineProperty(this, "_pollingBlockhash", false);
|
|
3175
3129
|
|
|
3176
|
-
_defineProperty(this, "_blockhashInfo", void 0);
|
|
3177
|
-
|
|
3178
3130
|
_defineProperty(this, "_accountChangeSubscriptionCounter", 0);
|
|
3179
3131
|
|
|
3180
3132
|
_defineProperty(this, "_accountChangeSubscriptions", {});
|
|
@@ -3756,6 +3708,25 @@ class Connection {
|
|
|
3756
3708
|
|
|
3757
3709
|
return res.result;
|
|
3758
3710
|
}
|
|
3711
|
+
/**
|
|
3712
|
+
* Fetch `limit` number of slot leaders starting from `startSlot`
|
|
3713
|
+
*
|
|
3714
|
+
* @param startSlot fetch slot leaders starting from this slot
|
|
3715
|
+
* @param limit number of slot leaders to return
|
|
3716
|
+
*/
|
|
3717
|
+
|
|
3718
|
+
|
|
3719
|
+
async getSlotLeaders(startSlot, limit) {
|
|
3720
|
+
const args = [startSlot, limit];
|
|
3721
|
+
const unsafeRes = await this._rpcRequest('getSlotLeaders', args);
|
|
3722
|
+
const res = create(unsafeRes, jsonRpcResult(array(PublicKeyFromString)));
|
|
3723
|
+
|
|
3724
|
+
if ('error' in res) {
|
|
3725
|
+
throw new Error('failed to get slot leaders: ' + res.error.message);
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
return res.result;
|
|
3729
|
+
}
|
|
3759
3730
|
/**
|
|
3760
3731
|
* Fetch the current status of a signature
|
|
3761
3732
|
*/
|
|
@@ -5106,10 +5077,6 @@ class Authorized {
|
|
|
5106
5077
|
* @param withdrawer the withdraw authority
|
|
5107
5078
|
*/
|
|
5108
5079
|
constructor(staker, withdrawer) {
|
|
5109
|
-
_defineProperty(this, "staker", void 0);
|
|
5110
|
-
|
|
5111
|
-
_defineProperty(this, "withdrawer", void 0);
|
|
5112
|
-
|
|
5113
5080
|
this.staker = staker;
|
|
5114
5081
|
this.withdrawer = withdrawer;
|
|
5115
5082
|
}
|
|
@@ -5130,12 +5097,6 @@ class Lockup {
|
|
|
5130
5097
|
* Create a new Lockup object
|
|
5131
5098
|
*/
|
|
5132
5099
|
constructor(unixTimestamp, epoch, custodian) {
|
|
5133
|
-
_defineProperty(this, "unixTimestamp", void 0);
|
|
5134
|
-
|
|
5135
|
-
_defineProperty(this, "epoch", void 0);
|
|
5136
|
-
|
|
5137
|
-
_defineProperty(this, "custodian", void 0);
|
|
5138
|
-
|
|
5139
5100
|
this.unixTimestamp = unixTimestamp;
|
|
5140
5101
|
this.epoch = epoch;
|
|
5141
5102
|
this.custodian = custodian;
|
|
@@ -5961,10 +5922,6 @@ class ValidatorInfo {
|
|
|
5961
5922
|
* @param info validator information
|
|
5962
5923
|
*/
|
|
5963
5924
|
constructor(key, info) {
|
|
5964
|
-
_defineProperty(this, "key", void 0);
|
|
5965
|
-
|
|
5966
|
-
_defineProperty(this, "info", void 0);
|
|
5967
|
-
|
|
5968
5925
|
this.key = key;
|
|
5969
5926
|
this.info = info;
|
|
5970
5927
|
}
|
|
@@ -6026,26 +5983,6 @@ class VoteAccount {
|
|
|
6026
5983
|
* @internal
|
|
6027
5984
|
*/
|
|
6028
5985
|
constructor(args) {
|
|
6029
|
-
_defineProperty(this, "nodePubkey", void 0);
|
|
6030
|
-
|
|
6031
|
-
_defineProperty(this, "authorizedVoterPubkey", void 0);
|
|
6032
|
-
|
|
6033
|
-
_defineProperty(this, "authorizedWithdrawerPubkey", void 0);
|
|
6034
|
-
|
|
6035
|
-
_defineProperty(this, "commission", void 0);
|
|
6036
|
-
|
|
6037
|
-
_defineProperty(this, "votes", void 0);
|
|
6038
|
-
|
|
6039
|
-
_defineProperty(this, "rootSlot", void 0);
|
|
6040
|
-
|
|
6041
|
-
_defineProperty(this, "epoch", void 0);
|
|
6042
|
-
|
|
6043
|
-
_defineProperty(this, "credits", void 0);
|
|
6044
|
-
|
|
6045
|
-
_defineProperty(this, "lastEpochCredits", void 0);
|
|
6046
|
-
|
|
6047
|
-
_defineProperty(this, "epochCredits", void 0);
|
|
6048
|
-
|
|
6049
5986
|
this.nodePubkey = args.nodePubkey;
|
|
6050
5987
|
this.authorizedVoterPubkey = args.authorizedVoterPubkey;
|
|
6051
5988
|
this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
|