@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.
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');
@@ -38,7 +37,6 @@ 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
41
  var nacl__namespace = /*#__PURE__*/_interopNamespace(nacl);
44
42
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
@@ -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
  }
@@ -1901,7 +1897,7 @@ class PublicKey extends Struct {
1901
1897
  let buffer$1 = buffer.Buffer.alloc(0);
1902
1898
  seeds.forEach(function (seed) {
1903
1899
  if (seed.length > MAX_SEED_LENGTH) {
1904
- throw new TypeError("Max seed length exceeded");
1900
+ throw new TypeError(`Max seed length exceeded`);
1905
1901
  }
1906
1902
 
1907
1903
  buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
@@ -1911,7 +1907,7 @@ class PublicKey extends Struct {
1911
1907
  let publicKeyBytes = new BN__default["default"](hash, 16).toArray(undefined, 32);
1912
1908
 
1913
1909
  if (is_on_curve(publicKeyBytes)) {
1914
- throw new Error("Invalid seeds, address must fall off the curve");
1910
+ throw new Error(`Invalid seeds, address must fall off the curve`);
1915
1911
  }
1916
1912
 
1917
1913
  return new PublicKey(publicKeyBytes);
@@ -1945,7 +1941,7 @@ class PublicKey extends Struct {
1945
1941
  return [address, nonce];
1946
1942
  }
1947
1943
 
1948
- throw new Error("Unable to find a viable program address nonce");
1944
+ throw new Error(`Unable to find a viable program address nonce`);
1949
1945
  }
1950
1946
  /**
1951
1947
  * Check that a pubkey is on the ed25519 curve.
@@ -1957,9 +1953,7 @@ class PublicKey extends Struct {
1957
1953
  }
1958
1954
 
1959
1955
  }
1960
-
1961
- _defineProperty__default["default"](PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
1962
-
1956
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
1963
1957
  SOLANA_SCHEMA.set(PublicKey, {
1964
1958
  kind: 'struct',
1965
1959
  fields: [['_bn', 'u256']]
@@ -2032,7 +2026,7 @@ class Account {
2032
2026
  * @param secretKey Secret key for the account
2033
2027
  */
2034
2028
  constructor(secretKey) {
2035
- _defineProperty__default["default"](this, "_keypair", void 0);
2029
+ this._keypair = void 0;
2036
2030
 
2037
2031
  if (secretKey) {
2038
2032
  this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
@@ -2157,27 +2151,52 @@ function encodeLength(bytes, len) {
2157
2151
  }
2158
2152
  }
2159
2153
 
2154
+ const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';
2160
2155
  /**
2161
- * The message header, identifying signed and read-only account
2156
+ * Delegates to `Array#shift`, but throws if the array is zero-length.
2162
2157
  */
2163
2158
 
2164
- const PUBKEY_LENGTH = 32;
2159
+ function guardedShift(byteArray) {
2160
+ if (byteArray.length === 0) {
2161
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
2162
+ }
2163
+
2164
+ return byteArray.shift();
2165
+ }
2165
2166
  /**
2166
- * List of instructions to be processed atomically
2167
+ * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of
2168
+ * the array.
2167
2169
  */
2168
2170
 
2169
- class Message {
2170
- constructor(args) {
2171
- _defineProperty__default["default"](this, "header", void 0);
2171
+ function guardedSplice(byteArray, ...args) {
2172
+ var _args$;
2173
+
2174
+ const [start] = args;
2172
2175
 
2173
- _defineProperty__default["default"](this, "accountKeys", void 0);
2176
+ if (args.length === 2 // Implies that `deleteCount` was supplied
2177
+ ? start + ((_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : 0) > byteArray.length : start >= byteArray.length) {
2178
+ throw new Error(END_OF_BUFFER_ERROR_MESSAGE);
2179
+ }
2174
2180
 
2175
- _defineProperty__default["default"](this, "recentBlockhash", void 0);
2181
+ return byteArray.splice(...args);
2182
+ }
2176
2183
 
2177
- _defineProperty__default["default"](this, "instructions", void 0);
2184
+ /**
2185
+ * The message header, identifying signed and read-only account
2186
+ */
2178
2187
 
2179
- _defineProperty__default["default"](this, "indexToProgramIds", new Map());
2188
+ const PUBKEY_LENGTH = 32;
2189
+ /**
2190
+ * List of instructions to be processed atomically
2191
+ */
2180
2192
 
2193
+ class Message {
2194
+ constructor(args) {
2195
+ this.header = void 0;
2196
+ this.accountKeys = void 0;
2197
+ this.recentBlockhash = void 0;
2198
+ this.instructions = void 0;
2199
+ this.indexToProgramIds = new Map();
2181
2200
  this.header = args.header;
2182
2201
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
2183
2202
  this.recentBlockhash = args.recentBlockhash;
@@ -2260,32 +2279,28 @@ class Message {
2260
2279
  static from(buffer$1) {
2261
2280
  // Slice up wire data
2262
2281
  let byteArray = [...buffer$1];
2263
- const numRequiredSignatures = byteArray.shift();
2264
- const numReadonlySignedAccounts = byteArray.shift();
2265
- const numReadonlyUnsignedAccounts = byteArray.shift();
2282
+ const numRequiredSignatures = guardedShift(byteArray);
2283
+ const numReadonlySignedAccounts = guardedShift(byteArray);
2284
+ const numReadonlyUnsignedAccounts = guardedShift(byteArray);
2266
2285
  const accountCount = decodeLength(byteArray);
2267
2286
  let accountKeys = [];
2268
2287
 
2269
2288
  for (let i = 0; i < accountCount; i++) {
2270
- const account = byteArray.slice(0, PUBKEY_LENGTH);
2271
- byteArray = byteArray.slice(PUBKEY_LENGTH);
2289
+ const account = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
2272
2290
  accountKeys.push(bs58__default["default"].encode(buffer.Buffer.from(account)));
2273
2291
  }
2274
2292
 
2275
- const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
2276
- byteArray = byteArray.slice(PUBKEY_LENGTH);
2293
+ const recentBlockhash = guardedSplice(byteArray, 0, PUBKEY_LENGTH);
2277
2294
  const instructionCount = decodeLength(byteArray);
2278
2295
  let instructions = [];
2279
2296
 
2280
2297
  for (let i = 0; i < instructionCount; i++) {
2281
- const programIdIndex = byteArray.shift();
2298
+ const programIdIndex = guardedShift(byteArray);
2282
2299
  const accountCount = decodeLength(byteArray);
2283
- const accounts = byteArray.slice(0, accountCount);
2284
- byteArray = byteArray.slice(accountCount);
2300
+ const accounts = guardedSplice(byteArray, 0, accountCount);
2285
2301
  const dataLength = decodeLength(byteArray);
2286
- const dataSlice = byteArray.slice(0, dataLength);
2302
+ const dataSlice = guardedSplice(byteArray, 0, dataLength);
2287
2303
  const data = bs58__default["default"].encode(buffer.Buffer.from(dataSlice));
2288
- byteArray = byteArray.slice(dataLength);
2289
2304
  instructions.push({
2290
2305
  programIdIndex,
2291
2306
  accounts,
@@ -2314,6 +2329,10 @@ function assert (condition, message) {
2314
2329
  }
2315
2330
  }
2316
2331
 
2332
+ /**
2333
+ * Transaction signature as base-58 encoded string
2334
+ */
2335
+
2317
2336
  /**
2318
2337
  * Default (empty) signature
2319
2338
  *
@@ -2351,12 +2370,9 @@ class TransactionInstruction {
2351
2370
  * Program input
2352
2371
  */
2353
2372
  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
-
2373
+ this.keys = void 0;
2374
+ this.programId = void 0;
2375
+ this.data = buffer.Buffer.alloc(0);
2360
2376
  this.programId = opts.programId;
2361
2377
  this.keys = opts.keys;
2362
2378
 
@@ -2398,16 +2414,11 @@ class Transaction {
2398
2414
  * Construct an empty Transaction
2399
2415
  */
2400
2416
  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
-
2417
+ this.signatures = [];
2418
+ this.feePayer = void 0;
2419
+ this.instructions = [];
2420
+ this.recentBlockhash = void 0;
2421
+ this.nonceInfo = void 0;
2411
2422
  opts && Object.assign(this, opts);
2412
2423
  }
2413
2424
  /**
@@ -2471,7 +2482,7 @@ class Transaction {
2471
2482
 
2472
2483
  for (let i = 0; i < this.instructions.length; i++) {
2473
2484
  if (this.instructions[i].programId === undefined) {
2474
- throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
2485
+ throw new Error(`Transaction instruction index ${i} has undefined program id`);
2475
2486
  }
2476
2487
  }
2477
2488
 
@@ -2546,7 +2557,7 @@ class Transaction {
2546
2557
  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
2558
  }
2548
2559
  } else {
2549
- throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
2560
+ throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
2550
2561
  }
2551
2562
  }
2552
2563
 
@@ -2781,7 +2792,7 @@ class Transaction {
2781
2792
  const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
2782
2793
 
2783
2794
  if (index < 0) {
2784
- throw new Error("unknown signer: ".concat(pubkey.toString()));
2795
+ throw new Error(`unknown signer: ${pubkey.toString()}`);
2785
2796
  }
2786
2797
 
2787
2798
  this.signatures[index].signature = buffer.Buffer.from(signature);
@@ -2857,12 +2868,12 @@ class Transaction {
2857
2868
  signature
2858
2869
  }, index) => {
2859
2870
  if (signature !== null) {
2860
- assert(signature.length === 64, "signature has invalid length");
2871
+ assert(signature.length === 64, `signature has invalid length`);
2861
2872
  buffer.Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
2862
2873
  }
2863
2874
  });
2864
2875
  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));
2876
+ assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
2866
2877
  return wireTransaction;
2867
2878
  }
2868
2879
  /**
@@ -2907,8 +2918,7 @@ class Transaction {
2907
2918
  let signatures = [];
2908
2919
 
2909
2920
  for (let i = 0; i < signatureCount; i++) {
2910
- const signature = byteArray.slice(0, SIGNATURE_LENGTH);
2911
- byteArray = byteArray.slice(SIGNATURE_LENGTH);
2921
+ const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH);
2912
2922
  signatures.push(bs58__default["default"].encode(buffer.Buffer.from(signature)));
2913
2923
  }
2914
2924
 
@@ -2981,7 +2991,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2981
2991
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2982
2992
 
2983
2993
  if (status.err) {
2984
- throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
2994
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
2985
2995
  }
2986
2996
 
2987
2997
  return signature;
@@ -3024,7 +3034,7 @@ function decodeData(type, buffer) {
3024
3034
  }
3025
3035
 
3026
3036
  if (data.instruction !== type.index) {
3027
- throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
3037
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
3028
3038
  }
3029
3039
 
3030
3040
  return data;
@@ -3058,12 +3068,9 @@ class NonceAccount {
3058
3068
  * @internal
3059
3069
  */
3060
3070
  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
-
3071
+ this.authorizedPubkey = void 0;
3072
+ this.nonce = void 0;
3073
+ this.feeCalculator = void 0;
3067
3074
  this.authorizedPubkey = args.authorizedPubkey;
3068
3075
  this.nonce = args.nonce;
3069
3076
  this.feeCalculator = args.feeCalculator;
@@ -3364,7 +3371,7 @@ class SystemInstruction {
3364
3371
 
3365
3372
  static checkKeyLength(keys, expectedLength) {
3366
3373
  if (keys.length < expectedLength) {
3367
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
3374
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
3368
3375
  }
3369
3376
  }
3370
3377
 
@@ -3796,8 +3803,7 @@ class SystemProgram {
3796
3803
  }
3797
3804
 
3798
3805
  }
3799
-
3800
- _defineProperty__default["default"](SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3806
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3801
3807
 
3802
3808
  // rest of the Transaction fields
3803
3809
  //
@@ -3966,8 +3972,7 @@ class Loader {
3966
3972
  }
3967
3973
 
3968
3974
  }
3969
-
3970
- _defineProperty__default["default"](Loader, "chunkSize", CHUNK_SIZE);
3975
+ Loader.chunkSize = CHUNK_SIZE;
3971
3976
 
3972
3977
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
3973
3978
  /**
@@ -4018,14 +4023,10 @@ class AgentManager {
4018
4023
  }
4019
4024
 
4020
4025
  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
-
4026
+ this._agent = void 0;
4027
+ this._activeRequests = 0;
4028
+ this._destroyTimeout = null;
4029
+ this._useHttps = void 0;
4029
4030
  this._useHttps = useHttps === true;
4030
4031
  this._agent = AgentManager._newAgent(this._useHttps);
4031
4032
  }
@@ -4098,16 +4099,11 @@ class EpochSchedule {
4098
4099
 
4099
4100
  /** The first slot of `firstNormalEpoch` */
4100
4101
  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
-
4102
+ this.slotsPerEpoch = void 0;
4103
+ this.leaderScheduleSlotOffset = void 0;
4104
+ this.warmup = void 0;
4105
+ this.firstNormalEpoch = void 0;
4106
+ this.firstNormalSlot = void 0;
4111
4107
  this.slotsPerEpoch = slotsPerEpoch;
4112
4108
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
4113
4109
  this.warmup = warmup;
@@ -4159,9 +4155,7 @@ class EpochSchedule {
4159
4155
  class SendTransactionError extends Error {
4160
4156
  constructor(message, logs) {
4161
4157
  super(message);
4162
-
4163
- _defineProperty__default["default"](this, "logs", void 0);
4164
-
4158
+ this.logs = void 0;
4165
4159
  this.logs = logs;
4166
4160
  }
4167
4161
 
@@ -4445,7 +4439,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4445
4439
  break;
4446
4440
  }
4447
4441
 
4448
- console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
4442
+ console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
4449
4443
  await sleep(waitTime);
4450
4444
  waitTime *= 2;
4451
4445
  }
@@ -4455,7 +4449,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4455
4449
  if (res.ok) {
4456
4450
  callback(null, text);
4457
4451
  } else {
4458
- callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
4452
+ callback(new Error(`${res.status} ${res.statusText}: ${text}`));
4459
4453
  }
4460
4454
  } catch (err) {
4461
4455
  if (err instanceof Error) callback(err);
@@ -5121,67 +5115,39 @@ class Connection {
5121
5115
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
5122
5116
  */
5123
5117
  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", {
5118
+ this._commitment = void 0;
5119
+ this._confirmTransactionInitialTimeout = void 0;
5120
+ this._rpcEndpoint = void 0;
5121
+ this._rpcWsEndpoint = void 0;
5122
+ this._rpcClient = void 0;
5123
+ this._rpcRequest = void 0;
5124
+ this._rpcBatchRequest = void 0;
5125
+ this._rpcWebSocket = void 0;
5126
+ this._rpcWebSocketConnected = false;
5127
+ this._rpcWebSocketHeartbeat = null;
5128
+ this._rpcWebSocketIdleTimeout = null;
5129
+ this._disableBlockhashCaching = false;
5130
+ this._pollingBlockhash = false;
5131
+ this._blockhashInfo = {
5151
5132
  recentBlockhash: null,
5152
5133
  lastFetch: 0,
5153
5134
  transactionSignatures: [],
5154
5135
  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
-
5136
+ };
5137
+ this._accountChangeSubscriptionCounter = 0;
5138
+ this._accountChangeSubscriptions = {};
5139
+ this._programAccountChangeSubscriptionCounter = 0;
5140
+ this._programAccountChangeSubscriptions = {};
5141
+ this._rootSubscriptionCounter = 0;
5142
+ this._rootSubscriptions = {};
5143
+ this._signatureSubscriptionCounter = 0;
5144
+ this._signatureSubscriptions = {};
5145
+ this._slotSubscriptionCounter = 0;
5146
+ this._slotSubscriptions = {};
5147
+ this._logsSubscriptionCounter = 0;
5148
+ this._logsSubscriptions = {};
5149
+ this._slotUpdateSubscriptionCounter = 0;
5150
+ this._slotUpdateSubscriptions = {};
5185
5151
  let url = new URL(endpoint);
5186
5152
  const useHttps = url.protocol === 'https:';
5187
5153
  let wsEndpoint;
@@ -5555,7 +5521,7 @@ class Connection {
5555
5521
  const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
5556
5522
 
5557
5523
  if ('error' in res) {
5558
- throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
5524
+ throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
5559
5525
  }
5560
5526
 
5561
5527
  return res.result;
@@ -5691,7 +5657,7 @@ class Connection {
5691
5657
 
5692
5658
  if (response === null) {
5693
5659
  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."));
5660
+ 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
5661
  }
5696
5662
 
5697
5663
  return response;
@@ -6465,7 +6431,7 @@ class Connection {
6465
6431
  await sleep(MS_PER_SLOT / 2);
6466
6432
  }
6467
6433
 
6468
- throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
6434
+ throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
6469
6435
  } finally {
6470
6436
  this._pollingBlockhash = false;
6471
6437
  }
@@ -6722,7 +6688,7 @@ class Connection {
6722
6688
  }
6723
6689
 
6724
6690
  if (err instanceof Error) {
6725
- console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
6691
+ console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
6726
6692
  }
6727
6693
  }
6728
6694
  }
@@ -6742,7 +6708,7 @@ class Connection {
6742
6708
  await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
6743
6709
  } catch (err) {
6744
6710
  if (err instanceof Error) {
6745
- console.error("".concat(rpcMethod, " error:"), err.message);
6711
+ console.error(`${rpcMethod} error:`, err.message);
6746
6712
  }
6747
6713
  }
6748
6714
  }
@@ -6907,7 +6873,7 @@ class Connection {
6907
6873
 
6908
6874
  this._updateSubscriptions();
6909
6875
  } else {
6910
- throw new Error("Unknown account change id: ".concat(id));
6876
+ throw new Error(`Unknown account change id: ${id}`);
6911
6877
  }
6912
6878
  }
6913
6879
  /**
@@ -6973,7 +6939,7 @@ class Connection {
6973
6939
 
6974
6940
  this._updateSubscriptions();
6975
6941
  } else {
6976
- throw new Error("Unknown program account change id: ".concat(id));
6942
+ throw new Error(`Unknown program account change id: ${id}`);
6977
6943
  }
6978
6944
  }
6979
6945
  /**
@@ -7003,7 +6969,7 @@ class Connection {
7003
6969
 
7004
6970
  async removeOnLogsListener(id) {
7005
6971
  if (!this._logsSubscriptions[id]) {
7006
- throw new Error("Unknown logs id: ".concat(id));
6972
+ throw new Error(`Unknown logs id: ${id}`);
7007
6973
  }
7008
6974
 
7009
6975
  const subInfo = this._logsSubscriptions[id];
@@ -7079,7 +7045,7 @@ class Connection {
7079
7045
 
7080
7046
  this._updateSubscriptions();
7081
7047
  } else {
7082
- throw new Error("Unknown slot change id: ".concat(id));
7048
+ throw new Error(`Unknown slot change id: ${id}`);
7083
7049
  }
7084
7050
  }
7085
7051
  /**
@@ -7132,7 +7098,7 @@ class Connection {
7132
7098
 
7133
7099
  this._updateSubscriptions();
7134
7100
  } else {
7135
- throw new Error("Unknown slot update id: ".concat(id));
7101
+ throw new Error(`Unknown slot update id: ${id}`);
7136
7102
  }
7137
7103
  }
7138
7104
 
@@ -7273,7 +7239,7 @@ class Connection {
7273
7239
 
7274
7240
  this._updateSubscriptions();
7275
7241
  } else {
7276
- throw new Error("Unknown signature result id: ".concat(id));
7242
+ throw new Error(`Unknown signature result id: ${id}`);
7277
7243
  }
7278
7244
  }
7279
7245
  /**
@@ -7325,7 +7291,7 @@ class Connection {
7325
7291
 
7326
7292
  this._updateSubscriptions();
7327
7293
  } else {
7328
- throw new Error("Unknown root change id: ".concat(id));
7294
+ throw new Error(`Unknown root change id: ${id}`);
7329
7295
  }
7330
7296
  }
7331
7297
 
@@ -7346,7 +7312,7 @@ class Keypair {
7346
7312
  * @param keypair ed25519 keypair
7347
7313
  */
7348
7314
  constructor(keypair) {
7349
- _defineProperty__default["default"](this, "_keypair", void 0);
7315
+ this._keypair = void 0;
7350
7316
 
7351
7317
  if (keypair) {
7352
7318
  this._keypair = keypair;
@@ -7450,8 +7416,8 @@ class Ed25519Program {
7450
7416
  signature,
7451
7417
  instructionIndex
7452
7418
  } = 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"));
7419
+ assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
7420
+ assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
7455
7421
  const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
7456
7422
  const signatureOffset = publicKeyOffset + publicKey.length;
7457
7423
  const messageDataOffset = signatureOffset + signature.length;
@@ -7489,7 +7455,7 @@ class Ed25519Program {
7489
7455
  message,
7490
7456
  instructionIndex
7491
7457
  } = 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"));
7458
+ assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
7493
7459
 
7494
7460
  try {
7495
7461
  const keypair = Keypair.fromSecretKey(privateKey);
@@ -7502,13 +7468,12 @@ class Ed25519Program {
7502
7468
  instructionIndex
7503
7469
  });
7504
7470
  } catch (error) {
7505
- throw new Error("Error creating instruction; ".concat(error));
7471
+ throw new Error(`Error creating instruction; ${error}`);
7506
7472
  }
7507
7473
  }
7508
7474
 
7509
7475
  }
7510
-
7511
- _defineProperty__default["default"](Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7476
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7512
7477
 
7513
7478
  /**
7514
7479
  * Address of the stake config account which configures the rate
@@ -7531,10 +7496,8 @@ class Authorized {
7531
7496
  * @param withdrawer the withdraw authority
7532
7497
  */
7533
7498
  constructor(staker, withdrawer) {
7534
- _defineProperty__default["default"](this, "staker", void 0);
7535
-
7536
- _defineProperty__default["default"](this, "withdrawer", void 0);
7537
-
7499
+ this.staker = void 0;
7500
+ this.withdrawer = void 0;
7538
7501
  this.staker = staker;
7539
7502
  this.withdrawer = withdrawer;
7540
7503
  }
@@ -7555,12 +7518,9 @@ class Lockup {
7555
7518
  * Create a new Lockup object
7556
7519
  */
7557
7520
  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
-
7521
+ this.unixTimestamp = void 0;
7522
+ this.epoch = void 0;
7523
+ this.custodian = void 0;
7564
7524
  this.unixTimestamp = unixTimestamp;
7565
7525
  this.epoch = epoch;
7566
7526
  this.custodian = custodian;
@@ -7575,7 +7535,7 @@ class Lockup {
7575
7535
  * Create stake account transaction params
7576
7536
  */
7577
7537
 
7578
- _defineProperty__default["default"](Lockup, "default", new Lockup(0, 0, PublicKey.default));
7538
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
7579
7539
 
7580
7540
  /**
7581
7541
  * Stake Instruction class
@@ -7788,7 +7748,7 @@ class StakeInstruction {
7788
7748
 
7789
7749
  static checkKeyLength(keys, expectedLength) {
7790
7750
  if (keys.length < expectedLength) {
7791
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
7751
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
7792
7752
  }
7793
7753
  }
7794
7754
 
@@ -8263,10 +8223,8 @@ class StakeProgram {
8263
8223
  }
8264
8224
 
8265
8225
  }
8266
-
8267
- _defineProperty__default["default"](StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
8268
-
8269
- _defineProperty__default["default"](StakeProgram, "space", 200);
8226
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8227
+ StakeProgram.space = 200;
8270
8228
 
8271
8229
  const {
8272
8230
  publicKeyCreate,
@@ -8296,12 +8254,12 @@ class Secp256k1Program {
8296
8254
  * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
8297
8255
  */
8298
8256
  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"));
8257
+ assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8300
8258
 
8301
8259
  try {
8302
8260
  return buffer.Buffer.from(jsSha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8303
8261
  } catch (error) {
8304
- throw new Error("Error constructing Ethereum address: ".concat(error));
8262
+ throw new Error(`Error constructing Ethereum address: ${error}`);
8305
8263
  }
8306
8264
  }
8307
8265
  /**
@@ -8352,7 +8310,7 @@ class Secp256k1Program {
8352
8310
  ethAddress = rawAddress;
8353
8311
  }
8354
8312
 
8355
- assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
8313
+ assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
8356
8314
  const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
8357
8315
  const ethAddressOffset = dataStart;
8358
8316
  const signatureOffset = dataStart + ethAddress.length;
@@ -8391,7 +8349,7 @@ class Secp256k1Program {
8391
8349
  message,
8392
8350
  instructionIndex
8393
8351
  } = params;
8394
- assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
8352
+ assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
8395
8353
 
8396
8354
  try {
8397
8355
  const privateKey = toBuffer(pkey);
@@ -8410,13 +8368,12 @@ class Secp256k1Program {
8410
8368
  instructionIndex
8411
8369
  });
8412
8370
  } catch (error) {
8413
- throw new Error("Error creating instruction; ".concat(error));
8371
+ throw new Error(`Error creating instruction; ${error}`);
8414
8372
  }
8415
8373
  }
8416
8374
 
8417
8375
  }
8418
-
8419
- _defineProperty__default["default"](Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8376
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
8420
8377
 
8421
8378
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
8422
8379
  /**
@@ -8449,10 +8406,8 @@ class ValidatorInfo {
8449
8406
  * @param info validator information
8450
8407
  */
8451
8408
  constructor(key, info) {
8452
- _defineProperty__default["default"](this, "key", void 0);
8453
-
8454
- _defineProperty__default["default"](this, "info", void 0);
8455
-
8409
+ this.key = void 0;
8410
+ this.info = void 0;
8456
8411
  this.key = key;
8457
8412
  this.info = info;
8458
8413
  }
@@ -8473,10 +8428,8 @@ class ValidatorInfo {
8473
8428
  const configKeys = [];
8474
8429
 
8475
8430
  for (let i = 0; i < 2; i++) {
8476
- const publicKey = new PublicKey(byteArray.slice(0, PUBKEY_LENGTH));
8477
- byteArray = byteArray.slice(PUBKEY_LENGTH);
8478
- const isSigner = byteArray.slice(0, 1)[0] === 1;
8479
- byteArray = byteArray.slice(1);
8431
+ const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBKEY_LENGTH));
8432
+ const isSigner = guardedShift(byteArray) === 1;
8480
8433
  configKeys.push({
8481
8434
  publicKey,
8482
8435
  isSigner
@@ -8516,26 +8469,16 @@ class VoteAccount {
8516
8469
  * @internal
8517
8470
  */
8518
8471
  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
-
8472
+ this.nodePubkey = void 0;
8473
+ this.authorizedVoterPubkey = void 0;
8474
+ this.authorizedWithdrawerPubkey = void 0;
8475
+ this.commission = void 0;
8476
+ this.votes = void 0;
8477
+ this.rootSlot = void 0;
8478
+ this.epoch = void 0;
8479
+ this.credits = void 0;
8480
+ this.lastEpochCredits = void 0;
8481
+ this.epochCredits = void 0;
8539
8482
  this.nodePubkey = args.nodePubkey;
8540
8483
  this.authorizedVoterPubkey = args.authorizedVoterPubkey;
8541
8484
  this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
@@ -8598,7 +8541,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
8598
8541
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
8599
8542
 
8600
8543
  if (status.err) {
8601
- throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
8544
+ throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
8602
8545
  }
8603
8546
 
8604
8547
  return signature;
@@ -8630,7 +8573,7 @@ function clusterApiUrl(cluster, tls) {
8630
8573
  const url = endpoint[key][cluster];
8631
8574
 
8632
8575
  if (!url) {
8633
- throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
8576
+ throw new Error(`Unknown ${key} cluster: ${cluster}`);
8634
8577
  }
8635
8578
 
8636
8579
  return url;