@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.esm.js CHANGED
@@ -1,14 +1,12 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
1
  import * as nacl from 'tweetnacl';
3
2
  import nacl__default from 'tweetnacl';
4
3
  import { Buffer } from 'buffer';
5
4
  import BN from 'bn.js';
6
5
  import bs58 from 'bs58';
7
- import { sha256 } from 'crypto-hash';
8
6
  import { serialize, deserialize, deserializeUnchecked } from 'borsh';
9
7
  import * as BufferLayout from '@solana/buffer-layout';
10
8
  import fetch from 'cross-fetch';
11
- import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$1 } from 'superstruct';
9
+ import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
12
10
  import { Client } from 'rpc-websockets';
13
11
  import RpcClient from 'jayson/lib/client/browser';
14
12
  import http from 'http';
@@ -26,6 +24,1683 @@ const toBuffer = arr => {
26
24
  }
27
25
  };
28
26
 
27
+ var hash$1 = {};
28
+
29
+ var utils$9 = {};
30
+
31
+ var minimalisticAssert = assert$6;
32
+
33
+ function assert$6(val, msg) {
34
+ if (!val)
35
+ throw new Error(msg || 'Assertion failed');
36
+ }
37
+
38
+ assert$6.equal = function assertEqual(l, r, msg) {
39
+ if (l != r)
40
+ throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
41
+ };
42
+
43
+ var inherits$1 = {exports: {}};
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
+ try {
72
+ var util = require('util');
73
+ if (typeof util.inherits !== 'function') throw '';
74
+ inherits$1.exports = util.inherits;
75
+ } catch (e) {
76
+ inherits$1.exports = inherits_browser.exports;
77
+ }
78
+
79
+ var assert$5 = minimalisticAssert;
80
+ var inherits = inherits$1.exports;
81
+
82
+ utils$9.inherits = inherits;
83
+
84
+ function isSurrogatePair(msg, i) {
85
+ if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
86
+ return false;
87
+ }
88
+ if (i < 0 || i + 1 >= msg.length) {
89
+ return false;
90
+ }
91
+ return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
92
+ }
93
+
94
+ function toArray(msg, enc) {
95
+ if (Array.isArray(msg))
96
+ return msg.slice();
97
+ if (!msg)
98
+ return [];
99
+ var res = [];
100
+ if (typeof msg === 'string') {
101
+ if (!enc) {
102
+ // Inspired by stringToUtf8ByteArray() in closure-library by Google
103
+ // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
104
+ // Apache License 2.0
105
+ // https://github.com/google/closure-library/blob/master/LICENSE
106
+ var p = 0;
107
+ for (var i = 0; i < msg.length; i++) {
108
+ var c = msg.charCodeAt(i);
109
+ if (c < 128) {
110
+ res[p++] = c;
111
+ } else if (c < 2048) {
112
+ res[p++] = (c >> 6) | 192;
113
+ res[p++] = (c & 63) | 128;
114
+ } else if (isSurrogatePair(msg, i)) {
115
+ c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
116
+ res[p++] = (c >> 18) | 240;
117
+ res[p++] = ((c >> 12) & 63) | 128;
118
+ res[p++] = ((c >> 6) & 63) | 128;
119
+ res[p++] = (c & 63) | 128;
120
+ } else {
121
+ res[p++] = (c >> 12) | 224;
122
+ res[p++] = ((c >> 6) & 63) | 128;
123
+ res[p++] = (c & 63) | 128;
124
+ }
125
+ }
126
+ } else if (enc === 'hex') {
127
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
128
+ if (msg.length % 2 !== 0)
129
+ msg = '0' + msg;
130
+ for (i = 0; i < msg.length; i += 2)
131
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
132
+ }
133
+ } else {
134
+ for (i = 0; i < msg.length; i++)
135
+ res[i] = msg[i] | 0;
136
+ }
137
+ return res;
138
+ }
139
+ utils$9.toArray = toArray;
140
+
141
+ function toHex(msg) {
142
+ var res = '';
143
+ for (var i = 0; i < msg.length; i++)
144
+ res += zero2(msg[i].toString(16));
145
+ return res;
146
+ }
147
+ utils$9.toHex = toHex;
148
+
149
+ function htonl(w) {
150
+ var res = (w >>> 24) |
151
+ ((w >>> 8) & 0xff00) |
152
+ ((w << 8) & 0xff0000) |
153
+ ((w & 0xff) << 24);
154
+ return res >>> 0;
155
+ }
156
+ utils$9.htonl = htonl;
157
+
158
+ function toHex32(msg, endian) {
159
+ var res = '';
160
+ for (var i = 0; i < msg.length; i++) {
161
+ var w = msg[i];
162
+ if (endian === 'little')
163
+ w = htonl(w);
164
+ res += zero8(w.toString(16));
165
+ }
166
+ return res;
167
+ }
168
+ utils$9.toHex32 = toHex32;
169
+
170
+ function zero2(word) {
171
+ if (word.length === 1)
172
+ return '0' + word;
173
+ else
174
+ return word;
175
+ }
176
+ utils$9.zero2 = zero2;
177
+
178
+ function zero8(word) {
179
+ if (word.length === 7)
180
+ return '0' + word;
181
+ else if (word.length === 6)
182
+ return '00' + word;
183
+ else if (word.length === 5)
184
+ return '000' + word;
185
+ else if (word.length === 4)
186
+ return '0000' + word;
187
+ else if (word.length === 3)
188
+ return '00000' + word;
189
+ else if (word.length === 2)
190
+ return '000000' + word;
191
+ else if (word.length === 1)
192
+ return '0000000' + word;
193
+ else
194
+ return word;
195
+ }
196
+ utils$9.zero8 = zero8;
197
+
198
+ function join32(msg, start, end, endian) {
199
+ var len = end - start;
200
+ assert$5(len % 4 === 0);
201
+ var res = new Array(len / 4);
202
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
203
+ var w;
204
+ if (endian === 'big')
205
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
206
+ else
207
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
208
+ res[i] = w >>> 0;
209
+ }
210
+ return res;
211
+ }
212
+ utils$9.join32 = join32;
213
+
214
+ function split32(msg, endian) {
215
+ var res = new Array(msg.length * 4);
216
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
217
+ var m = msg[i];
218
+ if (endian === 'big') {
219
+ res[k] = m >>> 24;
220
+ res[k + 1] = (m >>> 16) & 0xff;
221
+ res[k + 2] = (m >>> 8) & 0xff;
222
+ res[k + 3] = m & 0xff;
223
+ } else {
224
+ res[k + 3] = m >>> 24;
225
+ res[k + 2] = (m >>> 16) & 0xff;
226
+ res[k + 1] = (m >>> 8) & 0xff;
227
+ res[k] = m & 0xff;
228
+ }
229
+ }
230
+ return res;
231
+ }
232
+ utils$9.split32 = split32;
233
+
234
+ function rotr32$1(w, b) {
235
+ return (w >>> b) | (w << (32 - b));
236
+ }
237
+ utils$9.rotr32 = rotr32$1;
238
+
239
+ function rotl32$2(w, b) {
240
+ return (w << b) | (w >>> (32 - b));
241
+ }
242
+ utils$9.rotl32 = rotl32$2;
243
+
244
+ function sum32$3(a, b) {
245
+ return (a + b) >>> 0;
246
+ }
247
+ utils$9.sum32 = sum32$3;
248
+
249
+ function sum32_3$1(a, b, c) {
250
+ return (a + b + c) >>> 0;
251
+ }
252
+ utils$9.sum32_3 = sum32_3$1;
253
+
254
+ function sum32_4$2(a, b, c, d) {
255
+ return (a + b + c + d) >>> 0;
256
+ }
257
+ utils$9.sum32_4 = sum32_4$2;
258
+
259
+ function sum32_5$2(a, b, c, d, e) {
260
+ return (a + b + c + d + e) >>> 0;
261
+ }
262
+ utils$9.sum32_5 = sum32_5$2;
263
+
264
+ function sum64$1(buf, pos, ah, al) {
265
+ var bh = buf[pos];
266
+ var bl = buf[pos + 1];
267
+
268
+ var lo = (al + bl) >>> 0;
269
+ var hi = (lo < al ? 1 : 0) + ah + bh;
270
+ buf[pos] = hi >>> 0;
271
+ buf[pos + 1] = lo;
272
+ }
273
+ utils$9.sum64 = sum64$1;
274
+
275
+ function sum64_hi$1(ah, al, bh, bl) {
276
+ var lo = (al + bl) >>> 0;
277
+ var hi = (lo < al ? 1 : 0) + ah + bh;
278
+ return hi >>> 0;
279
+ }
280
+ utils$9.sum64_hi = sum64_hi$1;
281
+
282
+ function sum64_lo$1(ah, al, bh, bl) {
283
+ var lo = al + bl;
284
+ return lo >>> 0;
285
+ }
286
+ utils$9.sum64_lo = sum64_lo$1;
287
+
288
+ function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
289
+ var carry = 0;
290
+ var lo = al;
291
+ lo = (lo + bl) >>> 0;
292
+ carry += lo < al ? 1 : 0;
293
+ lo = (lo + cl) >>> 0;
294
+ carry += lo < cl ? 1 : 0;
295
+ lo = (lo + dl) >>> 0;
296
+ carry += lo < dl ? 1 : 0;
297
+
298
+ var hi = ah + bh + ch + dh + carry;
299
+ return hi >>> 0;
300
+ }
301
+ utils$9.sum64_4_hi = sum64_4_hi$1;
302
+
303
+ function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
304
+ var lo = al + bl + cl + dl;
305
+ return lo >>> 0;
306
+ }
307
+ utils$9.sum64_4_lo = sum64_4_lo$1;
308
+
309
+ function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
310
+ var carry = 0;
311
+ var lo = al;
312
+ lo = (lo + bl) >>> 0;
313
+ carry += lo < al ? 1 : 0;
314
+ lo = (lo + cl) >>> 0;
315
+ carry += lo < cl ? 1 : 0;
316
+ lo = (lo + dl) >>> 0;
317
+ carry += lo < dl ? 1 : 0;
318
+ lo = (lo + el) >>> 0;
319
+ carry += lo < el ? 1 : 0;
320
+
321
+ var hi = ah + bh + ch + dh + eh + carry;
322
+ return hi >>> 0;
323
+ }
324
+ utils$9.sum64_5_hi = sum64_5_hi$1;
325
+
326
+ function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
327
+ var lo = al + bl + cl + dl + el;
328
+
329
+ return lo >>> 0;
330
+ }
331
+ utils$9.sum64_5_lo = sum64_5_lo$1;
332
+
333
+ function rotr64_hi$1(ah, al, num) {
334
+ var r = (al << (32 - num)) | (ah >>> num);
335
+ return r >>> 0;
336
+ }
337
+ utils$9.rotr64_hi = rotr64_hi$1;
338
+
339
+ function rotr64_lo$1(ah, al, num) {
340
+ var r = (ah << (32 - num)) | (al >>> num);
341
+ return r >>> 0;
342
+ }
343
+ utils$9.rotr64_lo = rotr64_lo$1;
344
+
345
+ function shr64_hi$1(ah, al, num) {
346
+ return ah >>> num;
347
+ }
348
+ utils$9.shr64_hi = shr64_hi$1;
349
+
350
+ function shr64_lo$1(ah, al, num) {
351
+ var r = (ah << (32 - num)) | (al >>> num);
352
+ return r >>> 0;
353
+ }
354
+ utils$9.shr64_lo = shr64_lo$1;
355
+
356
+ var common$5 = {};
357
+
358
+ var utils$8 = utils$9;
359
+ var assert$4 = minimalisticAssert;
360
+
361
+ function BlockHash$4() {
362
+ this.pending = null;
363
+ this.pendingTotal = 0;
364
+ this.blockSize = this.constructor.blockSize;
365
+ this.outSize = this.constructor.outSize;
366
+ this.hmacStrength = this.constructor.hmacStrength;
367
+ this.padLength = this.constructor.padLength / 8;
368
+ this.endian = 'big';
369
+
370
+ this._delta8 = this.blockSize / 8;
371
+ this._delta32 = this.blockSize / 32;
372
+ }
373
+ common$5.BlockHash = BlockHash$4;
374
+
375
+ BlockHash$4.prototype.update = function update(msg, enc) {
376
+ // Convert message to array, pad it, and join into 32bit blocks
377
+ msg = utils$8.toArray(msg, enc);
378
+ if (!this.pending)
379
+ this.pending = msg;
380
+ else
381
+ this.pending = this.pending.concat(msg);
382
+ this.pendingTotal += msg.length;
383
+
384
+ // Enough data, try updating
385
+ if (this.pending.length >= this._delta8) {
386
+ msg = this.pending;
387
+
388
+ // Process pending data in blocks
389
+ var r = msg.length % this._delta8;
390
+ this.pending = msg.slice(msg.length - r, msg.length);
391
+ if (this.pending.length === 0)
392
+ this.pending = null;
393
+
394
+ msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
395
+ for (var i = 0; i < msg.length; i += this._delta32)
396
+ this._update(msg, i, i + this._delta32);
397
+ }
398
+
399
+ return this;
400
+ };
401
+
402
+ BlockHash$4.prototype.digest = function digest(enc) {
403
+ this.update(this._pad());
404
+ assert$4(this.pending === null);
405
+
406
+ return this._digest(enc);
407
+ };
408
+
409
+ BlockHash$4.prototype._pad = function pad() {
410
+ var len = this.pendingTotal;
411
+ var bytes = this._delta8;
412
+ var k = bytes - ((len + this.padLength) % bytes);
413
+ var res = new Array(k + this.padLength);
414
+ res[0] = 0x80;
415
+ for (var i = 1; i < k; i++)
416
+ res[i] = 0;
417
+
418
+ // Append length
419
+ len <<= 3;
420
+ if (this.endian === 'big') {
421
+ for (var t = 8; t < this.padLength; t++)
422
+ res[i++] = 0;
423
+
424
+ res[i++] = 0;
425
+ res[i++] = 0;
426
+ res[i++] = 0;
427
+ res[i++] = 0;
428
+ res[i++] = (len >>> 24) & 0xff;
429
+ res[i++] = (len >>> 16) & 0xff;
430
+ res[i++] = (len >>> 8) & 0xff;
431
+ res[i++] = len & 0xff;
432
+ } else {
433
+ res[i++] = len & 0xff;
434
+ res[i++] = (len >>> 8) & 0xff;
435
+ res[i++] = (len >>> 16) & 0xff;
436
+ res[i++] = (len >>> 24) & 0xff;
437
+ res[i++] = 0;
438
+ res[i++] = 0;
439
+ res[i++] = 0;
440
+ res[i++] = 0;
441
+
442
+ for (t = 8; t < this.padLength; t++)
443
+ res[i++] = 0;
444
+ }
445
+
446
+ return res;
447
+ };
448
+
449
+ var sha = {};
450
+
451
+ var common$4 = {};
452
+
453
+ var utils$7 = utils$9;
454
+ var rotr32 = utils$7.rotr32;
455
+
456
+ function ft_1$1(s, x, y, z) {
457
+ if (s === 0)
458
+ return ch32$1(x, y, z);
459
+ if (s === 1 || s === 3)
460
+ return p32(x, y, z);
461
+ if (s === 2)
462
+ return maj32$1(x, y, z);
463
+ }
464
+ common$4.ft_1 = ft_1$1;
465
+
466
+ function ch32$1(x, y, z) {
467
+ return (x & y) ^ ((~x) & z);
468
+ }
469
+ common$4.ch32 = ch32$1;
470
+
471
+ function maj32$1(x, y, z) {
472
+ return (x & y) ^ (x & z) ^ (y & z);
473
+ }
474
+ common$4.maj32 = maj32$1;
475
+
476
+ function p32(x, y, z) {
477
+ return x ^ y ^ z;
478
+ }
479
+ common$4.p32 = p32;
480
+
481
+ function s0_256$1(x) {
482
+ return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
483
+ }
484
+ common$4.s0_256 = s0_256$1;
485
+
486
+ function s1_256$1(x) {
487
+ return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
488
+ }
489
+ common$4.s1_256 = s1_256$1;
490
+
491
+ function g0_256$1(x) {
492
+ return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
493
+ }
494
+ common$4.g0_256 = g0_256$1;
495
+
496
+ function g1_256$1(x) {
497
+ return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
498
+ }
499
+ common$4.g1_256 = g1_256$1;
500
+
501
+ var utils$6 = utils$9;
502
+ var common$3 = common$5;
503
+ var shaCommon$1 = common$4;
504
+
505
+ var rotl32$1 = utils$6.rotl32;
506
+ var sum32$2 = utils$6.sum32;
507
+ var sum32_5$1 = utils$6.sum32_5;
508
+ var ft_1 = shaCommon$1.ft_1;
509
+ var BlockHash$3 = common$3.BlockHash;
510
+
511
+ var sha1_K = [
512
+ 0x5A827999, 0x6ED9EBA1,
513
+ 0x8F1BBCDC, 0xCA62C1D6
514
+ ];
515
+
516
+ function SHA1() {
517
+ if (!(this instanceof SHA1))
518
+ return new SHA1();
519
+
520
+ BlockHash$3.call(this);
521
+ this.h = [
522
+ 0x67452301, 0xefcdab89, 0x98badcfe,
523
+ 0x10325476, 0xc3d2e1f0 ];
524
+ this.W = new Array(80);
525
+ }
526
+
527
+ utils$6.inherits(SHA1, BlockHash$3);
528
+ var _1 = SHA1;
529
+
530
+ SHA1.blockSize = 512;
531
+ SHA1.outSize = 160;
532
+ SHA1.hmacStrength = 80;
533
+ SHA1.padLength = 64;
534
+
535
+ SHA1.prototype._update = function _update(msg, start) {
536
+ var W = this.W;
537
+
538
+ for (var i = 0; i < 16; i++)
539
+ W[i] = msg[start + i];
540
+
541
+ for(; i < W.length; i++)
542
+ W[i] = rotl32$1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
543
+
544
+ var a = this.h[0];
545
+ var b = this.h[1];
546
+ var c = this.h[2];
547
+ var d = this.h[3];
548
+ var e = this.h[4];
549
+
550
+ for (i = 0; i < W.length; i++) {
551
+ var s = ~~(i / 20);
552
+ var t = sum32_5$1(rotl32$1(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
553
+ e = d;
554
+ d = c;
555
+ c = rotl32$1(b, 30);
556
+ b = a;
557
+ a = t;
558
+ }
559
+
560
+ this.h[0] = sum32$2(this.h[0], a);
561
+ this.h[1] = sum32$2(this.h[1], b);
562
+ this.h[2] = sum32$2(this.h[2], c);
563
+ this.h[3] = sum32$2(this.h[3], d);
564
+ this.h[4] = sum32$2(this.h[4], e);
565
+ };
566
+
567
+ SHA1.prototype._digest = function digest(enc) {
568
+ if (enc === 'hex')
569
+ return utils$6.toHex32(this.h, 'big');
570
+ else
571
+ return utils$6.split32(this.h, 'big');
572
+ };
573
+
574
+ var utils$5 = utils$9;
575
+ var common$2 = common$5;
576
+ var shaCommon = common$4;
577
+ var assert$3 = minimalisticAssert;
578
+
579
+ var sum32$1 = utils$5.sum32;
580
+ var sum32_4$1 = utils$5.sum32_4;
581
+ var sum32_5 = utils$5.sum32_5;
582
+ var ch32 = shaCommon.ch32;
583
+ var maj32 = shaCommon.maj32;
584
+ var s0_256 = shaCommon.s0_256;
585
+ var s1_256 = shaCommon.s1_256;
586
+ var g0_256 = shaCommon.g0_256;
587
+ var g1_256 = shaCommon.g1_256;
588
+
589
+ var BlockHash$2 = common$2.BlockHash;
590
+
591
+ var sha256_K = [
592
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
593
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
594
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
595
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
596
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
597
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
598
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
599
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
600
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
601
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
602
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
603
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
604
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
605
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
606
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
607
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
608
+ ];
609
+
610
+ function SHA256$1() {
611
+ if (!(this instanceof SHA256$1))
612
+ return new SHA256$1();
613
+
614
+ BlockHash$2.call(this);
615
+ this.h = [
616
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
617
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
618
+ ];
619
+ this.k = sha256_K;
620
+ this.W = new Array(64);
621
+ }
622
+ utils$5.inherits(SHA256$1, BlockHash$2);
623
+ var _256 = SHA256$1;
624
+
625
+ SHA256$1.blockSize = 512;
626
+ SHA256$1.outSize = 256;
627
+ SHA256$1.hmacStrength = 192;
628
+ SHA256$1.padLength = 64;
629
+
630
+ SHA256$1.prototype._update = function _update(msg, start) {
631
+ var W = this.W;
632
+
633
+ for (var i = 0; i < 16; i++)
634
+ W[i] = msg[start + i];
635
+ for (; i < W.length; i++)
636
+ W[i] = sum32_4$1(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
637
+
638
+ var a = this.h[0];
639
+ var b = this.h[1];
640
+ var c = this.h[2];
641
+ var d = this.h[3];
642
+ var e = this.h[4];
643
+ var f = this.h[5];
644
+ var g = this.h[6];
645
+ var h = this.h[7];
646
+
647
+ assert$3(this.k.length === W.length);
648
+ for (i = 0; i < W.length; i++) {
649
+ var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
650
+ var T2 = sum32$1(s0_256(a), maj32(a, b, c));
651
+ h = g;
652
+ g = f;
653
+ f = e;
654
+ e = sum32$1(d, T1);
655
+ d = c;
656
+ c = b;
657
+ b = a;
658
+ a = sum32$1(T1, T2);
659
+ }
660
+
661
+ this.h[0] = sum32$1(this.h[0], a);
662
+ this.h[1] = sum32$1(this.h[1], b);
663
+ this.h[2] = sum32$1(this.h[2], c);
664
+ this.h[3] = sum32$1(this.h[3], d);
665
+ this.h[4] = sum32$1(this.h[4], e);
666
+ this.h[5] = sum32$1(this.h[5], f);
667
+ this.h[6] = sum32$1(this.h[6], g);
668
+ this.h[7] = sum32$1(this.h[7], h);
669
+ };
670
+
671
+ SHA256$1.prototype._digest = function digest(enc) {
672
+ if (enc === 'hex')
673
+ return utils$5.toHex32(this.h, 'big');
674
+ else
675
+ return utils$5.split32(this.h, 'big');
676
+ };
677
+
678
+ var utils$4 = utils$9;
679
+ var SHA256 = _256;
680
+
681
+ function SHA224() {
682
+ if (!(this instanceof SHA224))
683
+ return new SHA224();
684
+
685
+ SHA256.call(this);
686
+ this.h = [
687
+ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
688
+ 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
689
+ }
690
+ utils$4.inherits(SHA224, SHA256);
691
+ var _224 = SHA224;
692
+
693
+ SHA224.blockSize = 512;
694
+ SHA224.outSize = 224;
695
+ SHA224.hmacStrength = 192;
696
+ SHA224.padLength = 64;
697
+
698
+ SHA224.prototype._digest = function digest(enc) {
699
+ // Just truncate output
700
+ if (enc === 'hex')
701
+ return utils$4.toHex32(this.h.slice(0, 7), 'big');
702
+ else
703
+ return utils$4.split32(this.h.slice(0, 7), 'big');
704
+ };
705
+
706
+ var utils$3 = utils$9;
707
+ var common$1 = common$5;
708
+ var assert$2 = minimalisticAssert;
709
+
710
+ var rotr64_hi = utils$3.rotr64_hi;
711
+ var rotr64_lo = utils$3.rotr64_lo;
712
+ var shr64_hi = utils$3.shr64_hi;
713
+ var shr64_lo = utils$3.shr64_lo;
714
+ var sum64 = utils$3.sum64;
715
+ var sum64_hi = utils$3.sum64_hi;
716
+ var sum64_lo = utils$3.sum64_lo;
717
+ var sum64_4_hi = utils$3.sum64_4_hi;
718
+ var sum64_4_lo = utils$3.sum64_4_lo;
719
+ var sum64_5_hi = utils$3.sum64_5_hi;
720
+ var sum64_5_lo = utils$3.sum64_5_lo;
721
+
722
+ var BlockHash$1 = common$1.BlockHash;
723
+
724
+ var sha512_K = [
725
+ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
726
+ 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
727
+ 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
728
+ 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
729
+ 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
730
+ 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
731
+ 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
732
+ 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
733
+ 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
734
+ 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
735
+ 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
736
+ 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
737
+ 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
738
+ 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
739
+ 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
740
+ 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
741
+ 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
742
+ 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
743
+ 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
744
+ 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
745
+ 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
746
+ 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
747
+ 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
748
+ 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
749
+ 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
750
+ 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
751
+ 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
752
+ 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
753
+ 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
754
+ 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
755
+ 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
756
+ 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
757
+ 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
758
+ 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
759
+ 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
760
+ 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
761
+ 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
762
+ 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
763
+ 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
764
+ 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
765
+ ];
766
+
767
+ function SHA512$1() {
768
+ if (!(this instanceof SHA512$1))
769
+ return new SHA512$1();
770
+
771
+ BlockHash$1.call(this);
772
+ this.h = [
773
+ 0x6a09e667, 0xf3bcc908,
774
+ 0xbb67ae85, 0x84caa73b,
775
+ 0x3c6ef372, 0xfe94f82b,
776
+ 0xa54ff53a, 0x5f1d36f1,
777
+ 0x510e527f, 0xade682d1,
778
+ 0x9b05688c, 0x2b3e6c1f,
779
+ 0x1f83d9ab, 0xfb41bd6b,
780
+ 0x5be0cd19, 0x137e2179 ];
781
+ this.k = sha512_K;
782
+ this.W = new Array(160);
783
+ }
784
+ utils$3.inherits(SHA512$1, BlockHash$1);
785
+ var _512 = SHA512$1;
786
+
787
+ SHA512$1.blockSize = 1024;
788
+ SHA512$1.outSize = 512;
789
+ SHA512$1.hmacStrength = 192;
790
+ SHA512$1.padLength = 128;
791
+
792
+ SHA512$1.prototype._prepareBlock = function _prepareBlock(msg, start) {
793
+ var W = this.W;
794
+
795
+ // 32 x 32bit words
796
+ for (var i = 0; i < 32; i++)
797
+ W[i] = msg[start + i];
798
+ for (; i < W.length; i += 2) {
799
+ var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
800
+ var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
801
+ var c1_hi = W[i - 14]; // i - 7
802
+ var c1_lo = W[i - 13];
803
+ var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
804
+ var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
805
+ var c3_hi = W[i - 32]; // i - 16
806
+ var c3_lo = W[i - 31];
807
+
808
+ W[i] = sum64_4_hi(
809
+ c0_hi, c0_lo,
810
+ c1_hi, c1_lo,
811
+ c2_hi, c2_lo,
812
+ c3_hi, c3_lo);
813
+ W[i + 1] = sum64_4_lo(
814
+ c0_hi, c0_lo,
815
+ c1_hi, c1_lo,
816
+ c2_hi, c2_lo,
817
+ c3_hi, c3_lo);
818
+ }
819
+ };
820
+
821
+ SHA512$1.prototype._update = function _update(msg, start) {
822
+ this._prepareBlock(msg, start);
823
+
824
+ var W = this.W;
825
+
826
+ var ah = this.h[0];
827
+ var al = this.h[1];
828
+ var bh = this.h[2];
829
+ var bl = this.h[3];
830
+ var ch = this.h[4];
831
+ var cl = this.h[5];
832
+ var dh = this.h[6];
833
+ var dl = this.h[7];
834
+ var eh = this.h[8];
835
+ var el = this.h[9];
836
+ var fh = this.h[10];
837
+ var fl = this.h[11];
838
+ var gh = this.h[12];
839
+ var gl = this.h[13];
840
+ var hh = this.h[14];
841
+ var hl = this.h[15];
842
+
843
+ assert$2(this.k.length === W.length);
844
+ for (var i = 0; i < W.length; i += 2) {
845
+ var c0_hi = hh;
846
+ var c0_lo = hl;
847
+ var c1_hi = s1_512_hi(eh, el);
848
+ var c1_lo = s1_512_lo(eh, el);
849
+ var c2_hi = ch64_hi(eh, el, fh, fl, gh);
850
+ var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
851
+ var c3_hi = this.k[i];
852
+ var c3_lo = this.k[i + 1];
853
+ var c4_hi = W[i];
854
+ var c4_lo = W[i + 1];
855
+
856
+ var T1_hi = sum64_5_hi(
857
+ c0_hi, c0_lo,
858
+ c1_hi, c1_lo,
859
+ c2_hi, c2_lo,
860
+ c3_hi, c3_lo,
861
+ c4_hi, c4_lo);
862
+ var T1_lo = sum64_5_lo(
863
+ c0_hi, c0_lo,
864
+ c1_hi, c1_lo,
865
+ c2_hi, c2_lo,
866
+ c3_hi, c3_lo,
867
+ c4_hi, c4_lo);
868
+
869
+ c0_hi = s0_512_hi(ah, al);
870
+ c0_lo = s0_512_lo(ah, al);
871
+ c1_hi = maj64_hi(ah, al, bh, bl, ch);
872
+ c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
873
+
874
+ var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
875
+ var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
876
+
877
+ hh = gh;
878
+ hl = gl;
879
+
880
+ gh = fh;
881
+ gl = fl;
882
+
883
+ fh = eh;
884
+ fl = el;
885
+
886
+ eh = sum64_hi(dh, dl, T1_hi, T1_lo);
887
+ el = sum64_lo(dl, dl, T1_hi, T1_lo);
888
+
889
+ dh = ch;
890
+ dl = cl;
891
+
892
+ ch = bh;
893
+ cl = bl;
894
+
895
+ bh = ah;
896
+ bl = al;
897
+
898
+ ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
899
+ al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
900
+ }
901
+
902
+ sum64(this.h, 0, ah, al);
903
+ sum64(this.h, 2, bh, bl);
904
+ sum64(this.h, 4, ch, cl);
905
+ sum64(this.h, 6, dh, dl);
906
+ sum64(this.h, 8, eh, el);
907
+ sum64(this.h, 10, fh, fl);
908
+ sum64(this.h, 12, gh, gl);
909
+ sum64(this.h, 14, hh, hl);
910
+ };
911
+
912
+ SHA512$1.prototype._digest = function digest(enc) {
913
+ if (enc === 'hex')
914
+ return utils$3.toHex32(this.h, 'big');
915
+ else
916
+ return utils$3.split32(this.h, 'big');
917
+ };
918
+
919
+ function ch64_hi(xh, xl, yh, yl, zh) {
920
+ var r = (xh & yh) ^ ((~xh) & zh);
921
+ if (r < 0)
922
+ r += 0x100000000;
923
+ return r;
924
+ }
925
+
926
+ function ch64_lo(xh, xl, yh, yl, zh, zl) {
927
+ var r = (xl & yl) ^ ((~xl) & zl);
928
+ if (r < 0)
929
+ r += 0x100000000;
930
+ return r;
931
+ }
932
+
933
+ function maj64_hi(xh, xl, yh, yl, zh) {
934
+ var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
935
+ if (r < 0)
936
+ r += 0x100000000;
937
+ return r;
938
+ }
939
+
940
+ function maj64_lo(xh, xl, yh, yl, zh, zl) {
941
+ var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
942
+ if (r < 0)
943
+ r += 0x100000000;
944
+ return r;
945
+ }
946
+
947
+ function s0_512_hi(xh, xl) {
948
+ var c0_hi = rotr64_hi(xh, xl, 28);
949
+ var c1_hi = rotr64_hi(xl, xh, 2); // 34
950
+ var c2_hi = rotr64_hi(xl, xh, 7); // 39
951
+
952
+ var r = c0_hi ^ c1_hi ^ c2_hi;
953
+ if (r < 0)
954
+ r += 0x100000000;
955
+ return r;
956
+ }
957
+
958
+ function s0_512_lo(xh, xl) {
959
+ var c0_lo = rotr64_lo(xh, xl, 28);
960
+ var c1_lo = rotr64_lo(xl, xh, 2); // 34
961
+ var c2_lo = rotr64_lo(xl, xh, 7); // 39
962
+
963
+ var r = c0_lo ^ c1_lo ^ c2_lo;
964
+ if (r < 0)
965
+ r += 0x100000000;
966
+ return r;
967
+ }
968
+
969
+ function s1_512_hi(xh, xl) {
970
+ var c0_hi = rotr64_hi(xh, xl, 14);
971
+ var c1_hi = rotr64_hi(xh, xl, 18);
972
+ var c2_hi = rotr64_hi(xl, xh, 9); // 41
973
+
974
+ var r = c0_hi ^ c1_hi ^ c2_hi;
975
+ if (r < 0)
976
+ r += 0x100000000;
977
+ return r;
978
+ }
979
+
980
+ function s1_512_lo(xh, xl) {
981
+ var c0_lo = rotr64_lo(xh, xl, 14);
982
+ var c1_lo = rotr64_lo(xh, xl, 18);
983
+ var c2_lo = rotr64_lo(xl, xh, 9); // 41
984
+
985
+ var r = c0_lo ^ c1_lo ^ c2_lo;
986
+ if (r < 0)
987
+ r += 0x100000000;
988
+ return r;
989
+ }
990
+
991
+ function g0_512_hi(xh, xl) {
992
+ var c0_hi = rotr64_hi(xh, xl, 1);
993
+ var c1_hi = rotr64_hi(xh, xl, 8);
994
+ var c2_hi = shr64_hi(xh, xl, 7);
995
+
996
+ var r = c0_hi ^ c1_hi ^ c2_hi;
997
+ if (r < 0)
998
+ r += 0x100000000;
999
+ return r;
1000
+ }
1001
+
1002
+ function g0_512_lo(xh, xl) {
1003
+ var c0_lo = rotr64_lo(xh, xl, 1);
1004
+ var c1_lo = rotr64_lo(xh, xl, 8);
1005
+ var c2_lo = shr64_lo(xh, xl, 7);
1006
+
1007
+ var r = c0_lo ^ c1_lo ^ c2_lo;
1008
+ if (r < 0)
1009
+ r += 0x100000000;
1010
+ return r;
1011
+ }
1012
+
1013
+ function g1_512_hi(xh, xl) {
1014
+ var c0_hi = rotr64_hi(xh, xl, 19);
1015
+ var c1_hi = rotr64_hi(xl, xh, 29); // 61
1016
+ var c2_hi = shr64_hi(xh, xl, 6);
1017
+
1018
+ var r = c0_hi ^ c1_hi ^ c2_hi;
1019
+ if (r < 0)
1020
+ r += 0x100000000;
1021
+ return r;
1022
+ }
1023
+
1024
+ function g1_512_lo(xh, xl) {
1025
+ var c0_lo = rotr64_lo(xh, xl, 19);
1026
+ var c1_lo = rotr64_lo(xl, xh, 29); // 61
1027
+ var c2_lo = shr64_lo(xh, xl, 6);
1028
+
1029
+ var r = c0_lo ^ c1_lo ^ c2_lo;
1030
+ if (r < 0)
1031
+ r += 0x100000000;
1032
+ return r;
1033
+ }
1034
+
1035
+ var utils$2 = utils$9;
1036
+
1037
+ var SHA512 = _512;
1038
+
1039
+ function SHA384() {
1040
+ if (!(this instanceof SHA384))
1041
+ return new SHA384();
1042
+
1043
+ SHA512.call(this);
1044
+ this.h = [
1045
+ 0xcbbb9d5d, 0xc1059ed8,
1046
+ 0x629a292a, 0x367cd507,
1047
+ 0x9159015a, 0x3070dd17,
1048
+ 0x152fecd8, 0xf70e5939,
1049
+ 0x67332667, 0xffc00b31,
1050
+ 0x8eb44a87, 0x68581511,
1051
+ 0xdb0c2e0d, 0x64f98fa7,
1052
+ 0x47b5481d, 0xbefa4fa4 ];
1053
+ }
1054
+ utils$2.inherits(SHA384, SHA512);
1055
+ var _384 = SHA384;
1056
+
1057
+ SHA384.blockSize = 1024;
1058
+ SHA384.outSize = 384;
1059
+ SHA384.hmacStrength = 192;
1060
+ SHA384.padLength = 128;
1061
+
1062
+ SHA384.prototype._digest = function digest(enc) {
1063
+ if (enc === 'hex')
1064
+ return utils$2.toHex32(this.h.slice(0, 12), 'big');
1065
+ else
1066
+ return utils$2.split32(this.h.slice(0, 12), 'big');
1067
+ };
1068
+
1069
+ sha.sha1 = _1;
1070
+ sha.sha224 = _224;
1071
+ sha.sha256 = _256;
1072
+ sha.sha384 = _384;
1073
+ sha.sha512 = _512;
1074
+
1075
+ var ripemd = {};
1076
+
1077
+ var utils$1 = utils$9;
1078
+ var common = common$5;
1079
+
1080
+ var rotl32 = utils$1.rotl32;
1081
+ var sum32 = utils$1.sum32;
1082
+ var sum32_3 = utils$1.sum32_3;
1083
+ var sum32_4 = utils$1.sum32_4;
1084
+ var BlockHash = common.BlockHash;
1085
+
1086
+ function RIPEMD160() {
1087
+ if (!(this instanceof RIPEMD160))
1088
+ return new RIPEMD160();
1089
+
1090
+ BlockHash.call(this);
1091
+
1092
+ this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
1093
+ this.endian = 'little';
1094
+ }
1095
+ utils$1.inherits(RIPEMD160, BlockHash);
1096
+ ripemd.ripemd160 = RIPEMD160;
1097
+
1098
+ RIPEMD160.blockSize = 512;
1099
+ RIPEMD160.outSize = 160;
1100
+ RIPEMD160.hmacStrength = 192;
1101
+ RIPEMD160.padLength = 64;
1102
+
1103
+ RIPEMD160.prototype._update = function update(msg, start) {
1104
+ var A = this.h[0];
1105
+ var B = this.h[1];
1106
+ var C = this.h[2];
1107
+ var D = this.h[3];
1108
+ var E = this.h[4];
1109
+ var Ah = A;
1110
+ var Bh = B;
1111
+ var Ch = C;
1112
+ var Dh = D;
1113
+ var Eh = E;
1114
+ for (var j = 0; j < 80; j++) {
1115
+ var T = sum32(
1116
+ rotl32(
1117
+ sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
1118
+ s[j]),
1119
+ E);
1120
+ A = E;
1121
+ E = D;
1122
+ D = rotl32(C, 10);
1123
+ C = B;
1124
+ B = T;
1125
+ T = sum32(
1126
+ rotl32(
1127
+ sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
1128
+ sh[j]),
1129
+ Eh);
1130
+ Ah = Eh;
1131
+ Eh = Dh;
1132
+ Dh = rotl32(Ch, 10);
1133
+ Ch = Bh;
1134
+ Bh = T;
1135
+ }
1136
+ T = sum32_3(this.h[1], C, Dh);
1137
+ this.h[1] = sum32_3(this.h[2], D, Eh);
1138
+ this.h[2] = sum32_3(this.h[3], E, Ah);
1139
+ this.h[3] = sum32_3(this.h[4], A, Bh);
1140
+ this.h[4] = sum32_3(this.h[0], B, Ch);
1141
+ this.h[0] = T;
1142
+ };
1143
+
1144
+ RIPEMD160.prototype._digest = function digest(enc) {
1145
+ if (enc === 'hex')
1146
+ return utils$1.toHex32(this.h, 'little');
1147
+ else
1148
+ return utils$1.split32(this.h, 'little');
1149
+ };
1150
+
1151
+ function f(j, x, y, z) {
1152
+ if (j <= 15)
1153
+ return x ^ y ^ z;
1154
+ else if (j <= 31)
1155
+ return (x & y) | ((~x) & z);
1156
+ else if (j <= 47)
1157
+ return (x | (~y)) ^ z;
1158
+ else if (j <= 63)
1159
+ return (x & z) | (y & (~z));
1160
+ else
1161
+ return x ^ (y | (~z));
1162
+ }
1163
+
1164
+ function K(j) {
1165
+ if (j <= 15)
1166
+ return 0x00000000;
1167
+ else if (j <= 31)
1168
+ return 0x5a827999;
1169
+ else if (j <= 47)
1170
+ return 0x6ed9eba1;
1171
+ else if (j <= 63)
1172
+ return 0x8f1bbcdc;
1173
+ else
1174
+ return 0xa953fd4e;
1175
+ }
1176
+
1177
+ function Kh(j) {
1178
+ if (j <= 15)
1179
+ return 0x50a28be6;
1180
+ else if (j <= 31)
1181
+ return 0x5c4dd124;
1182
+ else if (j <= 47)
1183
+ return 0x6d703ef3;
1184
+ else if (j <= 63)
1185
+ return 0x7a6d76e9;
1186
+ else
1187
+ return 0x00000000;
1188
+ }
1189
+
1190
+ var r = [
1191
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1192
+ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
1193
+ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1194
+ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
1195
+ 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
1196
+ ];
1197
+
1198
+ var rh = [
1199
+ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
1200
+ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
1201
+ 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
1202
+ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
1203
+ 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
1204
+ ];
1205
+
1206
+ var s = [
1207
+ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
1208
+ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
1209
+ 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
1210
+ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
1211
+ 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
1212
+ ];
1213
+
1214
+ var sh = [
1215
+ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
1216
+ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
1217
+ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
1218
+ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
1219
+ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
1220
+ ];
1221
+
1222
+ var utils = utils$9;
1223
+ var assert$1 = minimalisticAssert;
1224
+
1225
+ function Hmac(hash, key, enc) {
1226
+ if (!(this instanceof Hmac))
1227
+ return new Hmac(hash, key, enc);
1228
+ this.Hash = hash;
1229
+ this.blockSize = hash.blockSize / 8;
1230
+ this.outSize = hash.outSize / 8;
1231
+ this.inner = null;
1232
+ this.outer = null;
1233
+
1234
+ this._init(utils.toArray(key, enc));
1235
+ }
1236
+ var hmac = Hmac;
1237
+
1238
+ Hmac.prototype._init = function init(key) {
1239
+ // Shorten key, if needed
1240
+ if (key.length > this.blockSize)
1241
+ key = new this.Hash().update(key).digest();
1242
+ assert$1(key.length <= this.blockSize);
1243
+
1244
+ // Add padding to key
1245
+ for (var i = key.length; i < this.blockSize; i++)
1246
+ key.push(0);
1247
+
1248
+ for (i = 0; i < key.length; i++)
1249
+ key[i] ^= 0x36;
1250
+ this.inner = new this.Hash().update(key);
1251
+
1252
+ // 0x36 ^ 0x5c = 0x6a
1253
+ for (i = 0; i < key.length; i++)
1254
+ key[i] ^= 0x6a;
1255
+ this.outer = new this.Hash().update(key);
1256
+ };
1257
+
1258
+ Hmac.prototype.update = function update(msg, enc) {
1259
+ this.inner.update(msg, enc);
1260
+ return this;
1261
+ };
1262
+
1263
+ Hmac.prototype.digest = function digest(enc) {
1264
+ this.outer.update(this.inner.digest());
1265
+ return this.outer.digest(enc);
1266
+ };
1267
+
1268
+ (function (exports) {
1269
+ var hash = exports;
1270
+
1271
+ hash.utils = utils$9;
1272
+ hash.common = common$5;
1273
+ hash.sha = sha;
1274
+ hash.ripemd = ripemd;
1275
+ hash.hmac = hmac;
1276
+
1277
+ // Proxy hash functions to the main object
1278
+ hash.sha1 = hash.sha.sha1;
1279
+ hash.sha256 = hash.sha.sha256;
1280
+ hash.sha224 = hash.sha.sha224;
1281
+ hash.sha384 = hash.sha.sha384;
1282
+ hash.sha512 = hash.sha.sha512;
1283
+ hash.ripemd160 = hash.ripemd.ripemd160;
1284
+ }(hash$1));
1285
+
1286
+ var hash = hash$1;
1287
+
1288
+ const version$2 = "logger/5.5.0";
1289
+
1290
+ let _permanentCensorErrors = false;
1291
+ let _censorErrors = false;
1292
+ const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
1293
+ let _logLevel = LogLevels["default"];
1294
+ let _globalLogger = null;
1295
+ function _checkNormalize() {
1296
+ try {
1297
+ const missing = [];
1298
+ // Make sure all forms of normalization are supported
1299
+ ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
1300
+ try {
1301
+ if ("test".normalize(form) !== "test") {
1302
+ throw new Error("bad normalize");
1303
+ }
1304
+ ;
1305
+ }
1306
+ catch (error) {
1307
+ missing.push(form);
1308
+ }
1309
+ });
1310
+ if (missing.length) {
1311
+ throw new Error("missing " + missing.join(", "));
1312
+ }
1313
+ if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
1314
+ throw new Error("broken implementation");
1315
+ }
1316
+ }
1317
+ catch (error) {
1318
+ return error.message;
1319
+ }
1320
+ return null;
1321
+ }
1322
+ const _normalizeError = _checkNormalize();
1323
+ var LogLevel;
1324
+ (function (LogLevel) {
1325
+ LogLevel["DEBUG"] = "DEBUG";
1326
+ LogLevel["INFO"] = "INFO";
1327
+ LogLevel["WARNING"] = "WARNING";
1328
+ LogLevel["ERROR"] = "ERROR";
1329
+ LogLevel["OFF"] = "OFF";
1330
+ })(LogLevel || (LogLevel = {}));
1331
+ var ErrorCode;
1332
+ (function (ErrorCode) {
1333
+ ///////////////////
1334
+ // Generic Errors
1335
+ // Unknown Error
1336
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1337
+ // Not Implemented
1338
+ ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
1339
+ // Unsupported Operation
1340
+ // - operation
1341
+ ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
1342
+ // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
1343
+ // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
1344
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
1345
+ // Some sort of bad response from the server
1346
+ ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
1347
+ // Timeout
1348
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
1349
+ ///////////////////
1350
+ // Operational Errors
1351
+ // Buffer Overrun
1352
+ ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
1353
+ // Numeric Fault
1354
+ // - operation: the operation being executed
1355
+ // - fault: the reason this faulted
1356
+ ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
1357
+ ///////////////////
1358
+ // Argument Errors
1359
+ // Missing new operator to an object
1360
+ // - name: The name of the class
1361
+ ErrorCode["MISSING_NEW"] = "MISSING_NEW";
1362
+ // Invalid argument (e.g. value is incompatible with type) to a function:
1363
+ // - argument: The argument name that was invalid
1364
+ // - value: The value of the argument
1365
+ ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
1366
+ // Missing argument to a function:
1367
+ // - count: The number of arguments received
1368
+ // - expectedCount: The number of arguments expected
1369
+ ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
1370
+ // Too many arguments
1371
+ // - count: The number of arguments received
1372
+ // - expectedCount: The number of arguments expected
1373
+ ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
1374
+ ///////////////////
1375
+ // Blockchain Errors
1376
+ // Call exception
1377
+ // - transaction: the transaction
1378
+ // - address?: the contract address
1379
+ // - args?: The arguments passed into the function
1380
+ // - method?: The Solidity method signature
1381
+ // - errorSignature?: The EIP848 error signature
1382
+ // - errorArgs?: The EIP848 error parameters
1383
+ // - reason: The reason (only for EIP848 "Error(string)")
1384
+ ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
1385
+ // Insufficient funds (< value + gasLimit * gasPrice)
1386
+ // - transaction: the transaction attempted
1387
+ ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
1388
+ // Nonce has already been used
1389
+ // - transaction: the transaction attempted
1390
+ ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
1391
+ // The replacement fee for the transaction is too low
1392
+ // - transaction: the transaction attempted
1393
+ ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
1394
+ // The gas limit could not be estimated
1395
+ // - transaction: the transaction passed to estimateGas
1396
+ ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
1397
+ // The transaction was replaced by one with a higher gas price
1398
+ // - reason: "cancelled", "replaced" or "repriced"
1399
+ // - cancelled: true if reason == "cancelled" or reason == "replaced")
1400
+ // - hash: original transaction hash
1401
+ // - replacement: the full TransactionsResponse for the replacement
1402
+ // - receipt: the receipt of the replacement
1403
+ ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
1404
+ })(ErrorCode || (ErrorCode = {}));
1405
+ const HEX = "0123456789abcdef";
1406
+ class Logger {
1407
+ constructor(version) {
1408
+ Object.defineProperty(this, "version", {
1409
+ enumerable: true,
1410
+ value: version,
1411
+ writable: false
1412
+ });
1413
+ }
1414
+ _log(logLevel, args) {
1415
+ const level = logLevel.toLowerCase();
1416
+ if (LogLevels[level] == null) {
1417
+ this.throwArgumentError("invalid log level name", "logLevel", logLevel);
1418
+ }
1419
+ if (_logLevel > LogLevels[level]) {
1420
+ return;
1421
+ }
1422
+ console.log.apply(console, args);
1423
+ }
1424
+ debug(...args) {
1425
+ this._log(Logger.levels.DEBUG, args);
1426
+ }
1427
+ info(...args) {
1428
+ this._log(Logger.levels.INFO, args);
1429
+ }
1430
+ warn(...args) {
1431
+ this._log(Logger.levels.WARNING, args);
1432
+ }
1433
+ makeError(message, code, params) {
1434
+ // Errors are being censored
1435
+ if (_censorErrors) {
1436
+ return this.makeError("censored error", code, {});
1437
+ }
1438
+ if (!code) {
1439
+ code = Logger.errors.UNKNOWN_ERROR;
1440
+ }
1441
+ if (!params) {
1442
+ params = {};
1443
+ }
1444
+ const messageDetails = [];
1445
+ Object.keys(params).forEach((key) => {
1446
+ const value = params[key];
1447
+ try {
1448
+ if (value instanceof Uint8Array) {
1449
+ let hex = "";
1450
+ for (let i = 0; i < value.length; i++) {
1451
+ hex += HEX[value[i] >> 4];
1452
+ hex += HEX[value[i] & 0x0f];
1453
+ }
1454
+ messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
1455
+ }
1456
+ else {
1457
+ messageDetails.push(key + "=" + JSON.stringify(value));
1458
+ }
1459
+ }
1460
+ catch (error) {
1461
+ messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
1462
+ }
1463
+ });
1464
+ messageDetails.push(`code=${code}`);
1465
+ messageDetails.push(`version=${this.version}`);
1466
+ const reason = message;
1467
+ if (messageDetails.length) {
1468
+ message += " (" + messageDetails.join(", ") + ")";
1469
+ }
1470
+ // @TODO: Any??
1471
+ const error = new Error(message);
1472
+ error.reason = reason;
1473
+ error.code = code;
1474
+ Object.keys(params).forEach(function (key) {
1475
+ error[key] = params[key];
1476
+ });
1477
+ return error;
1478
+ }
1479
+ throwError(message, code, params) {
1480
+ throw this.makeError(message, code, params);
1481
+ }
1482
+ throwArgumentError(message, name, value) {
1483
+ return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
1484
+ argument: name,
1485
+ value: value
1486
+ });
1487
+ }
1488
+ assert(condition, message, code, params) {
1489
+ if (!!condition) {
1490
+ return;
1491
+ }
1492
+ this.throwError(message, code, params);
1493
+ }
1494
+ assertArgument(condition, message, name, value) {
1495
+ if (!!condition) {
1496
+ return;
1497
+ }
1498
+ this.throwArgumentError(message, name, value);
1499
+ }
1500
+ checkNormalize(message) {
1501
+ if (_normalizeError) {
1502
+ this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
1503
+ operation: "String.prototype.normalize", form: _normalizeError
1504
+ });
1505
+ }
1506
+ }
1507
+ checkSafeUint53(value, message) {
1508
+ if (typeof (value) !== "number") {
1509
+ return;
1510
+ }
1511
+ if (message == null) {
1512
+ message = "value not safe";
1513
+ }
1514
+ if (value < 0 || value >= 0x1fffffffffffff) {
1515
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1516
+ operation: "checkSafeInteger",
1517
+ fault: "out-of-safe-range",
1518
+ value: value
1519
+ });
1520
+ }
1521
+ if (value % 1) {
1522
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1523
+ operation: "checkSafeInteger",
1524
+ fault: "non-integer",
1525
+ value: value
1526
+ });
1527
+ }
1528
+ }
1529
+ checkArgumentCount(count, expectedCount, message) {
1530
+ if (message) {
1531
+ message = ": " + message;
1532
+ }
1533
+ else {
1534
+ message = "";
1535
+ }
1536
+ if (count < expectedCount) {
1537
+ this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
1538
+ count: count,
1539
+ expectedCount: expectedCount
1540
+ });
1541
+ }
1542
+ if (count > expectedCount) {
1543
+ this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
1544
+ count: count,
1545
+ expectedCount: expectedCount
1546
+ });
1547
+ }
1548
+ }
1549
+ checkNew(target, kind) {
1550
+ if (target === Object || target == null) {
1551
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1552
+ }
1553
+ }
1554
+ checkAbstract(target, kind) {
1555
+ if (target === kind) {
1556
+ this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
1557
+ }
1558
+ else if (target === Object || target == null) {
1559
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1560
+ }
1561
+ }
1562
+ static globalLogger() {
1563
+ if (!_globalLogger) {
1564
+ _globalLogger = new Logger(version$2);
1565
+ }
1566
+ return _globalLogger;
1567
+ }
1568
+ static setCensorship(censorship, permanent) {
1569
+ if (!censorship && permanent) {
1570
+ this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
1571
+ operation: "setCensorship"
1572
+ });
1573
+ }
1574
+ if (_permanentCensorErrors) {
1575
+ if (!censorship) {
1576
+ return;
1577
+ }
1578
+ this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
1579
+ operation: "setCensorship"
1580
+ });
1581
+ }
1582
+ _censorErrors = !!censorship;
1583
+ _permanentCensorErrors = !!permanent;
1584
+ }
1585
+ static setLogLevel(logLevel) {
1586
+ const level = LogLevels[logLevel.toLowerCase()];
1587
+ if (level == null) {
1588
+ Logger.globalLogger().warn("invalid log level - " + logLevel);
1589
+ return;
1590
+ }
1591
+ _logLevel = level;
1592
+ }
1593
+ static from(version) {
1594
+ return new Logger(version);
1595
+ }
1596
+ }
1597
+ Logger.errors = ErrorCode;
1598
+ Logger.levels = LogLevel;
1599
+
1600
+ const version$1 = "bytes/5.5.0";
1601
+
1602
+ const logger = new Logger(version$1);
1603
+ ///////////////////////////////
1604
+ function isHexable(value) {
1605
+ return !!(value.toHexString);
1606
+ }
1607
+ function addSlice(array) {
1608
+ if (array.slice) {
1609
+ return array;
1610
+ }
1611
+ array.slice = function () {
1612
+ const args = Array.prototype.slice.call(arguments);
1613
+ return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
1614
+ };
1615
+ return array;
1616
+ }
1617
+ function isInteger(value) {
1618
+ return (typeof (value) === "number" && value == value && (value % 1) === 0);
1619
+ }
1620
+ function isBytes(value) {
1621
+ if (value == null) {
1622
+ return false;
1623
+ }
1624
+ if (value.constructor === Uint8Array) {
1625
+ return true;
1626
+ }
1627
+ if (typeof (value) === "string") {
1628
+ return false;
1629
+ }
1630
+ if (!isInteger(value.length) || value.length < 0) {
1631
+ return false;
1632
+ }
1633
+ for (let i = 0; i < value.length; i++) {
1634
+ const v = value[i];
1635
+ if (!isInteger(v) || v < 0 || v >= 256) {
1636
+ return false;
1637
+ }
1638
+ }
1639
+ return true;
1640
+ }
1641
+ function arrayify(value, options) {
1642
+ if (!options) {
1643
+ options = {};
1644
+ }
1645
+ if (typeof (value) === "number") {
1646
+ logger.checkSafeUint53(value, "invalid arrayify value");
1647
+ const result = [];
1648
+ while (value) {
1649
+ result.unshift(value & 0xff);
1650
+ value = parseInt(String(value / 256));
1651
+ }
1652
+ if (result.length === 0) {
1653
+ result.push(0);
1654
+ }
1655
+ return addSlice(new Uint8Array(result));
1656
+ }
1657
+ if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
1658
+ value = "0x" + value;
1659
+ }
1660
+ if (isHexable(value)) {
1661
+ value = value.toHexString();
1662
+ }
1663
+ if (isHexString(value)) {
1664
+ let hex = value.substring(2);
1665
+ if (hex.length % 2) {
1666
+ if (options.hexPad === "left") {
1667
+ hex = "0x0" + hex.substring(2);
1668
+ }
1669
+ else if (options.hexPad === "right") {
1670
+ hex += "0";
1671
+ }
1672
+ else {
1673
+ logger.throwArgumentError("hex data is odd-length", "value", value);
1674
+ }
1675
+ }
1676
+ const result = [];
1677
+ for (let i = 0; i < hex.length; i += 2) {
1678
+ result.push(parseInt(hex.substring(i, i + 2), 16));
1679
+ }
1680
+ return addSlice(new Uint8Array(result));
1681
+ }
1682
+ if (isBytes(value)) {
1683
+ return addSlice(new Uint8Array(value));
1684
+ }
1685
+ return logger.throwArgumentError("invalid arrayify value", "value", value);
1686
+ }
1687
+ function isHexString(value, length) {
1688
+ if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
1689
+ return false;
1690
+ }
1691
+ if (length && value.length !== 2 + 2 * length) {
1692
+ return false;
1693
+ }
1694
+ return true;
1695
+ }
1696
+
1697
+ const version = "sha2/5.5.0";
1698
+
1699
+ new Logger(version);
1700
+ function sha256(data) {
1701
+ return "0x" + (hash.sha256().update(arrayify(data)).digest("hex"));
1702
+ }
1703
+
29
1704
  class Struct {
30
1705
  constructor(properties) {
31
1706
  Object.assign(this, properties);
@@ -49,8 +1724,7 @@ class Struct {
49
1724
  class Enum extends Struct {
50
1725
  constructor(properties) {
51
1726
  super(properties);
52
-
53
- _defineProperty(this, "enum", '');
1727
+ this.enum = '';
54
1728
 
55
1729
  if (Object.keys(properties).length !== 1) {
56
1730
  throw new Error('Enum can only take single value');
@@ -90,8 +1764,7 @@ class PublicKey extends Struct {
90
1764
  */
91
1765
  constructor(value) {
92
1766
  super({});
93
-
94
- _defineProperty(this, "_bn", void 0);
1767
+ this._bn = void 0;
95
1768
 
96
1769
  if (isPublicKeyData(value)) {
97
1770
  this._bn = value._bn;
@@ -171,16 +1844,20 @@ class PublicKey extends Struct {
171
1844
  * it permission to write data to the account.
172
1845
  */
173
1846
 
1847
+ /* eslint-disable require-await */
1848
+
174
1849
 
175
1850
  static async createWithSeed(fromPublicKey, seed, programId) {
176
1851
  const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);
177
- const hash = await sha256(new Uint8Array(buffer));
1852
+ const hash = sha256(new Uint8Array(buffer)).slice(2);
178
1853
  return new PublicKey(Buffer.from(hash, 'hex'));
179
1854
  }
180
1855
  /**
181
1856
  * Derive a program address from seeds and a program ID.
182
1857
  */
183
1858
 
1859
+ /* eslint-disable require-await */
1860
+
184
1861
 
185
1862
  static async createProgramAddress(seeds, programId) {
186
1863
  let buffer = Buffer.alloc(0);
@@ -192,7 +1869,7 @@ class PublicKey extends Struct {
192
1869
  buffer = Buffer.concat([buffer, toBuffer(seed)]);
193
1870
  });
194
1871
  buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);
195
- let hash = await sha256(new Uint8Array(buffer));
1872
+ let hash = sha256(new Uint8Array(buffer)).slice(2);
196
1873
  let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
197
1874
 
198
1875
  if (is_on_curve(publicKeyBytes)) {
@@ -242,9 +1919,7 @@ class PublicKey extends Struct {
242
1919
  }
243
1920
 
244
1921
  }
245
-
246
- _defineProperty(PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
247
-
1922
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
248
1923
  SOLANA_SCHEMA.set(PublicKey, {
249
1924
  kind: 'struct',
250
1925
  fields: [['_bn', 'u256']]
@@ -317,7 +1992,7 @@ class Account {
317
1992
  * @param secretKey Secret key for the account
318
1993
  */
319
1994
  constructor(secretKey) {
320
- _defineProperty(this, "_keypair", void 0);
1995
+ this._keypair = void 0;
321
1996
 
322
1997
  if (secretKey) {
323
1998
  this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
@@ -453,16 +2128,11 @@ const PUBKEY_LENGTH = 32;
453
2128
 
454
2129
  class Message {
455
2130
  constructor(args) {
456
- _defineProperty(this, "header", void 0);
457
-
458
- _defineProperty(this, "accountKeys", void 0);
459
-
460
- _defineProperty(this, "recentBlockhash", void 0);
461
-
462
- _defineProperty(this, "instructions", void 0);
463
-
464
- _defineProperty(this, "indexToProgramIds", new Map());
465
-
2131
+ this.header = void 0;
2132
+ this.accountKeys = void 0;
2133
+ this.recentBlockhash = void 0;
2134
+ this.instructions = void 0;
2135
+ this.indexToProgramIds = new Map();
466
2136
  this.header = args.header;
467
2137
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
468
2138
  this.recentBlockhash = args.recentBlockhash;
@@ -636,12 +2306,9 @@ class TransactionInstruction {
636
2306
  * Program input
637
2307
  */
638
2308
  constructor(opts) {
639
- _defineProperty(this, "keys", void 0);
640
-
641
- _defineProperty(this, "programId", void 0);
642
-
643
- _defineProperty(this, "data", Buffer.alloc(0));
644
-
2309
+ this.keys = void 0;
2310
+ this.programId = void 0;
2311
+ this.data = Buffer.alloc(0);
645
2312
  this.programId = opts.programId;
646
2313
  this.keys = opts.keys;
647
2314
 
@@ -683,16 +2350,11 @@ class Transaction {
683
2350
  * Construct an empty Transaction
684
2351
  */
685
2352
  constructor(opts) {
686
- _defineProperty(this, "signatures", []);
687
-
688
- _defineProperty(this, "feePayer", void 0);
689
-
690
- _defineProperty(this, "instructions", []);
691
-
692
- _defineProperty(this, "recentBlockhash", void 0);
693
-
694
- _defineProperty(this, "nonceInfo", void 0);
695
-
2353
+ this.signatures = [];
2354
+ this.feePayer = void 0;
2355
+ this.instructions = [];
2356
+ this.recentBlockhash = void 0;
2357
+ this.nonceInfo = void 0;
696
2358
  opts && Object.assign(this, opts);
697
2359
  }
698
2360
  /**
@@ -1343,12 +3005,9 @@ class NonceAccount {
1343
3005
  * @internal
1344
3006
  */
1345
3007
  constructor(args) {
1346
- _defineProperty(this, "authorizedPubkey", void 0);
1347
-
1348
- _defineProperty(this, "nonce", void 0);
1349
-
1350
- _defineProperty(this, "feeCalculator", void 0);
1351
-
3008
+ this.authorizedPubkey = void 0;
3009
+ this.nonce = void 0;
3010
+ this.feeCalculator = void 0;
1352
3011
  this.authorizedPubkey = args.authorizedPubkey;
1353
3012
  this.nonce = args.nonce;
1354
3013
  this.feeCalculator = args.feeCalculator;
@@ -2081,8 +3740,7 @@ class SystemProgram {
2081
3740
  }
2082
3741
 
2083
3742
  }
2084
-
2085
- _defineProperty(SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3743
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
2086
3744
 
2087
3745
  // rest of the Transaction fields
2088
3746
  //
@@ -2111,7 +3769,8 @@ class Loader {
2111
3769
  * Can be used to calculate transaction fees
2112
3770
  */
2113
3771
  static getMinNumSignatures(dataLength) {
2114
- return 2 * (Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
3772
+ return 2 * ( // Every transaction requires two signatures (payer + program)
3773
+ Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
2115
3774
  1) // Add one for Finalize transaction
2116
3775
  ;
2117
3776
  }
@@ -2250,8 +3909,7 @@ class Loader {
2250
3909
  }
2251
3910
 
2252
3911
  }
2253
-
2254
- _defineProperty(Loader, "chunkSize", CHUNK_SIZE);
3912
+ Loader.chunkSize = CHUNK_SIZE;
2255
3913
 
2256
3914
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
2257
3915
  /**
@@ -2302,14 +3960,10 @@ class AgentManager {
2302
3960
  }
2303
3961
 
2304
3962
  constructor(useHttps) {
2305
- _defineProperty(this, "_agent", void 0);
2306
-
2307
- _defineProperty(this, "_activeRequests", 0);
2308
-
2309
- _defineProperty(this, "_destroyTimeout", null);
2310
-
2311
- _defineProperty(this, "_useHttps", void 0);
2312
-
3963
+ this._agent = void 0;
3964
+ this._activeRequests = 0;
3965
+ this._destroyTimeout = null;
3966
+ this._useHttps = void 0;
2313
3967
  this._useHttps = useHttps === true;
2314
3968
  this._agent = AgentManager._newAgent(this._useHttps);
2315
3969
  }
@@ -2382,16 +4036,11 @@ class EpochSchedule {
2382
4036
 
2383
4037
  /** The first slot of `firstNormalEpoch` */
2384
4038
  constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
2385
- _defineProperty(this, "slotsPerEpoch", void 0);
2386
-
2387
- _defineProperty(this, "leaderScheduleSlotOffset", void 0);
2388
-
2389
- _defineProperty(this, "warmup", void 0);
2390
-
2391
- _defineProperty(this, "firstNormalEpoch", void 0);
2392
-
2393
- _defineProperty(this, "firstNormalSlot", void 0);
2394
-
4039
+ this.slotsPerEpoch = void 0;
4040
+ this.leaderScheduleSlotOffset = void 0;
4041
+ this.warmup = void 0;
4042
+ this.firstNormalEpoch = void 0;
4043
+ this.firstNormalSlot = void 0;
2395
4044
  this.slotsPerEpoch = slotsPerEpoch;
2396
4045
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
2397
4046
  this.warmup = warmup;
@@ -2443,9 +4092,7 @@ class EpochSchedule {
2443
4092
  class SendTransactionError extends Error {
2444
4093
  constructor(message, logs) {
2445
4094
  super(message);
2446
-
2447
- _defineProperty(this, "logs", void 0);
2448
-
4095
+ this.logs = void 0;
2449
4096
  this.logs = logs;
2450
4097
  }
2451
4098
 
@@ -3405,67 +5052,39 @@ class Connection {
3405
5052
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
3406
5053
  */
3407
5054
  constructor(endpoint, commitmentOrConfig) {
3408
- _defineProperty(this, "_commitment", void 0);
3409
-
3410
- _defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
3411
-
3412
- _defineProperty(this, "_rpcEndpoint", void 0);
3413
-
3414
- _defineProperty(this, "_rpcWsEndpoint", void 0);
3415
-
3416
- _defineProperty(this, "_rpcClient", void 0);
3417
-
3418
- _defineProperty(this, "_rpcRequest", void 0);
3419
-
3420
- _defineProperty(this, "_rpcBatchRequest", void 0);
3421
-
3422
- _defineProperty(this, "_rpcWebSocket", void 0);
3423
-
3424
- _defineProperty(this, "_rpcWebSocketConnected", false);
3425
-
3426
- _defineProperty(this, "_rpcWebSocketHeartbeat", null);
3427
-
3428
- _defineProperty(this, "_rpcWebSocketIdleTimeout", null);
3429
-
3430
- _defineProperty(this, "_disableBlockhashCaching", false);
3431
-
3432
- _defineProperty(this, "_pollingBlockhash", false);
3433
-
3434
- _defineProperty(this, "_blockhashInfo", {
5055
+ this._commitment = void 0;
5056
+ this._confirmTransactionInitialTimeout = void 0;
5057
+ this._rpcEndpoint = void 0;
5058
+ this._rpcWsEndpoint = void 0;
5059
+ this._rpcClient = void 0;
5060
+ this._rpcRequest = void 0;
5061
+ this._rpcBatchRequest = void 0;
5062
+ this._rpcWebSocket = void 0;
5063
+ this._rpcWebSocketConnected = false;
5064
+ this._rpcWebSocketHeartbeat = null;
5065
+ this._rpcWebSocketIdleTimeout = null;
5066
+ this._disableBlockhashCaching = false;
5067
+ this._pollingBlockhash = false;
5068
+ this._blockhashInfo = {
3435
5069
  recentBlockhash: null,
3436
5070
  lastFetch: 0,
3437
5071
  transactionSignatures: [],
3438
5072
  simulatedSignatures: []
3439
- });
3440
-
3441
- _defineProperty(this, "_accountChangeSubscriptionCounter", 0);
3442
-
3443
- _defineProperty(this, "_accountChangeSubscriptions", {});
3444
-
3445
- _defineProperty(this, "_programAccountChangeSubscriptionCounter", 0);
3446
-
3447
- _defineProperty(this, "_programAccountChangeSubscriptions", {});
3448
-
3449
- _defineProperty(this, "_rootSubscriptionCounter", 0);
3450
-
3451
- _defineProperty(this, "_rootSubscriptions", {});
3452
-
3453
- _defineProperty(this, "_signatureSubscriptionCounter", 0);
3454
-
3455
- _defineProperty(this, "_signatureSubscriptions", {});
3456
-
3457
- _defineProperty(this, "_slotSubscriptionCounter", 0);
3458
-
3459
- _defineProperty(this, "_slotSubscriptions", {});
3460
-
3461
- _defineProperty(this, "_logsSubscriptionCounter", 0);
3462
-
3463
- _defineProperty(this, "_logsSubscriptions", {});
3464
-
3465
- _defineProperty(this, "_slotUpdateSubscriptionCounter", 0);
3466
-
3467
- _defineProperty(this, "_slotUpdateSubscriptions", {});
3468
-
5073
+ };
5074
+ this._accountChangeSubscriptionCounter = 0;
5075
+ this._accountChangeSubscriptions = {};
5076
+ this._programAccountChangeSubscriptionCounter = 0;
5077
+ this._programAccountChangeSubscriptions = {};
5078
+ this._rootSubscriptionCounter = 0;
5079
+ this._rootSubscriptions = {};
5080
+ this._signatureSubscriptionCounter = 0;
5081
+ this._signatureSubscriptions = {};
5082
+ this._slotSubscriptionCounter = 0;
5083
+ this._slotSubscriptions = {};
5084
+ this._logsSubscriptionCounter = 0;
5085
+ this._logsSubscriptions = {};
5086
+ this._slotUpdateSubscriptionCounter = 0;
5087
+ this._slotUpdateSubscriptions = {};
3469
5088
  let url = new URL(endpoint);
3470
5089
  const useHttps = url.protocol === 'https:';
3471
5090
  let wsEndpoint;
@@ -3600,10 +5219,24 @@ class Connection {
3600
5219
  */
3601
5220
 
3602
5221
 
3603
- async getSupply(commitment) {
3604
- const args = this._buildArgs([], commitment);
5222
+ async getSupply(config) {
5223
+ let configArg = {};
5224
+
5225
+ if (typeof config === 'string') {
5226
+ configArg = {
5227
+ commitment: config
5228
+ };
5229
+ } else if (config) {
5230
+ configArg = { ...config,
5231
+ commitment: config && config.commitment || this.commitment
5232
+ };
5233
+ } else {
5234
+ configArg = {
5235
+ commitment: this.commitment
5236
+ };
5237
+ }
3605
5238
 
3606
- const unsafeRes = await this._rpcRequest('getSupply', args);
5239
+ const unsafeRes = await this._rpcRequest('getSupply', [configArg]);
3607
5240
  const res = create(unsafeRes, GetSupplyRpcResult);
3608
5241
 
3609
5242
  if ('error' in res) {
@@ -4114,16 +5747,11 @@ class Connection {
4114
5747
 
4115
5748
 
4116
5749
  async getTotalSupply(commitment) {
4117
- const args = this._buildArgs([], commitment);
4118
-
4119
- const unsafeRes = await this._rpcRequest('getSupply', args);
4120
- const res = create(unsafeRes, GetSupplyRpcResult);
4121
-
4122
- if ('error' in res) {
4123
- throw new Error('failed to get total supply: ' + res.error.message);
4124
- }
4125
-
4126
- return res.result.value.total;
5750
+ const result = await this.getSupply({
5751
+ commitment,
5752
+ excludeNonCirculatingAccountsList: true
5753
+ });
5754
+ return result.value.total;
4127
5755
  }
4128
5756
  /**
4129
5757
  * Fetch the cluster InflationGovernor parameters
@@ -5621,7 +7249,7 @@ class Keypair {
5621
7249
  * @param keypair ed25519 keypair
5622
7250
  */
5623
7251
  constructor(keypair) {
5624
- _defineProperty(this, "_keypair", void 0);
7252
+ this._keypair = void 0;
5625
7253
 
5626
7254
  if (keypair) {
5627
7255
  this._keypair = keypair;
@@ -5782,8 +7410,7 @@ class Ed25519Program {
5782
7410
  }
5783
7411
 
5784
7412
  }
5785
-
5786
- _defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7413
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
5787
7414
 
5788
7415
  /**
5789
7416
  * Address of the stake config account which configures the rate
@@ -5806,10 +7433,8 @@ class Authorized {
5806
7433
  * @param withdrawer the withdraw authority
5807
7434
  */
5808
7435
  constructor(staker, withdrawer) {
5809
- _defineProperty(this, "staker", void 0);
5810
-
5811
- _defineProperty(this, "withdrawer", void 0);
5812
-
7436
+ this.staker = void 0;
7437
+ this.withdrawer = void 0;
5813
7438
  this.staker = staker;
5814
7439
  this.withdrawer = withdrawer;
5815
7440
  }
@@ -5830,12 +7455,9 @@ class Lockup {
5830
7455
  * Create a new Lockup object
5831
7456
  */
5832
7457
  constructor(unixTimestamp, epoch, custodian) {
5833
- _defineProperty(this, "unixTimestamp", void 0);
5834
-
5835
- _defineProperty(this, "epoch", void 0);
5836
-
5837
- _defineProperty(this, "custodian", void 0);
5838
-
7458
+ this.unixTimestamp = void 0;
7459
+ this.epoch = void 0;
7460
+ this.custodian = void 0;
5839
7461
  this.unixTimestamp = unixTimestamp;
5840
7462
  this.epoch = epoch;
5841
7463
  this.custodian = custodian;
@@ -5850,7 +7472,7 @@ class Lockup {
5850
7472
  * Create stake account transaction params
5851
7473
  */
5852
7474
 
5853
- _defineProperty(Lockup, "default", new Lockup(0, 0, PublicKey.default));
7475
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
5854
7476
 
5855
7477
  /**
5856
7478
  * Stake Instruction class
@@ -6538,10 +8160,8 @@ class StakeProgram {
6538
8160
  }
6539
8161
 
6540
8162
  }
6541
-
6542
- _defineProperty(StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
6543
-
6544
- _defineProperty(StakeProgram, "space", 200);
8163
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8164
+ StakeProgram.space = 200;
6545
8165
 
6546
8166
  const {
6547
8167
  publicKeyCreate,
@@ -6690,8 +8310,7 @@ class Secp256k1Program {
6690
8310
  }
6691
8311
 
6692
8312
  }
6693
-
6694
- _defineProperty(Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8313
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
6695
8314
 
6696
8315
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
6697
8316
  /**
@@ -6724,10 +8343,8 @@ class ValidatorInfo {
6724
8343
  * @param info validator information
6725
8344
  */
6726
8345
  constructor(key, info) {
6727
- _defineProperty(this, "key", void 0);
6728
-
6729
- _defineProperty(this, "info", void 0);
6730
-
8346
+ this.key = void 0;
8347
+ this.info = void 0;
6731
8348
  this.key = key;
6732
8349
  this.info = info;
6733
8350
  }
@@ -6762,7 +8379,7 @@ class ValidatorInfo {
6762
8379
  if (configKeys[1].isSigner) {
6763
8380
  const rawInfo = rustString().decode(Buffer.from(byteArray));
6764
8381
  const info = JSON.parse(rawInfo);
6765
- assert$1(info, InfoString);
8382
+ assert$7(info, InfoString);
6766
8383
  return new ValidatorInfo(configKeys[1].publicKey, info);
6767
8384
  }
6768
8385
  }
@@ -6791,26 +8408,16 @@ class VoteAccount {
6791
8408
  * @internal
6792
8409
  */
6793
8410
  constructor(args) {
6794
- _defineProperty(this, "nodePubkey", void 0);
6795
-
6796
- _defineProperty(this, "authorizedVoterPubkey", void 0);
6797
-
6798
- _defineProperty(this, "authorizedWithdrawerPubkey", void 0);
6799
-
6800
- _defineProperty(this, "commission", void 0);
6801
-
6802
- _defineProperty(this, "votes", void 0);
6803
-
6804
- _defineProperty(this, "rootSlot", void 0);
6805
-
6806
- _defineProperty(this, "epoch", void 0);
6807
-
6808
- _defineProperty(this, "credits", void 0);
6809
-
6810
- _defineProperty(this, "lastEpochCredits", void 0);
6811
-
6812
- _defineProperty(this, "epochCredits", void 0);
6813
-
8411
+ this.nodePubkey = void 0;
8412
+ this.authorizedVoterPubkey = void 0;
8413
+ this.authorizedWithdrawerPubkey = void 0;
8414
+ this.commission = void 0;
8415
+ this.votes = void 0;
8416
+ this.rootSlot = void 0;
8417
+ this.epoch = void 0;
8418
+ this.credits = void 0;
8419
+ this.lastEpochCredits = void 0;
8420
+ this.epochCredits = void 0;
6814
8421
  this.nodePubkey = args.nodePubkey;
6815
8422
  this.authorizedVoterPubkey = args.authorizedVoterPubkey;
6816
8423
  this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;