@gardenfi/utils 2.1.0 → 2.1.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.
Files changed (207) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +3 -79
  3. package/dist/index101.cjs +1 -1
  4. package/dist/index101.js +10 -17
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +19 -11
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +8 -19
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +16 -10
  11. package/dist/index105.cjs +1 -1
  12. package/dist/index105.js +638 -33
  13. package/dist/index106.cjs +1 -1
  14. package/dist/index106.js +173 -5
  15. package/dist/index107.cjs +1 -1
  16. package/dist/index107.js +12 -10
  17. package/dist/index108.cjs +1 -1
  18. package/dist/index108.js +128 -2
  19. package/dist/index109.cjs +2 -1
  20. package/dist/index109.js +3 -21
  21. package/dist/index110.cjs +1 -1
  22. package/dist/index110.js +2 -128
  23. package/dist/index111.cjs +1 -1
  24. package/dist/index111.js +2 -7
  25. package/dist/index112.cjs +1 -1
  26. package/dist/index112.js +38 -2
  27. package/dist/index113.cjs +1 -1
  28. package/dist/index113.js +34 -33
  29. package/dist/index114.cjs +1 -1
  30. package/dist/index114.js +5 -5
  31. package/dist/index115.cjs +1 -2
  32. package/dist/index115.js +11 -3
  33. package/dist/index116.cjs +1 -1
  34. package/dist/index116.js +6 -18
  35. package/dist/index117.cjs +1 -1
  36. package/dist/index117.js +15 -638
  37. package/dist/index118.cjs +1 -1
  38. package/dist/index118.js +5 -173
  39. package/dist/index15.cjs +1 -1
  40. package/dist/index15.js +2 -2
  41. package/dist/index18.cjs +1 -1
  42. package/dist/index18.js +11 -11
  43. package/dist/index19.cjs +1 -1
  44. package/dist/index19.js +9 -9
  45. package/dist/index20.cjs +1 -1
  46. package/dist/index20.js +18 -17
  47. package/dist/index21.cjs +16 -1
  48. package/dist/index21.js +112 -30
  49. package/dist/index22.cjs +1 -16
  50. package/dist/index22.js +30 -113
  51. package/dist/index23.cjs +1 -1
  52. package/dist/index23.js +41 -17
  53. package/dist/index24.cjs +1 -1
  54. package/dist/index24.js +44 -6
  55. package/dist/index25.cjs +1 -1
  56. package/dist/index25.js +24 -44
  57. package/dist/index26.cjs +1 -1
  58. package/dist/index26.js +6 -21
  59. package/dist/index27.cjs +1 -1
  60. package/dist/index27.js +13 -8
  61. package/dist/index28.cjs +1 -1
  62. package/dist/index28.js +15 -31
  63. package/dist/index29.cjs +1 -1
  64. package/dist/index29.js +5 -26
  65. package/dist/index30.cjs +1 -2
  66. package/dist/index30.js +13 -65
  67. package/dist/index31.cjs +1 -1
  68. package/dist/index31.js +10 -51
  69. package/dist/index32.cjs +1 -1
  70. package/dist/index32.js +12 -12
  71. package/dist/index33.cjs +1 -1
  72. package/dist/index33.js +11 -24
  73. package/dist/index34.cjs +1 -1
  74. package/dist/index34.js +13 -75
  75. package/dist/index35.cjs +1 -1
  76. package/dist/index35.js +2 -2
  77. package/dist/index36.cjs +1 -1
  78. package/dist/index36.js +55 -7
  79. package/dist/index37.cjs +1 -1
  80. package/dist/index37.js +16 -32
  81. package/dist/index38.cjs +1 -1
  82. package/dist/index38.js +5 -15
  83. package/dist/index39.cjs +1 -1
  84. package/dist/index39.js +9 -2
  85. package/dist/index40.cjs +1 -1
  86. package/dist/index40.js +171 -8
  87. package/dist/index41.cjs +1 -1
  88. package/dist/index41.js +102 -19
  89. package/dist/index42.cjs +1 -1
  90. package/dist/index42.js +21 -41
  91. package/dist/index43.cjs +1 -1
  92. package/dist/index43.js +17 -25
  93. package/dist/index44.cjs +1 -1
  94. package/dist/index44.js +7 -6
  95. package/dist/index45.cjs +1 -1
  96. package/dist/index45.js +20 -12
  97. package/dist/index46.cjs +1 -1
  98. package/dist/index46.js +8 -15
  99. package/dist/index47.cjs +1 -1
  100. package/dist/index47.js +31 -5
  101. package/dist/index48.cjs +1 -1
  102. package/dist/index48.js +26 -13
  103. package/dist/index49.cjs +2 -1
  104. package/dist/index49.js +65 -10
  105. package/dist/index50.cjs +1 -1
  106. package/dist/index50.js +51 -12
  107. package/dist/index51.cjs +1 -1
  108. package/dist/index51.js +12 -11
  109. package/dist/index52.cjs +1 -1
  110. package/dist/index52.js +24 -13
  111. package/dist/index53.cjs +1 -1
  112. package/dist/index53.js +75 -55
  113. package/dist/index54.cjs +1 -1
  114. package/dist/index54.js +7 -16
  115. package/dist/index55.cjs +1 -1
  116. package/dist/index55.js +32 -5
  117. package/dist/index56.cjs +1 -1
  118. package/dist/index56.js +15 -8
  119. package/dist/index57.cjs +1 -1
  120. package/dist/index57.js +2 -172
  121. package/dist/index58.cjs +1 -1
  122. package/dist/index58.js +7 -102
  123. package/dist/index59.cjs +1 -1
  124. package/dist/index59.js +20 -21
  125. package/dist/index60.cjs +1 -1
  126. package/dist/index60.js +38 -10
  127. package/dist/index61.cjs +1 -1
  128. package/dist/index61.js +32 -32
  129. package/dist/index62.cjs +1 -1
  130. package/dist/index62.js +69 -8
  131. package/dist/index63.cjs +1 -2
  132. package/dist/index63.js +110 -57
  133. package/dist/index64.cjs +1 -1
  134. package/dist/index64.js +68 -2
  135. package/dist/index65.cjs +1 -1
  136. package/dist/index65.js +2 -7
  137. package/dist/index66.cjs +1 -1
  138. package/dist/index66.js +16 -6
  139. package/dist/index67.cjs +1 -1
  140. package/dist/index67.js +223 -4
  141. package/dist/index68.cjs +1 -1
  142. package/dist/index68.js +230 -10
  143. package/dist/index69.cjs +1 -1
  144. package/dist/index69.js +12 -3
  145. package/dist/index70.cjs +1 -5
  146. package/dist/index70.js +29 -51
  147. package/dist/index71.cjs +2 -2
  148. package/dist/index71.js +57 -32
  149. package/dist/index72.cjs +1 -1
  150. package/dist/index72.js +21 -5
  151. package/dist/index73.cjs +1 -1
  152. package/dist/index73.js +18 -21
  153. package/dist/index74.cjs +1 -1
  154. package/dist/index74.js +42 -8
  155. package/dist/index75.cjs +1 -1
  156. package/dist/index75.js +8 -10
  157. package/dist/index76.cjs +1 -1
  158. package/dist/index76.js +104 -11
  159. package/dist/index77.cjs +1 -1
  160. package/dist/index77.js +3 -6
  161. package/dist/index78.cjs +1 -1
  162. package/dist/index78.js +17 -13
  163. package/dist/index79.cjs +1 -1
  164. package/dist/index79.js +8 -32
  165. package/dist/index80.cjs +1 -1
  166. package/dist/index80.js +10 -14
  167. package/dist/index81.cjs +1 -1
  168. package/dist/index81.js +11 -64
  169. package/dist/index82.cjs +1 -1
  170. package/dist/index82.js +12 -26
  171. package/dist/index83.cjs +1 -1
  172. package/dist/index83.js +7 -3
  173. package/dist/index84.cjs +1 -1
  174. package/dist/index84.js +78 -3
  175. package/dist/index85.cjs +1 -1
  176. package/dist/index85.js +14 -8
  177. package/dist/index86.cjs +1 -1
  178. package/dist/index86.js +16 -189
  179. package/dist/index87.cjs +1 -1
  180. package/dist/index87.js +191 -18
  181. package/dist/index88.cjs +1 -1
  182. package/dist/index88.js +63 -39
  183. package/dist/index89.cjs +1 -1
  184. package/dist/index89.js +4 -34
  185. package/dist/index9.cjs +1 -1
  186. package/dist/index9.js +51 -43
  187. package/dist/index90.cjs +1 -1
  188. package/dist/index90.js +2 -70
  189. package/dist/index91.cjs +1 -1
  190. package/dist/index91.js +5 -111
  191. package/dist/index92.cjs +1 -1
  192. package/dist/index92.js +11 -67
  193. package/dist/index93.cjs +5 -1
  194. package/dist/index93.js +57 -2
  195. package/dist/index94.cjs +2 -1
  196. package/dist/index94.js +33 -15
  197. package/dist/index95.cjs +1 -1
  198. package/dist/index95.js +5 -223
  199. package/dist/index96.cjs +1 -1
  200. package/dist/index96.js +3 -231
  201. package/dist/index97.cjs +1 -1
  202. package/dist/index97.js +6 -42
  203. package/dist/index98.cjs +1 -1
  204. package/dist/index98.js +30 -102
  205. package/dist/index99.cjs +1 -1
  206. package/dist/index99.js +26 -16
  207. package/package.json +1 -1
package/dist/index95.js CHANGED
@@ -1,226 +1,8 @@
1
- import { numberToBytesLE as S, numberToBytesBE as x, bitMask as _, bytesToNumberLE as y, bytesToNumberBE as L, validateObject as M } from "./index96.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;
7
- }
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;
19
- }
20
- function V(t, i, r) {
21
- let e = t;
22
- for (; i-- > d; )
23
- e *= e, e %= r;
24
- return e;
25
- }
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);
39
- }
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
- };
73
- }
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
- };
83
- }
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
- };
92
- }
93
- return j(t);
94
- }
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);
199
- }
200
- function O(t) {
201
- const i = T(t);
202
- return i + Math.ceil(i / 2);
203
- }
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);
1
+ import { gweiUnits as i } from "./index114.js";
2
+ import { formatUnits as o } from "./index115.js";
3
+ function f(r, t = "wei") {
4
+ return o(r, i[t]);
210
5
  }
211
6
  export {
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
7
+ f as formatGwei
226
8
  };
package/dist/index96.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const y=BigInt(0),d=BigInt(1),N=BigInt(2);function b(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function m(t){if(!b(t))throw new Error("Uint8Array expected")}function _(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const k=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function B(t){m(t);let e="";for(let r=0;r<t.length;r++)e+=k[t[r]];return e}function x(t){const e=t.toString(16);return e.length&1?"0"+e:e}function E(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?y:BigInt("0x"+t)}const f={_0:48,_9:57,A:65,F:70,a:97,f:102};function T(t){if(t>=f._0&&t<=f._9)return t-f._0;if(t>=f.A&&t<=f.F)return t-(f.A-10);if(t>=f.a&&t<=f.f)return t-(f.a-10)}function p(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){const a=T(t.charCodeAt(i)),s=T(t.charCodeAt(i+1));if(a===void 0||s===void 0){const c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=a*16+s}return n}function H(t){return E(B(t))}function O(t){return m(t),E(B(Uint8Array.from(t).reverse()))}function U(t,e){return p(t.toString(16).padStart(e*2,"0"))}function F(t,e){return U(t,e).reverse()}function V(t){return p(x(t))}function M(t,e,r){let n;if(typeof e=="string")try{n=p(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(b(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function I(...t){let e=0;for(let n=0;n<t.length;n++){const o=t[n];m(o),e+=o.length}const r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){const i=t[n];r.set(i,o),o+=i.length}return r}function R(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function j(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const w=t=>typeof t=="bigint"&&y<=t;function S(t,e,r){return w(t)&&w(e)&&w(r)&&e<=t&&t<r}function z(t,e,r,n){if(!S(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function C(t){let e;for(e=0;t>y;t>>=d,e+=1);return e}function D(t,e){return t>>BigInt(e)&d}function G(t,e,r){return t|(r?d:y)<<BigInt(e)}const L=t=>(N<<BigInt(t-1))-d,h=t=>new Uint8Array(t),A=t=>Uint8Array.from(t);function P(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=h(t),o=h(t),i=0;const a=()=>{n.fill(1),o.fill(0),i=0},s=(...u)=>r(o,n,...u),c=(u=h())=>{o=s(A([0]),u),n=s(),u.length!==0&&(o=s(A([1]),u),n=s())},v=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const l=[];for(;u<e;){n=s();const g=n.slice();l.push(g),u+=n.length}return I(...l)};return(u,l)=>{a(),c(u);let g;for(;!(g=l(v()));)c();return a(),g}}const q={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||b(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function W(t,e,r={}){const n=(o,i,a)=>{const s=q[i];if(typeof s!="function")throw new Error("invalid validator function");const c=t[o];if(!(a&&c===void 0)&&!s(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(const[o,i]of Object.entries(e))n(o,i,!1);for(const[o,i]of Object.entries(r))n(o,i,!0);return t}const J=()=>{throw new Error("not implemented")};function K(t){const e=new WeakMap;return(r,...n)=>{const o=e.get(r);if(o!==void 0)return o;const i=t(r,...n);return e.set(r,i),i}}exports.aInRange=z;exports.abool=_;exports.abytes=m;exports.bitGet=D;exports.bitLen=C;exports.bitMask=L;exports.bitSet=G;exports.bytesToHex=B;exports.bytesToNumberBE=H;exports.bytesToNumberLE=O;exports.concatBytes=I;exports.createHmacDrbg=P;exports.ensureBytes=M;exports.equalBytes=R;exports.hexToBytes=p;exports.hexToNumber=E;exports.inRange=S;exports.isBytes=b;exports.memoized=K;exports.notImplemented=J;exports.numberToBytesBE=U;exports.numberToBytesLE=F;exports.numberToHexUnpadded=x;exports.numberToVarBytesBE=V;exports.utf8ToBytes=j;exports.validateObject=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function i(e){return new Promise(t=>setTimeout(t,e))}exports.wait=i;
package/dist/index96.js CHANGED
@@ -1,234 +1,6 @@
1
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
- const d = /* @__PURE__ */ BigInt(0), y = /* @__PURE__ */ BigInt(1), I = /* @__PURE__ */ BigInt(2);
3
- function h(t) {
4
- return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
5
- }
6
- function b(t) {
7
- if (!h(t))
8
- throw new Error("Uint8Array expected");
9
- }
10
- function O(t, n) {
11
- if (typeof n != "boolean")
12
- throw new Error(t + " boolean expected, got " + n);
13
- }
14
- const T = /* @__PURE__ */ Array.from({ length: 256 }, (t, n) => n.toString(16).padStart(2, "0"));
15
- function B(t) {
16
- b(t);
17
- let n = "";
18
- for (let r = 0; r < t.length; r++)
19
- n += T[t[r]];
20
- return n;
21
- }
22
- function S(t) {
23
- const n = t.toString(16);
24
- return n.length & 1 ? "0" + n : n;
25
- }
26
- function U(t) {
27
- if (typeof t != "string")
28
- throw new Error("hex string expected, got " + typeof t);
29
- return t === "" ? d : BigInt("0x" + t);
30
- }
31
- const s = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
32
- function E(t) {
33
- if (t >= s._0 && t <= s._9)
34
- return t - s._0;
35
- if (t >= s.A && t <= s.F)
36
- return t - (s.A - 10);
37
- if (t >= s.a && t <= s.f)
38
- return t - (s.a - 10);
39
- }
40
- function m(t) {
41
- if (typeof t != "string")
42
- throw new Error("hex string expected, got " + typeof t);
43
- const n = t.length, r = n / 2;
44
- if (n % 2)
45
- throw new Error("hex string expected, got unpadded hex of length " + n);
46
- const e = new Uint8Array(r);
47
- for (let o = 0, i = 0; o < r; o++, i += 2) {
48
- const a = E(t.charCodeAt(i)), f = E(t.charCodeAt(i + 1));
49
- if (a === void 0 || f === void 0) {
50
- const c = t[i] + t[i + 1];
51
- throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + i);
52
- }
53
- e[o] = a * 16 + f;
54
- }
55
- return e;
56
- }
57
- function V(t) {
58
- return U(B(t));
59
- }
60
- function H(t) {
61
- return b(t), U(B(Uint8Array.from(t).reverse()));
62
- }
63
- function v(t, n) {
64
- return m(t.toString(16).padStart(n * 2, "0"));
65
- }
66
- function C(t, n) {
67
- return v(t, n).reverse();
68
- }
69
- function M(t) {
70
- return m(S(t));
71
- }
72
- function R(t, n, r) {
73
- let e;
74
- if (typeof n == "string")
75
- try {
76
- e = m(n);
77
- } catch (i) {
78
- throw new Error(t + " must be hex string or Uint8Array, cause: " + i);
79
- }
80
- else if (h(n))
81
- e = Uint8Array.from(n);
82
- else
83
- throw new Error(t + " must be hex string or Uint8Array");
84
- const o = e.length;
85
- if (typeof r == "number" && o !== r)
86
- throw new Error(t + " of length " + r + " expected, got " + o);
87
- return e;
88
- }
89
- function _(...t) {
90
- let n = 0;
91
- for (let e = 0; e < t.length; e++) {
92
- const o = t[e];
93
- b(o), n += o.length;
94
- }
95
- const r = new Uint8Array(n);
96
- for (let e = 0, o = 0; e < t.length; e++) {
97
- const i = t[e];
98
- r.set(i, o), o += i.length;
99
- }
100
- return r;
101
- }
102
- function j(t, n) {
103
- if (t.length !== n.length)
104
- return !1;
105
- let r = 0;
106
- for (let e = 0; e < t.length; e++)
107
- r |= t[e] ^ n[e];
108
- return r === 0;
109
- }
110
- function z(t) {
111
- if (typeof t != "string")
112
- throw new Error("string expected");
113
- return new Uint8Array(new TextEncoder().encode(t));
114
- }
115
- const w = (t) => typeof t == "bigint" && d <= t;
116
- function N(t, n, r) {
117
- return w(t) && w(n) && w(r) && n <= t && t < r;
118
- }
119
- function D(t, n, r, e) {
120
- if (!N(n, r, e))
121
- throw new Error("expected valid " + t + ": " + r + " <= n < " + e + ", got " + n);
122
- }
123
- function G(t) {
124
- let n;
125
- for (n = 0; t > d; t >>= y, n += 1)
126
- ;
127
- return n;
128
- }
129
- function P(t, n) {
130
- return t >> BigInt(n) & y;
131
- }
132
- function W(t, n, r) {
133
- return t | (r ? y : d) << BigInt(n);
134
- }
135
- const q = (t) => (I << BigInt(t - 1)) - y, p = (t) => new Uint8Array(t), A = (t) => Uint8Array.from(t);
136
- function J(t, n, r) {
137
- if (typeof t != "number" || t < 2)
138
- throw new Error("hashLen must be a number");
139
- if (typeof n != "number" || n < 2)
140
- throw new Error("qByteLen must be a number");
141
- if (typeof r != "function")
142
- throw new Error("hmacFn must be a function");
143
- let e = p(t), o = p(t), i = 0;
144
- const a = () => {
145
- e.fill(1), o.fill(0), i = 0;
146
- }, f = (...u) => r(o, e, ...u), c = (u = p()) => {
147
- o = f(A([0]), u), e = f(), u.length !== 0 && (o = f(A([1]), u), e = f());
148
- }, x = () => {
149
- if (i++ >= 1e3)
150
- throw new Error("drbg: tried 1000 values");
151
- let u = 0;
152
- const l = [];
153
- for (; u < n; ) {
154
- e = f();
155
- const g = e.slice();
156
- l.push(g), u += e.length;
157
- }
158
- return _(...l);
159
- };
160
- return (u, l) => {
161
- a(), c(u);
162
- let g;
163
- for (; !(g = l(x())); )
164
- c();
165
- return a(), g;
166
- };
167
- }
168
- const k = {
169
- bigint: (t) => typeof t == "bigint",
170
- function: (t) => typeof t == "function",
171
- boolean: (t) => typeof t == "boolean",
172
- string: (t) => typeof t == "string",
173
- stringOrUint8Array: (t) => typeof t == "string" || h(t),
174
- isSafeInteger: (t) => Number.isSafeInteger(t),
175
- array: (t) => Array.isArray(t),
176
- field: (t, n) => n.Fp.isValid(t),
177
- hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen)
178
- };
179
- function K(t, n, r = {}) {
180
- const e = (o, i, a) => {
181
- const f = k[i];
182
- if (typeof f != "function")
183
- throw new Error("invalid validator function");
184
- const c = t[o];
185
- if (!(a && c === void 0) && !f(c, t))
186
- throw new Error("param " + String(o) + " is invalid. Expected " + i + ", got " + c);
187
- };
188
- for (const [o, i] of Object.entries(n))
189
- e(o, i, !1);
190
- for (const [o, i] of Object.entries(r))
191
- e(o, i, !0);
192
- return t;
193
- }
194
- const Q = () => {
195
- throw new Error("not implemented");
196
- };
197
- function X(t) {
198
- const n = /* @__PURE__ */ new WeakMap();
199
- return (r, ...e) => {
200
- const o = n.get(r);
201
- if (o !== void 0)
202
- return o;
203
- const i = t(r, ...e);
204
- return n.set(r, i), i;
205
- };
1
+ async function n(e) {
2
+ return new Promise((t) => setTimeout(t, e));
206
3
  }
207
4
  export {
208
- D as aInRange,
209
- O as abool,
210
- b as abytes,
211
- P as bitGet,
212
- G as bitLen,
213
- q as bitMask,
214
- W as bitSet,
215
- B as bytesToHex,
216
- V as bytesToNumberBE,
217
- H as bytesToNumberLE,
218
- _ as concatBytes,
219
- J as createHmacDrbg,
220
- R as ensureBytes,
221
- j as equalBytes,
222
- m as hexToBytes,
223
- U as hexToNumber,
224
- N as inRange,
225
- h as isBytes,
226
- X as memoized,
227
- Q as notImplemented,
228
- v as numberToBytesBE,
229
- C as numberToBytesLE,
230
- S as numberToHexUnpadded,
231
- M as numberToVarBytesBE,
232
- z as utf8ToBytes,
233
- K as validateObject
5
+ n as wait
234
6
  };
package/dist/index97.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index63.cjs"),u=require("./index110.cjs"),f=require("./index53.cjs"),g=require("./index25.cjs");function c(n,e="hex"){const i=o(n),s=u.createCursor(new Uint8Array(i.length));return i.encode(s),e==="hex"?g.bytesToHex(s.bytes):s.bytes}function o(n){return Array.isArray(n)?p(n.map(e=>o(e))):y(n)}function p(n){const e=n.reduce((t,h)=>t+h.length,0),i=l(e);return{length:e<=55?1+e:1+i+e,encode(t){e<=55?t.pushByte(192+e):(t.pushByte(247+i),i===1?t.pushUint8(e):i===2?t.pushUint16(e):i===3?t.pushUint24(e):t.pushUint32(e));for(const{encode:h}of n)h(t)}}}function y(n){const e=typeof n=="string"?f.hexToBytes(n):n,i=l(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+i+e.length,encode(t){e.length===1&&e[0]<128?t.pushBytes(e):e.length<=55?(t.pushByte(128+e.length),t.pushBytes(e)):(t.pushByte(183+i),i===1?t.pushUint8(e.length):i===2?t.pushUint16(e.length):i===3?t.pushUint24(e.length):t.pushUint32(e.length),t.pushBytes(e))}}}function l(n){if(n<2**8)return 1;if(n<2**16)return 2;if(n<2**24)return 3;if(n<2**32)return 4;throw new r.BaseError("Length is too large.")}exports.toRlp=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index24.cjs"),r=require("./index116.cjs");function c(t){const{commitment:o,version:s=1}=t,n=t.to??(typeof o=="string"?"hex":"bytes"),e=r.sha256(o);return e.set([s],0),n==="bytes"?e:i.bytesToHex(e)}exports.commitmentToVersionedHash=c;
package/dist/index97.js CHANGED
@@ -1,45 +1,9 @@
1
- import { BaseError as l } from "./index63.js";
2
- import { createCursor as r } from "./index110.js";
3
- import { hexToBytes as g } from "./index53.js";
4
- import { bytesToHex as u } from "./index25.js";
5
- function m(n, e = "hex") {
6
- const i = s(n), h = r(new Uint8Array(i.length));
7
- return i.encode(h), e === "hex" ? u(h.bytes) : h.bytes;
8
- }
9
- function s(n) {
10
- return Array.isArray(n) ? p(n.map((e) => s(e))) : y(n);
11
- }
12
- function p(n) {
13
- const e = n.reduce((t, f) => t + f.length, 0), i = o(e);
14
- return {
15
- length: e <= 55 ? 1 + e : 1 + i + e,
16
- encode(t) {
17
- e <= 55 ? t.pushByte(192 + e) : (t.pushByte(247 + i), i === 1 ? t.pushUint8(e) : i === 2 ? t.pushUint16(e) : i === 3 ? t.pushUint24(e) : t.pushUint32(e));
18
- for (const { encode: f } of n)
19
- f(t);
20
- }
21
- };
22
- }
23
- function y(n) {
24
- const e = typeof n == "string" ? g(n) : n, i = o(e.length);
25
- return {
26
- length: e.length === 1 && e[0] < 128 ? 1 : e.length <= 55 ? 1 + e.length : 1 + i + e.length,
27
- encode(t) {
28
- e.length === 1 && e[0] < 128 ? t.pushBytes(e) : e.length <= 55 ? (t.pushByte(128 + e.length), t.pushBytes(e)) : (t.pushByte(183 + i), i === 1 ? t.pushUint8(e.length) : i === 2 ? t.pushUint16(e.length) : i === 3 ? t.pushUint24(e.length) : t.pushUint32(e.length), t.pushBytes(e));
29
- }
30
- };
31
- }
32
- function o(n) {
33
- if (n < 2 ** 8)
34
- return 1;
35
- if (n < 2 ** 16)
36
- return 2;
37
- if (n < 2 ** 24)
38
- return 3;
39
- if (n < 2 ** 32)
40
- return 4;
41
- throw new l("Length is too large.");
1
+ import { bytesToHex as i } from "./index24.js";
2
+ import { sha256 as m } from "./index116.js";
3
+ function f(t) {
4
+ const { commitment: e, version: s = 1 } = t, n = t.to ?? (typeof e == "string" ? "hex" : "bytes"), o = m(e);
5
+ return o.set([s], 0), n === "bytes" ? o : i(o);
42
6
  }
43
7
  export {
44
- m as toRlp
8
+ f as commitmentToVersionedHash
45
9
  };
package/dist/index98.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index89.cjs"),f=require("./index116.cjs"),c=require("./index90.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index118.cjs"),y=require("./index112.cjs"),u=require("./index108.cjs"),B=require("./index89.cjs"),h=require("./index36.cjs"),d=require("./index24.cjs");function f(t){const a=t.to??(typeof t.data=="string"?"hex":"bytes"),n=typeof t.data=="string"?h.hexToBytes(t.data):t.data,s=B.size(n);if(!s)throw new y.EmptyBlobError;if(s>o.maxBytesPerTransaction)throw new y.BlobSizeTooLargeError({maxSize:o.maxBytesPerTransaction,size:s});const r=[];let b=!0,i=0;for(;b;){const e=u.createCursor(new Uint8Array(o.bytesPerBlob));let l=0;for(;l<o.fieldElementsPerBlob;){const c=n.slice(i,i+(o.bytesPerFieldElement-1));if(e.pushByte(0),e.pushBytes(c),c.length<31){e.pushByte(128),b=!1;break}l++,i+=31}r.push(e)}return a==="bytes"?r.map(e=>e.bytes):r.map(e=>d.bytesToHex(e.bytes))}exports.toBlobs=f;