@gardenfi/utils 2.1.2-beta.7 → 2.1.2-beta.9

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.
Files changed (131) hide show
  1. package/dist/index102.cjs +1 -1
  2. package/dist/index102.js +2 -2
  3. package/dist/index103.cjs +1 -1
  4. package/dist/index103.js +1 -1
  5. package/dist/index15.cjs +1 -1
  6. package/dist/index15.js +2 -2
  7. package/dist/index20.cjs +1 -1
  8. package/dist/index20.js +17 -18
  9. package/dist/index21.cjs +1 -16
  10. package/dist/index21.js +30 -112
  11. package/dist/index22.cjs +16 -1
  12. package/dist/index22.js +113 -30
  13. package/dist/index23.cjs +1 -1
  14. package/dist/index23.js +3 -3
  15. package/dist/index32.cjs +1 -1
  16. package/dist/index32.js +1 -1
  17. package/dist/index33.cjs +1 -1
  18. package/dist/index33.js +1 -1
  19. package/dist/index35.cjs +1 -1
  20. package/dist/index35.js +1 -1
  21. package/dist/index36.cjs +1 -1
  22. package/dist/index36.js +2 -2
  23. package/dist/index37.cjs +1 -1
  24. package/dist/index37.js +2 -2
  25. package/dist/index38.cjs +1 -1
  26. package/dist/index38.js +1 -1
  27. package/dist/index39.cjs +1 -1
  28. package/dist/index39.js +2 -2
  29. package/dist/index40.cjs +1 -1
  30. package/dist/index40.js +11 -11
  31. package/dist/index41.cjs +1 -1
  32. package/dist/index41.js +3 -3
  33. package/dist/index42.cjs +1 -1
  34. package/dist/index42.js +1 -1
  35. package/dist/index43.cjs +1 -1
  36. package/dist/index43.js +1 -1
  37. package/dist/index45.cjs +1 -1
  38. package/dist/index45.js +1 -1
  39. package/dist/index46.cjs +1 -1
  40. package/dist/index46.js +1 -1
  41. package/dist/index47.cjs +1 -1
  42. package/dist/index47.js +105 -33
  43. package/dist/index48.cjs +1 -1
  44. package/dist/index48.js +15 -33
  45. package/dist/index49.cjs +1 -1
  46. package/dist/index49.js +213 -59
  47. package/dist/index50.cjs +2 -1
  48. package/dist/index50.js +57 -110
  49. package/dist/index51.cjs +1 -1
  50. package/dist/index51.js +18 -64
  51. package/dist/index52.cjs +1 -1
  52. package/dist/index52.js +105 -2
  53. package/dist/index53.cjs +1 -1
  54. package/dist/index53.js +3 -16
  55. package/dist/index54.cjs +1 -1
  56. package/dist/index54.js +16 -222
  57. package/dist/index55.cjs +1 -1
  58. package/dist/index55.js +8 -231
  59. package/dist/index56.cjs +1 -2
  60. package/dist/index56.js +9 -58
  61. package/dist/index57.cjs +1 -1
  62. package/dist/index57.js +11 -21
  63. package/dist/index58.cjs +1 -1
  64. package/dist/index58.js +13 -104
  65. package/dist/index59.cjs +1 -1
  66. package/dist/index59.js +18 -3
  67. package/dist/index60.cjs +1 -1
  68. package/dist/index60.js +6 -17
  69. package/dist/index61.cjs +1 -1
  70. package/dist/index61.js +42 -8
  71. package/dist/index62.cjs +1 -1
  72. package/dist/index62.js +77 -9
  73. package/dist/index63.cjs +1 -1
  74. package/dist/index63.js +14 -11
  75. package/dist/index64.cjs +1 -1
  76. package/dist/index64.js +18 -13
  77. package/dist/index65.cjs +1 -1
  78. package/dist/index65.js +8 -18
  79. package/dist/index66.cjs +1 -1
  80. package/dist/index66.js +191 -6
  81. package/dist/index67.cjs +1 -1
  82. package/dist/index67.js +60 -38
  83. package/dist/index68.cjs +1 -1
  84. package/dist/index68.js +4 -78
  85. package/dist/index69.cjs +1 -1
  86. package/dist/index69.js +40 -14
  87. package/dist/index70.cjs +1 -1
  88. package/dist/index70.js +34 -18
  89. package/dist/index71.cjs +1 -1
  90. package/dist/index71.js +69 -8
  91. package/dist/index72.cjs +1 -1
  92. package/dist/index72.js +58 -182
  93. package/dist/index73.cjs +1 -1
  94. package/dist/index73.js +2 -65
  95. package/dist/index74.cjs +1 -1
  96. package/dist/index74.js +231 -4
  97. package/dist/index76.cjs +1 -1
  98. package/dist/index76.js +1 -1
  99. package/dist/index79.cjs +1 -1
  100. package/dist/index79.js +2 -2
  101. package/dist/index80.cjs +1 -1
  102. package/dist/index80.js +1 -1
  103. package/dist/index84.cjs +1 -1
  104. package/dist/index84.js +2 -2
  105. package/dist/index85.cjs +1 -1
  106. package/dist/index85.js +1 -1
  107. package/dist/index87.cjs +1 -1
  108. package/dist/index87.js +1 -1
  109. package/dist/index89.cjs +1 -1
  110. package/dist/index89.js +12 -8
  111. package/dist/index9.cjs +1 -1
  112. package/dist/index9.js +2 -2
  113. package/dist/index90.cjs +1 -1
  114. package/dist/index90.js +8 -12
  115. package/dist/index91.cjs +1 -1
  116. package/dist/index91.js +641 -16
  117. package/dist/index92.cjs +1 -1
  118. package/dist/index92.js +153 -624
  119. package/dist/index93.cjs +1 -1
  120. package/dist/index93.js +17 -171
  121. package/dist/index95.cjs +1 -2
  122. package/dist/index95.js +2 -3
  123. package/dist/index96.cjs +1 -1
  124. package/dist/index96.js +2 -2
  125. package/dist/index97.cjs +1 -1
  126. package/dist/index97.js +38 -2
  127. package/dist/index98.cjs +1 -1
  128. package/dist/index98.js +34 -33
  129. package/dist/index99.cjs +2 -1
  130. package/dist/index99.js +3 -39
  131. package/package.json +1 -1
package/dist/index49.js CHANGED
@@ -1,72 +1,226 @@
1
- import { crypto as o } from "./index52.js";
2
- import { abytes as i } from "./index48.js";
3
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
- function g(t) {
5
- return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
1
+ import { numberToBytesLE as S, numberToBytesBE as x, bitMask as _, bytesToNumberLE as y, bytesToNumberBE as L, validateObject as M } from "./index74.js";
2
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
+ const d = BigInt(0), c = BigInt(1), w = /* @__PURE__ */ BigInt(2), C = /* @__PURE__ */ BigInt(3), b = /* @__PURE__ */ BigInt(4), N = /* @__PURE__ */ BigInt(5), m = /* @__PURE__ */ BigInt(8);
4
+ function g(t, i) {
5
+ const r = t % i;
6
+ return r >= d ? r : i + r;
6
7
  }
7
- function m(t) {
8
- return new DataView(t.buffer, t.byteOffset, t.byteLength);
8
+ function Z(t, i, r) {
9
+ if (i < d)
10
+ throw new Error("invalid exponent, negatives unsupported");
11
+ if (r <= d)
12
+ throw new Error("invalid modulus");
13
+ if (r === c)
14
+ return d;
15
+ let e = c;
16
+ for (; i > d; )
17
+ i & c && (e = e * t % r), t = t * t % r, i >>= c;
18
+ return e;
9
19
  }
10
- function w(t, e) {
11
- return t << 32 - e | t >>> e;
20
+ function V(t, i, r) {
21
+ let e = t;
22
+ for (; i-- > d; )
23
+ e *= e, e %= r;
24
+ return e;
12
25
  }
13
- const b = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
14
- function c(t) {
15
- return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
16
- }
17
- function a(t) {
18
- for (let e = 0; e < t.length; e++)
19
- t[e] = c(t[e]);
20
- }
21
- function s(t) {
22
- if (typeof t != "string")
23
- throw new Error("utf8ToBytes expected string, got " + typeof t);
24
- return new Uint8Array(new TextEncoder().encode(t));
26
+ function I(t, i) {
27
+ if (t === d)
28
+ throw new Error("invert: expected non-zero number");
29
+ if (i <= d)
30
+ throw new Error("invert: expected positive modulus, got " + i);
31
+ let r = g(t, i), e = i, s = d, u = c;
32
+ for (; r !== d; ) {
33
+ const o = e / r, n = e % r, l = s - u * o;
34
+ e = r, r = n, s = u, u = l;
35
+ }
36
+ if (e !== c)
37
+ throw new Error("invert: does not exist");
38
+ return g(s, i);
25
39
  }
26
- function y(t) {
27
- return typeof t == "string" && (t = s(t)), i(t), t;
40
+ function j(t) {
41
+ const i = (t - c) / w;
42
+ let r, e, s;
43
+ for (r = t - c, e = 0; r % w === d; r /= w, e++)
44
+ ;
45
+ for (s = w; s < t && Z(s, i, t) !== t - c; s++)
46
+ if (s > 1e3)
47
+ throw new Error("Cannot find square root: likely non-prime P");
48
+ if (e === 1) {
49
+ const f = (t + c) / b;
50
+ return function(n, l) {
51
+ const h = n.pow(l, f);
52
+ if (!n.eql(n.sqr(h), l))
53
+ throw new Error("Cannot find square root");
54
+ return h;
55
+ };
56
+ }
57
+ const u = (r + c) / w;
58
+ return function(o, n) {
59
+ if (o.pow(n, i) === o.neg(o.ONE))
60
+ throw new Error("Cannot find square root");
61
+ let l = e, h = o.pow(o.mul(o.ONE, s), r), v = o.pow(n, u), a = o.pow(n, r);
62
+ for (; !o.eql(a, o.ONE); ) {
63
+ if (o.eql(a, o.ZERO))
64
+ return o.ZERO;
65
+ let q = 1;
66
+ for (let B = o.sqr(a); q < l && !o.eql(B, o.ONE); q++)
67
+ B = o.sqr(B);
68
+ const E = o.pow(h, c << BigInt(l - q - 1));
69
+ h = o.sqr(E), v = o.mul(v, E), a = o.mul(a, h), l = q;
70
+ }
71
+ return v;
72
+ };
28
73
  }
29
- function x(...t) {
30
- let e = 0;
31
- for (let n = 0; n < t.length; n++) {
32
- const r = t[n];
33
- i(r), e += r.length;
74
+ function z(t) {
75
+ if (t % b === C) {
76
+ const i = (t + c) / b;
77
+ return function(e, s) {
78
+ const u = e.pow(s, i);
79
+ if (!e.eql(e.sqr(u), s))
80
+ throw new Error("Cannot find square root");
81
+ return u;
82
+ };
34
83
  }
35
- const f = new Uint8Array(e);
36
- for (let n = 0, r = 0; n < t.length; n++) {
37
- const u = t[n];
38
- f.set(u, r), r += u.length;
84
+ if (t % m === N) {
85
+ const i = (t - N) / m;
86
+ return function(e, s) {
87
+ const u = e.mul(s, w), f = e.pow(u, i), o = e.mul(s, f), n = e.mul(e.mul(o, w), f), l = e.mul(o, e.sub(n, e.ONE));
88
+ if (!e.eql(e.sqr(l), s))
89
+ throw new Error("Cannot find square root");
90
+ return l;
91
+ };
39
92
  }
40
- return f;
93
+ return j(t);
41
94
  }
42
- class h {
43
- // Safe version that clones internal state
44
- clone() {
45
- return this._cloneInto();
46
- }
95
+ const A = [
96
+ "create",
97
+ "isValid",
98
+ "is0",
99
+ "neg",
100
+ "inv",
101
+ "sqrt",
102
+ "sqr",
103
+ "eql",
104
+ "add",
105
+ "sub",
106
+ "mul",
107
+ "pow",
108
+ "div",
109
+ "addN",
110
+ "subN",
111
+ "mulN",
112
+ "sqrN"
113
+ ];
114
+ function Y(t) {
115
+ const i = {
116
+ ORDER: "bigint",
117
+ MASK: "bigint",
118
+ BYTES: "isSafeInteger",
119
+ BITS: "isSafeInteger"
120
+ }, r = A.reduce((e, s) => (e[s] = "function", e), i);
121
+ return M(t, r);
122
+ }
123
+ function k(t, i, r) {
124
+ if (r < d)
125
+ throw new Error("invalid exponent, negatives unsupported");
126
+ if (r === d)
127
+ return t.ONE;
128
+ if (r === c)
129
+ return i;
130
+ let e = t.ONE, s = i;
131
+ for (; r > d; )
132
+ r & c && (e = t.mul(e, s)), s = t.sqr(s), r >>= c;
133
+ return e;
134
+ }
135
+ function H(t, i) {
136
+ const r = new Array(i.length), e = i.reduce((u, f, o) => t.is0(f) ? u : (r[o] = u, t.mul(u, f)), t.ONE), s = t.inv(e);
137
+ return i.reduceRight((u, f, o) => t.is0(f) ? u : (r[o] = t.mul(u, r[o]), t.mul(u, f)), s), r;
138
+ }
139
+ function K(t, i) {
140
+ const r = i !== void 0 ? i : t.toString(2).length, e = Math.ceil(r / 8);
141
+ return { nBitLength: r, nByteLength: e };
142
+ }
143
+ function p(t, i, r = !1, e = {}) {
144
+ if (t <= d)
145
+ throw new Error("invalid field: expected ORDER > 0, got " + t);
146
+ const { nBitLength: s, nByteLength: u } = K(t, i);
147
+ if (u > 2048)
148
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
149
+ let f;
150
+ const o = Object.freeze({
151
+ ORDER: t,
152
+ isLE: r,
153
+ BITS: s,
154
+ BYTES: u,
155
+ MASK: _(s),
156
+ ZERO: d,
157
+ ONE: c,
158
+ create: (n) => g(n, t),
159
+ isValid: (n) => {
160
+ if (typeof n != "bigint")
161
+ throw new Error("invalid field element: expected bigint, got " + typeof n);
162
+ return d <= n && n < t;
163
+ },
164
+ is0: (n) => n === d,
165
+ isOdd: (n) => (n & c) === c,
166
+ neg: (n) => g(-n, t),
167
+ eql: (n, l) => n === l,
168
+ sqr: (n) => g(n * n, t),
169
+ add: (n, l) => g(n + l, t),
170
+ sub: (n, l) => g(n - l, t),
171
+ mul: (n, l) => g(n * l, t),
172
+ pow: (n, l) => k(o, n, l),
173
+ div: (n, l) => g(n * I(l, t), t),
174
+ // Same as above, but doesn't normalize
175
+ sqrN: (n) => n * n,
176
+ addN: (n, l) => n + l,
177
+ subN: (n, l) => n - l,
178
+ mulN: (n, l) => n * l,
179
+ inv: (n) => I(n, t),
180
+ sqrt: e.sqrt || ((n) => (f || (f = z(t)), f(o, n))),
181
+ invertBatch: (n) => H(o, n),
182
+ // TODO: do we really need constant cmov?
183
+ // We don't have const-time bigints anyway, so probably will be not very useful
184
+ cmov: (n, l, h) => h ? l : n,
185
+ toBytes: (n) => r ? S(n, u) : x(n, u),
186
+ fromBytes: (n) => {
187
+ if (n.length !== u)
188
+ throw new Error("Field.fromBytes: expected " + u + " bytes, got " + n.length);
189
+ return r ? y(n) : L(n);
190
+ }
191
+ });
192
+ return Object.freeze(o);
193
+ }
194
+ function T(t) {
195
+ if (typeof t != "bigint")
196
+ throw new Error("field order must be bigint");
197
+ const i = t.toString(2).length;
198
+ return Math.ceil(i / 8);
47
199
  }
48
- function B(t) {
49
- const e = (n) => t().update(y(n)).digest(), f = t();
50
- return e.outputLen = f.outputLen, e.blockLen = f.blockLen, e.create = () => t(), e;
200
+ function O(t) {
201
+ const i = T(t);
202
+ return i + Math.ceil(i / 2);
51
203
  }
52
- function d(t = 32) {
53
- if (o && typeof o.getRandomValues == "function")
54
- return o.getRandomValues(new Uint8Array(t));
55
- if (o && typeof o.randomBytes == "function")
56
- return o.randomBytes(t);
57
- throw new Error("crypto.getRandomValues must be defined");
204
+ function G(t, i, r = !1) {
205
+ const e = t.length, s = T(i), u = O(i);
206
+ if (e < 16 || e < u || e > 1024)
207
+ throw new Error("expected " + u + "-1024 bytes of input, got " + e);
208
+ const f = r ? y(t) : L(t), o = g(f, i - c) + c;
209
+ return r ? S(o, s) : x(o, s);
58
210
  }
59
211
  export {
60
- h as Hash,
61
- c as byteSwap,
62
- a as byteSwap32,
63
- x as concatBytes,
64
- m as createView,
65
- b as isLE,
66
- d as randomBytes,
67
- w as rotr,
68
- y as toBytes,
69
- g as u32,
70
- s as utf8ToBytes,
71
- B as wrapConstructor
212
+ p as Field,
213
+ H as FpInvertBatch,
214
+ k as FpPow,
215
+ z as FpSqrt,
216
+ T as getFieldBytesLength,
217
+ O as getMinHashLength,
218
+ I as invert,
219
+ G as mapHashToField,
220
+ g as mod,
221
+ K as nLength,
222
+ Z as pow,
223
+ V as pow2,
224
+ j as tonelliShanks,
225
+ Y as validateField
72
226
  };
package/dist/index50.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index51.cjs"),s=require("./index49.cjs"),S=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=new Uint32Array(64);class g extends H.HashMD{constructor(){super(64,32,8,!1),this.A=b[0]|0,this.B=b[1]|0,this.C=b[2]|0,this.D=b[3]|0,this.E=b[4]|0,this.F=b[5]|0,this.G=b[6]|0,this.H=b[7]|0}get(){const{A:d,B:o,C:x,D:e,E:a,F:i,G:c,H:r}=this;return[d,o,x,e,a,i,c,r]}set(d,o,x,e,a,i,c,r){this.A=d|0,this.B=o|0,this.C=x|0,this.D=e|0,this.E=a|0,this.F=i|0,this.G=c|0,this.H=r|0}process(d,o){for(let t=0;t<16;t++,o+=4)f[t]=d.getUint32(o,!1);for(let t=16;t<64;t++){const A=f[t-15],n=f[t-2],C=s.rotr(A,7)^s.rotr(A,18)^A>>>3,u=s.rotr(n,17)^s.rotr(n,19)^n>>>10;f[t]=u+f[t-7]+C+f[t-16]|0}let{A:x,B:e,C:a,D:i,E:c,F:r,G:h,H:l}=this;for(let t=0;t<64;t++){const A=s.rotr(c,6)^s.rotr(c,11)^s.rotr(c,25),n=l+A+H.Chi(c,r,h)+S[t]+f[t]|0,u=(s.rotr(x,2)^s.rotr(x,13)^s.rotr(x,22))+H.Maj(x,e,a)|0;l=h,h=r,r=c,c=i+n|0,i=a,a=e,e=x,x=n+u|0}x=x+this.A|0,e=e+this.B|0,a=a+this.C|0,i=i+this.D|0,c=c+this.E|0,r=r+this.F|0,h=h+this.G|0,l=l+this.H|0,this.set(x,e,a,i,c,r,h,l)}roundClean(){f.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const y=s.wrapConstructor(()=>new g);exports.SHA256=g;exports.sha256=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index75.cjs");let i={getDocsUrl:({docsBaseUrl:s,docsPath:t="",docsSlug:e})=>t?`${s??"https://viem.sh"}${t}${e?`#${e}`:""}`:void 0,version:`viem@${l.version}`};class u extends Error{constructor(t,e={}){var o;const r=(()=>{var c;return e.cause instanceof u?e.cause.details:(c=e.cause)!=null&&c.message?e.cause.message:e.details})(),n=e.cause instanceof u&&e.cause.docsPath||e.docsPath,a=(o=i.getDocsUrl)==null?void 0:o.call(i,{...e,docsPath:n}),b=[t||"An error occurred.","",...e.metaMessages?[...e.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...i.version?[`Version: ${i.version}`]:[]].join(`
2
+ `);super(b,e.cause?{cause:e.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=e.metaMessages,this.name=e.name??this.name,this.shortMessage=t,this.version=l.version}walk(t){return d(this,t)}}function d(s,t){return t!=null&&t(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?d(s.cause,t):t?null:s}exports.BaseError=u;
package/dist/index50.js CHANGED
@@ -1,115 +1,62 @@
1
- import { HashMD as m, Chi as p, Maj as u } from "./index51.js";
2
- import { wrapConstructor as D, rotr as i } from "./index49.js";
3
- const g = /* @__PURE__ */ new Uint32Array([
4
- 1116352408,
5
- 1899447441,
6
- 3049323471,
7
- 3921009573,
8
- 961987163,
9
- 1508970993,
10
- 2453635748,
11
- 2870763221,
12
- 3624381080,
13
- 310598401,
14
- 607225278,
15
- 1426881987,
16
- 1925078388,
17
- 2162078206,
18
- 2614888103,
19
- 3248222580,
20
- 3835390401,
21
- 4022224774,
22
- 264347078,
23
- 604807628,
24
- 770255983,
25
- 1249150122,
26
- 1555081692,
27
- 1996064986,
28
- 2554220882,
29
- 2821834349,
30
- 2952996808,
31
- 3210313671,
32
- 3336571891,
33
- 3584528711,
34
- 113926993,
35
- 338241895,
36
- 666307205,
37
- 773529912,
38
- 1294757372,
39
- 1396182291,
40
- 1695183700,
41
- 1986661051,
42
- 2177026350,
43
- 2456956037,
44
- 2730485921,
45
- 2820302411,
46
- 3259730800,
47
- 3345764771,
48
- 3516065817,
49
- 3600352804,
50
- 4094571909,
51
- 275423344,
52
- 430227734,
53
- 506948616,
54
- 659060556,
55
- 883997877,
56
- 958139571,
57
- 1322822218,
58
- 1537002063,
59
- 1747873779,
60
- 1955562222,
61
- 2024104815,
62
- 2227730452,
63
- 2361852424,
64
- 2428436474,
65
- 2756734187,
66
- 3204031479,
67
- 3329325298
68
- ]), b = /* @__PURE__ */ new Uint32Array([
69
- 1779033703,
70
- 3144134277,
71
- 1013904242,
72
- 2773480762,
73
- 1359893119,
74
- 2600822924,
75
- 528734635,
76
- 1541459225
77
- ]), h = /* @__PURE__ */ new Uint32Array(64);
78
- class w extends m {
79
- constructor() {
80
- super(64, 32, 8, !1), this.A = b[0] | 0, this.B = b[1] | 0, this.C = b[2] | 0, this.D = b[3] | 0, this.E = b[4] | 0, this.F = b[5] | 0, this.G = b[6] | 0, this.H = b[7] | 0;
81
- }
82
- get() {
83
- const { A: d, B: o, C: t, D: s, E: a, F: f, G: c, H: e } = this;
84
- return [d, o, t, s, a, f, c, e];
85
- }
86
- // prettier-ignore
87
- set(d, o, t, s, a, f, c, e) {
88
- this.A = d | 0, this.B = o | 0, this.C = t | 0, this.D = s | 0, this.E = a | 0, this.F = f | 0, this.G = c | 0, this.H = e | 0;
89
- }
90
- process(d, o) {
91
- for (let x = 0; x < 16; x++, o += 4)
92
- h[x] = d.getUint32(o, !1);
93
- for (let x = 16; x < 64; x++) {
94
- const A = h[x - 15], n = h[x - 2], C = i(A, 7) ^ i(A, 18) ^ A >>> 3, H = i(n, 17) ^ i(n, 19) ^ n >>> 10;
95
- h[x] = H + h[x - 7] + C + h[x - 16] | 0;
96
- }
97
- let { A: t, B: s, C: a, D: f, E: c, F: e, G: r, H: l } = this;
98
- for (let x = 0; x < 64; x++) {
99
- const A = i(c, 6) ^ i(c, 11) ^ i(c, 25), n = l + A + p(c, e, r) + g[x] + h[x] | 0, H = (i(t, 2) ^ i(t, 13) ^ i(t, 22)) + u(t, s, a) | 0;
100
- l = r, r = e, e = c, c = f + n | 0, f = a, a = s, s = t, t = n + H | 0;
101
- }
102
- t = t + this.A | 0, s = s + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, c = c + this.E | 0, e = e + this.F | 0, r = r + this.G | 0, l = l + this.H | 0, this.set(t, s, a, f, c, e, r, l);
103
- }
104
- roundClean() {
105
- h.fill(0);
1
+ import { version as l } from "./index75.js";
2
+ let i = {
3
+ getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
4
+ version: `viem@${l}`
5
+ };
6
+ class r extends Error {
7
+ constructor(t, e = {}) {
8
+ var o;
9
+ const u = (() => {
10
+ var c;
11
+ return e.cause instanceof r ? e.cause.details : (c = e.cause) != null && c.message ? e.cause.message : e.details;
12
+ })(), a = e.cause instanceof r && e.cause.docsPath || e.docsPath, n = (o = i.getDocsUrl) == null ? void 0 : o.call(i, { ...e, docsPath: a }), b = [
13
+ t || "An error occurred.",
14
+ "",
15
+ ...e.metaMessages ? [...e.metaMessages, ""] : [],
16
+ ...n ? [`Docs: ${n}`] : [],
17
+ ...u ? [`Details: ${u}`] : [],
18
+ ...i.version ? [`Version: ${i.version}`] : []
19
+ ].join(`
20
+ `);
21
+ super(b, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
22
+ enumerable: !0,
23
+ configurable: !0,
24
+ writable: !0,
25
+ value: void 0
26
+ }), Object.defineProperty(this, "docsPath", {
27
+ enumerable: !0,
28
+ configurable: !0,
29
+ writable: !0,
30
+ value: void 0
31
+ }), Object.defineProperty(this, "metaMessages", {
32
+ enumerable: !0,
33
+ configurable: !0,
34
+ writable: !0,
35
+ value: void 0
36
+ }), Object.defineProperty(this, "shortMessage", {
37
+ enumerable: !0,
38
+ configurable: !0,
39
+ writable: !0,
40
+ value: void 0
41
+ }), Object.defineProperty(this, "version", {
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0,
45
+ value: void 0
46
+ }), Object.defineProperty(this, "name", {
47
+ enumerable: !0,
48
+ configurable: !0,
49
+ writable: !0,
50
+ value: "BaseError"
51
+ }), this.details = u, this.docsPath = a, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = l;
106
52
  }
107
- destroy() {
108
- this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
53
+ walk(t) {
54
+ return d(this, t);
109
55
  }
110
56
  }
111
- const G = /* @__PURE__ */ D(() => new w());
57
+ function d(s, t) {
58
+ return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? d(s.cause, t) : t ? null : s;
59
+ }
112
60
  export {
113
- w as SHA256,
114
- G as sha256
61
+ r as BaseError
115
62
  };
package/dist/index51.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./index48.cjs"),c=require("./index49.cjs");function a(o,t,s,i){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,s,i);const n=BigInt(32),r=BigInt(4294967295),e=Number(s>>n&r),h=Number(s&r),u=i?4:0,l=i?0:4;o.setUint32(t+u,e,i),o.setUint32(t+l,h,i)}function d(o,t,s){return o&t^~o&s}function b(o,t,s){return o&t^o&s^t&s}class w extends c.Hash{constructor(t,s,i,n){super(),this.blockLen=t,this.outputLen=s,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=c.createView(this.buffer)}update(t){p.aexists(this);const{view:s,buffer:i,blockLen:n}=this;t=c.toBytes(t);const r=t.length;for(let e=0;e<r;){const h=Math.min(n-this.pos,r-e);if(h===n){const u=c.createView(t);for(;n<=r-e;e+=n)this.process(u,e);continue}i.set(t.subarray(e,e+h),this.pos),this.pos+=h,e+=h,this.pos===n&&(this.process(s,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){p.aexists(this),p.aoutput(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:n,isLE:r}=this;let{pos:e}=this;s[e++]=128,this.buffer.subarray(e).fill(0),this.padOffset>n-e&&(this.process(i,0),e=0);for(let f=e;f<n;f++)s[f]=0;a(i,n-8,BigInt(this.length*8),r),this.process(i,0);const h=c.createView(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,g=this.get();if(l>g.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)h.setUint32(4*f,g[f],r)}digest(){const{buffer:t,outputLen:s}=this;this.digestInto(t);const i=t.slice(0,s);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:s,buffer:i,length:n,finished:r,destroyed:e,pos:h}=this;return t.length=n,t.pos=h,t.finished=r,t.destroyed=e,n%s&&t.buffer.set(i),t}}exports.Chi=d;exports.HashMD=w;exports.Maj=b;exports.setBigUint64=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}exports.LruMap=i;
package/dist/index51.js CHANGED
@@ -1,70 +1,24 @@
1
- import { aexists as g, aoutput as d } from "./index48.js";
2
- import { Hash as b, createView as p, toBytes as a } from "./index49.js";
3
- function w(o, t, s, i) {
4
- if (typeof o.setBigUint64 == "function")
5
- return o.setBigUint64(t, s, i);
6
- const n = BigInt(32), h = BigInt(4294967295), e = Number(s >> n & h), r = Number(s & h), u = i ? 4 : 0, c = i ? 0 : 4;
7
- o.setUint32(t + u, e, i), o.setUint32(t + c, r, i);
8
- }
9
- function B(o, t, s) {
10
- return o & t ^ ~o & s;
11
- }
12
- function L(o, t, s) {
13
- return o & t ^ o & s ^ t & s;
14
- }
15
- class U extends b {
16
- constructor(t, s, i, n) {
17
- super(), this.blockLen = t, this.outputLen = s, this.padOffset = i, this.isLE = n, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = p(this.buffer);
1
+ class r extends Map {
2
+ constructor(e) {
3
+ super(), Object.defineProperty(this, "maxSize", {
4
+ enumerable: !0,
5
+ configurable: !0,
6
+ writable: !0,
7
+ value: void 0
8
+ }), this.maxSize = e;
18
9
  }
19
- update(t) {
20
- g(this);
21
- const { view: s, buffer: i, blockLen: n } = this;
22
- t = a(t);
23
- const h = t.length;
24
- for (let e = 0; e < h; ) {
25
- const r = Math.min(n - this.pos, h - e);
26
- if (r === n) {
27
- const u = p(t);
28
- for (; n <= h - e; e += n)
29
- this.process(u, e);
30
- continue;
31
- }
32
- i.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === n && (this.process(s, 0), this.pos = 0);
33
- }
34
- return this.length += t.length, this.roundClean(), this;
10
+ get(e) {
11
+ const t = super.get(e);
12
+ return super.has(e) && t !== void 0 && (this.delete(e), super.set(e, t)), t;
35
13
  }
36
- digestInto(t) {
37
- g(this), d(t, this), this.finished = !0;
38
- const { buffer: s, view: i, blockLen: n, isLE: h } = this;
39
- let { pos: e } = this;
40
- s[e++] = 128, this.buffer.subarray(e).fill(0), this.padOffset > n - e && (this.process(i, 0), e = 0);
41
- for (let f = e; f < n; f++)
42
- s[f] = 0;
43
- w(i, n - 8, BigInt(this.length * 8), h), this.process(i, 0);
44
- const r = p(t), u = this.outputLen;
45
- if (u % 4)
46
- throw new Error("_sha2: outputLen should be aligned to 32bit");
47
- const c = u / 4, l = this.get();
48
- if (c > l.length)
49
- throw new Error("_sha2: outputLen bigger than state");
50
- for (let f = 0; f < c; f++)
51
- r.setUint32(4 * f, l[f], h);
52
- }
53
- digest() {
54
- const { buffer: t, outputLen: s } = this;
55
- this.digestInto(t);
56
- const i = t.slice(0, s);
57
- return this.destroy(), i;
58
- }
59
- _cloneInto(t) {
60
- t || (t = new this.constructor()), t.set(...this.get());
61
- const { blockLen: s, buffer: i, length: n, finished: h, destroyed: e, pos: r } = this;
62
- return t.length = n, t.pos = r, t.finished = h, t.destroyed = e, n % s && t.buffer.set(i), t;
14
+ set(e, t) {
15
+ if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
16
+ const s = this.keys().next().value;
17
+ s && this.delete(s);
18
+ }
19
+ return this;
63
20
  }
64
21
  }
65
22
  export {
66
- B as Chi,
67
- U as HashMD,
68
- L as Maj,
69
- w as setBigUint64
23
+ r as LruMap
70
24
  };
package/dist/index52.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;exports.crypto=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index70.cjs"),f=require("./index93.cjs"),c=require("./index71.cjs"),I=[],O=[],w=[],B=BigInt(0),a=BigInt(1),A=BigInt(2),S=BigInt(7),H=BigInt(256),T=BigInt(113);for(let i=0,t=a,s=1,n=0;i<24;i++){[s,n]=[n,(2*s+3*n)%5],I.push(2*(5*n+s)),O.push((i+1)*(i+2)/2%64);let o=B;for(let r=0;r<7;r++)t=(t<<a^(t>>S)*T)%H,t&A&&(o^=a<<(a<<BigInt(r))-a);w.push(o)}const[m,E]=f.split(w,!0),y=(i,t,s)=>s>32?f.rotlBH(i,t,s):f.rotlSH(i,t,s),b=(i,t,s)=>s>32?f.rotlBL(i,t,s):f.rotlSL(i,t,s);function L(i,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let e=0;e<10;e++)s[e]=i[e]^i[e+10]^i[e+20]^i[e+30]^i[e+40];for(let e=0;e<10;e+=2){const h=(e+8)%10,p=(e+2)%10,d=s[p],u=s[p+1],_=y(d,u,1)^s[h],g=b(d,u,1)^s[h+1];for(let k=0;k<50;k+=10)i[e+k]^=_,i[e+k+1]^=g}let o=i[2],r=i[3];for(let e=0;e<24;e++){const h=O[e],p=y(o,r,h),d=b(o,r,h),u=I[e];o=i[u],r=i[u+1],i[u]=p,i[u+1]=d}for(let e=0;e<50;e+=10){for(let h=0;h<10;h++)s[h]=i[e+h];for(let h=0;h<10;h++)i[e+h]^=~s[(h+2)%10]&s[(h+4)%10]}i[0]^=m[n],i[1]^=E[n]}s.fill(0)}class x extends c.Hash{constructor(t,s,n,o=!1,r=24){if(super(),this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=o,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,l.anumber(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=c.u32(this.state)}keccak(){c.isLE||c.byteSwap32(this.state32),L(this.state32,this.rounds),c.isLE||c.byteSwap32(this.state32),this.posOut=0,this.pos=0}update(t){l.aexists(this);const{blockLen:s,state:n}=this;t=c.toBytes(t);const o=t.length;for(let r=0;r<o;){const e=Math.min(s-this.pos,o-r);for(let h=0;h<e;h++)n[this.pos++]^=t[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:o}=this;t[n]^=s,s&128&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){l.aexists(this,!1),l.abytes(t),this.finish();const s=this.state,{blockLen:n}=this;for(let o=0,r=t.length;o<r;){this.posOut>=n&&this.keccak();const e=Math.min(n-this.posOut,r-o);t.set(s.subarray(this.posOut,this.posOut+e),o),this.posOut+=e,o+=e}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return l.anumber(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(l.aoutput(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:o,rounds:r,enableXOF:e}=this;return t||(t=new x(s,n,o,e,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=n,t.outputLen=o,t.enableXOF=e,t.destroyed=this.destroyed,t}}const F=(i,t,s)=>c.wrapConstructor(()=>new x(t,i,s)),P=F(1,136,256/8);exports.Keccak=x;exports.keccakP=L;exports.keccak_256=P;