@solana/web3.js 1.30.1 → 1.30.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.
@@ -1,4 +1,3 @@
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';
@@ -1718,8 +1717,7 @@ class Struct {
1718
1717
  class Enum extends Struct {
1719
1718
  constructor(properties) {
1720
1719
  super(properties);
1721
-
1722
- _defineProperty(this, "enum", '');
1720
+ this.enum = '';
1723
1721
 
1724
1722
  if (Object.keys(properties).length !== 1) {
1725
1723
  throw new Error('Enum can only take single value');
@@ -1759,8 +1757,7 @@ class PublicKey extends Struct {
1759
1757
  */
1760
1758
  constructor(value) {
1761
1759
  super({});
1762
-
1763
- _defineProperty(this, "_bn", void 0);
1760
+ this._bn = void 0;
1764
1761
 
1765
1762
  if (isPublicKeyData(value)) {
1766
1763
  this._bn = value._bn;
@@ -1770,7 +1767,7 @@ class PublicKey extends Struct {
1770
1767
  const decoded = bs58.decode(value);
1771
1768
 
1772
1769
  if (decoded.length != 32) {
1773
- throw new Error("Invalid public key input");
1770
+ throw new Error(`Invalid public key input`);
1774
1771
  }
1775
1772
 
1776
1773
  this._bn = new BN(decoded);
@@ -1779,7 +1776,7 @@ class PublicKey extends Struct {
1779
1776
  }
1780
1777
 
1781
1778
  if (this._bn.byteLength() > 32) {
1782
- throw new Error("Invalid public key input");
1779
+ throw new Error(`Invalid public key input`);
1783
1780
  }
1784
1781
  }
1785
1782
  }
@@ -1859,7 +1856,7 @@ class PublicKey extends Struct {
1859
1856
  let buffer = Buffer.alloc(0);
1860
1857
  seeds.forEach(function (seed) {
1861
1858
  if (seed.length > MAX_SEED_LENGTH) {
1862
- throw new TypeError("Max seed length exceeded");
1859
+ throw new TypeError(`Max seed length exceeded`);
1863
1860
  }
1864
1861
 
1865
1862
  buffer = Buffer.concat([buffer, toBuffer(seed)]);
@@ -1869,7 +1866,7 @@ class PublicKey extends Struct {
1869
1866
  let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
1870
1867
 
1871
1868
  if (is_on_curve(publicKeyBytes)) {
1872
- throw new Error("Invalid seeds, address must fall off the curve");
1869
+ throw new Error(`Invalid seeds, address must fall off the curve`);
1873
1870
  }
1874
1871
 
1875
1872
  return new PublicKey(publicKeyBytes);
@@ -1903,7 +1900,7 @@ class PublicKey extends Struct {
1903
1900
  return [address, nonce];
1904
1901
  }
1905
1902
 
1906
- throw new Error("Unable to find a viable program address nonce");
1903
+ throw new Error(`Unable to find a viable program address nonce`);
1907
1904
  }
1908
1905
  /**
1909
1906
  * Check that a pubkey is on the ed25519 curve.
@@ -1915,9 +1912,7 @@ class PublicKey extends Struct {
1915
1912
  }
1916
1913
 
1917
1914
  }
1918
-
1919
- _defineProperty(PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
1920
-
1915
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
1921
1916
  SOLANA_SCHEMA.set(PublicKey, {
1922
1917
  kind: 'struct',
1923
1918
  fields: [['_bn', 'u256']]
@@ -1990,7 +1985,7 @@ class Account {
1990
1985
  * @param secretKey Secret key for the account
1991
1986
  */
1992
1987
  constructor(secretKey) {
1993
- _defineProperty(this, "_keypair", void 0);
1988
+ this._keypair = void 0;
1994
1989
 
1995
1990
  if (secretKey) {
1996
1991
  this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
@@ -2115,27 +2110,52 @@ function encodeLength(bytes, len) {
2115
2110
  }
2116
2111
  }
2117
2112
 
2113
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
2118
2114
  /**
2119
- * The message header, identifying signed and read-only account
2115
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
2120
2116
  */
2121
2117
 
2122
- const PUBKEY_LENGTH = 32;
2118
+ function guardedShift(byteArray) {
2119
+ if (byteArray.length === 0) {
2120
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
2121
+ }
2122
+
2123
+ return byteArray.shift();
2124
+ }
2123
2125
  /**
2124
- * List of instructions to be processed atomically
2126
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
2127
+ * the array.
2125
2128
  */
2126
2129
 
2127
- class Message {
2128
- constructor(args) {
2129
- _defineProperty(this, "header", void 0);
2130
+ function guardedSplice(byteArray, ...args) {
2131
+ var _args$;
2130
2132
 
2131
- _defineProperty(this, "accountKeys", void 0);
2133
+ const [start] = args;
2132
2134
 
2133
- _defineProperty(this, "recentBlockhash", void 0);
2135
+ if (args.length === 2 // Implies that `deleteCount` was supplied
2136
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
2137
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
2138
+ }
2134
2139
 
2135
- _defineProperty(this, "instructions", void 0);
2140
+ return byteArray.splice(...args);
2141
+ }
2142
+
2143
+ /**
2144
+ * The message header, identifying signed and read-only account
2145
+ */
2136
2146
 
2137
- _defineProperty(this, "indexToProgramIds", new Map());
2147
+ const PUBKEY_LENGTH = 32;
2148
+ /**
2149
+ * List of instructions to be processed atomically
2150
+ */
2138
2151
 
2152
+ class Message {
2153
+ constructor(args) {
2154
+ this.header = void 0;
2155
+ this.accountKeys = void 0;
2156
+ this.recentBlockhash = void 0;
2157
+ this.instructions = void 0;
2158
+ this.indexToProgramIds = new Map();
2139
2159
  this.header = args.header;
2140
2160
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
2141
2161
  this.recentBlockhash = args.recentBlockhash;
@@ -2218,32 +2238,28 @@ class Message {
2218
2238
  static from(buffer) {
2219
2239
  // Slice up wire data
2220
2240
  let byteArray = [...buffer];
2221
- const numRequiredSignatures = byteArray.shift();
2222
- const numReadonlySignedAccounts = byteArray.shift();
2223
- const numReadonlyUnsignedAccounts = byteArray.shift();
2241
+ const numRequiredSignatures = guardedShift(byteArray);
2242
+ const numReadonlySignedAccounts = guardedShift(byteArray);
2243
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
2224
2244
  const accountCount = decodeLength(byteArray);
2225
2245
  let accountKeys = [];
2226
2246
 
2227
2247
  for (let i = 0; i < accountCount; i++) {
2228
- const account = byteArray.slice(0, PUBKEY_LENGTH);
2229
- byteArray = byteArray.slice(PUBKEY_LENGTH);
2248
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
2230
2249
  accountKeys.push(bs58.encode(Buffer.from(account)));
2231
2250
  }
2232
2251
 
2233
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
2234
- byteArray = byteArray.slice(PUBKEY_LENGTH);
2252
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
2235
2253
  const instructionCount = decodeLength(byteArray);
2236
2254
  let instructions = [];
2237
2255
 
2238
2256
  for (let i = 0; i < instructionCount; i++) {
2239
- const programIdIndex = byteArray.shift();
2257
+ const programIdIndex = guardedShift(byteArray);
2240
2258
  const accountCount = decodeLength(byteArray);
2241
- const accounts = byteArray.slice(0, accountCount);
2242
- byteArray = byteArray.slice(accountCount);
2259
+ const accounts = guardedSplice(byteArray, 0, accountCount);
2243
2260
  const dataLength = decodeLength(byteArray);
2244
- const dataSlice = byteArray.slice(0, dataLength);
2261
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
2245
2262
  const data = bs58.encode(Buffer.from(dataSlice));
2246
- byteArray = byteArray.slice(dataLength);
2247
2263
  instructions.push({
2248
2264
  programIdIndex,
2249
2265
  accounts,
@@ -2272,6 +2288,10 @@ function assert (condition, message) {
2272
2288
  }
2273
2289
  }
2274
2290
 
2291
+ /**
2292
+ * Transaction signature as base-58 encoded string
2293
+ */
2294
+
2275
2295
  /**
2276
2296
  * Default (empty) signature
2277
2297
  *
@@ -2309,12 +2329,9 @@ class TransactionInstruction {
2309
2329
  * Program input
2310
2330
  */
2311
2331
  constructor(opts) {
2312
- _defineProperty(this, "keys", void 0);
2313
-
2314
- _defineProperty(this, "programId", void 0);
2315
-
2316
- _defineProperty(this, "data", Buffer.alloc(0));
2317
-
2332
+ this.keys = void 0;
2333
+ this.programId = void 0;
2334
+ this.data = Buffer.alloc(0);
2318
2335
  this.programId = opts.programId;
2319
2336
  this.keys = opts.keys;
2320
2337
 
@@ -2356,16 +2373,11 @@ class Transaction {
2356
2373
  * Construct an empty Transaction
2357
2374
  */
2358
2375
  constructor(opts) {
2359
- _defineProperty(this, "signatures", []);
2360
-
2361
- _defineProperty(this, "feePayer", void 0);
2362
-
2363
- _defineProperty(this, "instructions", []);
2364
-
2365
- _defineProperty(this, "recentBlockhash", void 0);
2366
-
2367
- _defineProperty(this, "nonceInfo", void 0);
2368
-
2376
+ this.signatures = [];
2377
+ this.feePayer = void 0;
2378
+ this.instructions = [];
2379
+ this.recentBlockhash = void 0;
2380
+ this.nonceInfo = void 0;
2369
2381
  opts && Object.assign(this, opts);
2370
2382
  }
2371
2383
  /**
@@ -2429,7 +2441,7 @@ class Transaction {
2429
2441
 
2430
2442
  for (let i = 0; i < this.instructions.length; i++) {
2431
2443
  if (this.instructions[i].programId === undefined) {
2432
- throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
2444
+ throw new Error(`Transaction instruction index ${i} has undefined program id`);
2433
2445
  }
2434
2446
  }
2435
2447
 
@@ -2504,7 +2516,7 @@ class Transaction {
2504
2516
  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.');
2505
2517
  }
2506
2518
  } else {
2507
- throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
2519
+ throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
2508
2520
  }
2509
2521
  }
2510
2522
 
@@ -2739,7 +2751,7 @@ class Transaction {
2739
2751
  const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
2740
2752
 
2741
2753
  if (index < 0) {
2742
- throw new Error("unknown signer: ".concat(pubkey.toString()));
2754
+ throw new Error(`unknown signer: ${pubkey.toString()}`);
2743
2755
  }
2744
2756
 
2745
2757
  this.signatures[index].signature = Buffer.from(signature);
@@ -2815,12 +2827,12 @@ class Transaction {
2815
2827
  signature
2816
2828
  }, index) => {
2817
2829
  if (signature !== null) {
2818
- assert(signature.length === 64, "signature has invalid length");
2830
+ assert(signature.length === 64, `signature has invalid length`);
2819
2831
  Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
2820
2832
  }
2821
2833
  });
2822
2834
  signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
2823
- assert(wireTransaction.length <= PACKET_DATA_SIZE, "Transaction too large: ".concat(wireTransaction.length, " > ").concat(PACKET_DATA_SIZE));
2835
+ assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
2824
2836
  return wireTransaction;
2825
2837
  }
2826
2838
  /**
@@ -2865,8 +2877,7 @@ class Transaction {
2865
2877
  let signatures = [];
2866
2878
 
2867
2879
  for (let i = 0; i < signatureCount; i++) {
2868
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
2869
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
2880
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
2870
2881
  signatures.push(bs58.encode(Buffer.from(signature)));
2871
2882
  }
2872
2883
 
@@ -2939,7 +2950,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2939
2950
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2940
2951
 
2941
2952
  if (status.err) {
2942
- throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
2953
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
2943
2954
  }
2944
2955
 
2945
2956
  return signature;
@@ -2982,7 +2993,7 @@ function decodeData(type, buffer) {
2982
2993
  }
2983
2994
 
2984
2995
  if (data.instruction !== type.index) {
2985
- throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
2996
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
2986
2997
  }
2987
2998
 
2988
2999
  return data;
@@ -3016,12 +3027,9 @@ class NonceAccount {
3016
3027
  * @internal
3017
3028
  */
3018
3029
  constructor(args) {
3019
- _defineProperty(this, "authorizedPubkey", void 0);
3020
-
3021
- _defineProperty(this, "nonce", void 0);
3022
-
3023
- _defineProperty(this, "feeCalculator", void 0);
3024
-
3030
+ this.authorizedPubkey = void 0;
3031
+ this.nonce = void 0;
3032
+ this.feeCalculator = void 0;
3025
3033
  this.authorizedPubkey = args.authorizedPubkey;
3026
3034
  this.nonce = args.nonce;
3027
3035
  this.feeCalculator = args.feeCalculator;
@@ -3322,7 +3330,7 @@ class SystemInstruction {
3322
3330
 
3323
3331
  static checkKeyLength(keys, expectedLength) {
3324
3332
  if (keys.length < expectedLength) {
3325
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
3333
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
3326
3334
  }
3327
3335
  }
3328
3336
 
@@ -3754,8 +3762,7 @@ class SystemProgram {
3754
3762
  }
3755
3763
 
3756
3764
  }
3757
-
3758
- _defineProperty(SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3765
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3759
3766
 
3760
3767
  // rest of the Transaction fields
3761
3768
  //
@@ -3924,8 +3931,7 @@ class Loader {
3924
3931
  }
3925
3932
 
3926
3933
  }
3927
-
3928
- _defineProperty(Loader, "chunkSize", CHUNK_SIZE);
3934
+ Loader.chunkSize = CHUNK_SIZE;
3929
3935
 
3930
3936
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
3931
3937
  /**
@@ -4564,16 +4570,11 @@ class EpochSchedule {
4564
4570
 
4565
4571
  /** The first slot of `firstNormalEpoch` */
4566
4572
  constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
4567
- _defineProperty(this, "slotsPerEpoch", void 0);
4568
-
4569
- _defineProperty(this, "leaderScheduleSlotOffset", void 0);
4570
-
4571
- _defineProperty(this, "warmup", void 0);
4572
-
4573
- _defineProperty(this, "firstNormalEpoch", void 0);
4574
-
4575
- _defineProperty(this, "firstNormalSlot", void 0);
4576
-
4573
+ this.slotsPerEpoch = void 0;
4574
+ this.leaderScheduleSlotOffset = void 0;
4575
+ this.warmup = void 0;
4576
+ this.firstNormalEpoch = void 0;
4577
+ this.firstNormalSlot = void 0;
4577
4578
  this.slotsPerEpoch = slotsPerEpoch;
4578
4579
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
4579
4580
  this.warmup = warmup;
@@ -4625,9 +4626,7 @@ class EpochSchedule {
4625
4626
  class SendTransactionError extends Error {
4626
4627
  constructor(message, logs) {
4627
4628
  super(message);
4628
-
4629
- _defineProperty(this, "logs", void 0);
4630
-
4629
+ this.logs = void 0;
4631
4630
  this.logs = logs;
4632
4631
  }
4633
4632
 
@@ -4906,7 +4905,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4906
4905
  break;
4907
4906
  }
4908
4907
 
4909
- console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
4908
+ console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
4910
4909
  await sleep(waitTime);
4911
4910
  waitTime *= 2;
4912
4911
  }
@@ -4916,7 +4915,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4916
4915
  if (res.ok) {
4917
4916
  callback(null, text);
4918
4917
  } else {
4919
- callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
4918
+ callback(new Error(`${res.status} ${res.statusText}: ${text}`));
4920
4919
  }
4921
4920
  } catch (err) {
4922
4921
  if (err instanceof Error) callback(err);
@@ -5581,67 +5580,39 @@ class Connection {
5581
5580
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
5582
5581
  */
5583
5582
  constructor(endpoint, commitmentOrConfig) {
5584
- _defineProperty(this, "_commitment", void 0);
5585
-
5586
- _defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
5587
-
5588
- _defineProperty(this, "_rpcEndpoint", void 0);
5589
-
5590
- _defineProperty(this, "_rpcWsEndpoint", void 0);
5591
-
5592
- _defineProperty(this, "_rpcClient", void 0);
5593
-
5594
- _defineProperty(this, "_rpcRequest", void 0);
5595
-
5596
- _defineProperty(this, "_rpcBatchRequest", void 0);
5597
-
5598
- _defineProperty(this, "_rpcWebSocket", void 0);
5599
-
5600
- _defineProperty(this, "_rpcWebSocketConnected", false);
5601
-
5602
- _defineProperty(this, "_rpcWebSocketHeartbeat", null);
5603
-
5604
- _defineProperty(this, "_rpcWebSocketIdleTimeout", null);
5605
-
5606
- _defineProperty(this, "_disableBlockhashCaching", false);
5607
-
5608
- _defineProperty(this, "_pollingBlockhash", false);
5609
-
5610
- _defineProperty(this, "_blockhashInfo", {
5583
+ this._commitment = void 0;
5584
+ this._confirmTransactionInitialTimeout = void 0;
5585
+ this._rpcEndpoint = void 0;
5586
+ this._rpcWsEndpoint = void 0;
5587
+ this._rpcClient = void 0;
5588
+ this._rpcRequest = void 0;
5589
+ this._rpcBatchRequest = void 0;
5590
+ this._rpcWebSocket = void 0;
5591
+ this._rpcWebSocketConnected = false;
5592
+ this._rpcWebSocketHeartbeat = null;
5593
+ this._rpcWebSocketIdleTimeout = null;
5594
+ this._disableBlockhashCaching = false;
5595
+ this._pollingBlockhash = false;
5596
+ this._blockhashInfo = {
5611
5597
  recentBlockhash: null,
5612
5598
  lastFetch: 0,
5613
5599
  transactionSignatures: [],
5614
5600
  simulatedSignatures: []
5615
- });
5616
-
5617
- _defineProperty(this, "_accountChangeSubscriptionCounter", 0);
5618
-
5619
- _defineProperty(this, "_accountChangeSubscriptions", {});
5620
-
5621
- _defineProperty(this, "_programAccountChangeSubscriptionCounter", 0);
5622
-
5623
- _defineProperty(this, "_programAccountChangeSubscriptions", {});
5624
-
5625
- _defineProperty(this, "_rootSubscriptionCounter", 0);
5626
-
5627
- _defineProperty(this, "_rootSubscriptions", {});
5628
-
5629
- _defineProperty(this, "_signatureSubscriptionCounter", 0);
5630
-
5631
- _defineProperty(this, "_signatureSubscriptions", {});
5632
-
5633
- _defineProperty(this, "_slotSubscriptionCounter", 0);
5634
-
5635
- _defineProperty(this, "_slotSubscriptions", {});
5636
-
5637
- _defineProperty(this, "_logsSubscriptionCounter", 0);
5638
-
5639
- _defineProperty(this, "_logsSubscriptions", {});
5640
-
5641
- _defineProperty(this, "_slotUpdateSubscriptionCounter", 0);
5642
-
5643
- _defineProperty(this, "_slotUpdateSubscriptions", {});
5644
-
5601
+ };
5602
+ this._accountChangeSubscriptionCounter = 0;
5603
+ this._accountChangeSubscriptions = {};
5604
+ this._programAccountChangeSubscriptionCounter = 0;
5605
+ this._programAccountChangeSubscriptions = {};
5606
+ this._rootSubscriptionCounter = 0;
5607
+ this._rootSubscriptions = {};
5608
+ this._signatureSubscriptionCounter = 0;
5609
+ this._signatureSubscriptions = {};
5610
+ this._slotSubscriptionCounter = 0;
5611
+ this._slotSubscriptions = {};
5612
+ this._logsSubscriptionCounter = 0;
5613
+ this._logsSubscriptions = {};
5614
+ this._slotUpdateSubscriptionCounter = 0;
5615
+ this._slotUpdateSubscriptions = {};
5645
5616
  let url = new URL(endpoint);
5646
5617
  const useHttps = url.protocol === 'https:';
5647
5618
  let wsEndpoint;
@@ -6015,7 +5986,7 @@ class Connection {
6015
5986
  const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
6016
5987
 
6017
5988
  if ('error' in res) {
6018
- throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
5989
+ throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
6019
5990
  }
6020
5991
 
6021
5992
  return res.result;
@@ -6151,7 +6122,7 @@ class Connection {
6151
6122
 
6152
6123
  if (response === null) {
6153
6124
  const duration = (Date.now() - start) / 1000;
6154
- 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."));
6125
+ 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.`);
6155
6126
  }
6156
6127
 
6157
6128
  return response;
@@ -6925,7 +6896,7 @@ class Connection {
6925
6896
  await sleep(MS_PER_SLOT / 2);
6926
6897
  }
6927
6898
 
6928
- throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
6899
+ throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
6929
6900
  } finally {
6930
6901
  this._pollingBlockhash = false;
6931
6902
  }
@@ -7182,7 +7153,7 @@ class Connection {
7182
7153
  }
7183
7154
 
7184
7155
  if (err instanceof Error) {
7185
- console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
7156
+ console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
7186
7157
  }
7187
7158
  }
7188
7159
  }
@@ -7202,7 +7173,7 @@ class Connection {
7202
7173
  await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
7203
7174
  } catch (err) {
7204
7175
  if (err instanceof Error) {
7205
- console.error("".concat(rpcMethod, " error:"), err.message);
7176
+ console.error(`${rpcMethod} error:`, err.message);
7206
7177
  }
7207
7178
  }
7208
7179
  }
@@ -7367,7 +7338,7 @@ class Connection {
7367
7338
 
7368
7339
  this._updateSubscriptions();
7369
7340
  } else {
7370
- throw new Error("Unknown account change id: ".concat(id));
7341
+ throw new Error(`Unknown account change id: ${id}`);
7371
7342
  }
7372
7343
  }
7373
7344
  /**
@@ -7433,7 +7404,7 @@ class Connection {
7433
7404
 
7434
7405
  this._updateSubscriptions();
7435
7406
  } else {
7436
- throw new Error("Unknown program account change id: ".concat(id));
7407
+ throw new Error(`Unknown program account change id: ${id}`);
7437
7408
  }
7438
7409
  }
7439
7410
  /**
@@ -7463,7 +7434,7 @@ class Connection {
7463
7434
 
7464
7435
  async removeOnLogsListener(id) {
7465
7436
  if (!this._logsSubscriptions[id]) {
7466
- throw new Error("Unknown logs id: ".concat(id));
7437
+ throw new Error(`Unknown logs id: ${id}`);
7467
7438
  }
7468
7439
 
7469
7440
  const subInfo = this._logsSubscriptions[id];
@@ -7539,7 +7510,7 @@ class Connection {
7539
7510
 
7540
7511
  this._updateSubscriptions();
7541
7512
  } else {
7542
- throw new Error("Unknown slot change id: ".concat(id));
7513
+ throw new Error(`Unknown slot change id: ${id}`);
7543
7514
  }
7544
7515
  }
7545
7516
  /**
@@ -7592,7 +7563,7 @@ class Connection {
7592
7563
 
7593
7564
  this._updateSubscriptions();
7594
7565
  } else {
7595
- throw new Error("Unknown slot update id: ".concat(id));
7566
+ throw new Error(`Unknown slot update id: ${id}`);
7596
7567
  }
7597
7568
  }
7598
7569
 
@@ -7733,7 +7704,7 @@ class Connection {
7733
7704
 
7734
7705
  this._updateSubscriptions();
7735
7706
  } else {
7736
- throw new Error("Unknown signature result id: ".concat(id));
7707
+ throw new Error(`Unknown signature result id: ${id}`);
7737
7708
  }
7738
7709
  }
7739
7710
  /**
@@ -7785,7 +7756,7 @@ class Connection {
7785
7756
 
7786
7757
  this._updateSubscriptions();
7787
7758
  } else {
7788
- throw new Error("Unknown root change id: ".concat(id));
7759
+ throw new Error(`Unknown root change id: ${id}`);
7789
7760
  }
7790
7761
  }
7791
7762
 
@@ -7806,7 +7777,7 @@ class Keypair {
7806
7777
  * @param keypair ed25519 keypair
7807
7778
  */
7808
7779
  constructor(keypair) {
7809
- _defineProperty(this, "_keypair", void 0);
7780
+ this._keypair = void 0;
7810
7781
 
7811
7782
  if (keypair) {
7812
7783
  this._keypair = keypair;
@@ -7910,8 +7881,8 @@ class Ed25519Program {
7910
7881
  signature,
7911
7882
  instructionIndex
7912
7883
  } = params;
7913
- assert(publicKey.length === PUBLIC_KEY_BYTES$1, "Public Key must be ".concat(PUBLIC_KEY_BYTES$1, " bytes but received ").concat(publicKey.length, " bytes"));
7914
- assert(signature.length === SIGNATURE_BYTES, "Signature must be ".concat(SIGNATURE_BYTES, " bytes but received ").concat(signature.length, " bytes"));
7884
+ assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
7885
+ assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
7915
7886
  const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
7916
7887
  const signatureOffset = publicKeyOffset + publicKey.length;
7917
7888
  const messageDataOffset = signatureOffset + signature.length;
@@ -7949,7 +7920,7 @@ class Ed25519Program {
7949
7920
  message,
7950
7921
  instructionIndex
7951
7922
  } = params;
7952
- assert(privateKey.length === PRIVATE_KEY_BYTES$1, "Private key must be ".concat(PRIVATE_KEY_BYTES$1, " bytes but received ").concat(privateKey.length, " bytes"));
7923
+ assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
7953
7924
 
7954
7925
  try {
7955
7926
  const keypair = Keypair.fromSecretKey(privateKey);
@@ -7962,13 +7933,12 @@ class Ed25519Program {
7962
7933
  instructionIndex
7963
7934
  });
7964
7935
  } catch (error) {
7965
- throw new Error("Error creating instruction; ".concat(error));
7936
+ throw new Error(`Error creating instruction; ${error}`);
7966
7937
  }
7967
7938
  }
7968
7939
 
7969
7940
  }
7970
-
7971
- _defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7941
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7972
7942
 
7973
7943
  /**
7974
7944
  * Address of the stake config account which configures the rate
@@ -7991,10 +7961,8 @@ class Authorized {
7991
7961
  * @param withdrawer the withdraw authority
7992
7962
  */
7993
7963
  constructor(staker, withdrawer) {
7994
- _defineProperty(this, "staker", void 0);
7995
-
7996
- _defineProperty(this, "withdrawer", void 0);
7997
-
7964
+ this.staker = void 0;
7965
+ this.withdrawer = void 0;
7998
7966
  this.staker = staker;
7999
7967
  this.withdrawer = withdrawer;
8000
7968
  }
@@ -8015,12 +7983,9 @@ class Lockup {
8015
7983
  * Create a new Lockup object
8016
7984
  */
8017
7985
  constructor(unixTimestamp, epoch, custodian) {
8018
- _defineProperty(this, "unixTimestamp", void 0);
8019
-
8020
- _defineProperty(this, "epoch", void 0);
8021
-
8022
- _defineProperty(this, "custodian", void 0);
8023
-
7986
+ this.unixTimestamp = void 0;
7987
+ this.epoch = void 0;
7988
+ this.custodian = void 0;
8024
7989
  this.unixTimestamp = unixTimestamp;
8025
7990
  this.epoch = epoch;
8026
7991
  this.custodian = custodian;
@@ -8035,7 +8000,7 @@ class Lockup {
8035
8000
  * Create stake account transaction params
8036
8001
  */
8037
8002
 
8038
- _defineProperty(Lockup, "default", new Lockup(0, 0, PublicKey.default));
8003
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
8039
8004
 
8040
8005
  /**
8041
8006
  * Stake Instruction class
@@ -8248,7 +8213,7 @@ class StakeInstruction {
8248
8213
 
8249
8214
  static checkKeyLength(keys, expectedLength) {
8250
8215
  if (keys.length < expectedLength) {
8251
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
8216
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
8252
8217
  }
8253
8218
  }
8254
8219
 
@@ -8723,10 +8688,8 @@ class StakeProgram {
8723
8688
  }
8724
8689
 
8725
8690
  }
8726
-
8727
- _defineProperty(StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
8728
-
8729
- _defineProperty(StakeProgram, "space", 200);
8691
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8692
+ StakeProgram.space = 200;
8730
8693
 
8731
8694
  const {
8732
8695
  publicKeyCreate,
@@ -8756,12 +8719,12 @@ class Secp256k1Program {
8756
8719
  * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
8757
8720
  */
8758
8721
  static publicKeyToEthAddress(publicKey) {
8759
- assert(publicKey.length === PUBLIC_KEY_BYTES, "Public key must be ".concat(PUBLIC_KEY_BYTES, " bytes but received ").concat(publicKey.length, " bytes"));
8722
+ assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8760
8723
 
8761
8724
  try {
8762
8725
  return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8763
8726
  } catch (error) {
8764
- throw new Error("Error constructing Ethereum address: ".concat(error));
8727
+ throw new Error(`Error constructing Ethereum address: ${error}`);
8765
8728
  }
8766
8729
  }
8767
8730
  /**
@@ -8812,7 +8775,7 @@ class Secp256k1Program {
8812
8775
  ethAddress = rawAddress;
8813
8776
  }
8814
8777
 
8815
- assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
8778
+ assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
8816
8779
  const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
8817
8780
  const ethAddressOffset = dataStart;
8818
8781
  const signatureOffset = dataStart + ethAddress.length;
@@ -8851,7 +8814,7 @@ class Secp256k1Program {
8851
8814
  message,
8852
8815
  instructionIndex
8853
8816
  } = params;
8854
- assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
8817
+ assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
8855
8818
 
8856
8819
  try {
8857
8820
  const privateKey = toBuffer(pkey);
@@ -8870,13 +8833,12 @@ class Secp256k1Program {
8870
8833
  instructionIndex
8871
8834
  });
8872
8835
  } catch (error) {
8873
- throw new Error("Error creating instruction; ".concat(error));
8836
+ throw new Error(`Error creating instruction; ${error}`);
8874
8837
  }
8875
8838
  }
8876
8839
 
8877
8840
  }
8878
-
8879
- _defineProperty(Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8841
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
8880
8842
 
8881
8843
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
8882
8844
  /**
@@ -8909,10 +8871,8 @@ class ValidatorInfo {
8909
8871
  * @param info validator information
8910
8872
  */
8911
8873
  constructor(key, info) {
8912
- _defineProperty(this, "key", void 0);
8913
-
8914
- _defineProperty(this, "info", void 0);
8915
-
8874
+ this.key = void 0;
8875
+ this.info = void 0;
8916
8876
  this.key = key;
8917
8877
  this.info = info;
8918
8878
  }
@@ -8933,10 +8893,8 @@ class ValidatorInfo {
8933
8893
  const configKeys = [];
8934
8894
 
8935
8895
  for (let i = 0; i < 2; i++) {
8936
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
8937
- byteArray = byteArray.slice(PUBKEY_LENGTH);
8938
- const isSigner = byteArray.slice(0, 1)[0] === 1;
8939
- byteArray = byteArray.slice(1);
8896
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
8897
+ const isSigner = guardedShift(byteArray) === 1;
8940
8898
  configKeys.push({
8941
8899
  publicKey,
8942
8900
  isSigner
@@ -8976,26 +8934,16 @@ class VoteAccount {
8976
8934
  * @internal
8977
8935
  */
8978
8936
  constructor(args) {
8979
- _defineProperty(this, "nodePubkey", void 0);
8980
-
8981
- _defineProperty(this, "authorizedVoterPubkey", void 0);
8982
-
8983
- _defineProperty(this, "authorizedWithdrawerPubkey", void 0);
8984
-
8985
- _defineProperty(this, "commission", void 0);
8986
-
8987
- _defineProperty(this, "votes", void 0);
8988
-
8989
- _defineProperty(this, "rootSlot", void 0);
8990
-
8991
- _defineProperty(this, "epoch", void 0);
8992
-
8993
- _defineProperty(this, "credits", void 0);
8994
-
8995
- _defineProperty(this, "lastEpochCredits", void 0);
8996
-
8997
- _defineProperty(this, "epochCredits", void 0);
8998
-
8937
+ this.nodePubkey = void 0;
8938
+ this.authorizedVoterPubkey = void 0;
8939
+ this.authorizedWithdrawerPubkey = void 0;
8940
+ this.commission = void 0;
8941
+ this.votes = void 0;
8942
+ this.rootSlot = void 0;
8943
+ this.epoch = void 0;
8944
+ this.credits = void 0;
8945
+ this.lastEpochCredits = void 0;
8946
+ this.epochCredits = void 0;
8999
8947
  this.nodePubkey = args.nodePubkey;
9000
8948
  this.authorizedVoterPubkey = args.authorizedVoterPubkey;
9001
8949
  this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
@@ -9058,7 +9006,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
9058
9006
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
9059
9007
 
9060
9008
  if (status.err) {
9061
- throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
9009
+ throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
9062
9010
  }
9063
9011
 
9064
9012
  return signature;
@@ -9090,7 +9038,7 @@ function clusterApiUrl(cluster, tls) {
9090
9038
  const url = endpoint[key][cluster];
9091
9039
 
9092
9040
  if (!url) {
9093
- throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
9041
+ throw new Error(`Unknown ${key} cluster: ${cluster}`);
9094
9042
  }
9095
9043
 
9096
9044
  return url;