@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.
@@ -1,13 +1,11 @@
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
- import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$1 } from 'superstruct';
8
+ import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
11
9
  import { Client } from 'rpc-websockets';
12
10
  import RpcClient from 'jayson/lib/client/browser';
13
11
  import secp256k1 from 'secp256k1';
@@ -23,6 +21,1679 @@ const toBuffer = arr => {
23
21
  }
24
22
  };
25
23
 
24
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
25
+
26
+ function getDefaultExportFromCjs (x) {
27
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
28
+ }
29
+
30
+ var hash$1 = {};
31
+
32
+ var utils$9 = {};
33
+
34
+ var minimalisticAssert = assert$6;
35
+
36
+ function assert$6(val, msg) {
37
+ if (!val)
38
+ throw new Error(msg || 'Assertion failed');
39
+ }
40
+
41
+ assert$6.equal = function assertEqual(l, r, msg) {
42
+ if (l != r)
43
+ throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
44
+ };
45
+
46
+ var inherits_browser = {exports: {}};
47
+
48
+ if (typeof Object.create === 'function') {
49
+ // implementation from standard node.js 'util' module
50
+ inherits_browser.exports = function inherits(ctor, superCtor) {
51
+ ctor.super_ = superCtor;
52
+ ctor.prototype = Object.create(superCtor.prototype, {
53
+ constructor: {
54
+ value: ctor,
55
+ enumerable: false,
56
+ writable: true,
57
+ configurable: true
58
+ }
59
+ });
60
+ };
61
+ } else {
62
+ // old school shim for old browsers
63
+ inherits_browser.exports = function inherits(ctor, superCtor) {
64
+ ctor.super_ = superCtor;
65
+ var TempCtor = function () {};
66
+ TempCtor.prototype = superCtor.prototype;
67
+ ctor.prototype = new TempCtor();
68
+ ctor.prototype.constructor = ctor;
69
+ };
70
+ }
71
+
72
+ var assert$5 = minimalisticAssert;
73
+ var inherits = inherits_browser.exports;
74
+
75
+ utils$9.inherits = inherits;
76
+
77
+ function isSurrogatePair(msg, i) {
78
+ if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
79
+ return false;
80
+ }
81
+ if (i < 0 || i + 1 >= msg.length) {
82
+ return false;
83
+ }
84
+ return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
85
+ }
86
+
87
+ function toArray(msg, enc) {
88
+ if (Array.isArray(msg))
89
+ return msg.slice();
90
+ if (!msg)
91
+ return [];
92
+ var res = [];
93
+ if (typeof msg === 'string') {
94
+ if (!enc) {
95
+ // Inspired by stringToUtf8ByteArray() in closure-library by Google
96
+ // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
97
+ // Apache License 2.0
98
+ // https://github.com/google/closure-library/blob/master/LICENSE
99
+ var p = 0;
100
+ for (var i = 0; i < msg.length; i++) {
101
+ var c = msg.charCodeAt(i);
102
+ if (c < 128) {
103
+ res[p++] = c;
104
+ } else if (c < 2048) {
105
+ res[p++] = (c >> 6) | 192;
106
+ res[p++] = (c & 63) | 128;
107
+ } else if (isSurrogatePair(msg, i)) {
108
+ c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
109
+ res[p++] = (c >> 18) | 240;
110
+ res[p++] = ((c >> 12) & 63) | 128;
111
+ res[p++] = ((c >> 6) & 63) | 128;
112
+ res[p++] = (c & 63) | 128;
113
+ } else {
114
+ res[p++] = (c >> 12) | 224;
115
+ res[p++] = ((c >> 6) & 63) | 128;
116
+ res[p++] = (c & 63) | 128;
117
+ }
118
+ }
119
+ } else if (enc === 'hex') {
120
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
121
+ if (msg.length % 2 !== 0)
122
+ msg = '0' + msg;
123
+ for (i = 0; i < msg.length; i += 2)
124
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
125
+ }
126
+ } else {
127
+ for (i = 0; i < msg.length; i++)
128
+ res[i] = msg[i] | 0;
129
+ }
130
+ return res;
131
+ }
132
+ utils$9.toArray = toArray;
133
+
134
+ function toHex(msg) {
135
+ var res = '';
136
+ for (var i = 0; i < msg.length; i++)
137
+ res += zero2(msg[i].toString(16));
138
+ return res;
139
+ }
140
+ utils$9.toHex = toHex;
141
+
142
+ function htonl(w) {
143
+ var res = (w >>> 24) |
144
+ ((w >>> 8) & 0xff00) |
145
+ ((w << 8) & 0xff0000) |
146
+ ((w & 0xff) << 24);
147
+ return res >>> 0;
148
+ }
149
+ utils$9.htonl = htonl;
150
+
151
+ function toHex32(msg, endian) {
152
+ var res = '';
153
+ for (var i = 0; i < msg.length; i++) {
154
+ var w = msg[i];
155
+ if (endian === 'little')
156
+ w = htonl(w);
157
+ res += zero8(w.toString(16));
158
+ }
159
+ return res;
160
+ }
161
+ utils$9.toHex32 = toHex32;
162
+
163
+ function zero2(word) {
164
+ if (word.length === 1)
165
+ return '0' + word;
166
+ else
167
+ return word;
168
+ }
169
+ utils$9.zero2 = zero2;
170
+
171
+ function zero8(word) {
172
+ if (word.length === 7)
173
+ return '0' + word;
174
+ else if (word.length === 6)
175
+ return '00' + word;
176
+ else if (word.length === 5)
177
+ return '000' + word;
178
+ else if (word.length === 4)
179
+ return '0000' + word;
180
+ else if (word.length === 3)
181
+ return '00000' + word;
182
+ else if (word.length === 2)
183
+ return '000000' + word;
184
+ else if (word.length === 1)
185
+ return '0000000' + word;
186
+ else
187
+ return word;
188
+ }
189
+ utils$9.zero8 = zero8;
190
+
191
+ function join32(msg, start, end, endian) {
192
+ var len = end - start;
193
+ assert$5(len % 4 === 0);
194
+ var res = new Array(len / 4);
195
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
196
+ var w;
197
+ if (endian === 'big')
198
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
199
+ else
200
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
201
+ res[i] = w >>> 0;
202
+ }
203
+ return res;
204
+ }
205
+ utils$9.join32 = join32;
206
+
207
+ function split32(msg, endian) {
208
+ var res = new Array(msg.length * 4);
209
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
210
+ var m = msg[i];
211
+ if (endian === 'big') {
212
+ res[k] = m >>> 24;
213
+ res[k + 1] = (m >>> 16) & 0xff;
214
+ res[k + 2] = (m >>> 8) & 0xff;
215
+ res[k + 3] = m & 0xff;
216
+ } else {
217
+ res[k + 3] = m >>> 24;
218
+ res[k + 2] = (m >>> 16) & 0xff;
219
+ res[k + 1] = (m >>> 8) & 0xff;
220
+ res[k] = m & 0xff;
221
+ }
222
+ }
223
+ return res;
224
+ }
225
+ utils$9.split32 = split32;
226
+
227
+ function rotr32$1(w, b) {
228
+ return (w >>> b) | (w << (32 - b));
229
+ }
230
+ utils$9.rotr32 = rotr32$1;
231
+
232
+ function rotl32$2(w, b) {
233
+ return (w << b) | (w >>> (32 - b));
234
+ }
235
+ utils$9.rotl32 = rotl32$2;
236
+
237
+ function sum32$3(a, b) {
238
+ return (a + b) >>> 0;
239
+ }
240
+ utils$9.sum32 = sum32$3;
241
+
242
+ function sum32_3$1(a, b, c) {
243
+ return (a + b + c) >>> 0;
244
+ }
245
+ utils$9.sum32_3 = sum32_3$1;
246
+
247
+ function sum32_4$2(a, b, c, d) {
248
+ return (a + b + c + d) >>> 0;
249
+ }
250
+ utils$9.sum32_4 = sum32_4$2;
251
+
252
+ function sum32_5$2(a, b, c, d, e) {
253
+ return (a + b + c + d + e) >>> 0;
254
+ }
255
+ utils$9.sum32_5 = sum32_5$2;
256
+
257
+ function sum64$1(buf, pos, ah, al) {
258
+ var bh = buf[pos];
259
+ var bl = buf[pos + 1];
260
+
261
+ var lo = (al + bl) >>> 0;
262
+ var hi = (lo < al ? 1 : 0) + ah + bh;
263
+ buf[pos] = hi >>> 0;
264
+ buf[pos + 1] = lo;
265
+ }
266
+ utils$9.sum64 = sum64$1;
267
+
268
+ function sum64_hi$1(ah, al, bh, bl) {
269
+ var lo = (al + bl) >>> 0;
270
+ var hi = (lo < al ? 1 : 0) + ah + bh;
271
+ return hi >>> 0;
272
+ }
273
+ utils$9.sum64_hi = sum64_hi$1;
274
+
275
+ function sum64_lo$1(ah, al, bh, bl) {
276
+ var lo = al + bl;
277
+ return lo >>> 0;
278
+ }
279
+ utils$9.sum64_lo = sum64_lo$1;
280
+
281
+ function sum64_4_hi$1(ah, al, bh, bl, ch, cl, dh, dl) {
282
+ var carry = 0;
283
+ var lo = al;
284
+ lo = (lo + bl) >>> 0;
285
+ carry += lo < al ? 1 : 0;
286
+ lo = (lo + cl) >>> 0;
287
+ carry += lo < cl ? 1 : 0;
288
+ lo = (lo + dl) >>> 0;
289
+ carry += lo < dl ? 1 : 0;
290
+
291
+ var hi = ah + bh + ch + dh + carry;
292
+ return hi >>> 0;
293
+ }
294
+ utils$9.sum64_4_hi = sum64_4_hi$1;
295
+
296
+ function sum64_4_lo$1(ah, al, bh, bl, ch, cl, dh, dl) {
297
+ var lo = al + bl + cl + dl;
298
+ return lo >>> 0;
299
+ }
300
+ utils$9.sum64_4_lo = sum64_4_lo$1;
301
+
302
+ function sum64_5_hi$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
303
+ var carry = 0;
304
+ var lo = al;
305
+ lo = (lo + bl) >>> 0;
306
+ carry += lo < al ? 1 : 0;
307
+ lo = (lo + cl) >>> 0;
308
+ carry += lo < cl ? 1 : 0;
309
+ lo = (lo + dl) >>> 0;
310
+ carry += lo < dl ? 1 : 0;
311
+ lo = (lo + el) >>> 0;
312
+ carry += lo < el ? 1 : 0;
313
+
314
+ var hi = ah + bh + ch + dh + eh + carry;
315
+ return hi >>> 0;
316
+ }
317
+ utils$9.sum64_5_hi = sum64_5_hi$1;
318
+
319
+ function sum64_5_lo$1(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
320
+ var lo = al + bl + cl + dl + el;
321
+
322
+ return lo >>> 0;
323
+ }
324
+ utils$9.sum64_5_lo = sum64_5_lo$1;
325
+
326
+ function rotr64_hi$1(ah, al, num) {
327
+ var r = (al << (32 - num)) | (ah >>> num);
328
+ return r >>> 0;
329
+ }
330
+ utils$9.rotr64_hi = rotr64_hi$1;
331
+
332
+ function rotr64_lo$1(ah, al, num) {
333
+ var r = (ah << (32 - num)) | (al >>> num);
334
+ return r >>> 0;
335
+ }
336
+ utils$9.rotr64_lo = rotr64_lo$1;
337
+
338
+ function shr64_hi$1(ah, al, num) {
339
+ return ah >>> num;
340
+ }
341
+ utils$9.shr64_hi = shr64_hi$1;
342
+
343
+ function shr64_lo$1(ah, al, num) {
344
+ var r = (ah << (32 - num)) | (al >>> num);
345
+ return r >>> 0;
346
+ }
347
+ utils$9.shr64_lo = shr64_lo$1;
348
+
349
+ var common$5 = {};
350
+
351
+ var utils$8 = utils$9;
352
+ var assert$4 = minimalisticAssert;
353
+
354
+ function BlockHash$4() {
355
+ this.pending = null;
356
+ this.pendingTotal = 0;
357
+ this.blockSize = this.constructor.blockSize;
358
+ this.outSize = this.constructor.outSize;
359
+ this.hmacStrength = this.constructor.hmacStrength;
360
+ this.padLength = this.constructor.padLength / 8;
361
+ this.endian = 'big';
362
+
363
+ this._delta8 = this.blockSize / 8;
364
+ this._delta32 = this.blockSize / 32;
365
+ }
366
+ common$5.BlockHash = BlockHash$4;
367
+
368
+ BlockHash$4.prototype.update = function update(msg, enc) {
369
+ // Convert message to array, pad it, and join into 32bit blocks
370
+ msg = utils$8.toArray(msg, enc);
371
+ if (!this.pending)
372
+ this.pending = msg;
373
+ else
374
+ this.pending = this.pending.concat(msg);
375
+ this.pendingTotal += msg.length;
376
+
377
+ // Enough data, try updating
378
+ if (this.pending.length >= this._delta8) {
379
+ msg = this.pending;
380
+
381
+ // Process pending data in blocks
382
+ var r = msg.length % this._delta8;
383
+ this.pending = msg.slice(msg.length - r, msg.length);
384
+ if (this.pending.length === 0)
385
+ this.pending = null;
386
+
387
+ msg = utils$8.join32(msg, 0, msg.length - r, this.endian);
388
+ for (var i = 0; i < msg.length; i += this._delta32)
389
+ this._update(msg, i, i + this._delta32);
390
+ }
391
+
392
+ return this;
393
+ };
394
+
395
+ BlockHash$4.prototype.digest = function digest(enc) {
396
+ this.update(this._pad());
397
+ assert$4(this.pending === null);
398
+
399
+ return this._digest(enc);
400
+ };
401
+
402
+ BlockHash$4.prototype._pad = function pad() {
403
+ var len = this.pendingTotal;
404
+ var bytes = this._delta8;
405
+ var k = bytes - ((len + this.padLength) % bytes);
406
+ var res = new Array(k + this.padLength);
407
+ res[0] = 0x80;
408
+ for (var i = 1; i < k; i++)
409
+ res[i] = 0;
410
+
411
+ // Append length
412
+ len <<= 3;
413
+ if (this.endian === 'big') {
414
+ for (var t = 8; t < this.padLength; t++)
415
+ res[i++] = 0;
416
+
417
+ res[i++] = 0;
418
+ res[i++] = 0;
419
+ res[i++] = 0;
420
+ res[i++] = 0;
421
+ res[i++] = (len >>> 24) & 0xff;
422
+ res[i++] = (len >>> 16) & 0xff;
423
+ res[i++] = (len >>> 8) & 0xff;
424
+ res[i++] = len & 0xff;
425
+ } else {
426
+ res[i++] = len & 0xff;
427
+ res[i++] = (len >>> 8) & 0xff;
428
+ res[i++] = (len >>> 16) & 0xff;
429
+ res[i++] = (len >>> 24) & 0xff;
430
+ res[i++] = 0;
431
+ res[i++] = 0;
432
+ res[i++] = 0;
433
+ res[i++] = 0;
434
+
435
+ for (t = 8; t < this.padLength; t++)
436
+ res[i++] = 0;
437
+ }
438
+
439
+ return res;
440
+ };
441
+
442
+ var sha = {};
443
+
444
+ var common$4 = {};
445
+
446
+ var utils$7 = utils$9;
447
+ var rotr32 = utils$7.rotr32;
448
+
449
+ function ft_1$1(s, x, y, z) {
450
+ if (s === 0)
451
+ return ch32$1(x, y, z);
452
+ if (s === 1 || s === 3)
453
+ return p32(x, y, z);
454
+ if (s === 2)
455
+ return maj32$1(x, y, z);
456
+ }
457
+ common$4.ft_1 = ft_1$1;
458
+
459
+ function ch32$1(x, y, z) {
460
+ return (x & y) ^ ((~x) & z);
461
+ }
462
+ common$4.ch32 = ch32$1;
463
+
464
+ function maj32$1(x, y, z) {
465
+ return (x & y) ^ (x & z) ^ (y & z);
466
+ }
467
+ common$4.maj32 = maj32$1;
468
+
469
+ function p32(x, y, z) {
470
+ return x ^ y ^ z;
471
+ }
472
+ common$4.p32 = p32;
473
+
474
+ function s0_256$1(x) {
475
+ return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
476
+ }
477
+ common$4.s0_256 = s0_256$1;
478
+
479
+ function s1_256$1(x) {
480
+ return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
481
+ }
482
+ common$4.s1_256 = s1_256$1;
483
+
484
+ function g0_256$1(x) {
485
+ return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
486
+ }
487
+ common$4.g0_256 = g0_256$1;
488
+
489
+ function g1_256$1(x) {
490
+ return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
491
+ }
492
+ common$4.g1_256 = g1_256$1;
493
+
494
+ var utils$6 = utils$9;
495
+ var common$3 = common$5;
496
+ var shaCommon$1 = common$4;
497
+
498
+ var rotl32$1 = utils$6.rotl32;
499
+ var sum32$2 = utils$6.sum32;
500
+ var sum32_5$1 = utils$6.sum32_5;
501
+ var ft_1 = shaCommon$1.ft_1;
502
+ var BlockHash$3 = common$3.BlockHash;
503
+
504
+ var sha1_K = [
505
+ 0x5A827999, 0x6ED9EBA1,
506
+ 0x8F1BBCDC, 0xCA62C1D6
507
+ ];
508
+
509
+ function SHA1() {
510
+ if (!(this instanceof SHA1))
511
+ return new SHA1();
512
+
513
+ BlockHash$3.call(this);
514
+ this.h = [
515
+ 0x67452301, 0xefcdab89, 0x98badcfe,
516
+ 0x10325476, 0xc3d2e1f0 ];
517
+ this.W = new Array(80);
518
+ }
519
+
520
+ utils$6.inherits(SHA1, BlockHash$3);
521
+ var _1 = SHA1;
522
+
523
+ SHA1.blockSize = 512;
524
+ SHA1.outSize = 160;
525
+ SHA1.hmacStrength = 80;
526
+ SHA1.padLength = 64;
527
+
528
+ SHA1.prototype._update = function _update(msg, start) {
529
+ var W = this.W;
530
+
531
+ for (var i = 0; i < 16; i++)
532
+ W[i] = msg[start + i];
533
+
534
+ for(; i < W.length; i++)
535
+ W[i] = rotl32$1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
536
+
537
+ var a = this.h[0];
538
+ var b = this.h[1];
539
+ var c = this.h[2];
540
+ var d = this.h[3];
541
+ var e = this.h[4];
542
+
543
+ for (i = 0; i < W.length; i++) {
544
+ var s = ~~(i / 20);
545
+ var t = sum32_5$1(rotl32$1(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
546
+ e = d;
547
+ d = c;
548
+ c = rotl32$1(b, 30);
549
+ b = a;
550
+ a = t;
551
+ }
552
+
553
+ this.h[0] = sum32$2(this.h[0], a);
554
+ this.h[1] = sum32$2(this.h[1], b);
555
+ this.h[2] = sum32$2(this.h[2], c);
556
+ this.h[3] = sum32$2(this.h[3], d);
557
+ this.h[4] = sum32$2(this.h[4], e);
558
+ };
559
+
560
+ SHA1.prototype._digest = function digest(enc) {
561
+ if (enc === 'hex')
562
+ return utils$6.toHex32(this.h, 'big');
563
+ else
564
+ return utils$6.split32(this.h, 'big');
565
+ };
566
+
567
+ var utils$5 = utils$9;
568
+ var common$2 = common$5;
569
+ var shaCommon = common$4;
570
+ var assert$3 = minimalisticAssert;
571
+
572
+ var sum32$1 = utils$5.sum32;
573
+ var sum32_4$1 = utils$5.sum32_4;
574
+ var sum32_5 = utils$5.sum32_5;
575
+ var ch32 = shaCommon.ch32;
576
+ var maj32 = shaCommon.maj32;
577
+ var s0_256 = shaCommon.s0_256;
578
+ var s1_256 = shaCommon.s1_256;
579
+ var g0_256 = shaCommon.g0_256;
580
+ var g1_256 = shaCommon.g1_256;
581
+
582
+ var BlockHash$2 = common$2.BlockHash;
583
+
584
+ var sha256_K = [
585
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
586
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
587
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
588
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
589
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
590
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
591
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
592
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
593
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
594
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
595
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
596
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
597
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
598
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
599
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
600
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
601
+ ];
602
+
603
+ function SHA256$1() {
604
+ if (!(this instanceof SHA256$1))
605
+ return new SHA256$1();
606
+
607
+ BlockHash$2.call(this);
608
+ this.h = [
609
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
610
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
611
+ ];
612
+ this.k = sha256_K;
613
+ this.W = new Array(64);
614
+ }
615
+ utils$5.inherits(SHA256$1, BlockHash$2);
616
+ var _256 = SHA256$1;
617
+
618
+ SHA256$1.blockSize = 512;
619
+ SHA256$1.outSize = 256;
620
+ SHA256$1.hmacStrength = 192;
621
+ SHA256$1.padLength = 64;
622
+
623
+ SHA256$1.prototype._update = function _update(msg, start) {
624
+ var W = this.W;
625
+
626
+ for (var i = 0; i < 16; i++)
627
+ W[i] = msg[start + i];
628
+ for (; i < W.length; i++)
629
+ W[i] = sum32_4$1(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
630
+
631
+ var a = this.h[0];
632
+ var b = this.h[1];
633
+ var c = this.h[2];
634
+ var d = this.h[3];
635
+ var e = this.h[4];
636
+ var f = this.h[5];
637
+ var g = this.h[6];
638
+ var h = this.h[7];
639
+
640
+ assert$3(this.k.length === W.length);
641
+ for (i = 0; i < W.length; i++) {
642
+ var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
643
+ var T2 = sum32$1(s0_256(a), maj32(a, b, c));
644
+ h = g;
645
+ g = f;
646
+ f = e;
647
+ e = sum32$1(d, T1);
648
+ d = c;
649
+ c = b;
650
+ b = a;
651
+ a = sum32$1(T1, T2);
652
+ }
653
+
654
+ this.h[0] = sum32$1(this.h[0], a);
655
+ this.h[1] = sum32$1(this.h[1], b);
656
+ this.h[2] = sum32$1(this.h[2], c);
657
+ this.h[3] = sum32$1(this.h[3], d);
658
+ this.h[4] = sum32$1(this.h[4], e);
659
+ this.h[5] = sum32$1(this.h[5], f);
660
+ this.h[6] = sum32$1(this.h[6], g);
661
+ this.h[7] = sum32$1(this.h[7], h);
662
+ };
663
+
664
+ SHA256$1.prototype._digest = function digest(enc) {
665
+ if (enc === 'hex')
666
+ return utils$5.toHex32(this.h, 'big');
667
+ else
668
+ return utils$5.split32(this.h, 'big');
669
+ };
670
+
671
+ var utils$4 = utils$9;
672
+ var SHA256 = _256;
673
+
674
+ function SHA224() {
675
+ if (!(this instanceof SHA224))
676
+ return new SHA224();
677
+
678
+ SHA256.call(this);
679
+ this.h = [
680
+ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
681
+ 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
682
+ }
683
+ utils$4.inherits(SHA224, SHA256);
684
+ var _224 = SHA224;
685
+
686
+ SHA224.blockSize = 512;
687
+ SHA224.outSize = 224;
688
+ SHA224.hmacStrength = 192;
689
+ SHA224.padLength = 64;
690
+
691
+ SHA224.prototype._digest = function digest(enc) {
692
+ // Just truncate output
693
+ if (enc === 'hex')
694
+ return utils$4.toHex32(this.h.slice(0, 7), 'big');
695
+ else
696
+ return utils$4.split32(this.h.slice(0, 7), 'big');
697
+ };
698
+
699
+ var utils$3 = utils$9;
700
+ var common$1 = common$5;
701
+ var assert$2 = minimalisticAssert;
702
+
703
+ var rotr64_hi = utils$3.rotr64_hi;
704
+ var rotr64_lo = utils$3.rotr64_lo;
705
+ var shr64_hi = utils$3.shr64_hi;
706
+ var shr64_lo = utils$3.shr64_lo;
707
+ var sum64 = utils$3.sum64;
708
+ var sum64_hi = utils$3.sum64_hi;
709
+ var sum64_lo = utils$3.sum64_lo;
710
+ var sum64_4_hi = utils$3.sum64_4_hi;
711
+ var sum64_4_lo = utils$3.sum64_4_lo;
712
+ var sum64_5_hi = utils$3.sum64_5_hi;
713
+ var sum64_5_lo = utils$3.sum64_5_lo;
714
+
715
+ var BlockHash$1 = common$1.BlockHash;
716
+
717
+ var sha512_K = [
718
+ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
719
+ 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
720
+ 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
721
+ 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
722
+ 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
723
+ 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
724
+ 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
725
+ 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
726
+ 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
727
+ 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
728
+ 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
729
+ 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
730
+ 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
731
+ 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
732
+ 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
733
+ 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
734
+ 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
735
+ 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
736
+ 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
737
+ 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
738
+ 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
739
+ 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
740
+ 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
741
+ 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
742
+ 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
743
+ 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
744
+ 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
745
+ 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
746
+ 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
747
+ 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
748
+ 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
749
+ 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
750
+ 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
751
+ 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
752
+ 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
753
+ 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
754
+ 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
755
+ 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
756
+ 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
757
+ 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
758
+ ];
759
+
760
+ function SHA512$1() {
761
+ if (!(this instanceof SHA512$1))
762
+ return new SHA512$1();
763
+
764
+ BlockHash$1.call(this);
765
+ this.h = [
766
+ 0x6a09e667, 0xf3bcc908,
767
+ 0xbb67ae85, 0x84caa73b,
768
+ 0x3c6ef372, 0xfe94f82b,
769
+ 0xa54ff53a, 0x5f1d36f1,
770
+ 0x510e527f, 0xade682d1,
771
+ 0x9b05688c, 0x2b3e6c1f,
772
+ 0x1f83d9ab, 0xfb41bd6b,
773
+ 0x5be0cd19, 0x137e2179 ];
774
+ this.k = sha512_K;
775
+ this.W = new Array(160);
776
+ }
777
+ utils$3.inherits(SHA512$1, BlockHash$1);
778
+ var _512 = SHA512$1;
779
+
780
+ SHA512$1.blockSize = 1024;
781
+ SHA512$1.outSize = 512;
782
+ SHA512$1.hmacStrength = 192;
783
+ SHA512$1.padLength = 128;
784
+
785
+ SHA512$1.prototype._prepareBlock = function _prepareBlock(msg, start) {
786
+ var W = this.W;
787
+
788
+ // 32 x 32bit words
789
+ for (var i = 0; i < 32; i++)
790
+ W[i] = msg[start + i];
791
+ for (; i < W.length; i += 2) {
792
+ var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
793
+ var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
794
+ var c1_hi = W[i - 14]; // i - 7
795
+ var c1_lo = W[i - 13];
796
+ var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
797
+ var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
798
+ var c3_hi = W[i - 32]; // i - 16
799
+ var c3_lo = W[i - 31];
800
+
801
+ W[i] = sum64_4_hi(
802
+ c0_hi, c0_lo,
803
+ c1_hi, c1_lo,
804
+ c2_hi, c2_lo,
805
+ c3_hi, c3_lo);
806
+ W[i + 1] = sum64_4_lo(
807
+ c0_hi, c0_lo,
808
+ c1_hi, c1_lo,
809
+ c2_hi, c2_lo,
810
+ c3_hi, c3_lo);
811
+ }
812
+ };
813
+
814
+ SHA512$1.prototype._update = function _update(msg, start) {
815
+ this._prepareBlock(msg, start);
816
+
817
+ var W = this.W;
818
+
819
+ var ah = this.h[0];
820
+ var al = this.h[1];
821
+ var bh = this.h[2];
822
+ var bl = this.h[3];
823
+ var ch = this.h[4];
824
+ var cl = this.h[5];
825
+ var dh = this.h[6];
826
+ var dl = this.h[7];
827
+ var eh = this.h[8];
828
+ var el = this.h[9];
829
+ var fh = this.h[10];
830
+ var fl = this.h[11];
831
+ var gh = this.h[12];
832
+ var gl = this.h[13];
833
+ var hh = this.h[14];
834
+ var hl = this.h[15];
835
+
836
+ assert$2(this.k.length === W.length);
837
+ for (var i = 0; i < W.length; i += 2) {
838
+ var c0_hi = hh;
839
+ var c0_lo = hl;
840
+ var c1_hi = s1_512_hi(eh, el);
841
+ var c1_lo = s1_512_lo(eh, el);
842
+ var c2_hi = ch64_hi(eh, el, fh, fl, gh);
843
+ var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
844
+ var c3_hi = this.k[i];
845
+ var c3_lo = this.k[i + 1];
846
+ var c4_hi = W[i];
847
+ var c4_lo = W[i + 1];
848
+
849
+ var T1_hi = sum64_5_hi(
850
+ c0_hi, c0_lo,
851
+ c1_hi, c1_lo,
852
+ c2_hi, c2_lo,
853
+ c3_hi, c3_lo,
854
+ c4_hi, c4_lo);
855
+ var T1_lo = sum64_5_lo(
856
+ c0_hi, c0_lo,
857
+ c1_hi, c1_lo,
858
+ c2_hi, c2_lo,
859
+ c3_hi, c3_lo,
860
+ c4_hi, c4_lo);
861
+
862
+ c0_hi = s0_512_hi(ah, al);
863
+ c0_lo = s0_512_lo(ah, al);
864
+ c1_hi = maj64_hi(ah, al, bh, bl, ch);
865
+ c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
866
+
867
+ var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
868
+ var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
869
+
870
+ hh = gh;
871
+ hl = gl;
872
+
873
+ gh = fh;
874
+ gl = fl;
875
+
876
+ fh = eh;
877
+ fl = el;
878
+
879
+ eh = sum64_hi(dh, dl, T1_hi, T1_lo);
880
+ el = sum64_lo(dl, dl, T1_hi, T1_lo);
881
+
882
+ dh = ch;
883
+ dl = cl;
884
+
885
+ ch = bh;
886
+ cl = bl;
887
+
888
+ bh = ah;
889
+ bl = al;
890
+
891
+ ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
892
+ al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
893
+ }
894
+
895
+ sum64(this.h, 0, ah, al);
896
+ sum64(this.h, 2, bh, bl);
897
+ sum64(this.h, 4, ch, cl);
898
+ sum64(this.h, 6, dh, dl);
899
+ sum64(this.h, 8, eh, el);
900
+ sum64(this.h, 10, fh, fl);
901
+ sum64(this.h, 12, gh, gl);
902
+ sum64(this.h, 14, hh, hl);
903
+ };
904
+
905
+ SHA512$1.prototype._digest = function digest(enc) {
906
+ if (enc === 'hex')
907
+ return utils$3.toHex32(this.h, 'big');
908
+ else
909
+ return utils$3.split32(this.h, 'big');
910
+ };
911
+
912
+ function ch64_hi(xh, xl, yh, yl, zh) {
913
+ var r = (xh & yh) ^ ((~xh) & zh);
914
+ if (r < 0)
915
+ r += 0x100000000;
916
+ return r;
917
+ }
918
+
919
+ function ch64_lo(xh, xl, yh, yl, zh, zl) {
920
+ var r = (xl & yl) ^ ((~xl) & zl);
921
+ if (r < 0)
922
+ r += 0x100000000;
923
+ return r;
924
+ }
925
+
926
+ function maj64_hi(xh, xl, yh, yl, zh) {
927
+ var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
928
+ if (r < 0)
929
+ r += 0x100000000;
930
+ return r;
931
+ }
932
+
933
+ function maj64_lo(xh, xl, yh, yl, zh, zl) {
934
+ var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
935
+ if (r < 0)
936
+ r += 0x100000000;
937
+ return r;
938
+ }
939
+
940
+ function s0_512_hi(xh, xl) {
941
+ var c0_hi = rotr64_hi(xh, xl, 28);
942
+ var c1_hi = rotr64_hi(xl, xh, 2); // 34
943
+ var c2_hi = rotr64_hi(xl, xh, 7); // 39
944
+
945
+ var r = c0_hi ^ c1_hi ^ c2_hi;
946
+ if (r < 0)
947
+ r += 0x100000000;
948
+ return r;
949
+ }
950
+
951
+ function s0_512_lo(xh, xl) {
952
+ var c0_lo = rotr64_lo(xh, xl, 28);
953
+ var c1_lo = rotr64_lo(xl, xh, 2); // 34
954
+ var c2_lo = rotr64_lo(xl, xh, 7); // 39
955
+
956
+ var r = c0_lo ^ c1_lo ^ c2_lo;
957
+ if (r < 0)
958
+ r += 0x100000000;
959
+ return r;
960
+ }
961
+
962
+ function s1_512_hi(xh, xl) {
963
+ var c0_hi = rotr64_hi(xh, xl, 14);
964
+ var c1_hi = rotr64_hi(xh, xl, 18);
965
+ var c2_hi = rotr64_hi(xl, xh, 9); // 41
966
+
967
+ var r = c0_hi ^ c1_hi ^ c2_hi;
968
+ if (r < 0)
969
+ r += 0x100000000;
970
+ return r;
971
+ }
972
+
973
+ function s1_512_lo(xh, xl) {
974
+ var c0_lo = rotr64_lo(xh, xl, 14);
975
+ var c1_lo = rotr64_lo(xh, xl, 18);
976
+ var c2_lo = rotr64_lo(xl, xh, 9); // 41
977
+
978
+ var r = c0_lo ^ c1_lo ^ c2_lo;
979
+ if (r < 0)
980
+ r += 0x100000000;
981
+ return r;
982
+ }
983
+
984
+ function g0_512_hi(xh, xl) {
985
+ var c0_hi = rotr64_hi(xh, xl, 1);
986
+ var c1_hi = rotr64_hi(xh, xl, 8);
987
+ var c2_hi = shr64_hi(xh, xl, 7);
988
+
989
+ var r = c0_hi ^ c1_hi ^ c2_hi;
990
+ if (r < 0)
991
+ r += 0x100000000;
992
+ return r;
993
+ }
994
+
995
+ function g0_512_lo(xh, xl) {
996
+ var c0_lo = rotr64_lo(xh, xl, 1);
997
+ var c1_lo = rotr64_lo(xh, xl, 8);
998
+ var c2_lo = shr64_lo(xh, xl, 7);
999
+
1000
+ var r = c0_lo ^ c1_lo ^ c2_lo;
1001
+ if (r < 0)
1002
+ r += 0x100000000;
1003
+ return r;
1004
+ }
1005
+
1006
+ function g1_512_hi(xh, xl) {
1007
+ var c0_hi = rotr64_hi(xh, xl, 19);
1008
+ var c1_hi = rotr64_hi(xl, xh, 29); // 61
1009
+ var c2_hi = shr64_hi(xh, xl, 6);
1010
+
1011
+ var r = c0_hi ^ c1_hi ^ c2_hi;
1012
+ if (r < 0)
1013
+ r += 0x100000000;
1014
+ return r;
1015
+ }
1016
+
1017
+ function g1_512_lo(xh, xl) {
1018
+ var c0_lo = rotr64_lo(xh, xl, 19);
1019
+ var c1_lo = rotr64_lo(xl, xh, 29); // 61
1020
+ var c2_lo = shr64_lo(xh, xl, 6);
1021
+
1022
+ var r = c0_lo ^ c1_lo ^ c2_lo;
1023
+ if (r < 0)
1024
+ r += 0x100000000;
1025
+ return r;
1026
+ }
1027
+
1028
+ var utils$2 = utils$9;
1029
+
1030
+ var SHA512 = _512;
1031
+
1032
+ function SHA384() {
1033
+ if (!(this instanceof SHA384))
1034
+ return new SHA384();
1035
+
1036
+ SHA512.call(this);
1037
+ this.h = [
1038
+ 0xcbbb9d5d, 0xc1059ed8,
1039
+ 0x629a292a, 0x367cd507,
1040
+ 0x9159015a, 0x3070dd17,
1041
+ 0x152fecd8, 0xf70e5939,
1042
+ 0x67332667, 0xffc00b31,
1043
+ 0x8eb44a87, 0x68581511,
1044
+ 0xdb0c2e0d, 0x64f98fa7,
1045
+ 0x47b5481d, 0xbefa4fa4 ];
1046
+ }
1047
+ utils$2.inherits(SHA384, SHA512);
1048
+ var _384 = SHA384;
1049
+
1050
+ SHA384.blockSize = 1024;
1051
+ SHA384.outSize = 384;
1052
+ SHA384.hmacStrength = 192;
1053
+ SHA384.padLength = 128;
1054
+
1055
+ SHA384.prototype._digest = function digest(enc) {
1056
+ if (enc === 'hex')
1057
+ return utils$2.toHex32(this.h.slice(0, 12), 'big');
1058
+ else
1059
+ return utils$2.split32(this.h.slice(0, 12), 'big');
1060
+ };
1061
+
1062
+ sha.sha1 = _1;
1063
+ sha.sha224 = _224;
1064
+ sha.sha256 = _256;
1065
+ sha.sha384 = _384;
1066
+ sha.sha512 = _512;
1067
+
1068
+ var ripemd = {};
1069
+
1070
+ var utils$1 = utils$9;
1071
+ var common = common$5;
1072
+
1073
+ var rotl32 = utils$1.rotl32;
1074
+ var sum32 = utils$1.sum32;
1075
+ var sum32_3 = utils$1.sum32_3;
1076
+ var sum32_4 = utils$1.sum32_4;
1077
+ var BlockHash = common.BlockHash;
1078
+
1079
+ function RIPEMD160() {
1080
+ if (!(this instanceof RIPEMD160))
1081
+ return new RIPEMD160();
1082
+
1083
+ BlockHash.call(this);
1084
+
1085
+ this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
1086
+ this.endian = 'little';
1087
+ }
1088
+ utils$1.inherits(RIPEMD160, BlockHash);
1089
+ ripemd.ripemd160 = RIPEMD160;
1090
+
1091
+ RIPEMD160.blockSize = 512;
1092
+ RIPEMD160.outSize = 160;
1093
+ RIPEMD160.hmacStrength = 192;
1094
+ RIPEMD160.padLength = 64;
1095
+
1096
+ RIPEMD160.prototype._update = function update(msg, start) {
1097
+ var A = this.h[0];
1098
+ var B = this.h[1];
1099
+ var C = this.h[2];
1100
+ var D = this.h[3];
1101
+ var E = this.h[4];
1102
+ var Ah = A;
1103
+ var Bh = B;
1104
+ var Ch = C;
1105
+ var Dh = D;
1106
+ var Eh = E;
1107
+ for (var j = 0; j < 80; j++) {
1108
+ var T = sum32(
1109
+ rotl32(
1110
+ sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
1111
+ s[j]),
1112
+ E);
1113
+ A = E;
1114
+ E = D;
1115
+ D = rotl32(C, 10);
1116
+ C = B;
1117
+ B = T;
1118
+ T = sum32(
1119
+ rotl32(
1120
+ sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
1121
+ sh[j]),
1122
+ Eh);
1123
+ Ah = Eh;
1124
+ Eh = Dh;
1125
+ Dh = rotl32(Ch, 10);
1126
+ Ch = Bh;
1127
+ Bh = T;
1128
+ }
1129
+ T = sum32_3(this.h[1], C, Dh);
1130
+ this.h[1] = sum32_3(this.h[2], D, Eh);
1131
+ this.h[2] = sum32_3(this.h[3], E, Ah);
1132
+ this.h[3] = sum32_3(this.h[4], A, Bh);
1133
+ this.h[4] = sum32_3(this.h[0], B, Ch);
1134
+ this.h[0] = T;
1135
+ };
1136
+
1137
+ RIPEMD160.prototype._digest = function digest(enc) {
1138
+ if (enc === 'hex')
1139
+ return utils$1.toHex32(this.h, 'little');
1140
+ else
1141
+ return utils$1.split32(this.h, 'little');
1142
+ };
1143
+
1144
+ function f(j, x, y, z) {
1145
+ if (j <= 15)
1146
+ return x ^ y ^ z;
1147
+ else if (j <= 31)
1148
+ return (x & y) | ((~x) & z);
1149
+ else if (j <= 47)
1150
+ return (x | (~y)) ^ z;
1151
+ else if (j <= 63)
1152
+ return (x & z) | (y & (~z));
1153
+ else
1154
+ return x ^ (y | (~z));
1155
+ }
1156
+
1157
+ function K(j) {
1158
+ if (j <= 15)
1159
+ return 0x00000000;
1160
+ else if (j <= 31)
1161
+ return 0x5a827999;
1162
+ else if (j <= 47)
1163
+ return 0x6ed9eba1;
1164
+ else if (j <= 63)
1165
+ return 0x8f1bbcdc;
1166
+ else
1167
+ return 0xa953fd4e;
1168
+ }
1169
+
1170
+ function Kh(j) {
1171
+ if (j <= 15)
1172
+ return 0x50a28be6;
1173
+ else if (j <= 31)
1174
+ return 0x5c4dd124;
1175
+ else if (j <= 47)
1176
+ return 0x6d703ef3;
1177
+ else if (j <= 63)
1178
+ return 0x7a6d76e9;
1179
+ else
1180
+ return 0x00000000;
1181
+ }
1182
+
1183
+ var r = [
1184
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1185
+ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
1186
+ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1187
+ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
1188
+ 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
1189
+ ];
1190
+
1191
+ var rh = [
1192
+ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
1193
+ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
1194
+ 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
1195
+ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
1196
+ 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
1197
+ ];
1198
+
1199
+ var s = [
1200
+ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
1201
+ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
1202
+ 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
1203
+ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
1204
+ 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
1205
+ ];
1206
+
1207
+ var sh = [
1208
+ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
1209
+ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
1210
+ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
1211
+ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
1212
+ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
1213
+ ];
1214
+
1215
+ var utils = utils$9;
1216
+ var assert$1 = minimalisticAssert;
1217
+
1218
+ function Hmac(hash, key, enc) {
1219
+ if (!(this instanceof Hmac))
1220
+ return new Hmac(hash, key, enc);
1221
+ this.Hash = hash;
1222
+ this.blockSize = hash.blockSize / 8;
1223
+ this.outSize = hash.outSize / 8;
1224
+ this.inner = null;
1225
+ this.outer = null;
1226
+
1227
+ this._init(utils.toArray(key, enc));
1228
+ }
1229
+ var hmac = Hmac;
1230
+
1231
+ Hmac.prototype._init = function init(key) {
1232
+ // Shorten key, if needed
1233
+ if (key.length > this.blockSize)
1234
+ key = new this.Hash().update(key).digest();
1235
+ assert$1(key.length <= this.blockSize);
1236
+
1237
+ // Add padding to key
1238
+ for (var i = key.length; i < this.blockSize; i++)
1239
+ key.push(0);
1240
+
1241
+ for (i = 0; i < key.length; i++)
1242
+ key[i] ^= 0x36;
1243
+ this.inner = new this.Hash().update(key);
1244
+
1245
+ // 0x36 ^ 0x5c = 0x6a
1246
+ for (i = 0; i < key.length; i++)
1247
+ key[i] ^= 0x6a;
1248
+ this.outer = new this.Hash().update(key);
1249
+ };
1250
+
1251
+ Hmac.prototype.update = function update(msg, enc) {
1252
+ this.inner.update(msg, enc);
1253
+ return this;
1254
+ };
1255
+
1256
+ Hmac.prototype.digest = function digest(enc) {
1257
+ this.outer.update(this.inner.digest());
1258
+ return this.outer.digest(enc);
1259
+ };
1260
+
1261
+ (function (exports) {
1262
+ var hash = exports;
1263
+
1264
+ hash.utils = utils$9;
1265
+ hash.common = common$5;
1266
+ hash.sha = sha;
1267
+ hash.ripemd = ripemd;
1268
+ hash.hmac = hmac;
1269
+
1270
+ // Proxy hash functions to the main object
1271
+ hash.sha1 = hash.sha.sha1;
1272
+ hash.sha256 = hash.sha.sha256;
1273
+ hash.sha224 = hash.sha.sha224;
1274
+ hash.sha384 = hash.sha.sha384;
1275
+ hash.sha512 = hash.sha.sha512;
1276
+ hash.ripemd160 = hash.ripemd.ripemd160;
1277
+ }(hash$1));
1278
+
1279
+ var hash = hash$1;
1280
+
1281
+ const version$2 = "logger/5.5.0";
1282
+
1283
+ let _permanentCensorErrors = false;
1284
+ let _censorErrors = false;
1285
+ const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
1286
+ let _logLevel = LogLevels["default"];
1287
+ let _globalLogger = null;
1288
+ function _checkNormalize() {
1289
+ try {
1290
+ const missing = [];
1291
+ // Make sure all forms of normalization are supported
1292
+ ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
1293
+ try {
1294
+ if ("test".normalize(form) !== "test") {
1295
+ throw new Error("bad normalize");
1296
+ }
1297
+ ;
1298
+ }
1299
+ catch (error) {
1300
+ missing.push(form);
1301
+ }
1302
+ });
1303
+ if (missing.length) {
1304
+ throw new Error("missing " + missing.join(", "));
1305
+ }
1306
+ if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
1307
+ throw new Error("broken implementation");
1308
+ }
1309
+ }
1310
+ catch (error) {
1311
+ return error.message;
1312
+ }
1313
+ return null;
1314
+ }
1315
+ const _normalizeError = _checkNormalize();
1316
+ var LogLevel;
1317
+ (function (LogLevel) {
1318
+ LogLevel["DEBUG"] = "DEBUG";
1319
+ LogLevel["INFO"] = "INFO";
1320
+ LogLevel["WARNING"] = "WARNING";
1321
+ LogLevel["ERROR"] = "ERROR";
1322
+ LogLevel["OFF"] = "OFF";
1323
+ })(LogLevel || (LogLevel = {}));
1324
+ var ErrorCode;
1325
+ (function (ErrorCode) {
1326
+ ///////////////////
1327
+ // Generic Errors
1328
+ // Unknown Error
1329
+ ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
1330
+ // Not Implemented
1331
+ ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
1332
+ // Unsupported Operation
1333
+ // - operation
1334
+ ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
1335
+ // Network Error (i.e. Ethereum Network, such as an invalid chain ID)
1336
+ // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
1337
+ ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
1338
+ // Some sort of bad response from the server
1339
+ ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
1340
+ // Timeout
1341
+ ErrorCode["TIMEOUT"] = "TIMEOUT";
1342
+ ///////////////////
1343
+ // Operational Errors
1344
+ // Buffer Overrun
1345
+ ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
1346
+ // Numeric Fault
1347
+ // - operation: the operation being executed
1348
+ // - fault: the reason this faulted
1349
+ ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
1350
+ ///////////////////
1351
+ // Argument Errors
1352
+ // Missing new operator to an object
1353
+ // - name: The name of the class
1354
+ ErrorCode["MISSING_NEW"] = "MISSING_NEW";
1355
+ // Invalid argument (e.g. value is incompatible with type) to a function:
1356
+ // - argument: The argument name that was invalid
1357
+ // - value: The value of the argument
1358
+ ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
1359
+ // Missing argument to a function:
1360
+ // - count: The number of arguments received
1361
+ // - expectedCount: The number of arguments expected
1362
+ ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
1363
+ // Too many arguments
1364
+ // - count: The number of arguments received
1365
+ // - expectedCount: The number of arguments expected
1366
+ ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
1367
+ ///////////////////
1368
+ // Blockchain Errors
1369
+ // Call exception
1370
+ // - transaction: the transaction
1371
+ // - address?: the contract address
1372
+ // - args?: The arguments passed into the function
1373
+ // - method?: The Solidity method signature
1374
+ // - errorSignature?: The EIP848 error signature
1375
+ // - errorArgs?: The EIP848 error parameters
1376
+ // - reason: The reason (only for EIP848 "Error(string)")
1377
+ ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
1378
+ // Insufficient funds (< value + gasLimit * gasPrice)
1379
+ // - transaction: the transaction attempted
1380
+ ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
1381
+ // Nonce has already been used
1382
+ // - transaction: the transaction attempted
1383
+ ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
1384
+ // The replacement fee for the transaction is too low
1385
+ // - transaction: the transaction attempted
1386
+ ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
1387
+ // The gas limit could not be estimated
1388
+ // - transaction: the transaction passed to estimateGas
1389
+ ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
1390
+ // The transaction was replaced by one with a higher gas price
1391
+ // - reason: "cancelled", "replaced" or "repriced"
1392
+ // - cancelled: true if reason == "cancelled" or reason == "replaced")
1393
+ // - hash: original transaction hash
1394
+ // - replacement: the full TransactionsResponse for the replacement
1395
+ // - receipt: the receipt of the replacement
1396
+ ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED";
1397
+ })(ErrorCode || (ErrorCode = {}));
1398
+ const HEX = "0123456789abcdef";
1399
+ class Logger {
1400
+ constructor(version) {
1401
+ Object.defineProperty(this, "version", {
1402
+ enumerable: true,
1403
+ value: version,
1404
+ writable: false
1405
+ });
1406
+ }
1407
+ _log(logLevel, args) {
1408
+ const level = logLevel.toLowerCase();
1409
+ if (LogLevels[level] == null) {
1410
+ this.throwArgumentError("invalid log level name", "logLevel", logLevel);
1411
+ }
1412
+ if (_logLevel > LogLevels[level]) {
1413
+ return;
1414
+ }
1415
+ console.log.apply(console, args);
1416
+ }
1417
+ debug(...args) {
1418
+ this._log(Logger.levels.DEBUG, args);
1419
+ }
1420
+ info(...args) {
1421
+ this._log(Logger.levels.INFO, args);
1422
+ }
1423
+ warn(...args) {
1424
+ this._log(Logger.levels.WARNING, args);
1425
+ }
1426
+ makeError(message, code, params) {
1427
+ // Errors are being censored
1428
+ if (_censorErrors) {
1429
+ return this.makeError("censored error", code, {});
1430
+ }
1431
+ if (!code) {
1432
+ code = Logger.errors.UNKNOWN_ERROR;
1433
+ }
1434
+ if (!params) {
1435
+ params = {};
1436
+ }
1437
+ const messageDetails = [];
1438
+ Object.keys(params).forEach((key) => {
1439
+ const value = params[key];
1440
+ try {
1441
+ if (value instanceof Uint8Array) {
1442
+ let hex = "";
1443
+ for (let i = 0; i < value.length; i++) {
1444
+ hex += HEX[value[i] >> 4];
1445
+ hex += HEX[value[i] & 0x0f];
1446
+ }
1447
+ messageDetails.push(key + "=Uint8Array(0x" + hex + ")");
1448
+ }
1449
+ else {
1450
+ messageDetails.push(key + "=" + JSON.stringify(value));
1451
+ }
1452
+ }
1453
+ catch (error) {
1454
+ messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
1455
+ }
1456
+ });
1457
+ messageDetails.push(`code=${code}`);
1458
+ messageDetails.push(`version=${this.version}`);
1459
+ const reason = message;
1460
+ if (messageDetails.length) {
1461
+ message += " (" + messageDetails.join(", ") + ")";
1462
+ }
1463
+ // @TODO: Any??
1464
+ const error = new Error(message);
1465
+ error.reason = reason;
1466
+ error.code = code;
1467
+ Object.keys(params).forEach(function (key) {
1468
+ error[key] = params[key];
1469
+ });
1470
+ return error;
1471
+ }
1472
+ throwError(message, code, params) {
1473
+ throw this.makeError(message, code, params);
1474
+ }
1475
+ throwArgumentError(message, name, value) {
1476
+ return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
1477
+ argument: name,
1478
+ value: value
1479
+ });
1480
+ }
1481
+ assert(condition, message, code, params) {
1482
+ if (!!condition) {
1483
+ return;
1484
+ }
1485
+ this.throwError(message, code, params);
1486
+ }
1487
+ assertArgument(condition, message, name, value) {
1488
+ if (!!condition) {
1489
+ return;
1490
+ }
1491
+ this.throwArgumentError(message, name, value);
1492
+ }
1493
+ checkNormalize(message) {
1494
+ if (_normalizeError) {
1495
+ this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
1496
+ operation: "String.prototype.normalize", form: _normalizeError
1497
+ });
1498
+ }
1499
+ }
1500
+ checkSafeUint53(value, message) {
1501
+ if (typeof (value) !== "number") {
1502
+ return;
1503
+ }
1504
+ if (message == null) {
1505
+ message = "value not safe";
1506
+ }
1507
+ if (value < 0 || value >= 0x1fffffffffffff) {
1508
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1509
+ operation: "checkSafeInteger",
1510
+ fault: "out-of-safe-range",
1511
+ value: value
1512
+ });
1513
+ }
1514
+ if (value % 1) {
1515
+ this.throwError(message, Logger.errors.NUMERIC_FAULT, {
1516
+ operation: "checkSafeInteger",
1517
+ fault: "non-integer",
1518
+ value: value
1519
+ });
1520
+ }
1521
+ }
1522
+ checkArgumentCount(count, expectedCount, message) {
1523
+ if (message) {
1524
+ message = ": " + message;
1525
+ }
1526
+ else {
1527
+ message = "";
1528
+ }
1529
+ if (count < expectedCount) {
1530
+ this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
1531
+ count: count,
1532
+ expectedCount: expectedCount
1533
+ });
1534
+ }
1535
+ if (count > expectedCount) {
1536
+ this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
1537
+ count: count,
1538
+ expectedCount: expectedCount
1539
+ });
1540
+ }
1541
+ }
1542
+ checkNew(target, kind) {
1543
+ if (target === Object || target == null) {
1544
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1545
+ }
1546
+ }
1547
+ checkAbstract(target, kind) {
1548
+ if (target === kind) {
1549
+ this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
1550
+ }
1551
+ else if (target === Object || target == null) {
1552
+ this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
1553
+ }
1554
+ }
1555
+ static globalLogger() {
1556
+ if (!_globalLogger) {
1557
+ _globalLogger = new Logger(version$2);
1558
+ }
1559
+ return _globalLogger;
1560
+ }
1561
+ static setCensorship(censorship, permanent) {
1562
+ if (!censorship && permanent) {
1563
+ this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
1564
+ operation: "setCensorship"
1565
+ });
1566
+ }
1567
+ if (_permanentCensorErrors) {
1568
+ if (!censorship) {
1569
+ return;
1570
+ }
1571
+ this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
1572
+ operation: "setCensorship"
1573
+ });
1574
+ }
1575
+ _censorErrors = !!censorship;
1576
+ _permanentCensorErrors = !!permanent;
1577
+ }
1578
+ static setLogLevel(logLevel) {
1579
+ const level = LogLevels[logLevel.toLowerCase()];
1580
+ if (level == null) {
1581
+ Logger.globalLogger().warn("invalid log level - " + logLevel);
1582
+ return;
1583
+ }
1584
+ _logLevel = level;
1585
+ }
1586
+ static from(version) {
1587
+ return new Logger(version);
1588
+ }
1589
+ }
1590
+ Logger.errors = ErrorCode;
1591
+ Logger.levels = LogLevel;
1592
+
1593
+ const version$1 = "bytes/5.5.0";
1594
+
1595
+ const logger = new Logger(version$1);
1596
+ ///////////////////////////////
1597
+ function isHexable(value) {
1598
+ return !!(value.toHexString);
1599
+ }
1600
+ function addSlice(array) {
1601
+ if (array.slice) {
1602
+ return array;
1603
+ }
1604
+ array.slice = function () {
1605
+ const args = Array.prototype.slice.call(arguments);
1606
+ return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args)));
1607
+ };
1608
+ return array;
1609
+ }
1610
+ function isInteger(value) {
1611
+ return (typeof (value) === "number" && value == value && (value % 1) === 0);
1612
+ }
1613
+ function isBytes(value) {
1614
+ if (value == null) {
1615
+ return false;
1616
+ }
1617
+ if (value.constructor === Uint8Array) {
1618
+ return true;
1619
+ }
1620
+ if (typeof (value) === "string") {
1621
+ return false;
1622
+ }
1623
+ if (!isInteger(value.length) || value.length < 0) {
1624
+ return false;
1625
+ }
1626
+ for (let i = 0; i < value.length; i++) {
1627
+ const v = value[i];
1628
+ if (!isInteger(v) || v < 0 || v >= 256) {
1629
+ return false;
1630
+ }
1631
+ }
1632
+ return true;
1633
+ }
1634
+ function arrayify(value, options) {
1635
+ if (!options) {
1636
+ options = {};
1637
+ }
1638
+ if (typeof (value) === "number") {
1639
+ logger.checkSafeUint53(value, "invalid arrayify value");
1640
+ const result = [];
1641
+ while (value) {
1642
+ result.unshift(value & 0xff);
1643
+ value = parseInt(String(value / 256));
1644
+ }
1645
+ if (result.length === 0) {
1646
+ result.push(0);
1647
+ }
1648
+ return addSlice(new Uint8Array(result));
1649
+ }
1650
+ if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") {
1651
+ value = "0x" + value;
1652
+ }
1653
+ if (isHexable(value)) {
1654
+ value = value.toHexString();
1655
+ }
1656
+ if (isHexString(value)) {
1657
+ let hex = value.substring(2);
1658
+ if (hex.length % 2) {
1659
+ if (options.hexPad === "left") {
1660
+ hex = "0x0" + hex.substring(2);
1661
+ }
1662
+ else if (options.hexPad === "right") {
1663
+ hex += "0";
1664
+ }
1665
+ else {
1666
+ logger.throwArgumentError("hex data is odd-length", "value", value);
1667
+ }
1668
+ }
1669
+ const result = [];
1670
+ for (let i = 0; i < hex.length; i += 2) {
1671
+ result.push(parseInt(hex.substring(i, i + 2), 16));
1672
+ }
1673
+ return addSlice(new Uint8Array(result));
1674
+ }
1675
+ if (isBytes(value)) {
1676
+ return addSlice(new Uint8Array(value));
1677
+ }
1678
+ return logger.throwArgumentError("invalid arrayify value", "value", value);
1679
+ }
1680
+ function isHexString(value, length) {
1681
+ if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
1682
+ return false;
1683
+ }
1684
+ if (length && value.length !== 2 + 2 * length) {
1685
+ return false;
1686
+ }
1687
+ return true;
1688
+ }
1689
+
1690
+ const version = "sha2/5.5.0";
1691
+
1692
+ new Logger(version);
1693
+ function sha256(data) {
1694
+ return "0x" + (hash.sha256().update(arrayify(data)).digest("hex"));
1695
+ }
1696
+
26
1697
  class Struct {
27
1698
  constructor(properties) {
28
1699
  Object.assign(this, properties);
@@ -46,8 +1717,7 @@ class Struct {
46
1717
  class Enum extends Struct {
47
1718
  constructor(properties) {
48
1719
  super(properties);
49
-
50
- _defineProperty(this, "enum", '');
1720
+ this.enum = '';
51
1721
 
52
1722
  if (Object.keys(properties).length !== 1) {
53
1723
  throw new Error('Enum can only take single value');
@@ -87,8 +1757,7 @@ class PublicKey extends Struct {
87
1757
  */
88
1758
  constructor(value) {
89
1759
  super({});
90
-
91
- _defineProperty(this, "_bn", void 0);
1760
+ this._bn = void 0;
92
1761
 
93
1762
  if (isPublicKeyData(value)) {
94
1763
  this._bn = value._bn;
@@ -168,16 +1837,20 @@ class PublicKey extends Struct {
168
1837
  * it permission to write data to the account.
169
1838
  */
170
1839
 
1840
+ /* eslint-disable require-await */
1841
+
171
1842
 
172
1843
  static async createWithSeed(fromPublicKey, seed, programId) {
173
1844
  const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);
174
- const hash = await sha256(new Uint8Array(buffer));
1845
+ const hash = sha256(new Uint8Array(buffer)).slice(2);
175
1846
  return new PublicKey(Buffer.from(hash, 'hex'));
176
1847
  }
177
1848
  /**
178
1849
  * Derive a program address from seeds and a program ID.
179
1850
  */
180
1851
 
1852
+ /* eslint-disable require-await */
1853
+
181
1854
 
182
1855
  static async createProgramAddress(seeds, programId) {
183
1856
  let buffer = Buffer.alloc(0);
@@ -189,7 +1862,7 @@ class PublicKey extends Struct {
189
1862
  buffer = Buffer.concat([buffer, toBuffer(seed)]);
190
1863
  });
191
1864
  buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);
192
- let hash = await sha256(new Uint8Array(buffer));
1865
+ let hash = sha256(new Uint8Array(buffer)).slice(2);
193
1866
  let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
194
1867
 
195
1868
  if (is_on_curve(publicKeyBytes)) {
@@ -239,9 +1912,7 @@ class PublicKey extends Struct {
239
1912
  }
240
1913
 
241
1914
  }
242
-
243
- _defineProperty(PublicKey, "default", new PublicKey('11111111111111111111111111111111'));
244
-
1915
+ PublicKey.default = new PublicKey('11111111111111111111111111111111');
245
1916
  SOLANA_SCHEMA.set(PublicKey, {
246
1917
  kind: 'struct',
247
1918
  fields: [['_bn', 'u256']]
@@ -314,7 +1985,7 @@ class Account {
314
1985
  * @param secretKey Secret key for the account
315
1986
  */
316
1987
  constructor(secretKey) {
317
- _defineProperty(this, "_keypair", void 0);
1988
+ this._keypair = void 0;
318
1989
 
319
1990
  if (secretKey) {
320
1991
  this._keypair = nacl.sign.keyPair.fromSecretKey(toBuffer(secretKey));
@@ -450,16 +2121,11 @@ const PUBKEY_LENGTH = 32;
450
2121
 
451
2122
  class Message {
452
2123
  constructor(args) {
453
- _defineProperty(this, "header", void 0);
454
-
455
- _defineProperty(this, "accountKeys", void 0);
456
-
457
- _defineProperty(this, "recentBlockhash", void 0);
458
-
459
- _defineProperty(this, "instructions", void 0);
460
-
461
- _defineProperty(this, "indexToProgramIds", new Map());
462
-
2124
+ this.header = void 0;
2125
+ this.accountKeys = void 0;
2126
+ this.recentBlockhash = void 0;
2127
+ this.instructions = void 0;
2128
+ this.indexToProgramIds = new Map();
463
2129
  this.header = args.header;
464
2130
  this.accountKeys = args.accountKeys.map(account => new PublicKey(account));
465
2131
  this.recentBlockhash = args.recentBlockhash;
@@ -633,12 +2299,9 @@ class TransactionInstruction {
633
2299
  * Program input
634
2300
  */
635
2301
  constructor(opts) {
636
- _defineProperty(this, "keys", void 0);
637
-
638
- _defineProperty(this, "programId", void 0);
639
-
640
- _defineProperty(this, "data", Buffer.alloc(0));
641
-
2302
+ this.keys = void 0;
2303
+ this.programId = void 0;
2304
+ this.data = Buffer.alloc(0);
642
2305
  this.programId = opts.programId;
643
2306
  this.keys = opts.keys;
644
2307
 
@@ -680,16 +2343,11 @@ class Transaction {
680
2343
  * Construct an empty Transaction
681
2344
  */
682
2345
  constructor(opts) {
683
- _defineProperty(this, "signatures", []);
684
-
685
- _defineProperty(this, "feePayer", void 0);
686
-
687
- _defineProperty(this, "instructions", []);
688
-
689
- _defineProperty(this, "recentBlockhash", void 0);
690
-
691
- _defineProperty(this, "nonceInfo", void 0);
692
-
2346
+ this.signatures = [];
2347
+ this.feePayer = void 0;
2348
+ this.instructions = [];
2349
+ this.recentBlockhash = void 0;
2350
+ this.nonceInfo = void 0;
693
2351
  opts && Object.assign(this, opts);
694
2352
  }
695
2353
  /**
@@ -1340,12 +2998,9 @@ class NonceAccount {
1340
2998
  * @internal
1341
2999
  */
1342
3000
  constructor(args) {
1343
- _defineProperty(this, "authorizedPubkey", void 0);
1344
-
1345
- _defineProperty(this, "nonce", void 0);
1346
-
1347
- _defineProperty(this, "feeCalculator", void 0);
1348
-
3001
+ this.authorizedPubkey = void 0;
3002
+ this.nonce = void 0;
3003
+ this.feeCalculator = void 0;
1349
3004
  this.authorizedPubkey = args.authorizedPubkey;
1350
3005
  this.nonce = args.nonce;
1351
3006
  this.feeCalculator = args.feeCalculator;
@@ -2078,8 +3733,7 @@ class SystemProgram {
2078
3733
  }
2079
3734
 
2080
3735
  }
2081
-
2082
- _defineProperty(SystemProgram, "programId", new PublicKey('11111111111111111111111111111111'));
3736
+ SystemProgram.programId = new PublicKey('11111111111111111111111111111111');
2083
3737
 
2084
3738
  // rest of the Transaction fields
2085
3739
  //
@@ -2108,7 +3762,8 @@ class Loader {
2108
3762
  * Can be used to calculate transaction fees
2109
3763
  */
2110
3764
  static getMinNumSignatures(dataLength) {
2111
- return 2 * (Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
3765
+ return 2 * ( // Every transaction requires two signatures (payer + program)
3766
+ Math.ceil(dataLength / Loader.chunkSize) + 1 + // Add one for Create transaction
2112
3767
  1) // Add one for Finalize transaction
2113
3768
  ;
2114
3769
  }
@@ -2247,8 +3902,7 @@ class Loader {
2247
3902
  }
2248
3903
 
2249
3904
  }
2250
-
2251
- _defineProperty(Loader, "chunkSize", CHUNK_SIZE);
3905
+ Loader.chunkSize = CHUNK_SIZE;
2252
3906
 
2253
3907
  const BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
2254
3908
  /**
@@ -2283,12 +3937,6 @@ class BpfLoader {
2283
3937
 
2284
3938
  }
2285
3939
 
2286
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2287
-
2288
- function getDefaultExportFromCjs (x) {
2289
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2290
- }
2291
-
2292
3940
  var browserPonyfill = {exports: {}};
2293
3941
 
2294
3942
  (function (module, exports) {
@@ -2893,16 +4541,11 @@ class EpochSchedule {
2893
4541
 
2894
4542
  /** The first slot of `firstNormalEpoch` */
2895
4543
  constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {
2896
- _defineProperty(this, "slotsPerEpoch", void 0);
2897
-
2898
- _defineProperty(this, "leaderScheduleSlotOffset", void 0);
2899
-
2900
- _defineProperty(this, "warmup", void 0);
2901
-
2902
- _defineProperty(this, "firstNormalEpoch", void 0);
2903
-
2904
- _defineProperty(this, "firstNormalSlot", void 0);
2905
-
4544
+ this.slotsPerEpoch = void 0;
4545
+ this.leaderScheduleSlotOffset = void 0;
4546
+ this.warmup = void 0;
4547
+ this.firstNormalEpoch = void 0;
4548
+ this.firstNormalSlot = void 0;
2906
4549
  this.slotsPerEpoch = slotsPerEpoch;
2907
4550
  this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;
2908
4551
  this.warmup = warmup;
@@ -2954,9 +4597,7 @@ class EpochSchedule {
2954
4597
  class SendTransactionError extends Error {
2955
4598
  constructor(message, logs) {
2956
4599
  super(message);
2957
-
2958
- _defineProperty(this, "logs", void 0);
2959
-
4600
+ this.logs = void 0;
2960
4601
  this.logs = logs;
2961
4602
  }
2962
4603
 
@@ -3910,67 +5551,39 @@ class Connection {
3910
5551
  * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
3911
5552
  */
3912
5553
  constructor(endpoint, commitmentOrConfig) {
3913
- _defineProperty(this, "_commitment", void 0);
3914
-
3915
- _defineProperty(this, "_confirmTransactionInitialTimeout", void 0);
3916
-
3917
- _defineProperty(this, "_rpcEndpoint", void 0);
3918
-
3919
- _defineProperty(this, "_rpcWsEndpoint", void 0);
3920
-
3921
- _defineProperty(this, "_rpcClient", void 0);
3922
-
3923
- _defineProperty(this, "_rpcRequest", void 0);
3924
-
3925
- _defineProperty(this, "_rpcBatchRequest", void 0);
3926
-
3927
- _defineProperty(this, "_rpcWebSocket", void 0);
3928
-
3929
- _defineProperty(this, "_rpcWebSocketConnected", false);
3930
-
3931
- _defineProperty(this, "_rpcWebSocketHeartbeat", null);
3932
-
3933
- _defineProperty(this, "_rpcWebSocketIdleTimeout", null);
3934
-
3935
- _defineProperty(this, "_disableBlockhashCaching", false);
3936
-
3937
- _defineProperty(this, "_pollingBlockhash", false);
3938
-
3939
- _defineProperty(this, "_blockhashInfo", {
5554
+ this._commitment = void 0;
5555
+ this._confirmTransactionInitialTimeout = void 0;
5556
+ this._rpcEndpoint = void 0;
5557
+ this._rpcWsEndpoint = void 0;
5558
+ this._rpcClient = void 0;
5559
+ this._rpcRequest = void 0;
5560
+ this._rpcBatchRequest = void 0;
5561
+ this._rpcWebSocket = void 0;
5562
+ this._rpcWebSocketConnected = false;
5563
+ this._rpcWebSocketHeartbeat = null;
5564
+ this._rpcWebSocketIdleTimeout = null;
5565
+ this._disableBlockhashCaching = false;
5566
+ this._pollingBlockhash = false;
5567
+ this._blockhashInfo = {
3940
5568
  recentBlockhash: null,
3941
5569
  lastFetch: 0,
3942
5570
  transactionSignatures: [],
3943
5571
  simulatedSignatures: []
3944
- });
3945
-
3946
- _defineProperty(this, "_accountChangeSubscriptionCounter", 0);
3947
-
3948
- _defineProperty(this, "_accountChangeSubscriptions", {});
3949
-
3950
- _defineProperty(this, "_programAccountChangeSubscriptionCounter", 0);
3951
-
3952
- _defineProperty(this, "_programAccountChangeSubscriptions", {});
3953
-
3954
- _defineProperty(this, "_rootSubscriptionCounter", 0);
3955
-
3956
- _defineProperty(this, "_rootSubscriptions", {});
3957
-
3958
- _defineProperty(this, "_signatureSubscriptionCounter", 0);
3959
-
3960
- _defineProperty(this, "_signatureSubscriptions", {});
3961
-
3962
- _defineProperty(this, "_slotSubscriptionCounter", 0);
3963
-
3964
- _defineProperty(this, "_slotSubscriptions", {});
3965
-
3966
- _defineProperty(this, "_logsSubscriptionCounter", 0);
3967
-
3968
- _defineProperty(this, "_logsSubscriptions", {});
3969
-
3970
- _defineProperty(this, "_slotUpdateSubscriptionCounter", 0);
3971
-
3972
- _defineProperty(this, "_slotUpdateSubscriptions", {});
3973
-
5572
+ };
5573
+ this._accountChangeSubscriptionCounter = 0;
5574
+ this._accountChangeSubscriptions = {};
5575
+ this._programAccountChangeSubscriptionCounter = 0;
5576
+ this._programAccountChangeSubscriptions = {};
5577
+ this._rootSubscriptionCounter = 0;
5578
+ this._rootSubscriptions = {};
5579
+ this._signatureSubscriptionCounter = 0;
5580
+ this._signatureSubscriptions = {};
5581
+ this._slotSubscriptionCounter = 0;
5582
+ this._slotSubscriptions = {};
5583
+ this._logsSubscriptionCounter = 0;
5584
+ this._logsSubscriptions = {};
5585
+ this._slotUpdateSubscriptionCounter = 0;
5586
+ this._slotUpdateSubscriptions = {};
3974
5587
  let url = new URL(endpoint);
3975
5588
  const useHttps = url.protocol === 'https:';
3976
5589
  let wsEndpoint;
@@ -4105,10 +5718,24 @@ class Connection {
4105
5718
  */
4106
5719
 
4107
5720
 
4108
- async getSupply(commitment) {
4109
- const args = this._buildArgs([], commitment);
5721
+ async getSupply(config) {
5722
+ let configArg = {};
4110
5723
 
4111
- const unsafeRes = await this._rpcRequest('getSupply', args);
5724
+ if (typeof config === 'string') {
5725
+ configArg = {
5726
+ commitment: config
5727
+ };
5728
+ } else if (config) {
5729
+ configArg = { ...config,
5730
+ commitment: config && config.commitment || this.commitment
5731
+ };
5732
+ } else {
5733
+ configArg = {
5734
+ commitment: this.commitment
5735
+ };
5736
+ }
5737
+
5738
+ const unsafeRes = await this._rpcRequest('getSupply', [configArg]);
4112
5739
  const res = create(unsafeRes, GetSupplyRpcResult);
4113
5740
 
4114
5741
  if ('error' in res) {
@@ -4619,16 +6246,11 @@ class Connection {
4619
6246
 
4620
6247
 
4621
6248
  async getTotalSupply(commitment) {
4622
- const args = this._buildArgs([], commitment);
4623
-
4624
- const unsafeRes = await this._rpcRequest('getSupply', args);
4625
- const res = create(unsafeRes, GetSupplyRpcResult);
4626
-
4627
- if ('error' in res) {
4628
- throw new Error('failed to get total supply: ' + res.error.message);
4629
- }
4630
-
4631
- return res.result.value.total;
6249
+ const result = await this.getSupply({
6250
+ commitment,
6251
+ excludeNonCirculatingAccountsList: true
6252
+ });
6253
+ return result.value.total;
4632
6254
  }
4633
6255
  /**
4634
6256
  * Fetch the cluster InflationGovernor parameters
@@ -6126,7 +7748,7 @@ class Keypair {
6126
7748
  * @param keypair ed25519 keypair
6127
7749
  */
6128
7750
  constructor(keypair) {
6129
- _defineProperty(this, "_keypair", void 0);
7751
+ this._keypair = void 0;
6130
7752
 
6131
7753
  if (keypair) {
6132
7754
  this._keypair = keypair;
@@ -6287,8 +7909,7 @@ class Ed25519Program {
6287
7909
  }
6288
7910
 
6289
7911
  }
6290
-
6291
- _defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
7912
+ Ed25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');
6292
7913
 
6293
7914
  /**
6294
7915
  * Address of the stake config account which configures the rate
@@ -6311,10 +7932,8 @@ class Authorized {
6311
7932
  * @param withdrawer the withdraw authority
6312
7933
  */
6313
7934
  constructor(staker, withdrawer) {
6314
- _defineProperty(this, "staker", void 0);
6315
-
6316
- _defineProperty(this, "withdrawer", void 0);
6317
-
7935
+ this.staker = void 0;
7936
+ this.withdrawer = void 0;
6318
7937
  this.staker = staker;
6319
7938
  this.withdrawer = withdrawer;
6320
7939
  }
@@ -6335,12 +7954,9 @@ class Lockup {
6335
7954
  * Create a new Lockup object
6336
7955
  */
6337
7956
  constructor(unixTimestamp, epoch, custodian) {
6338
- _defineProperty(this, "unixTimestamp", void 0);
6339
-
6340
- _defineProperty(this, "epoch", void 0);
6341
-
6342
- _defineProperty(this, "custodian", void 0);
6343
-
7957
+ this.unixTimestamp = void 0;
7958
+ this.epoch = void 0;
7959
+ this.custodian = void 0;
6344
7960
  this.unixTimestamp = unixTimestamp;
6345
7961
  this.epoch = epoch;
6346
7962
  this.custodian = custodian;
@@ -6355,7 +7971,7 @@ class Lockup {
6355
7971
  * Create stake account transaction params
6356
7972
  */
6357
7973
 
6358
- _defineProperty(Lockup, "default", new Lockup(0, 0, PublicKey.default));
7974
+ Lockup.default = new Lockup(0, 0, PublicKey.default);
6359
7975
 
6360
7976
  /**
6361
7977
  * Stake Instruction class
@@ -7043,10 +8659,8 @@ class StakeProgram {
7043
8659
  }
7044
8660
 
7045
8661
  }
7046
-
7047
- _defineProperty(StakeProgram, "programId", new PublicKey('Stake11111111111111111111111111111111111111'));
7048
-
7049
- _defineProperty(StakeProgram, "space", 200);
8662
+ StakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');
8663
+ StakeProgram.space = 200;
7050
8664
 
7051
8665
  const {
7052
8666
  publicKeyCreate,
@@ -7195,8 +8809,7 @@ class Secp256k1Program {
7195
8809
  }
7196
8810
 
7197
8811
  }
7198
-
7199
- _defineProperty(Secp256k1Program, "programId", new PublicKey('KeccakSecp256k11111111111111111111111111111'));
8812
+ Secp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');
7200
8813
 
7201
8814
  const VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');
7202
8815
  /**
@@ -7229,10 +8842,8 @@ class ValidatorInfo {
7229
8842
  * @param info validator information
7230
8843
  */
7231
8844
  constructor(key, info) {
7232
- _defineProperty(this, "key", void 0);
7233
-
7234
- _defineProperty(this, "info", void 0);
7235
-
8845
+ this.key = void 0;
8846
+ this.info = void 0;
7236
8847
  this.key = key;
7237
8848
  this.info = info;
7238
8849
  }
@@ -7267,7 +8878,7 @@ class ValidatorInfo {
7267
8878
  if (configKeys[1].isSigner) {
7268
8879
  const rawInfo = rustString().decode(Buffer.from(byteArray));
7269
8880
  const info = JSON.parse(rawInfo);
7270
- assert$1(info, InfoString);
8881
+ assert$7(info, InfoString);
7271
8882
  return new ValidatorInfo(configKeys[1].publicKey, info);
7272
8883
  }
7273
8884
  }
@@ -7296,26 +8907,16 @@ class VoteAccount {
7296
8907
  * @internal
7297
8908
  */
7298
8909
  constructor(args) {
7299
- _defineProperty(this, "nodePubkey", void 0);
7300
-
7301
- _defineProperty(this, "authorizedVoterPubkey", void 0);
7302
-
7303
- _defineProperty(this, "authorizedWithdrawerPubkey", void 0);
7304
-
7305
- _defineProperty(this, "commission", void 0);
7306
-
7307
- _defineProperty(this, "votes", void 0);
7308
-
7309
- _defineProperty(this, "rootSlot", void 0);
7310
-
7311
- _defineProperty(this, "epoch", void 0);
7312
-
7313
- _defineProperty(this, "credits", void 0);
7314
-
7315
- _defineProperty(this, "lastEpochCredits", void 0);
7316
-
7317
- _defineProperty(this, "epochCredits", void 0);
7318
-
8910
+ this.nodePubkey = void 0;
8911
+ this.authorizedVoterPubkey = void 0;
8912
+ this.authorizedWithdrawerPubkey = void 0;
8913
+ this.commission = void 0;
8914
+ this.votes = void 0;
8915
+ this.rootSlot = void 0;
8916
+ this.epoch = void 0;
8917
+ this.credits = void 0;
8918
+ this.lastEpochCredits = void 0;
8919
+ this.epochCredits = void 0;
7319
8920
  this.nodePubkey = args.nodePubkey;
7320
8921
  this.authorizedVoterPubkey = args.authorizedVoterPubkey;
7321
8922
  this.authorizedWithdrawerPubkey = args.authorizedWithdrawerPubkey;