@solana/web3.js 1.29.3 → 1.31.0

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,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)) {
@@ -60,743 +58,334 @@ const toBuffer = arr => {
60
58
  }
61
59
  };
62
60
 
63
- const version$2 = "logger/5.5.0";
61
+ var hash$1 = {};
64
62
 
65
- let _permanentCensorErrors = false;
66
- let _censorErrors = false;
67
- const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
68
- let _logLevel = LogLevels["default"];
69
- let _globalLogger = null;
70
- function _checkNormalize() {
71
- try {
72
- const missing = [];
73
- // Make sure all forms of normalization are supported
74
- ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
75
- try {
76
- if ("test".normalize(form) !== "test") {
77
- throw new Error("bad normalize");
78
- }
79
- ;
80
- }
81
- catch (error) {
82
- missing.push(form);
83
- }
84
- });
85
- if (missing.length) {
86
- throw new Error("missing " + missing.join(", "));
87
- }
88
- if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
89
- throw new Error("broken implementation");
63
+ var utils$9 = {};
64
+
65
+ var minimalisticAssert = assert$6;
66
+
67
+ function assert$6(val, msg) {
68
+ if (!val)
69
+ throw new Error(msg || 'Assertion failed');
70
+ }
71
+
72
+ assert$6.equal = function assertEqual(l, r, msg) {
73
+ if (l != r)
74
+ throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
75
+ };
76
+
77
+ var inherits$1 = {exports: {}};
78
+
79
+ var inherits_browser = {exports: {}};
80
+
81
+ if (typeof Object.create === 'function') {
82
+ // implementation from standard node.js 'util' module
83
+ inherits_browser.exports = function inherits(ctor, superCtor) {
84
+ ctor.super_ = superCtor;
85
+ ctor.prototype = Object.create(superCtor.prototype, {
86
+ constructor: {
87
+ value: ctor,
88
+ enumerable: false,
89
+ writable: true,
90
+ configurable: true
91
+ }
92
+ });
93
+ };
94
+ } else {
95
+ // old school shim for old browsers
96
+ inherits_browser.exports = function inherits(ctor, superCtor) {
97
+ ctor.super_ = superCtor;
98
+ var TempCtor = function () {};
99
+ TempCtor.prototype = superCtor.prototype;
100
+ ctor.prototype = new TempCtor();
101
+ ctor.prototype.constructor = ctor;
102
+ };
103
+ }
104
+
105
+ try {
106
+ var util = require('util');
107
+ if (typeof util.inherits !== 'function') throw '';
108
+ inherits$1.exports = util.inherits;
109
+ } catch (e) {
110
+ inherits$1.exports = inherits_browser.exports;
111
+ }
112
+
113
+ var assert$5 = minimalisticAssert;
114
+ var inherits = inherits$1.exports;
115
+
116
+ utils$9.inherits = inherits;
117
+
118
+ function isSurrogatePair(msg, i) {
119
+ if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
120
+ return false;
121
+ }
122
+ if (i < 0 || i + 1 >= msg.length) {
123
+ return false;
124
+ }
125
+ return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
126
+ }
127
+
128
+ function toArray(msg, enc) {
129
+ if (Array.isArray(msg))
130
+ return msg.slice();
131
+ if (!msg)
132
+ return [];
133
+ var res = [];
134
+ if (typeof msg === 'string') {
135
+ if (!enc) {
136
+ // Inspired by stringToUtf8ByteArray() in closure-library by Google
137
+ // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
138
+ // Apache License 2.0
139
+ // https://github.com/google/closure-library/blob/master/LICENSE
140
+ var p = 0;
141
+ for (var i = 0; i < msg.length; i++) {
142
+ var c = msg.charCodeAt(i);
143
+ if (c < 128) {
144
+ res[p++] = c;
145
+ } else if (c < 2048) {
146
+ res[p++] = (c >> 6) | 192;
147
+ res[p++] = (c & 63) | 128;
148
+ } else if (isSurrogatePair(msg, i)) {
149
+ c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
150
+ res[p++] = (c >> 18) | 240;
151
+ res[p++] = ((c >> 12) & 63) | 128;
152
+ res[p++] = ((c >> 6) & 63) | 128;
153
+ res[p++] = (c & 63) | 128;
154
+ } else {
155
+ res[p++] = (c >> 12) | 224;
156
+ res[p++] = ((c >> 6) & 63) | 128;
157
+ res[p++] = (c & 63) | 128;
90
158
  }
159
+ }
160
+ } else if (enc === 'hex') {
161
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
162
+ if (msg.length % 2 !== 0)
163
+ msg = '0' + msg;
164
+ for (i = 0; i < msg.length; i += 2)
165
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
91
166
  }
92
- catch (error) {
93
- return error.message;
167
+ } else {
168
+ for (i = 0; i < msg.length; i++)
169
+ res[i] = msg[i] | 0;
170
+ }
171
+ return res;
172
+ }
173
+ utils$9.toArray = toArray;
174
+
175
+ function toHex(msg) {
176
+ var res = '';
177
+ for (var i = 0; i < msg.length; i++)
178
+ res += zero2(msg[i].toString(16));
179
+ return res;
180
+ }
181
+ utils$9.toHex = toHex;
182
+
183
+ function htonl(w) {
184
+ var res = (w >>> 24) |
185
+ ((w >>> 8) & 0xff00) |
186
+ ((w << 8) & 0xff0000) |
187
+ ((w & 0xff) << 24);
188
+ return res >>> 0;
189
+ }
190
+ utils$9.htonl = htonl;
191
+
192
+ function toHex32(msg, endian) {
193
+ var res = '';
194
+ for (var i = 0; i < msg.length; i++) {
195
+ var w = msg[i];
196
+ if (endian === 'little')
197
+ w = htonl(w);
198
+ res += zero8(w.toString(16));
199
+ }
200
+ return res;
201
+ }
202
+ utils$9.toHex32 = toHex32;
203
+
204
+ function zero2(word) {
205
+ if (word.length === 1)
206
+ return '0' + word;
207
+ else
208
+ return word;
209
+ }
210
+ utils$9.zero2 = zero2;
211
+
212
+ function zero8(word) {
213
+ if (word.length === 7)
214
+ return '0' + word;
215
+ else if (word.length === 6)
216
+ return '00' + word;
217
+ else if (word.length === 5)
218
+ return '000' + word;
219
+ else if (word.length === 4)
220
+ return '0000' + word;
221
+ else if (word.length === 3)
222
+ return '00000' + word;
223
+ else if (word.length === 2)
224
+ return '000000' + word;
225
+ else if (word.length === 1)
226
+ return '0000000' + word;
227
+ else
228
+ return word;
229
+ }
230
+ utils$9.zero8 = zero8;
231
+
232
+ function join32(msg, start, end, endian) {
233
+ var len = end - start;
234
+ assert$5(len % 4 === 0);
235
+ var res = new Array(len / 4);
236
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
237
+ var w;
238
+ if (endian === 'big')
239
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
240
+ else
241
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
242
+ res[i] = w >>> 0;
243
+ }
244
+ return res;
245
+ }
246
+ utils$9.join32 = join32;
247
+
248
+ function split32(msg, endian) {
249
+ var res = new Array(msg.length * 4);
250
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
251
+ var m = msg[i];
252
+ if (endian === 'big') {
253
+ res[k] = m >>> 24;
254
+ res[k + 1] = (m >>> 16) & 0xff;
255
+ res[k + 2] = (m >>> 8) & 0xff;
256
+ res[k + 3] = m & 0xff;
257
+ } else {
258
+ res[k + 3] = m >>> 24;
259
+ res[k + 2] = (m >>> 16) & 0xff;
260
+ res[k + 1] = (m >>> 8) & 0xff;
261
+ res[k] = m & 0xff;
94
262
  }
95
- return null;
263
+ }
264
+ return res;
96
265
  }
97
- const _normalizeError = _checkNormalize();
98
- var LogLevel;
99
- (function (LogLevel) {
100
- LogLevel["DEBUG"] = "DEBUG";
101
- LogLevel["INFO"] = "INFO";
102
- LogLevel["WARNING"] = "WARNING";
103
- LogLevel["ERROR"] = "ERROR";
104
- LogLevel["OFF"] = "OFF";
105
- })(LogLevel || (LogLevel = {}));
106
- var ErrorCode;
107
- (function (ErrorCode) {
108
- ///////////////////
109
- // Generic Errors
110
- // Unknown Error
111
- ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
112
- // Not Implemented
113
- ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
114
- // Unsupported Operation
115
- // - operation
116
- ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
117
- // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
118
- // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
119
- ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
120
- // Some sort of bad response from the server
121
- ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
122
- // Timeout
123
- ErrorCode["TIMEOUT"] = "TIMEOUT";
124
- ///////////////////
125
- // Operational Errors
126
- // Buffer Overrun
127
- ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
128
- // Numeric Fault
129
- // - operation: the operation being executed
130
- // - fault: the reason this faulted
131
- ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
132
- ///////////////////
133
- // Argument Errors
134
- // Missing new operator to an object
135
- // - name: The name of the class
136
- ErrorCode["MISSING_NEW"] = "MISSING_NEW";
137
- // Invalid argument (e.g. value is incompatible with type) to a function:
138
- // - argument: The argument name that was invalid
139
- // - value: The value of the argument
140
- ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
141
- // Missing argument to a function:
142
- // - count: The number of arguments received
143
- // - expectedCount: The number of arguments expected
144
- ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
145
- // Too many arguments
146
- // - count: The number of arguments received
147
- // - expectedCount: The number of arguments expected
148
- ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
149
- ///////////////////
150
- // Blockchain Errors
151
- // Call exception
152
- // - transaction: the transaction
153
- // - address?: the contract address
154
- // - args?: The arguments passed into the function
155
- // - method?: The Solidity method signature
156
- // - errorSignature?: The EIP848 error signature
157
- // - errorArgs?: The EIP848 error parameters
158
- // - reason: The reason (only for EIP848 "Error(string)")
159
- ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
160
- // Insufficient funds (< value + gasLimit * gasPrice)
161
- // - transaction: the transaction attempted
162
- ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
163
- // Nonce has already been used
164
- // - transaction: the transaction attempted
165
- ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
166
- // The replacement fee for the transaction is too low
167
- // - transaction: the transaction attempted
168
- ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
169
- // The gas limit could not be estimated
170
- // - transaction: the transaction passed to estimateGas
171
- ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
172
- // The transaction was replaced by one with a higher gas price
173
- // - reason: "cancelled", "replaced" or "repriced"
174
- // - cancelled: true if reason == "cancelled" or reason == "replaced")
175
- // - hash: original transaction hash
176
- // - replacement: the full TransactionsResponse for the replacement
177
- // - receipt: the receipt of the replacement
178
- ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
179
- })(ErrorCode || (ErrorCode = {}));
180
- const HEX = "0123456789abcdef";
181
- class Logger {
182
- constructor(version) {
183
- Object.defineProperty(this, "version", {
184
- enumerable: true,
185
- value: version,
186
- writable: false
187
- });
188
- }
189
- _log(logLevel, args) {
190
- const level = logLevel.toLowerCase();
191
- if (LogLevels[level] == null) {
192
- this.throwArgumentError("invalid log level name", "logLevel", logLevel);
193
- }
194
- if (_logLevel > LogLevels[level]) {
195
- return;
196
- }
197
- console.log.apply(console, args);
198
- }
199
- debug(...args) {
200
- this._log(Logger.levels.DEBUG, args);
201
- }
202
- info(...args) {
203
- this._log(Logger.levels.INFO, args);
204
- }
205
- warn(...args) {
206
- this._log(Logger.levels.WARNING, args);
207
- }
208
- makeError(message, code, params) {
209
- // Errors are being censored
210
- if (_censorErrors) {
211
- return this.makeError("censored error", code, {});
212
- }
213
- if (!code) {
214
- code = Logger.errors.UNKNOWN_ERROR;
215
- }
216
- if (!params) {
217
- params = {};
218
- }
219
- const messageDetails = [];
220
- Object.keys(params).forEach((key) => {
221
- const value = params[key];
222
- try {
223
- if (value instanceof Uint8Array) {
224
- let hex = "";
225
- for (let i = 0; i < value.length; i++) {
226
- hex += HEX[value[i] >> 4];
227
- hex += HEX[value[i] & 0x0f];
228
- }
229
- messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
230
- }
231
- else {
232
- messageDetails.push(key + "=" + JSON.stringify(value));
233
- }
234
- }
235
- catch (error) {
236
- messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
237
- }
238
- });
239
- messageDetails.push(`code=${code}`);
240
- messageDetails.push(`version=${this.version}`);
241
- const reason = message;
242
- if (messageDetails.length) {
243
- message += " (" + messageDetails.join(", ") + ")";
244
- }
245
- // @TODO: Any??
246
- const error = new Error(message);
247
- error.reason = reason;
248
- error.code = code;
249
- Object.keys(params).forEach(function (key) {
250
- error[key] = params[key];
251
- });
252
- return error;
253
- }
254
- throwError(message, code, params) {
255
- throw this.makeError(message, code, params);
256
- }
257
- throwArgumentError(message, name, value) {
258
- return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
259
- argument: name,
260
- value: value
261
- });
262
- }
263
- assert(condition, message, code, params) {
264
- if (!!condition) {
265
- return;
266
- }
267
- this.throwError(message, code, params);
268
- }
269
- assertArgument(condition, message, name, value) {
270
- if (!!condition) {
271
- return;
272
- }
273
- this.throwArgumentError(message, name, value);
274
- }
275
- checkNormalize(message) {
276
- if (_normalizeError) {
277
- this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
278
- operation: "String.prototype.normalize", form: _normalizeError
279
- });
280
- }
281
- }
282
- checkSafeUint53(value, message) {
283
- if (typeof (value) !== "number") {
284
- return;
285
- }
286
- if (message == null) {
287
- message = "value not safe";
288
- }
289
- if (value < 0 || value >= 0x1fffffffffffff) {
290
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
291
- operation: "checkSafeInteger",
292
- fault: "out-of-safe-range",
293
- value: value
294
- });
295
- }
296
- if (value % 1) {
297
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
298
- operation: "checkSafeInteger",
299
- fault: "non-integer",
300
- value: value
301
- });
302
- }
303
- }
304
- checkArgumentCount(count, expectedCount, message) {
305
- if (message) {
306
- message = ": " + message;
307
- }
308
- else {
309
- message = "";
310
- }
311
- if (count < expectedCount) {
312
- this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
313
- count: count,
314
- expectedCount: expectedCount
315
- });
316
- }
317
- if (count > expectedCount) {
318
- this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
319
- count: count,
320
- expectedCount: expectedCount
321
- });
322
- }
323
- }
324
- checkNew(target, kind) {
325
- if (target === Object || target == null) {
326
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
327
- }
328
- }
329
- checkAbstract(target, kind) {
330
- if (target === kind) {
331
- this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
332
- }
333
- else if (target === Object || target == null) {
334
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
335
- }
336
- }
337
- static globalLogger() {
338
- if (!_globalLogger) {
339
- _globalLogger = new Logger(version$2);
340
- }
341
- return _globalLogger;
342
- }
343
- static setCensorship(censorship, permanent) {
344
- if (!censorship && permanent) {
345
- this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
346
- operation: "setCensorship"
347
- });
348
- }
349
- if (_permanentCensorErrors) {
350
- if (!censorship) {
351
- return;
352
- }
353
- this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
354
- operation: "setCensorship"
355
- });
356
- }
357
- _censorErrors = !!censorship;
358
- _permanentCensorErrors = !!permanent;
359
- }
360
- static setLogLevel(logLevel) {
361
- const level = LogLevels[logLevel.toLowerCase()];
362
- if (level == null) {
363
- Logger.globalLogger().warn("invalid log level - " + logLevel);
364
- return;
365
- }
366
- _logLevel = level;
367
- }
368
- static from(version) {
369
- return new Logger(version);
370
- }
371
- }
372
- Logger.errors = ErrorCode;
373
- Logger.levels = LogLevel;
266
+ utils$9.split32 = split32;
374
267
 
375
- const version$1 = "bytes/5.5.0";
268
+ function rotr32$1(w, b) {
269
+ return (w >>> b) | (w << (32 - b));
270
+ }
271
+ utils$9.rotr32 = rotr32$1;
376
272
 
377
- const logger = new Logger(version$1);
378
- ///////////////////////////////
379
- function isHexable(value) {
380
- return !!(value.toHexString);
273
+ function rotl32$2(w, b) {
274
+ return (w << b) | (w >>> (32 - b));
381
275
  }
382
- function addSlice(array) {
383
- if (array.slice) {
384
- return array;
385
- }
386
- array.slice = function () {
387
- const args = Array.prototype.slice.call(arguments);
388
- return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
389
- };
390
- return array;
276
+ utils$9.rotl32 = rotl32$2;
277
+
278
+ function sum32$3(a, b) {
279
+ return (a + b) >>> 0;
391
280
  }
392
- function isInteger(value) {
393
- return (typeof (value) === "number" && value == value && (value % 1) === 0);
281
+ utils$9.sum32 = sum32$3;
282
+
283
+ function sum32_3$1(a, b, c) {
284
+ return (a + b + c) >>> 0;
394
285
  }
395
- function isBytes(value) {
396
- if (value == null) {
397
- return false;
398
- }
399
- if (value.constructor === Uint8Array) {
400
- return true;
401
- }
402
- if (typeof (value) === "string") {
403
- return false;
404
- }
405
- if (!isInteger(value.length) || value.length < 0) {
406
- return false;
407
- }
408
- for (let i = 0; i < value.length; i++) {
409
- const v = value[i];
410
- if (!isInteger(v) || v < 0 || v >= 256) {
411
- return false;
412
- }
413
- }
414
- return true;
286
+ utils$9.sum32_3 = sum32_3$1;
287
+
288
+ function sum32_4$2(a, b, c, d) {
289
+ return (a + b + c + d) >>> 0;
415
290
  }
416
- function arrayify(value, options) {
417
- if (!options) {
418
- options = {};
419
- }
420
- if (typeof (value) === "number") {
421
- logger.checkSafeUint53(value, "invalid arrayify value");
422
- const result = [];
423
- while (value) {
424
- result.unshift(value & 0xff);
425
- value = parseInt(String(value / 256));
426
- }
427
- if (result.length === 0) {
428
- result.push(0);
429
- }
430
- return addSlice(new Uint8Array(result));
431
- }
432
- if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
433
- value = "0x" + value;
434
- }
435
- if (isHexable(value)) {
436
- value = value.toHexString();
437
- }
438
- if (isHexString(value)) {
439
- let hex = value.substring(2);
440
- if (hex.length % 2) {
441
- if (options.hexPad === "left") {
442
- hex = "0x0" + hex.substring(2);
443
- }
444
- else if (options.hexPad === "right") {
445
- hex += "0";
446
- }
447
- else {
448
- logger.throwArgumentError("hex data is odd-length", "value", value);
449
- }
450
- }
451
- const result = [];
452
- for (let i = 0; i < hex.length; i += 2) {
453
- result.push(parseInt(hex.substring(i, i + 2), 16));
454
- }
455
- return addSlice(new Uint8Array(result));
456
- }
457
- if (isBytes(value)) {
458
- return addSlice(new Uint8Array(value));
459
- }
460
- return logger.throwArgumentError("invalid arrayify value", "value", value);
291
+ utils$9.sum32_4 = sum32_4$2;
292
+
293
+ function sum32_5$2(a, b, c, d, e) {
294
+ return (a + b + c + d + e) >>> 0;
461
295
  }
462
- function isHexString(value, length) {
463
- if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
464
- return false;
465
- }
466
- if (length && value.length !== 2 + 2 * length) {
467
- return false;
468
- }
469
- return true;
296
+ utils$9.sum32_5 = sum32_5$2;
297
+
298
+ function sum64$1(buf, pos, ah, al) {
299
+ var bh = buf[pos];
300
+ var bl = buf[pos + 1];
301
+
302
+ var lo = (al + bl) >>> 0;
303
+ var hi = (lo < al ? 1 : 0) + ah + bh;
304
+ buf[pos] = hi >>> 0;
305
+ buf[pos + 1] = lo;
470
306
  }
307
+ utils$9.sum64 = sum64$1;
471
308
 
472
- var hash$1 = {};
309
+ function sum64_hi$1(ah, al, bh, bl) {
310
+ var lo = (al + bl) >>> 0;
311
+ var hi = (lo < al ? 1 : 0) + ah + bh;
312
+ return hi >>> 0;
313
+ }
314
+ utils$9.sum64_hi = sum64_hi$1;
473
315
 
474
- var utils$9 = {};
316
+ function sum64_lo$1(ah, al, bh, bl) {
317
+ var lo = al + bl;
318
+ return lo >>> 0;
319
+ }
320
+ utils$9.sum64_lo = sum64_lo$1;
475
321
 
476
- var minimalisticAssert = assert$6;
322
+ function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
323
+ var carry = 0;
324
+ var lo = al;
325
+ lo = (lo + bl) >>> 0;
326
+ carry += lo < al ? 1 : 0;
327
+ lo = (lo + cl) >>> 0;
328
+ carry += lo < cl ? 1 : 0;
329
+ lo = (lo + dl) >>> 0;
330
+ carry += lo < dl ? 1 : 0;
477
331
 
478
- function assert$6(val, msg) {
479
- if (!val)
480
- throw new Error(msg || 'Assertion failed');
332
+ var hi = ah + bh + ch + dh + carry;
333
+ return hi >>> 0;
481
334
  }
335
+ utils$9.sum64_4_hi = sum64_4_hi$1;
482
336
 
483
- assert$6.equal = function assertEqual(l, r, msg) {
484
- if (l != r)
485
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
486
- };
337
+ function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
338
+ var lo = al + bl + cl + dl;
339
+ return lo >>> 0;
340
+ }
341
+ utils$9.sum64_4_lo = sum64_4_lo$1;
487
342
 
488
- var inherits$1 = {exports: {}};
343
+ function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
344
+ var carry = 0;
345
+ var lo = al;
346
+ lo = (lo + bl) >>> 0;
347
+ carry += lo < al ? 1 : 0;
348
+ lo = (lo + cl) >>> 0;
349
+ carry += lo < cl ? 1 : 0;
350
+ lo = (lo + dl) >>> 0;
351
+ carry += lo < dl ? 1 : 0;
352
+ lo = (lo + el) >>> 0;
353
+ carry += lo < el ? 1 : 0;
489
354
 
490
- var inherits_browser = {exports: {}};
355
+ var hi = ah + bh + ch + dh + eh + carry;
356
+ return hi >>> 0;
357
+ }
358
+ utils$9.sum64_5_hi = sum64_5_hi$1;
491
359
 
492
- if (typeof Object.create === 'function') {
493
- // implementation from standard node.js 'util' module
494
- inherits_browser.exports = function inherits(ctor, superCtor) {
495
- ctor.super_ = superCtor;
496
- ctor.prototype = Object.create(superCtor.prototype, {
497
- constructor: {
498
- value: ctor,
499
- enumerable: false,
500
- writable: true,
501
- configurable: true
502
- }
503
- });
504
- };
505
- } else {
506
- // old school shim for old browsers
507
- inherits_browser.exports = function inherits(ctor, superCtor) {
508
- ctor.super_ = superCtor;
509
- var TempCtor = function () {};
510
- TempCtor.prototype = superCtor.prototype;
511
- ctor.prototype = new TempCtor();
512
- ctor.prototype.constructor = ctor;
513
- };
360
+ function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
361
+ var lo = al + bl + cl + dl + el;
362
+
363
+ return lo >>> 0;
514
364
  }
365
+ utils$9.sum64_5_lo = sum64_5_lo$1;
515
366
 
516
- try {
517
- var util = require('util');
518
- if (typeof util.inherits !== 'function') throw '';
519
- inherits$1.exports = util.inherits;
520
- } catch (e) {
521
- inherits$1.exports = inherits_browser.exports;
367
+ function rotr64_hi$1(ah, al, num) {
368
+ var r = (al << (32 - num)) | (ah >>> num);
369
+ return r >>> 0;
522
370
  }
371
+ utils$9.rotr64_hi = rotr64_hi$1;
523
372
 
524
- var assert$5 = minimalisticAssert;
525
- var inherits = inherits$1.exports;
373
+ function rotr64_lo$1(ah, al, num) {
374
+ var r = (ah << (32 - num)) | (al >>> num);
375
+ return r >>> 0;
376
+ }
377
+ utils$9.rotr64_lo = rotr64_lo$1;
526
378
 
527
- utils$9.inherits = inherits;
379
+ function shr64_hi$1(ah, al, num) {
380
+ return ah >>> num;
381
+ }
382
+ utils$9.shr64_hi = shr64_hi$1;
528
383
 
529
- function isSurrogatePair(msg, i) {
530
- if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
531
- return false;
532
- }
533
- if (i < 0 || i + 1 >= msg.length) {
534
- return false;
535
- }
536
- return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
384
+ function shr64_lo$1(ah, al, num) {
385
+ var r = (ah << (32 - num)) | (al >>> num);
386
+ return r >>> 0;
537
387
  }
538
-
539
- function toArray(msg, enc) {
540
- if (Array.isArray(msg))
541
- return msg.slice();
542
- if (!msg)
543
- return [];
544
- var res = [];
545
- if (typeof msg === 'string') {
546
- if (!enc) {
547
- // Inspired by stringToUtf8ByteArray() in closure-library by Google
548
- // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
549
- // Apache License 2.0
550
- // https://github.com/google/closure-library/blob/master/LICENSE
551
- var p = 0;
552
- for (var i = 0; i < msg.length; i++) {
553
- var c = msg.charCodeAt(i);
554
- if (c < 128) {
555
- res[p++] = c;
556
- } else if (c < 2048) {
557
- res[p++] = (c >> 6) | 192;
558
- res[p++] = (c & 63) | 128;
559
- } else if (isSurrogatePair(msg, i)) {
560
- c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
561
- res[p++] = (c >> 18) | 240;
562
- res[p++] = ((c >> 12) & 63) | 128;
563
- res[p++] = ((c >> 6) & 63) | 128;
564
- res[p++] = (c & 63) | 128;
565
- } else {
566
- res[p++] = (c >> 12) | 224;
567
- res[p++] = ((c >> 6) & 63) | 128;
568
- res[p++] = (c & 63) | 128;
569
- }
570
- }
571
- } else if (enc === 'hex') {
572
- msg = msg.replace(/[^a-z0-9]+/ig, '');
573
- if (msg.length % 2 !== 0)
574
- msg = '0' + msg;
575
- for (i = 0; i < msg.length; i += 2)
576
- res.push(parseInt(msg[i] + msg[i + 1], 16));
577
- }
578
- } else {
579
- for (i = 0; i < msg.length; i++)
580
- res[i] = msg[i] | 0;
581
- }
582
- return res;
583
- }
584
- utils$9.toArray = toArray;
585
-
586
- function toHex(msg) {
587
- var res = '';
588
- for (var i = 0; i < msg.length; i++)
589
- res += zero2(msg[i].toString(16));
590
- return res;
591
- }
592
- utils$9.toHex = toHex;
593
-
594
- function htonl(w) {
595
- var res = (w >>> 24) |
596
- ((w >>> 8) & 0xff00) |
597
- ((w << 8) & 0xff0000) |
598
- ((w & 0xff) << 24);
599
- return res >>> 0;
600
- }
601
- utils$9.htonl = htonl;
602
-
603
- function toHex32(msg, endian) {
604
- var res = '';
605
- for (var i = 0; i < msg.length; i++) {
606
- var w = msg[i];
607
- if (endian === 'little')
608
- w = htonl(w);
609
- res += zero8(w.toString(16));
610
- }
611
- return res;
612
- }
613
- utils$9.toHex32 = toHex32;
614
-
615
- function zero2(word) {
616
- if (word.length === 1)
617
- return '0' + word;
618
- else
619
- return word;
620
- }
621
- utils$9.zero2 = zero2;
622
-
623
- function zero8(word) {
624
- if (word.length === 7)
625
- return '0' + word;
626
- else if (word.length === 6)
627
- return '00' + word;
628
- else if (word.length === 5)
629
- return '000' + word;
630
- else if (word.length === 4)
631
- return '0000' + word;
632
- else if (word.length === 3)
633
- return '00000' + word;
634
- else if (word.length === 2)
635
- return '000000' + word;
636
- else if (word.length === 1)
637
- return '0000000' + word;
638
- else
639
- return word;
640
- }
641
- utils$9.zero8 = zero8;
642
-
643
- function join32(msg, start, end, endian) {
644
- var len = end - start;
645
- assert$5(len % 4 === 0);
646
- var res = new Array(len / 4);
647
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
648
- var w;
649
- if (endian === 'big')
650
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
651
- else
652
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
653
- res[i] = w >>> 0;
654
- }
655
- return res;
656
- }
657
- utils$9.join32 = join32;
658
-
659
- function split32(msg, endian) {
660
- var res = new Array(msg.length * 4);
661
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
662
- var m = msg[i];
663
- if (endian === 'big') {
664
- res[k] = m >>> 24;
665
- res[k + 1] = (m >>> 16) & 0xff;
666
- res[k + 2] = (m >>> 8) & 0xff;
667
- res[k + 3] = m & 0xff;
668
- } else {
669
- res[k + 3] = m >>> 24;
670
- res[k + 2] = (m >>> 16) & 0xff;
671
- res[k + 1] = (m >>> 8) & 0xff;
672
- res[k] = m & 0xff;
673
- }
674
- }
675
- return res;
676
- }
677
- utils$9.split32 = split32;
678
-
679
- function rotr32$1(w, b) {
680
- return (w >>> b) | (w << (32 - b));
681
- }
682
- utils$9.rotr32 = rotr32$1;
683
-
684
- function rotl32$2(w, b) {
685
- return (w << b) | (w >>> (32 - b));
686
- }
687
- utils$9.rotl32 = rotl32$2;
688
-
689
- function sum32$3(a, b) {
690
- return (a + b) >>> 0;
691
- }
692
- utils$9.sum32 = sum32$3;
693
-
694
- function sum32_3$1(a, b, c) {
695
- return (a + b + c) >>> 0;
696
- }
697
- utils$9.sum32_3 = sum32_3$1;
698
-
699
- function sum32_4$2(a, b, c, d) {
700
- return (a + b + c + d) >>> 0;
701
- }
702
- utils$9.sum32_4 = sum32_4$2;
703
-
704
- function sum32_5$2(a, b, c, d, e) {
705
- return (a + b + c + d + e) >>> 0;
706
- }
707
- utils$9.sum32_5 = sum32_5$2;
708
-
709
- function sum64$1(buf, pos, ah, al) {
710
- var bh = buf[pos];
711
- var bl = buf[pos + 1];
712
-
713
- var lo = (al + bl) >>> 0;
714
- var hi = (lo < al ? 1 : 0) + ah + bh;
715
- buf[pos] = hi >>> 0;
716
- buf[pos + 1] = lo;
717
- }
718
- utils$9.sum64 = sum64$1;
719
-
720
- function sum64_hi$1(ah, al, bh, bl) {
721
- var lo = (al + bl) >>> 0;
722
- var hi = (lo < al ? 1 : 0) + ah + bh;
723
- return hi >>> 0;
724
- }
725
- utils$9.sum64_hi = sum64_hi$1;
726
-
727
- function sum64_lo$1(ah, al, bh, bl) {
728
- var lo = al + bl;
729
- return lo >>> 0;
730
- }
731
- utils$9.sum64_lo = sum64_lo$1;
732
-
733
- function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
734
- var carry = 0;
735
- var lo = al;
736
- lo = (lo + bl) >>> 0;
737
- carry += lo < al ? 1 : 0;
738
- lo = (lo + cl) >>> 0;
739
- carry += lo < cl ? 1 : 0;
740
- lo = (lo + dl) >>> 0;
741
- carry += lo < dl ? 1 : 0;
742
-
743
- var hi = ah + bh + ch + dh + carry;
744
- return hi >>> 0;
745
- }
746
- utils$9.sum64_4_hi = sum64_4_hi$1;
747
-
748
- function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
749
- var lo = al + bl + cl + dl;
750
- return lo >>> 0;
751
- }
752
- utils$9.sum64_4_lo = sum64_4_lo$1;
753
-
754
- function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
755
- var carry = 0;
756
- var lo = al;
757
- lo = (lo + bl) >>> 0;
758
- carry += lo < al ? 1 : 0;
759
- lo = (lo + cl) >>> 0;
760
- carry += lo < cl ? 1 : 0;
761
- lo = (lo + dl) >>> 0;
762
- carry += lo < dl ? 1 : 0;
763
- lo = (lo + el) >>> 0;
764
- carry += lo < el ? 1 : 0;
765
-
766
- var hi = ah + bh + ch + dh + eh + carry;
767
- return hi >>> 0;
768
- }
769
- utils$9.sum64_5_hi = sum64_5_hi$1;
770
-
771
- function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
772
- var lo = al + bl + cl + dl + el;
773
-
774
- return lo >>> 0;
775
- }
776
- utils$9.sum64_5_lo = sum64_5_lo$1;
777
-
778
- function rotr64_hi$1(ah, al, num) {
779
- var r = (al << (32 - num)) | (ah >>> num);
780
- return r >>> 0;
781
- }
782
- utils$9.rotr64_hi = rotr64_hi$1;
783
-
784
- function rotr64_lo$1(ah, al, num) {
785
- var r = (ah << (32 - num)) | (al >>> num);
786
- return r >>> 0;
787
- }
788
- utils$9.rotr64_lo = rotr64_lo$1;
789
-
790
- function shr64_hi$1(ah, al, num) {
791
- return ah >>> num;
792
- }
793
- utils$9.shr64_hi = shr64_hi$1;
794
-
795
- function shr64_lo$1(ah, al, num) {
796
- var r = (ah << (32 - num)) | (al >>> num);
797
- return r >>> 0;
798
- }
799
- utils$9.shr64_lo = shr64_lo$1;
388
+ utils$9.shr64_lo = shr64_lo$1;
800
389
 
801
390
  var common$5 = {};
802
391
 
@@ -1678,57 +1267,466 @@ function Hmac(hash, key, enc) {
1678
1267
 
1679
1268
  this._init(utils.toArray(key, enc));
1680
1269
  }
1681
- var hmac = Hmac;
1682
-
1683
- Hmac.prototype._init = function init(key) {
1684
- // Shorten key, if needed
1685
- if (key.length > this.blockSize)
1686
- key = new this.Hash().update(key).digest();
1687
- assert$1(key.length <= this.blockSize);
1688
-
1689
- // Add padding to key
1690
- for (var i = key.length; i < this.blockSize; i++)
1691
- key.push(0);
1692
-
1693
- for (i = 0; i < key.length; i++)
1694
- key[i] ^= 0x36;
1695
- this.inner = new this.Hash().update(key);
1696
-
1697
- // 0x36 ^ 0x5c = 0x6a
1698
- for (i = 0; i < key.length; i++)
1699
- key[i] ^= 0x6a;
1700
- this.outer = new this.Hash().update(key);
1701
- };
1702
-
1703
- Hmac.prototype.update = function update(msg, enc) {
1704
- this.inner.update(msg, enc);
1705
- return this;
1706
- };
1707
-
1708
- Hmac.prototype.digest = function digest(enc) {
1709
- this.outer.update(this.inner.digest());
1710
- return this.outer.digest(enc);
1711
- };
1712
-
1713
- (function (exports) {
1714
- var hash = exports;
1715
-
1716
- hash.utils = utils$9;
1717
- hash.common = common$5;
1718
- hash.sha = sha;
1719
- hash.ripemd = ripemd;
1720
- hash.hmac = hmac;
1270
+ var hmac = Hmac;
1271
+
1272
+ Hmac.prototype._init = function init(key) {
1273
+ // Shorten key, if needed
1274
+ if (key.length > this.blockSize)
1275
+ key = new this.Hash().update(key).digest();
1276
+ assert$1(key.length <= this.blockSize);
1277
+
1278
+ // Add padding to key
1279
+ for (var i = key.length; i < this.blockSize; i++)
1280
+ key.push(0);
1281
+
1282
+ for (i = 0; i < key.length; i++)
1283
+ key[i] ^= 0x36;
1284
+ this.inner = new this.Hash().update(key);
1285
+
1286
+ // 0x36 ^ 0x5c = 0x6a
1287
+ for (i = 0; i < key.length; i++)
1288
+ key[i] ^= 0x6a;
1289
+ this.outer = new this.Hash().update(key);
1290
+ };
1291
+
1292
+ Hmac.prototype.update = function update(msg, enc) {
1293
+ this.inner.update(msg, enc);
1294
+ return this;
1295
+ };
1296
+
1297
+ Hmac.prototype.digest = function digest(enc) {
1298
+ this.outer.update(this.inner.digest());
1299
+ return this.outer.digest(enc);
1300
+ };
1301
+
1302
+ (function (exports) {
1303
+ var hash = exports;
1304
+
1305
+ hash.utils = utils$9;
1306
+ hash.common = common$5;
1307
+ hash.sha = sha;
1308
+ hash.ripemd = ripemd;
1309
+ hash.hmac = hmac;
1310
+
1311
+ // Proxy hash functions to the main object
1312
+ hash.sha1 = hash.sha.sha1;
1313
+ hash.sha256 = hash.sha.sha256;
1314
+ hash.sha224 = hash.sha.sha224;
1315
+ hash.sha384 = hash.sha.sha384;
1316
+ hash.sha512 = hash.sha.sha512;
1317
+ hash.ripemd160 = hash.ripemd.ripemd160;
1318
+ }(hash$1));
1319
+
1320
+ var hash = hash$1;
1321
+
1322
+ const version$2 = "logger/5.5.0";
1323
+
1324
+ let _permanentCensorErrors = false;
1325
+ let _censorErrors = false;
1326
+ const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
1327
+ let _logLevel = LogLevels["default"];
1328
+ let _globalLogger = null;
1329
+ function _checkNormalize() {
1330
+ try {
1331
+ const missing = [];
1332
+ // Make sure all forms of normalization are supported
1333
+ ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
1334
+ try {
1335
+ if ("test".normalize(form) !== "test") {
1336
+ throw new Error("bad normalize");
1337
+ }
1338
+ ;
1339
+ }
1340
+ catch (error) {
1341
+ missing.push(form);
1342
+ }
1343
+ });
1344
+ if (missing.length) {
1345
+ throw new Error("missing " + missing.join(", "));
1346
+ }
1347
+ if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
1348
+ throw new Error("broken implementation");
1349
+ }
1350
+ }
1351
+ catch (error) {
1352
+ return error.message;
1353
+ }
1354
+ return null;
1355
+ }
1356
+ const _normalizeError = _checkNormalize();
1357
+ var LogLevel;
1358
+ (function (LogLevel) {
1359
+ LogLevel["DEBUG"] = "DEBUG";
1360
+ LogLevel["INFO"] = "INFO";
1361
+ LogLevel["WARNING"] = "WARNING";
1362
+ LogLevel["ERROR"] = "ERROR";
1363
+ LogLevel["OFF"] = "OFF";
1364
+ })(LogLevel || (LogLevel = {}));
1365
+ var ErrorCode;
1366
+ (function (ErrorCode) {
1367
+ ///////////////////
1368
+ // Generic Errors
1369
+ // Unknown Error
1370
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1371
+ // Not Implemented
1372
+ ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
1373
+ // Unsupported Operation
1374
+ // - operation
1375
+ ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
1376
+ // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
1377
+ // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
1378
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
1379
+ // Some sort of bad response from the server
1380
+ ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
1381
+ // Timeout
1382
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
1383
+ ///////////////////
1384
+ // Operational Errors
1385
+ // Buffer Overrun
1386
+ ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
1387
+ // Numeric Fault
1388
+ // - operation: the operation being executed
1389
+ // - fault: the reason this faulted
1390
+ ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
1391
+ ///////////////////
1392
+ // Argument Errors
1393
+ // Missing new operator to an object
1394
+ // - name: The name of the class
1395
+ ErrorCode["MISSING_NEW"] = "MISSING_NEW";
1396
+ // Invalid argument (e.g. value is incompatible with type) to a function:
1397
+ // - argument: The argument name that was invalid
1398
+ // - value: The value of the argument
1399
+ ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
1400
+ // Missing argument to a function:
1401
+ // - count: The number of arguments received
1402
+ // - expectedCount: The number of arguments expected
1403
+ ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
1404
+ // Too many arguments
1405
+ // - count: The number of arguments received
1406
+ // - expectedCount: The number of arguments expected
1407
+ ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
1408
+ ///////////////////
1409
+ // Blockchain Errors
1410
+ // Call exception
1411
+ // - transaction: the transaction
1412
+ // - address?: the contract address
1413
+ // - args?: The arguments passed into the function
1414
+ // - method?: The Solidity method signature
1415
+ // - errorSignature?: The EIP848 error signature
1416
+ // - errorArgs?: The EIP848 error parameters
1417
+ // - reason: The reason (only for EIP848 "Error(string)")
1418
+ ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
1419
+ // Insufficient funds (< value + gasLimit * gasPrice)
1420
+ // - transaction: the transaction attempted
1421
+ ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
1422
+ // Nonce has already been used
1423
+ // - transaction: the transaction attempted
1424
+ ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
1425
+ // The replacement fee for the transaction is too low
1426
+ // - transaction: the transaction attempted
1427
+ ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
1428
+ // The gas limit could not be estimated
1429
+ // - transaction: the transaction passed to estimateGas
1430
+ ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
1431
+ // The transaction was replaced by one with a higher gas price
1432
+ // - reason: "cancelled", "replaced" or "repriced"
1433
+ // - cancelled: true if reason == "cancelled" or reason == "replaced")
1434
+ // - hash: original transaction hash
1435
+ // - replacement: the full TransactionsResponse for the replacement
1436
+ // - receipt: the receipt of the replacement
1437
+ ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
1438
+ })(ErrorCode || (ErrorCode = {}));
1439
+ const HEX = "0123456789abcdef";
1440
+ class Logger {
1441
+ constructor(version) {
1442
+ Object.defineProperty(this, "version", {
1443
+ enumerable: true,
1444
+ value: version,
1445
+ writable: false
1446
+ });
1447
+ }
1448
+ _log(logLevel, args) {
1449
+ const level = logLevel.toLowerCase();
1450
+ if (LogLevels[level] == null) {
1451
+ this.throwArgumentError("invalid log level name", "logLevel", logLevel);
1452
+ }
1453
+ if (_logLevel > LogLevels[level]) {
1454
+ return;
1455
+ }
1456
+ console.log.apply(console, args);
1457
+ }
1458
+ debug(...args) {
1459
+ this._log(Logger.levels.DEBUG, args);
1460
+ }
1461
+ info(...args) {
1462
+ this._log(Logger.levels.INFO, args);
1463
+ }
1464
+ warn(...args) {
1465
+ this._log(Logger.levels.WARNING, args);
1466
+ }
1467
+ makeError(message, code, params) {
1468
+ // Errors are being censored
1469
+ if (_censorErrors) {
1470
+ return this.makeError("censored error", code, {});
1471
+ }
1472
+ if (!code) {
1473
+ code = Logger.errors.UNKNOWN_ERROR;
1474
+ }
1475
+ if (!params) {
1476
+ params = {};
1477
+ }
1478
+ const messageDetails = [];
1479
+ Object.keys(params).forEach((key) => {
1480
+ const value = params[key];
1481
+ try {
1482
+ if (value instanceof Uint8Array) {
1483
+ let hex = "";
1484
+ for (let i = 0; i < value.length; i++) {
1485
+ hex += HEX[value[i] >> 4];
1486
+ hex += HEX[value[i] & 0x0f];
1487
+ }
1488
+ messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
1489
+ }
1490
+ else {
1491
+ messageDetails.push(key + "=" + JSON.stringify(value));
1492
+ }
1493
+ }
1494
+ catch (error) {
1495
+ messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
1496
+ }
1497
+ });
1498
+ messageDetails.push(`code=${code}`);
1499
+ messageDetails.push(`version=${this.version}`);
1500
+ const reason = message;
1501
+ if (messageDetails.length) {
1502
+ message += " (" + messageDetails.join(", ") + ")";
1503
+ }
1504
+ // @TODO: Any??
1505
+ const error = new Error(message);
1506
+ error.reason = reason;
1507
+ error.code = code;
1508
+ Object.keys(params).forEach(function (key) {
1509
+ error[key] = params[key];
1510
+ });
1511
+ return error;
1512
+ }
1513
+ throwError(message, code, params) {
1514
+ throw this.makeError(message, code, params);
1515
+ }
1516
+ throwArgumentError(message, name, value) {
1517
+ return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
1518
+ argument: name,
1519
+ value: value
1520
+ });
1521
+ }
1522
+ assert(condition, message, code, params) {
1523
+ if (!!condition) {
1524
+ return;
1525
+ }
1526
+ this.throwError(message, code, params);
1527
+ }
1528
+ assertArgument(condition, message, name, value) {
1529
+ if (!!condition) {
1530
+ return;
1531
+ }
1532
+ this.throwArgumentError(message, name, value);
1533
+ }
1534
+ checkNormalize(message) {
1535
+ if (_normalizeError) {
1536
+ this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
1537
+ operation: "String.prototype.normalize", form: _normalizeError
1538
+ });
1539
+ }
1540
+ }
1541
+ checkSafeUint53(value, message) {
1542
+ if (typeof (value) !== "number") {
1543
+ return;
1544
+ }
1545
+ if (message == null) {
1546
+ message = "value not safe";
1547
+ }
1548
+ if (value < 0 || value >= 0x1fffffffffffff) {
1549
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1550
+ operation: "checkSafeInteger",
1551
+ fault: "out-of-safe-range",
1552
+ value: value
1553
+ });
1554
+ }
1555
+ if (value % 1) {
1556
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1557
+ operation: "checkSafeInteger",
1558
+ fault: "non-integer",
1559
+ value: value
1560
+ });
1561
+ }
1562
+ }
1563
+ checkArgumentCount(count, expectedCount, message) {
1564
+ if (message) {
1565
+ message = ": " + message;
1566
+ }
1567
+ else {
1568
+ message = "";
1569
+ }
1570
+ if (count < expectedCount) {
1571
+ this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
1572
+ count: count,
1573
+ expectedCount: expectedCount
1574
+ });
1575
+ }
1576
+ if (count > expectedCount) {
1577
+ this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
1578
+ count: count,
1579
+ expectedCount: expectedCount
1580
+ });
1581
+ }
1582
+ }
1583
+ checkNew(target, kind) {
1584
+ if (target === Object || target == null) {
1585
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1586
+ }
1587
+ }
1588
+ checkAbstract(target, kind) {
1589
+ if (target === kind) {
1590
+ this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
1591
+ }
1592
+ else if (target === Object || target == null) {
1593
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1594
+ }
1595
+ }
1596
+ static globalLogger() {
1597
+ if (!_globalLogger) {
1598
+ _globalLogger = new Logger(version$2);
1599
+ }
1600
+ return _globalLogger;
1601
+ }
1602
+ static setCensorship(censorship, permanent) {
1603
+ if (!censorship && permanent) {
1604
+ this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
1605
+ operation: "setCensorship"
1606
+ });
1607
+ }
1608
+ if (_permanentCensorErrors) {
1609
+ if (!censorship) {
1610
+ return;
1611
+ }
1612
+ this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
1613
+ operation: "setCensorship"
1614
+ });
1615
+ }
1616
+ _censorErrors = !!censorship;
1617
+ _permanentCensorErrors = !!permanent;
1618
+ }
1619
+ static setLogLevel(logLevel) {
1620
+ const level = LogLevels[logLevel.toLowerCase()];
1621
+ if (level == null) {
1622
+ Logger.globalLogger().warn("invalid log level - " + logLevel);
1623
+ return;
1624
+ }
1625
+ _logLevel = level;
1626
+ }
1627
+ static from(version) {
1628
+ return new Logger(version);
1629
+ }
1630
+ }
1631
+ Logger.errors = ErrorCode;
1632
+ Logger.levels = LogLevel;
1721
1633
 
1722
- // Proxy hash functions to the main object
1723
- hash.sha1 = hash.sha.sha1;
1724
- hash.sha256 = hash.sha.sha256;
1725
- hash.sha224 = hash.sha.sha224;
1726
- hash.sha384 = hash.sha.sha384;
1727
- hash.sha512 = hash.sha.sha512;
1728
- hash.ripemd160 = hash.ripemd.ripemd160;
1729
- }(hash$1));
1634
+ const version$1 = "bytes/5.5.0";
1730
1635
 
1731
- var hash = hash$1;
1636
+ const logger = new Logger(version$1);
1637
+ ///////////////////////////////
1638
+ function isHexable(value) {
1639
+ return !!(value.toHexString);
1640
+ }
1641
+ function addSlice(array) {
1642
+ if (array.slice) {
1643
+ return array;
1644
+ }
1645
+ array.slice = function () {
1646
+ const args = Array.prototype.slice.call(arguments);
1647
+ return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
1648
+ };
1649
+ return array;
1650
+ }
1651
+ function isInteger(value) {
1652
+ return (typeof (value) === "number" && value == value && (value % 1) === 0);
1653
+ }
1654
+ function isBytes(value) {
1655
+ if (value == null) {
1656
+ return false;
1657
+ }
1658
+ if (value.constructor === Uint8Array) {
1659
+ return true;
1660
+ }
1661
+ if (typeof (value) === "string") {
1662
+ return false;
1663
+ }
1664
+ if (!isInteger(value.length) || value.length < 0) {
1665
+ return false;
1666
+ }
1667
+ for (let i = 0; i < value.length; i++) {
1668
+ const v = value[i];
1669
+ if (!isInteger(v) || v < 0 || v >= 256) {
1670
+ return false;
1671
+ }
1672
+ }
1673
+ return true;
1674
+ }
1675
+ function arrayify(value, options) {
1676
+ if (!options) {
1677
+ options = {};
1678
+ }
1679
+ if (typeof (value) === "number") {
1680
+ logger.checkSafeUint53(value, "invalid arrayify value");
1681
+ const result = [];
1682
+ while (value) {
1683
+ result.unshift(value & 0xff);
1684
+ value = parseInt(String(value / 256));
1685
+ }
1686
+ if (result.length === 0) {
1687
+ result.push(0);
1688
+ }
1689
+ return addSlice(new Uint8Array(result));
1690
+ }
1691
+ if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
1692
+ value = "0x" + value;
1693
+ }
1694
+ if (isHexable(value)) {
1695
+ value = value.toHexString();
1696
+ }
1697
+ if (isHexString(value)) {
1698
+ let hex = value.substring(2);
1699
+ if (hex.length % 2) {
1700
+ if (options.hexPad === "left") {
1701
+ hex = "0x0" + hex.substring(2);
1702
+ }
1703
+ else if (options.hexPad === "right") {
1704
+ hex += "0";
1705
+ }
1706
+ else {
1707
+ logger.throwArgumentError("hex data is odd-length", "value", value);
1708
+ }
1709
+ }
1710
+ const result = [];
1711
+ for (let i = 0; i < hex.length; i += 2) {
1712
+ result.push(parseInt(hex.substring(i, i + 2), 16));
1713
+ }
1714
+ return addSlice(new Uint8Array(result));
1715
+ }
1716
+ if (isBytes(value)) {
1717
+ return addSlice(new Uint8Array(value));
1718
+ }
1719
+ return logger.throwArgumentError("invalid arrayify value", "value", value);
1720
+ }
1721
+ function isHexString(value, length) {
1722
+ if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
1723
+ return false;
1724
+ }
1725
+ if (length && value.length !== 2 + 2 * length) {
1726
+ return false;
1727
+ }
1728
+ return true;
1729
+ }
1732
1730
 
1733
1731
  const version = "sha2/5.5.0";
1734
1732
 
@@ -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,12 +2026,12 @@ 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
- this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
2032
+ this._keypair = nacl__default["default"].sign.keyPair.fromSecretKey(toBuffer(secretKey));
2039
2033
  } else {
2040
- this._keypair = nacl__namespace.sign.keyPair();
2034
+ this._keypair = nacl__default["default"].sign.keyPair();
2041
2035
  }
2042
2036
  }
2043
2037
  /**
@@ -2168,16 +2162,11 @@ const PUBKEY_LENGTH = 32;
2168
2162
 
2169
2163
  class Message {
2170
2164
  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
-
2165
+ this.header = void 0;
2166
+ this.accountKeys = void 0;
2167
+ this.recentBlockhash = void 0;
2168
+ this.instructions = void 0;
2169
+ this.indexToProgramIds = new Map();
2181
2170
  this.header = args.header;
2182
2171
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
2183
2172
  this.recentBlockhash = args.recentBlockhash;
@@ -2351,12 +2340,9 @@ class TransactionInstruction {
2351
2340
  * Program input
2352
2341
  */
2353
2342
  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
-
2343
+ this.keys = void 0;
2344
+ this.programId = void 0;
2345
+ this.data = buffer.Buffer.alloc(0);
2360
2346
  this.programId = opts.programId;
2361
2347
  this.keys = opts.keys;
2362
2348
 
@@ -2398,16 +2384,11 @@ class Transaction {
2398
2384
  * Construct an empty Transaction
2399
2385
  */
2400
2386
  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
-
2387
+ this.signatures = [];
2388
+ this.feePayer = void 0;
2389
+ this.instructions = [];
2390
+ this.recentBlockhash = void 0;
2391
+ this.nonceInfo = void 0;
2411
2392
  opts && Object.assign(this, opts);
2412
2393
  }
2413
2394
  /**
@@ -2471,7 +2452,7 @@ class Transaction {
2471
2452
 
2472
2453
  for (let i = 0; i < this.instructions.length; i++) {
2473
2454
  if (this.instructions[i].programId === undefined) {
2474
- throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
2455
+ throw new Error(`Transaction instruction index ${i} has undefined program id`);
2475
2456
  }
2476
2457
  }
2477
2458
 
@@ -2546,7 +2527,7 @@ class Transaction {
2546
2527
  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
2528
  }
2548
2529
  } else {
2549
- throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
2530
+ throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
2550
2531
  }
2551
2532
  }
2552
2533
 
@@ -2781,7 +2762,7 @@ class Transaction {
2781
2762
  const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
2782
2763
 
2783
2764
  if (index < 0) {
2784
- throw new Error("unknown signer: ".concat(pubkey.toString()));
2765
+ throw new Error(`unknown signer: ${pubkey.toString()}`);
2785
2766
  }
2786
2767
 
2787
2768
  this.signatures[index].signature = buffer.Buffer.from(signature);
@@ -2857,12 +2838,12 @@ class Transaction {
2857
2838
  signature
2858
2839
  }, index) => {
2859
2840
  if (signature !== null) {
2860
- assert(signature.length === 64, "signature has invalid length");
2841
+ assert(signature.length === 64, `signature has invalid length`);
2861
2842
  buffer.Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
2862
2843
  }
2863
2844
  });
2864
2845
  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));
2846
+ assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
2866
2847
  return wireTransaction;
2867
2848
  }
2868
2849
  /**
@@ -2981,7 +2962,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2981
2962
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2982
2963
 
2983
2964
  if (status.err) {
2984
- throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
2965
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
2985
2966
  }
2986
2967
 
2987
2968
  return signature;
@@ -3024,7 +3005,7 @@ function decodeData(type, buffer) {
3024
3005
  }
3025
3006
 
3026
3007
  if (data.instruction !== type.index) {
3027
- throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
3008
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
3028
3009
  }
3029
3010
 
3030
3011
  return data;
@@ -3058,12 +3039,9 @@ class NonceAccount {
3058
3039
  * @internal
3059
3040
  */
3060
3041
  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
-
3042
+ this.authorizedPubkey = void 0;
3043
+ this.nonce = void 0;
3044
+ this.feeCalculator = void 0;
3067
3045
  this.authorizedPubkey = args.authorizedPubkey;
3068
3046
  this.nonce = args.nonce;
3069
3047
  this.feeCalculator = args.feeCalculator;
@@ -3364,7 +3342,7 @@ class SystemInstruction {
3364
3342
 
3365
3343
  static checkKeyLength(keys, expectedLength) {
3366
3344
  if (keys.length < expectedLength) {
3367
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
3345
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
3368
3346
  }
3369
3347
  }
3370
3348
 
@@ -3796,8 +3774,7 @@ class SystemProgram {
3796
3774
  }
3797
3775
 
3798
3776
  }
3799
-
3800
- _defineProperty__default["default"](SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3777
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3801
3778
 
3802
3779
  // rest of the Transaction fields
3803
3780
  //
@@ -3966,8 +3943,7 @@ class Loader {
3966
3943
  }
3967
3944
 
3968
3945
  }
3969
-
3970
- _defineProperty__default["default"](Loader, "chunkSize", CHUNK_SIZE);
3946
+ Loader.chunkSize = CHUNK_SIZE;
3971
3947
 
3972
3948
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
3973
3949
  /**
@@ -4018,14 +3994,10 @@ class AgentManager {
4018
3994
  }
4019
3995
 
4020
3996
  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
-
3997
+ this._agent = void 0;
3998
+ this._activeRequests = 0;
3999
+ this._destroyTimeout = null;
4000
+ this._useHttps = void 0;
4029
4001
  this._useHttps = useHttps === true;
4030
4002
  this._agent = AgentManager._newAgent(this._useHttps);
4031
4003
  }
@@ -4098,16 +4070,11 @@ class EpochSchedule {
4098
4070
 
4099
4071
  /** The first slot of `firstNormalEpoch` */
4100
4072
  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
-
4073
+ this.slotsPerEpoch = void 0;
4074
+ this.leaderScheduleSlotOffset = void 0;
4075
+ this.warmup = void 0;
4076
+ this.firstNormalEpoch = void 0;
4077
+ this.firstNormalSlot = void 0;
4111
4078
  this.slotsPerEpoch = slotsPerEpoch;
4112
4079
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
4113
4080
  this.warmup = warmup;
@@ -4159,9 +4126,7 @@ class EpochSchedule {
4159
4126
  class SendTransactionError extends Error {
4160
4127
  constructor(message, logs) {
4161
4128
  super(message);
4162
-
4163
- _defineProperty__default["default"](this, "logs", void 0);
4164
-
4129
+ this.logs = void 0;
4165
4130
  this.logs = logs;
4166
4131
  }
4167
4132
 
@@ -4445,7 +4410,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4445
4410
  break;
4446
4411
  }
4447
4412
 
4448
- console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
4413
+ console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
4449
4414
  await sleep(waitTime);
4450
4415
  waitTime *= 2;
4451
4416
  }
@@ -4455,7 +4420,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4455
4420
  if (res.ok) {
4456
4421
  callback(null, text);
4457
4422
  } else {
4458
- callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
4423
+ callback(new Error(`${res.status} ${res.statusText}: ${text}`));
4459
4424
  }
4460
4425
  } catch (err) {
4461
4426
  if (err instanceof Error) callback(err);
@@ -5121,67 +5086,39 @@ class Connection {
5121
5086
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
5122
5087
  */
5123
5088
  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", {
5089
+ this._commitment = void 0;
5090
+ this._confirmTransactionInitialTimeout = void 0;
5091
+ this._rpcEndpoint = void 0;
5092
+ this._rpcWsEndpoint = void 0;
5093
+ this._rpcClient = void 0;
5094
+ this._rpcRequest = void 0;
5095
+ this._rpcBatchRequest = void 0;
5096
+ this._rpcWebSocket = void 0;
5097
+ this._rpcWebSocketConnected = false;
5098
+ this._rpcWebSocketHeartbeat = null;
5099
+ this._rpcWebSocketIdleTimeout = null;
5100
+ this._disableBlockhashCaching = false;
5101
+ this._pollingBlockhash = false;
5102
+ this._blockhashInfo = {
5151
5103
  recentBlockhash: null,
5152
5104
  lastFetch: 0,
5153
5105
  transactionSignatures: [],
5154
5106
  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
-
5107
+ };
5108
+ this._accountChangeSubscriptionCounter = 0;
5109
+ this._accountChangeSubscriptions = {};
5110
+ this._programAccountChangeSubscriptionCounter = 0;
5111
+ this._programAccountChangeSubscriptions = {};
5112
+ this._rootSubscriptionCounter = 0;
5113
+ this._rootSubscriptions = {};
5114
+ this._signatureSubscriptionCounter = 0;
5115
+ this._signatureSubscriptions = {};
5116
+ this._slotSubscriptionCounter = 0;
5117
+ this._slotSubscriptions = {};
5118
+ this._logsSubscriptionCounter = 0;
5119
+ this._logsSubscriptions = {};
5120
+ this._slotUpdateSubscriptionCounter = 0;
5121
+ this._slotUpdateSubscriptions = {};
5185
5122
  let url = new URL(endpoint);
5186
5123
  const useHttps = url.protocol === 'https:';
5187
5124
  let wsEndpoint;
@@ -5316,10 +5253,24 @@ class Connection {
5316
5253
  */
5317
5254
 
5318
5255
 
5319
- async getSupply(commitment) {
5320
- const args = this._buildArgs([], commitment);
5256
+ async getSupply(config) {
5257
+ let configArg = {};
5258
+
5259
+ if (typeof config === 'string') {
5260
+ configArg = {
5261
+ commitment: config
5262
+ };
5263
+ } else if (config) {
5264
+ configArg = { ...config,
5265
+ commitment: config && config.commitment || this.commitment
5266
+ };
5267
+ } else {
5268
+ configArg = {
5269
+ commitment: this.commitment
5270
+ };
5271
+ }
5321
5272
 
5322
- const unsafeRes = await this._rpcRequest('getSupply', args);
5273
+ const unsafeRes = await this._rpcRequest('getSupply', [configArg]);
5323
5274
  const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
5324
5275
 
5325
5276
  if ('error' in res) {
@@ -5541,7 +5492,7 @@ class Connection {
5541
5492
  const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
5542
5493
 
5543
5494
  if ('error' in res) {
5544
- throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
5495
+ throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
5545
5496
  }
5546
5497
 
5547
5498
  return res.result;
@@ -5677,7 +5628,7 @@ class Connection {
5677
5628
 
5678
5629
  if (response === null) {
5679
5630
  const duration = (Date.now() - start) / 1000;
5680
- 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."));
5631
+ 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.`);
5681
5632
  }
5682
5633
 
5683
5634
  return response;
@@ -5830,16 +5781,11 @@ class Connection {
5830
5781
 
5831
5782
 
5832
5783
  async getTotalSupply(commitment) {
5833
- const args = this._buildArgs([], commitment);
5834
-
5835
- const unsafeRes = await this._rpcRequest('getSupply', args);
5836
- const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
5837
-
5838
- if ('error' in res) {
5839
- throw new Error('failed to get total supply: ' + res.error.message);
5840
- }
5841
-
5842
- return res.result.value.total;
5784
+ const result = await this.getSupply({
5785
+ commitment,
5786
+ excludeNonCirculatingAccountsList: true
5787
+ });
5788
+ return result.value.total;
5843
5789
  }
5844
5790
  /**
5845
5791
  * Fetch the cluster InflationGovernor parameters
@@ -6456,7 +6402,7 @@ class Connection {
6456
6402
  await sleep(MS_PER_SLOT / 2);
6457
6403
  }
6458
6404
 
6459
- throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
6405
+ throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
6460
6406
  } finally {
6461
6407
  this._pollingBlockhash = false;
6462
6408
  }
@@ -6713,7 +6659,7 @@ class Connection {
6713
6659
  }
6714
6660
 
6715
6661
  if (err instanceof Error) {
6716
- console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
6662
+ console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
6717
6663
  }
6718
6664
  }
6719
6665
  }
@@ -6733,7 +6679,7 @@ class Connection {
6733
6679
  await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
6734
6680
  } catch (err) {
6735
6681
  if (err instanceof Error) {
6736
- console.error("".concat(rpcMethod, " error:"), err.message);
6682
+ console.error(`${rpcMethod} error:`, err.message);
6737
6683
  }
6738
6684
  }
6739
6685
  }
@@ -6898,7 +6844,7 @@ class Connection {
6898
6844
 
6899
6845
  this._updateSubscriptions();
6900
6846
  } else {
6901
- throw new Error("Unknown account change id: ".concat(id));
6847
+ throw new Error(`Unknown account change id: ${id}`);
6902
6848
  }
6903
6849
  }
6904
6850
  /**
@@ -6964,7 +6910,7 @@ class Connection {
6964
6910
 
6965
6911
  this._updateSubscriptions();
6966
6912
  } else {
6967
- throw new Error("Unknown program account change id: ".concat(id));
6913
+ throw new Error(`Unknown program account change id: ${id}`);
6968
6914
  }
6969
6915
  }
6970
6916
  /**
@@ -6994,7 +6940,7 @@ class Connection {
6994
6940
 
6995
6941
  async removeOnLogsListener(id) {
6996
6942
  if (!this._logsSubscriptions[id]) {
6997
- throw new Error("Unknown logs id: ".concat(id));
6943
+ throw new Error(`Unknown logs id: ${id}`);
6998
6944
  }
6999
6945
 
7000
6946
  const subInfo = this._logsSubscriptions[id];
@@ -7070,7 +7016,7 @@ class Connection {
7070
7016
 
7071
7017
  this._updateSubscriptions();
7072
7018
  } else {
7073
- throw new Error("Unknown slot change id: ".concat(id));
7019
+ throw new Error(`Unknown slot change id: ${id}`);
7074
7020
  }
7075
7021
  }
7076
7022
  /**
@@ -7123,7 +7069,7 @@ class Connection {
7123
7069
 
7124
7070
  this._updateSubscriptions();
7125
7071
  } else {
7126
- throw new Error("Unknown slot update id: ".concat(id));
7072
+ throw new Error(`Unknown slot update id: ${id}`);
7127
7073
  }
7128
7074
  }
7129
7075
 
@@ -7264,7 +7210,7 @@ class Connection {
7264
7210
 
7265
7211
  this._updateSubscriptions();
7266
7212
  } else {
7267
- throw new Error("Unknown signature result id: ".concat(id));
7213
+ throw new Error(`Unknown signature result id: ${id}`);
7268
7214
  }
7269
7215
  }
7270
7216
  /**
@@ -7316,7 +7262,7 @@ class Connection {
7316
7262
 
7317
7263
  this._updateSubscriptions();
7318
7264
  } else {
7319
- throw new Error("Unknown root change id: ".concat(id));
7265
+ throw new Error(`Unknown root change id: ${id}`);
7320
7266
  }
7321
7267
  }
7322
7268
 
@@ -7337,12 +7283,12 @@ class Keypair {
7337
7283
  * @param keypair ed25519 keypair
7338
7284
  */
7339
7285
  constructor(keypair) {
7340
- _defineProperty__default["default"](this, "_keypair", void 0);
7286
+ this._keypair = void 0;
7341
7287
 
7342
7288
  if (keypair) {
7343
7289
  this._keypair = keypair;
7344
7290
  } else {
7345
- this._keypair = nacl__namespace.sign.keyPair();
7291
+ this._keypair = nacl__default["default"].sign.keyPair();
7346
7292
  }
7347
7293
  }
7348
7294
  /**
@@ -7351,7 +7297,7 @@ class Keypair {
7351
7297
 
7352
7298
 
7353
7299
  static generate() {
7354
- return new Keypair(nacl__namespace.sign.keyPair());
7300
+ return new Keypair(nacl__default["default"].sign.keyPair());
7355
7301
  }
7356
7302
  /**
7357
7303
  * Create a keypair from a raw secret key byte array.
@@ -7368,14 +7314,14 @@ class Keypair {
7368
7314
 
7369
7315
 
7370
7316
  static fromSecretKey(secretKey, options) {
7371
- const keypair = nacl__namespace.sign.keyPair.fromSecretKey(secretKey);
7317
+ const keypair = nacl__default["default"].sign.keyPair.fromSecretKey(secretKey);
7372
7318
 
7373
7319
  if (!options || !options.skipValidation) {
7374
7320
  const encoder = new TextEncoder();
7375
7321
  const signData = encoder.encode('@solana/web3.js-validation-v1');
7376
- const signature = nacl__namespace.sign.detached(signData, keypair.secretKey);
7322
+ const signature = nacl__default["default"].sign.detached(signData, keypair.secretKey);
7377
7323
 
7378
- if (!nacl__namespace.sign.detached.verify(signData, signature, keypair.publicKey)) {
7324
+ if (!nacl__default["default"].sign.detached.verify(signData, signature, keypair.publicKey)) {
7379
7325
  throw new Error('provided secretKey is invalid');
7380
7326
  }
7381
7327
  }
@@ -7390,7 +7336,7 @@ class Keypair {
7390
7336
 
7391
7337
 
7392
7338
  static fromSeed(seed) {
7393
- return new Keypair(nacl__namespace.sign.keyPair.fromSeed(seed));
7339
+ return new Keypair(nacl__default["default"].sign.keyPair.fromSeed(seed));
7394
7340
  }
7395
7341
  /**
7396
7342
  * The public key for this keypair
@@ -7441,8 +7387,8 @@ class Ed25519Program {
7441
7387
  signature,
7442
7388
  instructionIndex
7443
7389
  } = params;
7444
- assert(publicKey.length === PUBLIC_KEY_BYTES$1, "Public Key must be ".concat(PUBLIC_KEY_BYTES$1, " bytes but received ").concat(publicKey.length, " bytes"));
7445
- assert(signature.length === SIGNATURE_BYTES, "Signature must be ".concat(SIGNATURE_BYTES, " bytes but received ").concat(signature.length, " bytes"));
7390
+ assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
7391
+ assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
7446
7392
  const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
7447
7393
  const signatureOffset = publicKeyOffset + publicKey.length;
7448
7394
  const messageDataOffset = signatureOffset + signature.length;
@@ -7480,7 +7426,7 @@ class Ed25519Program {
7480
7426
  message,
7481
7427
  instructionIndex
7482
7428
  } = params;
7483
- assert(privateKey.length === PRIVATE_KEY_BYTES$1, "Private key must be ".concat(PRIVATE_KEY_BYTES$1, " bytes but received ").concat(privateKey.length, " bytes"));
7429
+ assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
7484
7430
 
7485
7431
  try {
7486
7432
  const keypair = Keypair.fromSecretKey(privateKey);
@@ -7493,13 +7439,12 @@ class Ed25519Program {
7493
7439
  instructionIndex
7494
7440
  });
7495
7441
  } catch (error) {
7496
- throw new Error("Error creating instruction; ".concat(error));
7442
+ throw new Error(`Error creating instruction; ${error}`);
7497
7443
  }
7498
7444
  }
7499
7445
 
7500
7446
  }
7501
-
7502
- _defineProperty__default["default"](Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7447
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7503
7448
 
7504
7449
  /**
7505
7450
  * Address of the stake config account which configures the rate
@@ -7522,10 +7467,8 @@ class Authorized {
7522
7467
  * @param withdrawer the withdraw authority
7523
7468
  */
7524
7469
  constructor(staker, withdrawer) {
7525
- _defineProperty__default["default"](this, "staker", void 0);
7526
-
7527
- _defineProperty__default["default"](this, "withdrawer", void 0);
7528
-
7470
+ this.staker = void 0;
7471
+ this.withdrawer = void 0;
7529
7472
  this.staker = staker;
7530
7473
  this.withdrawer = withdrawer;
7531
7474
  }
@@ -7546,12 +7489,9 @@ class Lockup {
7546
7489
  * Create a new Lockup object
7547
7490
  */
7548
7491
  constructor(unixTimestamp, epoch, custodian) {
7549
- _defineProperty__default["default"](this, "unixTimestamp", void 0);
7550
-
7551
- _defineProperty__default["default"](this, "epoch", void 0);
7552
-
7553
- _defineProperty__default["default"](this, "custodian", void 0);
7554
-
7492
+ this.unixTimestamp = void 0;
7493
+ this.epoch = void 0;
7494
+ this.custodian = void 0;
7555
7495
  this.unixTimestamp = unixTimestamp;
7556
7496
  this.epoch = epoch;
7557
7497
  this.custodian = custodian;
@@ -7566,7 +7506,7 @@ class Lockup {
7566
7506
  * Create stake account transaction params
7567
7507
  */
7568
7508
 
7569
- _defineProperty__default["default"](Lockup, "default", new Lockup(0, 0, PublicKey.default));
7509
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
7570
7510
 
7571
7511
  /**
7572
7512
  * Stake Instruction class
@@ -7779,7 +7719,7 @@ class StakeInstruction {
7779
7719
 
7780
7720
  static checkKeyLength(keys, expectedLength) {
7781
7721
  if (keys.length < expectedLength) {
7782
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
7722
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
7783
7723
  }
7784
7724
  }
7785
7725
 
@@ -8254,10 +8194,8 @@ class StakeProgram {
8254
8194
  }
8255
8195
 
8256
8196
  }
8257
-
8258
- _defineProperty__default["default"](StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
8259
-
8260
- _defineProperty__default["default"](StakeProgram, "space", 200);
8197
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8198
+ StakeProgram.space = 200;
8261
8199
 
8262
8200
  const {
8263
8201
  publicKeyCreate,
@@ -8287,12 +8225,12 @@ class Secp256k1Program {
8287
8225
  * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
8288
8226
  */
8289
8227
  static publicKeyToEthAddress(publicKey) {
8290
- assert(publicKey.length === PUBLIC_KEY_BYTES, "Public key must be ".concat(PUBLIC_KEY_BYTES, " bytes but received ").concat(publicKey.length, " bytes"));
8228
+ assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8291
8229
 
8292
8230
  try {
8293
- return buffer.Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8231
+ return buffer.Buffer.from(sha3__default["default"].keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8294
8232
  } catch (error) {
8295
- throw new Error("Error constructing Ethereum address: ".concat(error));
8233
+ throw new Error(`Error constructing Ethereum address: ${error}`);
8296
8234
  }
8297
8235
  }
8298
8236
  /**
@@ -8343,7 +8281,7 @@ class Secp256k1Program {
8343
8281
  ethAddress = rawAddress;
8344
8282
  }
8345
8283
 
8346
- assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
8284
+ assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
8347
8285
  const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
8348
8286
  const ethAddressOffset = dataStart;
8349
8287
  const signatureOffset = dataStart + ethAddress.length;
@@ -8382,13 +8320,13 @@ class Secp256k1Program {
8382
8320
  message,
8383
8321
  instructionIndex
8384
8322
  } = params;
8385
- assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
8323
+ assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
8386
8324
 
8387
8325
  try {
8388
8326
  const privateKey = toBuffer(pkey);
8389
8327
  const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
8390
8328
 
8391
- const messageHash = buffer.Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
8329
+ const messageHash = buffer.Buffer.from(sha3__default["default"].keccak_256.update(toBuffer(message)).digest());
8392
8330
  const {
8393
8331
  signature,
8394
8332
  recid: recoveryId
@@ -8401,13 +8339,12 @@ class Secp256k1Program {
8401
8339
  instructionIndex
8402
8340
  });
8403
8341
  } catch (error) {
8404
- throw new Error("Error creating instruction; ".concat(error));
8342
+ throw new Error(`Error creating instruction; ${error}`);
8405
8343
  }
8406
8344
  }
8407
8345
 
8408
8346
  }
8409
-
8410
- _defineProperty__default["default"](Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8347
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
8411
8348
 
8412
8349
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
8413
8350
  /**
@@ -8440,10 +8377,8 @@ class ValidatorInfo {
8440
8377
  * @param info validator information
8441
8378
  */
8442
8379
  constructor(key, info) {
8443
- _defineProperty__default["default"](this, "key", void 0);
8444
-
8445
- _defineProperty__default["default"](this, "info", void 0);
8446
-
8380
+ this.key = void 0;
8381
+ this.info = void 0;
8447
8382
  this.key = key;
8448
8383
  this.info = info;
8449
8384
  }
@@ -8507,26 +8442,16 @@ class VoteAccount {
8507
8442
  * @internal
8508
8443
  */
8509
8444
  constructor(args) {
8510
- _defineProperty__default["default"](this, "nodePubkey", void 0);
8511
-
8512
- _defineProperty__default["default"](this, "authorizedVoterPubkey", void 0);
8513
-
8514
- _defineProperty__default["default"](this, "authorizedWithdrawerPubkey", void 0);
8515
-
8516
- _defineProperty__default["default"](this, "commission", void 0);
8517
-
8518
- _defineProperty__default["default"](this, "votes", void 0);
8519
-
8520
- _defineProperty__default["default"](this, "rootSlot", void 0);
8521
-
8522
- _defineProperty__default["default"](this, "epoch", void 0);
8523
-
8524
- _defineProperty__default["default"](this, "credits", void 0);
8525
-
8526
- _defineProperty__default["default"](this, "lastEpochCredits", void 0);
8527
-
8528
- _defineProperty__default["default"](this, "epochCredits", void 0);
8529
-
8445
+ this.nodePubkey = void 0;
8446
+ this.authorizedVoterPubkey = void 0;
8447
+ this.authorizedWithdrawerPubkey = void 0;
8448
+ this.commission = void 0;
8449
+ this.votes = void 0;
8450
+ this.rootSlot = void 0;
8451
+ this.epoch = void 0;
8452
+ this.credits = void 0;
8453
+ this.lastEpochCredits = void 0;
8454
+ this.epochCredits = void 0;
8530
8455
  this.nodePubkey = args.nodePubkey;
8531
8456
  this.authorizedVoterPubkey = args.authorizedVoterPubkey;
8532
8457
  this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
@@ -8589,7 +8514,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
8589
8514
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
8590
8515
 
8591
8516
  if (status.err) {
8592
- throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
8517
+ throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
8593
8518
  }
8594
8519
 
8595
8520
  return signature;
@@ -8621,7 +8546,7 @@ function clusterApiUrl(cluster, tls) {
8621
8546
  const url = endpoint[key][cluster];
8622
8547
 
8623
8548
  if (!url) {
8624
- throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
8549
+ throw new Error(`Unknown ${key} cluster: ${cluster}`);
8625
8550
  }
8626
8551
 
8627
8552
  return url;