@coinbase/cdp-hooks 0.0.95 → 0.0.97

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 (293) hide show
  1. package/dist/esm/index100.js +35 -42
  2. package/dist/esm/index101.js +9 -88
  3. package/dist/esm/index102.js +31 -40
  4. package/dist/esm/index103.js +35 -7
  5. package/dist/esm/index104.js +7 -4
  6. package/dist/esm/index105.js +29 -16
  7. package/dist/esm/index106.js +46 -8
  8. package/dist/esm/index107.js +69 -13
  9. package/dist/esm/index108.js +40 -7
  10. package/dist/esm/index109.js +75 -9
  11. package/dist/esm/index110.js +30 -15
  12. package/dist/esm/index111.js +6 -46
  13. package/dist/esm/index112.js +16 -13
  14. package/dist/esm/index113.js +8 -16
  15. package/dist/esm/index114.js +13 -13
  16. package/dist/esm/index115.js +6 -5
  17. package/dist/esm/index116.js +9 -35
  18. package/dist/esm/index117.js +15 -8
  19. package/dist/esm/index118.js +11 -7
  20. package/dist/esm/index119.js +45 -24
  21. package/dist/esm/index120.js +13 -10
  22. package/dist/esm/index121.js +15 -13
  23. package/dist/esm/index122.js +13 -11
  24. package/dist/esm/index123.js +6 -116
  25. package/dist/esm/index124.js +34 -32
  26. package/dist/esm/index125.js +9 -79
  27. package/dist/esm/index126.js +8 -177
  28. package/dist/esm/index127.js +27 -43
  29. package/dist/esm/index128.js +10 -6
  30. package/dist/esm/index129.js +13 -12
  31. package/dist/esm/index130.js +11 -13
  32. package/dist/esm/index131.js +118 -97
  33. package/dist/esm/index132.js +32 -71
  34. package/dist/esm/index133.js +77 -84
  35. package/dist/esm/index134.js +174 -145
  36. package/dist/esm/index135.js +43 -135
  37. package/dist/esm/index136.js +6 -68
  38. package/dist/esm/index137.js +152 -21
  39. package/dist/esm/index138.js +14 -105
  40. package/dist/esm/index139.js +14 -6
  41. package/dist/esm/index140.js +98 -130
  42. package/dist/esm/index141.js +72 -275
  43. package/dist/esm/index142.js +88 -3
  44. package/dist/esm/index143.js +149 -4
  45. package/dist/esm/index144.js +137 -9
  46. package/dist/esm/index145.js +69 -2
  47. package/dist/esm/index146.js +24 -2
  48. package/dist/esm/index147.js +159 -3
  49. package/dist/esm/index148.js +6 -326
  50. package/dist/esm/index149.js +11 -13
  51. package/dist/esm/index150.js +19 -4
  52. package/dist/esm/index151.js +134 -54
  53. package/dist/esm/index152.js +79 -2
  54. package/dist/esm/index153.js +8 -6
  55. package/dist/esm/index154.js +26 -212
  56. package/dist/esm/index155.js +89 -31
  57. package/dist/esm/index156.js +351 -22
  58. package/dist/esm/index157.js +3 -6
  59. package/dist/esm/index158.js +5 -74
  60. package/dist/esm/index159.js +2 -6
  61. package/dist/esm/index160.js +3 -6
  62. package/dist/esm/index161.js +9 -36
  63. package/dist/esm/index162.js +303 -52
  64. package/dist/esm/index163.js +14 -3
  65. package/dist/esm/index164.js +4 -23
  66. package/dist/esm/index165.js +40 -436
  67. package/dist/esm/index166.js +8 -26
  68. package/dist/esm/index167.js +2 -27
  69. package/dist/esm/index168.js +6 -32
  70. package/dist/esm/index169.js +28 -32
  71. package/dist/esm/index170.js +196 -175
  72. package/dist/esm/index171.js +32 -9
  73. package/dist/esm/index172.js +22 -2
  74. package/dist/esm/index173.js +5 -12
  75. package/dist/esm/index174.js +68 -13
  76. package/dist/esm/index175.js +5 -27
  77. package/dist/esm/index176.js +5 -8
  78. package/dist/esm/index177.js +31 -51
  79. package/dist/esm/index178.js +116 -42
  80. package/dist/esm/index179.js +3 -9
  81. package/dist/esm/index180.js +18 -7
  82. package/dist/esm/index181.js +25 -15
  83. package/dist/esm/index182.js +31 -16
  84. package/dist/esm/index183.js +34 -24
  85. package/dist/esm/index184.js +23 -16
  86. package/dist/esm/index185.js +8 -54
  87. package/dist/esm/index186.js +193 -11
  88. package/dist/esm/index187.js +2 -161
  89. package/dist/esm/index188.js +467 -21
  90. package/dist/esm/index189.js +26 -126
  91. package/dist/esm/index190.js +153 -31
  92. package/dist/esm/index191.js +21 -6
  93. package/dist/esm/index192.js +127 -27
  94. package/dist/esm/index193.js +31 -184
  95. package/dist/esm/index194.js +7 -4
  96. package/dist/esm/index195.js +26 -63
  97. package/dist/esm/index196.js +56 -3
  98. package/dist/esm/index197.js +42 -17
  99. package/dist/esm/index198.js +188 -13
  100. package/dist/esm/index199.js +4 -24
  101. package/dist/esm/index2.js +2 -2
  102. package/dist/esm/index200.js +73 -11
  103. package/dist/esm/index201.js +17 -31
  104. package/dist/esm/index202.js +3 -3
  105. package/dist/esm/index203.js +15 -17
  106. package/dist/esm/index204.js +22 -26
  107. package/dist/esm/index205.js +11 -35
  108. package/dist/esm/index206.js +18 -7
  109. package/dist/esm/index207.js +32 -23
  110. package/dist/esm/index208.js +3 -29
  111. package/dist/esm/index209.js +18 -64
  112. package/dist/esm/index210.js +27 -9
  113. package/dist/esm/index211.js +34 -32
  114. package/dist/esm/index212.js +8 -27
  115. package/dist/esm/index213.js +7 -24
  116. package/dist/esm/index214.js +25 -3
  117. package/dist/esm/index215.js +28 -14
  118. package/dist/esm/index216.js +3 -103
  119. package/dist/esm/index217.js +75 -60
  120. package/dist/esm/index218.js +9 -5
  121. package/dist/esm/index219.js +12 -6
  122. package/dist/esm/index220.js +20 -26
  123. package/dist/esm/index221.js +8 -38
  124. package/dist/esm/index222.js +10 -13
  125. package/dist/esm/index223.js +11 -42
  126. package/dist/esm/index224.js +6 -5
  127. package/dist/esm/index225.js +6 -11
  128. package/dist/esm/index226.js +13 -19
  129. package/dist/esm/index227.js +30 -76
  130. package/dist/esm/index228.js +5 -2
  131. package/dist/esm/index229.js +2 -2
  132. package/dist/esm/index230.js +8 -8
  133. package/dist/esm/index231.js +3 -3
  134. package/dist/esm/index232.js +5 -5
  135. package/dist/esm/index233.js +17 -8
  136. package/dist/esm/index234.js +19 -6
  137. package/dist/esm/index235.js +42 -6
  138. package/dist/esm/index236.js +42 -11
  139. package/dist/esm/index237.js +8 -10
  140. package/dist/esm/index238.js +7 -13
  141. package/dist/esm/index239.js +15 -31
  142. package/dist/esm/index240.js +23 -5
  143. package/dist/esm/index241.js +22 -6
  144. package/dist/esm/index242.js +16 -19
  145. package/dist/esm/index243.js +52 -29
  146. package/dist/esm/index244.js +27 -20
  147. package/dist/esm/index245.js +24 -3
  148. package/dist/esm/index246.js +104 -17
  149. package/dist/esm/index247.js +3 -11
  150. package/dist/esm/index248.js +5 -21
  151. package/dist/esm/index249.js +31 -22
  152. package/dist/esm/index250.js +20 -5
  153. package/dist/esm/index251.js +3 -5
  154. package/dist/esm/index252.js +17 -8
  155. package/dist/esm/index253.js +5 -104
  156. package/dist/esm/index254.js +9 -3
  157. package/dist/esm/index255.js +102 -17
  158. package/dist/esm/index256.js +60 -167
  159. package/dist/esm/index257.js +5 -17
  160. package/dist/esm/index258.js +7 -10
  161. package/dist/esm/index259.js +27 -38
  162. package/dist/esm/index260.js +34 -2
  163. package/dist/esm/index261.js +13 -69
  164. package/dist/esm/index262.js +16 -34
  165. package/dist/esm/index263.js +77 -13
  166. package/dist/esm/index264.js +2 -41
  167. package/dist/esm/index265.js +15 -2
  168. package/dist/esm/index266.js +18 -4
  169. package/dist/esm/index267.js +170 -9
  170. package/dist/esm/index268.js +16 -18
  171. package/dist/esm/index269.js +10 -7
  172. package/dist/esm/index270.js +10 -12
  173. package/dist/esm/index271.js +2 -67
  174. package/dist/esm/index272.js +39 -64
  175. package/dist/esm/index273.js +2 -186
  176. package/dist/esm/index274.js +4 -22
  177. package/dist/esm/index275.js +9 -41
  178. package/dist/esm/index276.js +17 -74
  179. package/dist/esm/index277.js +7 -40
  180. package/dist/esm/index278.js +10 -15
  181. package/dist/esm/index279.js +72 -13
  182. package/dist/esm/index280.js +65 -7
  183. package/dist/esm/index281.js +187 -6
  184. package/dist/esm/index282.js +21 -35
  185. package/dist/esm/index283.js +42 -15
  186. package/dist/esm/index284.js +25 -8
  187. package/dist/esm/index285.js +91 -13
  188. package/dist/esm/index286.js +40 -9
  189. package/dist/esm/index287.js +15 -15
  190. package/dist/esm/index288.js +12 -21
  191. package/dist/esm/index289.js +7 -30
  192. package/dist/esm/index290.js +7 -2
  193. package/dist/esm/index291.js +36 -13
  194. package/dist/esm/index292.js +15 -12
  195. package/dist/esm/index293.js +8 -47
  196. package/dist/esm/index294.js +8 -9
  197. package/dist/esm/index295.js +16 -13
  198. package/dist/esm/index296.js +21 -13
  199. package/dist/esm/index297.js +28 -6
  200. package/dist/esm/index298.js +2 -16
  201. package/dist/esm/index299.js +12 -23
  202. package/dist/esm/index3.js +1 -1
  203. package/dist/esm/index300.js +12 -11
  204. package/dist/esm/index301.js +45 -22
  205. package/dist/esm/index302.js +9 -51
  206. package/dist/esm/index303.js +13 -17
  207. package/dist/esm/index304.js +13 -14
  208. package/dist/esm/index305.js +14 -11
  209. package/dist/esm/index306.js +8 -103
  210. package/dist/esm/index307.js +15 -5
  211. package/dist/esm/index308.js +23 -222
  212. package/dist/esm/index309.js +24 -6
  213. package/dist/esm/index310.js +32 -7
  214. package/dist/esm/index311.js +9 -26
  215. package/dist/esm/index312.js +49 -17
  216. package/dist/esm/index313.js +34 -142
  217. package/dist/esm/index314.js +18 -13
  218. package/dist/esm/index315.js +15 -36
  219. package/dist/esm/index316.js +11 -41
  220. package/dist/esm/index317.js +13 -2
  221. package/dist/esm/index318.js +19 -68
  222. package/dist/esm/index319.js +107 -3
  223. package/dist/esm/index320.js +100 -133
  224. package/dist/esm/index321.js +6 -155
  225. package/dist/esm/index322.js +7 -10
  226. package/dist/esm/index323.js +26 -16
  227. package/dist/esm/index324.js +12 -110
  228. package/dist/esm/index325.js +206 -127
  229. package/dist/esm/index326.js +12 -78
  230. package/dist/esm/index327.js +36 -2
  231. package/dist/esm/index328.js +41 -697
  232. package/dist/esm/index329.js +3 -138
  233. package/dist/esm/index330.js +68 -42
  234. package/dist/esm/index331.js +3 -200
  235. package/dist/esm/index332.js +136 -3
  236. package/dist/esm/index333.js +155 -46
  237. package/dist/esm/index334.js +9 -4
  238. package/dist/esm/index335.js +16 -40
  239. package/dist/esm/index336.js +133 -7
  240. package/dist/esm/index337.js +187 -56
  241. package/dist/esm/index338.js +2 -78
  242. package/dist/esm/index339.js +79 -4
  243. package/dist/esm/index340.js +11 -191
  244. package/dist/esm/index341.js +82 -55
  245. package/dist/esm/index342.js +159 -40
  246. package/dist/esm/index343.js +42 -4
  247. package/dist/esm/index344.js +656 -5
  248. package/dist/esm/index345.js +206 -2
  249. package/dist/esm/index346.js +174 -19
  250. package/dist/esm/index347.js +43 -0
  251. package/dist/esm/index348.js +7 -0
  252. package/dist/esm/index349.js +10 -0
  253. package/dist/esm/index350.js +65 -0
  254. package/dist/esm/index351.js +80 -0
  255. package/dist/esm/index352.js +122 -0
  256. package/dist/esm/index353.js +345 -0
  257. package/dist/esm/index354.js +163 -0
  258. package/dist/esm/index355.js +7 -0
  259. package/dist/esm/index356.js +7 -0
  260. package/dist/esm/index357.js +55 -0
  261. package/dist/esm/index358.js +7 -0
  262. package/dist/esm/index359.js +4 -0
  263. package/dist/esm/index360.js +24 -0
  264. package/dist/esm/index71.js +26 -17
  265. package/dist/esm/index73.js +2 -2
  266. package/dist/esm/index74.js +12 -40
  267. package/dist/esm/index75.js +49 -58
  268. package/dist/esm/index76.js +13 -43
  269. package/dist/esm/index77.js +28 -5
  270. package/dist/esm/index78.js +30 -48
  271. package/dist/esm/index79.js +29 -32
  272. package/dist/esm/index80.js +56 -4
  273. package/dist/esm/index81.js +54 -10
  274. package/dist/esm/index82.js +57 -67
  275. package/dist/esm/index83.js +5 -10
  276. package/dist/esm/index84.js +47 -28
  277. package/dist/esm/index85.js +37 -69
  278. package/dist/esm/index86.js +2 -20
  279. package/dist/esm/index87.js +69 -110
  280. package/dist/esm/index88.js +34 -60
  281. package/dist/esm/index89.js +13 -23
  282. package/dist/esm/index90.js +33 -39
  283. package/dist/esm/index91.js +3 -37
  284. package/dist/esm/index92.js +8 -57
  285. package/dist/esm/index93.js +118 -163
  286. package/dist/esm/index94.js +58 -36
  287. package/dist/esm/index95.js +23 -8
  288. package/dist/esm/index96.js +36 -31
  289. package/dist/esm/index97.js +38 -33
  290. package/dist/esm/index98.js +58 -9
  291. package/dist/esm/index99.js +164 -25
  292. package/dist/types/index.d.ts +1 -3
  293. package/package.json +4 -4
@@ -1,4 +1,208 @@
1
- const o = "0.1.1";
1
+ const w = /* @__PURE__ */ BigInt(0), p = /* @__PURE__ */ BigInt(1);
2
+ function b(t) {
3
+ return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
4
+ }
5
+ function h(t) {
6
+ if (!b(t))
7
+ throw new Error("Uint8Array expected");
8
+ }
9
+ function k(t, n) {
10
+ if (typeof n != "boolean")
11
+ throw new Error(t + " boolean expected, got " + n);
12
+ }
13
+ function F(t) {
14
+ const n = t.toString(16);
15
+ return n.length & 1 ? "0" + n : n;
16
+ }
17
+ function E(t) {
18
+ if (typeof t != "string")
19
+ throw new Error("hex string expected, got " + typeof t);
20
+ return t === "" ? w : BigInt("0x" + t);
21
+ }
22
+ const U = (
23
+ // @ts-ignore
24
+ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function"
25
+ ), S = /* @__PURE__ */ Array.from({ length: 256 }, (t, n) => n.toString(16).padStart(2, "0"));
26
+ function x(t) {
27
+ if (h(t), U)
28
+ return t.toHex();
29
+ let n = "";
30
+ for (let e = 0; e < t.length; e++)
31
+ n += S[t[e]];
32
+ return n;
33
+ }
34
+ const u = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
35
+ function m(t) {
36
+ if (t >= u._0 && t <= u._9)
37
+ return t - u._0;
38
+ if (t >= u.A && t <= u.F)
39
+ return t - (u.A - 10);
40
+ if (t >= u.a && t <= u.f)
41
+ return t - (u.a - 10);
42
+ }
43
+ function B(t) {
44
+ if (typeof t != "string")
45
+ throw new Error("hex string expected, got " + typeof t);
46
+ if (U)
47
+ return Uint8Array.fromHex(t);
48
+ const n = t.length, e = n / 2;
49
+ if (n % 2)
50
+ throw new Error("hex string expected, got unpadded hex of length " + n);
51
+ const r = new Uint8Array(e);
52
+ for (let o = 0, i = 0; o < e; o++, i += 2) {
53
+ const a = m(t.charCodeAt(i)), f = m(t.charCodeAt(i + 1));
54
+ if (a === void 0 || f === void 0) {
55
+ const c = t[i] + t[i + 1];
56
+ throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + i);
57
+ }
58
+ r[o] = a * 16 + f;
59
+ }
60
+ return r;
61
+ }
62
+ function O(t) {
63
+ return E(x(t));
64
+ }
65
+ function V(t) {
66
+ return h(t), E(x(Uint8Array.from(t).reverse()));
67
+ }
68
+ function T(t, n) {
69
+ return B(t.toString(16).padStart(n * 2, "0"));
70
+ }
71
+ function C(t, n) {
72
+ return T(t, n).reverse();
73
+ }
74
+ function M(t, n, e) {
75
+ let r;
76
+ if (typeof n == "string")
77
+ try {
78
+ r = B(n);
79
+ } catch (i) {
80
+ throw new Error(t + " must be hex string or Uint8Array, cause: " + i);
81
+ }
82
+ else if (b(n))
83
+ r = Uint8Array.from(n);
84
+ else
85
+ throw new Error(t + " must be hex string or Uint8Array");
86
+ const o = r.length;
87
+ if (typeof e == "number" && o !== e)
88
+ throw new Error(t + " of length " + e + " expected, got " + o);
89
+ return r;
90
+ }
91
+ function H(...t) {
92
+ let n = 0;
93
+ for (let r = 0; r < t.length; r++) {
94
+ const o = t[r];
95
+ h(o), n += o.length;
96
+ }
97
+ const e = new Uint8Array(n);
98
+ for (let r = 0, o = 0; r < t.length; r++) {
99
+ const i = t[r];
100
+ e.set(i, o), o += i.length;
101
+ }
102
+ return e;
103
+ }
104
+ const y = (t) => typeof t == "bigint" && w <= t;
105
+ function I(t, n, e) {
106
+ return y(t) && y(n) && y(e) && n <= t && t < e;
107
+ }
108
+ function R(t, n, e, r) {
109
+ if (!I(n, e, r))
110
+ throw new Error("expected valid " + t + ": " + e + " <= n < " + r + ", got " + n);
111
+ }
112
+ function j(t) {
113
+ let n;
114
+ for (n = 0; t > w; t >>= p, n += 1)
115
+ ;
116
+ return n;
117
+ }
118
+ const z = (t) => (p << BigInt(t)) - p, d = (t) => new Uint8Array(t), A = (t) => Uint8Array.from(t);
119
+ function D(t, n, e) {
120
+ if (typeof t != "number" || t < 2)
121
+ throw new Error("hashLen must be a number");
122
+ if (typeof n != "number" || n < 2)
123
+ throw new Error("qByteLen must be a number");
124
+ if (typeof e != "function")
125
+ throw new Error("hmacFn must be a function");
126
+ let r = d(t), o = d(t), i = 0;
127
+ const a = () => {
128
+ r.fill(1), o.fill(0), i = 0;
129
+ }, f = (...s) => e(o, r, ...s), c = (s = d(0)) => {
130
+ o = f(A([0]), s), r = f(), s.length !== 0 && (o = f(A([1]), s), r = f());
131
+ }, v = () => {
132
+ if (i++ >= 1e3)
133
+ throw new Error("drbg: tried 1000 values");
134
+ let s = 0;
135
+ const l = [];
136
+ for (; s < n; ) {
137
+ r = f();
138
+ const g = r.slice();
139
+ l.push(g), s += r.length;
140
+ }
141
+ return H(...l);
142
+ };
143
+ return (s, l) => {
144
+ a(), c(s);
145
+ let g;
146
+ for (; !(g = l(v())); )
147
+ c();
148
+ return a(), g;
149
+ };
150
+ }
151
+ const _ = {
152
+ bigint: (t) => typeof t == "bigint",
153
+ function: (t) => typeof t == "function",
154
+ boolean: (t) => typeof t == "boolean",
155
+ string: (t) => typeof t == "string",
156
+ stringOrUint8Array: (t) => typeof t == "string" || b(t),
157
+ isSafeInteger: (t) => Number.isSafeInteger(t),
158
+ array: (t) => Array.isArray(t),
159
+ field: (t, n) => n.Fp.isValid(t),
160
+ hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen)
161
+ };
162
+ function P(t, n, e = {}) {
163
+ const r = (o, i, a) => {
164
+ const f = _[i];
165
+ if (typeof f != "function")
166
+ throw new Error("invalid validator function");
167
+ const c = t[o];
168
+ if (!(a && c === void 0) && !f(c, t))
169
+ throw new Error("param " + String(o) + " is invalid. Expected " + i + ", got " + c);
170
+ };
171
+ for (const [o, i] of Object.entries(n))
172
+ r(o, i, !1);
173
+ for (const [o, i] of Object.entries(e))
174
+ r(o, i, !0);
175
+ return t;
176
+ }
177
+ function W(t) {
178
+ const n = /* @__PURE__ */ new WeakMap();
179
+ return (e, ...r) => {
180
+ const o = n.get(e);
181
+ if (o !== void 0)
182
+ return o;
183
+ const i = t(e, ...r);
184
+ return n.set(e, i), i;
185
+ };
186
+ }
2
187
  export {
3
- o as version
188
+ R as aInRange,
189
+ k as abool,
190
+ h as abytes,
191
+ j as bitLen,
192
+ z as bitMask,
193
+ x as bytesToHex,
194
+ O as bytesToNumberBE,
195
+ V as bytesToNumberLE,
196
+ H as concatBytes,
197
+ D as createHmacDrbg,
198
+ M as ensureBytes,
199
+ B as hexToBytes,
200
+ E as hexToNumber,
201
+ I as inRange,
202
+ b as isBytes,
203
+ W as memoized,
204
+ T as numberToBytesBE,
205
+ C as numberToBytesLE,
206
+ F as numberToHexUnpadded,
207
+ P as validateObject
4
208
  };
@@ -1,24 +1,179 @@
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;
9
- }
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;
13
- }
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);
1
+ import { validateField as M, nLength as z } from "./index325.js";
2
+ import { validateObject as O, bitLen as k, bitMask as x } from "./index345.js";
3
+ const E = BigInt(0), F = BigInt(1);
4
+ function m(e, a) {
5
+ const t = a.negate();
6
+ return e ? t : a;
7
+ }
8
+ function y(e, a) {
9
+ if (!Number.isSafeInteger(e) || e <= 0 || e > a)
10
+ throw new Error("invalid window size, expected [1.." + a + "], got W=" + e);
11
+ }
12
+ function N(e, a) {
13
+ y(e, a);
14
+ const t = Math.ceil(a / e) + 1, n = 2 ** (e - 1), i = 2 ** e, o = x(e), r = BigInt(e);
15
+ return { windows: t, windowSize: n, mask: o, maxNumber: i, shiftBy: r };
16
+ }
17
+ function B(e, a, t) {
18
+ const { windowSize: n, mask: i, maxNumber: o, shiftBy: r } = t;
19
+ let f = Number(e & i), s = e >> r;
20
+ f > n && (f -= o, s += F);
21
+ const c = a * n, d = c + Math.abs(f) - 1, g = f === 0, l = f < 0, u = a % 2 !== 0;
22
+ return { nextN: s, offset: d, isZero: g, isNeg: l, isNegF: u, offsetF: c };
23
+ }
24
+ function L(e, a) {
25
+ if (!Array.isArray(e))
26
+ throw new Error("array expected");
27
+ e.forEach((t, n) => {
28
+ if (!(t instanceof a))
29
+ throw new Error("invalid point at index " + n);
30
+ });
31
+ }
32
+ function Z(e, a) {
33
+ if (!Array.isArray(e))
34
+ throw new Error("array of scalars expected");
35
+ e.forEach((t, n) => {
36
+ if (!a.isValid(t))
37
+ throw new Error("invalid scalar at index " + n);
38
+ });
39
+ }
40
+ const b = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap();
41
+ function S(e) {
42
+ return I.get(e) || 1;
43
+ }
44
+ function v(e, a) {
45
+ return {
46
+ constTimeNegate: m,
47
+ hasPrecomputes(t) {
48
+ return S(t) !== 1;
49
+ },
50
+ // non-const time multiplication ladder
51
+ unsafeLadder(t, n, i = e.ZERO) {
52
+ let o = t;
53
+ for (; n > E; )
54
+ n & F && (i = i.add(o)), o = o.double(), n >>= F;
55
+ return i;
56
+ },
57
+ /**
58
+ * Creates a wNAF precomputation window. Used for caching.
59
+ * Default window size is set by `utils.precompute()` and is equal to 8.
60
+ * Number of precomputed points depends on the curve size:
61
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
62
+ * - 𝑊 is the window size
63
+ * - 𝑛 is the bitlength of the curve order.
64
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
65
+ * @param elm Point instance
66
+ * @param W window size
67
+ * @returns precomputed point tables flattened to a single array
68
+ */
69
+ precomputeWindow(t, n) {
70
+ const { windows: i, windowSize: o } = N(n, a), r = [];
71
+ let f = t, s = f;
72
+ for (let c = 0; c < i; c++) {
73
+ s = f, r.push(s);
74
+ for (let d = 1; d < o; d++)
75
+ s = s.add(f), r.push(s);
76
+ f = s.double();
77
+ }
78
+ return r;
79
+ },
80
+ /**
81
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
82
+ * @param W window size
83
+ * @param precomputes precomputed tables
84
+ * @param n scalar (we don't check here, but should be less than curve order)
85
+ * @returns real and fake (for const-time) points
86
+ */
87
+ wNAF(t, n, i) {
88
+ let o = e.ZERO, r = e.BASE;
89
+ const f = N(t, a);
90
+ for (let s = 0; s < f.windows; s++) {
91
+ const { nextN: c, offset: d, isZero: g, isNeg: l, isNegF: u, offsetF: h } = B(i, s, f);
92
+ i = c, g ? r = r.add(m(u, n[h])) : o = o.add(m(l, n[d]));
93
+ }
94
+ return { p: o, f: r };
95
+ },
96
+ /**
97
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
98
+ * @param W window size
99
+ * @param precomputes precomputed tables
100
+ * @param n scalar (we don't check here, but should be less than curve order)
101
+ * @param acc accumulator point to add result of multiplication
102
+ * @returns point
103
+ */
104
+ wNAFUnsafe(t, n, i, o = e.ZERO) {
105
+ const r = N(t, a);
106
+ for (let f = 0; f < r.windows && i !== E; f++) {
107
+ const { nextN: s, offset: c, isZero: d, isNeg: g } = B(i, f, r);
108
+ if (i = s, !d) {
109
+ const l = n[c];
110
+ o = o.add(g ? l.negate() : l);
111
+ }
112
+ }
113
+ return o;
114
+ },
115
+ getPrecomputes(t, n, i) {
116
+ let o = b.get(n);
117
+ return o || (o = this.precomputeWindow(n, t), t !== 1 && b.set(n, i(o))), o;
118
+ },
119
+ wNAFCached(t, n, i) {
120
+ const o = S(t);
121
+ return this.wNAF(o, this.getPrecomputes(o, t, i), n);
122
+ },
123
+ wNAFCachedUnsafe(t, n, i, o) {
124
+ const r = S(t);
125
+ return r === 1 ? this.unsafeLadder(t, n, o) : this.wNAFUnsafe(r, this.getPrecomputes(r, t, i), n, o);
126
+ },
127
+ // We calculate precomputes for elliptic curve point multiplication
128
+ // using windowed method. This specifies window size and
129
+ // stores precomputed values. Usually only base point would be precomputed.
130
+ setWindowSize(t, n) {
131
+ y(n, a), I.set(t, n), b.delete(t);
18
132
  }
19
- return this;
133
+ };
134
+ }
135
+ function U(e, a, t, n) {
136
+ L(t, e), Z(n, a);
137
+ const i = t.length, o = n.length;
138
+ if (i !== o)
139
+ throw new Error("arrays of points and scalars must have equal length");
140
+ const r = e.ZERO, f = k(BigInt(i));
141
+ let s = 1;
142
+ f > 12 ? s = f - 3 : f > 4 ? s = f - 2 : f > 0 && (s = 2);
143
+ const c = x(s), d = new Array(Number(c) + 1).fill(r), g = Math.floor((a.BITS - 1) / s) * s;
144
+ let l = r;
145
+ for (let u = g; u >= 0; u -= s) {
146
+ d.fill(r);
147
+ for (let w = 0; w < o; w++) {
148
+ const p = n[w], A = Number(p >> BigInt(u) & c);
149
+ d[A] = d[A].add(t[w]);
150
+ }
151
+ let h = r;
152
+ for (let w = d.length - 1, p = r; w > 0; w--)
153
+ p = p.add(d[w]), h = h.add(p);
154
+ if (l = l.add(h), u !== 0)
155
+ for (let w = 0; w < s; w++)
156
+ l = l.double();
20
157
  }
158
+ return l;
159
+ }
160
+ function C(e) {
161
+ return M(e.Fp), O(e, {
162
+ n: "bigint",
163
+ h: "bigint",
164
+ Gx: "field",
165
+ Gy: "field"
166
+ }, {
167
+ nBitLength: "isSafeInteger",
168
+ nByteLength: "isSafeInteger"
169
+ }), Object.freeze({
170
+ ...z(e.n, e.nBitLength),
171
+ ...e,
172
+ p: e.Fp.ORDER
173
+ });
21
174
  }
22
175
  export {
23
- r as LruMap
176
+ U as pippenger,
177
+ C as validateBasic,
178
+ v as wNAF
24
179
  };
@@ -0,0 +1,43 @@
1
+ import { size as i, SliceOffsetOutOfBoundsError as f, SizeExceedsPaddingSizeError as s, SizeOverflowError as p } from "./index333.js";
2
+ function c(t, e) {
3
+ if (i(t) > e)
4
+ throw new p({
5
+ givenSize: i(t),
6
+ maxSize: e
7
+ });
8
+ }
9
+ function S(t, e) {
10
+ if (typeof e == "number" && e > 0 && e > i(t) - 1)
11
+ throw new f({
12
+ offset: e,
13
+ position: "start",
14
+ size: i(t)
15
+ });
16
+ }
17
+ function d(t, e, r) {
18
+ if (typeof e == "number" && typeof r == "number" && i(t) !== r - e)
19
+ throw new f({
20
+ offset: r,
21
+ position: "end",
22
+ size: i(t)
23
+ });
24
+ }
25
+ function u(t, e = {}) {
26
+ const { dir: r, size: n = 32 } = e;
27
+ if (n === 0)
28
+ return t;
29
+ const o = t.replace("0x", "");
30
+ if (o.length > n * 2)
31
+ throw new s({
32
+ size: Math.ceil(o.length / 2),
33
+ targetSize: n,
34
+ type: "Hex"
35
+ });
36
+ return `0x${o[r === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
37
+ }
38
+ export {
39
+ d as assertEndOffset,
40
+ c as assertSize,
41
+ S as assertStartOffset,
42
+ u as pad
43
+ };
@@ -0,0 +1,7 @@
1
+ const r = "#__bigint";
2
+ function g(i, f, n) {
3
+ return JSON.stringify(i, (e, t) => typeof t == "bigint" ? t.toString() + r : t, n);
4
+ }
5
+ export {
6
+ g as stringify
7
+ };
@@ -0,0 +1,10 @@
1
+ import { keccak_256 as f } from "./index246.js";
2
+ import { from as m } from "./index352.js";
3
+ import { fromBytes as s } from "./index333.js";
4
+ function p(t, o = {}) {
5
+ const { as: e = typeof t == "string" ? "Hex" : "Bytes" } = o, r = f(m(t));
6
+ return e === "Bytes" ? r : s(r);
7
+ }
8
+ export {
9
+ p as keccak256
10
+ };
@@ -0,0 +1,65 @@
1
+ import { validate as c } from "./index351.js";
2
+ import { BaseError as f } from "./index341.js";
3
+ function y(r) {
4
+ let i = !0, t = "", e = 0, n = "", o = !1;
5
+ for (let s = 0; s < r.length; s++) {
6
+ const u = r[s];
7
+ if (["(", ")", ","].includes(u) && (i = !0), u === "(" && e++, u === ")" && e--, !!i) {
8
+ if (e === 0) {
9
+ if (u === " " && ["event", "function", "error", ""].includes(n))
10
+ n = "";
11
+ else if (n += u, u === ")") {
12
+ o = !0;
13
+ break;
14
+ }
15
+ continue;
16
+ }
17
+ if (u === " ") {
18
+ r[s - 1] !== "," && t !== "," && t !== ",(" && (t = "", i = !1);
19
+ continue;
20
+ }
21
+ n += u, t += u;
22
+ }
23
+ }
24
+ if (!o)
25
+ throw new f("Unable to normalize signature.");
26
+ return n;
27
+ }
28
+ function l(r, i) {
29
+ const t = typeof r, e = i.type;
30
+ switch (e) {
31
+ case "address":
32
+ return c(r, { strict: !1 });
33
+ case "bool":
34
+ return t === "boolean";
35
+ case "function":
36
+ return t === "string";
37
+ case "string":
38
+ return t === "string";
39
+ default:
40
+ return e === "tuple" && "components" in i ? Object.values(i.components).every((n, o) => l(Object.values(r)[o], n)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e) ? t === "number" || t === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e) ? t === "string" || r instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e) ? Array.isArray(r) && r.every((n) => l(n, {
41
+ ...i,
42
+ // Pop off `[]` or `[M]` from end of type
43
+ type: e.replace(/(\[[0-9]{0,}\])$/, "")
44
+ })) : !1;
45
+ }
46
+ }
47
+ function a(r, i, t) {
48
+ for (const e in r) {
49
+ const n = r[e], o = i[e];
50
+ if (n.type === "tuple" && o.type === "tuple" && "components" in n && "components" in o)
51
+ return a(n.components, o.components, t[e]);
52
+ const s = [n.type, o.type];
53
+ if (s.includes("address") && s.includes("bytes20") ? !0 : s.includes("address") && s.includes("string") ? c(t[e], {
54
+ strict: !1
55
+ }) : s.includes("address") && s.includes("bytes") ? c(t[e], {
56
+ strict: !1
57
+ }) : !1)
58
+ return s;
59
+ }
60
+ }
61
+ export {
62
+ a as getAmbiguousTypes,
63
+ l as isArgOfType,
64
+ y as normalizeSignature
65
+ };
@@ -0,0 +1,80 @@
1
+ import { fromString as d } from "./index352.js";
2
+ import { checksum as o } from "./index358.js";
3
+ import { BaseError as c } from "./index341.js";
4
+ import { keccak256 as f } from "./index349.js";
5
+ const l = /^0x[a-fA-F0-9]{40}$/;
6
+ function u(r, t = {}) {
7
+ const { strict: s = !0 } = t;
8
+ if (!l.test(r))
9
+ throw new i({
10
+ address: r,
11
+ cause: new h()
12
+ });
13
+ if (s) {
14
+ if (r.toLowerCase() === r)
15
+ return;
16
+ if (m(r) !== r)
17
+ throw new i({
18
+ address: r,
19
+ cause: new p()
20
+ });
21
+ }
22
+ }
23
+ function m(r) {
24
+ if (o.has(r))
25
+ return o.get(r);
26
+ u(r, { strict: !1 });
27
+ const t = r.substring(2).toLowerCase(), s = f(d(t), { as: "Bytes" }), n = t.split("");
28
+ for (let e = 0; e < 40; e += 2)
29
+ s[e >> 1] >> 4 >= 8 && n[e] && (n[e] = n[e].toUpperCase()), (s[e >> 1] & 15) >= 8 && n[e + 1] && (n[e + 1] = n[e + 1].toUpperCase());
30
+ const a = `0x${n.join("")}`;
31
+ return o.set(r, a), a;
32
+ }
33
+ function k(r, t = {}) {
34
+ const { strict: s = !0 } = t ?? {};
35
+ try {
36
+ return u(r, { strict: s }), !0;
37
+ } catch {
38
+ return !1;
39
+ }
40
+ }
41
+ class i extends c {
42
+ constructor({ address: t, cause: s }) {
43
+ super(`Address "${t}" is invalid.`, {
44
+ cause: s
45
+ }), Object.defineProperty(this, "name", {
46
+ enumerable: !0,
47
+ configurable: !0,
48
+ writable: !0,
49
+ value: "Address.InvalidAddressError"
50
+ });
51
+ }
52
+ }
53
+ class h extends c {
54
+ constructor() {
55
+ super("Address is not a 20 byte (40 hexadecimal character) value."), Object.defineProperty(this, "name", {
56
+ enumerable: !0,
57
+ configurable: !0,
58
+ writable: !0,
59
+ value: "Address.InvalidInputError"
60
+ });
61
+ }
62
+ }
63
+ class p extends c {
64
+ constructor() {
65
+ super("Address does not match its checksum counterpart."), Object.defineProperty(this, "name", {
66
+ enumerable: !0,
67
+ configurable: !0,
68
+ writable: !0,
69
+ value: "Address.InvalidChecksumError"
70
+ });
71
+ }
72
+ }
73
+ export {
74
+ i as InvalidAddressError,
75
+ p as InvalidChecksumError,
76
+ h as InvalidInputError,
77
+ u as assert,
78
+ m as checksum,
79
+ k as validate
80
+ };