@solana/web3.js 1.29.2 → 1.30.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs.js CHANGED
@@ -2,12 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
5
  var nacl = require('tweetnacl');
7
6
  var buffer = require('buffer');
8
7
  var BN = require('bn.js');
9
8
  var bs58 = require('bs58');
10
- var cryptoHash = require('crypto-hash');
11
9
  var borsh = require('borsh');
12
10
  var BufferLayout = require('@solana/buffer-layout');
13
11
  var fetch = require('cross-fetch');
@@ -39,7 +37,6 @@ function _interopNamespace(e) {
39
37
  return Object.freeze(n);
40
38
  }
41
39
 
42
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
43
40
  var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
44
41
  var nacl__namespace = /*#__PURE__*/_interopNamespace(nacl);
45
42
  var BN__default = /*#__PURE__*/_interopDefaultLegacy(BN);
@@ -61,6 +58,1683 @@ const toBuffer = arr => {
61
58
  }
62
59
  };
63
60
 
61
+ var hash$1 = {};
62
+
63
+ var utils$9 = {};
64
+
65
+ var minimalisticAssert = assert$6;
66
+
67
+ function assert$6(val, msg) {
68
+ if (!val)
69
+ throw new Error(msg || 'Assertion failed');
70
+ }
71
+
72
+ assert$6.equal = function assertEqual(l, r, msg) {
73
+ if (l != r)
74
+ throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
75
+ };
76
+
77
+ var inherits$1 = {exports: {}};
78
+
79
+ var inherits_browser = {exports: {}};
80
+
81
+ if (typeof Object.create === 'function') {
82
+ // implementation from standard node.js 'util' module
83
+ inherits_browser.exports = function inherits(ctor, superCtor) {
84
+ ctor.super_ = superCtor;
85
+ ctor.prototype = Object.create(superCtor.prototype, {
86
+ constructor: {
87
+ value: ctor,
88
+ enumerable: false,
89
+ writable: true,
90
+ configurable: true
91
+ }
92
+ });
93
+ };
94
+ } else {
95
+ // old school shim for old browsers
96
+ inherits_browser.exports = function inherits(ctor, superCtor) {
97
+ ctor.super_ = superCtor;
98
+ var TempCtor = function () {};
99
+ TempCtor.prototype = superCtor.prototype;
100
+ ctor.prototype = new TempCtor();
101
+ ctor.prototype.constructor = ctor;
102
+ };
103
+ }
104
+
105
+ try {
106
+ var util = require('util');
107
+ if (typeof util.inherits !== 'function') throw '';
108
+ inherits$1.exports = util.inherits;
109
+ } catch (e) {
110
+ inherits$1.exports = inherits_browser.exports;
111
+ }
112
+
113
+ var assert$5 = minimalisticAssert;
114
+ var inherits = inherits$1.exports;
115
+
116
+ utils$9.inherits = inherits;
117
+
118
+ function isSurrogatePair(msg, i) {
119
+ if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
120
+ return false;
121
+ }
122
+ if (i < 0 || i + 1 >= msg.length) {
123
+ return false;
124
+ }
125
+ return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
126
+ }
127
+
128
+ function toArray(msg, enc) {
129
+ if (Array.isArray(msg))
130
+ return msg.slice();
131
+ if (!msg)
132
+ return [];
133
+ var res = [];
134
+ if (typeof msg === 'string') {
135
+ if (!enc) {
136
+ // Inspired by stringToUtf8ByteArray() in closure-library by Google
137
+ // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
138
+ // Apache License 2.0
139
+ // https://github.com/google/closure-library/blob/master/LICENSE
140
+ var p = 0;
141
+ for (var i = 0; i < msg.length; i++) {
142
+ var c = msg.charCodeAt(i);
143
+ if (c < 128) {
144
+ res[p++] = c;
145
+ } else if (c < 2048) {
146
+ res[p++] = (c >> 6) | 192;
147
+ res[p++] = (c & 63) | 128;
148
+ } else if (isSurrogatePair(msg, i)) {
149
+ c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
150
+ res[p++] = (c >> 18) | 240;
151
+ res[p++] = ((c >> 12) & 63) | 128;
152
+ res[p++] = ((c >> 6) & 63) | 128;
153
+ res[p++] = (c & 63) | 128;
154
+ } else {
155
+ res[p++] = (c >> 12) | 224;
156
+ res[p++] = ((c >> 6) & 63) | 128;
157
+ res[p++] = (c & 63) | 128;
158
+ }
159
+ }
160
+ } else if (enc === 'hex') {
161
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
162
+ if (msg.length % 2 !== 0)
163
+ msg = '0' + msg;
164
+ for (i = 0; i < msg.length; i += 2)
165
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
166
+ }
167
+ } else {
168
+ for (i = 0; i < msg.length; i++)
169
+ res[i] = msg[i] | 0;
170
+ }
171
+ return res;
172
+ }
173
+ utils$9.toArray = toArray;
174
+
175
+ function toHex(msg) {
176
+ var res = '';
177
+ for (var i = 0; i < msg.length; i++)
178
+ res += zero2(msg[i].toString(16));
179
+ return res;
180
+ }
181
+ utils$9.toHex = toHex;
182
+
183
+ function htonl(w) {
184
+ var res = (w >>> 24) |
185
+ ((w >>> 8) & 0xff00) |
186
+ ((w << 8) & 0xff0000) |
187
+ ((w & 0xff) << 24);
188
+ return res >>> 0;
189
+ }
190
+ utils$9.htonl = htonl;
191
+
192
+ function toHex32(msg, endian) {
193
+ var res = '';
194
+ for (var i = 0; i < msg.length; i++) {
195
+ var w = msg[i];
196
+ if (endian === 'little')
197
+ w = htonl(w);
198
+ res += zero8(w.toString(16));
199
+ }
200
+ return res;
201
+ }
202
+ utils$9.toHex32 = toHex32;
203
+
204
+ function zero2(word) {
205
+ if (word.length === 1)
206
+ return '0' + word;
207
+ else
208
+ return word;
209
+ }
210
+ utils$9.zero2 = zero2;
211
+
212
+ function zero8(word) {
213
+ if (word.length === 7)
214
+ return '0' + word;
215
+ else if (word.length === 6)
216
+ return '00' + word;
217
+ else if (word.length === 5)
218
+ return '000' + word;
219
+ else if (word.length === 4)
220
+ return '0000' + word;
221
+ else if (word.length === 3)
222
+ return '00000' + word;
223
+ else if (word.length === 2)
224
+ return '000000' + word;
225
+ else if (word.length === 1)
226
+ return '0000000' + word;
227
+ else
228
+ return word;
229
+ }
230
+ utils$9.zero8 = zero8;
231
+
232
+ function join32(msg, start, end, endian) {
233
+ var len = end - start;
234
+ assert$5(len % 4 === 0);
235
+ var res = new Array(len / 4);
236
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
237
+ var w;
238
+ if (endian === 'big')
239
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
240
+ else
241
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
242
+ res[i] = w >>> 0;
243
+ }
244
+ return res;
245
+ }
246
+ utils$9.join32 = join32;
247
+
248
+ function split32(msg, endian) {
249
+ var res = new Array(msg.length * 4);
250
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
251
+ var m = msg[i];
252
+ if (endian === 'big') {
253
+ res[k] = m >>> 24;
254
+ res[k + 1] = (m >>> 16) & 0xff;
255
+ res[k + 2] = (m >>> 8) & 0xff;
256
+ res[k + 3] = m & 0xff;
257
+ } else {
258
+ res[k + 3] = m >>> 24;
259
+ res[k + 2] = (m >>> 16) & 0xff;
260
+ res[k + 1] = (m >>> 8) & 0xff;
261
+ res[k] = m & 0xff;
262
+ }
263
+ }
264
+ return res;
265
+ }
266
+ utils$9.split32 = split32;
267
+
268
+ function rotr32$1(w, b) {
269
+ return (w >>> b) | (w << (32 - b));
270
+ }
271
+ utils$9.rotr32 = rotr32$1;
272
+
273
+ function rotl32$2(w, b) {
274
+ return (w << b) | (w >>> (32 - b));
275
+ }
276
+ utils$9.rotl32 = rotl32$2;
277
+
278
+ function sum32$3(a, b) {
279
+ return (a + b) >>> 0;
280
+ }
281
+ utils$9.sum32 = sum32$3;
282
+
283
+ function sum32_3$1(a, b, c) {
284
+ return (a + b + c) >>> 0;
285
+ }
286
+ utils$9.sum32_3 = sum32_3$1;
287
+
288
+ function sum32_4$2(a, b, c, d) {
289
+ return (a + b + c + d) >>> 0;
290
+ }
291
+ utils$9.sum32_4 = sum32_4$2;
292
+
293
+ function sum32_5$2(a, b, c, d, e) {
294
+ return (a + b + c + d + e) >>> 0;
295
+ }
296
+ utils$9.sum32_5 = sum32_5$2;
297
+
298
+ function sum64$1(buf, pos, ah, al) {
299
+ var bh = buf[pos];
300
+ var bl = buf[pos + 1];
301
+
302
+ var lo = (al + bl) >>> 0;
303
+ var hi = (lo < al ? 1 : 0) + ah + bh;
304
+ buf[pos] = hi >>> 0;
305
+ buf[pos + 1] = lo;
306
+ }
307
+ utils$9.sum64 = sum64$1;
308
+
309
+ function sum64_hi$1(ah, al, bh, bl) {
310
+ var lo = (al + bl) >>> 0;
311
+ var hi = (lo < al ? 1 : 0) + ah + bh;
312
+ return hi >>> 0;
313
+ }
314
+ utils$9.sum64_hi = sum64_hi$1;
315
+
316
+ function sum64_lo$1(ah, al, bh, bl) {
317
+ var lo = al + bl;
318
+ return lo >>> 0;
319
+ }
320
+ utils$9.sum64_lo = sum64_lo$1;
321
+
322
+ function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
323
+ var carry = 0;
324
+ var lo = al;
325
+ lo = (lo + bl) >>> 0;
326
+ carry += lo < al ? 1 : 0;
327
+ lo = (lo + cl) >>> 0;
328
+ carry += lo < cl ? 1 : 0;
329
+ lo = (lo + dl) >>> 0;
330
+ carry += lo < dl ? 1 : 0;
331
+
332
+ var hi = ah + bh + ch + dh + carry;
333
+ return hi >>> 0;
334
+ }
335
+ utils$9.sum64_4_hi = sum64_4_hi$1;
336
+
337
+ function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
338
+ var lo = al + bl + cl + dl;
339
+ return lo >>> 0;
340
+ }
341
+ utils$9.sum64_4_lo = sum64_4_lo$1;
342
+
343
+ function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
344
+ var carry = 0;
345
+ var lo = al;
346
+ lo = (lo + bl) >>> 0;
347
+ carry += lo < al ? 1 : 0;
348
+ lo = (lo + cl) >>> 0;
349
+ carry += lo < cl ? 1 : 0;
350
+ lo = (lo + dl) >>> 0;
351
+ carry += lo < dl ? 1 : 0;
352
+ lo = (lo + el) >>> 0;
353
+ carry += lo < el ? 1 : 0;
354
+
355
+ var hi = ah + bh + ch + dh + eh + carry;
356
+ return hi >>> 0;
357
+ }
358
+ utils$9.sum64_5_hi = sum64_5_hi$1;
359
+
360
+ function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
361
+ var lo = al + bl + cl + dl + el;
362
+
363
+ return lo >>> 0;
364
+ }
365
+ utils$9.sum64_5_lo = sum64_5_lo$1;
366
+
367
+ function rotr64_hi$1(ah, al, num) {
368
+ var r = (al << (32 - num)) | (ah >>> num);
369
+ return r >>> 0;
370
+ }
371
+ utils$9.rotr64_hi = rotr64_hi$1;
372
+
373
+ function rotr64_lo$1(ah, al, num) {
374
+ var r = (ah << (32 - num)) | (al >>> num);
375
+ return r >>> 0;
376
+ }
377
+ utils$9.rotr64_lo = rotr64_lo$1;
378
+
379
+ function shr64_hi$1(ah, al, num) {
380
+ return ah >>> num;
381
+ }
382
+ utils$9.shr64_hi = shr64_hi$1;
383
+
384
+ function shr64_lo$1(ah, al, num) {
385
+ var r = (ah << (32 - num)) | (al >>> num);
386
+ return r >>> 0;
387
+ }
388
+ utils$9.shr64_lo = shr64_lo$1;
389
+
390
+ var common$5 = {};
391
+
392
+ var utils$8 = utils$9;
393
+ var assert$4 = minimalisticAssert;
394
+
395
+ function BlockHash$4() {
396
+ this.pending = null;
397
+ this.pendingTotal = 0;
398
+ this.blockSize = this.constructor.blockSize;
399
+ this.outSize = this.constructor.outSize;
400
+ this.hmacStrength = this.constructor.hmacStrength;
401
+ this.padLength = this.constructor.padLength / 8;
402
+ this.endian = 'big';
403
+
404
+ this._delta8 = this.blockSize / 8;
405
+ this._delta32 = this.blockSize / 32;
406
+ }
407
+ common$5.BlockHash = BlockHash$4;
408
+
409
+ BlockHash$4.prototype.update = function update(msg, enc) {
410
+ // Convert message to array, pad it, and join into 32bit blocks
411
+ msg = utils$8.toArray(msg, enc);
412
+ if (!this.pending)
413
+ this.pending = msg;
414
+ else
415
+ this.pending = this.pending.concat(msg);
416
+ this.pendingTotal += msg.length;
417
+
418
+ // Enough data, try updating
419
+ if (this.pending.length >= this._delta8) {
420
+ msg = this.pending;
421
+
422
+ // Process pending data in blocks
423
+ var r = msg.length % this._delta8;
424
+ this.pending = msg.slice(msg.length - r, msg.length);
425
+ if (this.pending.length === 0)
426
+ this.pending = null;
427
+
428
+ msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
429
+ for (var i = 0; i < msg.length; i += this._delta32)
430
+ this._update(msg, i, i + this._delta32);
431
+ }
432
+
433
+ return this;
434
+ };
435
+
436
+ BlockHash$4.prototype.digest = function digest(enc) {
437
+ this.update(this._pad());
438
+ assert$4(this.pending === null);
439
+
440
+ return this._digest(enc);
441
+ };
442
+
443
+ BlockHash$4.prototype._pad = function pad() {
444
+ var len = this.pendingTotal;
445
+ var bytes = this._delta8;
446
+ var k = bytes - ((len + this.padLength) % bytes);
447
+ var res = new Array(k + this.padLength);
448
+ res[0] = 0x80;
449
+ for (var i = 1; i < k; i++)
450
+ res[i] = 0;
451
+
452
+ // Append length
453
+ len <<= 3;
454
+ if (this.endian === 'big') {
455
+ for (var t = 8; t < this.padLength; t++)
456
+ res[i++] = 0;
457
+
458
+ res[i++] = 0;
459
+ res[i++] = 0;
460
+ res[i++] = 0;
461
+ res[i++] = 0;
462
+ res[i++] = (len >>> 24) & 0xff;
463
+ res[i++] = (len >>> 16) & 0xff;
464
+ res[i++] = (len >>> 8) & 0xff;
465
+ res[i++] = len & 0xff;
466
+ } else {
467
+ res[i++] = len & 0xff;
468
+ res[i++] = (len >>> 8) & 0xff;
469
+ res[i++] = (len >>> 16) & 0xff;
470
+ res[i++] = (len >>> 24) & 0xff;
471
+ res[i++] = 0;
472
+ res[i++] = 0;
473
+ res[i++] = 0;
474
+ res[i++] = 0;
475
+
476
+ for (t = 8; t < this.padLength; t++)
477
+ res[i++] = 0;
478
+ }
479
+
480
+ return res;
481
+ };
482
+
483
+ var sha = {};
484
+
485
+ var common$4 = {};
486
+
487
+ var utils$7 = utils$9;
488
+ var rotr32 = utils$7.rotr32;
489
+
490
+ function ft_1$1(s, x, y, z) {
491
+ if (s === 0)
492
+ return ch32$1(x, y, z);
493
+ if (s === 1 || s === 3)
494
+ return p32(x, y, z);
495
+ if (s === 2)
496
+ return maj32$1(x, y, z);
497
+ }
498
+ common$4.ft_1 = ft_1$1;
499
+
500
+ function ch32$1(x, y, z) {
501
+ return (x & y) ^ ((~x) & z);
502
+ }
503
+ common$4.ch32 = ch32$1;
504
+
505
+ function maj32$1(x, y, z) {
506
+ return (x & y) ^ (x & z) ^ (y & z);
507
+ }
508
+ common$4.maj32 = maj32$1;
509
+
510
+ function p32(x, y, z) {
511
+ return x ^ y ^ z;
512
+ }
513
+ common$4.p32 = p32;
514
+
515
+ function s0_256$1(x) {
516
+ return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
517
+ }
518
+ common$4.s0_256 = s0_256$1;
519
+
520
+ function s1_256$1(x) {
521
+ return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
522
+ }
523
+ common$4.s1_256 = s1_256$1;
524
+
525
+ function g0_256$1(x) {
526
+ return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
527
+ }
528
+ common$4.g0_256 = g0_256$1;
529
+
530
+ function g1_256$1(x) {
531
+ return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
532
+ }
533
+ common$4.g1_256 = g1_256$1;
534
+
535
+ var utils$6 = utils$9;
536
+ var common$3 = common$5;
537
+ var shaCommon$1 = common$4;
538
+
539
+ var rotl32$1 = utils$6.rotl32;
540
+ var sum32$2 = utils$6.sum32;
541
+ var sum32_5$1 = utils$6.sum32_5;
542
+ var ft_1 = shaCommon$1.ft_1;
543
+ var BlockHash$3 = common$3.BlockHash;
544
+
545
+ var sha1_K = [
546
+ 0x5A827999, 0x6ED9EBA1,
547
+ 0x8F1BBCDC, 0xCA62C1D6
548
+ ];
549
+
550
+ function SHA1() {
551
+ if (!(this instanceof SHA1))
552
+ return new SHA1();
553
+
554
+ BlockHash$3.call(this);
555
+ this.h = [
556
+ 0x67452301, 0xefcdab89, 0x98badcfe,
557
+ 0x10325476, 0xc3d2e1f0 ];
558
+ this.W = new Array(80);
559
+ }
560
+
561
+ utils$6.inherits(SHA1, BlockHash$3);
562
+ var _1 = SHA1;
563
+
564
+ SHA1.blockSize = 512;
565
+ SHA1.outSize = 160;
566
+ SHA1.hmacStrength = 80;
567
+ SHA1.padLength = 64;
568
+
569
+ SHA1.prototype._update = function _update(msg, start) {
570
+ var W = this.W;
571
+
572
+ for (var i = 0; i < 16; i++)
573
+ W[i] = msg[start + i];
574
+
575
+ for(; i < W.length; i++)
576
+ W[i] = rotl32$1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
577
+
578
+ var a = this.h[0];
579
+ var b = this.h[1];
580
+ var c = this.h[2];
581
+ var d = this.h[3];
582
+ var e = this.h[4];
583
+
584
+ for (i = 0; i < W.length; i++) {
585
+ var s = ~~(i / 20);
586
+ var t = sum32_5$1(rotl32$1(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
587
+ e = d;
588
+ d = c;
589
+ c = rotl32$1(b, 30);
590
+ b = a;
591
+ a = t;
592
+ }
593
+
594
+ this.h[0] = sum32$2(this.h[0], a);
595
+ this.h[1] = sum32$2(this.h[1], b);
596
+ this.h[2] = sum32$2(this.h[2], c);
597
+ this.h[3] = sum32$2(this.h[3], d);
598
+ this.h[4] = sum32$2(this.h[4], e);
599
+ };
600
+
601
+ SHA1.prototype._digest = function digest(enc) {
602
+ if (enc === 'hex')
603
+ return utils$6.toHex32(this.h, 'big');
604
+ else
605
+ return utils$6.split32(this.h, 'big');
606
+ };
607
+
608
+ var utils$5 = utils$9;
609
+ var common$2 = common$5;
610
+ var shaCommon = common$4;
611
+ var assert$3 = minimalisticAssert;
612
+
613
+ var sum32$1 = utils$5.sum32;
614
+ var sum32_4$1 = utils$5.sum32_4;
615
+ var sum32_5 = utils$5.sum32_5;
616
+ var ch32 = shaCommon.ch32;
617
+ var maj32 = shaCommon.maj32;
618
+ var s0_256 = shaCommon.s0_256;
619
+ var s1_256 = shaCommon.s1_256;
620
+ var g0_256 = shaCommon.g0_256;
621
+ var g1_256 = shaCommon.g1_256;
622
+
623
+ var BlockHash$2 = common$2.BlockHash;
624
+
625
+ var sha256_K = [
626
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
627
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
628
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
629
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
630
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
631
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
632
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
633
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
634
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
635
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
636
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
637
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
638
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
639
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
640
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
641
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
642
+ ];
643
+
644
+ function SHA256$1() {
645
+ if (!(this instanceof SHA256$1))
646
+ return new SHA256$1();
647
+
648
+ BlockHash$2.call(this);
649
+ this.h = [
650
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
651
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
652
+ ];
653
+ this.k = sha256_K;
654
+ this.W = new Array(64);
655
+ }
656
+ utils$5.inherits(SHA256$1, BlockHash$2);
657
+ var _256 = SHA256$1;
658
+
659
+ SHA256$1.blockSize = 512;
660
+ SHA256$1.outSize = 256;
661
+ SHA256$1.hmacStrength = 192;
662
+ SHA256$1.padLength = 64;
663
+
664
+ SHA256$1.prototype._update = function _update(msg, start) {
665
+ var W = this.W;
666
+
667
+ for (var i = 0; i < 16; i++)
668
+ W[i] = msg[start + i];
669
+ for (; i < W.length; i++)
670
+ W[i] = sum32_4$1(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
671
+
672
+ var a = this.h[0];
673
+ var b = this.h[1];
674
+ var c = this.h[2];
675
+ var d = this.h[3];
676
+ var e = this.h[4];
677
+ var f = this.h[5];
678
+ var g = this.h[6];
679
+ var h = this.h[7];
680
+
681
+ assert$3(this.k.length === W.length);
682
+ for (i = 0; i < W.length; i++) {
683
+ var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
684
+ var T2 = sum32$1(s0_256(a), maj32(a, b, c));
685
+ h = g;
686
+ g = f;
687
+ f = e;
688
+ e = sum32$1(d, T1);
689
+ d = c;
690
+ c = b;
691
+ b = a;
692
+ a = sum32$1(T1, T2);
693
+ }
694
+
695
+ this.h[0] = sum32$1(this.h[0], a);
696
+ this.h[1] = sum32$1(this.h[1], b);
697
+ this.h[2] = sum32$1(this.h[2], c);
698
+ this.h[3] = sum32$1(this.h[3], d);
699
+ this.h[4] = sum32$1(this.h[4], e);
700
+ this.h[5] = sum32$1(this.h[5], f);
701
+ this.h[6] = sum32$1(this.h[6], g);
702
+ this.h[7] = sum32$1(this.h[7], h);
703
+ };
704
+
705
+ SHA256$1.prototype._digest = function digest(enc) {
706
+ if (enc === 'hex')
707
+ return utils$5.toHex32(this.h, 'big');
708
+ else
709
+ return utils$5.split32(this.h, 'big');
710
+ };
711
+
712
+ var utils$4 = utils$9;
713
+ var SHA256 = _256;
714
+
715
+ function SHA224() {
716
+ if (!(this instanceof SHA224))
717
+ return new SHA224();
718
+
719
+ SHA256.call(this);
720
+ this.h = [
721
+ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
722
+ 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
723
+ }
724
+ utils$4.inherits(SHA224, SHA256);
725
+ var _224 = SHA224;
726
+
727
+ SHA224.blockSize = 512;
728
+ SHA224.outSize = 224;
729
+ SHA224.hmacStrength = 192;
730
+ SHA224.padLength = 64;
731
+
732
+ SHA224.prototype._digest = function digest(enc) {
733
+ // Just truncate output
734
+ if (enc === 'hex')
735
+ return utils$4.toHex32(this.h.slice(0, 7), 'big');
736
+ else
737
+ return utils$4.split32(this.h.slice(0, 7), 'big');
738
+ };
739
+
740
+ var utils$3 = utils$9;
741
+ var common$1 = common$5;
742
+ var assert$2 = minimalisticAssert;
743
+
744
+ var rotr64_hi = utils$3.rotr64_hi;
745
+ var rotr64_lo = utils$3.rotr64_lo;
746
+ var shr64_hi = utils$3.shr64_hi;
747
+ var shr64_lo = utils$3.shr64_lo;
748
+ var sum64 = utils$3.sum64;
749
+ var sum64_hi = utils$3.sum64_hi;
750
+ var sum64_lo = utils$3.sum64_lo;
751
+ var sum64_4_hi = utils$3.sum64_4_hi;
752
+ var sum64_4_lo = utils$3.sum64_4_lo;
753
+ var sum64_5_hi = utils$3.sum64_5_hi;
754
+ var sum64_5_lo = utils$3.sum64_5_lo;
755
+
756
+ var BlockHash$1 = common$1.BlockHash;
757
+
758
+ var sha512_K = [
759
+ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
760
+ 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
761
+ 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
762
+ 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
763
+ 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
764
+ 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
765
+ 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
766
+ 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
767
+ 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
768
+ 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
769
+ 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
770
+ 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
771
+ 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
772
+ 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
773
+ 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
774
+ 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
775
+ 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
776
+ 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
777
+ 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
778
+ 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
779
+ 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
780
+ 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
781
+ 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
782
+ 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
783
+ 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
784
+ 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
785
+ 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
786
+ 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
787
+ 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
788
+ 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
789
+ 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
790
+ 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
791
+ 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
792
+ 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
793
+ 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
794
+ 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
795
+ 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
796
+ 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
797
+ 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
798
+ 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
799
+ ];
800
+
801
+ function SHA512$1() {
802
+ if (!(this instanceof SHA512$1))
803
+ return new SHA512$1();
804
+
805
+ BlockHash$1.call(this);
806
+ this.h = [
807
+ 0x6a09e667, 0xf3bcc908,
808
+ 0xbb67ae85, 0x84caa73b,
809
+ 0x3c6ef372, 0xfe94f82b,
810
+ 0xa54ff53a, 0x5f1d36f1,
811
+ 0x510e527f, 0xade682d1,
812
+ 0x9b05688c, 0x2b3e6c1f,
813
+ 0x1f83d9ab, 0xfb41bd6b,
814
+ 0x5be0cd19, 0x137e2179 ];
815
+ this.k = sha512_K;
816
+ this.W = new Array(160);
817
+ }
818
+ utils$3.inherits(SHA512$1, BlockHash$1);
819
+ var _512 = SHA512$1;
820
+
821
+ SHA512$1.blockSize = 1024;
822
+ SHA512$1.outSize = 512;
823
+ SHA512$1.hmacStrength = 192;
824
+ SHA512$1.padLength = 128;
825
+
826
+ SHA512$1.prototype._prepareBlock = function _prepareBlock(msg, start) {
827
+ var W = this.W;
828
+
829
+ // 32 x 32bit words
830
+ for (var i = 0; i < 32; i++)
831
+ W[i] = msg[start + i];
832
+ for (; i < W.length; i += 2) {
833
+ var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
834
+ var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
835
+ var c1_hi = W[i - 14]; // i - 7
836
+ var c1_lo = W[i - 13];
837
+ var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
838
+ var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
839
+ var c3_hi = W[i - 32]; // i - 16
840
+ var c3_lo = W[i - 31];
841
+
842
+ W[i] = sum64_4_hi(
843
+ c0_hi, c0_lo,
844
+ c1_hi, c1_lo,
845
+ c2_hi, c2_lo,
846
+ c3_hi, c3_lo);
847
+ W[i + 1] = sum64_4_lo(
848
+ c0_hi, c0_lo,
849
+ c1_hi, c1_lo,
850
+ c2_hi, c2_lo,
851
+ c3_hi, c3_lo);
852
+ }
853
+ };
854
+
855
+ SHA512$1.prototype._update = function _update(msg, start) {
856
+ this._prepareBlock(msg, start);
857
+
858
+ var W = this.W;
859
+
860
+ var ah = this.h[0];
861
+ var al = this.h[1];
862
+ var bh = this.h[2];
863
+ var bl = this.h[3];
864
+ var ch = this.h[4];
865
+ var cl = this.h[5];
866
+ var dh = this.h[6];
867
+ var dl = this.h[7];
868
+ var eh = this.h[8];
869
+ var el = this.h[9];
870
+ var fh = this.h[10];
871
+ var fl = this.h[11];
872
+ var gh = this.h[12];
873
+ var gl = this.h[13];
874
+ var hh = this.h[14];
875
+ var hl = this.h[15];
876
+
877
+ assert$2(this.k.length === W.length);
878
+ for (var i = 0; i < W.length; i += 2) {
879
+ var c0_hi = hh;
880
+ var c0_lo = hl;
881
+ var c1_hi = s1_512_hi(eh, el);
882
+ var c1_lo = s1_512_lo(eh, el);
883
+ var c2_hi = ch64_hi(eh, el, fh, fl, gh);
884
+ var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
885
+ var c3_hi = this.k[i];
886
+ var c3_lo = this.k[i + 1];
887
+ var c4_hi = W[i];
888
+ var c4_lo = W[i + 1];
889
+
890
+ var T1_hi = sum64_5_hi(
891
+ c0_hi, c0_lo,
892
+ c1_hi, c1_lo,
893
+ c2_hi, c2_lo,
894
+ c3_hi, c3_lo,
895
+ c4_hi, c4_lo);
896
+ var T1_lo = sum64_5_lo(
897
+ c0_hi, c0_lo,
898
+ c1_hi, c1_lo,
899
+ c2_hi, c2_lo,
900
+ c3_hi, c3_lo,
901
+ c4_hi, c4_lo);
902
+
903
+ c0_hi = s0_512_hi(ah, al);
904
+ c0_lo = s0_512_lo(ah, al);
905
+ c1_hi = maj64_hi(ah, al, bh, bl, ch);
906
+ c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
907
+
908
+ var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
909
+ var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
910
+
911
+ hh = gh;
912
+ hl = gl;
913
+
914
+ gh = fh;
915
+ gl = fl;
916
+
917
+ fh = eh;
918
+ fl = el;
919
+
920
+ eh = sum64_hi(dh, dl, T1_hi, T1_lo);
921
+ el = sum64_lo(dl, dl, T1_hi, T1_lo);
922
+
923
+ dh = ch;
924
+ dl = cl;
925
+
926
+ ch = bh;
927
+ cl = bl;
928
+
929
+ bh = ah;
930
+ bl = al;
931
+
932
+ ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
933
+ al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
934
+ }
935
+
936
+ sum64(this.h, 0, ah, al);
937
+ sum64(this.h, 2, bh, bl);
938
+ sum64(this.h, 4, ch, cl);
939
+ sum64(this.h, 6, dh, dl);
940
+ sum64(this.h, 8, eh, el);
941
+ sum64(this.h, 10, fh, fl);
942
+ sum64(this.h, 12, gh, gl);
943
+ sum64(this.h, 14, hh, hl);
944
+ };
945
+
946
+ SHA512$1.prototype._digest = function digest(enc) {
947
+ if (enc === 'hex')
948
+ return utils$3.toHex32(this.h, 'big');
949
+ else
950
+ return utils$3.split32(this.h, 'big');
951
+ };
952
+
953
+ function ch64_hi(xh, xl, yh, yl, zh) {
954
+ var r = (xh & yh) ^ ((~xh) & zh);
955
+ if (r < 0)
956
+ r += 0x100000000;
957
+ return r;
958
+ }
959
+
960
+ function ch64_lo(xh, xl, yh, yl, zh, zl) {
961
+ var r = (xl & yl) ^ ((~xl) & zl);
962
+ if (r < 0)
963
+ r += 0x100000000;
964
+ return r;
965
+ }
966
+
967
+ function maj64_hi(xh, xl, yh, yl, zh) {
968
+ var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
969
+ if (r < 0)
970
+ r += 0x100000000;
971
+ return r;
972
+ }
973
+
974
+ function maj64_lo(xh, xl, yh, yl, zh, zl) {
975
+ var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
976
+ if (r < 0)
977
+ r += 0x100000000;
978
+ return r;
979
+ }
980
+
981
+ function s0_512_hi(xh, xl) {
982
+ var c0_hi = rotr64_hi(xh, xl, 28);
983
+ var c1_hi = rotr64_hi(xl, xh, 2); // 34
984
+ var c2_hi = rotr64_hi(xl, xh, 7); // 39
985
+
986
+ var r = c0_hi ^ c1_hi ^ c2_hi;
987
+ if (r < 0)
988
+ r += 0x100000000;
989
+ return r;
990
+ }
991
+
992
+ function s0_512_lo(xh, xl) {
993
+ var c0_lo = rotr64_lo(xh, xl, 28);
994
+ var c1_lo = rotr64_lo(xl, xh, 2); // 34
995
+ var c2_lo = rotr64_lo(xl, xh, 7); // 39
996
+
997
+ var r = c0_lo ^ c1_lo ^ c2_lo;
998
+ if (r < 0)
999
+ r += 0x100000000;
1000
+ return r;
1001
+ }
1002
+
1003
+ function s1_512_hi(xh, xl) {
1004
+ var c0_hi = rotr64_hi(xh, xl, 14);
1005
+ var c1_hi = rotr64_hi(xh, xl, 18);
1006
+ var c2_hi = rotr64_hi(xl, xh, 9); // 41
1007
+
1008
+ var r = c0_hi ^ c1_hi ^ c2_hi;
1009
+ if (r < 0)
1010
+ r += 0x100000000;
1011
+ return r;
1012
+ }
1013
+
1014
+ function s1_512_lo(xh, xl) {
1015
+ var c0_lo = rotr64_lo(xh, xl, 14);
1016
+ var c1_lo = rotr64_lo(xh, xl, 18);
1017
+ var c2_lo = rotr64_lo(xl, xh, 9); // 41
1018
+
1019
+ var r = c0_lo ^ c1_lo ^ c2_lo;
1020
+ if (r < 0)
1021
+ r += 0x100000000;
1022
+ return r;
1023
+ }
1024
+
1025
+ function g0_512_hi(xh, xl) {
1026
+ var c0_hi = rotr64_hi(xh, xl, 1);
1027
+ var c1_hi = rotr64_hi(xh, xl, 8);
1028
+ var c2_hi = shr64_hi(xh, xl, 7);
1029
+
1030
+ var r = c0_hi ^ c1_hi ^ c2_hi;
1031
+ if (r < 0)
1032
+ r += 0x100000000;
1033
+ return r;
1034
+ }
1035
+
1036
+ function g0_512_lo(xh, xl) {
1037
+ var c0_lo = rotr64_lo(xh, xl, 1);
1038
+ var c1_lo = rotr64_lo(xh, xl, 8);
1039
+ var c2_lo = shr64_lo(xh, xl, 7);
1040
+
1041
+ var r = c0_lo ^ c1_lo ^ c2_lo;
1042
+ if (r < 0)
1043
+ r += 0x100000000;
1044
+ return r;
1045
+ }
1046
+
1047
+ function g1_512_hi(xh, xl) {
1048
+ var c0_hi = rotr64_hi(xh, xl, 19);
1049
+ var c1_hi = rotr64_hi(xl, xh, 29); // 61
1050
+ var c2_hi = shr64_hi(xh, xl, 6);
1051
+
1052
+ var r = c0_hi ^ c1_hi ^ c2_hi;
1053
+ if (r < 0)
1054
+ r += 0x100000000;
1055
+ return r;
1056
+ }
1057
+
1058
+ function g1_512_lo(xh, xl) {
1059
+ var c0_lo = rotr64_lo(xh, xl, 19);
1060
+ var c1_lo = rotr64_lo(xl, xh, 29); // 61
1061
+ var c2_lo = shr64_lo(xh, xl, 6);
1062
+
1063
+ var r = c0_lo ^ c1_lo ^ c2_lo;
1064
+ if (r < 0)
1065
+ r += 0x100000000;
1066
+ return r;
1067
+ }
1068
+
1069
+ var utils$2 = utils$9;
1070
+
1071
+ var SHA512 = _512;
1072
+
1073
+ function SHA384() {
1074
+ if (!(this instanceof SHA384))
1075
+ return new SHA384();
1076
+
1077
+ SHA512.call(this);
1078
+ this.h = [
1079
+ 0xcbbb9d5d, 0xc1059ed8,
1080
+ 0x629a292a, 0x367cd507,
1081
+ 0x9159015a, 0x3070dd17,
1082
+ 0x152fecd8, 0xf70e5939,
1083
+ 0x67332667, 0xffc00b31,
1084
+ 0x8eb44a87, 0x68581511,
1085
+ 0xdb0c2e0d, 0x64f98fa7,
1086
+ 0x47b5481d, 0xbefa4fa4 ];
1087
+ }
1088
+ utils$2.inherits(SHA384, SHA512);
1089
+ var _384 = SHA384;
1090
+
1091
+ SHA384.blockSize = 1024;
1092
+ SHA384.outSize = 384;
1093
+ SHA384.hmacStrength = 192;
1094
+ SHA384.padLength = 128;
1095
+
1096
+ SHA384.prototype._digest = function digest(enc) {
1097
+ if (enc === 'hex')
1098
+ return utils$2.toHex32(this.h.slice(0, 12), 'big');
1099
+ else
1100
+ return utils$2.split32(this.h.slice(0, 12), 'big');
1101
+ };
1102
+
1103
+ sha.sha1 = _1;
1104
+ sha.sha224 = _224;
1105
+ sha.sha256 = _256;
1106
+ sha.sha384 = _384;
1107
+ sha.sha512 = _512;
1108
+
1109
+ var ripemd = {};
1110
+
1111
+ var utils$1 = utils$9;
1112
+ var common = common$5;
1113
+
1114
+ var rotl32 = utils$1.rotl32;
1115
+ var sum32 = utils$1.sum32;
1116
+ var sum32_3 = utils$1.sum32_3;
1117
+ var sum32_4 = utils$1.sum32_4;
1118
+ var BlockHash = common.BlockHash;
1119
+
1120
+ function RIPEMD160() {
1121
+ if (!(this instanceof RIPEMD160))
1122
+ return new RIPEMD160();
1123
+
1124
+ BlockHash.call(this);
1125
+
1126
+ this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
1127
+ this.endian = 'little';
1128
+ }
1129
+ utils$1.inherits(RIPEMD160, BlockHash);
1130
+ ripemd.ripemd160 = RIPEMD160;
1131
+
1132
+ RIPEMD160.blockSize = 512;
1133
+ RIPEMD160.outSize = 160;
1134
+ RIPEMD160.hmacStrength = 192;
1135
+ RIPEMD160.padLength = 64;
1136
+
1137
+ RIPEMD160.prototype._update = function update(msg, start) {
1138
+ var A = this.h[0];
1139
+ var B = this.h[1];
1140
+ var C = this.h[2];
1141
+ var D = this.h[3];
1142
+ var E = this.h[4];
1143
+ var Ah = A;
1144
+ var Bh = B;
1145
+ var Ch = C;
1146
+ var Dh = D;
1147
+ var Eh = E;
1148
+ for (var j = 0; j < 80; j++) {
1149
+ var T = sum32(
1150
+ rotl32(
1151
+ sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
1152
+ s[j]),
1153
+ E);
1154
+ A = E;
1155
+ E = D;
1156
+ D = rotl32(C, 10);
1157
+ C = B;
1158
+ B = T;
1159
+ T = sum32(
1160
+ rotl32(
1161
+ sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
1162
+ sh[j]),
1163
+ Eh);
1164
+ Ah = Eh;
1165
+ Eh = Dh;
1166
+ Dh = rotl32(Ch, 10);
1167
+ Ch = Bh;
1168
+ Bh = T;
1169
+ }
1170
+ T = sum32_3(this.h[1], C, Dh);
1171
+ this.h[1] = sum32_3(this.h[2], D, Eh);
1172
+ this.h[2] = sum32_3(this.h[3], E, Ah);
1173
+ this.h[3] = sum32_3(this.h[4], A, Bh);
1174
+ this.h[4] = sum32_3(this.h[0], B, Ch);
1175
+ this.h[0] = T;
1176
+ };
1177
+
1178
+ RIPEMD160.prototype._digest = function digest(enc) {
1179
+ if (enc === 'hex')
1180
+ return utils$1.toHex32(this.h, 'little');
1181
+ else
1182
+ return utils$1.split32(this.h, 'little');
1183
+ };
1184
+
1185
+ function f(j, x, y, z) {
1186
+ if (j <= 15)
1187
+ return x ^ y ^ z;
1188
+ else if (j <= 31)
1189
+ return (x & y) | ((~x) & z);
1190
+ else if (j <= 47)
1191
+ return (x | (~y)) ^ z;
1192
+ else if (j <= 63)
1193
+ return (x & z) | (y & (~z));
1194
+ else
1195
+ return x ^ (y | (~z));
1196
+ }
1197
+
1198
+ function K(j) {
1199
+ if (j <= 15)
1200
+ return 0x00000000;
1201
+ else if (j <= 31)
1202
+ return 0x5a827999;
1203
+ else if (j <= 47)
1204
+ return 0x6ed9eba1;
1205
+ else if (j <= 63)
1206
+ return 0x8f1bbcdc;
1207
+ else
1208
+ return 0xa953fd4e;
1209
+ }
1210
+
1211
+ function Kh(j) {
1212
+ if (j <= 15)
1213
+ return 0x50a28be6;
1214
+ else if (j <= 31)
1215
+ return 0x5c4dd124;
1216
+ else if (j <= 47)
1217
+ return 0x6d703ef3;
1218
+ else if (j <= 63)
1219
+ return 0x7a6d76e9;
1220
+ else
1221
+ return 0x00000000;
1222
+ }
1223
+
1224
+ var r = [
1225
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1226
+ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
1227
+ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1228
+ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
1229
+ 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
1230
+ ];
1231
+
1232
+ var rh = [
1233
+ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
1234
+ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
1235
+ 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
1236
+ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
1237
+ 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
1238
+ ];
1239
+
1240
+ var s = [
1241
+ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
1242
+ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
1243
+ 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
1244
+ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
1245
+ 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
1246
+ ];
1247
+
1248
+ var sh = [
1249
+ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
1250
+ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
1251
+ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
1252
+ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
1253
+ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
1254
+ ];
1255
+
1256
+ var utils = utils$9;
1257
+ var assert$1 = minimalisticAssert;
1258
+
1259
+ function Hmac(hash, key, enc) {
1260
+ if (!(this instanceof Hmac))
1261
+ return new Hmac(hash, key, enc);
1262
+ this.Hash = hash;
1263
+ this.blockSize = hash.blockSize / 8;
1264
+ this.outSize = hash.outSize / 8;
1265
+ this.inner = null;
1266
+ this.outer = null;
1267
+
1268
+ this._init(utils.toArray(key, enc));
1269
+ }
1270
+ var hmac = Hmac;
1271
+
1272
+ Hmac.prototype._init = function init(key) {
1273
+ // Shorten key, if needed
1274
+ if (key.length > this.blockSize)
1275
+ key = new this.Hash().update(key).digest();
1276
+ assert$1(key.length <= this.blockSize);
1277
+
1278
+ // Add padding to key
1279
+ for (var i = key.length; i < this.blockSize; i++)
1280
+ key.push(0);
1281
+
1282
+ for (i = 0; i < key.length; i++)
1283
+ key[i] ^= 0x36;
1284
+ this.inner = new this.Hash().update(key);
1285
+
1286
+ // 0x36 ^ 0x5c = 0x6a
1287
+ for (i = 0; i < key.length; i++)
1288
+ key[i] ^= 0x6a;
1289
+ this.outer = new this.Hash().update(key);
1290
+ };
1291
+
1292
+ Hmac.prototype.update = function update(msg, enc) {
1293
+ this.inner.update(msg, enc);
1294
+ return this;
1295
+ };
1296
+
1297
+ Hmac.prototype.digest = function digest(enc) {
1298
+ this.outer.update(this.inner.digest());
1299
+ return this.outer.digest(enc);
1300
+ };
1301
+
1302
+ (function (exports) {
1303
+ var hash = exports;
1304
+
1305
+ hash.utils = utils$9;
1306
+ hash.common = common$5;
1307
+ hash.sha = sha;
1308
+ hash.ripemd = ripemd;
1309
+ hash.hmac = hmac;
1310
+
1311
+ // Proxy hash functions to the main object
1312
+ hash.sha1 = hash.sha.sha1;
1313
+ hash.sha256 = hash.sha.sha256;
1314
+ hash.sha224 = hash.sha.sha224;
1315
+ hash.sha384 = hash.sha.sha384;
1316
+ hash.sha512 = hash.sha.sha512;
1317
+ hash.ripemd160 = hash.ripemd.ripemd160;
1318
+ }(hash$1));
1319
+
1320
+ var hash = hash$1;
1321
+
1322
+ const version$2 = "logger/5.5.0";
1323
+
1324
+ let _permanentCensorErrors = false;
1325
+ let _censorErrors = false;
1326
+ const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
1327
+ let _logLevel = LogLevels["default"];
1328
+ let _globalLogger = null;
1329
+ function _checkNormalize() {
1330
+ try {
1331
+ const missing = [];
1332
+ // Make sure all forms of normalization are supported
1333
+ ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
1334
+ try {
1335
+ if ("test".normalize(form) !== "test") {
1336
+ throw new Error("bad normalize");
1337
+ }
1338
+ ;
1339
+ }
1340
+ catch (error) {
1341
+ missing.push(form);
1342
+ }
1343
+ });
1344
+ if (missing.length) {
1345
+ throw new Error("missing " + missing.join(", "));
1346
+ }
1347
+ if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
1348
+ throw new Error("broken implementation");
1349
+ }
1350
+ }
1351
+ catch (error) {
1352
+ return error.message;
1353
+ }
1354
+ return null;
1355
+ }
1356
+ const _normalizeError = _checkNormalize();
1357
+ var LogLevel;
1358
+ (function (LogLevel) {
1359
+ LogLevel["DEBUG"] = "DEBUG";
1360
+ LogLevel["INFO"] = "INFO";
1361
+ LogLevel["WARNING"] = "WARNING";
1362
+ LogLevel["ERROR"] = "ERROR";
1363
+ LogLevel["OFF"] = "OFF";
1364
+ })(LogLevel || (LogLevel = {}));
1365
+ var ErrorCode;
1366
+ (function (ErrorCode) {
1367
+ ///////////////////
1368
+ // Generic Errors
1369
+ // Unknown Error
1370
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1371
+ // Not Implemented
1372
+ ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
1373
+ // Unsupported Operation
1374
+ // - operation
1375
+ ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
1376
+ // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
1377
+ // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
1378
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
1379
+ // Some sort of bad response from the server
1380
+ ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
1381
+ // Timeout
1382
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
1383
+ ///////////////////
1384
+ // Operational Errors
1385
+ // Buffer Overrun
1386
+ ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
1387
+ // Numeric Fault
1388
+ // - operation: the operation being executed
1389
+ // - fault: the reason this faulted
1390
+ ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
1391
+ ///////////////////
1392
+ // Argument Errors
1393
+ // Missing new operator to an object
1394
+ // - name: The name of the class
1395
+ ErrorCode["MISSING_NEW"] = "MISSING_NEW";
1396
+ // Invalid argument (e.g. value is incompatible with type) to a function:
1397
+ // - argument: The argument name that was invalid
1398
+ // - value: The value of the argument
1399
+ ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
1400
+ // Missing argument to a function:
1401
+ // - count: The number of arguments received
1402
+ // - expectedCount: The number of arguments expected
1403
+ ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
1404
+ // Too many arguments
1405
+ // - count: The number of arguments received
1406
+ // - expectedCount: The number of arguments expected
1407
+ ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
1408
+ ///////////////////
1409
+ // Blockchain Errors
1410
+ // Call exception
1411
+ // - transaction: the transaction
1412
+ // - address?: the contract address
1413
+ // - args?: The arguments passed into the function
1414
+ // - method?: The Solidity method signature
1415
+ // - errorSignature?: The EIP848 error signature
1416
+ // - errorArgs?: The EIP848 error parameters
1417
+ // - reason: The reason (only for EIP848 "Error(string)")
1418
+ ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
1419
+ // Insufficient funds (< value + gasLimit * gasPrice)
1420
+ // - transaction: the transaction attempted
1421
+ ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
1422
+ // Nonce has already been used
1423
+ // - transaction: the transaction attempted
1424
+ ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
1425
+ // The replacement fee for the transaction is too low
1426
+ // - transaction: the transaction attempted
1427
+ ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
1428
+ // The gas limit could not be estimated
1429
+ // - transaction: the transaction passed to estimateGas
1430
+ ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
1431
+ // The transaction was replaced by one with a higher gas price
1432
+ // - reason: "cancelled", "replaced" or "repriced"
1433
+ // - cancelled: true if reason == "cancelled" or reason == "replaced")
1434
+ // - hash: original transaction hash
1435
+ // - replacement: the full TransactionsResponse for the replacement
1436
+ // - receipt: the receipt of the replacement
1437
+ ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
1438
+ })(ErrorCode || (ErrorCode = {}));
1439
+ const HEX = "0123456789abcdef";
1440
+ class Logger {
1441
+ constructor(version) {
1442
+ Object.defineProperty(this, "version", {
1443
+ enumerable: true,
1444
+ value: version,
1445
+ writable: false
1446
+ });
1447
+ }
1448
+ _log(logLevel, args) {
1449
+ const level = logLevel.toLowerCase();
1450
+ if (LogLevels[level] == null) {
1451
+ this.throwArgumentError("invalid log level name", "logLevel", logLevel);
1452
+ }
1453
+ if (_logLevel > LogLevels[level]) {
1454
+ return;
1455
+ }
1456
+ console.log.apply(console, args);
1457
+ }
1458
+ debug(...args) {
1459
+ this._log(Logger.levels.DEBUG, args);
1460
+ }
1461
+ info(...args) {
1462
+ this._log(Logger.levels.INFO, args);
1463
+ }
1464
+ warn(...args) {
1465
+ this._log(Logger.levels.WARNING, args);
1466
+ }
1467
+ makeError(message, code, params) {
1468
+ // Errors are being censored
1469
+ if (_censorErrors) {
1470
+ return this.makeError("censored error", code, {});
1471
+ }
1472
+ if (!code) {
1473
+ code = Logger.errors.UNKNOWN_ERROR;
1474
+ }
1475
+ if (!params) {
1476
+ params = {};
1477
+ }
1478
+ const messageDetails = [];
1479
+ Object.keys(params).forEach((key) => {
1480
+ const value = params[key];
1481
+ try {
1482
+ if (value instanceof Uint8Array) {
1483
+ let hex = "";
1484
+ for (let i = 0; i < value.length; i++) {
1485
+ hex += HEX[value[i] >> 4];
1486
+ hex += HEX[value[i] & 0x0f];
1487
+ }
1488
+ messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
1489
+ }
1490
+ else {
1491
+ messageDetails.push(key + "=" + JSON.stringify(value));
1492
+ }
1493
+ }
1494
+ catch (error) {
1495
+ messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
1496
+ }
1497
+ });
1498
+ messageDetails.push(`code=${code}`);
1499
+ messageDetails.push(`version=${this.version}`);
1500
+ const reason = message;
1501
+ if (messageDetails.length) {
1502
+ message += " (" + messageDetails.join(", ") + ")";
1503
+ }
1504
+ // @TODO: Any??
1505
+ const error = new Error(message);
1506
+ error.reason = reason;
1507
+ error.code = code;
1508
+ Object.keys(params).forEach(function (key) {
1509
+ error[key] = params[key];
1510
+ });
1511
+ return error;
1512
+ }
1513
+ throwError(message, code, params) {
1514
+ throw this.makeError(message, code, params);
1515
+ }
1516
+ throwArgumentError(message, name, value) {
1517
+ return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
1518
+ argument: name,
1519
+ value: value
1520
+ });
1521
+ }
1522
+ assert(condition, message, code, params) {
1523
+ if (!!condition) {
1524
+ return;
1525
+ }
1526
+ this.throwError(message, code, params);
1527
+ }
1528
+ assertArgument(condition, message, name, value) {
1529
+ if (!!condition) {
1530
+ return;
1531
+ }
1532
+ this.throwArgumentError(message, name, value);
1533
+ }
1534
+ checkNormalize(message) {
1535
+ if (_normalizeError) {
1536
+ this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
1537
+ operation: "String.prototype.normalize", form: _normalizeError
1538
+ });
1539
+ }
1540
+ }
1541
+ checkSafeUint53(value, message) {
1542
+ if (typeof (value) !== "number") {
1543
+ return;
1544
+ }
1545
+ if (message == null) {
1546
+ message = "value not safe";
1547
+ }
1548
+ if (value < 0 || value >= 0x1fffffffffffff) {
1549
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1550
+ operation: "checkSafeInteger",
1551
+ fault: "out-of-safe-range",
1552
+ value: value
1553
+ });
1554
+ }
1555
+ if (value % 1) {
1556
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1557
+ operation: "checkSafeInteger",
1558
+ fault: "non-integer",
1559
+ value: value
1560
+ });
1561
+ }
1562
+ }
1563
+ checkArgumentCount(count, expectedCount, message) {
1564
+ if (message) {
1565
+ message = ": " + message;
1566
+ }
1567
+ else {
1568
+ message = "";
1569
+ }
1570
+ if (count < expectedCount) {
1571
+ this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
1572
+ count: count,
1573
+ expectedCount: expectedCount
1574
+ });
1575
+ }
1576
+ if (count > expectedCount) {
1577
+ this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
1578
+ count: count,
1579
+ expectedCount: expectedCount
1580
+ });
1581
+ }
1582
+ }
1583
+ checkNew(target, kind) {
1584
+ if (target === Object || target == null) {
1585
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1586
+ }
1587
+ }
1588
+ checkAbstract(target, kind) {
1589
+ if (target === kind) {
1590
+ this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
1591
+ }
1592
+ else if (target === Object || target == null) {
1593
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1594
+ }
1595
+ }
1596
+ static globalLogger() {
1597
+ if (!_globalLogger) {
1598
+ _globalLogger = new Logger(version$2);
1599
+ }
1600
+ return _globalLogger;
1601
+ }
1602
+ static setCensorship(censorship, permanent) {
1603
+ if (!censorship && permanent) {
1604
+ this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
1605
+ operation: "setCensorship"
1606
+ });
1607
+ }
1608
+ if (_permanentCensorErrors) {
1609
+ if (!censorship) {
1610
+ return;
1611
+ }
1612
+ this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
1613
+ operation: "setCensorship"
1614
+ });
1615
+ }
1616
+ _censorErrors = !!censorship;
1617
+ _permanentCensorErrors = !!permanent;
1618
+ }
1619
+ static setLogLevel(logLevel) {
1620
+ const level = LogLevels[logLevel.toLowerCase()];
1621
+ if (level == null) {
1622
+ Logger.globalLogger().warn("invalid log level - " + logLevel);
1623
+ return;
1624
+ }
1625
+ _logLevel = level;
1626
+ }
1627
+ static from(version) {
1628
+ return new Logger(version);
1629
+ }
1630
+ }
1631
+ Logger.errors = ErrorCode;
1632
+ Logger.levels = LogLevel;
1633
+
1634
+ const version$1 = "bytes/5.5.0";
1635
+
1636
+ const logger = new Logger(version$1);
1637
+ ///////////////////////////////
1638
+ function isHexable(value) {
1639
+ return !!(value.toHexString);
1640
+ }
1641
+ function addSlice(array) {
1642
+ if (array.slice) {
1643
+ return array;
1644
+ }
1645
+ array.slice = function () {
1646
+ const args = Array.prototype.slice.call(arguments);
1647
+ return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
1648
+ };
1649
+ return array;
1650
+ }
1651
+ function isInteger(value) {
1652
+ return (typeof (value) === "number" && value == value && (value % 1) === 0);
1653
+ }
1654
+ function isBytes(value) {
1655
+ if (value == null) {
1656
+ return false;
1657
+ }
1658
+ if (value.constructor === Uint8Array) {
1659
+ return true;
1660
+ }
1661
+ if (typeof (value) === "string") {
1662
+ return false;
1663
+ }
1664
+ if (!isInteger(value.length) || value.length < 0) {
1665
+ return false;
1666
+ }
1667
+ for (let i = 0; i < value.length; i++) {
1668
+ const v = value[i];
1669
+ if (!isInteger(v) || v < 0 || v >= 256) {
1670
+ return false;
1671
+ }
1672
+ }
1673
+ return true;
1674
+ }
1675
+ function arrayify(value, options) {
1676
+ if (!options) {
1677
+ options = {};
1678
+ }
1679
+ if (typeof (value) === "number") {
1680
+ logger.checkSafeUint53(value, "invalid arrayify value");
1681
+ const result = [];
1682
+ while (value) {
1683
+ result.unshift(value & 0xff);
1684
+ value = parseInt(String(value / 256));
1685
+ }
1686
+ if (result.length === 0) {
1687
+ result.push(0);
1688
+ }
1689
+ return addSlice(new Uint8Array(result));
1690
+ }
1691
+ if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
1692
+ value = "0x" + value;
1693
+ }
1694
+ if (isHexable(value)) {
1695
+ value = value.toHexString();
1696
+ }
1697
+ if (isHexString(value)) {
1698
+ let hex = value.substring(2);
1699
+ if (hex.length % 2) {
1700
+ if (options.hexPad === "left") {
1701
+ hex = "0x0" + hex.substring(2);
1702
+ }
1703
+ else if (options.hexPad === "right") {
1704
+ hex += "0";
1705
+ }
1706
+ else {
1707
+ logger.throwArgumentError("hex data is odd-length", "value", value);
1708
+ }
1709
+ }
1710
+ const result = [];
1711
+ for (let i = 0; i < hex.length; i += 2) {
1712
+ result.push(parseInt(hex.substring(i, i + 2), 16));
1713
+ }
1714
+ return addSlice(new Uint8Array(result));
1715
+ }
1716
+ if (isBytes(value)) {
1717
+ return addSlice(new Uint8Array(value));
1718
+ }
1719
+ return logger.throwArgumentError("invalid arrayify value", "value", value);
1720
+ }
1721
+ function isHexString(value, length) {
1722
+ if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
1723
+ return false;
1724
+ }
1725
+ if (length && value.length !== 2 + 2 * length) {
1726
+ return false;
1727
+ }
1728
+ return true;
1729
+ }
1730
+
1731
+ const version = "sha2/5.5.0";
1732
+
1733
+ new Logger(version);
1734
+ function sha256(data) {
1735
+ return "0x" + (hash.sha256().update(arrayify(data)).digest("hex"));
1736
+ }
1737
+
64
1738
  class Struct {
65
1739
  constructor(properties) {
66
1740
  Object.assign(this, properties);
@@ -84,8 +1758,7 @@ class Struct {
84
1758
  class Enum extends Struct {
85
1759
  constructor(properties) {
86
1760
  super(properties);
87
-
88
- _defineProperty__default["default"](this, "enum", '');
1761
+ this.enum = '';
89
1762
 
90
1763
  if (Object.keys(properties).length !== 1) {
91
1764
  throw new Error('Enum can only take single value');
@@ -125,8 +1798,7 @@ class PublicKey extends Struct {
125
1798
  */
126
1799
  constructor(value) {
127
1800
  super({});
128
-
129
- _defineProperty__default["default"](this, "_bn", void 0);
1801
+ this._bn = void 0;
130
1802
 
131
1803
  if (isPublicKeyData(value)) {
132
1804
  this._bn = value._bn;
@@ -206,16 +1878,20 @@ class PublicKey extends Struct {
206
1878
  * it permission to write data to the account.
207
1879
  */
208
1880
 
1881
+ /* eslint-disable require-await */
1882
+
209
1883
 
210
1884
  static async createWithSeed(fromPublicKey, seed, programId) {
211
1885
  const buffer$1 = buffer.Buffer.concat([fromPublicKey.toBuffer(), buffer.Buffer.from(seed), programId.toBuffer()]);
212
- const hash = await cryptoHash.sha256(new Uint8Array(buffer$1));
1886
+ const hash = sha256(new Uint8Array(buffer$1)).slice(2);
213
1887
  return new PublicKey(buffer.Buffer.from(hash, 'hex'));
214
1888
  }
215
1889
  /**
216
1890
  * Derive a program address from seeds and a program ID.
217
1891
  */
218
1892
 
1893
+ /* eslint-disable require-await */
1894
+
219
1895
 
220
1896
  static async createProgramAddress(seeds, programId) {
221
1897
  let buffer$1 = buffer.Buffer.alloc(0);
@@ -227,7 +1903,7 @@ class PublicKey extends Struct {
227
1903
  buffer$1 = buffer.Buffer.concat([buffer$1, toBuffer(seed)]);
228
1904
  });
229
1905
  buffer$1 = buffer.Buffer.concat([buffer$1, programId.toBuffer(), buffer.Buffer.from('ProgramDerivedAddress')]);
230
- let hash = await cryptoHash.sha256(new Uint8Array(buffer$1));
1906
+ let hash = sha256(new Uint8Array(buffer$1)).slice(2);
231
1907
  let publicKeyBytes = new BN__default["default"](hash, 16).toArray(undefined, 32);
232
1908
 
233
1909
  if (is_on_curve(publicKeyBytes)) {
@@ -277,9 +1953,7 @@ class PublicKey extends Struct {
277
1953
  }
278
1954
 
279
1955
  }
280
-
281
- _defineProperty__default["default"](PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
282
-
1956
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
283
1957
  SOLANA_SCHEMA.set(PublicKey, {
284
1958
  kind: 'struct',
285
1959
  fields: [['_bn', 'u256']]
@@ -352,7 +2026,7 @@ class Account {
352
2026
  * @param secretKey Secret key for the account
353
2027
  */
354
2028
  constructor(secretKey) {
355
- _defineProperty__default["default"](this, "_keypair", void 0);
2029
+ this._keypair = void 0;
356
2030
 
357
2031
  if (secretKey) {
358
2032
  this._keypair = nacl__namespace.sign.keyPair.fromSecretKey(toBuffer(secretKey));
@@ -488,16 +2162,11 @@ const PUBKEY_LENGTH = 32;
488
2162
 
489
2163
  class Message {
490
2164
  constructor(args) {
491
- _defineProperty__default["default"](this, "header", void 0);
492
-
493
- _defineProperty__default["default"](this, "accountKeys", void 0);
494
-
495
- _defineProperty__default["default"](this, "recentBlockhash", void 0);
496
-
497
- _defineProperty__default["default"](this, "instructions", void 0);
498
-
499
- _defineProperty__default["default"](this, "indexToProgramIds", new Map());
500
-
2165
+ this.header = void 0;
2166
+ this.accountKeys = void 0;
2167
+ this.recentBlockhash = void 0;
2168
+ this.instructions = void 0;
2169
+ this.indexToProgramIds = new Map();
501
2170
  this.header = args.header;
502
2171
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
503
2172
  this.recentBlockhash = args.recentBlockhash;
@@ -671,12 +2340,9 @@ class TransactionInstruction {
671
2340
  * Program input
672
2341
  */
673
2342
  constructor(opts) {
674
- _defineProperty__default["default"](this, "keys", void 0);
675
-
676
- _defineProperty__default["default"](this, "programId", void 0);
677
-
678
- _defineProperty__default["default"](this, "data", buffer.Buffer.alloc(0));
679
-
2343
+ this.keys = void 0;
2344
+ this.programId = void 0;
2345
+ this.data = buffer.Buffer.alloc(0);
680
2346
  this.programId = opts.programId;
681
2347
  this.keys = opts.keys;
682
2348
 
@@ -718,16 +2384,11 @@ class Transaction {
718
2384
  * Construct an empty Transaction
719
2385
  */
720
2386
  constructor(opts) {
721
- _defineProperty__default["default"](this, "signatures", []);
722
-
723
- _defineProperty__default["default"](this, "feePayer", void 0);
724
-
725
- _defineProperty__default["default"](this, "instructions", []);
726
-
727
- _defineProperty__default["default"](this, "recentBlockhash", void 0);
728
-
729
- _defineProperty__default["default"](this, "nonceInfo", void 0);
730
-
2387
+ this.signatures = [];
2388
+ this.feePayer = void 0;
2389
+ this.instructions = [];
2390
+ this.recentBlockhash = void 0;
2391
+ this.nonceInfo = void 0;
731
2392
  opts && Object.assign(this, opts);
732
2393
  }
733
2394
  /**
@@ -1378,12 +3039,9 @@ class NonceAccount {
1378
3039
  * @internal
1379
3040
  */
1380
3041
  constructor(args) {
1381
- _defineProperty__default["default"](this, "authorizedPubkey", void 0);
1382
-
1383
- _defineProperty__default["default"](this, "nonce", void 0);
1384
-
1385
- _defineProperty__default["default"](this, "feeCalculator", void 0);
1386
-
3042
+ this.authorizedPubkey = void 0;
3043
+ this.nonce = void 0;
3044
+ this.feeCalculator = void 0;
1387
3045
  this.authorizedPubkey = args.authorizedPubkey;
1388
3046
  this.nonce = args.nonce;
1389
3047
  this.feeCalculator = args.feeCalculator;
@@ -2116,8 +3774,7 @@ class SystemProgram {
2116
3774
  }
2117
3775
 
2118
3776
  }
2119
-
2120
- _defineProperty__default["default"](SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3777
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
2121
3778
 
2122
3779
  // rest of the Transaction fields
2123
3780
  //
@@ -2146,7 +3803,8 @@ class Loader {
2146
3803
  * Can be used to calculate transaction fees
2147
3804
  */
2148
3805
  static getMinNumSignatures(dataLength) {
2149
- return 2 * (Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
3806
+ return 2 * ( // Every transaction requires two signatures (payer + program)
3807
+ Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
2150
3808
  1) // Add one for Finalize transaction
2151
3809
  ;
2152
3810
  }
@@ -2285,8 +3943,7 @@ class Loader {
2285
3943
  }
2286
3944
 
2287
3945
  }
2288
-
2289
- _defineProperty__default["default"](Loader, "chunkSize", CHUNK_SIZE);
3946
+ Loader.chunkSize = CHUNK_SIZE;
2290
3947
 
2291
3948
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
2292
3949
  /**
@@ -2337,14 +3994,10 @@ class AgentManager {
2337
3994
  }
2338
3995
 
2339
3996
  constructor(useHttps) {
2340
- _defineProperty__default["default"](this, "_agent", void 0);
2341
-
2342
- _defineProperty__default["default"](this, "_activeRequests", 0);
2343
-
2344
- _defineProperty__default["default"](this, "_destroyTimeout", null);
2345
-
2346
- _defineProperty__default["default"](this, "_useHttps", void 0);
2347
-
3997
+ this._agent = void 0;
3998
+ this._activeRequests = 0;
3999
+ this._destroyTimeout = null;
4000
+ this._useHttps = void 0;
2348
4001
  this._useHttps = useHttps === true;
2349
4002
  this._agent = AgentManager._newAgent(this._useHttps);
2350
4003
  }
@@ -2417,16 +4070,11 @@ class EpochSchedule {
2417
4070
 
2418
4071
  /** The first slot of `firstNormalEpoch` */
2419
4072
  constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
2420
- _defineProperty__default["default"](this, "slotsPerEpoch", void 0);
2421
-
2422
- _defineProperty__default["default"](this, "leaderScheduleSlotOffset", void 0);
2423
-
2424
- _defineProperty__default["default"](this, "warmup", void 0);
2425
-
2426
- _defineProperty__default["default"](this, "firstNormalEpoch", void 0);
2427
-
2428
- _defineProperty__default["default"](this, "firstNormalSlot", void 0);
2429
-
4073
+ this.slotsPerEpoch = void 0;
4074
+ this.leaderScheduleSlotOffset = void 0;
4075
+ this.warmup = void 0;
4076
+ this.firstNormalEpoch = void 0;
4077
+ this.firstNormalSlot = void 0;
2430
4078
  this.slotsPerEpoch = slotsPerEpoch;
2431
4079
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
2432
4080
  this.warmup = warmup;
@@ -2478,9 +4126,7 @@ class EpochSchedule {
2478
4126
  class SendTransactionError extends Error {
2479
4127
  constructor(message, logs) {
2480
4128
  super(message);
2481
-
2482
- _defineProperty__default["default"](this, "logs", void 0);
2483
-
4129
+ this.logs = void 0;
2484
4130
  this.logs = logs;
2485
4131
  }
2486
4132
 
@@ -3440,67 +5086,39 @@ class Connection {
3440
5086
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
3441
5087
  */
3442
5088
  constructor(endpoint, commitmentOrConfig) {
3443
- _defineProperty__default["default"](this, "_commitment", void 0);
3444
-
3445
- _defineProperty__default["default"](this, "_confirmTransactionInitialTimeout", void 0);
3446
-
3447
- _defineProperty__default["default"](this, "_rpcEndpoint", void 0);
3448
-
3449
- _defineProperty__default["default"](this, "_rpcWsEndpoint", void 0);
3450
-
3451
- _defineProperty__default["default"](this, "_rpcClient", void 0);
3452
-
3453
- _defineProperty__default["default"](this, "_rpcRequest", void 0);
3454
-
3455
- _defineProperty__default["default"](this, "_rpcBatchRequest", void 0);
3456
-
3457
- _defineProperty__default["default"](this, "_rpcWebSocket", void 0);
3458
-
3459
- _defineProperty__default["default"](this, "_rpcWebSocketConnected", false);
3460
-
3461
- _defineProperty__default["default"](this, "_rpcWebSocketHeartbeat", null);
3462
-
3463
- _defineProperty__default["default"](this, "_rpcWebSocketIdleTimeout", null);
3464
-
3465
- _defineProperty__default["default"](this, "_disableBlockhashCaching", false);
3466
-
3467
- _defineProperty__default["default"](this, "_pollingBlockhash", false);
3468
-
3469
- _defineProperty__default["default"](this, "_blockhashInfo", {
5089
+ this._commitment = void 0;
5090
+ this._confirmTransactionInitialTimeout = void 0;
5091
+ this._rpcEndpoint = void 0;
5092
+ this._rpcWsEndpoint = void 0;
5093
+ this._rpcClient = void 0;
5094
+ this._rpcRequest = void 0;
5095
+ this._rpcBatchRequest = void 0;
5096
+ this._rpcWebSocket = void 0;
5097
+ this._rpcWebSocketConnected = false;
5098
+ this._rpcWebSocketHeartbeat = null;
5099
+ this._rpcWebSocketIdleTimeout = null;
5100
+ this._disableBlockhashCaching = false;
5101
+ this._pollingBlockhash = false;
5102
+ this._blockhashInfo = {
3470
5103
  recentBlockhash: null,
3471
5104
  lastFetch: 0,
3472
5105
  transactionSignatures: [],
3473
5106
  simulatedSignatures: []
3474
- });
3475
-
3476
- _defineProperty__default["default"](this, "_accountChangeSubscriptionCounter", 0);
3477
-
3478
- _defineProperty__default["default"](this, "_accountChangeSubscriptions", {});
3479
-
3480
- _defineProperty__default["default"](this, "_programAccountChangeSubscriptionCounter", 0);
3481
-
3482
- _defineProperty__default["default"](this, "_programAccountChangeSubscriptions", {});
3483
-
3484
- _defineProperty__default["default"](this, "_rootSubscriptionCounter", 0);
3485
-
3486
- _defineProperty__default["default"](this, "_rootSubscriptions", {});
3487
-
3488
- _defineProperty__default["default"](this, "_signatureSubscriptionCounter", 0);
3489
-
3490
- _defineProperty__default["default"](this, "_signatureSubscriptions", {});
3491
-
3492
- _defineProperty__default["default"](this, "_slotSubscriptionCounter", 0);
3493
-
3494
- _defineProperty__default["default"](this, "_slotSubscriptions", {});
3495
-
3496
- _defineProperty__default["default"](this, "_logsSubscriptionCounter", 0);
3497
-
3498
- _defineProperty__default["default"](this, "_logsSubscriptions", {});
3499
-
3500
- _defineProperty__default["default"](this, "_slotUpdateSubscriptionCounter", 0);
3501
-
3502
- _defineProperty__default["default"](this, "_slotUpdateSubscriptions", {});
3503
-
5107
+ };
5108
+ this._accountChangeSubscriptionCounter = 0;
5109
+ this._accountChangeSubscriptions = {};
5110
+ this._programAccountChangeSubscriptionCounter = 0;
5111
+ this._programAccountChangeSubscriptions = {};
5112
+ this._rootSubscriptionCounter = 0;
5113
+ this._rootSubscriptions = {};
5114
+ this._signatureSubscriptionCounter = 0;
5115
+ this._signatureSubscriptions = {};
5116
+ this._slotSubscriptionCounter = 0;
5117
+ this._slotSubscriptions = {};
5118
+ this._logsSubscriptionCounter = 0;
5119
+ this._logsSubscriptions = {};
5120
+ this._slotUpdateSubscriptionCounter = 0;
5121
+ this._slotUpdateSubscriptions = {};
3504
5122
  let url = new URL(endpoint);
3505
5123
  const useHttps = url.protocol === 'https:';
3506
5124
  let wsEndpoint;
@@ -3635,10 +5253,24 @@ class Connection {
3635
5253
  */
3636
5254
 
3637
5255
 
3638
- async getSupply(commitment) {
3639
- const args = this._buildArgs([], commitment);
5256
+ async getSupply(config) {
5257
+ let configArg = {};
5258
+
5259
+ if (typeof config === 'string') {
5260
+ configArg = {
5261
+ commitment: config
5262
+ };
5263
+ } else if (config) {
5264
+ configArg = { ...config,
5265
+ commitment: config && config.commitment || this.commitment
5266
+ };
5267
+ } else {
5268
+ configArg = {
5269
+ commitment: this.commitment
5270
+ };
5271
+ }
3640
5272
 
3641
- const unsafeRes = await this._rpcRequest('getSupply', args);
5273
+ const unsafeRes = await this._rpcRequest('getSupply', [configArg]);
3642
5274
  const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
3643
5275
 
3644
5276
  if ('error' in res) {
@@ -4149,16 +5781,11 @@ class Connection {
4149
5781
 
4150
5782
 
4151
5783
  async getTotalSupply(commitment) {
4152
- const args = this._buildArgs([], commitment);
4153
-
4154
- const unsafeRes = await this._rpcRequest('getSupply', args);
4155
- const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
4156
-
4157
- if ('error' in res) {
4158
- throw new Error('failed to get total supply: ' + res.error.message);
4159
- }
4160
-
4161
- return res.result.value.total;
5784
+ const result = await this.getSupply({
5785
+ commitment,
5786
+ excludeNonCirculatingAccountsList: true
5787
+ });
5788
+ return result.value.total;
4162
5789
  }
4163
5790
  /**
4164
5791
  * Fetch the cluster InflationGovernor parameters
@@ -5656,7 +7283,7 @@ class Keypair {
5656
7283
  * @param keypair ed25519 keypair
5657
7284
  */
5658
7285
  constructor(keypair) {
5659
- _defineProperty__default["default"](this, "_keypair", void 0);
7286
+ this._keypair = void 0;
5660
7287
 
5661
7288
  if (keypair) {
5662
7289
  this._keypair = keypair;
@@ -5817,8 +7444,7 @@ class Ed25519Program {
5817
7444
  }
5818
7445
 
5819
7446
  }
5820
-
5821
- _defineProperty__default["default"](Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7447
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
5822
7448
 
5823
7449
  /**
5824
7450
  * Address of the stake config account which configures the rate
@@ -5841,10 +7467,8 @@ class Authorized {
5841
7467
  * @param withdrawer the withdraw authority
5842
7468
  */
5843
7469
  constructor(staker, withdrawer) {
5844
- _defineProperty__default["default"](this, "staker", void 0);
5845
-
5846
- _defineProperty__default["default"](this, "withdrawer", void 0);
5847
-
7470
+ this.staker = void 0;
7471
+ this.withdrawer = void 0;
5848
7472
  this.staker = staker;
5849
7473
  this.withdrawer = withdrawer;
5850
7474
  }
@@ -5865,12 +7489,9 @@ class Lockup {
5865
7489
  * Create a new Lockup object
5866
7490
  */
5867
7491
  constructor(unixTimestamp, epoch, custodian) {
5868
- _defineProperty__default["default"](this, "unixTimestamp", void 0);
5869
-
5870
- _defineProperty__default["default"](this, "epoch", void 0);
5871
-
5872
- _defineProperty__default["default"](this, "custodian", void 0);
5873
-
7492
+ this.unixTimestamp = void 0;
7493
+ this.epoch = void 0;
7494
+ this.custodian = void 0;
5874
7495
  this.unixTimestamp = unixTimestamp;
5875
7496
  this.epoch = epoch;
5876
7497
  this.custodian = custodian;
@@ -5885,7 +7506,7 @@ class Lockup {
5885
7506
  * Create stake account transaction params
5886
7507
  */
5887
7508
 
5888
- _defineProperty__default["default"](Lockup, "default", new Lockup(0, 0, PublicKey.default));
7509
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
5889
7510
 
5890
7511
  /**
5891
7512
  * Stake Instruction class
@@ -6573,10 +8194,8 @@ class StakeProgram {
6573
8194
  }
6574
8195
 
6575
8196
  }
6576
-
6577
- _defineProperty__default["default"](StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
6578
-
6579
- _defineProperty__default["default"](StakeProgram, "space", 200);
8197
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8198
+ StakeProgram.space = 200;
6580
8199
 
6581
8200
  const {
6582
8201
  publicKeyCreate,
@@ -6725,8 +8344,7 @@ class Secp256k1Program {
6725
8344
  }
6726
8345
 
6727
8346
  }
6728
-
6729
- _defineProperty__default["default"](Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8347
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
6730
8348
 
6731
8349
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
6732
8350
  /**
@@ -6759,10 +8377,8 @@ class ValidatorInfo {
6759
8377
  * @param info validator information
6760
8378
  */
6761
8379
  constructor(key, info) {
6762
- _defineProperty__default["default"](this, "key", void 0);
6763
-
6764
- _defineProperty__default["default"](this, "info", void 0);
6765
-
8380
+ this.key = void 0;
8381
+ this.info = void 0;
6766
8382
  this.key = key;
6767
8383
  this.info = info;
6768
8384
  }
@@ -6826,26 +8442,16 @@ class VoteAccount {
6826
8442
  * @internal
6827
8443
  */
6828
8444
  constructor(args) {
6829
- _defineProperty__default["default"](this, "nodePubkey", void 0);
6830
-
6831
- _defineProperty__default["default"](this, "authorizedVoterPubkey", void 0);
6832
-
6833
- _defineProperty__default["default"](this, "authorizedWithdrawerPubkey", void 0);
6834
-
6835
- _defineProperty__default["default"](this, "commission", void 0);
6836
-
6837
- _defineProperty__default["default"](this, "votes", void 0);
6838
-
6839
- _defineProperty__default["default"](this, "rootSlot", void 0);
6840
-
6841
- _defineProperty__default["default"](this, "epoch", void 0);
6842
-
6843
- _defineProperty__default["default"](this, "credits", void 0);
6844
-
6845
- _defineProperty__default["default"](this, "lastEpochCredits", void 0);
6846
-
6847
- _defineProperty__default["default"](this, "epochCredits", void 0);
6848
-
8445
+ this.nodePubkey = void 0;
8446
+ this.authorizedVoterPubkey = void 0;
8447
+ this.authorizedWithdrawerPubkey = void 0;
8448
+ this.commission = void 0;
8449
+ this.votes = void 0;
8450
+ this.rootSlot = void 0;
8451
+ this.epoch = void 0;
8452
+ this.credits = void 0;
8453
+ this.lastEpochCredits = void 0;
8454
+ this.epochCredits = void 0;
6849
8455
  this.nodePubkey = args.nodePubkey;
6850
8456
  this.authorizedVoterPubkey = args.authorizedVoterPubkey;
6851
8457
  this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;