@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.
@@ -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';
@@ -10,7 +8,7 @@ import { coerce, instance, string, tuple, literal, unknown, union, type, optiona
10
8
  import { Client } from 'rpc-websockets';
11
9
  import RpcClient from 'jayson/lib/client/browser';
12
10
  import secp256k1 from 'secp256k1';
13
- import { keccak_256 } from 'js-sha3';
11
+ import sha3 from 'js-sha3';
14
12
 
15
13
  const toBuffer = arr => {
16
14
  if (Buffer.isBuffer(arr)) {
@@ -22,884 +20,475 @@ const toBuffer = arr => {
22
20
  }
23
21
  };
24
22
 
25
- const version$2 = "logger/5.5.0";
23
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
26
24
 
27
- let _permanentCensorErrors = false;
28
- let _censorErrors = false;
29
- const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
30
- let _logLevel = LogLevels["default"];
31
- let _globalLogger = null;
32
- function _checkNormalize() {
33
- try {
34
- const missing = [];
35
- // Make sure all forms of normalization are supported
36
- ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
37
- try {
38
- if ("test".normalize(form) !== "test") {
39
- throw new Error("bad normalize");
40
- }
41
- ;
42
- }
43
- catch (error) {
44
- missing.push(form);
45
- }
46
- });
47
- if (missing.length) {
48
- throw new Error("missing " + missing.join(", "));
49
- }
50
- if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
51
- throw new Error("broken implementation");
25
+ function getDefaultExportFromCjs (x) {
26
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
27
+ }
28
+
29
+ var hash$1 = {};
30
+
31
+ var utils$9 = {};
32
+
33
+ var minimalisticAssert = assert$6;
34
+
35
+ function assert$6(val, msg) {
36
+ if (!val)
37
+ throw new Error(msg || 'Assertion failed');
38
+ }
39
+
40
+ assert$6.equal = function assertEqual(l, r, msg) {
41
+ if (l != r)
42
+ throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
43
+ };
44
+
45
+ var inherits_browser = {exports: {}};
46
+
47
+ if (typeof Object.create === 'function') {
48
+ // implementation from standard node.js 'util' module
49
+ inherits_browser.exports = function inherits(ctor, superCtor) {
50
+ ctor.super_ = superCtor;
51
+ ctor.prototype = Object.create(superCtor.prototype, {
52
+ constructor: {
53
+ value: ctor,
54
+ enumerable: false,
55
+ writable: true,
56
+ configurable: true
57
+ }
58
+ });
59
+ };
60
+ } else {
61
+ // old school shim for old browsers
62
+ inherits_browser.exports = function inherits(ctor, superCtor) {
63
+ ctor.super_ = superCtor;
64
+ var TempCtor = function () {};
65
+ TempCtor.prototype = superCtor.prototype;
66
+ ctor.prototype = new TempCtor();
67
+ ctor.prototype.constructor = ctor;
68
+ };
69
+ }
70
+
71
+ var assert$5 = minimalisticAssert;
72
+ var inherits = inherits_browser.exports;
73
+
74
+ utils$9.inherits = inherits;
75
+
76
+ function isSurrogatePair(msg, i) {
77
+ if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
78
+ return false;
79
+ }
80
+ if (i < 0 || i + 1 >= msg.length) {
81
+ return false;
82
+ }
83
+ return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
84
+ }
85
+
86
+ function toArray(msg, enc) {
87
+ if (Array.isArray(msg))
88
+ return msg.slice();
89
+ if (!msg)
90
+ return [];
91
+ var res = [];
92
+ if (typeof msg === 'string') {
93
+ if (!enc) {
94
+ // Inspired by stringToUtf8ByteArray() in closure-library by Google
95
+ // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
96
+ // Apache License 2.0
97
+ // https://github.com/google/closure-library/blob/master/LICENSE
98
+ var p = 0;
99
+ for (var i = 0; i < msg.length; i++) {
100
+ var c = msg.charCodeAt(i);
101
+ if (c < 128) {
102
+ res[p++] = c;
103
+ } else if (c < 2048) {
104
+ res[p++] = (c >> 6) | 192;
105
+ res[p++] = (c & 63) | 128;
106
+ } else if (isSurrogatePair(msg, i)) {
107
+ c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
108
+ res[p++] = (c >> 18) | 240;
109
+ res[p++] = ((c >> 12) & 63) | 128;
110
+ res[p++] = ((c >> 6) & 63) | 128;
111
+ res[p++] = (c & 63) | 128;
112
+ } else {
113
+ res[p++] = (c >> 12) | 224;
114
+ res[p++] = ((c >> 6) & 63) | 128;
115
+ res[p++] = (c & 63) | 128;
52
116
  }
117
+ }
118
+ } else if (enc === 'hex') {
119
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
120
+ if (msg.length % 2 !== 0)
121
+ msg = '0' + msg;
122
+ for (i = 0; i < msg.length; i += 2)
123
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
53
124
  }
54
- catch (error) {
55
- return error.message;
125
+ } else {
126
+ for (i = 0; i < msg.length; i++)
127
+ res[i] = msg[i] | 0;
128
+ }
129
+ return res;
130
+ }
131
+ utils$9.toArray = toArray;
132
+
133
+ function toHex(msg) {
134
+ var res = '';
135
+ for (var i = 0; i < msg.length; i++)
136
+ res += zero2(msg[i].toString(16));
137
+ return res;
138
+ }
139
+ utils$9.toHex = toHex;
140
+
141
+ function htonl(w) {
142
+ var res = (w >>> 24) |
143
+ ((w >>> 8) & 0xff00) |
144
+ ((w << 8) & 0xff0000) |
145
+ ((w & 0xff) << 24);
146
+ return res >>> 0;
147
+ }
148
+ utils$9.htonl = htonl;
149
+
150
+ function toHex32(msg, endian) {
151
+ var res = '';
152
+ for (var i = 0; i < msg.length; i++) {
153
+ var w = msg[i];
154
+ if (endian === 'little')
155
+ w = htonl(w);
156
+ res += zero8(w.toString(16));
157
+ }
158
+ return res;
159
+ }
160
+ utils$9.toHex32 = toHex32;
161
+
162
+ function zero2(word) {
163
+ if (word.length === 1)
164
+ return '0' + word;
165
+ else
166
+ return word;
167
+ }
168
+ utils$9.zero2 = zero2;
169
+
170
+ function zero8(word) {
171
+ if (word.length === 7)
172
+ return '0' + word;
173
+ else if (word.length === 6)
174
+ return '00' + word;
175
+ else if (word.length === 5)
176
+ return '000' + word;
177
+ else if (word.length === 4)
178
+ return '0000' + word;
179
+ else if (word.length === 3)
180
+ return '00000' + word;
181
+ else if (word.length === 2)
182
+ return '000000' + word;
183
+ else if (word.length === 1)
184
+ return '0000000' + word;
185
+ else
186
+ return word;
187
+ }
188
+ utils$9.zero8 = zero8;
189
+
190
+ function join32(msg, start, end, endian) {
191
+ var len = end - start;
192
+ assert$5(len % 4 === 0);
193
+ var res = new Array(len / 4);
194
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
195
+ var w;
196
+ if (endian === 'big')
197
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
198
+ else
199
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
200
+ res[i] = w >>> 0;
201
+ }
202
+ return res;
203
+ }
204
+ utils$9.join32 = join32;
205
+
206
+ function split32(msg, endian) {
207
+ var res = new Array(msg.length * 4);
208
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
209
+ var m = msg[i];
210
+ if (endian === 'big') {
211
+ res[k] = m >>> 24;
212
+ res[k + 1] = (m >>> 16) & 0xff;
213
+ res[k + 2] = (m >>> 8) & 0xff;
214
+ res[k + 3] = m & 0xff;
215
+ } else {
216
+ res[k + 3] = m >>> 24;
217
+ res[k + 2] = (m >>> 16) & 0xff;
218
+ res[k + 1] = (m >>> 8) & 0xff;
219
+ res[k] = m & 0xff;
56
220
  }
57
- return null;
221
+ }
222
+ return res;
58
223
  }
59
- const _normalizeError = _checkNormalize();
60
- var LogLevel;
61
- (function (LogLevel) {
62
- LogLevel["DEBUG"] = "DEBUG";
63
- LogLevel["INFO"] = "INFO";
64
- LogLevel["WARNING"] = "WARNING";
65
- LogLevel["ERROR"] = "ERROR";
66
- LogLevel["OFF"] = "OFF";
67
- })(LogLevel || (LogLevel = {}));
68
- var ErrorCode;
69
- (function (ErrorCode) {
70
- ///////////////////
71
- // Generic Errors
72
- // Unknown Error
73
- ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
74
- // Not Implemented
75
- ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
76
- // Unsupported Operation
77
- // - operation
78
- ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
79
- // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
80
- // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
81
- ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
82
- // Some sort of bad response from the server
83
- ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
84
- // Timeout
85
- ErrorCode["TIMEOUT"] = "TIMEOUT";
86
- ///////////////////
87
- // Operational Errors
88
- // Buffer Overrun
89
- ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
90
- // Numeric Fault
91
- // - operation: the operation being executed
92
- // - fault: the reason this faulted
93
- ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
94
- ///////////////////
95
- // Argument Errors
96
- // Missing new operator to an object
97
- // - name: The name of the class
98
- ErrorCode["MISSING_NEW"] = "MISSING_NEW";
99
- // Invalid argument (e.g. value is incompatible with type) to a function:
100
- // - argument: The argument name that was invalid
101
- // - value: The value of the argument
102
- ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
103
- // Missing argument to a function:
104
- // - count: The number of arguments received
105
- // - expectedCount: The number of arguments expected
106
- ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
107
- // Too many arguments
108
- // - count: The number of arguments received
109
- // - expectedCount: The number of arguments expected
110
- ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
111
- ///////////////////
112
- // Blockchain Errors
113
- // Call exception
114
- // - transaction: the transaction
115
- // - address?: the contract address
116
- // - args?: The arguments passed into the function
117
- // - method?: The Solidity method signature
118
- // - errorSignature?: The EIP848 error signature
119
- // - errorArgs?: The EIP848 error parameters
120
- // - reason: The reason (only for EIP848 "Error(string)")
121
- ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
122
- // Insufficient funds (< value + gasLimit * gasPrice)
123
- // - transaction: the transaction attempted
124
- ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
125
- // Nonce has already been used
126
- // - transaction: the transaction attempted
127
- ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
128
- // The replacement fee for the transaction is too low
129
- // - transaction: the transaction attempted
130
- ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
131
- // The gas limit could not be estimated
132
- // - transaction: the transaction passed to estimateGas
133
- ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
134
- // The transaction was replaced by one with a higher gas price
135
- // - reason: "cancelled", "replaced" or "repriced"
136
- // - cancelled: true if reason == "cancelled" or reason == "replaced")
137
- // - hash: original transaction hash
138
- // - replacement: the full TransactionsResponse for the replacement
139
- // - receipt: the receipt of the replacement
140
- ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
141
- })(ErrorCode || (ErrorCode = {}));
142
- const HEX = "0123456789abcdef";
143
- class Logger {
144
- constructor(version) {
145
- Object.defineProperty(this, "version", {
146
- enumerable: true,
147
- value: version,
148
- writable: false
149
- });
150
- }
151
- _log(logLevel, args) {
152
- const level = logLevel.toLowerCase();
153
- if (LogLevels[level] == null) {
154
- this.throwArgumentError("invalid log level name", "logLevel", logLevel);
155
- }
156
- if (_logLevel > LogLevels[level]) {
157
- return;
158
- }
159
- console.log.apply(console, args);
160
- }
161
- debug(...args) {
162
- this._log(Logger.levels.DEBUG, args);
163
- }
164
- info(...args) {
165
- this._log(Logger.levels.INFO, args);
166
- }
167
- warn(...args) {
168
- this._log(Logger.levels.WARNING, args);
169
- }
170
- makeError(message, code, params) {
171
- // Errors are being censored
172
- if (_censorErrors) {
173
- return this.makeError("censored error", code, {});
174
- }
175
- if (!code) {
176
- code = Logger.errors.UNKNOWN_ERROR;
177
- }
178
- if (!params) {
179
- params = {};
180
- }
181
- const messageDetails = [];
182
- Object.keys(params).forEach((key) => {
183
- const value = params[key];
184
- try {
185
- if (value instanceof Uint8Array) {
186
- let hex = "";
187
- for (let i = 0; i < value.length; i++) {
188
- hex += HEX[value[i] >> 4];
189
- hex += HEX[value[i] & 0x0f];
190
- }
191
- messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
192
- }
193
- else {
194
- messageDetails.push(key + "=" + JSON.stringify(value));
195
- }
196
- }
197
- catch (error) {
198
- messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
199
- }
200
- });
201
- messageDetails.push(`code=${code}`);
202
- messageDetails.push(`version=${this.version}`);
203
- const reason = message;
204
- if (messageDetails.length) {
205
- message += " (" + messageDetails.join(", ") + ")";
206
- }
207
- // @TODO: Any??
208
- const error = new Error(message);
209
- error.reason = reason;
210
- error.code = code;
211
- Object.keys(params).forEach(function (key) {
212
- error[key] = params[key];
213
- });
214
- return error;
215
- }
216
- throwError(message, code, params) {
217
- throw this.makeError(message, code, params);
218
- }
219
- throwArgumentError(message, name, value) {
220
- return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
221
- argument: name,
222
- value: value
223
- });
224
- }
225
- assert(condition, message, code, params) {
226
- if (!!condition) {
227
- return;
228
- }
229
- this.throwError(message, code, params);
230
- }
231
- assertArgument(condition, message, name, value) {
232
- if (!!condition) {
233
- return;
234
- }
235
- this.throwArgumentError(message, name, value);
236
- }
237
- checkNormalize(message) {
238
- if (_normalizeError) {
239
- this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
240
- operation: "String.prototype.normalize", form: _normalizeError
241
- });
242
- }
243
- }
244
- checkSafeUint53(value, message) {
245
- if (typeof (value) !== "number") {
246
- return;
247
- }
248
- if (message == null) {
249
- message = "value not safe";
250
- }
251
- if (value < 0 || value >= 0x1fffffffffffff) {
252
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
253
- operation: "checkSafeInteger",
254
- fault: "out-of-safe-range",
255
- value: value
256
- });
257
- }
258
- if (value % 1) {
259
- this.throwError(message, Logger.errors.NUMERIC_FAULT, {
260
- operation: "checkSafeInteger",
261
- fault: "non-integer",
262
- value: value
263
- });
264
- }
265
- }
266
- checkArgumentCount(count, expectedCount, message) {
267
- if (message) {
268
- message = ": " + message;
269
- }
270
- else {
271
- message = "";
272
- }
273
- if (count < expectedCount) {
274
- this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
275
- count: count,
276
- expectedCount: expectedCount
277
- });
278
- }
279
- if (count > expectedCount) {
280
- this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
281
- count: count,
282
- expectedCount: expectedCount
283
- });
284
- }
285
- }
286
- checkNew(target, kind) {
287
- if (target === Object || target == null) {
288
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
289
- }
290
- }
291
- checkAbstract(target, kind) {
292
- if (target === kind) {
293
- this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
294
- }
295
- else if (target === Object || target == null) {
296
- this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
297
- }
298
- }
299
- static globalLogger() {
300
- if (!_globalLogger) {
301
- _globalLogger = new Logger(version$2);
302
- }
303
- return _globalLogger;
304
- }
305
- static setCensorship(censorship, permanent) {
306
- if (!censorship && permanent) {
307
- this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
308
- operation: "setCensorship"
309
- });
310
- }
311
- if (_permanentCensorErrors) {
312
- if (!censorship) {
313
- return;
314
- }
315
- this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
316
- operation: "setCensorship"
317
- });
318
- }
319
- _censorErrors = !!censorship;
320
- _permanentCensorErrors = !!permanent;
321
- }
322
- static setLogLevel(logLevel) {
323
- const level = LogLevels[logLevel.toLowerCase()];
324
- if (level == null) {
325
- Logger.globalLogger().warn("invalid log level - " + logLevel);
326
- return;
327
- }
328
- _logLevel = level;
329
- }
330
- static from(version) {
331
- return new Logger(version);
332
- }
224
+ utils$9.split32 = split32;
225
+
226
+ function rotr32$1(w, b) {
227
+ return (w >>> b) | (w << (32 - b));
333
228
  }
334
- Logger.errors = ErrorCode;
335
- Logger.levels = LogLevel;
229
+ utils$9.rotr32 = rotr32$1;
336
230
 
337
- const version$1 = "bytes/5.5.0";
231
+ function rotl32$2(w, b) {
232
+ return (w << b) | (w >>> (32 - b));
233
+ }
234
+ utils$9.rotl32 = rotl32$2;
338
235
 
339
- const logger = new Logger(version$1);
340
- ///////////////////////////////
341
- function isHexable(value) {
342
- return !!(value.toHexString);
236
+ function sum32$3(a, b) {
237
+ return (a + b) >>> 0;
343
238
  }
344
- function addSlice(array) {
345
- if (array.slice) {
346
- return array;
347
- }
348
- array.slice = function () {
349
- const args = Array.prototype.slice.call(arguments);
350
- return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
351
- };
352
- return array;
239
+ utils$9.sum32 = sum32$3;
240
+
241
+ function sum32_3$1(a, b, c) {
242
+ return (a + b + c) >>> 0;
353
243
  }
354
- function isInteger(value) {
355
- return (typeof (value) === "number" && value == value && (value % 1) === 0);
244
+ utils$9.sum32_3 = sum32_3$1;
245
+
246
+ function sum32_4$2(a, b, c, d) {
247
+ return (a + b + c + d) >>> 0;
356
248
  }
357
- function isBytes(value) {
358
- if (value == null) {
359
- return false;
360
- }
361
- if (value.constructor === Uint8Array) {
362
- return true;
363
- }
364
- if (typeof (value) === "string") {
365
- return false;
366
- }
367
- if (!isInteger(value.length) || value.length < 0) {
368
- return false;
369
- }
370
- for (let i = 0; i < value.length; i++) {
371
- const v = value[i];
372
- if (!isInteger(v) || v < 0 || v >= 256) {
373
- return false;
374
- }
375
- }
376
- return true;
249
+ utils$9.sum32_4 = sum32_4$2;
250
+
251
+ function sum32_5$2(a, b, c, d, e) {
252
+ return (a + b + c + d + e) >>> 0;
377
253
  }
378
- function arrayify(value, options) {
379
- if (!options) {
380
- options = {};
381
- }
382
- if (typeof (value) === "number") {
383
- logger.checkSafeUint53(value, "invalid arrayify value");
384
- const result = [];
385
- while (value) {
386
- result.unshift(value & 0xff);
387
- value = parseInt(String(value / 256));
388
- }
389
- if (result.length === 0) {
390
- result.push(0);
391
- }
392
- return addSlice(new Uint8Array(result));
393
- }
394
- if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
395
- value = "0x" + value;
396
- }
397
- if (isHexable(value)) {
398
- value = value.toHexString();
399
- }
400
- if (isHexString(value)) {
401
- let hex = value.substring(2);
402
- if (hex.length % 2) {
403
- if (options.hexPad === "left") {
404
- hex = "0x0" + hex.substring(2);
405
- }
406
- else if (options.hexPad === "right") {
407
- hex += "0";
408
- }
409
- else {
410
- logger.throwArgumentError("hex data is odd-length", "value", value);
411
- }
412
- }
413
- const result = [];
414
- for (let i = 0; i < hex.length; i += 2) {
415
- result.push(parseInt(hex.substring(i, i + 2), 16));
416
- }
417
- return addSlice(new Uint8Array(result));
418
- }
419
- if (isBytes(value)) {
420
- return addSlice(new Uint8Array(value));
421
- }
422
- return logger.throwArgumentError("invalid arrayify value", "value", value);
254
+ utils$9.sum32_5 = sum32_5$2;
255
+
256
+ function sum64$1(buf, pos, ah, al) {
257
+ var bh = buf[pos];
258
+ var bl = buf[pos + 1];
259
+
260
+ var lo = (al + bl) >>> 0;
261
+ var hi = (lo < al ? 1 : 0) + ah + bh;
262
+ buf[pos] = hi >>> 0;
263
+ buf[pos + 1] = lo;
423
264
  }
424
- function isHexString(value, length) {
425
- if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
426
- return false;
427
- }
428
- if (length && value.length !== 2 + 2 * length) {
429
- return false;
430
- }
431
- return true;
265
+ utils$9.sum64 = sum64$1;
266
+
267
+ function sum64_hi$1(ah, al, bh, bl) {
268
+ var lo = (al + bl) >>> 0;
269
+ var hi = (lo < al ? 1 : 0) + ah + bh;
270
+ return hi >>> 0;
432
271
  }
272
+ utils$9.sum64_hi = sum64_hi$1;
433
273
 
434
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
274
+ function sum64_lo$1(ah, al, bh, bl) {
275
+ var lo = al + bl;
276
+ return lo >>> 0;
277
+ }
278
+ utils$9.sum64_lo = sum64_lo$1;
435
279
 
436
- function getDefaultExportFromCjs (x) {
437
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
280
+ function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
281
+ var carry = 0;
282
+ var lo = al;
283
+ lo = (lo + bl) >>> 0;
284
+ carry += lo < al ? 1 : 0;
285
+ lo = (lo + cl) >>> 0;
286
+ carry += lo < cl ? 1 : 0;
287
+ lo = (lo + dl) >>> 0;
288
+ carry += lo < dl ? 1 : 0;
289
+
290
+ var hi = ah + bh + ch + dh + carry;
291
+ return hi >>> 0;
438
292
  }
293
+ utils$9.sum64_4_hi = sum64_4_hi$1;
439
294
 
440
- var hash$1 = {};
295
+ function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
296
+ var lo = al + bl + cl + dl;
297
+ return lo >>> 0;
298
+ }
299
+ utils$9.sum64_4_lo = sum64_4_lo$1;
441
300
 
442
- var utils$9 = {};
301
+ function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
302
+ var carry = 0;
303
+ var lo = al;
304
+ lo = (lo + bl) >>> 0;
305
+ carry += lo < al ? 1 : 0;
306
+ lo = (lo + cl) >>> 0;
307
+ carry += lo < cl ? 1 : 0;
308
+ lo = (lo + dl) >>> 0;
309
+ carry += lo < dl ? 1 : 0;
310
+ lo = (lo + el) >>> 0;
311
+ carry += lo < el ? 1 : 0;
443
312
 
444
- var minimalisticAssert = assert$6;
313
+ var hi = ah + bh + ch + dh + eh + carry;
314
+ return hi >>> 0;
315
+ }
316
+ utils$9.sum64_5_hi = sum64_5_hi$1;
445
317
 
446
- function assert$6(val, msg) {
447
- if (!val)
448
- throw new Error(msg || 'Assertion failed');
318
+ function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
319
+ var lo = al + bl + cl + dl + el;
320
+
321
+ return lo >>> 0;
449
322
  }
323
+ utils$9.sum64_5_lo = sum64_5_lo$1;
450
324
 
451
- assert$6.equal = function assertEqual(l, r, msg) {
452
- if (l != r)
453
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
454
- };
325
+ function rotr64_hi$1(ah, al, num) {
326
+ var r = (al << (32 - num)) | (ah >>> num);
327
+ return r >>> 0;
328
+ }
329
+ utils$9.rotr64_hi = rotr64_hi$1;
455
330
 
456
- var inherits_browser = {exports: {}};
331
+ function rotr64_lo$1(ah, al, num) {
332
+ var r = (ah << (32 - num)) | (al >>> num);
333
+ return r >>> 0;
334
+ }
335
+ utils$9.rotr64_lo = rotr64_lo$1;
457
336
 
458
- if (typeof Object.create === 'function') {
459
- // implementation from standard node.js 'util' module
460
- inherits_browser.exports = function inherits(ctor, superCtor) {
461
- ctor.super_ = superCtor;
462
- ctor.prototype = Object.create(superCtor.prototype, {
463
- constructor: {
464
- value: ctor,
465
- enumerable: false,
466
- writable: true,
467
- configurable: true
468
- }
469
- });
470
- };
471
- } else {
472
- // old school shim for old browsers
473
- inherits_browser.exports = function inherits(ctor, superCtor) {
474
- ctor.super_ = superCtor;
475
- var TempCtor = function () {};
476
- TempCtor.prototype = superCtor.prototype;
477
- ctor.prototype = new TempCtor();
478
- ctor.prototype.constructor = ctor;
479
- };
337
+ function shr64_hi$1(ah, al, num) {
338
+ return ah >>> num;
480
339
  }
340
+ utils$9.shr64_hi = shr64_hi$1;
481
341
 
482
- var assert$5 = minimalisticAssert;
483
- var inherits = inherits_browser.exports;
342
+ function shr64_lo$1(ah, al, num) {
343
+ var r = (ah << (32 - num)) | (al >>> num);
344
+ return r >>> 0;
345
+ }
346
+ utils$9.shr64_lo = shr64_lo$1;
484
347
 
485
- utils$9.inherits = inherits;
348
+ var common$5 = {};
486
349
 
487
- function isSurrogatePair(msg, i) {
488
- if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
489
- return false;
490
- }
491
- if (i < 0 || i + 1 >= msg.length) {
492
- return false;
493
- }
494
- return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
350
+ var utils$8 = utils$9;
351
+ var assert$4 = minimalisticAssert;
352
+
353
+ function BlockHash$4() {
354
+ this.pending = null;
355
+ this.pendingTotal = 0;
356
+ this.blockSize = this.constructor.blockSize;
357
+ this.outSize = this.constructor.outSize;
358
+ this.hmacStrength = this.constructor.hmacStrength;
359
+ this.padLength = this.constructor.padLength / 8;
360
+ this.endian = 'big';
361
+
362
+ this._delta8 = this.blockSize / 8;
363
+ this._delta32 = this.blockSize / 32;
495
364
  }
365
+ common$5.BlockHash = BlockHash$4;
496
366
 
497
- function toArray(msg, enc) {
498
- if (Array.isArray(msg))
499
- return msg.slice();
500
- if (!msg)
501
- return [];
502
- var res = [];
503
- if (typeof msg === 'string') {
504
- if (!enc) {
505
- // Inspired by stringToUtf8ByteArray() in closure-library by Google
506
- // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
507
- // Apache License 2.0
508
- // https://github.com/google/closure-library/blob/master/LICENSE
509
- var p = 0;
510
- for (var i = 0; i < msg.length; i++) {
511
- var c = msg.charCodeAt(i);
512
- if (c < 128) {
513
- res[p++] = c;
514
- } else if (c < 2048) {
515
- res[p++] = (c >> 6) | 192;
516
- res[p++] = (c & 63) | 128;
517
- } else if (isSurrogatePair(msg, i)) {
518
- c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
519
- res[p++] = (c >> 18) | 240;
520
- res[p++] = ((c >> 12) & 63) | 128;
521
- res[p++] = ((c >> 6) & 63) | 128;
522
- res[p++] = (c & 63) | 128;
523
- } else {
524
- res[p++] = (c >> 12) | 224;
525
- res[p++] = ((c >> 6) & 63) | 128;
526
- res[p++] = (c & 63) | 128;
527
- }
528
- }
529
- } else if (enc === 'hex') {
530
- msg = msg.replace(/[^a-z0-9]+/ig, '');
531
- if (msg.length % 2 !== 0)
532
- msg = '0' + msg;
533
- for (i = 0; i < msg.length; i += 2)
534
- res.push(parseInt(msg[i] + msg[i + 1], 16));
535
- }
536
- } else {
537
- for (i = 0; i < msg.length; i++)
538
- res[i] = msg[i] | 0;
539
- }
540
- return res;
541
- }
542
- utils$9.toArray = toArray;
367
+ BlockHash$4.prototype.update = function update(msg, enc) {
368
+ // Convert message to array, pad it, and join into 32bit blocks
369
+ msg = utils$8.toArray(msg, enc);
370
+ if (!this.pending)
371
+ this.pending = msg;
372
+ else
373
+ this.pending = this.pending.concat(msg);
374
+ this.pendingTotal += msg.length;
543
375
 
544
- function toHex(msg) {
545
- var res = '';
546
- for (var i = 0; i < msg.length; i++)
547
- res += zero2(msg[i].toString(16));
548
- return res;
549
- }
550
- utils$9.toHex = toHex;
376
+ // Enough data, try updating
377
+ if (this.pending.length >= this._delta8) {
378
+ msg = this.pending;
551
379
 
552
- function htonl(w) {
553
- var res = (w >>> 24) |
554
- ((w >>> 8) & 0xff00) |
555
- ((w << 8) & 0xff0000) |
556
- ((w & 0xff) << 24);
557
- return res >>> 0;
558
- }
559
- utils$9.htonl = htonl;
380
+ // Process pending data in blocks
381
+ var r = msg.length % this._delta8;
382
+ this.pending = msg.slice(msg.length - r, msg.length);
383
+ if (this.pending.length === 0)
384
+ this.pending = null;
560
385
 
561
- function toHex32(msg, endian) {
562
- var res = '';
563
- for (var i = 0; i < msg.length; i++) {
564
- var w = msg[i];
565
- if (endian === 'little')
566
- w = htonl(w);
567
- res += zero8(w.toString(16));
386
+ msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
387
+ for (var i = 0; i < msg.length; i += this._delta32)
388
+ this._update(msg, i, i + this._delta32);
568
389
  }
569
- return res;
570
- }
571
- utils$9.toHex32 = toHex32;
572
390
 
573
- function zero2(word) {
574
- if (word.length === 1)
575
- return '0' + word;
576
- else
577
- return word;
578
- }
579
- utils$9.zero2 = zero2;
391
+ return this;
392
+ };
580
393
 
581
- function zero8(word) {
582
- if (word.length === 7)
583
- return '0' + word;
584
- else if (word.length === 6)
585
- return '00' + word;
586
- else if (word.length === 5)
587
- return '000' + word;
588
- else if (word.length === 4)
589
- return '0000' + word;
590
- else if (word.length === 3)
591
- return '00000' + word;
592
- else if (word.length === 2)
593
- return '000000' + word;
594
- else if (word.length === 1)
595
- return '0000000' + word;
596
- else
597
- return word;
598
- }
599
- utils$9.zero8 = zero8;
394
+ BlockHash$4.prototype.digest = function digest(enc) {
395
+ this.update(this._pad());
396
+ assert$4(this.pending === null);
600
397
 
601
- function join32(msg, start, end, endian) {
602
- var len = end - start;
603
- assert$5(len % 4 === 0);
604
- var res = new Array(len / 4);
605
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
606
- var w;
607
- if (endian === 'big')
608
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
609
- else
610
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
611
- res[i] = w >>> 0;
612
- }
613
- return res;
614
- }
615
- utils$9.join32 = join32;
398
+ return this._digest(enc);
399
+ };
616
400
 
617
- function split32(msg, endian) {
618
- var res = new Array(msg.length * 4);
619
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
620
- var m = msg[i];
621
- if (endian === 'big') {
622
- res[k] = m >>> 24;
623
- res[k + 1] = (m >>> 16) & 0xff;
624
- res[k + 2] = (m >>> 8) & 0xff;
625
- res[k + 3] = m & 0xff;
626
- } else {
627
- res[k + 3] = m >>> 24;
628
- res[k + 2] = (m >>> 16) & 0xff;
629
- res[k + 1] = (m >>> 8) & 0xff;
630
- res[k] = m & 0xff;
631
- }
401
+ BlockHash$4.prototype._pad = function pad() {
402
+ var len = this.pendingTotal;
403
+ var bytes = this._delta8;
404
+ var k = bytes - ((len + this.padLength) % bytes);
405
+ var res = new Array(k + this.padLength);
406
+ res[0] = 0x80;
407
+ for (var i = 1; i < k; i++)
408
+ res[i] = 0;
409
+
410
+ // Append length
411
+ len <<= 3;
412
+ if (this.endian === 'big') {
413
+ for (var t = 8; t < this.padLength; t++)
414
+ res[i++] = 0;
415
+
416
+ res[i++] = 0;
417
+ res[i++] = 0;
418
+ res[i++] = 0;
419
+ res[i++] = 0;
420
+ res[i++] = (len >>> 24) & 0xff;
421
+ res[i++] = (len >>> 16) & 0xff;
422
+ res[i++] = (len >>> 8) & 0xff;
423
+ res[i++] = len & 0xff;
424
+ } else {
425
+ res[i++] = len & 0xff;
426
+ res[i++] = (len >>> 8) & 0xff;
427
+ res[i++] = (len >>> 16) & 0xff;
428
+ res[i++] = (len >>> 24) & 0xff;
429
+ res[i++] = 0;
430
+ res[i++] = 0;
431
+ res[i++] = 0;
432
+ res[i++] = 0;
433
+
434
+ for (t = 8; t < this.padLength; t++)
435
+ res[i++] = 0;
632
436
  }
437
+
633
438
  return res;
634
- }
635
- utils$9.split32 = split32;
439
+ };
636
440
 
637
- function rotr32$1(w, b) {
638
- return (w >>> b) | (w << (32 - b));
639
- }
640
- utils$9.rotr32 = rotr32$1;
441
+ var sha = {};
641
442
 
642
- function rotl32$2(w, b) {
643
- return (w << b) | (w >>> (32 - b));
644
- }
645
- utils$9.rotl32 = rotl32$2;
443
+ var common$4 = {};
646
444
 
647
- function sum32$3(a, b) {
648
- return (a + b) >>> 0;
445
+ var utils$7 = utils$9;
446
+ var rotr32 = utils$7.rotr32;
447
+
448
+ function ft_1$1(s, x, y, z) {
449
+ if (s === 0)
450
+ return ch32$1(x, y, z);
451
+ if (s === 1 || s === 3)
452
+ return p32(x, y, z);
453
+ if (s === 2)
454
+ return maj32$1(x, y, z);
649
455
  }
650
- utils$9.sum32 = sum32$3;
456
+ common$4.ft_1 = ft_1$1;
651
457
 
652
- function sum32_3$1(a, b, c) {
653
- return (a + b + c) >>> 0;
458
+ function ch32$1(x, y, z) {
459
+ return (x & y) ^ ((~x) & z);
654
460
  }
655
- utils$9.sum32_3 = sum32_3$1;
461
+ common$4.ch32 = ch32$1;
656
462
 
657
- function sum32_4$2(a, b, c, d) {
658
- return (a + b + c + d) >>> 0;
463
+ function maj32$1(x, y, z) {
464
+ return (x & y) ^ (x & z) ^ (y & z);
659
465
  }
660
- utils$9.sum32_4 = sum32_4$2;
466
+ common$4.maj32 = maj32$1;
661
467
 
662
- function sum32_5$2(a, b, c, d, e) {
663
- return (a + b + c + d + e) >>> 0;
468
+ function p32(x, y, z) {
469
+ return x ^ y ^ z;
664
470
  }
665
- utils$9.sum32_5 = sum32_5$2;
471
+ common$4.p32 = p32;
666
472
 
667
- function sum64$1(buf, pos, ah, al) {
668
- var bh = buf[pos];
669
- var bl = buf[pos + 1];
473
+ function s0_256$1(x) {
474
+ return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
475
+ }
476
+ common$4.s0_256 = s0_256$1;
670
477
 
671
- var lo = (al + bl) >>> 0;
672
- var hi = (lo < al ? 1 : 0) + ah + bh;
673
- buf[pos] = hi >>> 0;
674
- buf[pos + 1] = lo;
478
+ function s1_256$1(x) {
479
+ return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
675
480
  }
676
- utils$9.sum64 = sum64$1;
481
+ common$4.s1_256 = s1_256$1;
677
482
 
678
- function sum64_hi$1(ah, al, bh, bl) {
679
- var lo = (al + bl) >>> 0;
680
- var hi = (lo < al ? 1 : 0) + ah + bh;
681
- return hi >>> 0;
483
+ function g0_256$1(x) {
484
+ return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
682
485
  }
683
- utils$9.sum64_hi = sum64_hi$1;
486
+ common$4.g0_256 = g0_256$1;
684
487
 
685
- function sum64_lo$1(ah, al, bh, bl) {
686
- var lo = al + bl;
687
- return lo >>> 0;
488
+ function g1_256$1(x) {
489
+ return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
688
490
  }
689
- utils$9.sum64_lo = sum64_lo$1;
690
-
691
- function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
692
- var carry = 0;
693
- var lo = al;
694
- lo = (lo + bl) >>> 0;
695
- carry += lo < al ? 1 : 0;
696
- lo = (lo + cl) >>> 0;
697
- carry += lo < cl ? 1 : 0;
698
- lo = (lo + dl) >>> 0;
699
- carry += lo < dl ? 1 : 0;
700
-
701
- var hi = ah + bh + ch + dh + carry;
702
- return hi >>> 0;
703
- }
704
- utils$9.sum64_4_hi = sum64_4_hi$1;
705
-
706
- function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
707
- var lo = al + bl + cl + dl;
708
- return lo >>> 0;
709
- }
710
- utils$9.sum64_4_lo = sum64_4_lo$1;
711
-
712
- function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
713
- var carry = 0;
714
- var lo = al;
715
- lo = (lo + bl) >>> 0;
716
- carry += lo < al ? 1 : 0;
717
- lo = (lo + cl) >>> 0;
718
- carry += lo < cl ? 1 : 0;
719
- lo = (lo + dl) >>> 0;
720
- carry += lo < dl ? 1 : 0;
721
- lo = (lo + el) >>> 0;
722
- carry += lo < el ? 1 : 0;
723
-
724
- var hi = ah + bh + ch + dh + eh + carry;
725
- return hi >>> 0;
726
- }
727
- utils$9.sum64_5_hi = sum64_5_hi$1;
728
-
729
- function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
730
- var lo = al + bl + cl + dl + el;
731
-
732
- return lo >>> 0;
733
- }
734
- utils$9.sum64_5_lo = sum64_5_lo$1;
735
-
736
- function rotr64_hi$1(ah, al, num) {
737
- var r = (al << (32 - num)) | (ah >>> num);
738
- return r >>> 0;
739
- }
740
- utils$9.rotr64_hi = rotr64_hi$1;
741
-
742
- function rotr64_lo$1(ah, al, num) {
743
- var r = (ah << (32 - num)) | (al >>> num);
744
- return r >>> 0;
745
- }
746
- utils$9.rotr64_lo = rotr64_lo$1;
747
-
748
- function shr64_hi$1(ah, al, num) {
749
- return ah >>> num;
750
- }
751
- utils$9.shr64_hi = shr64_hi$1;
752
-
753
- function shr64_lo$1(ah, al, num) {
754
- var r = (ah << (32 - num)) | (al >>> num);
755
- return r >>> 0;
756
- }
757
- utils$9.shr64_lo = shr64_lo$1;
758
-
759
- var common$5 = {};
760
-
761
- var utils$8 = utils$9;
762
- var assert$4 = minimalisticAssert;
763
-
764
- function BlockHash$4() {
765
- this.pending = null;
766
- this.pendingTotal = 0;
767
- this.blockSize = this.constructor.blockSize;
768
- this.outSize = this.constructor.outSize;
769
- this.hmacStrength = this.constructor.hmacStrength;
770
- this.padLength = this.constructor.padLength / 8;
771
- this.endian = 'big';
772
-
773
- this._delta8 = this.blockSize / 8;
774
- this._delta32 = this.blockSize / 32;
775
- }
776
- common$5.BlockHash = BlockHash$4;
777
-
778
- BlockHash$4.prototype.update = function update(msg, enc) {
779
- // Convert message to array, pad it, and join into 32bit blocks
780
- msg = utils$8.toArray(msg, enc);
781
- if (!this.pending)
782
- this.pending = msg;
783
- else
784
- this.pending = this.pending.concat(msg);
785
- this.pendingTotal += msg.length;
786
-
787
- // Enough data, try updating
788
- if (this.pending.length >= this._delta8) {
789
- msg = this.pending;
790
-
791
- // Process pending data in blocks
792
- var r = msg.length % this._delta8;
793
- this.pending = msg.slice(msg.length - r, msg.length);
794
- if (this.pending.length === 0)
795
- this.pending = null;
796
-
797
- msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
798
- for (var i = 0; i < msg.length; i += this._delta32)
799
- this._update(msg, i, i + this._delta32);
800
- }
801
-
802
- return this;
803
- };
804
-
805
- BlockHash$4.prototype.digest = function digest(enc) {
806
- this.update(this._pad());
807
- assert$4(this.pending === null);
808
-
809
- return this._digest(enc);
810
- };
811
-
812
- BlockHash$4.prototype._pad = function pad() {
813
- var len = this.pendingTotal;
814
- var bytes = this._delta8;
815
- var k = bytes - ((len + this.padLength) % bytes);
816
- var res = new Array(k + this.padLength);
817
- res[0] = 0x80;
818
- for (var i = 1; i < k; i++)
819
- res[i] = 0;
820
-
821
- // Append length
822
- len <<= 3;
823
- if (this.endian === 'big') {
824
- for (var t = 8; t < this.padLength; t++)
825
- res[i++] = 0;
826
-
827
- res[i++] = 0;
828
- res[i++] = 0;
829
- res[i++] = 0;
830
- res[i++] = 0;
831
- res[i++] = (len >>> 24) & 0xff;
832
- res[i++] = (len >>> 16) & 0xff;
833
- res[i++] = (len >>> 8) & 0xff;
834
- res[i++] = len & 0xff;
835
- } else {
836
- res[i++] = len & 0xff;
837
- res[i++] = (len >>> 8) & 0xff;
838
- res[i++] = (len >>> 16) & 0xff;
839
- res[i++] = (len >>> 24) & 0xff;
840
- res[i++] = 0;
841
- res[i++] = 0;
842
- res[i++] = 0;
843
- res[i++] = 0;
844
-
845
- for (t = 8; t < this.padLength; t++)
846
- res[i++] = 0;
847
- }
848
-
849
- return res;
850
- };
851
-
852
- var sha = {};
853
-
854
- var common$4 = {};
855
-
856
- var utils$7 = utils$9;
857
- var rotr32 = utils$7.rotr32;
858
-
859
- function ft_1$1(s, x, y, z) {
860
- if (s === 0)
861
- return ch32$1(x, y, z);
862
- if (s === 1 || s === 3)
863
- return p32(x, y, z);
864
- if (s === 2)
865
- return maj32$1(x, y, z);
866
- }
867
- common$4.ft_1 = ft_1$1;
868
-
869
- function ch32$1(x, y, z) {
870
- return (x & y) ^ ((~x) & z);
871
- }
872
- common$4.ch32 = ch32$1;
873
-
874
- function maj32$1(x, y, z) {
875
- return (x & y) ^ (x & z) ^ (y & z);
876
- }
877
- common$4.maj32 = maj32$1;
878
-
879
- function p32(x, y, z) {
880
- return x ^ y ^ z;
881
- }
882
- common$4.p32 = p32;
883
-
884
- function s0_256$1(x) {
885
- return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
886
- }
887
- common$4.s0_256 = s0_256$1;
888
-
889
- function s1_256$1(x) {
890
- return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
891
- }
892
- common$4.s1_256 = s1_256$1;
893
-
894
- function g0_256$1(x) {
895
- return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
896
- }
897
- common$4.g0_256 = g0_256$1;
898
-
899
- function g1_256$1(x) {
900
- return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
901
- }
902
- common$4.g1_256 = g1_256$1;
491
+ common$4.g1_256 = g1_256$1;
903
492
 
904
493
  var utils$6 = utils$9;
905
494
  var common$3 = common$5;
@@ -1677,16 +1266,425 @@ hash.sha = sha;
1677
1266
  hash.ripemd = ripemd;
1678
1267
  hash.hmac = hmac;
1679
1268
 
1680
- // Proxy hash functions to the main object
1681
- hash.sha1 = hash.sha.sha1;
1682
- hash.sha256 = hash.sha.sha256;
1683
- hash.sha224 = hash.sha.sha224;
1684
- hash.sha384 = hash.sha.sha384;
1685
- hash.sha512 = hash.sha.sha512;
1686
- hash.ripemd160 = hash.ripemd.ripemd160;
1687
- }(hash$1));
1269
+ // Proxy hash functions to the main object
1270
+ hash.sha1 = hash.sha.sha1;
1271
+ hash.sha256 = hash.sha.sha256;
1272
+ hash.sha224 = hash.sha.sha224;
1273
+ hash.sha384 = hash.sha.sha384;
1274
+ hash.sha512 = hash.sha.sha512;
1275
+ hash.ripemd160 = hash.ripemd.ripemd160;
1276
+ }(hash$1));
1277
+
1278
+ var hash = hash$1;
1279
+
1280
+ const version$2 = "logger/5.5.0";
1281
+
1282
+ let _permanentCensorErrors = false;
1283
+ let _censorErrors = false;
1284
+ const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
1285
+ let _logLevel = LogLevels["default"];
1286
+ let _globalLogger = null;
1287
+ function _checkNormalize() {
1288
+ try {
1289
+ const missing = [];
1290
+ // Make sure all forms of normalization are supported
1291
+ ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
1292
+ try {
1293
+ if ("test".normalize(form) !== "test") {
1294
+ throw new Error("bad normalize");
1295
+ }
1296
+ ;
1297
+ }
1298
+ catch (error) {
1299
+ missing.push(form);
1300
+ }
1301
+ });
1302
+ if (missing.length) {
1303
+ throw new Error("missing " + missing.join(", "));
1304
+ }
1305
+ if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
1306
+ throw new Error("broken implementation");
1307
+ }
1308
+ }
1309
+ catch (error) {
1310
+ return error.message;
1311
+ }
1312
+ return null;
1313
+ }
1314
+ const _normalizeError = _checkNormalize();
1315
+ var LogLevel;
1316
+ (function (LogLevel) {
1317
+ LogLevel["DEBUG"] = "DEBUG";
1318
+ LogLevel["INFO"] = "INFO";
1319
+ LogLevel["WARNING"] = "WARNING";
1320
+ LogLevel["ERROR"] = "ERROR";
1321
+ LogLevel["OFF"] = "OFF";
1322
+ })(LogLevel || (LogLevel = {}));
1323
+ var ErrorCode;
1324
+ (function (ErrorCode) {
1325
+ ///////////////////
1326
+ // Generic Errors
1327
+ // Unknown Error
1328
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1329
+ // Not Implemented
1330
+ ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
1331
+ // Unsupported Operation
1332
+ // - operation
1333
+ ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
1334
+ // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
1335
+ // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
1336
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
1337
+ // Some sort of bad response from the server
1338
+ ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
1339
+ // Timeout
1340
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
1341
+ ///////////////////
1342
+ // Operational Errors
1343
+ // Buffer Overrun
1344
+ ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
1345
+ // Numeric Fault
1346
+ // - operation: the operation being executed
1347
+ // - fault: the reason this faulted
1348
+ ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
1349
+ ///////////////////
1350
+ // Argument Errors
1351
+ // Missing new operator to an object
1352
+ // - name: The name of the class
1353
+ ErrorCode["MISSING_NEW"] = "MISSING_NEW";
1354
+ // Invalid argument (e.g. value is incompatible with type) to a function:
1355
+ // - argument: The argument name that was invalid
1356
+ // - value: The value of the argument
1357
+ ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
1358
+ // Missing argument to a function:
1359
+ // - count: The number of arguments received
1360
+ // - expectedCount: The number of arguments expected
1361
+ ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
1362
+ // Too many arguments
1363
+ // - count: The number of arguments received
1364
+ // - expectedCount: The number of arguments expected
1365
+ ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
1366
+ ///////////////////
1367
+ // Blockchain Errors
1368
+ // Call exception
1369
+ // - transaction: the transaction
1370
+ // - address?: the contract address
1371
+ // - args?: The arguments passed into the function
1372
+ // - method?: The Solidity method signature
1373
+ // - errorSignature?: The EIP848 error signature
1374
+ // - errorArgs?: The EIP848 error parameters
1375
+ // - reason: The reason (only for EIP848 "Error(string)")
1376
+ ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
1377
+ // Insufficient funds (< value + gasLimit * gasPrice)
1378
+ // - transaction: the transaction attempted
1379
+ ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
1380
+ // Nonce has already been used
1381
+ // - transaction: the transaction attempted
1382
+ ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
1383
+ // The replacement fee for the transaction is too low
1384
+ // - transaction: the transaction attempted
1385
+ ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
1386
+ // The gas limit could not be estimated
1387
+ // - transaction: the transaction passed to estimateGas
1388
+ ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
1389
+ // The transaction was replaced by one with a higher gas price
1390
+ // - reason: "cancelled", "replaced" or "repriced"
1391
+ // - cancelled: true if reason == "cancelled" or reason == "replaced")
1392
+ // - hash: original transaction hash
1393
+ // - replacement: the full TransactionsResponse for the replacement
1394
+ // - receipt: the receipt of the replacement
1395
+ ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
1396
+ })(ErrorCode || (ErrorCode = {}));
1397
+ const HEX = "0123456789abcdef";
1398
+ class Logger {
1399
+ constructor(version) {
1400
+ Object.defineProperty(this, "version", {
1401
+ enumerable: true,
1402
+ value: version,
1403
+ writable: false
1404
+ });
1405
+ }
1406
+ _log(logLevel, args) {
1407
+ const level = logLevel.toLowerCase();
1408
+ if (LogLevels[level] == null) {
1409
+ this.throwArgumentError("invalid log level name", "logLevel", logLevel);
1410
+ }
1411
+ if (_logLevel > LogLevels[level]) {
1412
+ return;
1413
+ }
1414
+ console.log.apply(console, args);
1415
+ }
1416
+ debug(...args) {
1417
+ this._log(Logger.levels.DEBUG, args);
1418
+ }
1419
+ info(...args) {
1420
+ this._log(Logger.levels.INFO, args);
1421
+ }
1422
+ warn(...args) {
1423
+ this._log(Logger.levels.WARNING, args);
1424
+ }
1425
+ makeError(message, code, params) {
1426
+ // Errors are being censored
1427
+ if (_censorErrors) {
1428
+ return this.makeError("censored error", code, {});
1429
+ }
1430
+ if (!code) {
1431
+ code = Logger.errors.UNKNOWN_ERROR;
1432
+ }
1433
+ if (!params) {
1434
+ params = {};
1435
+ }
1436
+ const messageDetails = [];
1437
+ Object.keys(params).forEach((key) => {
1438
+ const value = params[key];
1439
+ try {
1440
+ if (value instanceof Uint8Array) {
1441
+ let hex = "";
1442
+ for (let i = 0; i < value.length; i++) {
1443
+ hex += HEX[value[i] >> 4];
1444
+ hex += HEX[value[i] & 0x0f];
1445
+ }
1446
+ messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
1447
+ }
1448
+ else {
1449
+ messageDetails.push(key + "=" + JSON.stringify(value));
1450
+ }
1451
+ }
1452
+ catch (error) {
1453
+ messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
1454
+ }
1455
+ });
1456
+ messageDetails.push(`code=${code}`);
1457
+ messageDetails.push(`version=${this.version}`);
1458
+ const reason = message;
1459
+ if (messageDetails.length) {
1460
+ message += " (" + messageDetails.join(", ") + ")";
1461
+ }
1462
+ // @TODO: Any??
1463
+ const error = new Error(message);
1464
+ error.reason = reason;
1465
+ error.code = code;
1466
+ Object.keys(params).forEach(function (key) {
1467
+ error[key] = params[key];
1468
+ });
1469
+ return error;
1470
+ }
1471
+ throwError(message, code, params) {
1472
+ throw this.makeError(message, code, params);
1473
+ }
1474
+ throwArgumentError(message, name, value) {
1475
+ return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
1476
+ argument: name,
1477
+ value: value
1478
+ });
1479
+ }
1480
+ assert(condition, message, code, params) {
1481
+ if (!!condition) {
1482
+ return;
1483
+ }
1484
+ this.throwError(message, code, params);
1485
+ }
1486
+ assertArgument(condition, message, name, value) {
1487
+ if (!!condition) {
1488
+ return;
1489
+ }
1490
+ this.throwArgumentError(message, name, value);
1491
+ }
1492
+ checkNormalize(message) {
1493
+ if (_normalizeError) {
1494
+ this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
1495
+ operation: "String.prototype.normalize", form: _normalizeError
1496
+ });
1497
+ }
1498
+ }
1499
+ checkSafeUint53(value, message) {
1500
+ if (typeof (value) !== "number") {
1501
+ return;
1502
+ }
1503
+ if (message == null) {
1504
+ message = "value not safe";
1505
+ }
1506
+ if (value < 0 || value >= 0x1fffffffffffff) {
1507
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1508
+ operation: "checkSafeInteger",
1509
+ fault: "out-of-safe-range",
1510
+ value: value
1511
+ });
1512
+ }
1513
+ if (value % 1) {
1514
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1515
+ operation: "checkSafeInteger",
1516
+ fault: "non-integer",
1517
+ value: value
1518
+ });
1519
+ }
1520
+ }
1521
+ checkArgumentCount(count, expectedCount, message) {
1522
+ if (message) {
1523
+ message = ": " + message;
1524
+ }
1525
+ else {
1526
+ message = "";
1527
+ }
1528
+ if (count < expectedCount) {
1529
+ this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
1530
+ count: count,
1531
+ expectedCount: expectedCount
1532
+ });
1533
+ }
1534
+ if (count > expectedCount) {
1535
+ this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
1536
+ count: count,
1537
+ expectedCount: expectedCount
1538
+ });
1539
+ }
1540
+ }
1541
+ checkNew(target, kind) {
1542
+ if (target === Object || target == null) {
1543
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1544
+ }
1545
+ }
1546
+ checkAbstract(target, kind) {
1547
+ if (target === kind) {
1548
+ this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
1549
+ }
1550
+ else if (target === Object || target == null) {
1551
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1552
+ }
1553
+ }
1554
+ static globalLogger() {
1555
+ if (!_globalLogger) {
1556
+ _globalLogger = new Logger(version$2);
1557
+ }
1558
+ return _globalLogger;
1559
+ }
1560
+ static setCensorship(censorship, permanent) {
1561
+ if (!censorship && permanent) {
1562
+ this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
1563
+ operation: "setCensorship"
1564
+ });
1565
+ }
1566
+ if (_permanentCensorErrors) {
1567
+ if (!censorship) {
1568
+ return;
1569
+ }
1570
+ this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
1571
+ operation: "setCensorship"
1572
+ });
1573
+ }
1574
+ _censorErrors = !!censorship;
1575
+ _permanentCensorErrors = !!permanent;
1576
+ }
1577
+ static setLogLevel(logLevel) {
1578
+ const level = LogLevels[logLevel.toLowerCase()];
1579
+ if (level == null) {
1580
+ Logger.globalLogger().warn("invalid log level - " + logLevel);
1581
+ return;
1582
+ }
1583
+ _logLevel = level;
1584
+ }
1585
+ static from(version) {
1586
+ return new Logger(version);
1587
+ }
1588
+ }
1589
+ Logger.errors = ErrorCode;
1590
+ Logger.levels = LogLevel;
1591
+
1592
+ const version$1 = "bytes/5.5.0";
1688
1593
 
1689
- var hash = hash$1;
1594
+ const logger = new Logger(version$1);
1595
+ ///////////////////////////////
1596
+ function isHexable(value) {
1597
+ return !!(value.toHexString);
1598
+ }
1599
+ function addSlice(array) {
1600
+ if (array.slice) {
1601
+ return array;
1602
+ }
1603
+ array.slice = function () {
1604
+ const args = Array.prototype.slice.call(arguments);
1605
+ return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
1606
+ };
1607
+ return array;
1608
+ }
1609
+ function isInteger(value) {
1610
+ return (typeof (value) === "number" && value == value && (value % 1) === 0);
1611
+ }
1612
+ function isBytes(value) {
1613
+ if (value == null) {
1614
+ return false;
1615
+ }
1616
+ if (value.constructor === Uint8Array) {
1617
+ return true;
1618
+ }
1619
+ if (typeof (value) === "string") {
1620
+ return false;
1621
+ }
1622
+ if (!isInteger(value.length) || value.length < 0) {
1623
+ return false;
1624
+ }
1625
+ for (let i = 0; i < value.length; i++) {
1626
+ const v = value[i];
1627
+ if (!isInteger(v) || v < 0 || v >= 256) {
1628
+ return false;
1629
+ }
1630
+ }
1631
+ return true;
1632
+ }
1633
+ function arrayify(value, options) {
1634
+ if (!options) {
1635
+ options = {};
1636
+ }
1637
+ if (typeof (value) === "number") {
1638
+ logger.checkSafeUint53(value, "invalid arrayify value");
1639
+ const result = [];
1640
+ while (value) {
1641
+ result.unshift(value & 0xff);
1642
+ value = parseInt(String(value / 256));
1643
+ }
1644
+ if (result.length === 0) {
1645
+ result.push(0);
1646
+ }
1647
+ return addSlice(new Uint8Array(result));
1648
+ }
1649
+ if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
1650
+ value = "0x" + value;
1651
+ }
1652
+ if (isHexable(value)) {
1653
+ value = value.toHexString();
1654
+ }
1655
+ if (isHexString(value)) {
1656
+ let hex = value.substring(2);
1657
+ if (hex.length % 2) {
1658
+ if (options.hexPad === "left") {
1659
+ hex = "0x0" + hex.substring(2);
1660
+ }
1661
+ else if (options.hexPad === "right") {
1662
+ hex += "0";
1663
+ }
1664
+ else {
1665
+ logger.throwArgumentError("hex data is odd-length", "value", value);
1666
+ }
1667
+ }
1668
+ const result = [];
1669
+ for (let i = 0; i < hex.length; i += 2) {
1670
+ result.push(parseInt(hex.substring(i, i + 2), 16));
1671
+ }
1672
+ return addSlice(new Uint8Array(result));
1673
+ }
1674
+ if (isBytes(value)) {
1675
+ return addSlice(new Uint8Array(value));
1676
+ }
1677
+ return logger.throwArgumentError("invalid arrayify value", "value", value);
1678
+ }
1679
+ function isHexString(value, length) {
1680
+ if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
1681
+ return false;
1682
+ }
1683
+ if (length && value.length !== 2 + 2 * length) {
1684
+ return false;
1685
+ }
1686
+ return true;
1687
+ }
1690
1688
 
1691
1689
  const version = "sha2/5.5.0";
1692
1690
 
@@ -1718,8 +1716,7 @@ class Struct {
1718
1716
  class Enum extends Struct {
1719
1717
  constructor(properties) {
1720
1718
  super(properties);
1721
-
1722
- _defineProperty(this, "enum", '');
1719
+ this.enum = '';
1723
1720
 
1724
1721
  if (Object.keys(properties).length !== 1) {
1725
1722
  throw new Error('Enum can only take single value');
@@ -1759,8 +1756,7 @@ class PublicKey extends Struct {
1759
1756
  */
1760
1757
  constructor(value) {
1761
1758
  super({});
1762
-
1763
- _defineProperty(this, "_bn", void 0);
1759
+ this._bn = void 0;
1764
1760
 
1765
1761
  if (isPublicKeyData(value)) {
1766
1762
  this._bn = value._bn;
@@ -1770,7 +1766,7 @@ class PublicKey extends Struct {
1770
1766
  const decoded = bs58.decode(value);
1771
1767
 
1772
1768
  if (decoded.length != 32) {
1773
- throw new Error("Invalid public key input");
1769
+ throw new Error(`Invalid public key input`);
1774
1770
  }
1775
1771
 
1776
1772
  this._bn = new BN(decoded);
@@ -1779,7 +1775,7 @@ class PublicKey extends Struct {
1779
1775
  }
1780
1776
 
1781
1777
  if (this._bn.byteLength() > 32) {
1782
- throw new Error("Invalid public key input");
1778
+ throw new Error(`Invalid public key input`);
1783
1779
  }
1784
1780
  }
1785
1781
  }
@@ -1802,6 +1798,10 @@ class PublicKey extends Struct {
1802
1798
  toBase58() {
1803
1799
  return bs58.encode(this.toBytes());
1804
1800
  }
1801
+
1802
+ toJSON() {
1803
+ return this.toBase58();
1804
+ }
1805
1805
  /**
1806
1806
  * Return the byte array representation of the public key
1807
1807
  */
@@ -1859,7 +1859,7 @@ class PublicKey extends Struct {
1859
1859
  let buffer = Buffer.alloc(0);
1860
1860
  seeds.forEach(function (seed) {
1861
1861
  if (seed.length > MAX_SEED_LENGTH) {
1862
- throw new TypeError("Max seed length exceeded");
1862
+ throw new TypeError(`Max seed length exceeded`);
1863
1863
  }
1864
1864
 
1865
1865
  buffer = Buffer.concat([buffer, toBuffer(seed)]);
@@ -1869,7 +1869,7 @@ class PublicKey extends Struct {
1869
1869
  let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
1870
1870
 
1871
1871
  if (is_on_curve(publicKeyBytes)) {
1872
- throw new Error("Invalid seeds, address must fall off the curve");
1872
+ throw new Error(`Invalid seeds, address must fall off the curve`);
1873
1873
  }
1874
1874
 
1875
1875
  return new PublicKey(publicKeyBytes);
@@ -1903,7 +1903,7 @@ class PublicKey extends Struct {
1903
1903
  return [address, nonce];
1904
1904
  }
1905
1905
 
1906
- throw new Error("Unable to find a viable program address nonce");
1906
+ throw new Error(`Unable to find a viable program address nonce`);
1907
1907
  }
1908
1908
  /**
1909
1909
  * Check that a pubkey is on the ed25519 curve.
@@ -1915,15 +1915,13 @@ class PublicKey extends Struct {
1915
1915
  }
1916
1916
 
1917
1917
  }
1918
-
1919
- _defineProperty(PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
1920
-
1918
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
1921
1919
  SOLANA_SCHEMA.set(PublicKey, {
1922
1920
  kind: 'struct',
1923
1921
  fields: [['_bn', 'u256']]
1924
1922
  }); // @ts-ignore
1925
1923
 
1926
- let naclLowLevel = nacl__default.lowlevel; // Check that a pubkey is on the curve.
1924
+ let naclLowLevel = nacl.lowlevel; // Check that a pubkey is on the curve.
1927
1925
  // This function and its dependents were sourced from:
1928
1926
  // https://github.com/dchest/tweetnacl-js/blob/f1ec050ceae0861f34280e62498b1d3ed9c350c6/nacl.js#L792
1929
1927
 
@@ -1990,7 +1988,7 @@ class Account {
1990
1988
  * @param secretKey Secret key for the account
1991
1989
  */
1992
1990
  constructor(secretKey) {
1993
- _defineProperty(this, "_keypair", void 0);
1991
+ this._keypair = void 0;
1994
1992
 
1995
1993
  if (secretKey) {
1996
1994
  this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
@@ -2126,16 +2124,11 @@ const PUBKEY_LENGTH = 32;
2126
2124
 
2127
2125
  class Message {
2128
2126
  constructor(args) {
2129
- _defineProperty(this, "header", void 0);
2130
-
2131
- _defineProperty(this, "accountKeys", void 0);
2132
-
2133
- _defineProperty(this, "recentBlockhash", void 0);
2134
-
2135
- _defineProperty(this, "instructions", void 0);
2136
-
2137
- _defineProperty(this, "indexToProgramIds", new Map());
2138
-
2127
+ this.header = void 0;
2128
+ this.accountKeys = void 0;
2129
+ this.recentBlockhash = void 0;
2130
+ this.instructions = void 0;
2131
+ this.indexToProgramIds = new Map();
2139
2132
  this.header = args.header;
2140
2133
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
2141
2134
  this.recentBlockhash = args.recentBlockhash;
@@ -2309,12 +2302,9 @@ class TransactionInstruction {
2309
2302
  * Program input
2310
2303
  */
2311
2304
  constructor(opts) {
2312
- _defineProperty(this, "keys", void 0);
2313
-
2314
- _defineProperty(this, "programId", void 0);
2315
-
2316
- _defineProperty(this, "data", Buffer.alloc(0));
2317
-
2305
+ this.keys = void 0;
2306
+ this.programId = void 0;
2307
+ this.data = Buffer.alloc(0);
2318
2308
  this.programId = opts.programId;
2319
2309
  this.keys = opts.keys;
2320
2310
 
@@ -2356,16 +2346,11 @@ class Transaction {
2356
2346
  * Construct an empty Transaction
2357
2347
  */
2358
2348
  constructor(opts) {
2359
- _defineProperty(this, "signatures", []);
2360
-
2361
- _defineProperty(this, "feePayer", void 0);
2362
-
2363
- _defineProperty(this, "instructions", []);
2364
-
2365
- _defineProperty(this, "recentBlockhash", void 0);
2366
-
2367
- _defineProperty(this, "nonceInfo", void 0);
2368
-
2349
+ this.signatures = [];
2350
+ this.feePayer = void 0;
2351
+ this.instructions = [];
2352
+ this.recentBlockhash = void 0;
2353
+ this.nonceInfo = void 0;
2369
2354
  opts && Object.assign(this, opts);
2370
2355
  }
2371
2356
  /**
@@ -2429,7 +2414,7 @@ class Transaction {
2429
2414
 
2430
2415
  for (let i = 0; i < this.instructions.length; i++) {
2431
2416
  if (this.instructions[i].programId === undefined) {
2432
- throw new Error("Transaction instruction index ".concat(i, " has undefined program id"));
2417
+ throw new Error(`Transaction instruction index ${i} has undefined program id`);
2433
2418
  }
2434
2419
  }
2435
2420
 
@@ -2456,8 +2441,9 @@ class Transaction {
2456
2441
  }); // Sort. Prioritizing first by signer, then by writable
2457
2442
 
2458
2443
  accountMetas.sort(function (x, y) {
2444
+ const pubkeySorting = x.pubkey.toBase58().localeCompare(y.pubkey.toBase58());
2459
2445
  const checkSigner = x.isSigner === y.isSigner ? 0 : x.isSigner ? -1 : 1;
2460
- const checkWritable = x.isWritable === y.isWritable ? 0 : x.isWritable ? -1 : 1;
2446
+ const checkWritable = x.isWritable === y.isWritable ? pubkeySorting : x.isWritable ? -1 : 1;
2461
2447
  return checkSigner || checkWritable;
2462
2448
  }); // Cull duplicate account metas
2463
2449
 
@@ -2504,7 +2490,7 @@ class Transaction {
2504
2490
  console.warn('Transaction references a signature that is unnecessary, ' + 'only the fee payer and instruction signer accounts should sign a transaction. ' + 'This behavior is deprecated and will throw an error in the next major version release.');
2505
2491
  }
2506
2492
  } else {
2507
- throw new Error("unknown signer: ".concat(signature.publicKey.toString()));
2493
+ throw new Error(`unknown signer: ${signature.publicKey.toString()}`);
2508
2494
  }
2509
2495
  }
2510
2496
 
@@ -2711,7 +2697,7 @@ class Transaction {
2711
2697
  _partialSign(message, ...signers) {
2712
2698
  const signData = message.serialize();
2713
2699
  signers.forEach(signer => {
2714
- const signature = nacl__default.sign.detached(signData, signer.secretKey);
2700
+ const signature = nacl.sign.detached(signData, signer.secretKey);
2715
2701
 
2716
2702
  this._addSignature(signer.publicKey, toBuffer(signature));
2717
2703
  });
@@ -2739,7 +2725,7 @@ class Transaction {
2739
2725
  const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));
2740
2726
 
2741
2727
  if (index < 0) {
2742
- throw new Error("unknown signer: ".concat(pubkey.toString()));
2728
+ throw new Error(`unknown signer: ${pubkey.toString()}`);
2743
2729
  }
2744
2730
 
2745
2731
  this.signatures[index].signature = Buffer.from(signature);
@@ -2767,7 +2753,7 @@ class Transaction {
2767
2753
  return false;
2768
2754
  }
2769
2755
  } else {
2770
- if (!nacl__default.sign.detached.verify(signData, signature, publicKey.toBuffer())) {
2756
+ if (!nacl.sign.detached.verify(signData, signature, publicKey.toBuffer())) {
2771
2757
  return false;
2772
2758
  }
2773
2759
  }
@@ -2815,12 +2801,12 @@ class Transaction {
2815
2801
  signature
2816
2802
  }, index) => {
2817
2803
  if (signature !== null) {
2818
- assert(signature.length === 64, "signature has invalid length");
2804
+ assert(signature.length === 64, `signature has invalid length`);
2819
2805
  Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
2820
2806
  }
2821
2807
  });
2822
2808
  signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
2823
- assert(wireTransaction.length <= PACKET_DATA_SIZE, "Transaction too large: ".concat(wireTransaction.length, " > ").concat(PACKET_DATA_SIZE));
2809
+ assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);
2824
2810
  return wireTransaction;
2825
2811
  }
2826
2812
  /**
@@ -2913,11 +2899,14 @@ class Transaction {
2913
2899
  }
2914
2900
 
2915
2901
  const SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');
2902
+ const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');
2903
+ const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2916
2904
  const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');
2917
2905
  const SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');
2918
2906
  const SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');
2907
+ const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');
2908
+ const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');
2919
2909
  const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');
2920
- const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');
2921
2910
 
2922
2911
  /**
2923
2912
  * Sign, send and confirm a transaction.
@@ -2939,7 +2928,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2939
2928
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2940
2929
 
2941
2930
  if (status.err) {
2942
- throw new Error("Transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
2931
+ throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);
2943
2932
  }
2944
2933
 
2945
2934
  return signature;
@@ -2982,7 +2971,7 @@ function decodeData(type, buffer) {
2982
2971
  }
2983
2972
 
2984
2973
  if (data.instruction !== type.index) {
2985
- throw new Error("invalid instruction; instruction index mismatch ".concat(data.instruction, " != ").concat(type.index));
2974
+ throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);
2986
2975
  }
2987
2976
 
2988
2977
  return data;
@@ -3016,12 +3005,9 @@ class NonceAccount {
3016
3005
  * @internal
3017
3006
  */
3018
3007
  constructor(args) {
3019
- _defineProperty(this, "authorizedPubkey", void 0);
3020
-
3021
- _defineProperty(this, "nonce", void 0);
3022
-
3023
- _defineProperty(this, "feeCalculator", void 0);
3024
-
3008
+ this.authorizedPubkey = void 0;
3009
+ this.nonce = void 0;
3010
+ this.feeCalculator = void 0;
3025
3011
  this.authorizedPubkey = args.authorizedPubkey;
3026
3012
  this.nonce = args.nonce;
3027
3013
  this.feeCalculator = args.feeCalculator;
@@ -3322,7 +3308,7 @@ class SystemInstruction {
3322
3308
 
3323
3309
  static checkKeyLength(keys, expectedLength) {
3324
3310
  if (keys.length < expectedLength) {
3325
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
3311
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
3326
3312
  }
3327
3313
  }
3328
3314
 
@@ -3754,8 +3740,7 @@ class SystemProgram {
3754
3740
  }
3755
3741
 
3756
3742
  }
3757
-
3758
- _defineProperty(SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3743
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
3759
3744
 
3760
3745
  // rest of the Transaction fields
3761
3746
  //
@@ -3924,8 +3909,7 @@ class Loader {
3924
3909
  }
3925
3910
 
3926
3911
  }
3927
-
3928
- _defineProperty(Loader, "chunkSize", CHUNK_SIZE);
3912
+ Loader.chunkSize = CHUNK_SIZE;
3929
3913
 
3930
3914
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
3931
3915
  /**
@@ -4564,16 +4548,11 @@ class EpochSchedule {
4564
4548
 
4565
4549
  /** The first slot of `firstNormalEpoch` */
4566
4550
  constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
4567
- _defineProperty(this, "slotsPerEpoch", void 0);
4568
-
4569
- _defineProperty(this, "leaderScheduleSlotOffset", void 0);
4570
-
4571
- _defineProperty(this, "warmup", void 0);
4572
-
4573
- _defineProperty(this, "firstNormalEpoch", void 0);
4574
-
4575
- _defineProperty(this, "firstNormalSlot", void 0);
4576
-
4551
+ this.slotsPerEpoch = void 0;
4552
+ this.leaderScheduleSlotOffset = void 0;
4553
+ this.warmup = void 0;
4554
+ this.firstNormalEpoch = void 0;
4555
+ this.firstNormalSlot = void 0;
4577
4556
  this.slotsPerEpoch = slotsPerEpoch;
4578
4557
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
4579
4558
  this.warmup = warmup;
@@ -4625,9 +4604,7 @@ class EpochSchedule {
4625
4604
  class SendTransactionError extends Error {
4626
4605
  constructor(message, logs) {
4627
4606
  super(message);
4628
-
4629
- _defineProperty(this, "logs", void 0);
4630
-
4607
+ this.logs = void 0;
4631
4608
  this.logs = logs;
4632
4609
  }
4633
4610
 
@@ -4854,16 +4831,15 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4854
4831
  let fetchWithMiddleware;
4855
4832
 
4856
4833
  if (fetchMiddleware) {
4857
- fetchWithMiddleware = (url, options) => {
4858
- return new Promise((resolve, reject) => {
4859
- fetchMiddleware(url, options, async (url, options) => {
4860
- try {
4861
- resolve(await fetch(url, options));
4862
- } catch (error) {
4863
- reject(error);
4864
- }
4865
- });
4834
+ fetchWithMiddleware = async (url, options) => {
4835
+ const modifiedFetchArgs = await new Promise((resolve, reject) => {
4836
+ try {
4837
+ fetchMiddleware(url, options, (modifiedUrl, modifiedOptions) => resolve([modifiedUrl, modifiedOptions]));
4838
+ } catch (error) {
4839
+ reject(error);
4840
+ }
4866
4841
  });
4842
+ return await fetch(...modifiedFetchArgs);
4867
4843
  };
4868
4844
  }
4869
4845
 
@@ -4906,7 +4882,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4906
4882
  break;
4907
4883
  }
4908
4884
 
4909
- console.log("Server responded with ".concat(res.status, " ").concat(res.statusText, ". Retrying after ").concat(waitTime, "ms delay..."));
4885
+ console.log(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);
4910
4886
  await sleep(waitTime);
4911
4887
  waitTime *= 2;
4912
4888
  }
@@ -4916,7 +4892,7 @@ function createRpcClient(url, useHttps, httpHeaders, fetchMiddleware, disableRet
4916
4892
  if (res.ok) {
4917
4893
  callback(null, text);
4918
4894
  } else {
4919
- callback(new Error("".concat(res.status, " ").concat(res.statusText, ": ").concat(text)));
4895
+ callback(new Error(`${res.status} ${res.statusText}: ${text}`));
4920
4896
  }
4921
4897
  } catch (err) {
4922
4898
  if (err instanceof Error) callback(err);
@@ -5356,6 +5332,7 @@ const ParsedConfirmedTransactionResult = type({
5356
5332
  const TokenBalanceResult = type({
5357
5333
  accountIndex: number(),
5358
5334
  mint: string(),
5335
+ owner: optional(string()),
5359
5336
  uiTokenAmount: TokenAmountResult
5360
5337
  });
5361
5338
  /**
@@ -5581,67 +5558,39 @@ class Connection {
5581
5558
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
5582
5559
  */
5583
5560
  constructor(endpoint, commitmentOrConfig) {
5584
- _defineProperty(this, "_commitment", void 0);
5585
-
5586
- _defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
5587
-
5588
- _defineProperty(this, "_rpcEndpoint", void 0);
5589
-
5590
- _defineProperty(this, "_rpcWsEndpoint", void 0);
5591
-
5592
- _defineProperty(this, "_rpcClient", void 0);
5593
-
5594
- _defineProperty(this, "_rpcRequest", void 0);
5595
-
5596
- _defineProperty(this, "_rpcBatchRequest", void 0);
5597
-
5598
- _defineProperty(this, "_rpcWebSocket", void 0);
5599
-
5600
- _defineProperty(this, "_rpcWebSocketConnected", false);
5601
-
5602
- _defineProperty(this, "_rpcWebSocketHeartbeat", null);
5603
-
5604
- _defineProperty(this, "_rpcWebSocketIdleTimeout", null);
5605
-
5606
- _defineProperty(this, "_disableBlockhashCaching", false);
5607
-
5608
- _defineProperty(this, "_pollingBlockhash", false);
5609
-
5610
- _defineProperty(this, "_blockhashInfo", {
5561
+ this._commitment = void 0;
5562
+ this._confirmTransactionInitialTimeout = void 0;
5563
+ this._rpcEndpoint = void 0;
5564
+ this._rpcWsEndpoint = void 0;
5565
+ this._rpcClient = void 0;
5566
+ this._rpcRequest = void 0;
5567
+ this._rpcBatchRequest = void 0;
5568
+ this._rpcWebSocket = void 0;
5569
+ this._rpcWebSocketConnected = false;
5570
+ this._rpcWebSocketHeartbeat = null;
5571
+ this._rpcWebSocketIdleTimeout = null;
5572
+ this._disableBlockhashCaching = false;
5573
+ this._pollingBlockhash = false;
5574
+ this._blockhashInfo = {
5611
5575
  recentBlockhash: null,
5612
5576
  lastFetch: 0,
5613
5577
  transactionSignatures: [],
5614
5578
  simulatedSignatures: []
5615
- });
5616
-
5617
- _defineProperty(this, "_accountChangeSubscriptionCounter", 0);
5618
-
5619
- _defineProperty(this, "_accountChangeSubscriptions", {});
5620
-
5621
- _defineProperty(this, "_programAccountChangeSubscriptionCounter", 0);
5622
-
5623
- _defineProperty(this, "_programAccountChangeSubscriptions", {});
5624
-
5625
- _defineProperty(this, "_rootSubscriptionCounter", 0);
5626
-
5627
- _defineProperty(this, "_rootSubscriptions", {});
5628
-
5629
- _defineProperty(this, "_signatureSubscriptionCounter", 0);
5630
-
5631
- _defineProperty(this, "_signatureSubscriptions", {});
5632
-
5633
- _defineProperty(this, "_slotSubscriptionCounter", 0);
5634
-
5635
- _defineProperty(this, "_slotSubscriptions", {});
5636
-
5637
- _defineProperty(this, "_logsSubscriptionCounter", 0);
5638
-
5639
- _defineProperty(this, "_logsSubscriptions", {});
5640
-
5641
- _defineProperty(this, "_slotUpdateSubscriptionCounter", 0);
5642
-
5643
- _defineProperty(this, "_slotUpdateSubscriptions", {});
5644
-
5579
+ };
5580
+ this._accountChangeSubscriptionCounter = 0;
5581
+ this._accountChangeSubscriptions = {};
5582
+ this._programAccountChangeSubscriptionCounter = 0;
5583
+ this._programAccountChangeSubscriptions = {};
5584
+ this._rootSubscriptionCounter = 0;
5585
+ this._rootSubscriptions = {};
5586
+ this._signatureSubscriptionCounter = 0;
5587
+ this._signatureSubscriptions = {};
5588
+ this._slotSubscriptionCounter = 0;
5589
+ this._slotSubscriptions = {};
5590
+ this._logsSubscriptionCounter = 0;
5591
+ this._logsSubscriptions = {};
5592
+ this._slotUpdateSubscriptionCounter = 0;
5593
+ this._slotUpdateSubscriptions = {};
5645
5594
  let url = new URL(endpoint);
5646
5595
  const useHttps = url.protocol === 'https:';
5647
5596
  let wsEndpoint;
@@ -5987,13 +5936,25 @@ class Connection {
5987
5936
  */
5988
5937
 
5989
5938
 
5990
- async getMultipleAccountsInfo(publicKeys, commitment) {
5939
+ async getMultipleAccountsInfo(publicKeys, configOrCommitment) {
5991
5940
  const keys = publicKeys.map(key => key.toBase58());
5941
+ let commitment;
5942
+ let encoding = 'base64';
5943
+
5944
+ if (configOrCommitment) {
5945
+ if (typeof configOrCommitment === 'string') {
5946
+ commitment = configOrCommitment;
5947
+ encoding = 'base64';
5948
+ } else {
5949
+ commitment = configOrCommitment.commitment;
5950
+ encoding = configOrCommitment.encoding || 'base64';
5951
+ }
5952
+ }
5992
5953
 
5993
- const args = this._buildArgs([keys], commitment, 'base64');
5954
+ const args = this._buildArgs([keys], commitment, encoding);
5994
5955
 
5995
5956
  const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
5996
- const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
5957
+ const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(ParsedAccountInfoResult))));
5997
5958
 
5998
5959
  if ('error' in res) {
5999
5960
  throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
@@ -6015,7 +5976,7 @@ class Connection {
6015
5976
  const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
6016
5977
 
6017
5978
  if ('error' in res) {
6018
- throw new Error("failed to get Stake Activation ".concat(publicKey.toBase58(), ": ").concat(res.error.message));
5979
+ throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
6019
5980
  }
6020
5981
 
6021
5982
  return res.result;
@@ -6151,7 +6112,7 @@ class Connection {
6151
6112
 
6152
6113
  if (response === null) {
6153
6114
  const duration = (Date.now() - start) / 1000;
6154
- throw new Error("Transaction was not confirmed in ".concat(duration.toFixed(2), " seconds. It is unknown if it succeeded or failed. Check signature ").concat(signature, " using the Solana Explorer or CLI tools."));
6115
+ throw new Error(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`);
6155
6116
  }
6156
6117
 
6157
6118
  return response;
@@ -6474,6 +6435,29 @@ class Connection {
6474
6435
  value: value !== null ? value.feeCalculator : null
6475
6436
  };
6476
6437
  }
6438
+ /**
6439
+ * Fetch the fee for a message from the cluster, return with context
6440
+ */
6441
+
6442
+
6443
+ async getFeeForMessage(message, commitment) {
6444
+ const wireMessage = message.serialize().toString('base64');
6445
+
6446
+ const args = this._buildArgs([wireMessage], commitment);
6447
+
6448
+ const unsafeRes = await this._rpcRequest('getFeeForMessage', args);
6449
+ const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));
6450
+
6451
+ if ('error' in res) {
6452
+ throw new Error('failed to get slot: ' + res.error.message);
6453
+ }
6454
+
6455
+ if (res.result === null) {
6456
+ throw new Error('invalid blockhash');
6457
+ }
6458
+
6459
+ return res.result;
6460
+ }
6477
6461
  /**
6478
6462
  * Fetch a recent blockhash from the cluster
6479
6463
  * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
@@ -6925,7 +6909,7 @@ class Connection {
6925
6909
  await sleep(MS_PER_SLOT / 2);
6926
6910
  }
6927
6911
 
6928
- throw new Error("Unable to obtain a new blockhash after ".concat(Date.now() - startTime, "ms"));
6912
+ throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);
6929
6913
  } finally {
6930
6914
  this._pollingBlockhash = false;
6931
6915
  }
@@ -7182,7 +7166,7 @@ class Connection {
7182
7166
  }
7183
7167
 
7184
7168
  if (err instanceof Error) {
7185
- console.error("".concat(rpcMethod, " error for argument"), rpcArgs, err.message);
7169
+ console.error(`${rpcMethod} error for argument`, rpcArgs, err.message);
7186
7170
  }
7187
7171
  }
7188
7172
  }
@@ -7202,7 +7186,7 @@ class Connection {
7202
7186
  await this._rpcWebSocket.call(rpcMethod, [unsubscribeId]);
7203
7187
  } catch (err) {
7204
7188
  if (err instanceof Error) {
7205
- console.error("".concat(rpcMethod, " error:"), err.message);
7189
+ console.error(`${rpcMethod} error:`, err.message);
7206
7190
  }
7207
7191
  }
7208
7192
  }
@@ -7367,7 +7351,7 @@ class Connection {
7367
7351
 
7368
7352
  this._updateSubscriptions();
7369
7353
  } else {
7370
- throw new Error("Unknown account change id: ".concat(id));
7354
+ throw new Error(`Unknown account change id: ${id}`);
7371
7355
  }
7372
7356
  }
7373
7357
  /**
@@ -7433,7 +7417,7 @@ class Connection {
7433
7417
 
7434
7418
  this._updateSubscriptions();
7435
7419
  } else {
7436
- throw new Error("Unknown program account change id: ".concat(id));
7420
+ throw new Error(`Unknown program account change id: ${id}`);
7437
7421
  }
7438
7422
  }
7439
7423
  /**
@@ -7463,7 +7447,7 @@ class Connection {
7463
7447
 
7464
7448
  async removeOnLogsListener(id) {
7465
7449
  if (!this._logsSubscriptions[id]) {
7466
- throw new Error("Unknown logs id: ".concat(id));
7450
+ throw new Error(`Unknown logs id: ${id}`);
7467
7451
  }
7468
7452
 
7469
7453
  const subInfo = this._logsSubscriptions[id];
@@ -7539,7 +7523,7 @@ class Connection {
7539
7523
 
7540
7524
  this._updateSubscriptions();
7541
7525
  } else {
7542
- throw new Error("Unknown slot change id: ".concat(id));
7526
+ throw new Error(`Unknown slot change id: ${id}`);
7543
7527
  }
7544
7528
  }
7545
7529
  /**
@@ -7592,7 +7576,7 @@ class Connection {
7592
7576
 
7593
7577
  this._updateSubscriptions();
7594
7578
  } else {
7595
- throw new Error("Unknown slot update id: ".concat(id));
7579
+ throw new Error(`Unknown slot update id: ${id}`);
7596
7580
  }
7597
7581
  }
7598
7582
 
@@ -7733,7 +7717,7 @@ class Connection {
7733
7717
 
7734
7718
  this._updateSubscriptions();
7735
7719
  } else {
7736
- throw new Error("Unknown signature result id: ".concat(id));
7720
+ throw new Error(`Unknown signature result id: ${id}`);
7737
7721
  }
7738
7722
  }
7739
7723
  /**
@@ -7785,7 +7769,7 @@ class Connection {
7785
7769
 
7786
7770
  this._updateSubscriptions();
7787
7771
  } else {
7788
- throw new Error("Unknown root change id: ".concat(id));
7772
+ throw new Error(`Unknown root change id: ${id}`);
7789
7773
  }
7790
7774
  }
7791
7775
 
@@ -7806,7 +7790,7 @@ class Keypair {
7806
7790
  * @param keypair ed25519 keypair
7807
7791
  */
7808
7792
  constructor(keypair) {
7809
- _defineProperty(this, "_keypair", void 0);
7793
+ this._keypair = void 0;
7810
7794
 
7811
7795
  if (keypair) {
7812
7796
  this._keypair = keypair;
@@ -7910,8 +7894,8 @@ class Ed25519Program {
7910
7894
  signature,
7911
7895
  instructionIndex
7912
7896
  } = params;
7913
- assert(publicKey.length === PUBLIC_KEY_BYTES$1, "Public Key must be ".concat(PUBLIC_KEY_BYTES$1, " bytes but received ").concat(publicKey.length, " bytes"));
7914
- assert(signature.length === SIGNATURE_BYTES, "Signature must be ".concat(SIGNATURE_BYTES, " bytes but received ").concat(signature.length, " bytes"));
7897
+ assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
7898
+ assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
7915
7899
  const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
7916
7900
  const signatureOffset = publicKeyOffset + publicKey.length;
7917
7901
  const messageDataOffset = signatureOffset + signature.length;
@@ -7949,12 +7933,12 @@ class Ed25519Program {
7949
7933
  message,
7950
7934
  instructionIndex
7951
7935
  } = params;
7952
- assert(privateKey.length === PRIVATE_KEY_BYTES$1, "Private key must be ".concat(PRIVATE_KEY_BYTES$1, " bytes but received ").concat(privateKey.length, " bytes"));
7936
+ assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
7953
7937
 
7954
7938
  try {
7955
7939
  const keypair = Keypair.fromSecretKey(privateKey);
7956
7940
  const publicKey = keypair.publicKey.toBytes();
7957
- const signature = nacl__default.sign.detached(message, keypair.secretKey);
7941
+ const signature = nacl.sign.detached(message, keypair.secretKey);
7958
7942
  return this.createInstructionWithPublicKey({
7959
7943
  publicKey,
7960
7944
  message,
@@ -7962,13 +7946,12 @@ class Ed25519Program {
7962
7946
  instructionIndex
7963
7947
  });
7964
7948
  } catch (error) {
7965
- throw new Error("Error creating instruction; ".concat(error));
7949
+ throw new Error(`Error creating instruction; ${error}`);
7966
7950
  }
7967
7951
  }
7968
7952
 
7969
7953
  }
7970
-
7971
- _defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7954
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
7972
7955
 
7973
7956
  /**
7974
7957
  * Address of the stake config account which configures the rate
@@ -7991,10 +7974,8 @@ class Authorized {
7991
7974
  * @param withdrawer the withdraw authority
7992
7975
  */
7993
7976
  constructor(staker, withdrawer) {
7994
- _defineProperty(this, "staker", void 0);
7995
-
7996
- _defineProperty(this, "withdrawer", void 0);
7997
-
7977
+ this.staker = void 0;
7978
+ this.withdrawer = void 0;
7998
7979
  this.staker = staker;
7999
7980
  this.withdrawer = withdrawer;
8000
7981
  }
@@ -8015,12 +7996,9 @@ class Lockup {
8015
7996
  * Create a new Lockup object
8016
7997
  */
8017
7998
  constructor(unixTimestamp, epoch, custodian) {
8018
- _defineProperty(this, "unixTimestamp", void 0);
8019
-
8020
- _defineProperty(this, "epoch", void 0);
8021
-
8022
- _defineProperty(this, "custodian", void 0);
8023
-
7999
+ this.unixTimestamp = void 0;
8000
+ this.epoch = void 0;
8001
+ this.custodian = void 0;
8024
8002
  this.unixTimestamp = unixTimestamp;
8025
8003
  this.epoch = epoch;
8026
8004
  this.custodian = custodian;
@@ -8035,7 +8013,7 @@ class Lockup {
8035
8013
  * Create stake account transaction params
8036
8014
  */
8037
8015
 
8038
- _defineProperty(Lockup, "default", new Lockup(0, 0, PublicKey.default));
8016
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
8039
8017
 
8040
8018
  /**
8041
8019
  * Stake Instruction class
@@ -8248,7 +8226,7 @@ class StakeInstruction {
8248
8226
 
8249
8227
  static checkKeyLength(keys, expectedLength) {
8250
8228
  if (keys.length < expectedLength) {
8251
- throw new Error("invalid instruction; found ".concat(keys.length, " keys, expected at least ").concat(expectedLength));
8229
+ throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);
8252
8230
  }
8253
8231
  }
8254
8232
 
@@ -8723,10 +8701,8 @@ class StakeProgram {
8723
8701
  }
8724
8702
 
8725
8703
  }
8726
-
8727
- _defineProperty(StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
8728
-
8729
- _defineProperty(StakeProgram, "space", 200);
8704
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8705
+ StakeProgram.space = 200;
8730
8706
 
8731
8707
  const {
8732
8708
  publicKeyCreate,
@@ -8756,12 +8732,12 @@ class Secp256k1Program {
8756
8732
  * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
8757
8733
  */
8758
8734
  static publicKeyToEthAddress(publicKey) {
8759
- assert(publicKey.length === PUBLIC_KEY_BYTES, "Public key must be ".concat(PUBLIC_KEY_BYTES, " bytes but received ").concat(publicKey.length, " bytes"));
8735
+ assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
8760
8736
 
8761
8737
  try {
8762
- return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8738
+ return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
8763
8739
  } catch (error) {
8764
- throw new Error("Error constructing Ethereum address: ".concat(error));
8740
+ throw new Error(`Error constructing Ethereum address: ${error}`);
8765
8741
  }
8766
8742
  }
8767
8743
  /**
@@ -8812,7 +8788,7 @@ class Secp256k1Program {
8812
8788
  ethAddress = rawAddress;
8813
8789
  }
8814
8790
 
8815
- assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, "Address must be ".concat(ETHEREUM_ADDRESS_BYTES, " bytes but received ").concat(ethAddress.length, " bytes"));
8791
+ assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);
8816
8792
  const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;
8817
8793
  const ethAddressOffset = dataStart;
8818
8794
  const signatureOffset = dataStart + ethAddress.length;
@@ -8851,13 +8827,13 @@ class Secp256k1Program {
8851
8827
  message,
8852
8828
  instructionIndex
8853
8829
  } = params;
8854
- assert(pkey.length === PRIVATE_KEY_BYTES, "Private key must be ".concat(PRIVATE_KEY_BYTES, " bytes but received ").concat(pkey.length, " bytes"));
8830
+ assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);
8855
8831
 
8856
8832
  try {
8857
8833
  const privateKey = toBuffer(pkey);
8858
8834
  const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
8859
8835
 
8860
- const messageHash = Buffer.from(keccak_256.update(toBuffer(message)).digest());
8836
+ const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
8861
8837
  const {
8862
8838
  signature,
8863
8839
  recid: recoveryId
@@ -8870,13 +8846,12 @@ class Secp256k1Program {
8870
8846
  instructionIndex
8871
8847
  });
8872
8848
  } catch (error) {
8873
- throw new Error("Error creating instruction; ".concat(error));
8849
+ throw new Error(`Error creating instruction; ${error}`);
8874
8850
  }
8875
8851
  }
8876
8852
 
8877
8853
  }
8878
-
8879
- _defineProperty(Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8854
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
8880
8855
 
8881
8856
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
8882
8857
  /**
@@ -8909,10 +8884,8 @@ class ValidatorInfo {
8909
8884
  * @param info validator information
8910
8885
  */
8911
8886
  constructor(key, info) {
8912
- _defineProperty(this, "key", void 0);
8913
-
8914
- _defineProperty(this, "info", void 0);
8915
-
8887
+ this.key = void 0;
8888
+ this.info = void 0;
8916
8889
  this.key = key;
8917
8890
  this.info = info;
8918
8891
  }
@@ -8964,9 +8937,10 @@ const VOTE_PROGRAM_ID = new PublicKey('Vote1111111111111111111111111111111111111
8964
8937
  *
8965
8938
  * @internal
8966
8939
  */
8967
- const VoteAccountLayout = BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedVoterPubkey'), publicKey('authorizedWithdrawerPubkey'), BufferLayout.u8('commission'), BufferLayout.nu64(), // votes.length
8968
- 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
8969
- BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('epoch'), BufferLayout.nu64('credits'), BufferLayout.nu64('prevCredits')]), BufferLayout.offset(BufferLayout.u32(), -8), 'epochCredits')]);
8940
+ const VoteAccountLayout = BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedWithdrawer'), BufferLayout.u8('commission'), BufferLayout.nu64(), // votes.length
8941
+ 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
8942
+ 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
8943
+ 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')]);
8970
8944
 
8971
8945
  /**
8972
8946
  * VoteAccount class
@@ -8976,36 +8950,24 @@ class VoteAccount {
8976
8950
  * @internal
8977
8951
  */
8978
8952
  constructor(args) {
8979
- _defineProperty(this, "nodePubkey", void 0);
8980
-
8981
- _defineProperty(this, "authorizedVoterPubkey", void 0);
8982
-
8983
- _defineProperty(this, "authorizedWithdrawerPubkey", void 0);
8984
-
8985
- _defineProperty(this, "commission", void 0);
8986
-
8987
- _defineProperty(this, "votes", void 0);
8988
-
8989
- _defineProperty(this, "rootSlot", void 0);
8990
-
8991
- _defineProperty(this, "epoch", void 0);
8992
-
8993
- _defineProperty(this, "credits", void 0);
8994
-
8995
- _defineProperty(this, "lastEpochCredits", void 0);
8996
-
8997
- _defineProperty(this, "epochCredits", void 0);
8998
-
8953
+ this.nodePubkey = void 0;
8954
+ this.authorizedWithdrawer = void 0;
8955
+ this.commission = void 0;
8956
+ this.rootSlot = void 0;
8957
+ this.votes = void 0;
8958
+ this.authorizedVoters = void 0;
8959
+ this.priorVoters = void 0;
8960
+ this.epochCredits = void 0;
8961
+ this.lastTimestamp = void 0;
8999
8962
  this.nodePubkey = args.nodePubkey;
9000
- this.authorizedVoterPubkey = args.authorizedVoterPubkey;
9001
- this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;
8963
+ this.authorizedWithdrawer = args.authorizedWithdrawer;
9002
8964
  this.commission = args.commission;
9003
- this.votes = args.votes;
9004
8965
  this.rootSlot = args.rootSlot;
9005
- this.epoch = args.epoch;
9006
- this.credits = args.credits;
9007
- this.lastEpochCredits = args.lastEpochCredits;
8966
+ this.votes = args.votes;
8967
+ this.authorizedVoters = args.authorizedVoters;
8968
+ this.priorVoters = args.priorVoters;
9008
8969
  this.epochCredits = args.epochCredits;
8970
+ this.lastTimestamp = args.lastTimestamp;
9009
8971
  }
9010
8972
  /**
9011
8973
  * Deserialize VoteAccount from the account data.
@@ -9016,7 +8978,8 @@ class VoteAccount {
9016
8978
 
9017
8979
 
9018
8980
  static fromAccountData(buffer) {
9019
- const va = VoteAccountLayout.decode(toBuffer(buffer), 0);
8981
+ const versionOffset = 4;
8982
+ const va = VoteAccountLayout.decode(toBuffer(buffer), versionOffset);
9020
8983
  let rootSlot = va.rootSlot;
9021
8984
 
9022
8985
  if (!va.rootSlotValid) {
@@ -9025,20 +8988,53 @@ class VoteAccount {
9025
8988
 
9026
8989
  return new VoteAccount({
9027
8990
  nodePubkey: new PublicKey(va.nodePubkey),
9028
- authorizedVoterPubkey: new PublicKey(va.authorizedVoterPubkey),
9029
- authorizedWithdrawerPubkey: new PublicKey(va.authorizedWithdrawerPubkey),
8991
+ authorizedWithdrawer: new PublicKey(va.authorizedWithdrawer),
9030
8992
  commission: va.commission,
9031
8993
  votes: va.votes,
9032
8994
  rootSlot,
9033
- epoch: va.epoch,
9034
- credits: va.credits,
9035
- lastEpochCredits: va.lastEpochCredits,
9036
- epochCredits: va.epochCredits
8995
+ authorizedVoters: va.authorizedVoters.map(parseAuthorizedVoter),
8996
+ priorVoters: getPriorVoters(va.priorVoters),
8997
+ epochCredits: va.epochCredits,
8998
+ lastTimestamp: va.lastTimestamp
9037
8999
  });
9038
9000
  }
9039
9001
 
9040
9002
  }
9041
9003
 
9004
+ function parseAuthorizedVoter({
9005
+ epoch,
9006
+ authorizedVoter
9007
+ }) {
9008
+ return {
9009
+ epoch,
9010
+ authorizedVoter: new PublicKey(authorizedVoter)
9011
+ };
9012
+ }
9013
+
9014
+ function parsePriorVoters({
9015
+ authorizedPubkey,
9016
+ epochOfLastAuthorizedSwitch,
9017
+ targetEpoch
9018
+ }) {
9019
+ return {
9020
+ authorizedPubkey: new PublicKey(authorizedPubkey),
9021
+ epochOfLastAuthorizedSwitch,
9022
+ targetEpoch
9023
+ };
9024
+ }
9025
+
9026
+ function getPriorVoters({
9027
+ buf,
9028
+ idx,
9029
+ isEmpty
9030
+ }) {
9031
+ if (isEmpty) {
9032
+ return [];
9033
+ }
9034
+
9035
+ return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx)];
9036
+ }
9037
+
9042
9038
  /**
9043
9039
  * Send and confirm a raw transaction
9044
9040
  *
@@ -9058,7 +9054,7 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, options)
9058
9054
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
9059
9055
 
9060
9056
  if (status.err) {
9061
- throw new Error("Raw transaction ".concat(signature, " failed (").concat(JSON.stringify(status), ")"));
9057
+ throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
9062
9058
  }
9063
9059
 
9064
9060
  return signature;
@@ -9090,7 +9086,7 @@ function clusterApiUrl(cluster, tls) {
9090
9086
  const url = endpoint[key][cluster];
9091
9087
 
9092
9088
  if (!url) {
9093
- throw new Error("Unknown ".concat(key, " cluster: ").concat(cluster));
9089
+ throw new Error(`Unknown ${key} cluster: ${cluster}`);
9094
9090
  }
9095
9091
 
9096
9092
  return url;
@@ -9102,5 +9098,5 @@ function clusterApiUrl(cluster, tls) {
9102
9098
 
9103
9099
  const LAMPORTS_PER_SOL = 1000000000;
9104
9100
 
9105
- 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 };
9101
+ 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 };
9106
9102
  //# sourceMappingURL=index.browser.esm.js.map