@solana/web3.js 1.30.1 → 1.32.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.cjs.js CHANGED
@@ -2,7 +2,6 @@
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');
8
7
  var BN = require('bn.js');
@@ -16,7 +15,7 @@ var RpcClient = require('jayson/lib/client/browser');
16
15
  var http = require('http');
17
16
  var https = require('https');
18
17
  var secp256k1 = require('secp256k1');
19
- var jsSha3 = require('js-sha3');
18
+ var sha3 = require('js-sha3');
20
19
 
21
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
21
 
@@ -38,9 +37,7 @@ function _interopNamespace(e) {
38
37
  return Object.freeze(n);
39
38
  }
40
39
 
41
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
42
40
  var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
43
- var nacl__namespace = /*#__PURE__*/_interopNamespace(nacl);
44
41
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
45
42
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
46
43
  var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
@@ -49,6 +46,7 @@ var RpcClient__default = /*#__PURE__*/_interopDefaultLegacy(RpcClient);
49
46
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
50
47
  var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
51
48
  var secp256k1__default = /*#__PURE__*/_interopDefaultLegacy(secp256k1);
49
+ var sha3__default = /*#__PURE__*/_interopDefaultLegacy(sha3);
52
50
 
53
51
  const toBuffer = arr => {
54
52
  if (buffer.Buffer.isBuffer(arr)) {
@@ -1760,8 +1758,7 @@ class Struct {
1760
1758
  class Enum extends Struct {
1761
1759
  constructor(properties) {
1762
1760
  super(properties);
1763
-
1764
- _defineProperty__default["default"](this, "enum", '');
1761
+ this.enum = '';
1765
1762
 
1766
1763
  if (Object.keys(properties).length !== 1) {
1767
1764
  throw new Error('Enum can only take single value');
@@ -1801,8 +1798,7 @@ class PublicKey extends Struct {
1801
1798
  */
1802
1799
  constructor(value) {
1803
1800
  super({});
1804
-
1805
- _defineProperty__default["default"](this, "_bn", void 0);
1801
+ this._bn = void 0;
1806
1802
 
1807
1803
  if (isPublicKeyData(value)) {
1808
1804
  this._bn = value._bn;
@@ -1812,7 +1808,7 @@ class PublicKey extends Struct {
1812
1808
  const decoded = bs58__default["default"].decode(value);
1813
1809
 
1814
1810
  if (decoded.length != 32) {
1815
- throw new Error("Invalid public key input");
1811
+ throw new Error(`Invalid public key input`);
1816
1812
  }
1817
1813
 
1818
1814
  this._bn = new BN__default["default"](decoded);
@@ -1821,7 +1817,7 @@ class PublicKey extends Struct {
1821
1817
  }
1822
1818
 
1823
1819
  if (this._bn.byteLength() > 32) {
1824
- throw new Error("Invalid public key input");
1820
+ throw new Error(`Invalid public key input`);
1825
1821
  }
1826
1822
  }
1827
1823
  }
@@ -1844,6 +1840,10 @@ class PublicKey extends Struct {
1844
1840
  toBase58() {
1845
1841
  return bs58__default["default"].encode(this.toBytes());
1846
1842
  }
1843
+
1844
+ toJSON() {
1845
+ return this.toBase58();
1846
+ }
1847
1847
  /**
1848
1848
  * Return the byte array representation of the public key
1849
1849
  */
@@ -1901,7 +1901,7 @@ class PublicKey extends Struct {
1901
1901
  let buffer$1 = buffer.Buffer.alloc(0);
1902
1902
  seeds.forEach(function (seed) {
1903
1903
  if (seed.length > MAX_SEED_LENGTH) {
1904
- throw new TypeError("Max seed length exceeded");
1904
+ throw new TypeError(`Max seed length exceeded`);
1905
1905
  }
1906
1906
 
1907
1907
  buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
@@ -1911,7 +1911,7 @@ class PublicKey extends Struct {
1911
1911
  let publicKeyBytes = new BN__default["default"](hash, 16).toArray(undefined, 32);
1912
1912
 
1913
1913
  if (is_on_curve(publicKeyBytes)) {
1914
- throw new Error("Invalid seeds, address must fall off the curve");
1914
+ throw new Error(`Invalid seeds, address must fall off the curve`);
1915
1915
  }
1916
1916
 
1917
1917
  return new PublicKey(publicKeyBytes);
@@ -1945,7 +1945,7 @@ class PublicKey extends Struct {
1945
1945
  return [address, nonce];
1946
1946
  }
1947
1947
 
1948
- throw new Error("Unable to find a viable program address nonce");
1948
+ throw new Error(`Unable to find a viable program address nonce`);
1949
1949
  }
1950
1950
  /**
1951
1951
  * Check that a pubkey is on the ed25519 curve.
@@ -1957,9 +1957,7 @@ class PublicKey extends Struct {
1957
1957
  }
1958
1958
 
1959
1959
  }
1960
-
1961
- _defineProperty__default["default"](PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
1962
-
1960
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
1963
1961
  SOLANA_SCHEMA.set(PublicKey, {
1964
1962
  kind: 'struct',
1965
1963
  fields: [['_bn', 'u256']]
@@ -2032,12 +2030,12 @@ class Account {
2032
2030
  * @param secretKey Secret key for the account
2033
2031
  */
2034
2032
  constructor(secretKey) {
2035
- _defineProperty__default["default"](this, "_keypair", void 0);
2033
+ this._keypair = void 0;
2036
2034
 
2037
2035
  if (secretKey) {
2038
- this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
2036
+ this._keypair = nacl__default["default"].sign.keyPair.fromSecretKey(toBuffer(secretKey));
2039
2037
  } else {
2040
- this._keypair = nacl__namespace.sign.keyPair();
2038
+ this._keypair = nacl__default["default"].sign.keyPair();
2041
2039
  }
2042
2040
  }
2043
2041
  /**
@@ -2168,16 +2166,11 @@ const PUBKEY_LENGTH = 32;
2168
2166
 
2169
2167
  class Message {
2170
2168
  constructor(args) {
2171
- _defineProperty__default["default"](this, "header", void 0);
2172
-
2173
- _defineProperty__default["default"](this, "accountKeys", void 0);
2174
-
2175
- _defineProperty__default["default"](this, "recentBlockhash", void 0);
2176
-
2177
- _defineProperty__default["default"](this, "instructions", void 0);
2178
-
2179
- _defineProperty__default["default"](this, "indexToProgramIds", new Map());
2180
-
2169
+ this.header = void 0;
2170
+ this.accountKeys = void 0;
2171
+ this.recentBlockhash = void 0;
2172
+ this.instructions = void 0;
2173
+ this.indexToProgramIds = new Map();
2181
2174
  this.header = args.header;
2182
2175
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
2183
2176
  this.recentBlockhash = args.recentBlockhash;
@@ -2351,12 +2344,9 @@ class TransactionInstruction {
2351
2344
  * Program input
2352
2345
  */
2353
2346
  constructor(opts) {
2354
- _defineProperty__default["default"](this, "keys", void 0);
2355
-
2356
- _defineProperty__default["default"](this, "programId", void 0);
2357
-
2358
- _defineProperty__default["default"](this, "data", buffer.Buffer.alloc(0));
2359
-
2347
+ this.keys = void 0;
2348
+ this.programId = void 0;
2349
+ this.data = buffer.Buffer.alloc(0);
2360
2350
  this.programId = opts.programId;
2361
2351
  this.keys = opts.keys;
2362
2352
 
@@ -2398,16 +2388,11 @@ class Transaction {
2398
2388
  * Construct an empty Transaction
2399
2389
  */
2400
2390
  constructor(opts) {
2401
- _defineProperty__default["default"](this, "signatures", []);
2402
-
2403
- _defineProperty__default["default"](this, "feePayer", void 0);
2404
-
2405
- _defineProperty__default["default"](this, "instructions", []);
2406
-
2407
- _defineProperty__default["default"](this, "recentBlockhash", void 0);
2408
-
2409
- _defineProperty__default["default"](this, "nonceInfo", void 0);
2410
-
2391
+ this.signatures = [];
2392
+ this.feePayer = void 0;
2393
+ this.instructions = [];
2394
+ this.recentBlockhash = void 0;
2395
+ this.nonceInfo = void 0;
2411
2396
  opts && Object.assign(this, opts);
2412
2397
  }
2413
2398
  /**
@@ -2471,7 +2456,7 @@ class Transaction {
2471
2456
 
2472
2457
  for (let i = 0; i < this.instructions.length; i++) {
2473
2458
  if (this.instructions[i].programId === undefined) {
2474
- throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
2459
+ throw new Error(`Transaction instruction index ${i} has undefined program id`);
2475
2460
  }
2476
2461
  }
2477
2462
 
@@ -2498,8 +2483,9 @@ class Transaction {
2498
2483
  }); // Sort. Prioritizing first by signer, then by writable
2499
2484
 
2500
2485
  accountMetas.sort(function (x, y) {
2486
+ const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2501
2487
  const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2502
- const checkWritable = x.isWritable === y.isWritable ? 0 : x.isWritable ? -1 : 1;
2488
+ const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2503
2489
  return checkSigner || checkWritable;
2504
2490
  }); // Cull duplicate account metas
2505
2491
 
@@ -2546,7 +2532,7 @@ class Transaction {
2546
2532
  console.warn('Transaction references a signature that is unnecessary, ' + 'only the fee payer and instruction signer accounts should sign a transaction. ' + 'This behavior is deprecated and will throw an error in the next major version release.');
2547
2533
  }
2548
2534
  } else {
2549
- throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
2535
+ throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
2550
2536
  }
2551
2537
  }
2552
2538
 
@@ -2781,7 +2767,7 @@ class Transaction {
2781
2767
  const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
2782
2768
 
2783
2769
  if (index < 0) {
2784
- throw new Error("unknown signer: ".concat(pubkey.toString()));
2770
+ throw new Error(`unknown signer: ${pubkey.toString()}`);
2785
2771
  }
2786
2772
 
2787
2773
  this.signatures[index].signature = buffer.Buffer.from(signature);
@@ -2857,12 +2843,12 @@ class Transaction {
2857
2843
  signature
2858
2844
  }, index) => {
2859
2845
  if (signature !== null) {
2860
- assert(signature.length === 64, "signature has invalid length");
2846
+ assert(signature.length === 64, `signature has invalid length`);
2861
2847
  buffer.Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
2862
2848
  }
2863
2849
  });
2864
2850
  signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
2865
- assert(wireTransaction.length <= PACKET_DATA_SIZE, "Transaction too large: ".concat(wireTransaction.length, " > ").concat(PACKET_DATA_SIZE));
2851
+ assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
2866
2852
  return wireTransaction;
2867
2853
  }
2868
2854
  /**
@@ -2955,11 +2941,14 @@ class Transaction {
2955
2941
  }
2956
2942
 
2957
2943
  const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
2944
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
2945
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2958
2946
  const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
2959
2947
  const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
2960
2948
  const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
2949
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
2950
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
2961
2951
  const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
2962
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2963
2952
 
2964
2953
  /**
2965
2954
  * Sign, send and confirm a transaction.
@@ -2975,13 +2964,14 @@ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions111111111111
2975
2964
  async function sendAndConfirmTransaction(connection, transaction, signers, options) {
2976
2965
  const sendOptions = options && {
2977
2966
  skipPreflight: options.skipPreflight,
2978
- preflightCommitment: options.preflightCommitment || options.commitment
2967
+ preflightCommitment: options.preflightCommitment || options.commitment,
2968
+ maxRetries: options.maxRetries
2979
2969
  };
2980
2970
  const signature = await connection.sendTransaction(transaction, signers, sendOptions);
2981
2971
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2982
2972
 
2983
2973
  if (status.err) {
2984
- throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
2974
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
2985
2975
  }
2986
2976
 
2987
2977
  return signature;
@@ -3024,7 +3014,7 @@ function decodeData(type, buffer) {
3024
3014
  }
3025
3015
 
3026
3016
  if (data.instruction !== type.index) {
3027
- throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
3017
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
3028
3018
  }
3029
3019
 
3030
3020
  return data;
@@ -3058,12 +3048,9 @@ class NonceAccount {
3058
3048
  * @internal
3059
3049
  */
3060
3050
  constructor(args) {
3061
- _defineProperty__default["default"](this, "authorizedPubkey", void 0);
3062
-
3063
- _defineProperty__default["default"](this, "nonce", void 0);
3064
-
3065
- _defineProperty__default["default"](this, "feeCalculator", void 0);
3066
-
3051
+ this.authorizedPubkey = void 0;
3052
+ this.nonce = void 0;
3053
+ this.feeCalculator = void 0;
3067
3054
  this.authorizedPubkey = args.authorizedPubkey;
3068
3055
  this.nonce = args.nonce;
3069
3056
  this.feeCalculator = args.feeCalculator;
@@ -3364,7 +3351,7 @@ class SystemInstruction {
3364
3351
 
3365
3352
  static checkKeyLength(keys, expectedLength) {
3366
3353
  if (keys.length < expectedLength) {
3367
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
3354
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
3368
3355
  }
3369
3356
  }
3370
3357
 
@@ -3796,8 +3783,7 @@ class SystemProgram {
3796
3783
  }
3797
3784
 
3798
3785
  }
3799
-
3800
- _defineProperty__default["default"](SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3786
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3801
3787
 
3802
3788
  // rest of the Transaction fields
3803
3789
  //
@@ -3966,8 +3952,7 @@ class Loader {
3966
3952
  }
3967
3953
 
3968
3954
  }
3969
-
3970
- _defineProperty__default["default"](Loader, "chunkSize", CHUNK_SIZE);
3955
+ Loader.chunkSize = CHUNK_SIZE;
3971
3956
 
3972
3957
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
3973
3958
  /**
@@ -4018,14 +4003,10 @@ class AgentManager {
4018
4003
  }
4019
4004
 
4020
4005
  constructor(useHttps) {
4021
- _defineProperty__default["default"](this, "_agent", void 0);
4022
-
4023
- _defineProperty__default["default"](this, "_activeRequests", 0);
4024
-
4025
- _defineProperty__default["default"](this, "_destroyTimeout", null);
4026
-
4027
- _defineProperty__default["default"](this, "_useHttps", void 0);
4028
-
4006
+ this._agent = void 0;
4007
+ this._activeRequests = 0;
4008
+ this._destroyTimeout = null;
4009
+ this._useHttps = void 0;
4029
4010
  this._useHttps = useHttps === true;
4030
4011
  this._agent = AgentManager._newAgent(this._useHttps);
4031
4012
  }
@@ -4098,16 +4079,11 @@ class EpochSchedule {
4098
4079
 
4099
4080
  /** The first slot of `firstNormalEpoch` */
4100
4081
  constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
4101
- _defineProperty__default["default"](this, "slotsPerEpoch", void 0);
4102
-
4103
- _defineProperty__default["default"](this, "leaderScheduleSlotOffset", void 0);
4104
-
4105
- _defineProperty__default["default"](this, "warmup", void 0);
4106
-
4107
- _defineProperty__default["default"](this, "firstNormalEpoch", void 0);
4108
-
4109
- _defineProperty__default["default"](this, "firstNormalSlot", void 0);
4110
-
4082
+ this.slotsPerEpoch = void 0;
4083
+ this.leaderScheduleSlotOffset = void 0;
4084
+ this.warmup = void 0;
4085
+ this.firstNormalEpoch = void 0;
4086
+ this.firstNormalSlot = void 0;
4111
4087
  this.slotsPerEpoch = slotsPerEpoch;
4112
4088
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
4113
4089
  this.warmup = warmup;
@@ -4159,9 +4135,7 @@ class EpochSchedule {
4159
4135
  class SendTransactionError extends Error {
4160
4136
  constructor(message, logs) {
4161
4137
  super(message);
4162
-
4163
- _defineProperty__default["default"](this, "logs", void 0);
4164
-
4138
+ this.logs = void 0;
4165
4139
  this.logs = logs;
4166
4140
  }
4167
4141
 
@@ -4393,16 +4367,15 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4393
4367
  let fetchWithMiddleware;
4394
4368
 
4395
4369
  if (fetchMiddleware) {
4396
- fetchWithMiddleware = (url, options) => {
4397
- return new Promise((resolve, reject) => {
4398
- fetchMiddleware(url, options, async (url, options) => {
4399
- try {
4400
- resolve(await fetch__default["default"](url, options));
4401
- } catch (error) {
4402
- reject(error);
4403
- }
4404
- });
4370
+ fetchWithMiddleware = async (url, options) => {
4371
+ const modifiedFetchArgs = await new Promise((resolve, reject) => {
4372
+ try {
4373
+ fetchMiddleware(url, options, (modifiedUrl, modifiedOptions) => resolve([modifiedUrl, modifiedOptions]));
4374
+ } catch (error) {
4375
+ reject(error);
4376
+ }
4405
4377
  });
4378
+ return await fetch__default["default"](...modifiedFetchArgs);
4406
4379
  };
4407
4380
  }
4408
4381
 
@@ -4445,7 +4418,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4445
4418
  break;
4446
4419
  }
4447
4420
 
4448
- console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
4421
+ console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
4449
4422
  await sleep(waitTime);
4450
4423
  waitTime *= 2;
4451
4424
  }
@@ -4455,7 +4428,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4455
4428
  if (res.ok) {
4456
4429
  callback(null, text);
4457
4430
  } else {
4458
- callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
4431
+ callback(new Error(`${res.status} ${res.statusText}: ${text}`));
4459
4432
  }
4460
4433
  } catch (err) {
4461
4434
  if (err instanceof Error) callback(err);
@@ -4896,6 +4869,7 @@ const ParsedConfirmedTransactionResult = superstruct.type({
4896
4869
  const TokenBalanceResult = superstruct.type({
4897
4870
  accountIndex: superstruct.number(),
4898
4871
  mint: superstruct.string(),
4872
+ owner: superstruct.optional(superstruct.string()),
4899
4873
  uiTokenAmount: TokenAmountResult
4900
4874
  });
4901
4875
  /**
@@ -4936,8 +4910,31 @@ const ParsedConfirmedTransactionMetaResult = superstruct.type({
4936
4910
  preTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult))),
4937
4911
  postTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult)))
4938
4912
  });
4913
+ /**
4914
+ * Expected JSON RPC response for the "getBlock" message
4915
+ */
4916
+
4917
+ const GetBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
4918
+ blockhash: superstruct.string(),
4919
+ previousBlockhash: superstruct.string(),
4920
+ parentSlot: superstruct.number(),
4921
+ transactions: superstruct.array(superstruct.type({
4922
+ transaction: ConfirmedTransactionResult,
4923
+ meta: superstruct.nullable(ConfirmedTransactionMetaResult)
4924
+ })),
4925
+ rewards: superstruct.optional(superstruct.array(superstruct.type({
4926
+ pubkey: superstruct.string(),
4927
+ lamports: superstruct.number(),
4928
+ postBalance: superstruct.nullable(superstruct.number()),
4929
+ rewardType: superstruct.nullable(superstruct.string())
4930
+ }))),
4931
+ blockTime: superstruct.nullable(superstruct.number()),
4932
+ blockHeight: superstruct.nullable(superstruct.number())
4933
+ })));
4939
4934
  /**
4940
4935
  * Expected JSON RPC response for the "getConfirmedBlock" message
4936
+ *
4937
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link GetBlockRpcResult} instead.
4941
4938
  */
4942
4939
 
4943
4940
  const GetConfirmedBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
@@ -4957,10 +4954,10 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruc
4957
4954
  blockTime: superstruct.nullable(superstruct.number())
4958
4955
  })));
4959
4956
  /**
4960
- * Expected JSON RPC response for the "getConfirmedBlockSignatures" message
4957
+ * Expected JSON RPC response for the "getBlock" message
4961
4958
  */
4962
4959
 
4963
- const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
4960
+ const GetBlockSignaturesRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
4964
4961
  blockhash: superstruct.string(),
4965
4962
  previousBlockhash: superstruct.string(),
4966
4963
  parentSlot: superstruct.number(),
@@ -4968,20 +4965,20 @@ const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(superstruct.nullable(
4968
4965
  blockTime: superstruct.nullable(superstruct.number())
4969
4966
  })));
4970
4967
  /**
4971
- * Expected JSON RPC response for the "getConfirmedTransaction" message
4968
+ * Expected JSON RPC response for the "getTransaction" message
4972
4969
  */
4973
4970
 
4974
- const GetConfirmedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
4971
+ const GetTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
4975
4972
  slot: superstruct.number(),
4976
4973
  meta: ConfirmedTransactionMetaResult,
4977
4974
  blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
4978
4975
  transaction: ConfirmedTransactionResult
4979
4976
  })));
4980
4977
  /**
4981
- * Expected JSON RPC response for the "getConfirmedTransaction" message
4978
+ * Expected parsed JSON RPC response for the "getTransaction" message
4982
4979
  */
4983
4980
 
4984
- const GetParsedConfirmedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
4981
+ const GetParsedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
4985
4982
  slot: superstruct.number(),
4986
4983
  transaction: ParsedConfirmedTransactionResult,
4987
4984
  meta: superstruct.nullable(ParsedConfirmedTransactionMetaResult),
@@ -4989,6 +4986,8 @@ const GetParsedConfirmedTransactionRpcResult = jsonRpcResult(superstruct.nullabl
4989
4986
  })));
4990
4987
  /**
4991
4988
  * Expected JSON RPC response for the "getRecentBlockhash" message
4989
+ *
4990
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link GetLatestBlockhashRpcResult} instead.
4992
4991
  */
4993
4992
 
4994
4993
  const GetRecentBlockhashAndContextRpcResult = jsonRpcResultAndContext(superstruct.type({
@@ -4997,6 +4996,14 @@ const GetRecentBlockhashAndContextRpcResult = jsonRpcResultAndContext(superstruc
4997
4996
  lamportsPerSignature: superstruct.number()
4998
4997
  })
4999
4998
  }));
4999
+ /**
5000
+ * Expected JSON RPC response for the "getLatestBlockhash" message
5001
+ */
5002
+
5003
+ const GetLatestBlockhashRpcResult = jsonRpcResultAndContext(superstruct.type({
5004
+ blockhash: superstruct.string(),
5005
+ lastValidBlockHeight: superstruct.number()
5006
+ }));
5000
5007
  const PerfSampleResult = superstruct.type({
5001
5008
  slot: superstruct.number(),
5002
5009
  numTransactions: superstruct.number(),
@@ -5121,67 +5128,39 @@ class Connection {
5121
5128
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
5122
5129
  */
5123
5130
  constructor(endpoint, commitmentOrConfig) {
5124
- _defineProperty__default["default"](this, "_commitment", void 0);
5125
-
5126
- _defineProperty__default["default"](this, "_confirmTransactionInitialTimeout", void 0);
5127
-
5128
- _defineProperty__default["default"](this, "_rpcEndpoint", void 0);
5129
-
5130
- _defineProperty__default["default"](this, "_rpcWsEndpoint", void 0);
5131
-
5132
- _defineProperty__default["default"](this, "_rpcClient", void 0);
5133
-
5134
- _defineProperty__default["default"](this, "_rpcRequest", void 0);
5135
-
5136
- _defineProperty__default["default"](this, "_rpcBatchRequest", void 0);
5137
-
5138
- _defineProperty__default["default"](this, "_rpcWebSocket", void 0);
5139
-
5140
- _defineProperty__default["default"](this, "_rpcWebSocketConnected", false);
5141
-
5142
- _defineProperty__default["default"](this, "_rpcWebSocketHeartbeat", null);
5143
-
5144
- _defineProperty__default["default"](this, "_rpcWebSocketIdleTimeout", null);
5145
-
5146
- _defineProperty__default["default"](this, "_disableBlockhashCaching", false);
5147
-
5148
- _defineProperty__default["default"](this, "_pollingBlockhash", false);
5149
-
5150
- _defineProperty__default["default"](this, "_blockhashInfo", {
5131
+ this._commitment = void 0;
5132
+ this._confirmTransactionInitialTimeout = void 0;
5133
+ this._rpcEndpoint = void 0;
5134
+ this._rpcWsEndpoint = void 0;
5135
+ this._rpcClient = void 0;
5136
+ this._rpcRequest = void 0;
5137
+ this._rpcBatchRequest = void 0;
5138
+ this._rpcWebSocket = void 0;
5139
+ this._rpcWebSocketConnected = false;
5140
+ this._rpcWebSocketHeartbeat = null;
5141
+ this._rpcWebSocketIdleTimeout = null;
5142
+ this._disableBlockhashCaching = false;
5143
+ this._pollingBlockhash = false;
5144
+ this._blockhashInfo = {
5151
5145
  recentBlockhash: null,
5152
5146
  lastFetch: 0,
5153
5147
  transactionSignatures: [],
5154
5148
  simulatedSignatures: []
5155
- });
5156
-
5157
- _defineProperty__default["default"](this, "_accountChangeSubscriptionCounter", 0);
5158
-
5159
- _defineProperty__default["default"](this, "_accountChangeSubscriptions", {});
5160
-
5161
- _defineProperty__default["default"](this, "_programAccountChangeSubscriptionCounter", 0);
5162
-
5163
- _defineProperty__default["default"](this, "_programAccountChangeSubscriptions", {});
5164
-
5165
- _defineProperty__default["default"](this, "_rootSubscriptionCounter", 0);
5166
-
5167
- _defineProperty__default["default"](this, "_rootSubscriptions", {});
5168
-
5169
- _defineProperty__default["default"](this, "_signatureSubscriptionCounter", 0);
5170
-
5171
- _defineProperty__default["default"](this, "_signatureSubscriptions", {});
5172
-
5173
- _defineProperty__default["default"](this, "_slotSubscriptionCounter", 0);
5174
-
5175
- _defineProperty__default["default"](this, "_slotSubscriptions", {});
5176
-
5177
- _defineProperty__default["default"](this, "_logsSubscriptionCounter", 0);
5178
-
5179
- _defineProperty__default["default"](this, "_logsSubscriptions", {});
5180
-
5181
- _defineProperty__default["default"](this, "_slotUpdateSubscriptionCounter", 0);
5182
-
5183
- _defineProperty__default["default"](this, "_slotUpdateSubscriptions", {});
5184
-
5149
+ };
5150
+ this._accountChangeSubscriptionCounter = 0;
5151
+ this._accountChangeSubscriptions = {};
5152
+ this._programAccountChangeSubscriptionCounter = 0;
5153
+ this._programAccountChangeSubscriptions = {};
5154
+ this._rootSubscriptionCounter = 0;
5155
+ this._rootSubscriptions = {};
5156
+ this._signatureSubscriptionCounter = 0;
5157
+ this._signatureSubscriptions = {};
5158
+ this._slotSubscriptionCounter = 0;
5159
+ this._slotSubscriptions = {};
5160
+ this._logsSubscriptionCounter = 0;
5161
+ this._logsSubscriptions = {};
5162
+ this._slotUpdateSubscriptionCounter = 0;
5163
+ this._slotUpdateSubscriptions = {};
5185
5164
  let url = new URL(endpoint);
5186
5165
  const useHttps = url.protocol === 'https:';
5187
5166
  let wsEndpoint;
@@ -5527,13 +5506,25 @@ class Connection {
5527
5506
  */
5528
5507
 
5529
5508
 
5530
- async getMultipleAccountsInfo(publicKeys, commitment) {
5509
+ async getMultipleAccountsInfo(publicKeys, configOrCommitment) {
5531
5510
  const keys = publicKeys.map(key => key.toBase58());
5511
+ let commitment;
5512
+ let encoding = 'base64';
5513
+
5514
+ if (configOrCommitment) {
5515
+ if (typeof configOrCommitment === 'string') {
5516
+ commitment = configOrCommitment;
5517
+ encoding = 'base64';
5518
+ } else {
5519
+ commitment = configOrCommitment.commitment;
5520
+ encoding = configOrCommitment.encoding || 'base64';
5521
+ }
5522
+ }
5532
5523
 
5533
- const args = this._buildArgs([keys], commitment, 'base64');
5524
+ const args = this._buildArgs([keys], commitment, encoding);
5534
5525
 
5535
5526
  const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
5536
- const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
5527
+ const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(ParsedAccountInfoResult))));
5537
5528
 
5538
5529
  if ('error' in res) {
5539
5530
  throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
@@ -5555,7 +5546,7 @@ class Connection {
5555
5546
  const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
5556
5547
 
5557
5548
  if ('error' in res) {
5558
- throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
5549
+ throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
5559
5550
  }
5560
5551
 
5561
5552
  return res.result;
@@ -5691,7 +5682,7 @@ class Connection {
5691
5682
 
5692
5683
  if (response === null) {
5693
5684
  const duration = (Date.now() - start) / 1000;
5694
- throw new Error("Transaction was not confirmed in ".concat(duration.toFixed(2), " seconds. It is unknown if it succeeded or failed. Check signature ").concat(signature, " using the Solana Explorer or CLI tools."));
5685
+ throw new Error(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`);
5695
5686
  }
5696
5687
 
5697
5688
  return response;
@@ -5957,6 +5948,8 @@ class Connection {
5957
5948
  /**
5958
5949
  * Fetch a recent blockhash from the cluster, return with context
5959
5950
  * @return {Promise<RpcResponseAndContext<{blockhash: Blockhash, feeCalculator: FeeCalculator}>>}
5951
+ *
5952
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
5960
5953
  */
5961
5954
 
5962
5955
 
@@ -5992,6 +5985,8 @@ class Connection {
5992
5985
  }
5993
5986
  /**
5994
5987
  * Fetch the fee calculator for a recent blockhash from the cluster, return with context
5988
+ *
5989
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getFeeForMessage} instead.
5995
5990
  */
5996
5991
 
5997
5992
 
@@ -6014,9 +6009,34 @@ class Connection {
6014
6009
  value: value !== null ? value.feeCalculator : null
6015
6010
  };
6016
6011
  }
6012
+ /**
6013
+ * Fetch the fee for a message from the cluster, return with context
6014
+ */
6015
+
6016
+
6017
+ async getFeeForMessage(message, commitment) {
6018
+ const wireMessage = message.serialize().toString('base64');
6019
+
6020
+ const args = this._buildArgs([wireMessage], commitment);
6021
+
6022
+ const unsafeRes = await this._rpcRequest('getFeeForMessage', args);
6023
+ const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
6024
+
6025
+ if ('error' in res) {
6026
+ throw new Error('failed to get slot: ' + res.error.message);
6027
+ }
6028
+
6029
+ if (res.result === null) {
6030
+ throw new Error('invalid blockhash');
6031
+ }
6032
+
6033
+ return res.result;
6034
+ }
6017
6035
  /**
6018
6036
  * Fetch a recent blockhash from the cluster
6019
6037
  * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
6038
+ *
6039
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
6020
6040
  */
6021
6041
 
6022
6042
 
@@ -6028,6 +6048,38 @@ class Connection {
6028
6048
  throw new Error('failed to get recent blockhash: ' + e);
6029
6049
  }
6030
6050
  }
6051
+ /**
6052
+ * Fetch the latest blockhash from the cluster
6053
+ * @return {Promise<{blockhash: Blockhash, lastValidBlockHeight: number}>}
6054
+ */
6055
+
6056
+
6057
+ async getLatestBlockhash(commitment) {
6058
+ try {
6059
+ const res = await this.getLatestBlockhashAndContext(commitment);
6060
+ return res.value;
6061
+ } catch (e) {
6062
+ throw new Error('failed to get recent blockhash: ' + e);
6063
+ }
6064
+ }
6065
+ /**
6066
+ * Fetch the latest blockhash from the cluster
6067
+ * @return {Promise<{blockhash: Blockhash, lastValidBlockHeight: number}>}
6068
+ */
6069
+
6070
+
6071
+ async getLatestBlockhashAndContext(commitment) {
6072
+ const args = this._buildArgs([], commitment);
6073
+
6074
+ const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
6075
+ const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
6076
+
6077
+ if ('error' in res) {
6078
+ throw new Error('failed to get latest blockhash: ' + res.error.message);
6079
+ }
6080
+
6081
+ return res.result;
6082
+ }
6031
6083
  /**
6032
6084
  * Fetch the node version
6033
6085
  */
@@ -6066,8 +6118,8 @@ class Connection {
6066
6118
  async getBlock(slot, opts) {
6067
6119
  const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
6068
6120
 
6069
- const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
6070
- const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
6121
+ const unsafeRes = await this._rpcRequest('getBlock', args);
6122
+ const res = superstruct.create(unsafeRes, GetBlockRpcResult);
6071
6123
 
6072
6124
  if ('error' in res) {
6073
6125
  throw new Error('failed to get confirmed block: ' + res.error.message);
@@ -6091,18 +6143,18 @@ class Connection {
6091
6143
  };
6092
6144
  }
6093
6145
  /**
6094
- * Fetch a processed transaction from the cluster.
6146
+ * Fetch a confirmed or finalized transaction from the cluster.
6095
6147
  */
6096
6148
 
6097
6149
 
6098
6150
  async getTransaction(signature, opts) {
6099
6151
  const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
6100
6152
 
6101
- const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
6102
- const res = superstruct.create(unsafeRes, GetConfirmedTransactionRpcResult);
6153
+ const unsafeRes = await this._rpcRequest('getTransaction', args);
6154
+ const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
6103
6155
 
6104
6156
  if ('error' in res) {
6105
- throw new Error('failed to get confirmed transaction: ' + res.error.message);
6157
+ throw new Error('failed to get transaction: ' + res.error.message);
6106
6158
  }
6107
6159
 
6108
6160
  const result = res.result;
@@ -6113,6 +6165,49 @@ class Connection {
6113
6165
  }
6114
6166
  };
6115
6167
  }
6168
+ /**
6169
+ * Fetch parsed transaction details for a confirmed or finalized transaction
6170
+ */
6171
+
6172
+
6173
+ async getParsedTransaction(signature, commitment) {
6174
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
6175
+
6176
+ const unsafeRes = await this._rpcRequest('getTransaction', args);
6177
+ const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
6178
+
6179
+ if ('error' in res) {
6180
+ throw new Error('failed to get transaction: ' + res.error.message);
6181
+ }
6182
+
6183
+ return res.result;
6184
+ }
6185
+ /**
6186
+ * Fetch parsed transaction details for a batch of confirmed transactions
6187
+ */
6188
+
6189
+
6190
+ async getParsedTransactions(signatures, commitment) {
6191
+ const batch = signatures.map(signature => {
6192
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
6193
+
6194
+ return {
6195
+ methodName: 'getTransaction',
6196
+ args
6197
+ };
6198
+ });
6199
+ const unsafeRes = await this._rpcBatchRequest(batch);
6200
+ const res = unsafeRes.map(unsafeRes => {
6201
+ const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
6202
+
6203
+ if ('error' in res) {
6204
+ throw new Error('failed to get transactions: ' + res.error.message);
6205
+ }
6206
+
6207
+ return res.result;
6208
+ });
6209
+ return res;
6210
+ }
6116
6211
  /**
6117
6212
  * Fetch a list of Transactions and transaction statuses from the cluster
6118
6213
  * for a confirmed block.
@@ -6122,18 +6217,39 @@ class Connection {
6122
6217
 
6123
6218
 
6124
6219
  async getConfirmedBlock(slot, commitment) {
6125
- const result = await this.getBlock(slot, {
6126
- commitment
6127
- });
6220
+ const args = this._buildArgsAtLeastConfirmed([slot], commitment);
6221
+
6222
+ const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
6223
+ const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
6224
+
6225
+ if ('error' in res) {
6226
+ throw new Error('failed to get confirmed block: ' + res.error.message);
6227
+ }
6228
+
6229
+ const result = res.result;
6128
6230
 
6129
6231
  if (!result) {
6130
6232
  throw new Error('Confirmed block ' + slot + ' not found');
6131
6233
  }
6132
6234
 
6133
- return { ...result,
6235
+ const block = { ...result,
6134
6236
  transactions: result.transactions.map(({
6135
6237
  transaction,
6136
6238
  meta
6239
+ }) => {
6240
+ const message = new Message(transaction.message);
6241
+ return {
6242
+ meta,
6243
+ transaction: { ...transaction,
6244
+ message
6245
+ }
6246
+ };
6247
+ })
6248
+ };
6249
+ return { ...block,
6250
+ transactions: block.transactions.map(({
6251
+ transaction,
6252
+ meta
6137
6253
  }) => {
6138
6254
  return {
6139
6255
  meta,
@@ -6150,7 +6266,7 @@ class Connection {
6150
6266
  async getBlocks(startSlot, endSlot, commitment) {
6151
6267
  const args = this._buildArgsAtLeastConfirmed(endSlot !== undefined ? [startSlot, endSlot] : [startSlot], commitment);
6152
6268
 
6153
- const unsafeRes = await this._rpcRequest('getConfirmedBlocks', args);
6269
+ const unsafeRes = await this._rpcRequest('getBlocks', args);
6154
6270
  const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(superstruct.number())));
6155
6271
 
6156
6272
  if ('error' in res) {
@@ -6159,8 +6275,36 @@ class Connection {
6159
6275
 
6160
6276
  return res.result;
6161
6277
  }
6278
+ /**
6279
+ * Fetch a list of Signatures from the cluster for a block, excluding rewards
6280
+ */
6281
+
6282
+
6283
+ async getBlockSignatures(slot, commitment) {
6284
+ const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined, {
6285
+ transactionDetails: 'signatures',
6286
+ rewards: false
6287
+ });
6288
+
6289
+ const unsafeRes = await this._rpcRequest('getBlock', args);
6290
+ const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
6291
+
6292
+ if ('error' in res) {
6293
+ throw new Error('failed to get block: ' + res.error.message);
6294
+ }
6295
+
6296
+ const result = res.result;
6297
+
6298
+ if (!result) {
6299
+ throw new Error('Block ' + slot + ' not found');
6300
+ }
6301
+
6302
+ return result;
6303
+ }
6162
6304
  /**
6163
6305
  * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
6306
+ *
6307
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getBlockSignatures} instead.
6164
6308
  */
6165
6309
 
6166
6310
 
@@ -6171,7 +6315,7 @@ class Connection {
6171
6315
  });
6172
6316
 
6173
6317
  const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
6174
- const res = superstruct.create(unsafeRes, GetConfirmedBlockSignaturesRpcResult);
6318
+ const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
6175
6319
 
6176
6320
  if ('error' in res) {
6177
6321
  throw new Error('failed to get confirmed block: ' + res.error.message);
@@ -6187,24 +6331,33 @@ class Connection {
6187
6331
  }
6188
6332
  /**
6189
6333
  * Fetch a transaction details for a confirmed transaction
6334
+ *
6335
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getTransaction} instead.
6190
6336
  */
6191
6337
 
6192
6338
 
6193
6339
  async getConfirmedTransaction(signature, commitment) {
6194
- const result = await this.getTransaction(signature, {
6195
- commitment
6196
- });
6340
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment);
6341
+
6342
+ const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
6343
+ const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
6344
+
6345
+ if ('error' in res) {
6346
+ throw new Error('failed to get transaction: ' + res.error.message);
6347
+ }
6348
+
6349
+ const result = res.result;
6197
6350
  if (!result) return result;
6198
- const {
6199
- message,
6200
- signatures
6201
- } = result.transaction;
6351
+ const message = new Message(result.transaction.message);
6352
+ const signatures = result.transaction.signatures;
6202
6353
  return { ...result,
6203
6354
  transaction: Transaction.populate(message, signatures)
6204
6355
  };
6205
6356
  }
6206
6357
  /**
6207
6358
  * Fetch parsed transaction details for a confirmed transaction
6359
+ *
6360
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransaction} instead.
6208
6361
  */
6209
6362
 
6210
6363
 
@@ -6212,7 +6365,7 @@ class Connection {
6212
6365
  const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
6213
6366
 
6214
6367
  const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
6215
- const res = superstruct.create(unsafeRes, GetParsedConfirmedTransactionRpcResult);
6368
+ const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
6216
6369
 
6217
6370
  if ('error' in res) {
6218
6371
  throw new Error('failed to get confirmed transaction: ' + res.error.message);
@@ -6222,6 +6375,8 @@ class Connection {
6222
6375
  }
6223
6376
  /**
6224
6377
  * Fetch parsed transaction details for a batch of confirmed transactions
6378
+ *
6379
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransactions} instead.
6225
6380
  */
6226
6381
 
6227
6382
 
@@ -6236,7 +6391,7 @@ class Connection {
6236
6391
  });
6237
6392
  const unsafeRes = await this._rpcBatchRequest(batch);
6238
6393
  const res = unsafeRes.map(unsafeRes => {
6239
- const res = superstruct.create(unsafeRes, GetParsedConfirmedTransactionRpcResult);
6394
+ const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
6240
6395
 
6241
6396
  if ('error' in res) {
6242
6397
  throw new Error('failed to get confirmed transactions: ' + res.error.message);
@@ -6465,7 +6620,7 @@ class Connection {
6465
6620
  await sleep(MS_PER_SLOT / 2);
6466
6621
  }
6467
6622
 
6468
- throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
6623
+ throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
6469
6624
  } finally {
6470
6625
  this._pollingBlockhash = false;
6471
6626
  }
@@ -6626,6 +6781,10 @@ class Connection {
6626
6781
  const skipPreflight = options && options.skipPreflight;
6627
6782
  const preflightCommitment = options && options.preflightCommitment || this.commitment;
6628
6783
 
6784
+ if (options && options.maxRetries) {
6785
+ config.maxRetries = options.maxRetries;
6786
+ }
6787
+
6629
6788
  if (skipPreflight) {
6630
6789
  config.skipPreflight = skipPreflight;
6631
6790
  }
@@ -6722,7 +6881,7 @@ class Connection {
6722
6881
  }
6723
6882
 
6724
6883
  if (err instanceof Error) {
6725
- console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
6884
+ console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
6726
6885
  }
6727
6886
  }
6728
6887
  }
@@ -6742,7 +6901,7 @@ class Connection {
6742
6901
  await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
6743
6902
  } catch (err) {
6744
6903
  if (err instanceof Error) {
6745
- console.error("".concat(rpcMethod, " error:"), err.message);
6904
+ console.error(`${rpcMethod} error:`, err.message);
6746
6905
  }
6747
6906
  }
6748
6907
  }
@@ -6907,7 +7066,7 @@ class Connection {
6907
7066
 
6908
7067
  this._updateSubscriptions();
6909
7068
  } else {
6910
- throw new Error("Unknown account change id: ".concat(id));
7069
+ throw new Error(`Unknown account change id: ${id}`);
6911
7070
  }
6912
7071
  }
6913
7072
  /**
@@ -6973,7 +7132,7 @@ class Connection {
6973
7132
 
6974
7133
  this._updateSubscriptions();
6975
7134
  } else {
6976
- throw new Error("Unknown program account change id: ".concat(id));
7135
+ throw new Error(`Unknown program account change id: ${id}`);
6977
7136
  }
6978
7137
  }
6979
7138
  /**
@@ -7003,7 +7162,7 @@ class Connection {
7003
7162
 
7004
7163
  async removeOnLogsListener(id) {
7005
7164
  if (!this._logsSubscriptions[id]) {
7006
- throw new Error("Unknown logs id: ".concat(id));
7165
+ throw new Error(`Unknown logs id: ${id}`);
7007
7166
  }
7008
7167
 
7009
7168
  const subInfo = this._logsSubscriptions[id];
@@ -7079,7 +7238,7 @@ class Connection {
7079
7238
 
7080
7239
  this._updateSubscriptions();
7081
7240
  } else {
7082
- throw new Error("Unknown slot change id: ".concat(id));
7241
+ throw new Error(`Unknown slot change id: ${id}`);
7083
7242
  }
7084
7243
  }
7085
7244
  /**
@@ -7132,7 +7291,7 @@ class Connection {
7132
7291
 
7133
7292
  this._updateSubscriptions();
7134
7293
  } else {
7135
- throw new Error("Unknown slot update id: ".concat(id));
7294
+ throw new Error(`Unknown slot update id: ${id}`);
7136
7295
  }
7137
7296
  }
7138
7297
 
@@ -7273,7 +7432,7 @@ class Connection {
7273
7432
 
7274
7433
  this._updateSubscriptions();
7275
7434
  } else {
7276
- throw new Error("Unknown signature result id: ".concat(id));
7435
+ throw new Error(`Unknown signature result id: ${id}`);
7277
7436
  }
7278
7437
  }
7279
7438
  /**
@@ -7325,7 +7484,7 @@ class Connection {
7325
7484
 
7326
7485
  this._updateSubscriptions();
7327
7486
  } else {
7328
- throw new Error("Unknown root change id: ".concat(id));
7487
+ throw new Error(`Unknown root change id: ${id}`);
7329
7488
  }
7330
7489
  }
7331
7490
 
@@ -7346,12 +7505,12 @@ class Keypair {
7346
7505
  * @param keypair ed25519 keypair
7347
7506
  */
7348
7507
  constructor(keypair) {
7349
- _defineProperty__default["default"](this, "_keypair", void 0);
7508
+ this._keypair = void 0;
7350
7509
 
7351
7510
  if (keypair) {
7352
7511
  this._keypair = keypair;
7353
7512
  } else {
7354
- this._keypair = nacl__namespace.sign.keyPair();
7513
+ this._keypair = nacl__default["default"].sign.keyPair();
7355
7514
  }
7356
7515
  }
7357
7516
  /**
@@ -7360,7 +7519,7 @@ class Keypair {
7360
7519
 
7361
7520
 
7362
7521
  static generate() {
7363
- return new Keypair(nacl__namespace.sign.keyPair());
7522
+ return new Keypair(nacl__default["default"].sign.keyPair());
7364
7523
  }
7365
7524
  /**
7366
7525
  * Create a keypair from a raw secret key byte array.
@@ -7377,14 +7536,14 @@ class Keypair {
7377
7536
 
7378
7537
 
7379
7538
  static fromSecretKey(secretKey, options) {
7380
- const keypair = nacl__namespace.sign.keyPair.fromSecretKey(secretKey);
7539
+ const keypair = nacl__default["default"].sign.keyPair.fromSecretKey(secretKey);
7381
7540
 
7382
7541
  if (!options || !options.skipValidation) {
7383
7542
  const encoder = new TextEncoder();
7384
7543
  const signData = encoder.encode('@solana/web3.js-validation-v1');
7385
- const signature = nacl__namespace.sign.detached(signData, keypair.secretKey);
7544
+ const signature = nacl__default["default"].sign.detached(signData, keypair.secretKey);
7386
7545
 
7387
- if (!nacl__namespace.sign.detached.verify(signData, signature, keypair.publicKey)) {
7546
+ if (!nacl__default["default"].sign.detached.verify(signData, signature, keypair.publicKey)) {
7388
7547
  throw new Error('provided secretKey is invalid');
7389
7548
  }
7390
7549
  }
@@ -7399,7 +7558,7 @@ class Keypair {
7399
7558
 
7400
7559
 
7401
7560
  static fromSeed(seed) {
7402
- return new Keypair(nacl__namespace.sign.keyPair.fromSeed(seed));
7561
+ return new Keypair(nacl__default["default"].sign.keyPair.fromSeed(seed));
7403
7562
  }
7404
7563
  /**
7405
7564
  * The public key for this keypair
@@ -7450,8 +7609,8 @@ class Ed25519Program {
7450
7609
  signature,
7451
7610
  instructionIndex
7452
7611
  } = params;
7453
- assert(publicKey.length === PUBLIC_KEY_BYTES$1, "Public Key must be ".concat(PUBLIC_KEY_BYTES$1, " bytes but received ").concat(publicKey.length, " bytes"));
7454
- assert(signature.length === SIGNATURE_BYTES, "Signature must be ".concat(SIGNATURE_BYTES, " bytes but received ").concat(signature.length, " bytes"));
7612
+ assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
7613
+ assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
7455
7614
  const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
7456
7615
  const signatureOffset = publicKeyOffset + publicKey.length;
7457
7616
  const messageDataOffset = signatureOffset + signature.length;
@@ -7489,7 +7648,7 @@ class Ed25519Program {
7489
7648
  message,
7490
7649
  instructionIndex
7491
7650
  } = params;
7492
- assert(privateKey.length === PRIVATE_KEY_BYTES$1, "Private key must be ".concat(PRIVATE_KEY_BYTES$1, " bytes but received ").concat(privateKey.length, " bytes"));
7651
+ assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
7493
7652
 
7494
7653
  try {
7495
7654
  const keypair = Keypair.fromSecretKey(privateKey);
@@ -7502,13 +7661,12 @@ class Ed25519Program {
7502
7661
  instructionIndex
7503
7662
  });
7504
7663
  } catch (error) {
7505
- throw new Error("Error creating instruction; ".concat(error));
7664
+ throw new Error(`Error creating instruction; ${error}`);
7506
7665
  }
7507
7666
  }
7508
7667
 
7509
7668
  }
7510
-
7511
- _defineProperty__default["default"](Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7669
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7512
7670
 
7513
7671
  /**
7514
7672
  * Address of the stake config account which configures the rate
@@ -7531,10 +7689,8 @@ class Authorized {
7531
7689
  * @param withdrawer the withdraw authority
7532
7690
  */
7533
7691
  constructor(staker, withdrawer) {
7534
- _defineProperty__default["default"](this, "staker", void 0);
7535
-
7536
- _defineProperty__default["default"](this, "withdrawer", void 0);
7537
-
7692
+ this.staker = void 0;
7693
+ this.withdrawer = void 0;
7538
7694
  this.staker = staker;
7539
7695
  this.withdrawer = withdrawer;
7540
7696
  }
@@ -7555,12 +7711,9 @@ class Lockup {
7555
7711
  * Create a new Lockup object
7556
7712
  */
7557
7713
  constructor(unixTimestamp, epoch, custodian) {
7558
- _defineProperty__default["default"](this, "unixTimestamp", void 0);
7559
-
7560
- _defineProperty__default["default"](this, "epoch", void 0);
7561
-
7562
- _defineProperty__default["default"](this, "custodian", void 0);
7563
-
7714
+ this.unixTimestamp = void 0;
7715
+ this.epoch = void 0;
7716
+ this.custodian = void 0;
7564
7717
  this.unixTimestamp = unixTimestamp;
7565
7718
  this.epoch = epoch;
7566
7719
  this.custodian = custodian;
@@ -7575,7 +7728,7 @@ class Lockup {
7575
7728
  * Create stake account transaction params
7576
7729
  */
7577
7730
 
7578
- _defineProperty__default["default"](Lockup, "default", new Lockup(0, 0, PublicKey.default));
7731
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
7579
7732
 
7580
7733
  /**
7581
7734
  * Stake Instruction class
@@ -7788,7 +7941,7 @@ class StakeInstruction {
7788
7941
 
7789
7942
  static checkKeyLength(keys, expectedLength) {
7790
7943
  if (keys.length < expectedLength) {
7791
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
7944
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
7792
7945
  }
7793
7946
  }
7794
7947
 
@@ -8263,10 +8416,8 @@ class StakeProgram {
8263
8416
  }
8264
8417
 
8265
8418
  }
8266
-
8267
- _defineProperty__default["default"](StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
8268
-
8269
- _defineProperty__default["default"](StakeProgram, "space", 200);
8419
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8420
+ StakeProgram.space = 200;
8270
8421
 
8271
8422
  const {
8272
8423
  publicKeyCreate,
@@ -8296,12 +8447,12 @@ class Secp256k1Program {
8296
8447
  * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
8297
8448
  */
8298
8449
  static publicKeyToEthAddress(publicKey) {
8299
- assert(publicKey.length === PUBLIC_KEY_BYTES, "Public key must be ".concat(PUBLIC_KEY_BYTES, " bytes but received ").concat(publicKey.length, " bytes"));
8450
+ assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8300
8451
 
8301
8452
  try {
8302
- return buffer.Buffer.from(jsSha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8453
+ return buffer.Buffer.from(sha3__default["default"].keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8303
8454
  } catch (error) {
8304
- throw new Error("Error constructing Ethereum address: ".concat(error));
8455
+ throw new Error(`Error constructing Ethereum address: ${error}`);
8305
8456
  }
8306
8457
  }
8307
8458
  /**
@@ -8352,7 +8503,7 @@ class Secp256k1Program {
8352
8503
  ethAddress = rawAddress;
8353
8504
  }
8354
8505
 
8355
- assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
8506
+ assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
8356
8507
  const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
8357
8508
  const ethAddressOffset = dataStart;
8358
8509
  const signatureOffset = dataStart + ethAddress.length;
@@ -8391,13 +8542,13 @@ class Secp256k1Program {
8391
8542
  message,
8392
8543
  instructionIndex
8393
8544
  } = params;
8394
- assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
8545
+ assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
8395
8546
 
8396
8547
  try {
8397
8548
  const privateKey = toBuffer(pkey);
8398
8549
  const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
8399
8550
 
8400
- const messageHash = buffer.Buffer.from(jsSha3.keccak_256.update(toBuffer(message)).digest());
8551
+ const messageHash = buffer.Buffer.from(sha3__default["default"].keccak_256.update(toBuffer(message)).digest());
8401
8552
  const {
8402
8553
  signature,
8403
8554
  recid: recoveryId
@@ -8410,13 +8561,12 @@ class Secp256k1Program {
8410
8561
  instructionIndex
8411
8562
  });
8412
8563
  } catch (error) {
8413
- throw new Error("Error creating instruction; ".concat(error));
8564
+ throw new Error(`Error creating instruction; ${error}`);
8414
8565
  }
8415
8566
  }
8416
8567
 
8417
8568
  }
8418
-
8419
- _defineProperty__default["default"](Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8569
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
8420
8570
 
8421
8571
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
8422
8572
  /**
@@ -8449,10 +8599,8 @@ class ValidatorInfo {
8449
8599
  * @param info validator information
8450
8600
  */
8451
8601
  constructor(key, info) {
8452
- _defineProperty__default["default"](this, "key", void 0);
8453
-
8454
- _defineProperty__default["default"](this, "info", void 0);
8455
-
8602
+ this.key = void 0;
8603
+ this.info = void 0;
8456
8604
  this.key = key;
8457
8605
  this.info = info;
8458
8606
  }
@@ -8504,9 +8652,10 @@ const VOTE_PROGRAM_ID = new PublicKey('Vote1111111111111111111111111111111111111
8504
8652
  *
8505
8653
  * @internal
8506
8654
  */
8507
- const VoteAccountLayout = BufferLayout__namespace.struct([publicKey('nodePubkey'), publicKey('authorizedVoterPubkey'), publicKey('authorizedWithdrawerPubkey'), BufferLayout__namespace.u8('commission'), BufferLayout__namespace.nu64(), // votes.length
8508
- BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('slot'), BufferLayout__namespace.u32('confirmationCount')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'votes'), BufferLayout__namespace.u8('rootSlotValid'), BufferLayout__namespace.nu64('rootSlot'), BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('lastEpochCredits'), BufferLayout__namespace.nu64(), // epochCredits.length
8509
- BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('prevCredits')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'epochCredits')]);
8655
+ const VoteAccountLayout = BufferLayout__namespace.struct([publicKey('nodePubkey'), publicKey('authorizedWithdrawer'), BufferLayout__namespace.u8('commission'), BufferLayout__namespace.nu64(), // votes.length
8656
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('slot'), BufferLayout__namespace.u32('confirmationCount')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'votes'), BufferLayout__namespace.u8('rootSlotValid'), BufferLayout__namespace.nu64('rootSlot'), BufferLayout__namespace.nu64(), // authorizedVoters.length
8657
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('epoch'), publicKey('authorizedVoter')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'authorizedVoters'), BufferLayout__namespace.struct([BufferLayout__namespace.seq(BufferLayout__namespace.struct([publicKey('authorizedPubkey'), BufferLayout__namespace.nu64('epochOfLastAuthorizedSwitch'), BufferLayout__namespace.nu64('targetEpoch')]), 32, 'buf'), BufferLayout__namespace.nu64('idx'), BufferLayout__namespace.u8('isEmpty')], 'priorVoters'), BufferLayout__namespace.nu64(), // epochCredits.length
8658
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('prevCredits')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'epochCredits'), BufferLayout__namespace.struct([BufferLayout__namespace.nu64('slot'), BufferLayout__namespace.nu64('timestamp')], 'lastTimestamp')]);
8510
8659
 
8511
8660
  /**
8512
8661
  * VoteAccount class
@@ -8516,36 +8665,24 @@ class VoteAccount {
8516
8665
  * @internal
8517
8666
  */
8518
8667
  constructor(args) {
8519
- _defineProperty__default["default"](this, "nodePubkey", void 0);
8520
-
8521
- _defineProperty__default["default"](this, "authorizedVoterPubkey", void 0);
8522
-
8523
- _defineProperty__default["default"](this, "authorizedWithdrawerPubkey", void 0);
8524
-
8525
- _defineProperty__default["default"](this, "commission", void 0);
8526
-
8527
- _defineProperty__default["default"](this, "votes", void 0);
8528
-
8529
- _defineProperty__default["default"](this, "rootSlot", void 0);
8530
-
8531
- _defineProperty__default["default"](this, "epoch", void 0);
8532
-
8533
- _defineProperty__default["default"](this, "credits", void 0);
8534
-
8535
- _defineProperty__default["default"](this, "lastEpochCredits", void 0);
8536
-
8537
- _defineProperty__default["default"](this, "epochCredits", void 0);
8538
-
8668
+ this.nodePubkey = void 0;
8669
+ this.authorizedWithdrawer = void 0;
8670
+ this.commission = void 0;
8671
+ this.rootSlot = void 0;
8672
+ this.votes = void 0;
8673
+ this.authorizedVoters = void 0;
8674
+ this.priorVoters = void 0;
8675
+ this.epochCredits = void 0;
8676
+ this.lastTimestamp = void 0;
8539
8677
  this.nodePubkey = args.nodePubkey;
8540
- this.authorizedVoterPubkey = args.authorizedVoterPubkey;
8541
- this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
8678
+ this.authorizedWithdrawer = args.authorizedWithdrawer;
8542
8679
  this.commission = args.commission;
8543
- this.votes = args.votes;
8544
8680
  this.rootSlot = args.rootSlot;
8545
- this.epoch = args.epoch;
8546
- this.credits = args.credits;
8547
- this.lastEpochCredits = args.lastEpochCredits;
8681
+ this.votes = args.votes;
8682
+ this.authorizedVoters = args.authorizedVoters;
8683
+ this.priorVoters = args.priorVoters;
8548
8684
  this.epochCredits = args.epochCredits;
8685
+ this.lastTimestamp = args.lastTimestamp;
8549
8686
  }
8550
8687
  /**
8551
8688
  * Deserialize VoteAccount from the account data.
@@ -8556,7 +8693,8 @@ class VoteAccount {
8556
8693
 
8557
8694
 
8558
8695
  static fromAccountData(buffer) {
8559
- const va = VoteAccountLayout.decode(toBuffer(buffer), 0);
8696
+ const versionOffset = 4;
8697
+ const va = VoteAccountLayout.decode(toBuffer(buffer), versionOffset);
8560
8698
  let rootSlot = va.rootSlot;
8561
8699
 
8562
8700
  if (!va.rootSlotValid) {
@@ -8565,20 +8703,53 @@ class VoteAccount {
8565
8703
 
8566
8704
  return new VoteAccount({
8567
8705
  nodePubkey: new PublicKey(va.nodePubkey),
8568
- authorizedVoterPubkey: new PublicKey(va.authorizedVoterPubkey),
8569
- authorizedWithdrawerPubkey: new PublicKey(va.authorizedWithdrawerPubkey),
8706
+ authorizedWithdrawer: new PublicKey(va.authorizedWithdrawer),
8570
8707
  commission: va.commission,
8571
8708
  votes: va.votes,
8572
8709
  rootSlot,
8573
- epoch: va.epoch,
8574
- credits: va.credits,
8575
- lastEpochCredits: va.lastEpochCredits,
8576
- epochCredits: va.epochCredits
8710
+ authorizedVoters: va.authorizedVoters.map(parseAuthorizedVoter),
8711
+ priorVoters: getPriorVoters(va.priorVoters),
8712
+ epochCredits: va.epochCredits,
8713
+ lastTimestamp: va.lastTimestamp
8577
8714
  });
8578
8715
  }
8579
8716
 
8580
8717
  }
8581
8718
 
8719
+ function parseAuthorizedVoter({
8720
+ epoch,
8721
+ authorizedVoter
8722
+ }) {
8723
+ return {
8724
+ epoch,
8725
+ authorizedVoter: new PublicKey(authorizedVoter)
8726
+ };
8727
+ }
8728
+
8729
+ function parsePriorVoters({
8730
+ authorizedPubkey,
8731
+ epochOfLastAuthorizedSwitch,
8732
+ targetEpoch
8733
+ }) {
8734
+ return {
8735
+ authorizedPubkey: new PublicKey(authorizedPubkey),
8736
+ epochOfLastAuthorizedSwitch,
8737
+ targetEpoch
8738
+ };
8739
+ }
8740
+
8741
+ function getPriorVoters({
8742
+ buf,
8743
+ idx,
8744
+ isEmpty
8745
+ }) {
8746
+ if (isEmpty) {
8747
+ return [];
8748
+ }
8749
+
8750
+ return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx)];
8751
+ }
8752
+
8582
8753
  /**
8583
8754
  * Send and confirm a raw transaction
8584
8755
  *
@@ -8598,7 +8769,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
8598
8769
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
8599
8770
 
8600
8771
  if (status.err) {
8601
- throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
8772
+ throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
8602
8773
  }
8603
8774
 
8604
8775
  return signature;
@@ -8608,12 +8779,12 @@ const endpoint = {
8608
8779
  http: {
8609
8780
  devnet: 'http://api.devnet.solana.com',
8610
8781
  testnet: 'http://api.testnet.solana.com',
8611
- 'mainnet-beta': 'http://api.mainnet-beta.solana.com'
8782
+ 'mainnet-beta': 'http://api.mainnet-beta.solana.com/'
8612
8783
  },
8613
8784
  https: {
8614
8785
  devnet: 'https://api.devnet.solana.com',
8615
8786
  testnet: 'https://api.testnet.solana.com',
8616
- 'mainnet-beta': 'https://api.mainnet-beta.solana.com'
8787
+ 'mainnet-beta': 'https://api.mainnet-beta.solana.com/'
8617
8788
  }
8618
8789
  };
8619
8790
 
@@ -8630,7 +8801,7 @@ function clusterApiUrl(cluster, tls) {
8630
8801
  const url = endpoint[key][cluster];
8631
8802
 
8632
8803
  if (!url) {
8633
- throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
8804
+ throw new Error(`Unknown ${key} cluster: ${cluster}`);
8634
8805
  }
8635
8806
 
8636
8807
  return url;
@@ -8668,10 +8839,13 @@ exports.STAKE_CONFIG_ID = STAKE_CONFIG_ID;
8668
8839
  exports.STAKE_INSTRUCTION_LAYOUTS = STAKE_INSTRUCTION_LAYOUTS;
8669
8840
  exports.SYSTEM_INSTRUCTION_LAYOUTS = SYSTEM_INSTRUCTION_LAYOUTS;
8670
8841
  exports.SYSVAR_CLOCK_PUBKEY = SYSVAR_CLOCK_PUBKEY;
8842
+ exports.SYSVAR_EPOCH_SCHEDULE_PUBKEY = SYSVAR_EPOCH_SCHEDULE_PUBKEY;
8671
8843
  exports.SYSVAR_INSTRUCTIONS_PUBKEY = SYSVAR_INSTRUCTIONS_PUBKEY;
8672
8844
  exports.SYSVAR_RECENT_BLOCKHASHES_PUBKEY = SYSVAR_RECENT_BLOCKHASHES_PUBKEY;
8673
8845
  exports.SYSVAR_RENT_PUBKEY = SYSVAR_RENT_PUBKEY;
8674
8846
  exports.SYSVAR_REWARDS_PUBKEY = SYSVAR_REWARDS_PUBKEY;
8847
+ exports.SYSVAR_SLOT_HASHES_PUBKEY = SYSVAR_SLOT_HASHES_PUBKEY;
8848
+ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
8675
8849
  exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
8676
8850
  exports.Secp256k1Program = Secp256k1Program;
8677
8851
  exports.SendTransactionError = SendTransactionError;