@solana/web3.js 1.30.0 → 1.32.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
 
@@ -1719,16 +1308,425 @@ hash.sha = sha;
1719
1308
  hash.ripemd = ripemd;
1720
1309
  hash.hmac = hmac;
1721
1310
 
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));
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;
1633
+
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
  }
@@ -1844,6 +1840,10 @@ class PublicKey extends Struct {
1844
1840
  toBase58() {
1845
1841
  return bs58__default["default"].encode(this.toBytes());
1846
1842
  }
1843
+
1844
+ toJSON() {
1845
+ return this.toBase58();
1846
+ }
1847
1847
  /**
1848
1848
  * Return the byte array representation of the public key
1849
1849
  */
@@ -1901,7 +1901,7 @@ class PublicKey extends Struct {
1901
1901
  let buffer$1 = buffer.Buffer.alloc(0);
1902
1902
  seeds.forEach(function (seed) {
1903
1903
  if (seed.length > MAX_SEED_LENGTH) {
1904
- throw new TypeError("Max seed length exceeded");
1904
+ throw new TypeError(`Max seed length exceeded`);
1905
1905
  }
1906
1906
 
1907
1907
  buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
@@ -1911,7 +1911,7 @@ class PublicKey extends Struct {
1911
1911
  let publicKeyBytes = new BN__default["default"](hash, 16).toArray(undefined, 32);
1912
1912
 
1913
1913
  if (is_on_curve(publicKeyBytes)) {
1914
- throw new Error("Invalid seeds, address must fall off the curve");
1914
+ throw new Error(`Invalid seeds, address must fall off the curve`);
1915
1915
  }
1916
1916
 
1917
1917
  return new PublicKey(publicKeyBytes);
@@ -1945,7 +1945,7 @@ class PublicKey extends Struct {
1945
1945
  return [address, nonce];
1946
1946
  }
1947
1947
 
1948
- throw new Error("Unable to find a viable program address nonce");
1948
+ throw new Error(`Unable to find a viable program address nonce`);
1949
1949
  }
1950
1950
  /**
1951
1951
  * Check that a pubkey is on the ed25519 curve.
@@ -1957,9 +1957,7 @@ class PublicKey extends Struct {
1957
1957
  }
1958
1958
 
1959
1959
  }
1960
-
1961
- _defineProperty__default["default"](PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
1962
-
1960
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
1963
1961
  SOLANA_SCHEMA.set(PublicKey, {
1964
1962
  kind: 'struct',
1965
1963
  fields: [['_bn', 'u256']]
@@ -2032,12 +2030,12 @@ class Account {
2032
2030
  * @param secretKey Secret key for the account
2033
2031
  */
2034
2032
  constructor(secretKey) {
2035
- _defineProperty__default["default"](this, "_keypair", void 0);
2033
+ this._keypair = void 0;
2036
2034
 
2037
2035
  if (secretKey) {
2038
- this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
2036
+ this._keypair = nacl__default["default"].sign.keyPair.fromSecretKey(toBuffer(secretKey));
2039
2037
  } else {
2040
- this._keypair = nacl__namespace.sign.keyPair();
2038
+ this._keypair = nacl__default["default"].sign.keyPair();
2041
2039
  }
2042
2040
  }
2043
2041
  /**
@@ -2168,16 +2166,11 @@ const PUBKEY_LENGTH = 32;
2168
2166
 
2169
2167
  class Message {
2170
2168
  constructor(args) {
2171
- _defineProperty__default["default"](this, "header", void 0);
2172
-
2173
- _defineProperty__default["default"](this, "accountKeys", void 0);
2174
-
2175
- _defineProperty__default["default"](this, "recentBlockhash", void 0);
2176
-
2177
- _defineProperty__default["default"](this, "instructions", void 0);
2178
-
2179
- _defineProperty__default["default"](this, "indexToProgramIds", new Map());
2180
-
2169
+ this.header = void 0;
2170
+ this.accountKeys = void 0;
2171
+ this.recentBlockhash = void 0;
2172
+ this.instructions = void 0;
2173
+ this.indexToProgramIds = new Map();
2181
2174
  this.header = args.header;
2182
2175
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
2183
2176
  this.recentBlockhash = args.recentBlockhash;
@@ -2351,12 +2344,9 @@ class TransactionInstruction {
2351
2344
  * Program input
2352
2345
  */
2353
2346
  constructor(opts) {
2354
- _defineProperty__default["default"](this, "keys", void 0);
2355
-
2356
- _defineProperty__default["default"](this, "programId", void 0);
2357
-
2358
- _defineProperty__default["default"](this, "data", buffer.Buffer.alloc(0));
2359
-
2347
+ this.keys = void 0;
2348
+ this.programId = void 0;
2349
+ this.data = buffer.Buffer.alloc(0);
2360
2350
  this.programId = opts.programId;
2361
2351
  this.keys = opts.keys;
2362
2352
 
@@ -2398,16 +2388,11 @@ class Transaction {
2398
2388
  * Construct an empty Transaction
2399
2389
  */
2400
2390
  constructor(opts) {
2401
- _defineProperty__default["default"](this, "signatures", []);
2402
-
2403
- _defineProperty__default["default"](this, "feePayer", void 0);
2404
-
2405
- _defineProperty__default["default"](this, "instructions", []);
2406
-
2407
- _defineProperty__default["default"](this, "recentBlockhash", void 0);
2408
-
2409
- _defineProperty__default["default"](this, "nonceInfo", void 0);
2410
-
2391
+ this.signatures = [];
2392
+ this.feePayer = void 0;
2393
+ this.instructions = [];
2394
+ this.recentBlockhash = void 0;
2395
+ this.nonceInfo = void 0;
2411
2396
  opts && Object.assign(this, opts);
2412
2397
  }
2413
2398
  /**
@@ -2471,7 +2456,7 @@ class Transaction {
2471
2456
 
2472
2457
  for (let i = 0; i < this.instructions.length; i++) {
2473
2458
  if (this.instructions[i].programId === undefined) {
2474
- throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
2459
+ throw new Error(`Transaction instruction index ${i} has undefined program id`);
2475
2460
  }
2476
2461
  }
2477
2462
 
@@ -2498,8 +2483,9 @@ class Transaction {
2498
2483
  }); // Sort. Prioritizing first by signer, then by writable
2499
2484
 
2500
2485
  accountMetas.sort(function (x, y) {
2486
+ const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2501
2487
  const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2502
- const checkWritable = x.isWritable === y.isWritable ? 0 : x.isWritable ? -1 : 1;
2488
+ const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2503
2489
  return checkSigner || checkWritable;
2504
2490
  }); // Cull duplicate account metas
2505
2491
 
@@ -2546,7 +2532,7 @@ class Transaction {
2546
2532
  console.warn('Transaction references a signature that is unnecessary, ' + 'only the fee payer and instruction signer accounts should sign a transaction. ' + 'This behavior is deprecated and will throw an error in the next major version release.');
2547
2533
  }
2548
2534
  } else {
2549
- throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
2535
+ throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
2550
2536
  }
2551
2537
  }
2552
2538
 
@@ -2781,7 +2767,7 @@ class Transaction {
2781
2767
  const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
2782
2768
 
2783
2769
  if (index < 0) {
2784
- throw new Error("unknown signer: ".concat(pubkey.toString()));
2770
+ throw new Error(`unknown signer: ${pubkey.toString()}`);
2785
2771
  }
2786
2772
 
2787
2773
  this.signatures[index].signature = buffer.Buffer.from(signature);
@@ -2857,12 +2843,12 @@ class Transaction {
2857
2843
  signature
2858
2844
  }, index) => {
2859
2845
  if (signature !== null) {
2860
- assert(signature.length === 64, "signature has invalid length");
2846
+ assert(signature.length === 64, `signature has invalid length`);
2861
2847
  buffer.Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
2862
2848
  }
2863
2849
  });
2864
2850
  signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
2865
- assert(wireTransaction.length <= PACKET_DATA_SIZE, "Transaction too large: ".concat(wireTransaction.length, " > ").concat(PACKET_DATA_SIZE));
2851
+ assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
2866
2852
  return wireTransaction;
2867
2853
  }
2868
2854
  /**
@@ -2955,11 +2941,14 @@ class Transaction {
2955
2941
  }
2956
2942
 
2957
2943
  const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
2944
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
2945
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2958
2946
  const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
2959
2947
  const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
2960
2948
  const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
2949
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
2950
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
2961
2951
  const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
2962
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2963
2952
 
2964
2953
  /**
2965
2954
  * Sign, send and confirm a transaction.
@@ -2981,7 +2970,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2981
2970
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2982
2971
 
2983
2972
  if (status.err) {
2984
- throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
2973
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
2985
2974
  }
2986
2975
 
2987
2976
  return signature;
@@ -3024,7 +3013,7 @@ function decodeData(type, buffer) {
3024
3013
  }
3025
3014
 
3026
3015
  if (data.instruction !== type.index) {
3027
- throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
3016
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
3028
3017
  }
3029
3018
 
3030
3019
  return data;
@@ -3058,12 +3047,9 @@ class NonceAccount {
3058
3047
  * @internal
3059
3048
  */
3060
3049
  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
-
3050
+ this.authorizedPubkey = void 0;
3051
+ this.nonce = void 0;
3052
+ this.feeCalculator = void 0;
3067
3053
  this.authorizedPubkey = args.authorizedPubkey;
3068
3054
  this.nonce = args.nonce;
3069
3055
  this.feeCalculator = args.feeCalculator;
@@ -3364,7 +3350,7 @@ class SystemInstruction {
3364
3350
 
3365
3351
  static checkKeyLength(keys, expectedLength) {
3366
3352
  if (keys.length < expectedLength) {
3367
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
3353
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
3368
3354
  }
3369
3355
  }
3370
3356
 
@@ -3796,8 +3782,7 @@ class SystemProgram {
3796
3782
  }
3797
3783
 
3798
3784
  }
3799
-
3800
- _defineProperty__default["default"](SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3785
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3801
3786
 
3802
3787
  // rest of the Transaction fields
3803
3788
  //
@@ -3966,8 +3951,7 @@ class Loader {
3966
3951
  }
3967
3952
 
3968
3953
  }
3969
-
3970
- _defineProperty__default["default"](Loader, "chunkSize", CHUNK_SIZE);
3954
+ Loader.chunkSize = CHUNK_SIZE;
3971
3955
 
3972
3956
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
3973
3957
  /**
@@ -4018,14 +4002,10 @@ class AgentManager {
4018
4002
  }
4019
4003
 
4020
4004
  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
-
4005
+ this._agent = void 0;
4006
+ this._activeRequests = 0;
4007
+ this._destroyTimeout = null;
4008
+ this._useHttps = void 0;
4029
4009
  this._useHttps = useHttps === true;
4030
4010
  this._agent = AgentManager._newAgent(this._useHttps);
4031
4011
  }
@@ -4098,16 +4078,11 @@ class EpochSchedule {
4098
4078
 
4099
4079
  /** The first slot of `firstNormalEpoch` */
4100
4080
  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
-
4081
+ this.slotsPerEpoch = void 0;
4082
+ this.leaderScheduleSlotOffset = void 0;
4083
+ this.warmup = void 0;
4084
+ this.firstNormalEpoch = void 0;
4085
+ this.firstNormalSlot = void 0;
4111
4086
  this.slotsPerEpoch = slotsPerEpoch;
4112
4087
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
4113
4088
  this.warmup = warmup;
@@ -4159,9 +4134,7 @@ class EpochSchedule {
4159
4134
  class SendTransactionError extends Error {
4160
4135
  constructor(message, logs) {
4161
4136
  super(message);
4162
-
4163
- _defineProperty__default["default"](this, "logs", void 0);
4164
-
4137
+ this.logs = void 0;
4165
4138
  this.logs = logs;
4166
4139
  }
4167
4140
 
@@ -4393,16 +4366,15 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4393
4366
  let fetchWithMiddleware;
4394
4367
 
4395
4368
  if (fetchMiddleware) {
4396
- fetchWithMiddleware = (url, options) => {
4397
- return new Promise((resolve, reject) => {
4398
- fetchMiddleware(url, options, async (url, options) => {
4399
- try {
4400
- resolve(await fetch__default["default"](url, options));
4401
- } catch (error) {
4402
- reject(error);
4403
- }
4404
- });
4369
+ fetchWithMiddleware = async (url, options) => {
4370
+ const modifiedFetchArgs = await new Promise((resolve, reject) => {
4371
+ try {
4372
+ fetchMiddleware(url, options, (modifiedUrl, modifiedOptions) => resolve([modifiedUrl, modifiedOptions]));
4373
+ } catch (error) {
4374
+ reject(error);
4375
+ }
4405
4376
  });
4377
+ return await fetch__default["default"](...modifiedFetchArgs);
4406
4378
  };
4407
4379
  }
4408
4380
 
@@ -4445,7 +4417,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4445
4417
  break;
4446
4418
  }
4447
4419
 
4448
- console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
4420
+ console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
4449
4421
  await sleep(waitTime);
4450
4422
  waitTime *= 2;
4451
4423
  }
@@ -4455,7 +4427,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4455
4427
  if (res.ok) {
4456
4428
  callback(null, text);
4457
4429
  } else {
4458
- callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
4430
+ callback(new Error(`${res.status} ${res.statusText}: ${text}`));
4459
4431
  }
4460
4432
  } catch (err) {
4461
4433
  if (err instanceof Error) callback(err);
@@ -4896,6 +4868,7 @@ const ParsedConfirmedTransactionResult = superstruct.type({
4896
4868
  const TokenBalanceResult = superstruct.type({
4897
4869
  accountIndex: superstruct.number(),
4898
4870
  mint: superstruct.string(),
4871
+ owner: superstruct.optional(superstruct.string()),
4899
4872
  uiTokenAmount: TokenAmountResult
4900
4873
  });
4901
4874
  /**
@@ -5121,67 +5094,39 @@ class Connection {
5121
5094
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
5122
5095
  */
5123
5096
  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", {
5097
+ this._commitment = void 0;
5098
+ this._confirmTransactionInitialTimeout = void 0;
5099
+ this._rpcEndpoint = void 0;
5100
+ this._rpcWsEndpoint = void 0;
5101
+ this._rpcClient = void 0;
5102
+ this._rpcRequest = void 0;
5103
+ this._rpcBatchRequest = void 0;
5104
+ this._rpcWebSocket = void 0;
5105
+ this._rpcWebSocketConnected = false;
5106
+ this._rpcWebSocketHeartbeat = null;
5107
+ this._rpcWebSocketIdleTimeout = null;
5108
+ this._disableBlockhashCaching = false;
5109
+ this._pollingBlockhash = false;
5110
+ this._blockhashInfo = {
5151
5111
  recentBlockhash: null,
5152
5112
  lastFetch: 0,
5153
5113
  transactionSignatures: [],
5154
5114
  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
-
5115
+ };
5116
+ this._accountChangeSubscriptionCounter = 0;
5117
+ this._accountChangeSubscriptions = {};
5118
+ this._programAccountChangeSubscriptionCounter = 0;
5119
+ this._programAccountChangeSubscriptions = {};
5120
+ this._rootSubscriptionCounter = 0;
5121
+ this._rootSubscriptions = {};
5122
+ this._signatureSubscriptionCounter = 0;
5123
+ this._signatureSubscriptions = {};
5124
+ this._slotSubscriptionCounter = 0;
5125
+ this._slotSubscriptions = {};
5126
+ this._logsSubscriptionCounter = 0;
5127
+ this._logsSubscriptions = {};
5128
+ this._slotUpdateSubscriptionCounter = 0;
5129
+ this._slotUpdateSubscriptions = {};
5185
5130
  let url = new URL(endpoint);
5186
5131
  const useHttps = url.protocol === 'https:';
5187
5132
  let wsEndpoint;
@@ -5527,13 +5472,25 @@ class Connection {
5527
5472
  */
5528
5473
 
5529
5474
 
5530
- async getMultipleAccountsInfo(publicKeys, commitment) {
5475
+ async getMultipleAccountsInfo(publicKeys, configOrCommitment) {
5531
5476
  const keys = publicKeys.map(key => key.toBase58());
5477
+ let commitment;
5478
+ let encoding = 'base64';
5479
+
5480
+ if (configOrCommitment) {
5481
+ if (typeof configOrCommitment === 'string') {
5482
+ commitment = configOrCommitment;
5483
+ encoding = 'base64';
5484
+ } else {
5485
+ commitment = configOrCommitment.commitment;
5486
+ encoding = configOrCommitment.encoding || 'base64';
5487
+ }
5488
+ }
5532
5489
 
5533
- const args = this._buildArgs([keys], commitment, 'base64');
5490
+ const args = this._buildArgs([keys], commitment, encoding);
5534
5491
 
5535
5492
  const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
5536
- const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
5493
+ const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(ParsedAccountInfoResult))));
5537
5494
 
5538
5495
  if ('error' in res) {
5539
5496
  throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
@@ -5555,7 +5512,7 @@ class Connection {
5555
5512
  const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
5556
5513
 
5557
5514
  if ('error' in res) {
5558
- throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
5515
+ throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
5559
5516
  }
5560
5517
 
5561
5518
  return res.result;
@@ -5691,7 +5648,7 @@ class Connection {
5691
5648
 
5692
5649
  if (response === null) {
5693
5650
  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."));
5651
+ 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
5652
  }
5696
5653
 
5697
5654
  return response;
@@ -6014,6 +5971,29 @@ class Connection {
6014
5971
  value: value !== null ? value.feeCalculator : null
6015
5972
  };
6016
5973
  }
5974
+ /**
5975
+ * Fetch the fee for a message from the cluster, return with context
5976
+ */
5977
+
5978
+
5979
+ async getFeeForMessage(message, commitment) {
5980
+ const wireMessage = message.serialize().toString('base64');
5981
+
5982
+ const args = this._buildArgs([wireMessage], commitment);
5983
+
5984
+ const unsafeRes = await this._rpcRequest('getFeeForMessage', args);
5985
+ const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
5986
+
5987
+ if ('error' in res) {
5988
+ throw new Error('failed to get slot: ' + res.error.message);
5989
+ }
5990
+
5991
+ if (res.result === null) {
5992
+ throw new Error('invalid blockhash');
5993
+ }
5994
+
5995
+ return res.result;
5996
+ }
6017
5997
  /**
6018
5998
  * Fetch a recent blockhash from the cluster
6019
5999
  * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
@@ -6465,7 +6445,7 @@ class Connection {
6465
6445
  await sleep(MS_PER_SLOT / 2);
6466
6446
  }
6467
6447
 
6468
- throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
6448
+ throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
6469
6449
  } finally {
6470
6450
  this._pollingBlockhash = false;
6471
6451
  }
@@ -6722,7 +6702,7 @@ class Connection {
6722
6702
  }
6723
6703
 
6724
6704
  if (err instanceof Error) {
6725
- console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
6705
+ console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
6726
6706
  }
6727
6707
  }
6728
6708
  }
@@ -6742,7 +6722,7 @@ class Connection {
6742
6722
  await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
6743
6723
  } catch (err) {
6744
6724
  if (err instanceof Error) {
6745
- console.error("".concat(rpcMethod, " error:"), err.message);
6725
+ console.error(`${rpcMethod} error:`, err.message);
6746
6726
  }
6747
6727
  }
6748
6728
  }
@@ -6907,7 +6887,7 @@ class Connection {
6907
6887
 
6908
6888
  this._updateSubscriptions();
6909
6889
  } else {
6910
- throw new Error("Unknown account change id: ".concat(id));
6890
+ throw new Error(`Unknown account change id: ${id}`);
6911
6891
  }
6912
6892
  }
6913
6893
  /**
@@ -6973,7 +6953,7 @@ class Connection {
6973
6953
 
6974
6954
  this._updateSubscriptions();
6975
6955
  } else {
6976
- throw new Error("Unknown program account change id: ".concat(id));
6956
+ throw new Error(`Unknown program account change id: ${id}`);
6977
6957
  }
6978
6958
  }
6979
6959
  /**
@@ -7003,7 +6983,7 @@ class Connection {
7003
6983
 
7004
6984
  async removeOnLogsListener(id) {
7005
6985
  if (!this._logsSubscriptions[id]) {
7006
- throw new Error("Unknown logs id: ".concat(id));
6986
+ throw new Error(`Unknown logs id: ${id}`);
7007
6987
  }
7008
6988
 
7009
6989
  const subInfo = this._logsSubscriptions[id];
@@ -7079,7 +7059,7 @@ class Connection {
7079
7059
 
7080
7060
  this._updateSubscriptions();
7081
7061
  } else {
7082
- throw new Error("Unknown slot change id: ".concat(id));
7062
+ throw new Error(`Unknown slot change id: ${id}`);
7083
7063
  }
7084
7064
  }
7085
7065
  /**
@@ -7132,7 +7112,7 @@ class Connection {
7132
7112
 
7133
7113
  this._updateSubscriptions();
7134
7114
  } else {
7135
- throw new Error("Unknown slot update id: ".concat(id));
7115
+ throw new Error(`Unknown slot update id: ${id}`);
7136
7116
  }
7137
7117
  }
7138
7118
 
@@ -7273,7 +7253,7 @@ class Connection {
7273
7253
 
7274
7254
  this._updateSubscriptions();
7275
7255
  } else {
7276
- throw new Error("Unknown signature result id: ".concat(id));
7256
+ throw new Error(`Unknown signature result id: ${id}`);
7277
7257
  }
7278
7258
  }
7279
7259
  /**
@@ -7325,7 +7305,7 @@ class Connection {
7325
7305
 
7326
7306
  this._updateSubscriptions();
7327
7307
  } else {
7328
- throw new Error("Unknown root change id: ".concat(id));
7308
+ throw new Error(`Unknown root change id: ${id}`);
7329
7309
  }
7330
7310
  }
7331
7311
 
@@ -7346,12 +7326,12 @@ class Keypair {
7346
7326
  * @param keypair ed25519 keypair
7347
7327
  */
7348
7328
  constructor(keypair) {
7349
- _defineProperty__default["default"](this, "_keypair", void 0);
7329
+ this._keypair = void 0;
7350
7330
 
7351
7331
  if (keypair) {
7352
7332
  this._keypair = keypair;
7353
7333
  } else {
7354
- this._keypair = nacl__namespace.sign.keyPair();
7334
+ this._keypair = nacl__default["default"].sign.keyPair();
7355
7335
  }
7356
7336
  }
7357
7337
  /**
@@ -7360,7 +7340,7 @@ class Keypair {
7360
7340
 
7361
7341
 
7362
7342
  static generate() {
7363
- return new Keypair(nacl__namespace.sign.keyPair());
7343
+ return new Keypair(nacl__default["default"].sign.keyPair());
7364
7344
  }
7365
7345
  /**
7366
7346
  * Create a keypair from a raw secret key byte array.
@@ -7377,14 +7357,14 @@ class Keypair {
7377
7357
 
7378
7358
 
7379
7359
  static fromSecretKey(secretKey, options) {
7380
- const keypair = nacl__namespace.sign.keyPair.fromSecretKey(secretKey);
7360
+ const keypair = nacl__default["default"].sign.keyPair.fromSecretKey(secretKey);
7381
7361
 
7382
7362
  if (!options || !options.skipValidation) {
7383
7363
  const encoder = new TextEncoder();
7384
7364
  const signData = encoder.encode('@solana/web3.js-validation-v1');
7385
- const signature = nacl__namespace.sign.detached(signData, keypair.secretKey);
7365
+ const signature = nacl__default["default"].sign.detached(signData, keypair.secretKey);
7386
7366
 
7387
- if (!nacl__namespace.sign.detached.verify(signData, signature, keypair.publicKey)) {
7367
+ if (!nacl__default["default"].sign.detached.verify(signData, signature, keypair.publicKey)) {
7388
7368
  throw new Error('provided secretKey is invalid');
7389
7369
  }
7390
7370
  }
@@ -7399,7 +7379,7 @@ class Keypair {
7399
7379
 
7400
7380
 
7401
7381
  static fromSeed(seed) {
7402
- return new Keypair(nacl__namespace.sign.keyPair.fromSeed(seed));
7382
+ return new Keypair(nacl__default["default"].sign.keyPair.fromSeed(seed));
7403
7383
  }
7404
7384
  /**
7405
7385
  * The public key for this keypair
@@ -7450,8 +7430,8 @@ class Ed25519Program {
7450
7430
  signature,
7451
7431
  instructionIndex
7452
7432
  } = 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"));
7433
+ assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
7434
+ assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
7455
7435
  const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
7456
7436
  const signatureOffset = publicKeyOffset + publicKey.length;
7457
7437
  const messageDataOffset = signatureOffset + signature.length;
@@ -7489,7 +7469,7 @@ class Ed25519Program {
7489
7469
  message,
7490
7470
  instructionIndex
7491
7471
  } = 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"));
7472
+ assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
7493
7473
 
7494
7474
  try {
7495
7475
  const keypair = Keypair.fromSecretKey(privateKey);
@@ -7502,13 +7482,12 @@ class Ed25519Program {
7502
7482
  instructionIndex
7503
7483
  });
7504
7484
  } catch (error) {
7505
- throw new Error("Error creating instruction; ".concat(error));
7485
+ throw new Error(`Error creating instruction; ${error}`);
7506
7486
  }
7507
7487
  }
7508
7488
 
7509
7489
  }
7510
-
7511
- _defineProperty__default["default"](Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7490
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7512
7491
 
7513
7492
  /**
7514
7493
  * Address of the stake config account which configures the rate
@@ -7531,10 +7510,8 @@ class Authorized {
7531
7510
  * @param withdrawer the withdraw authority
7532
7511
  */
7533
7512
  constructor(staker, withdrawer) {
7534
- _defineProperty__default["default"](this, "staker", void 0);
7535
-
7536
- _defineProperty__default["default"](this, "withdrawer", void 0);
7537
-
7513
+ this.staker = void 0;
7514
+ this.withdrawer = void 0;
7538
7515
  this.staker = staker;
7539
7516
  this.withdrawer = withdrawer;
7540
7517
  }
@@ -7555,12 +7532,9 @@ class Lockup {
7555
7532
  * Create a new Lockup object
7556
7533
  */
7557
7534
  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
-
7535
+ this.unixTimestamp = void 0;
7536
+ this.epoch = void 0;
7537
+ this.custodian = void 0;
7564
7538
  this.unixTimestamp = unixTimestamp;
7565
7539
  this.epoch = epoch;
7566
7540
  this.custodian = custodian;
@@ -7575,7 +7549,7 @@ class Lockup {
7575
7549
  * Create stake account transaction params
7576
7550
  */
7577
7551
 
7578
- _defineProperty__default["default"](Lockup, "default", new Lockup(0, 0, PublicKey.default));
7552
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
7579
7553
 
7580
7554
  /**
7581
7555
  * Stake Instruction class
@@ -7788,7 +7762,7 @@ class StakeInstruction {
7788
7762
 
7789
7763
  static checkKeyLength(keys, expectedLength) {
7790
7764
  if (keys.length < expectedLength) {
7791
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
7765
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
7792
7766
  }
7793
7767
  }
7794
7768
 
@@ -8263,10 +8237,8 @@ class StakeProgram {
8263
8237
  }
8264
8238
 
8265
8239
  }
8266
-
8267
- _defineProperty__default["default"](StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
8268
-
8269
- _defineProperty__default["default"](StakeProgram, "space", 200);
8240
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8241
+ StakeProgram.space = 200;
8270
8242
 
8271
8243
  const {
8272
8244
  publicKeyCreate,
@@ -8296,12 +8268,12 @@ class Secp256k1Program {
8296
8268
  * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
8297
8269
  */
8298
8270
  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"));
8271
+ assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8300
8272
 
8301
8273
  try {
8302
- return buffer.Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8274
+ return buffer.Buffer.from(sha3__default["default"].keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8303
8275
  } catch (error) {
8304
- throw new Error("Error constructing Ethereum address: ".concat(error));
8276
+ throw new Error(`Error constructing Ethereum address: ${error}`);
8305
8277
  }
8306
8278
  }
8307
8279
  /**
@@ -8352,7 +8324,7 @@ class Secp256k1Program {
8352
8324
  ethAddress = rawAddress;
8353
8325
  }
8354
8326
 
8355
- assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
8327
+ assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
8356
8328
  const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
8357
8329
  const ethAddressOffset = dataStart;
8358
8330
  const signatureOffset = dataStart + ethAddress.length;
@@ -8391,13 +8363,13 @@ class Secp256k1Program {
8391
8363
  message,
8392
8364
  instructionIndex
8393
8365
  } = params;
8394
- assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
8366
+ assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
8395
8367
 
8396
8368
  try {
8397
8369
  const privateKey = toBuffer(pkey);
8398
8370
  const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
8399
8371
 
8400
- const messageHash = buffer.Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
8372
+ const messageHash = buffer.Buffer.from(sha3__default["default"].keccak_256.update(toBuffer(message)).digest());
8401
8373
  const {
8402
8374
  signature,
8403
8375
  recid: recoveryId
@@ -8410,13 +8382,12 @@ class Secp256k1Program {
8410
8382
  instructionIndex
8411
8383
  });
8412
8384
  } catch (error) {
8413
- throw new Error("Error creating instruction; ".concat(error));
8385
+ throw new Error(`Error creating instruction; ${error}`);
8414
8386
  }
8415
8387
  }
8416
8388
 
8417
8389
  }
8418
-
8419
- _defineProperty__default["default"](Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8390
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
8420
8391
 
8421
8392
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
8422
8393
  /**
@@ -8449,10 +8420,8 @@ class ValidatorInfo {
8449
8420
  * @param info validator information
8450
8421
  */
8451
8422
  constructor(key, info) {
8452
- _defineProperty__default["default"](this, "key", void 0);
8453
-
8454
- _defineProperty__default["default"](this, "info", void 0);
8455
-
8423
+ this.key = void 0;
8424
+ this.info = void 0;
8456
8425
  this.key = key;
8457
8426
  this.info = info;
8458
8427
  }
@@ -8504,9 +8473,10 @@ const VOTE_PROGRAM_ID = new PublicKey('Vote1111111111111111111111111111111111111
8504
8473
  *
8505
8474
  * @internal
8506
8475
  */
8507
- const VoteAccountLayout = BufferLayout__namespace.struct([publicKey('nodePubkey'), publicKey('authorizedVoterPubkey'), publicKey('authorizedWithdrawerPubkey'), BufferLayout__namespace.u8('commission'), BufferLayout__namespace.nu64(), // votes.length
8508
- BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('slot'), BufferLayout__namespace.u32('confirmationCount')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'votes'), BufferLayout__namespace.u8('rootSlotValid'), BufferLayout__namespace.nu64('rootSlot'), BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('lastEpochCredits'), BufferLayout__namespace.nu64(), // epochCredits.length
8509
- BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('prevCredits')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'epochCredits')]);
8476
+ const VoteAccountLayout = BufferLayout__namespace.struct([publicKey('nodePubkey'), publicKey('authorizedWithdrawer'), BufferLayout__namespace.u8('commission'), BufferLayout__namespace.nu64(), // votes.length
8477
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('slot'), BufferLayout__namespace.u32('confirmationCount')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'votes'), BufferLayout__namespace.u8('rootSlotValid'), BufferLayout__namespace.nu64('rootSlot'), BufferLayout__namespace.nu64(), // authorizedVoters.length
8478
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('epoch'), publicKey('authorizedVoter')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'authorizedVoters'), BufferLayout__namespace.struct([BufferLayout__namespace.seq(BufferLayout__namespace.struct([publicKey('authorizedPubkey'), BufferLayout__namespace.nu64('epochOfLastAuthorizedSwitch'), BufferLayout__namespace.nu64('targetEpoch')]), 32, 'buf'), BufferLayout__namespace.nu64('idx'), BufferLayout__namespace.u8('isEmpty')], 'priorVoters'), BufferLayout__namespace.nu64(), // epochCredits.length
8479
+ BufferLayout__namespace.seq(BufferLayout__namespace.struct([BufferLayout__namespace.nu64('epoch'), BufferLayout__namespace.nu64('credits'), BufferLayout__namespace.nu64('prevCredits')]), BufferLayout__namespace.offset(BufferLayout__namespace.u32(), -8), 'epochCredits'), BufferLayout__namespace.struct([BufferLayout__namespace.nu64('slot'), BufferLayout__namespace.nu64('timestamp')], 'lastTimestamp')]);
8510
8480
 
8511
8481
  /**
8512
8482
  * VoteAccount class
@@ -8516,36 +8486,24 @@ class VoteAccount {
8516
8486
  * @internal
8517
8487
  */
8518
8488
  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
-
8489
+ this.nodePubkey = void 0;
8490
+ this.authorizedWithdrawer = void 0;
8491
+ this.commission = void 0;
8492
+ this.rootSlot = void 0;
8493
+ this.votes = void 0;
8494
+ this.authorizedVoters = void 0;
8495
+ this.priorVoters = void 0;
8496
+ this.epochCredits = void 0;
8497
+ this.lastTimestamp = void 0;
8539
8498
  this.nodePubkey = args.nodePubkey;
8540
- this.authorizedVoterPubkey = args.authorizedVoterPubkey;
8541
- this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
8499
+ this.authorizedWithdrawer = args.authorizedWithdrawer;
8542
8500
  this.commission = args.commission;
8543
- this.votes = args.votes;
8544
8501
  this.rootSlot = args.rootSlot;
8545
- this.epoch = args.epoch;
8546
- this.credits = args.credits;
8547
- this.lastEpochCredits = args.lastEpochCredits;
8502
+ this.votes = args.votes;
8503
+ this.authorizedVoters = args.authorizedVoters;
8504
+ this.priorVoters = args.priorVoters;
8548
8505
  this.epochCredits = args.epochCredits;
8506
+ this.lastTimestamp = args.lastTimestamp;
8549
8507
  }
8550
8508
  /**
8551
8509
  * Deserialize VoteAccount from the account data.
@@ -8556,7 +8514,8 @@ class VoteAccount {
8556
8514
 
8557
8515
 
8558
8516
  static fromAccountData(buffer) {
8559
- const va = VoteAccountLayout.decode(toBuffer(buffer), 0);
8517
+ const versionOffset = 4;
8518
+ const va = VoteAccountLayout.decode(toBuffer(buffer), versionOffset);
8560
8519
  let rootSlot = va.rootSlot;
8561
8520
 
8562
8521
  if (!va.rootSlotValid) {
@@ -8565,20 +8524,53 @@ class VoteAccount {
8565
8524
 
8566
8525
  return new VoteAccount({
8567
8526
  nodePubkey: new PublicKey(va.nodePubkey),
8568
- authorizedVoterPubkey: new PublicKey(va.authorizedVoterPubkey),
8569
- authorizedWithdrawerPubkey: new PublicKey(va.authorizedWithdrawerPubkey),
8527
+ authorizedWithdrawer: new PublicKey(va.authorizedWithdrawer),
8570
8528
  commission: va.commission,
8571
8529
  votes: va.votes,
8572
8530
  rootSlot,
8573
- epoch: va.epoch,
8574
- credits: va.credits,
8575
- lastEpochCredits: va.lastEpochCredits,
8576
- epochCredits: va.epochCredits
8531
+ authorizedVoters: va.authorizedVoters.map(parseAuthorizedVoter),
8532
+ priorVoters: getPriorVoters(va.priorVoters),
8533
+ epochCredits: va.epochCredits,
8534
+ lastTimestamp: va.lastTimestamp
8577
8535
  });
8578
8536
  }
8579
8537
 
8580
8538
  }
8581
8539
 
8540
+ function parseAuthorizedVoter({
8541
+ epoch,
8542
+ authorizedVoter
8543
+ }) {
8544
+ return {
8545
+ epoch,
8546
+ authorizedVoter: new PublicKey(authorizedVoter)
8547
+ };
8548
+ }
8549
+
8550
+ function parsePriorVoters({
8551
+ authorizedPubkey,
8552
+ epochOfLastAuthorizedSwitch,
8553
+ targetEpoch
8554
+ }) {
8555
+ return {
8556
+ authorizedPubkey: new PublicKey(authorizedPubkey),
8557
+ epochOfLastAuthorizedSwitch,
8558
+ targetEpoch
8559
+ };
8560
+ }
8561
+
8562
+ function getPriorVoters({
8563
+ buf,
8564
+ idx,
8565
+ isEmpty
8566
+ }) {
8567
+ if (isEmpty) {
8568
+ return [];
8569
+ }
8570
+
8571
+ return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx)];
8572
+ }
8573
+
8582
8574
  /**
8583
8575
  * Send and confirm a raw transaction
8584
8576
  *
@@ -8598,7 +8590,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
8598
8590
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
8599
8591
 
8600
8592
  if (status.err) {
8601
- throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
8593
+ throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
8602
8594
  }
8603
8595
 
8604
8596
  return signature;
@@ -8630,7 +8622,7 @@ function clusterApiUrl(cluster, tls) {
8630
8622
  const url = endpoint[key][cluster];
8631
8623
 
8632
8624
  if (!url) {
8633
- throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
8625
+ throw new Error(`Unknown ${key} cluster: ${cluster}`);
8634
8626
  }
8635
8627
 
8636
8628
  return url;
@@ -8668,10 +8660,13 @@ exports.STAKE_CONFIG_ID = STAKE_CONFIG_ID;
8668
8660
  exports.STAKE_INSTRUCTION_LAYOUTS = STAKE_INSTRUCTION_LAYOUTS;
8669
8661
  exports.SYSTEM_INSTRUCTION_LAYOUTS = SYSTEM_INSTRUCTION_LAYOUTS;
8670
8662
  exports.SYSVAR_CLOCK_PUBKEY = SYSVAR_CLOCK_PUBKEY;
8663
+ exports.SYSVAR_EPOCH_SCHEDULE_PUBKEY = SYSVAR_EPOCH_SCHEDULE_PUBKEY;
8671
8664
  exports.SYSVAR_INSTRUCTIONS_PUBKEY = SYSVAR_INSTRUCTIONS_PUBKEY;
8672
8665
  exports.SYSVAR_RECENT_BLOCKHASHES_PUBKEY = SYSVAR_RECENT_BLOCKHASHES_PUBKEY;
8673
8666
  exports.SYSVAR_RENT_PUBKEY = SYSVAR_RENT_PUBKEY;
8674
8667
  exports.SYSVAR_REWARDS_PUBKEY = SYSVAR_REWARDS_PUBKEY;
8668
+ exports.SYSVAR_SLOT_HASHES_PUBKEY = SYSVAR_SLOT_HASHES_PUBKEY;
8669
+ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
8675
8670
  exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
8676
8671
  exports.Secp256k1Program = Secp256k1Program;
8677
8672
  exports.SendTransactionError = SendTransactionError;