@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.esm.js CHANGED
@@ -1,6 +1,4 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import * as nacl from 'tweetnacl';
3
- import nacl__default from 'tweetnacl';
1
+ import nacl from 'tweetnacl';
4
2
  import { Buffer } from 'buffer';
5
3
  import BN from 'bn.js';
6
4
  import bs58 from 'bs58';
@@ -13,7 +11,7 @@ import RpcClient from 'jayson/lib/client/browser';
13
11
  import http from 'http';
14
12
  import https from 'https';
15
13
  import secp256k1 from 'secp256k1';
16
- import { keccak_256 } from 'js-sha3';
14
+ import sha3 from 'js-sha3';
17
15
 
18
16
  const toBuffer = arr => {
19
17
  if (Buffer.isBuffer(arr)) {
@@ -25,743 +23,334 @@ const toBuffer = arr => {
25
23
  }
26
24
  };
27
25
 
28
- const version$2 = "logger/5.5.0";
26
+ var hash$1 = {};
29
27
 
30
- let _permanentCensorErrors = false;
31
- let _censorErrors = false;
32
- const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
33
- let _logLevel = LogLevels["default"];
34
- let _globalLogger = null;
35
- function _checkNormalize() {
36
- try {
37
- const missing = [];
38
- // Make sure all forms of normalization are supported
39
- ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
40
- try {
41
- if ("test".normalize(form) !== "test") {
42
- throw new Error("bad normalize");
43
- }
44
- ;
45
- }
46
- catch (error) {
47
- missing.push(form);
48
- }
49
- });
50
- if (missing.length) {
51
- throw new Error("missing " + missing.join(", "));
52
- }
53
- if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
54
- throw new Error("broken implementation");
28
+ var utils$9 = {};
29
+
30
+ var minimalisticAssert = assert$6;
31
+
32
+ function assert$6(val, msg) {
33
+ if (!val)
34
+ throw new Error(msg || 'Assertion failed');
35
+ }
36
+
37
+ assert$6.equal = function assertEqual(l, r, msg) {
38
+ if (l != r)
39
+ throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
40
+ };
41
+
42
+ var inherits$1 = {exports: {}};
43
+
44
+ var inherits_browser = {exports: {}};
45
+
46
+ if (typeof Object.create === 'function') {
47
+ // implementation from standard node.js 'util' module
48
+ inherits_browser.exports = function inherits(ctor, superCtor) {
49
+ ctor.super_ = superCtor;
50
+ ctor.prototype = Object.create(superCtor.prototype, {
51
+ constructor: {
52
+ value: ctor,
53
+ enumerable: false,
54
+ writable: true,
55
+ configurable: true
56
+ }
57
+ });
58
+ };
59
+ } else {
60
+ // old school shim for old browsers
61
+ inherits_browser.exports = function inherits(ctor, superCtor) {
62
+ ctor.super_ = superCtor;
63
+ var TempCtor = function () {};
64
+ TempCtor.prototype = superCtor.prototype;
65
+ ctor.prototype = new TempCtor();
66
+ ctor.prototype.constructor = ctor;
67
+ };
68
+ }
69
+
70
+ try {
71
+ var util = require('util');
72
+ if (typeof util.inherits !== 'function') throw '';
73
+ inherits$1.exports = util.inherits;
74
+ } catch (e) {
75
+ inherits$1.exports = inherits_browser.exports;
76
+ }
77
+
78
+ var assert$5 = minimalisticAssert;
79
+ var inherits = inherits$1.exports;
80
+
81
+ utils$9.inherits = inherits;
82
+
83
+ function isSurrogatePair(msg, i) {
84
+ if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
85
+ return false;
86
+ }
87
+ if (i < 0 || i + 1 >= msg.length) {
88
+ return false;
89
+ }
90
+ return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
91
+ }
92
+
93
+ function toArray(msg, enc) {
94
+ if (Array.isArray(msg))
95
+ return msg.slice();
96
+ if (!msg)
97
+ return [];
98
+ var res = [];
99
+ if (typeof msg === 'string') {
100
+ if (!enc) {
101
+ // Inspired by stringToUtf8ByteArray() in closure-library by Google
102
+ // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
103
+ // Apache License 2.0
104
+ // https://github.com/google/closure-library/blob/master/LICENSE
105
+ var p = 0;
106
+ for (var i = 0; i < msg.length; i++) {
107
+ var c = msg.charCodeAt(i);
108
+ if (c < 128) {
109
+ res[p++] = c;
110
+ } else if (c < 2048) {
111
+ res[p++] = (c >> 6) | 192;
112
+ res[p++] = (c & 63) | 128;
113
+ } else if (isSurrogatePair(msg, i)) {
114
+ c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
115
+ res[p++] = (c >> 18) | 240;
116
+ res[p++] = ((c >> 12) & 63) | 128;
117
+ res[p++] = ((c >> 6) & 63) | 128;
118
+ res[p++] = (c & 63) | 128;
119
+ } else {
120
+ res[p++] = (c >> 12) | 224;
121
+ res[p++] = ((c >> 6) & 63) | 128;
122
+ res[p++] = (c & 63) | 128;
55
123
  }
124
+ }
125
+ } else if (enc === 'hex') {
126
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
127
+ if (msg.length % 2 !== 0)
128
+ msg = '0' + msg;
129
+ for (i = 0; i < msg.length; i += 2)
130
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
56
131
  }
57
- catch (error) {
58
- return error.message;
132
+ } else {
133
+ for (i = 0; i < msg.length; i++)
134
+ res[i] = msg[i] | 0;
135
+ }
136
+ return res;
137
+ }
138
+ utils$9.toArray = toArray;
139
+
140
+ function toHex(msg) {
141
+ var res = '';
142
+ for (var i = 0; i < msg.length; i++)
143
+ res += zero2(msg[i].toString(16));
144
+ return res;
145
+ }
146
+ utils$9.toHex = toHex;
147
+
148
+ function htonl(w) {
149
+ var res = (w >>> 24) |
150
+ ((w >>> 8) & 0xff00) |
151
+ ((w << 8) & 0xff0000) |
152
+ ((w & 0xff) << 24);
153
+ return res >>> 0;
154
+ }
155
+ utils$9.htonl = htonl;
156
+
157
+ function toHex32(msg, endian) {
158
+ var res = '';
159
+ for (var i = 0; i < msg.length; i++) {
160
+ var w = msg[i];
161
+ if (endian === 'little')
162
+ w = htonl(w);
163
+ res += zero8(w.toString(16));
164
+ }
165
+ return res;
166
+ }
167
+ utils$9.toHex32 = toHex32;
168
+
169
+ function zero2(word) {
170
+ if (word.length === 1)
171
+ return '0' + word;
172
+ else
173
+ return word;
174
+ }
175
+ utils$9.zero2 = zero2;
176
+
177
+ function zero8(word) {
178
+ if (word.length === 7)
179
+ return '0' + word;
180
+ else if (word.length === 6)
181
+ return '00' + word;
182
+ else if (word.length === 5)
183
+ return '000' + word;
184
+ else if (word.length === 4)
185
+ return '0000' + word;
186
+ else if (word.length === 3)
187
+ return '00000' + word;
188
+ else if (word.length === 2)
189
+ return '000000' + word;
190
+ else if (word.length === 1)
191
+ return '0000000' + word;
192
+ else
193
+ return word;
194
+ }
195
+ utils$9.zero8 = zero8;
196
+
197
+ function join32(msg, start, end, endian) {
198
+ var len = end - start;
199
+ assert$5(len % 4 === 0);
200
+ var res = new Array(len / 4);
201
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
202
+ var w;
203
+ if (endian === 'big')
204
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
205
+ else
206
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
207
+ res[i] = w >>> 0;
208
+ }
209
+ return res;
210
+ }
211
+ utils$9.join32 = join32;
212
+
213
+ function split32(msg, endian) {
214
+ var res = new Array(msg.length * 4);
215
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
216
+ var m = msg[i];
217
+ if (endian === 'big') {
218
+ res[k] = m >>> 24;
219
+ res[k + 1] = (m >>> 16) & 0xff;
220
+ res[k + 2] = (m >>> 8) & 0xff;
221
+ res[k + 3] = m & 0xff;
222
+ } else {
223
+ res[k + 3] = m >>> 24;
224
+ res[k + 2] = (m >>> 16) & 0xff;
225
+ res[k + 1] = (m >>> 8) & 0xff;
226
+ res[k] = m & 0xff;
59
227
  }
60
- return null;
228
+ }
229
+ return res;
61
230
  }
62
- const _normalizeError = _checkNormalize();
63
- var LogLevel;
64
- (function (LogLevel) {
65
- LogLevel["DEBUG"] = "DEBUG";
66
- LogLevel["INFO"] = "INFO";
67
- LogLevel["WARNING"] = "WARNING";
68
- LogLevel["ERROR"] = "ERROR";
69
- LogLevel["OFF"] = "OFF";
70
- })(LogLevel || (LogLevel = {}));
71
- var ErrorCode;
72
- (function (ErrorCode) {
73
- ///////////////////
74
- // Generic Errors
75
- // Unknown Error
76
- ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
77
- // Not Implemented
78
- ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
79
- // Unsupported Operation
80
- // - operation
81
- ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
82
- // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
83
- // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
84
- ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
85
- // Some sort of bad response from the server
86
- ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
87
- // Timeout
88
- ErrorCode["TIMEOUT"] = "TIMEOUT";
89
- ///////////////////
90
- // Operational Errors
91
- // Buffer Overrun
92
- ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
93
- // Numeric Fault
94
- // - operation: the operation being executed
95
- // - fault: the reason this faulted
96
- ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
97
- ///////////////////
98
- // Argument Errors
99
- // Missing new operator to an object
100
- // - name: The name of the class
101
- ErrorCode["MISSING_NEW"] = "MISSING_NEW";
102
- // Invalid argument (e.g. value is incompatible with type) to a function:
103
- // - argument: The argument name that was invalid
104
- // - value: The value of the argument
105
- ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
106
- // Missing argument to a function:
107
- // - count: The number of arguments received
108
- // - expectedCount: The number of arguments expected
109
- ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
110
- // Too many arguments
111
- // - count: The number of arguments received
112
- // - expectedCount: The number of arguments expected
113
- ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
114
- ///////////////////
115
- // Blockchain Errors
116
- // Call exception
117
- // - transaction: the transaction
118
- // - address?: the contract address
119
- // - args?: The arguments passed into the function
120
- // - method?: The Solidity method signature
121
- // - errorSignature?: The EIP848 error signature
122
- // - errorArgs?: The EIP848 error parameters
123
- // - reason: The reason (only for EIP848 "Error(string)")
124
- ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
125
- // Insufficient funds (< value + gasLimit * gasPrice)
126
- // - transaction: the transaction attempted
127
- ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
128
- // Nonce has already been used
129
- // - transaction: the transaction attempted
130
- ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
131
- // The replacement fee for the transaction is too low
132
- // - transaction: the transaction attempted
133
- ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
134
- // The gas limit could not be estimated
135
- // - transaction: the transaction passed to estimateGas
136
- ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
137
- // The transaction was replaced by one with a higher gas price
138
- // - reason: "cancelled", "replaced" or "repriced"
139
- // - cancelled: true if reason == "cancelled" or reason == "replaced")
140
- // - hash: original transaction hash
141
- // - replacement: the full TransactionsResponse for the replacement
142
- // - receipt: the receipt of the replacement
143
- ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
144
- })(ErrorCode || (ErrorCode = {}));
145
- const HEX = "0123456789abcdef";
146
- class Logger {
147
- constructor(version) {
148
- Object.defineProperty(this, "version", {
149
- enumerable: true,
150
- value: version,
151
- writable: false
152
- });
153
- }
154
- _log(logLevel, args) {
155
- const level = logLevel.toLowerCase();
156
- if (LogLevels[level] == null) {
157
- this.throwArgumentError("invalid log level name", "logLevel", logLevel);
158
- }
159
- if (_logLevel > LogLevels[level]) {
160
- return;
161
- }
162
- console.log.apply(console, args);
163
- }
164
- debug(...args) {
165
- this._log(Logger.levels.DEBUG, args);
166
- }
167
- info(...args) {
168
- this._log(Logger.levels.INFO, args);
169
- }
170
- warn(...args) {
171
- this._log(Logger.levels.WARNING, args);
172
- }
173
- makeError(message, code, params) {
174
- // Errors are being censored
175
- if (_censorErrors) {
176
- return this.makeError("censored error", code, {});
177
- }
178
- if (!code) {
179
- code = Logger.errors.UNKNOWN_ERROR;
180
- }
181
- if (!params) {
182
- params = {};
183
- }
184
- const messageDetails = [];
185
- Object.keys(params).forEach((key) => {
186
- const value = params[key];
187
- try {
188
- if (value instanceof Uint8Array) {
189
- let hex = "";
190
- for (let i = 0; i < value.length; i++) {
191
- hex += HEX[value[i] >> 4];
192
- hex += HEX[value[i] & 0x0f];
193
- }
194
- messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
195
- }
196
- else {
197
- messageDetails.push(key + "=" + JSON.stringify(value));
198
- }
199
- }
200
- catch (error) {
201
- messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
202
- }
203
- });
204
- messageDetails.push(`code=${code}`);
205
- messageDetails.push(`version=${this.version}`);
206
- const reason = message;
207
- if (messageDetails.length) {
208
- message += " (" + messageDetails.join(", ") + ")";
209
- }
210
- // @TODO: Any??
211
- const error = new Error(message);
212
- error.reason = reason;
213
- error.code = code;
214
- Object.keys(params).forEach(function (key) {
215
- error[key] = params[key];
216
- });
217
- return error;
218
- }
219
- throwError(message, code, params) {
220
- throw this.makeError(message, code, params);
221
- }
222
- throwArgumentError(message, name, value) {
223
- return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
224
- argument: name,
225
- value: value
226
- });
227
- }
228
- assert(condition, message, code, params) {
229
- if (!!condition) {
230
- return;
231
- }
232
- this.throwError(message, code, params);
233
- }
234
- assertArgument(condition, message, name, value) {
235
- if (!!condition) {
236
- return;
237
- }
238
- this.throwArgumentError(message, name, value);
239
- }
240
- checkNormalize(message) {
241
- if (_normalizeError) {
242
- this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
243
- operation: "String.prototype.normalize", form: _normalizeError
244
- });
245
- }
246
- }
247
- checkSafeUint53(value, message) {
248
- if (typeof (value) !== "number") {
249
- return;
250
- }
251
- if (message == null) {
252
- message = "value not safe";
253
- }
254
- if (value < 0 || value >= 0x1fffffffffffff) {
255
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
256
- operation: "checkSafeInteger",
257
- fault: "out-of-safe-range",
258
- value: value
259
- });
260
- }
261
- if (value % 1) {
262
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
263
- operation: "checkSafeInteger",
264
- fault: "non-integer",
265
- value: value
266
- });
267
- }
268
- }
269
- checkArgumentCount(count, expectedCount, message) {
270
- if (message) {
271
- message = ": " + message;
272
- }
273
- else {
274
- message = "";
275
- }
276
- if (count < expectedCount) {
277
- this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
278
- count: count,
279
- expectedCount: expectedCount
280
- });
281
- }
282
- if (count > expectedCount) {
283
- this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
284
- count: count,
285
- expectedCount: expectedCount
286
- });
287
- }
288
- }
289
- checkNew(target, kind) {
290
- if (target === Object || target == null) {
291
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
292
- }
293
- }
294
- checkAbstract(target, kind) {
295
- if (target === kind) {
296
- this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
297
- }
298
- else if (target === Object || target == null) {
299
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
300
- }
301
- }
302
- static globalLogger() {
303
- if (!_globalLogger) {
304
- _globalLogger = new Logger(version$2);
305
- }
306
- return _globalLogger;
307
- }
308
- static setCensorship(censorship, permanent) {
309
- if (!censorship && permanent) {
310
- this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
311
- operation: "setCensorship"
312
- });
313
- }
314
- if (_permanentCensorErrors) {
315
- if (!censorship) {
316
- return;
317
- }
318
- this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
319
- operation: "setCensorship"
320
- });
321
- }
322
- _censorErrors = !!censorship;
323
- _permanentCensorErrors = !!permanent;
324
- }
325
- static setLogLevel(logLevel) {
326
- const level = LogLevels[logLevel.toLowerCase()];
327
- if (level == null) {
328
- Logger.globalLogger().warn("invalid log level - " + logLevel);
329
- return;
330
- }
331
- _logLevel = level;
332
- }
333
- static from(version) {
334
- return new Logger(version);
335
- }
336
- }
337
- Logger.errors = ErrorCode;
338
- Logger.levels = LogLevel;
231
+ utils$9.split32 = split32;
339
232
 
340
- const version$1 = "bytes/5.5.0";
233
+ function rotr32$1(w, b) {
234
+ return (w >>> b) | (w << (32 - b));
235
+ }
236
+ utils$9.rotr32 = rotr32$1;
341
237
 
342
- const logger = new Logger(version$1);
343
- ///////////////////////////////
344
- function isHexable(value) {
345
- return !!(value.toHexString);
238
+ function rotl32$2(w, b) {
239
+ return (w << b) | (w >>> (32 - b));
346
240
  }
347
- function addSlice(array) {
348
- if (array.slice) {
349
- return array;
350
- }
351
- array.slice = function () {
352
- const args = Array.prototype.slice.call(arguments);
353
- return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
354
- };
355
- return array;
241
+ utils$9.rotl32 = rotl32$2;
242
+
243
+ function sum32$3(a, b) {
244
+ return (a + b) >>> 0;
356
245
  }
357
- function isInteger(value) {
358
- return (typeof (value) === "number" && value == value && (value % 1) === 0);
246
+ utils$9.sum32 = sum32$3;
247
+
248
+ function sum32_3$1(a, b, c) {
249
+ return (a + b + c) >>> 0;
359
250
  }
360
- function isBytes(value) {
361
- if (value == null) {
362
- return false;
363
- }
364
- if (value.constructor === Uint8Array) {
365
- return true;
366
- }
367
- if (typeof (value) === "string") {
368
- return false;
369
- }
370
- if (!isInteger(value.length) || value.length < 0) {
371
- return false;
372
- }
373
- for (let i = 0; i < value.length; i++) {
374
- const v = value[i];
375
- if (!isInteger(v) || v < 0 || v >= 256) {
376
- return false;
377
- }
378
- }
379
- return true;
251
+ utils$9.sum32_3 = sum32_3$1;
252
+
253
+ function sum32_4$2(a, b, c, d) {
254
+ return (a + b + c + d) >>> 0;
380
255
  }
381
- function arrayify(value, options) {
382
- if (!options) {
383
- options = {};
384
- }
385
- if (typeof (value) === "number") {
386
- logger.checkSafeUint53(value, "invalid arrayify value");
387
- const result = [];
388
- while (value) {
389
- result.unshift(value & 0xff);
390
- value = parseInt(String(value / 256));
391
- }
392
- if (result.length === 0) {
393
- result.push(0);
394
- }
395
- return addSlice(new Uint8Array(result));
396
- }
397
- if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
398
- value = "0x" + value;
399
- }
400
- if (isHexable(value)) {
401
- value = value.toHexString();
402
- }
403
- if (isHexString(value)) {
404
- let hex = value.substring(2);
405
- if (hex.length % 2) {
406
- if (options.hexPad === "left") {
407
- hex = "0x0" + hex.substring(2);
408
- }
409
- else if (options.hexPad === "right") {
410
- hex += "0";
411
- }
412
- else {
413
- logger.throwArgumentError("hex data is odd-length", "value", value);
414
- }
415
- }
416
- const result = [];
417
- for (let i = 0; i < hex.length; i += 2) {
418
- result.push(parseInt(hex.substring(i, i + 2), 16));
419
- }
420
- return addSlice(new Uint8Array(result));
421
- }
422
- if (isBytes(value)) {
423
- return addSlice(new Uint8Array(value));
424
- }
425
- return logger.throwArgumentError("invalid arrayify value", "value", value);
256
+ utils$9.sum32_4 = sum32_4$2;
257
+
258
+ function sum32_5$2(a, b, c, d, e) {
259
+ return (a + b + c + d + e) >>> 0;
426
260
  }
427
- function isHexString(value, length) {
428
- if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
429
- return false;
430
- }
431
- if (length && value.length !== 2 + 2 * length) {
432
- return false;
433
- }
434
- return true;
261
+ utils$9.sum32_5 = sum32_5$2;
262
+
263
+ function sum64$1(buf, pos, ah, al) {
264
+ var bh = buf[pos];
265
+ var bl = buf[pos + 1];
266
+
267
+ var lo = (al + bl) >>> 0;
268
+ var hi = (lo < al ? 1 : 0) + ah + bh;
269
+ buf[pos] = hi >>> 0;
270
+ buf[pos + 1] = lo;
435
271
  }
272
+ utils$9.sum64 = sum64$1;
436
273
 
437
- var hash$1 = {};
274
+ function sum64_hi$1(ah, al, bh, bl) {
275
+ var lo = (al + bl) >>> 0;
276
+ var hi = (lo < al ? 1 : 0) + ah + bh;
277
+ return hi >>> 0;
278
+ }
279
+ utils$9.sum64_hi = sum64_hi$1;
438
280
 
439
- var utils$9 = {};
281
+ function sum64_lo$1(ah, al, bh, bl) {
282
+ var lo = al + bl;
283
+ return lo >>> 0;
284
+ }
285
+ utils$9.sum64_lo = sum64_lo$1;
440
286
 
441
- var minimalisticAssert = assert$6;
287
+ function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
288
+ var carry = 0;
289
+ var lo = al;
290
+ lo = (lo + bl) >>> 0;
291
+ carry += lo < al ? 1 : 0;
292
+ lo = (lo + cl) >>> 0;
293
+ carry += lo < cl ? 1 : 0;
294
+ lo = (lo + dl) >>> 0;
295
+ carry += lo < dl ? 1 : 0;
442
296
 
443
- function assert$6(val, msg) {
444
- if (!val)
445
- throw new Error(msg || 'Assertion failed');
297
+ var hi = ah + bh + ch + dh + carry;
298
+ return hi >>> 0;
446
299
  }
300
+ utils$9.sum64_4_hi = sum64_4_hi$1;
447
301
 
448
- assert$6.equal = function assertEqual(l, r, msg) {
449
- if (l != r)
450
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
451
- };
302
+ function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
303
+ var lo = al + bl + cl + dl;
304
+ return lo >>> 0;
305
+ }
306
+ utils$9.sum64_4_lo = sum64_4_lo$1;
452
307
 
453
- var inherits$1 = {exports: {}};
308
+ function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
309
+ var carry = 0;
310
+ var lo = al;
311
+ lo = (lo + bl) >>> 0;
312
+ carry += lo < al ? 1 : 0;
313
+ lo = (lo + cl) >>> 0;
314
+ carry += lo < cl ? 1 : 0;
315
+ lo = (lo + dl) >>> 0;
316
+ carry += lo < dl ? 1 : 0;
317
+ lo = (lo + el) >>> 0;
318
+ carry += lo < el ? 1 : 0;
454
319
 
455
- var inherits_browser = {exports: {}};
320
+ var hi = ah + bh + ch + dh + eh + carry;
321
+ return hi >>> 0;
322
+ }
323
+ utils$9.sum64_5_hi = sum64_5_hi$1;
456
324
 
457
- if (typeof Object.create === 'function') {
458
- // implementation from standard node.js 'util' module
459
- inherits_browser.exports = function inherits(ctor, superCtor) {
460
- ctor.super_ = superCtor;
461
- ctor.prototype = Object.create(superCtor.prototype, {
462
- constructor: {
463
- value: ctor,
464
- enumerable: false,
465
- writable: true,
466
- configurable: true
467
- }
468
- });
469
- };
470
- } else {
471
- // old school shim for old browsers
472
- inherits_browser.exports = function inherits(ctor, superCtor) {
473
- ctor.super_ = superCtor;
474
- var TempCtor = function () {};
475
- TempCtor.prototype = superCtor.prototype;
476
- ctor.prototype = new TempCtor();
477
- ctor.prototype.constructor = ctor;
478
- };
325
+ function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
326
+ var lo = al + bl + cl + dl + el;
327
+
328
+ return lo >>> 0;
479
329
  }
330
+ utils$9.sum64_5_lo = sum64_5_lo$1;
480
331
 
481
- try {
482
- var util = require('util');
483
- if (typeof util.inherits !== 'function') throw '';
484
- inherits$1.exports = util.inherits;
485
- } catch (e) {
486
- inherits$1.exports = inherits_browser.exports;
332
+ function rotr64_hi$1(ah, al, num) {
333
+ var r = (al << (32 - num)) | (ah >>> num);
334
+ return r >>> 0;
487
335
  }
336
+ utils$9.rotr64_hi = rotr64_hi$1;
488
337
 
489
- var assert$5 = minimalisticAssert;
490
- var inherits = inherits$1.exports;
338
+ function rotr64_lo$1(ah, al, num) {
339
+ var r = (ah << (32 - num)) | (al >>> num);
340
+ return r >>> 0;
341
+ }
342
+ utils$9.rotr64_lo = rotr64_lo$1;
491
343
 
492
- utils$9.inherits = inherits;
344
+ function shr64_hi$1(ah, al, num) {
345
+ return ah >>> num;
346
+ }
347
+ utils$9.shr64_hi = shr64_hi$1;
493
348
 
494
- function isSurrogatePair(msg, i) {
495
- if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
496
- return false;
497
- }
498
- if (i < 0 || i + 1 >= msg.length) {
499
- return false;
500
- }
501
- return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
349
+ function shr64_lo$1(ah, al, num) {
350
+ var r = (ah << (32 - num)) | (al >>> num);
351
+ return r >>> 0;
502
352
  }
503
-
504
- function toArray(msg, enc) {
505
- if (Array.isArray(msg))
506
- return msg.slice();
507
- if (!msg)
508
- return [];
509
- var res = [];
510
- if (typeof msg === 'string') {
511
- if (!enc) {
512
- // Inspired by stringToUtf8ByteArray() in closure-library by Google
513
- // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
514
- // Apache License 2.0
515
- // https://github.com/google/closure-library/blob/master/LICENSE
516
- var p = 0;
517
- for (var i = 0; i < msg.length; i++) {
518
- var c = msg.charCodeAt(i);
519
- if (c < 128) {
520
- res[p++] = c;
521
- } else if (c < 2048) {
522
- res[p++] = (c >> 6) | 192;
523
- res[p++] = (c & 63) | 128;
524
- } else if (isSurrogatePair(msg, i)) {
525
- c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
526
- res[p++] = (c >> 18) | 240;
527
- res[p++] = ((c >> 12) & 63) | 128;
528
- res[p++] = ((c >> 6) & 63) | 128;
529
- res[p++] = (c & 63) | 128;
530
- } else {
531
- res[p++] = (c >> 12) | 224;
532
- res[p++] = ((c >> 6) & 63) | 128;
533
- res[p++] = (c & 63) | 128;
534
- }
535
- }
536
- } else if (enc === 'hex') {
537
- msg = msg.replace(/[^a-z0-9]+/ig, '');
538
- if (msg.length % 2 !== 0)
539
- msg = '0' + msg;
540
- for (i = 0; i < msg.length; i += 2)
541
- res.push(parseInt(msg[i] + msg[i + 1], 16));
542
- }
543
- } else {
544
- for (i = 0; i < msg.length; i++)
545
- res[i] = msg[i] | 0;
546
- }
547
- return res;
548
- }
549
- utils$9.toArray = toArray;
550
-
551
- function toHex(msg) {
552
- var res = '';
553
- for (var i = 0; i < msg.length; i++)
554
- res += zero2(msg[i].toString(16));
555
- return res;
556
- }
557
- utils$9.toHex = toHex;
558
-
559
- function htonl(w) {
560
- var res = (w >>> 24) |
561
- ((w >>> 8) & 0xff00) |
562
- ((w << 8) & 0xff0000) |
563
- ((w & 0xff) << 24);
564
- return res >>> 0;
565
- }
566
- utils$9.htonl = htonl;
567
-
568
- function toHex32(msg, endian) {
569
- var res = '';
570
- for (var i = 0; i < msg.length; i++) {
571
- var w = msg[i];
572
- if (endian === 'little')
573
- w = htonl(w);
574
- res += zero8(w.toString(16));
575
- }
576
- return res;
577
- }
578
- utils$9.toHex32 = toHex32;
579
-
580
- function zero2(word) {
581
- if (word.length === 1)
582
- return '0' + word;
583
- else
584
- return word;
585
- }
586
- utils$9.zero2 = zero2;
587
-
588
- function zero8(word) {
589
- if (word.length === 7)
590
- return '0' + word;
591
- else if (word.length === 6)
592
- return '00' + word;
593
- else if (word.length === 5)
594
- return '000' + word;
595
- else if (word.length === 4)
596
- return '0000' + word;
597
- else if (word.length === 3)
598
- return '00000' + word;
599
- else if (word.length === 2)
600
- return '000000' + word;
601
- else if (word.length === 1)
602
- return '0000000' + word;
603
- else
604
- return word;
605
- }
606
- utils$9.zero8 = zero8;
607
-
608
- function join32(msg, start, end, endian) {
609
- var len = end - start;
610
- assert$5(len % 4 === 0);
611
- var res = new Array(len / 4);
612
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
613
- var w;
614
- if (endian === 'big')
615
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
616
- else
617
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
618
- res[i] = w >>> 0;
619
- }
620
- return res;
621
- }
622
- utils$9.join32 = join32;
623
-
624
- function split32(msg, endian) {
625
- var res = new Array(msg.length * 4);
626
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
627
- var m = msg[i];
628
- if (endian === 'big') {
629
- res[k] = m >>> 24;
630
- res[k + 1] = (m >>> 16) & 0xff;
631
- res[k + 2] = (m >>> 8) & 0xff;
632
- res[k + 3] = m & 0xff;
633
- } else {
634
- res[k + 3] = m >>> 24;
635
- res[k + 2] = (m >>> 16) & 0xff;
636
- res[k + 1] = (m >>> 8) & 0xff;
637
- res[k] = m & 0xff;
638
- }
639
- }
640
- return res;
641
- }
642
- utils$9.split32 = split32;
643
-
644
- function rotr32$1(w, b) {
645
- return (w >>> b) | (w << (32 - b));
646
- }
647
- utils$9.rotr32 = rotr32$1;
648
-
649
- function rotl32$2(w, b) {
650
- return (w << b) | (w >>> (32 - b));
651
- }
652
- utils$9.rotl32 = rotl32$2;
653
-
654
- function sum32$3(a, b) {
655
- return (a + b) >>> 0;
656
- }
657
- utils$9.sum32 = sum32$3;
658
-
659
- function sum32_3$1(a, b, c) {
660
- return (a + b + c) >>> 0;
661
- }
662
- utils$9.sum32_3 = sum32_3$1;
663
-
664
- function sum32_4$2(a, b, c, d) {
665
- return (a + b + c + d) >>> 0;
666
- }
667
- utils$9.sum32_4 = sum32_4$2;
668
-
669
- function sum32_5$2(a, b, c, d, e) {
670
- return (a + b + c + d + e) >>> 0;
671
- }
672
- utils$9.sum32_5 = sum32_5$2;
673
-
674
- function sum64$1(buf, pos, ah, al) {
675
- var bh = buf[pos];
676
- var bl = buf[pos + 1];
677
-
678
- var lo = (al + bl) >>> 0;
679
- var hi = (lo < al ? 1 : 0) + ah + bh;
680
- buf[pos] = hi >>> 0;
681
- buf[pos + 1] = lo;
682
- }
683
- utils$9.sum64 = sum64$1;
684
-
685
- function sum64_hi$1(ah, al, bh, bl) {
686
- var lo = (al + bl) >>> 0;
687
- var hi = (lo < al ? 1 : 0) + ah + bh;
688
- return hi >>> 0;
689
- }
690
- utils$9.sum64_hi = sum64_hi$1;
691
-
692
- function sum64_lo$1(ah, al, bh, bl) {
693
- var lo = al + bl;
694
- return lo >>> 0;
695
- }
696
- utils$9.sum64_lo = sum64_lo$1;
697
-
698
- function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
699
- var carry = 0;
700
- var lo = al;
701
- lo = (lo + bl) >>> 0;
702
- carry += lo < al ? 1 : 0;
703
- lo = (lo + cl) >>> 0;
704
- carry += lo < cl ? 1 : 0;
705
- lo = (lo + dl) >>> 0;
706
- carry += lo < dl ? 1 : 0;
707
-
708
- var hi = ah + bh + ch + dh + carry;
709
- return hi >>> 0;
710
- }
711
- utils$9.sum64_4_hi = sum64_4_hi$1;
712
-
713
- function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
714
- var lo = al + bl + cl + dl;
715
- return lo >>> 0;
716
- }
717
- utils$9.sum64_4_lo = sum64_4_lo$1;
718
-
719
- function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
720
- var carry = 0;
721
- var lo = al;
722
- lo = (lo + bl) >>> 0;
723
- carry += lo < al ? 1 : 0;
724
- lo = (lo + cl) >>> 0;
725
- carry += lo < cl ? 1 : 0;
726
- lo = (lo + dl) >>> 0;
727
- carry += lo < dl ? 1 : 0;
728
- lo = (lo + el) >>> 0;
729
- carry += lo < el ? 1 : 0;
730
-
731
- var hi = ah + bh + ch + dh + eh + carry;
732
- return hi >>> 0;
733
- }
734
- utils$9.sum64_5_hi = sum64_5_hi$1;
735
-
736
- function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
737
- var lo = al + bl + cl + dl + el;
738
-
739
- return lo >>> 0;
740
- }
741
- utils$9.sum64_5_lo = sum64_5_lo$1;
742
-
743
- function rotr64_hi$1(ah, al, num) {
744
- var r = (al << (32 - num)) | (ah >>> num);
745
- return r >>> 0;
746
- }
747
- utils$9.rotr64_hi = rotr64_hi$1;
748
-
749
- function rotr64_lo$1(ah, al, num) {
750
- var r = (ah << (32 - num)) | (al >>> num);
751
- return r >>> 0;
752
- }
753
- utils$9.rotr64_lo = rotr64_lo$1;
754
-
755
- function shr64_hi$1(ah, al, num) {
756
- return ah >>> num;
757
- }
758
- utils$9.shr64_hi = shr64_hi$1;
759
-
760
- function shr64_lo$1(ah, al, num) {
761
- var r = (ah << (32 - num)) | (al >>> num);
762
- return r >>> 0;
763
- }
764
- utils$9.shr64_lo = shr64_lo$1;
353
+ utils$9.shr64_lo = shr64_lo$1;
765
354
 
766
355
  var common$5 = {};
767
356
 
@@ -1684,16 +1273,425 @@ hash.sha = sha;
1684
1273
  hash.ripemd = ripemd;
1685
1274
  hash.hmac = hmac;
1686
1275
 
1687
- // Proxy hash functions to the main object
1688
- hash.sha1 = hash.sha.sha1;
1689
- hash.sha256 = hash.sha.sha256;
1690
- hash.sha224 = hash.sha.sha224;
1691
- hash.sha384 = hash.sha.sha384;
1692
- hash.sha512 = hash.sha.sha512;
1693
- hash.ripemd160 = hash.ripemd.ripemd160;
1694
- }(hash$1));
1276
+ // Proxy hash functions to the main object
1277
+ hash.sha1 = hash.sha.sha1;
1278
+ hash.sha256 = hash.sha.sha256;
1279
+ hash.sha224 = hash.sha.sha224;
1280
+ hash.sha384 = hash.sha.sha384;
1281
+ hash.sha512 = hash.sha.sha512;
1282
+ hash.ripemd160 = hash.ripemd.ripemd160;
1283
+ }(hash$1));
1284
+
1285
+ var hash = hash$1;
1286
+
1287
+ const version$2 = "logger/5.5.0";
1288
+
1289
+ let _permanentCensorErrors = false;
1290
+ let _censorErrors = false;
1291
+ const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
1292
+ let _logLevel = LogLevels["default"];
1293
+ let _globalLogger = null;
1294
+ function _checkNormalize() {
1295
+ try {
1296
+ const missing = [];
1297
+ // Make sure all forms of normalization are supported
1298
+ ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
1299
+ try {
1300
+ if ("test".normalize(form) !== "test") {
1301
+ throw new Error("bad normalize");
1302
+ }
1303
+ ;
1304
+ }
1305
+ catch (error) {
1306
+ missing.push(form);
1307
+ }
1308
+ });
1309
+ if (missing.length) {
1310
+ throw new Error("missing " + missing.join(", "));
1311
+ }
1312
+ if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
1313
+ throw new Error("broken implementation");
1314
+ }
1315
+ }
1316
+ catch (error) {
1317
+ return error.message;
1318
+ }
1319
+ return null;
1320
+ }
1321
+ const _normalizeError = _checkNormalize();
1322
+ var LogLevel;
1323
+ (function (LogLevel) {
1324
+ LogLevel["DEBUG"] = "DEBUG";
1325
+ LogLevel["INFO"] = "INFO";
1326
+ LogLevel["WARNING"] = "WARNING";
1327
+ LogLevel["ERROR"] = "ERROR";
1328
+ LogLevel["OFF"] = "OFF";
1329
+ })(LogLevel || (LogLevel = {}));
1330
+ var ErrorCode;
1331
+ (function (ErrorCode) {
1332
+ ///////////////////
1333
+ // Generic Errors
1334
+ // Unknown Error
1335
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1336
+ // Not Implemented
1337
+ ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
1338
+ // Unsupported Operation
1339
+ // - operation
1340
+ ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
1341
+ // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
1342
+ // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
1343
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
1344
+ // Some sort of bad response from the server
1345
+ ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
1346
+ // Timeout
1347
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
1348
+ ///////////////////
1349
+ // Operational Errors
1350
+ // Buffer Overrun
1351
+ ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
1352
+ // Numeric Fault
1353
+ // - operation: the operation being executed
1354
+ // - fault: the reason this faulted
1355
+ ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
1356
+ ///////////////////
1357
+ // Argument Errors
1358
+ // Missing new operator to an object
1359
+ // - name: The name of the class
1360
+ ErrorCode["MISSING_NEW"] = "MISSING_NEW";
1361
+ // Invalid argument (e.g. value is incompatible with type) to a function:
1362
+ // - argument: The argument name that was invalid
1363
+ // - value: The value of the argument
1364
+ ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
1365
+ // Missing argument to a function:
1366
+ // - count: The number of arguments received
1367
+ // - expectedCount: The number of arguments expected
1368
+ ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
1369
+ // Too many arguments
1370
+ // - count: The number of arguments received
1371
+ // - expectedCount: The number of arguments expected
1372
+ ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
1373
+ ///////////////////
1374
+ // Blockchain Errors
1375
+ // Call exception
1376
+ // - transaction: the transaction
1377
+ // - address?: the contract address
1378
+ // - args?: The arguments passed into the function
1379
+ // - method?: The Solidity method signature
1380
+ // - errorSignature?: The EIP848 error signature
1381
+ // - errorArgs?: The EIP848 error parameters
1382
+ // - reason: The reason (only for EIP848 "Error(string)")
1383
+ ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
1384
+ // Insufficient funds (< value + gasLimit * gasPrice)
1385
+ // - transaction: the transaction attempted
1386
+ ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
1387
+ // Nonce has already been used
1388
+ // - transaction: the transaction attempted
1389
+ ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
1390
+ // The replacement fee for the transaction is too low
1391
+ // - transaction: the transaction attempted
1392
+ ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
1393
+ // The gas limit could not be estimated
1394
+ // - transaction: the transaction passed to estimateGas
1395
+ ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
1396
+ // The transaction was replaced by one with a higher gas price
1397
+ // - reason: "cancelled", "replaced" or "repriced"
1398
+ // - cancelled: true if reason == "cancelled" or reason == "replaced")
1399
+ // - hash: original transaction hash
1400
+ // - replacement: the full TransactionsResponse for the replacement
1401
+ // - receipt: the receipt of the replacement
1402
+ ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
1403
+ })(ErrorCode || (ErrorCode = {}));
1404
+ const HEX = "0123456789abcdef";
1405
+ class Logger {
1406
+ constructor(version) {
1407
+ Object.defineProperty(this, "version", {
1408
+ enumerable: true,
1409
+ value: version,
1410
+ writable: false
1411
+ });
1412
+ }
1413
+ _log(logLevel, args) {
1414
+ const level = logLevel.toLowerCase();
1415
+ if (LogLevels[level] == null) {
1416
+ this.throwArgumentError("invalid log level name", "logLevel", logLevel);
1417
+ }
1418
+ if (_logLevel > LogLevels[level]) {
1419
+ return;
1420
+ }
1421
+ console.log.apply(console, args);
1422
+ }
1423
+ debug(...args) {
1424
+ this._log(Logger.levels.DEBUG, args);
1425
+ }
1426
+ info(...args) {
1427
+ this._log(Logger.levels.INFO, args);
1428
+ }
1429
+ warn(...args) {
1430
+ this._log(Logger.levels.WARNING, args);
1431
+ }
1432
+ makeError(message, code, params) {
1433
+ // Errors are being censored
1434
+ if (_censorErrors) {
1435
+ return this.makeError("censored error", code, {});
1436
+ }
1437
+ if (!code) {
1438
+ code = Logger.errors.UNKNOWN_ERROR;
1439
+ }
1440
+ if (!params) {
1441
+ params = {};
1442
+ }
1443
+ const messageDetails = [];
1444
+ Object.keys(params).forEach((key) => {
1445
+ const value = params[key];
1446
+ try {
1447
+ if (value instanceof Uint8Array) {
1448
+ let hex = "";
1449
+ for (let i = 0; i < value.length; i++) {
1450
+ hex += HEX[value[i] >> 4];
1451
+ hex += HEX[value[i] & 0x0f];
1452
+ }
1453
+ messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
1454
+ }
1455
+ else {
1456
+ messageDetails.push(key + "=" + JSON.stringify(value));
1457
+ }
1458
+ }
1459
+ catch (error) {
1460
+ messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
1461
+ }
1462
+ });
1463
+ messageDetails.push(`code=${code}`);
1464
+ messageDetails.push(`version=${this.version}`);
1465
+ const reason = message;
1466
+ if (messageDetails.length) {
1467
+ message += " (" + messageDetails.join(", ") + ")";
1468
+ }
1469
+ // @TODO: Any??
1470
+ const error = new Error(message);
1471
+ error.reason = reason;
1472
+ error.code = code;
1473
+ Object.keys(params).forEach(function (key) {
1474
+ error[key] = params[key];
1475
+ });
1476
+ return error;
1477
+ }
1478
+ throwError(message, code, params) {
1479
+ throw this.makeError(message, code, params);
1480
+ }
1481
+ throwArgumentError(message, name, value) {
1482
+ return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
1483
+ argument: name,
1484
+ value: value
1485
+ });
1486
+ }
1487
+ assert(condition, message, code, params) {
1488
+ if (!!condition) {
1489
+ return;
1490
+ }
1491
+ this.throwError(message, code, params);
1492
+ }
1493
+ assertArgument(condition, message, name, value) {
1494
+ if (!!condition) {
1495
+ return;
1496
+ }
1497
+ this.throwArgumentError(message, name, value);
1498
+ }
1499
+ checkNormalize(message) {
1500
+ if (_normalizeError) {
1501
+ this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
1502
+ operation: "String.prototype.normalize", form: _normalizeError
1503
+ });
1504
+ }
1505
+ }
1506
+ checkSafeUint53(value, message) {
1507
+ if (typeof (value) !== "number") {
1508
+ return;
1509
+ }
1510
+ if (message == null) {
1511
+ message = "value not safe";
1512
+ }
1513
+ if (value < 0 || value >= 0x1fffffffffffff) {
1514
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1515
+ operation: "checkSafeInteger",
1516
+ fault: "out-of-safe-range",
1517
+ value: value
1518
+ });
1519
+ }
1520
+ if (value % 1) {
1521
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1522
+ operation: "checkSafeInteger",
1523
+ fault: "non-integer",
1524
+ value: value
1525
+ });
1526
+ }
1527
+ }
1528
+ checkArgumentCount(count, expectedCount, message) {
1529
+ if (message) {
1530
+ message = ": " + message;
1531
+ }
1532
+ else {
1533
+ message = "";
1534
+ }
1535
+ if (count < expectedCount) {
1536
+ this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
1537
+ count: count,
1538
+ expectedCount: expectedCount
1539
+ });
1540
+ }
1541
+ if (count > expectedCount) {
1542
+ this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
1543
+ count: count,
1544
+ expectedCount: expectedCount
1545
+ });
1546
+ }
1547
+ }
1548
+ checkNew(target, kind) {
1549
+ if (target === Object || target == null) {
1550
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1551
+ }
1552
+ }
1553
+ checkAbstract(target, kind) {
1554
+ if (target === kind) {
1555
+ this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
1556
+ }
1557
+ else if (target === Object || target == null) {
1558
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1559
+ }
1560
+ }
1561
+ static globalLogger() {
1562
+ if (!_globalLogger) {
1563
+ _globalLogger = new Logger(version$2);
1564
+ }
1565
+ return _globalLogger;
1566
+ }
1567
+ static setCensorship(censorship, permanent) {
1568
+ if (!censorship && permanent) {
1569
+ this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
1570
+ operation: "setCensorship"
1571
+ });
1572
+ }
1573
+ if (_permanentCensorErrors) {
1574
+ if (!censorship) {
1575
+ return;
1576
+ }
1577
+ this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
1578
+ operation: "setCensorship"
1579
+ });
1580
+ }
1581
+ _censorErrors = !!censorship;
1582
+ _permanentCensorErrors = !!permanent;
1583
+ }
1584
+ static setLogLevel(logLevel) {
1585
+ const level = LogLevels[logLevel.toLowerCase()];
1586
+ if (level == null) {
1587
+ Logger.globalLogger().warn("invalid log level - " + logLevel);
1588
+ return;
1589
+ }
1590
+ _logLevel = level;
1591
+ }
1592
+ static from(version) {
1593
+ return new Logger(version);
1594
+ }
1595
+ }
1596
+ Logger.errors = ErrorCode;
1597
+ Logger.levels = LogLevel;
1598
+
1599
+ const version$1 = "bytes/5.5.0";
1695
1600
 
1696
- var hash = hash$1;
1601
+ const logger = new Logger(version$1);
1602
+ ///////////////////////////////
1603
+ function isHexable(value) {
1604
+ return !!(value.toHexString);
1605
+ }
1606
+ function addSlice(array) {
1607
+ if (array.slice) {
1608
+ return array;
1609
+ }
1610
+ array.slice = function () {
1611
+ const args = Array.prototype.slice.call(arguments);
1612
+ return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
1613
+ };
1614
+ return array;
1615
+ }
1616
+ function isInteger(value) {
1617
+ return (typeof (value) === "number" && value == value && (value % 1) === 0);
1618
+ }
1619
+ function isBytes(value) {
1620
+ if (value == null) {
1621
+ return false;
1622
+ }
1623
+ if (value.constructor === Uint8Array) {
1624
+ return true;
1625
+ }
1626
+ if (typeof (value) === "string") {
1627
+ return false;
1628
+ }
1629
+ if (!isInteger(value.length) || value.length < 0) {
1630
+ return false;
1631
+ }
1632
+ for (let i = 0; i < value.length; i++) {
1633
+ const v = value[i];
1634
+ if (!isInteger(v) || v < 0 || v >= 256) {
1635
+ return false;
1636
+ }
1637
+ }
1638
+ return true;
1639
+ }
1640
+ function arrayify(value, options) {
1641
+ if (!options) {
1642
+ options = {};
1643
+ }
1644
+ if (typeof (value) === "number") {
1645
+ logger.checkSafeUint53(value, "invalid arrayify value");
1646
+ const result = [];
1647
+ while (value) {
1648
+ result.unshift(value & 0xff);
1649
+ value = parseInt(String(value / 256));
1650
+ }
1651
+ if (result.length === 0) {
1652
+ result.push(0);
1653
+ }
1654
+ return addSlice(new Uint8Array(result));
1655
+ }
1656
+ if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
1657
+ value = "0x" + value;
1658
+ }
1659
+ if (isHexable(value)) {
1660
+ value = value.toHexString();
1661
+ }
1662
+ if (isHexString(value)) {
1663
+ let hex = value.substring(2);
1664
+ if (hex.length % 2) {
1665
+ if (options.hexPad === "left") {
1666
+ hex = "0x0" + hex.substring(2);
1667
+ }
1668
+ else if (options.hexPad === "right") {
1669
+ hex += "0";
1670
+ }
1671
+ else {
1672
+ logger.throwArgumentError("hex data is odd-length", "value", value);
1673
+ }
1674
+ }
1675
+ const result = [];
1676
+ for (let i = 0; i < hex.length; i += 2) {
1677
+ result.push(parseInt(hex.substring(i, i + 2), 16));
1678
+ }
1679
+ return addSlice(new Uint8Array(result));
1680
+ }
1681
+ if (isBytes(value)) {
1682
+ return addSlice(new Uint8Array(value));
1683
+ }
1684
+ return logger.throwArgumentError("invalid arrayify value", "value", value);
1685
+ }
1686
+ function isHexString(value, length) {
1687
+ if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
1688
+ return false;
1689
+ }
1690
+ if (length && value.length !== 2 + 2 * length) {
1691
+ return false;
1692
+ }
1693
+ return true;
1694
+ }
1697
1695
 
1698
1696
  const version = "sha2/5.5.0";
1699
1697
 
@@ -1725,8 +1723,7 @@ class Struct {
1725
1723
  class Enum extends Struct {
1726
1724
  constructor(properties) {
1727
1725
  super(properties);
1728
-
1729
- _defineProperty(this, "enum", '');
1726
+ this.enum = '';
1730
1727
 
1731
1728
  if (Object.keys(properties).length !== 1) {
1732
1729
  throw new Error('Enum can only take single value');
@@ -1766,8 +1763,7 @@ class PublicKey extends Struct {
1766
1763
  */
1767
1764
  constructor(value) {
1768
1765
  super({});
1769
-
1770
- _defineProperty(this, "_bn", void 0);
1766
+ this._bn = void 0;
1771
1767
 
1772
1768
  if (isPublicKeyData(value)) {
1773
1769
  this._bn = value._bn;
@@ -1777,7 +1773,7 @@ class PublicKey extends Struct {
1777
1773
  const decoded = bs58.decode(value);
1778
1774
 
1779
1775
  if (decoded.length != 32) {
1780
- throw new Error("Invalid public key input");
1776
+ throw new Error(`Invalid public key input`);
1781
1777
  }
1782
1778
 
1783
1779
  this._bn = new BN(decoded);
@@ -1786,7 +1782,7 @@ class PublicKey extends Struct {
1786
1782
  }
1787
1783
 
1788
1784
  if (this._bn.byteLength() > 32) {
1789
- throw new Error("Invalid public key input");
1785
+ throw new Error(`Invalid public key input`);
1790
1786
  }
1791
1787
  }
1792
1788
  }
@@ -1809,6 +1805,10 @@ class PublicKey extends Struct {
1809
1805
  toBase58() {
1810
1806
  return bs58.encode(this.toBytes());
1811
1807
  }
1808
+
1809
+ toJSON() {
1810
+ return this.toBase58();
1811
+ }
1812
1812
  /**
1813
1813
  * Return the byte array representation of the public key
1814
1814
  */
@@ -1866,7 +1866,7 @@ class PublicKey extends Struct {
1866
1866
  let buffer = Buffer.alloc(0);
1867
1867
  seeds.forEach(function (seed) {
1868
1868
  if (seed.length > MAX_SEED_LENGTH) {
1869
- throw new TypeError("Max seed length exceeded");
1869
+ throw new TypeError(`Max seed length exceeded`);
1870
1870
  }
1871
1871
 
1872
1872
  buffer = Buffer.concat([buffer, toBuffer(seed)]);
@@ -1876,7 +1876,7 @@ class PublicKey extends Struct {
1876
1876
  let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
1877
1877
 
1878
1878
  if (is_on_curve(publicKeyBytes)) {
1879
- throw new Error("Invalid seeds, address must fall off the curve");
1879
+ throw new Error(`Invalid seeds, address must fall off the curve`);
1880
1880
  }
1881
1881
 
1882
1882
  return new PublicKey(publicKeyBytes);
@@ -1910,7 +1910,7 @@ class PublicKey extends Struct {
1910
1910
  return [address, nonce];
1911
1911
  }
1912
1912
 
1913
- throw new Error("Unable to find a viable program address nonce");
1913
+ throw new Error(`Unable to find a viable program address nonce`);
1914
1914
  }
1915
1915
  /**
1916
1916
  * Check that a pubkey is on the ed25519 curve.
@@ -1922,15 +1922,13 @@ class PublicKey extends Struct {
1922
1922
  }
1923
1923
 
1924
1924
  }
1925
-
1926
- _defineProperty(PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
1927
-
1925
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
1928
1926
  SOLANA_SCHEMA.set(PublicKey, {
1929
1927
  kind: 'struct',
1930
1928
  fields: [['_bn', 'u256']]
1931
1929
  }); // @ts-ignore
1932
1930
 
1933
- let naclLowLevel = nacl__default.lowlevel; // Check that a pubkey is on the curve.
1931
+ let naclLowLevel = nacl.lowlevel; // Check that a pubkey is on the curve.
1934
1932
  // This function and its dependents were sourced from:
1935
1933
  // https://github.com/dchest/tweetnacl-js/blob/f1ec050ceae0861f34280e62498b1d3ed9c350c6/nacl.js#L792
1936
1934
 
@@ -1997,7 +1995,7 @@ class Account {
1997
1995
  * @param secretKey Secret key for the account
1998
1996
  */
1999
1997
  constructor(secretKey) {
2000
- _defineProperty(this, "_keypair", void 0);
1998
+ this._keypair = void 0;
2001
1999
 
2002
2000
  if (secretKey) {
2003
2001
  this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
@@ -2133,16 +2131,11 @@ const PUBKEY_LENGTH = 32;
2133
2131
 
2134
2132
  class Message {
2135
2133
  constructor(args) {
2136
- _defineProperty(this, "header", void 0);
2137
-
2138
- _defineProperty(this, "accountKeys", void 0);
2139
-
2140
- _defineProperty(this, "recentBlockhash", void 0);
2141
-
2142
- _defineProperty(this, "instructions", void 0);
2143
-
2144
- _defineProperty(this, "indexToProgramIds", new Map());
2145
-
2134
+ this.header = void 0;
2135
+ this.accountKeys = void 0;
2136
+ this.recentBlockhash = void 0;
2137
+ this.instructions = void 0;
2138
+ this.indexToProgramIds = new Map();
2146
2139
  this.header = args.header;
2147
2140
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
2148
2141
  this.recentBlockhash = args.recentBlockhash;
@@ -2316,12 +2309,9 @@ class TransactionInstruction {
2316
2309
  * Program input
2317
2310
  */
2318
2311
  constructor(opts) {
2319
- _defineProperty(this, "keys", void 0);
2320
-
2321
- _defineProperty(this, "programId", void 0);
2322
-
2323
- _defineProperty(this, "data", Buffer.alloc(0));
2324
-
2312
+ this.keys = void 0;
2313
+ this.programId = void 0;
2314
+ this.data = Buffer.alloc(0);
2325
2315
  this.programId = opts.programId;
2326
2316
  this.keys = opts.keys;
2327
2317
 
@@ -2363,16 +2353,11 @@ class Transaction {
2363
2353
  * Construct an empty Transaction
2364
2354
  */
2365
2355
  constructor(opts) {
2366
- _defineProperty(this, "signatures", []);
2367
-
2368
- _defineProperty(this, "feePayer", void 0);
2369
-
2370
- _defineProperty(this, "instructions", []);
2371
-
2372
- _defineProperty(this, "recentBlockhash", void 0);
2373
-
2374
- _defineProperty(this, "nonceInfo", void 0);
2375
-
2356
+ this.signatures = [];
2357
+ this.feePayer = void 0;
2358
+ this.instructions = [];
2359
+ this.recentBlockhash = void 0;
2360
+ this.nonceInfo = void 0;
2376
2361
  opts && Object.assign(this, opts);
2377
2362
  }
2378
2363
  /**
@@ -2436,7 +2421,7 @@ class Transaction {
2436
2421
 
2437
2422
  for (let i = 0; i < this.instructions.length; i++) {
2438
2423
  if (this.instructions[i].programId === undefined) {
2439
- throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
2424
+ throw new Error(`Transaction instruction index ${i} has undefined program id`);
2440
2425
  }
2441
2426
  }
2442
2427
 
@@ -2463,8 +2448,9 @@ class Transaction {
2463
2448
  }); // Sort. Prioritizing first by signer, then by writable
2464
2449
 
2465
2450
  accountMetas.sort(function (x, y) {
2451
+ const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2466
2452
  const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2467
- const checkWritable = x.isWritable === y.isWritable ? 0 : x.isWritable ? -1 : 1;
2453
+ const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2468
2454
  return checkSigner || checkWritable;
2469
2455
  }); // Cull duplicate account metas
2470
2456
 
@@ -2511,7 +2497,7 @@ class Transaction {
2511
2497
  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.');
2512
2498
  }
2513
2499
  } else {
2514
- throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
2500
+ throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
2515
2501
  }
2516
2502
  }
2517
2503
 
@@ -2718,7 +2704,7 @@ class Transaction {
2718
2704
  _partialSign(message, ...signers) {
2719
2705
  const signData = message.serialize();
2720
2706
  signers.forEach(signer => {
2721
- const signature = nacl__default.sign.detached(signData, signer.secretKey);
2707
+ const signature = nacl.sign.detached(signData, signer.secretKey);
2722
2708
 
2723
2709
  this._addSignature(signer.publicKey, toBuffer(signature));
2724
2710
  });
@@ -2746,7 +2732,7 @@ class Transaction {
2746
2732
  const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
2747
2733
 
2748
2734
  if (index < 0) {
2749
- throw new Error("unknown signer: ".concat(pubkey.toString()));
2735
+ throw new Error(`unknown signer: ${pubkey.toString()}`);
2750
2736
  }
2751
2737
 
2752
2738
  this.signatures[index].signature = Buffer.from(signature);
@@ -2774,7 +2760,7 @@ class Transaction {
2774
2760
  return false;
2775
2761
  }
2776
2762
  } else {
2777
- if (!nacl__default.sign.detached.verify(signData, signature, publicKey.toBuffer())) {
2763
+ if (!nacl.sign.detached.verify(signData, signature, publicKey.toBuffer())) {
2778
2764
  return false;
2779
2765
  }
2780
2766
  }
@@ -2822,12 +2808,12 @@ class Transaction {
2822
2808
  signature
2823
2809
  }, index) => {
2824
2810
  if (signature !== null) {
2825
- assert(signature.length === 64, "signature has invalid length");
2811
+ assert(signature.length === 64, `signature has invalid length`);
2826
2812
  Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
2827
2813
  }
2828
2814
  });
2829
2815
  signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
2830
- assert(wireTransaction.length <= PACKET_DATA_SIZE, "Transaction too large: ".concat(wireTransaction.length, " > ").concat(PACKET_DATA_SIZE));
2816
+ assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
2831
2817
  return wireTransaction;
2832
2818
  }
2833
2819
  /**
@@ -2920,11 +2906,14 @@ class Transaction {
2920
2906
  }
2921
2907
 
2922
2908
  const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
2909
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
2910
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2923
2911
  const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
2924
2912
  const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
2925
2913
  const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
2914
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
2915
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
2926
2916
  const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
2927
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2928
2917
 
2929
2918
  /**
2930
2919
  * Sign, send and confirm a transaction.
@@ -2946,7 +2935,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2946
2935
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2947
2936
 
2948
2937
  if (status.err) {
2949
- throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
2938
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
2950
2939
  }
2951
2940
 
2952
2941
  return signature;
@@ -2989,7 +2978,7 @@ function decodeData(type, buffer) {
2989
2978
  }
2990
2979
 
2991
2980
  if (data.instruction !== type.index) {
2992
- throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
2981
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
2993
2982
  }
2994
2983
 
2995
2984
  return data;
@@ -3023,12 +3012,9 @@ class NonceAccount {
3023
3012
  * @internal
3024
3013
  */
3025
3014
  constructor(args) {
3026
- _defineProperty(this, "authorizedPubkey", void 0);
3027
-
3028
- _defineProperty(this, "nonce", void 0);
3029
-
3030
- _defineProperty(this, "feeCalculator", void 0);
3031
-
3015
+ this.authorizedPubkey = void 0;
3016
+ this.nonce = void 0;
3017
+ this.feeCalculator = void 0;
3032
3018
  this.authorizedPubkey = args.authorizedPubkey;
3033
3019
  this.nonce = args.nonce;
3034
3020
  this.feeCalculator = args.feeCalculator;
@@ -3329,7 +3315,7 @@ class SystemInstruction {
3329
3315
 
3330
3316
  static checkKeyLength(keys, expectedLength) {
3331
3317
  if (keys.length < expectedLength) {
3332
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
3318
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
3333
3319
  }
3334
3320
  }
3335
3321
 
@@ -3761,8 +3747,7 @@ class SystemProgram {
3761
3747
  }
3762
3748
 
3763
3749
  }
3764
-
3765
- _defineProperty(SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3750
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3766
3751
 
3767
3752
  // rest of the Transaction fields
3768
3753
  //
@@ -3931,8 +3916,7 @@ class Loader {
3931
3916
  }
3932
3917
 
3933
3918
  }
3934
-
3935
- _defineProperty(Loader, "chunkSize", CHUNK_SIZE);
3919
+ Loader.chunkSize = CHUNK_SIZE;
3936
3920
 
3937
3921
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
3938
3922
  /**
@@ -3983,14 +3967,10 @@ class AgentManager {
3983
3967
  }
3984
3968
 
3985
3969
  constructor(useHttps) {
3986
- _defineProperty(this, "_agent", void 0);
3987
-
3988
- _defineProperty(this, "_activeRequests", 0);
3989
-
3990
- _defineProperty(this, "_destroyTimeout", null);
3991
-
3992
- _defineProperty(this, "_useHttps", void 0);
3993
-
3970
+ this._agent = void 0;
3971
+ this._activeRequests = 0;
3972
+ this._destroyTimeout = null;
3973
+ this._useHttps = void 0;
3994
3974
  this._useHttps = useHttps === true;
3995
3975
  this._agent = AgentManager._newAgent(this._useHttps);
3996
3976
  }
@@ -4063,16 +4043,11 @@ class EpochSchedule {
4063
4043
 
4064
4044
  /** The first slot of `firstNormalEpoch` */
4065
4045
  constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
4066
- _defineProperty(this, "slotsPerEpoch", void 0);
4067
-
4068
- _defineProperty(this, "leaderScheduleSlotOffset", void 0);
4069
-
4070
- _defineProperty(this, "warmup", void 0);
4071
-
4072
- _defineProperty(this, "firstNormalEpoch", void 0);
4073
-
4074
- _defineProperty(this, "firstNormalSlot", void 0);
4075
-
4046
+ this.slotsPerEpoch = void 0;
4047
+ this.leaderScheduleSlotOffset = void 0;
4048
+ this.warmup = void 0;
4049
+ this.firstNormalEpoch = void 0;
4050
+ this.firstNormalSlot = void 0;
4076
4051
  this.slotsPerEpoch = slotsPerEpoch;
4077
4052
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
4078
4053
  this.warmup = warmup;
@@ -4124,9 +4099,7 @@ class EpochSchedule {
4124
4099
  class SendTransactionError extends Error {
4125
4100
  constructor(message, logs) {
4126
4101
  super(message);
4127
-
4128
- _defineProperty(this, "logs", void 0);
4129
-
4102
+ this.logs = void 0;
4130
4103
  this.logs = logs;
4131
4104
  }
4132
4105
 
@@ -4358,16 +4331,15 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4358
4331
  let fetchWithMiddleware;
4359
4332
 
4360
4333
  if (fetchMiddleware) {
4361
- fetchWithMiddleware = (url, options) => {
4362
- return new Promise((resolve, reject) => {
4363
- fetchMiddleware(url, options, async (url, options) => {
4364
- try {
4365
- resolve(await fetch(url, options));
4366
- } catch (error) {
4367
- reject(error);
4368
- }
4369
- });
4334
+ fetchWithMiddleware = async (url, options) => {
4335
+ const modifiedFetchArgs = await new Promise((resolve, reject) => {
4336
+ try {
4337
+ fetchMiddleware(url, options, (modifiedUrl, modifiedOptions) => resolve([modifiedUrl, modifiedOptions]));
4338
+ } catch (error) {
4339
+ reject(error);
4340
+ }
4370
4341
  });
4342
+ return await fetch(...modifiedFetchArgs);
4371
4343
  };
4372
4344
  }
4373
4345
 
@@ -4410,7 +4382,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4410
4382
  break;
4411
4383
  }
4412
4384
 
4413
- console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
4385
+ console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
4414
4386
  await sleep(waitTime);
4415
4387
  waitTime *= 2;
4416
4388
  }
@@ -4420,7 +4392,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4420
4392
  if (res.ok) {
4421
4393
  callback(null, text);
4422
4394
  } else {
4423
- callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
4395
+ callback(new Error(`${res.status} ${res.statusText}: ${text}`));
4424
4396
  }
4425
4397
  } catch (err) {
4426
4398
  if (err instanceof Error) callback(err);
@@ -4861,6 +4833,7 @@ const ParsedConfirmedTransactionResult = type({
4861
4833
  const TokenBalanceResult = type({
4862
4834
  accountIndex: number(),
4863
4835
  mint: string(),
4836
+ owner: optional(string()),
4864
4837
  uiTokenAmount: TokenAmountResult
4865
4838
  });
4866
4839
  /**
@@ -5086,67 +5059,39 @@ class Connection {
5086
5059
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
5087
5060
  */
5088
5061
  constructor(endpoint, commitmentOrConfig) {
5089
- _defineProperty(this, "_commitment", void 0);
5090
-
5091
- _defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
5092
-
5093
- _defineProperty(this, "_rpcEndpoint", void 0);
5094
-
5095
- _defineProperty(this, "_rpcWsEndpoint", void 0);
5096
-
5097
- _defineProperty(this, "_rpcClient", void 0);
5098
-
5099
- _defineProperty(this, "_rpcRequest", void 0);
5100
-
5101
- _defineProperty(this, "_rpcBatchRequest", void 0);
5102
-
5103
- _defineProperty(this, "_rpcWebSocket", void 0);
5104
-
5105
- _defineProperty(this, "_rpcWebSocketConnected", false);
5106
-
5107
- _defineProperty(this, "_rpcWebSocketHeartbeat", null);
5108
-
5109
- _defineProperty(this, "_rpcWebSocketIdleTimeout", null);
5110
-
5111
- _defineProperty(this, "_disableBlockhashCaching", false);
5112
-
5113
- _defineProperty(this, "_pollingBlockhash", false);
5114
-
5115
- _defineProperty(this, "_blockhashInfo", {
5062
+ this._commitment = void 0;
5063
+ this._confirmTransactionInitialTimeout = void 0;
5064
+ this._rpcEndpoint = void 0;
5065
+ this._rpcWsEndpoint = void 0;
5066
+ this._rpcClient = void 0;
5067
+ this._rpcRequest = void 0;
5068
+ this._rpcBatchRequest = void 0;
5069
+ this._rpcWebSocket = void 0;
5070
+ this._rpcWebSocketConnected = false;
5071
+ this._rpcWebSocketHeartbeat = null;
5072
+ this._rpcWebSocketIdleTimeout = null;
5073
+ this._disableBlockhashCaching = false;
5074
+ this._pollingBlockhash = false;
5075
+ this._blockhashInfo = {
5116
5076
  recentBlockhash: null,
5117
5077
  lastFetch: 0,
5118
5078
  transactionSignatures: [],
5119
5079
  simulatedSignatures: []
5120
- });
5121
-
5122
- _defineProperty(this, "_accountChangeSubscriptionCounter", 0);
5123
-
5124
- _defineProperty(this, "_accountChangeSubscriptions", {});
5125
-
5126
- _defineProperty(this, "_programAccountChangeSubscriptionCounter", 0);
5127
-
5128
- _defineProperty(this, "_programAccountChangeSubscriptions", {});
5129
-
5130
- _defineProperty(this, "_rootSubscriptionCounter", 0);
5131
-
5132
- _defineProperty(this, "_rootSubscriptions", {});
5133
-
5134
- _defineProperty(this, "_signatureSubscriptionCounter", 0);
5135
-
5136
- _defineProperty(this, "_signatureSubscriptions", {});
5137
-
5138
- _defineProperty(this, "_slotSubscriptionCounter", 0);
5139
-
5140
- _defineProperty(this, "_slotSubscriptions", {});
5141
-
5142
- _defineProperty(this, "_logsSubscriptionCounter", 0);
5143
-
5144
- _defineProperty(this, "_logsSubscriptions", {});
5145
-
5146
- _defineProperty(this, "_slotUpdateSubscriptionCounter", 0);
5147
-
5148
- _defineProperty(this, "_slotUpdateSubscriptions", {});
5149
-
5080
+ };
5081
+ this._accountChangeSubscriptionCounter = 0;
5082
+ this._accountChangeSubscriptions = {};
5083
+ this._programAccountChangeSubscriptionCounter = 0;
5084
+ this._programAccountChangeSubscriptions = {};
5085
+ this._rootSubscriptionCounter = 0;
5086
+ this._rootSubscriptions = {};
5087
+ this._signatureSubscriptionCounter = 0;
5088
+ this._signatureSubscriptions = {};
5089
+ this._slotSubscriptionCounter = 0;
5090
+ this._slotSubscriptions = {};
5091
+ this._logsSubscriptionCounter = 0;
5092
+ this._logsSubscriptions = {};
5093
+ this._slotUpdateSubscriptionCounter = 0;
5094
+ this._slotUpdateSubscriptions = {};
5150
5095
  let url = new URL(endpoint);
5151
5096
  const useHttps = url.protocol === 'https:';
5152
5097
  let wsEndpoint;
@@ -5492,13 +5437,25 @@ class Connection {
5492
5437
  */
5493
5438
 
5494
5439
 
5495
- async getMultipleAccountsInfo(publicKeys, commitment) {
5440
+ async getMultipleAccountsInfo(publicKeys, configOrCommitment) {
5496
5441
  const keys = publicKeys.map(key => key.toBase58());
5442
+ let commitment;
5443
+ let encoding = 'base64';
5444
+
5445
+ if (configOrCommitment) {
5446
+ if (typeof configOrCommitment === 'string') {
5447
+ commitment = configOrCommitment;
5448
+ encoding = 'base64';
5449
+ } else {
5450
+ commitment = configOrCommitment.commitment;
5451
+ encoding = configOrCommitment.encoding || 'base64';
5452
+ }
5453
+ }
5497
5454
 
5498
- const args = this._buildArgs([keys], commitment, 'base64');
5455
+ const args = this._buildArgs([keys], commitment, encoding);
5499
5456
 
5500
5457
  const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
5501
- const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
5458
+ const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(ParsedAccountInfoResult))));
5502
5459
 
5503
5460
  if ('error' in res) {
5504
5461
  throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
@@ -5520,7 +5477,7 @@ class Connection {
5520
5477
  const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
5521
5478
 
5522
5479
  if ('error' in res) {
5523
- throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
5480
+ throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
5524
5481
  }
5525
5482
 
5526
5483
  return res.result;
@@ -5656,7 +5613,7 @@ class Connection {
5656
5613
 
5657
5614
  if (response === null) {
5658
5615
  const duration = (Date.now() - start) / 1000;
5659
- 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."));
5616
+ 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.`);
5660
5617
  }
5661
5618
 
5662
5619
  return response;
@@ -5979,6 +5936,29 @@ class Connection {
5979
5936
  value: value !== null ? value.feeCalculator : null
5980
5937
  };
5981
5938
  }
5939
+ /**
5940
+ * Fetch the fee for a message from the cluster, return with context
5941
+ */
5942
+
5943
+
5944
+ async getFeeForMessage(message, commitment) {
5945
+ const wireMessage = message.serialize().toString('base64');
5946
+
5947
+ const args = this._buildArgs([wireMessage], commitment);
5948
+
5949
+ const unsafeRes = await this._rpcRequest('getFeeForMessage', args);
5950
+ const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));
5951
+
5952
+ if ('error' in res) {
5953
+ throw new Error('failed to get slot: ' + res.error.message);
5954
+ }
5955
+
5956
+ if (res.result === null) {
5957
+ throw new Error('invalid blockhash');
5958
+ }
5959
+
5960
+ return res.result;
5961
+ }
5982
5962
  /**
5983
5963
  * Fetch a recent blockhash from the cluster
5984
5964
  * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
@@ -6430,7 +6410,7 @@ class Connection {
6430
6410
  await sleep(MS_PER_SLOT / 2);
6431
6411
  }
6432
6412
 
6433
- throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
6413
+ throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
6434
6414
  } finally {
6435
6415
  this._pollingBlockhash = false;
6436
6416
  }
@@ -6687,7 +6667,7 @@ class Connection {
6687
6667
  }
6688
6668
 
6689
6669
  if (err instanceof Error) {
6690
- console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
6670
+ console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
6691
6671
  }
6692
6672
  }
6693
6673
  }
@@ -6707,7 +6687,7 @@ class Connection {
6707
6687
  await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
6708
6688
  } catch (err) {
6709
6689
  if (err instanceof Error) {
6710
- console.error("".concat(rpcMethod, " error:"), err.message);
6690
+ console.error(`${rpcMethod} error:`, err.message);
6711
6691
  }
6712
6692
  }
6713
6693
  }
@@ -6872,7 +6852,7 @@ class Connection {
6872
6852
 
6873
6853
  this._updateSubscriptions();
6874
6854
  } else {
6875
- throw new Error("Unknown account change id: ".concat(id));
6855
+ throw new Error(`Unknown account change id: ${id}`);
6876
6856
  }
6877
6857
  }
6878
6858
  /**
@@ -6938,7 +6918,7 @@ class Connection {
6938
6918
 
6939
6919
  this._updateSubscriptions();
6940
6920
  } else {
6941
- throw new Error("Unknown program account change id: ".concat(id));
6921
+ throw new Error(`Unknown program account change id: ${id}`);
6942
6922
  }
6943
6923
  }
6944
6924
  /**
@@ -6968,7 +6948,7 @@ class Connection {
6968
6948
 
6969
6949
  async removeOnLogsListener(id) {
6970
6950
  if (!this._logsSubscriptions[id]) {
6971
- throw new Error("Unknown logs id: ".concat(id));
6951
+ throw new Error(`Unknown logs id: ${id}`);
6972
6952
  }
6973
6953
 
6974
6954
  const subInfo = this._logsSubscriptions[id];
@@ -7044,7 +7024,7 @@ class Connection {
7044
7024
 
7045
7025
  this._updateSubscriptions();
7046
7026
  } else {
7047
- throw new Error("Unknown slot change id: ".concat(id));
7027
+ throw new Error(`Unknown slot change id: ${id}`);
7048
7028
  }
7049
7029
  }
7050
7030
  /**
@@ -7097,7 +7077,7 @@ class Connection {
7097
7077
 
7098
7078
  this._updateSubscriptions();
7099
7079
  } else {
7100
- throw new Error("Unknown slot update id: ".concat(id));
7080
+ throw new Error(`Unknown slot update id: ${id}`);
7101
7081
  }
7102
7082
  }
7103
7083
 
@@ -7238,7 +7218,7 @@ class Connection {
7238
7218
 
7239
7219
  this._updateSubscriptions();
7240
7220
  } else {
7241
- throw new Error("Unknown signature result id: ".concat(id));
7221
+ throw new Error(`Unknown signature result id: ${id}`);
7242
7222
  }
7243
7223
  }
7244
7224
  /**
@@ -7290,7 +7270,7 @@ class Connection {
7290
7270
 
7291
7271
  this._updateSubscriptions();
7292
7272
  } else {
7293
- throw new Error("Unknown root change id: ".concat(id));
7273
+ throw new Error(`Unknown root change id: ${id}`);
7294
7274
  }
7295
7275
  }
7296
7276
 
@@ -7311,7 +7291,7 @@ class Keypair {
7311
7291
  * @param keypair ed25519 keypair
7312
7292
  */
7313
7293
  constructor(keypair) {
7314
- _defineProperty(this, "_keypair", void 0);
7294
+ this._keypair = void 0;
7315
7295
 
7316
7296
  if (keypair) {
7317
7297
  this._keypair = keypair;
@@ -7415,8 +7395,8 @@ class Ed25519Program {
7415
7395
  signature,
7416
7396
  instructionIndex
7417
7397
  } = params;
7418
- assert(publicKey.length === PUBLIC_KEY_BYTES$1, "Public Key must be ".concat(PUBLIC_KEY_BYTES$1, " bytes but received ").concat(publicKey.length, " bytes"));
7419
- assert(signature.length === SIGNATURE_BYTES, "Signature must be ".concat(SIGNATURE_BYTES, " bytes but received ").concat(signature.length, " bytes"));
7398
+ assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
7399
+ assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
7420
7400
  const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
7421
7401
  const signatureOffset = publicKeyOffset + publicKey.length;
7422
7402
  const messageDataOffset = signatureOffset + signature.length;
@@ -7454,12 +7434,12 @@ class Ed25519Program {
7454
7434
  message,
7455
7435
  instructionIndex
7456
7436
  } = params;
7457
- assert(privateKey.length === PRIVATE_KEY_BYTES$1, "Private key must be ".concat(PRIVATE_KEY_BYTES$1, " bytes but received ").concat(privateKey.length, " bytes"));
7437
+ assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
7458
7438
 
7459
7439
  try {
7460
7440
  const keypair = Keypair.fromSecretKey(privateKey);
7461
7441
  const publicKey = keypair.publicKey.toBytes();
7462
- const signature = nacl__default.sign.detached(message, keypair.secretKey);
7442
+ const signature = nacl.sign.detached(message, keypair.secretKey);
7463
7443
  return this.createInstructionWithPublicKey({
7464
7444
  publicKey,
7465
7445
  message,
@@ -7467,13 +7447,12 @@ class Ed25519Program {
7467
7447
  instructionIndex
7468
7448
  });
7469
7449
  } catch (error) {
7470
- throw new Error("Error creating instruction; ".concat(error));
7450
+ throw new Error(`Error creating instruction; ${error}`);
7471
7451
  }
7472
7452
  }
7473
7453
 
7474
7454
  }
7475
-
7476
- _defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7455
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7477
7456
 
7478
7457
  /**
7479
7458
  * Address of the stake config account which configures the rate
@@ -7496,10 +7475,8 @@ class Authorized {
7496
7475
  * @param withdrawer the withdraw authority
7497
7476
  */
7498
7477
  constructor(staker, withdrawer) {
7499
- _defineProperty(this, "staker", void 0);
7500
-
7501
- _defineProperty(this, "withdrawer", void 0);
7502
-
7478
+ this.staker = void 0;
7479
+ this.withdrawer = void 0;
7503
7480
  this.staker = staker;
7504
7481
  this.withdrawer = withdrawer;
7505
7482
  }
@@ -7520,12 +7497,9 @@ class Lockup {
7520
7497
  * Create a new Lockup object
7521
7498
  */
7522
7499
  constructor(unixTimestamp, epoch, custodian) {
7523
- _defineProperty(this, "unixTimestamp", void 0);
7524
-
7525
- _defineProperty(this, "epoch", void 0);
7526
-
7527
- _defineProperty(this, "custodian", void 0);
7528
-
7500
+ this.unixTimestamp = void 0;
7501
+ this.epoch = void 0;
7502
+ this.custodian = void 0;
7529
7503
  this.unixTimestamp = unixTimestamp;
7530
7504
  this.epoch = epoch;
7531
7505
  this.custodian = custodian;
@@ -7540,7 +7514,7 @@ class Lockup {
7540
7514
  * Create stake account transaction params
7541
7515
  */
7542
7516
 
7543
- _defineProperty(Lockup, "default", new Lockup(0, 0, PublicKey.default));
7517
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
7544
7518
 
7545
7519
  /**
7546
7520
  * Stake Instruction class
@@ -7753,7 +7727,7 @@ class StakeInstruction {
7753
7727
 
7754
7728
  static checkKeyLength(keys, expectedLength) {
7755
7729
  if (keys.length < expectedLength) {
7756
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
7730
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
7757
7731
  }
7758
7732
  }
7759
7733
 
@@ -8228,10 +8202,8 @@ class StakeProgram {
8228
8202
  }
8229
8203
 
8230
8204
  }
8231
-
8232
- _defineProperty(StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
8233
-
8234
- _defineProperty(StakeProgram, "space", 200);
8205
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8206
+ StakeProgram.space = 200;
8235
8207
 
8236
8208
  const {
8237
8209
  publicKeyCreate,
@@ -8261,12 +8233,12 @@ class Secp256k1Program {
8261
8233
  * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
8262
8234
  */
8263
8235
  static publicKeyToEthAddress(publicKey) {
8264
- assert(publicKey.length === PUBLIC_KEY_BYTES, "Public key must be ".concat(PUBLIC_KEY_BYTES, " bytes but received ").concat(publicKey.length, " bytes"));
8236
+ assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8265
8237
 
8266
8238
  try {
8267
- return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8239
+ return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8268
8240
  } catch (error) {
8269
- throw new Error("Error constructing Ethereum address: ".concat(error));
8241
+ throw new Error(`Error constructing Ethereum address: ${error}`);
8270
8242
  }
8271
8243
  }
8272
8244
  /**
@@ -8317,7 +8289,7 @@ class Secp256k1Program {
8317
8289
  ethAddress = rawAddress;
8318
8290
  }
8319
8291
 
8320
- assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
8292
+ assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
8321
8293
  const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
8322
8294
  const ethAddressOffset = dataStart;
8323
8295
  const signatureOffset = dataStart + ethAddress.length;
@@ -8356,13 +8328,13 @@ class Secp256k1Program {
8356
8328
  message,
8357
8329
  instructionIndex
8358
8330
  } = params;
8359
- assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
8331
+ assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
8360
8332
 
8361
8333
  try {
8362
8334
  const privateKey = toBuffer(pkey);
8363
8335
  const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
8364
8336
 
8365
- const messageHash = Buffer.from(keccak_256.update(toBuffer(message)).digest());
8337
+ const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
8366
8338
  const {
8367
8339
  signature,
8368
8340
  recid: recoveryId
@@ -8375,13 +8347,12 @@ class Secp256k1Program {
8375
8347
  instructionIndex
8376
8348
  });
8377
8349
  } catch (error) {
8378
- throw new Error("Error creating instruction; ".concat(error));
8350
+ throw new Error(`Error creating instruction; ${error}`);
8379
8351
  }
8380
8352
  }
8381
8353
 
8382
8354
  }
8383
-
8384
- _defineProperty(Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8355
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
8385
8356
 
8386
8357
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
8387
8358
  /**
@@ -8414,10 +8385,8 @@ class ValidatorInfo {
8414
8385
  * @param info validator information
8415
8386
  */
8416
8387
  constructor(key, info) {
8417
- _defineProperty(this, "key", void 0);
8418
-
8419
- _defineProperty(this, "info", void 0);
8420
-
8388
+ this.key = void 0;
8389
+ this.info = void 0;
8421
8390
  this.key = key;
8422
8391
  this.info = info;
8423
8392
  }
@@ -8469,9 +8438,10 @@ const VOTE_PROGRAM_ID = new PublicKey('Vote1111111111111111111111111111111111111
8469
8438
  *
8470
8439
  * @internal
8471
8440
  */
8472
- const VoteAccountLayout = BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedVoterPubkey'), publicKey('authorizedWithdrawerPubkey'), BufferLayout.u8('commission'), BufferLayout.nu64(), // votes.length
8473
- BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('slot'), BufferLayout.u32('confirmationCount')]), BufferLayout.offset(BufferLayout.u32(), -8), 'votes'), BufferLayout.u8('rootSlotValid'), BufferLayout.nu64('rootSlot'), BufferLayout.nu64('epoch'), BufferLayout.nu64('credits'), BufferLayout.nu64('lastEpochCredits'), BufferLayout.nu64(), // epochCredits.length
8474
- BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('epoch'), BufferLayout.nu64('credits'), BufferLayout.nu64('prevCredits')]), BufferLayout.offset(BufferLayout.u32(), -8), 'epochCredits')]);
8441
+ const VoteAccountLayout = BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedWithdrawer'), BufferLayout.u8('commission'), BufferLayout.nu64(), // votes.length
8442
+ BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('slot'), BufferLayout.u32('confirmationCount')]), BufferLayout.offset(BufferLayout.u32(), -8), 'votes'), BufferLayout.u8('rootSlotValid'), BufferLayout.nu64('rootSlot'), BufferLayout.nu64(), // authorizedVoters.length
8443
+ BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('epoch'), publicKey('authorizedVoter')]), BufferLayout.offset(BufferLayout.u32(), -8), 'authorizedVoters'), BufferLayout.struct([BufferLayout.seq(BufferLayout.struct([publicKey('authorizedPubkey'), BufferLayout.nu64('epochOfLastAuthorizedSwitch'), BufferLayout.nu64('targetEpoch')]), 32, 'buf'), BufferLayout.nu64('idx'), BufferLayout.u8('isEmpty')], 'priorVoters'), BufferLayout.nu64(), // epochCredits.length
8444
+ BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('epoch'), BufferLayout.nu64('credits'), BufferLayout.nu64('prevCredits')]), BufferLayout.offset(BufferLayout.u32(), -8), 'epochCredits'), BufferLayout.struct([BufferLayout.nu64('slot'), BufferLayout.nu64('timestamp')], 'lastTimestamp')]);
8475
8445
 
8476
8446
  /**
8477
8447
  * VoteAccount class
@@ -8481,36 +8451,24 @@ class VoteAccount {
8481
8451
  * @internal
8482
8452
  */
8483
8453
  constructor(args) {
8484
- _defineProperty(this, "nodePubkey", void 0);
8485
-
8486
- _defineProperty(this, "authorizedVoterPubkey", void 0);
8487
-
8488
- _defineProperty(this, "authorizedWithdrawerPubkey", void 0);
8489
-
8490
- _defineProperty(this, "commission", void 0);
8491
-
8492
- _defineProperty(this, "votes", void 0);
8493
-
8494
- _defineProperty(this, "rootSlot", void 0);
8495
-
8496
- _defineProperty(this, "epoch", void 0);
8497
-
8498
- _defineProperty(this, "credits", void 0);
8499
-
8500
- _defineProperty(this, "lastEpochCredits", void 0);
8501
-
8502
- _defineProperty(this, "epochCredits", void 0);
8503
-
8454
+ this.nodePubkey = void 0;
8455
+ this.authorizedWithdrawer = void 0;
8456
+ this.commission = void 0;
8457
+ this.rootSlot = void 0;
8458
+ this.votes = void 0;
8459
+ this.authorizedVoters = void 0;
8460
+ this.priorVoters = void 0;
8461
+ this.epochCredits = void 0;
8462
+ this.lastTimestamp = void 0;
8504
8463
  this.nodePubkey = args.nodePubkey;
8505
- this.authorizedVoterPubkey = args.authorizedVoterPubkey;
8506
- this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
8464
+ this.authorizedWithdrawer = args.authorizedWithdrawer;
8507
8465
  this.commission = args.commission;
8508
- this.votes = args.votes;
8509
8466
  this.rootSlot = args.rootSlot;
8510
- this.epoch = args.epoch;
8511
- this.credits = args.credits;
8512
- this.lastEpochCredits = args.lastEpochCredits;
8467
+ this.votes = args.votes;
8468
+ this.authorizedVoters = args.authorizedVoters;
8469
+ this.priorVoters = args.priorVoters;
8513
8470
  this.epochCredits = args.epochCredits;
8471
+ this.lastTimestamp = args.lastTimestamp;
8514
8472
  }
8515
8473
  /**
8516
8474
  * Deserialize VoteAccount from the account data.
@@ -8521,7 +8479,8 @@ class VoteAccount {
8521
8479
 
8522
8480
 
8523
8481
  static fromAccountData(buffer) {
8524
- const va = VoteAccountLayout.decode(toBuffer(buffer), 0);
8482
+ const versionOffset = 4;
8483
+ const va = VoteAccountLayout.decode(toBuffer(buffer), versionOffset);
8525
8484
  let rootSlot = va.rootSlot;
8526
8485
 
8527
8486
  if (!va.rootSlotValid) {
@@ -8530,20 +8489,53 @@ class VoteAccount {
8530
8489
 
8531
8490
  return new VoteAccount({
8532
8491
  nodePubkey: new PublicKey(va.nodePubkey),
8533
- authorizedVoterPubkey: new PublicKey(va.authorizedVoterPubkey),
8534
- authorizedWithdrawerPubkey: new PublicKey(va.authorizedWithdrawerPubkey),
8492
+ authorizedWithdrawer: new PublicKey(va.authorizedWithdrawer),
8535
8493
  commission: va.commission,
8536
8494
  votes: va.votes,
8537
8495
  rootSlot,
8538
- epoch: va.epoch,
8539
- credits: va.credits,
8540
- lastEpochCredits: va.lastEpochCredits,
8541
- epochCredits: va.epochCredits
8496
+ authorizedVoters: va.authorizedVoters.map(parseAuthorizedVoter),
8497
+ priorVoters: getPriorVoters(va.priorVoters),
8498
+ epochCredits: va.epochCredits,
8499
+ lastTimestamp: va.lastTimestamp
8542
8500
  });
8543
8501
  }
8544
8502
 
8545
8503
  }
8546
8504
 
8505
+ function parseAuthorizedVoter({
8506
+ epoch,
8507
+ authorizedVoter
8508
+ }) {
8509
+ return {
8510
+ epoch,
8511
+ authorizedVoter: new PublicKey(authorizedVoter)
8512
+ };
8513
+ }
8514
+
8515
+ function parsePriorVoters({
8516
+ authorizedPubkey,
8517
+ epochOfLastAuthorizedSwitch,
8518
+ targetEpoch
8519
+ }) {
8520
+ return {
8521
+ authorizedPubkey: new PublicKey(authorizedPubkey),
8522
+ epochOfLastAuthorizedSwitch,
8523
+ targetEpoch
8524
+ };
8525
+ }
8526
+
8527
+ function getPriorVoters({
8528
+ buf,
8529
+ idx,
8530
+ isEmpty
8531
+ }) {
8532
+ if (isEmpty) {
8533
+ return [];
8534
+ }
8535
+
8536
+ return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx)];
8537
+ }
8538
+
8547
8539
  /**
8548
8540
  * Send and confirm a raw transaction
8549
8541
  *
@@ -8563,7 +8555,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
8563
8555
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
8564
8556
 
8565
8557
  if (status.err) {
8566
- throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
8558
+ throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
8567
8559
  }
8568
8560
 
8569
8561
  return signature;
@@ -8595,7 +8587,7 @@ function clusterApiUrl(cluster, tls) {
8595
8587
  const url = endpoint[key][cluster];
8596
8588
 
8597
8589
  if (!url) {
8598
- throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
8590
+ throw new Error(`Unknown ${key} cluster: ${cluster}`);
8599
8591
  }
8600
8592
 
8601
8593
  return url;
@@ -8607,5 +8599,5 @@ function clusterApiUrl(cluster, tls) {
8607
8599
 
8608
8600
  const LAMPORTS_PER_SOL = 1000000000;
8609
8601
 
8610
- export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
8602
+ export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
8611
8603
  //# sourceMappingURL=index.esm.js.map