@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/index66.js CHANGED
@@ -1,9 +1,194 @@
1
- function f(e, { dir: n = "left" } = {}) {
2
- let t = typeof e == "string" ? e.replace("0x", "") : e, i = 0;
3
- for (let l = 0; l < t.length - 1 && t[n === "left" ? l : t.length - l - 1].toString() === "0"; l++)
4
- i++;
5
- return t = n === "left" ? t.slice(i) : t.slice(0, t.length - i), typeof e == "string" ? (t.length === 1 && n === "right" && (t = `${t}0`), `0x${t.length % 2 === 1 ? `0${t}` : t}`) : t;
1
+ import { AbiEncodingLengthMismatchError as y, InvalidAbiEncodingTypeError as u, InvalidArrayError as g, AbiEncodingArrayLengthMismatchError as l, AbiEncodingBytesSizeMismatchError as b } from "./index79.js";
2
+ import { InvalidAddressError as w } from "./index32.js";
3
+ import { BaseError as A } from "./index50.js";
4
+ import { IntegerOutOfRangeError as x } from "./index45.js";
5
+ import { isAddress as z } from "./index33.js";
6
+ import { concat as f } from "./index59.js";
7
+ import { padHex as d } from "./index46.js";
8
+ import { size as a } from "./index68.js";
9
+ import { slice as E } from "./index98.js";
10
+ import { numberToHex as m, boolToHex as P, stringToHex as S } from "./index24.js";
11
+ import { integerRegex as I } from "./index86.js";
12
+ function K(e, t) {
13
+ if (e.length !== t.length)
14
+ throw new y({
15
+ expectedLength: e.length,
16
+ givenLength: t.length
17
+ });
18
+ const o = L({
19
+ params: e,
20
+ values: t
21
+ }), n = h(o);
22
+ return n.length === 0 ? "0x" : n;
23
+ }
24
+ function L({ params: e, values: t }) {
25
+ const o = [];
26
+ for (let n = 0; n < e.length; n++)
27
+ o.push(p({ param: e[n], value: t[n] }));
28
+ return o;
29
+ }
30
+ function p({ param: e, value: t }) {
31
+ const o = W(e.type);
32
+ if (o) {
33
+ const [n, r] = o;
34
+ return M(t, { length: n, param: { ...e, type: r } });
35
+ }
36
+ if (e.type === "tuple")
37
+ return H(t, {
38
+ param: e
39
+ });
40
+ if (e.type === "address")
41
+ return B(t);
42
+ if (e.type === "bool")
43
+ return T(t);
44
+ if (e.type.startsWith("uint") || e.type.startsWith("int")) {
45
+ const n = e.type.startsWith("int"), [, , r = "256"] = I.exec(e.type) ?? [];
46
+ return $(t, {
47
+ signed: n,
48
+ size: Number(r)
49
+ });
50
+ }
51
+ if (e.type.startsWith("bytes"))
52
+ return N(t, { param: e });
53
+ if (e.type === "string")
54
+ return C(t);
55
+ throw new u(e.type, {
56
+ docsPath: "/docs/contract/encodeAbiParameters"
57
+ });
58
+ }
59
+ function h(e) {
60
+ let t = 0;
61
+ for (let i = 0; i < e.length; i++) {
62
+ const { dynamic: c, encoded: s } = e[i];
63
+ c ? t += 32 : t += a(s);
64
+ }
65
+ const o = [], n = [];
66
+ let r = 0;
67
+ for (let i = 0; i < e.length; i++) {
68
+ const { dynamic: c, encoded: s } = e[i];
69
+ c ? (o.push(m(t + r, { size: 32 })), n.push(s), r += a(s)) : o.push(s);
70
+ }
71
+ return f([...o, ...n]);
72
+ }
73
+ function B(e) {
74
+ if (!z(e))
75
+ throw new w({ address: e });
76
+ return { dynamic: !1, encoded: d(e.toLowerCase()) };
77
+ }
78
+ function M(e, { length: t, param: o }) {
79
+ const n = t === null;
80
+ if (!Array.isArray(e))
81
+ throw new g(e);
82
+ if (!n && e.length !== t)
83
+ throw new l({
84
+ expectedLength: t,
85
+ givenLength: e.length,
86
+ type: `${o.type}[${t}]`
87
+ });
88
+ let r = !1;
89
+ const i = [];
90
+ for (let c = 0; c < e.length; c++) {
91
+ const s = p({ param: o, value: e[c] });
92
+ s.dynamic && (r = !0), i.push(s);
93
+ }
94
+ if (n || r) {
95
+ const c = h(i);
96
+ if (n) {
97
+ const s = m(i.length, { size: 32 });
98
+ return {
99
+ dynamic: !0,
100
+ encoded: i.length > 0 ? f([s, c]) : s
101
+ };
102
+ }
103
+ if (r)
104
+ return { dynamic: !0, encoded: c };
105
+ }
106
+ return {
107
+ dynamic: !1,
108
+ encoded: f(i.map(({ encoded: c }) => c))
109
+ };
110
+ }
111
+ function N(e, { param: t }) {
112
+ const [, o] = t.type.split("bytes"), n = a(e);
113
+ if (!o) {
114
+ let r = e;
115
+ return n % 32 !== 0 && (r = d(r, {
116
+ dir: "right",
117
+ size: Math.ceil((e.length - 2) / 2 / 32) * 32
118
+ })), {
119
+ dynamic: !0,
120
+ encoded: f([d(m(n, { size: 32 })), r])
121
+ };
122
+ }
123
+ if (n !== Number.parseInt(o))
124
+ throw new b({
125
+ expectedSize: Number.parseInt(o),
126
+ value: e
127
+ });
128
+ return { dynamic: !1, encoded: d(e, { dir: "right" }) };
129
+ }
130
+ function T(e) {
131
+ if (typeof e != "boolean")
132
+ throw new A(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
133
+ return { dynamic: !1, encoded: d(P(e)) };
134
+ }
135
+ function $(e, { signed: t, size: o = 256 }) {
136
+ if (typeof o == "number") {
137
+ const n = 2n ** (BigInt(o) - (t ? 1n : 0n)) - 1n, r = t ? -n - 1n : 0n;
138
+ if (e > n || e < r)
139
+ throw new x({
140
+ max: n.toString(),
141
+ min: r.toString(),
142
+ signed: t,
143
+ size: o / 8,
144
+ value: e.toString()
145
+ });
146
+ }
147
+ return {
148
+ dynamic: !1,
149
+ encoded: m(e, {
150
+ size: 32,
151
+ signed: t
152
+ })
153
+ };
154
+ }
155
+ function C(e) {
156
+ const t = S(e), o = Math.ceil(a(t) / 32), n = [];
157
+ for (let r = 0; r < o; r++)
158
+ n.push(d(E(t, r * 32, (r + 1) * 32), {
159
+ dir: "right"
160
+ }));
161
+ return {
162
+ dynamic: !0,
163
+ encoded: f([
164
+ d(m(a(t), { size: 32 })),
165
+ ...n
166
+ ])
167
+ };
168
+ }
169
+ function H(e, { param: t }) {
170
+ let o = !1;
171
+ const n = [];
172
+ for (let r = 0; r < t.components.length; r++) {
173
+ const i = t.components[r], c = Array.isArray(e) ? r : i.name, s = p({
174
+ param: i,
175
+ value: e[c]
176
+ });
177
+ n.push(s), s.dynamic && (o = !0);
178
+ }
179
+ return {
180
+ dynamic: o,
181
+ encoded: o ? h(n) : f(n.map(({ encoded: r }) => r))
182
+ };
183
+ }
184
+ function W(e) {
185
+ const t = e.match(/^(.*)\[(\d+)?\]$/);
186
+ return t ? (
187
+ // Return `null` if the array is dynamic.
188
+ [t[2] ? Number(t[2]) : null, t[1]]
189
+ ) : void 0;
6
190
  }
7
191
  export {
8
- f as trim
192
+ K as encodeAbiParameters,
193
+ W as getArrayComponents
9
194
  };
package/dist/index67.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index56.cjs"),u=require("./index94.cjs"),f=require("./index36.cjs"),g=require("./index24.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 E=require("./index79.cjs"),z=require("./index32.cjs"),o=require("./index85.cjs"),T=require("./index33.cjs"),u=require("./index68.cjs"),q=require("./index24.cjs"),g=require("./index86.cjs");function P(e){const{domain:n,message:b,primaryType:a,types:r}=e,c=(l,h)=>{for(const v of l){const{name:I,type:s}=v,t=h[I],y=s.match(g.integerRegex);if(y&&(typeof t=="number"||typeof t=="bigint")){const[w,i,D]=y;q.numberToHex(t,{signed:i==="int",size:Number.parseInt(D)/8})}if(s==="address"&&typeof t=="string"&&!T.isAddress(t))throw new z.InvalidAddressError({address:t});const f=s.match(g.bytesRegex);if(f){const[w,i]=f;if(i&&u.size(t)!==Number.parseInt(i))throw new E.BytesSizeMismatchError({expectedSize:Number.parseInt(i),givenSize:u.size(t)})}const p=r[s];p&&(x(s),c(p,t))}};if(r.EIP712Domain&&n){if(typeof n!="object")throw new o.InvalidDomainError({domain:n});c(r.EIP712Domain,n)}if(a!=="EIP712Domain")if(r[a])c(r[a],b);else throw new o.InvalidPrimaryTypeError({primaryType:a,types:r})}function d({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},(typeof(e==null?void 0:e.chainId)=="number"||typeof(e==null?void 0:e.chainId)=="bigint")&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function x(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new o.InvalidStructTypeError({type:e})}exports.getTypesForEIP712Domain=d;exports.validateTypedData=P;
package/dist/index67.js CHANGED
@@ -1,45 +1,67 @@
1
- import { BaseError as l } from "./index56.js";
2
- import { createCursor as r } from "./index94.js";
3
- import { hexToBytes as g } from "./index36.js";
4
- import { bytesToHex as u } from "./index24.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);
1
+ import { BytesSizeMismatchError as m } from "./index79.js";
2
+ import { InvalidAddressError as w } from "./index32.js";
3
+ import { InvalidDomainError as E, InvalidPrimaryTypeError as z, InvalidStructTypeError as D } from "./index85.js";
4
+ import { isAddress as T } from "./index33.js";
5
+ import { size as y } from "./index68.js";
6
+ import { numberToHex as x } from "./index24.js";
7
+ import { integerRegex as P, bytesRegex as S } from "./index86.js";
8
+ function j(e) {
9
+ const { domain: n, message: g, primaryType: o, types: r } = e, f = (h, b) => {
10
+ for (const u of h) {
11
+ const { name: l, type: s } = u, t = b[l], a = s.match(P);
12
+ if (a && (typeof t == "number" || typeof t == "bigint")) {
13
+ const [I, i, v] = a;
14
+ x(t, {
15
+ signed: i === "int",
16
+ size: Number.parseInt(v) / 8
17
+ });
18
+ }
19
+ if (s === "address" && typeof t == "string" && !T(t))
20
+ throw new w({ address: t });
21
+ const p = s.match(S);
22
+ if (p) {
23
+ const [I, i] = p;
24
+ if (i && y(t) !== Number.parseInt(i))
25
+ throw new m({
26
+ expectedSize: Number.parseInt(i),
27
+ givenSize: y(t)
28
+ });
29
+ }
30
+ const c = r[s];
31
+ c && (_(s), f(c, t));
20
32
  }
21
33
  };
34
+ if (r.EIP712Domain && n) {
35
+ if (typeof n != "object")
36
+ throw new E({ domain: n });
37
+ f(r.EIP712Domain, n);
38
+ }
39
+ if (o !== "EIP712Domain")
40
+ if (r[o])
41
+ f(r[o], g);
42
+ else
43
+ throw new z({ primaryType: o, types: r });
22
44
  }
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
- };
45
+ function F({ domain: e }) {
46
+ return [
47
+ typeof (e == null ? void 0 : e.name) == "string" && { name: "name", type: "string" },
48
+ (e == null ? void 0 : e.version) && { name: "version", type: "string" },
49
+ (typeof (e == null ? void 0 : e.chainId) == "number" || typeof (e == null ? void 0 : e.chainId) == "bigint") && {
50
+ name: "chainId",
51
+ type: "uint256"
52
+ },
53
+ (e == null ? void 0 : e.verifyingContract) && {
54
+ name: "verifyingContract",
55
+ type: "address"
56
+ },
57
+ (e == null ? void 0 : e.salt) && { name: "salt", type: "bytes32" }
58
+ ].filter(Boolean);
31
59
  }
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.");
60
+ function _(e) {
61
+ if (e === "address" || e === "bool" || e === "string" || e.startsWith("bytes") || e.startsWith("uint") || e.startsWith("int"))
62
+ throw new D({ type: e });
42
63
  }
43
64
  export {
44
- m as toRlp
65
+ F as getTypesForEIP712Domain,
66
+ j as validateTypedData
45
67
  };
package/dist/index68.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index96.cjs"),w=require("./index97.cjs"),t=require("./index32.cjs"),P=require("./index56.cjs"),h=require("./index98.cjs"),d=require("./index76.cjs"),n=require("./index80.cjs"),c=require("./index33.cjs"),I=require("./index74.cjs"),u=require("./index99.cjs"),l=require("./index35.cjs");function m(o){const{authorizationList:e}=o;if(e)for(const s of e){const{chainId:r}=s,i=s.address;if(!c.isAddress(i))throw new t.InvalidAddressError({address:i});if(r<0)throw new d.InvalidChainIdError({chainId:r})}f(o)}function T(o){const{blobVersionedHashes:e}=o;if(e){if(e.length===0)throw new h.EmptyBlobError;for(const s of e){const r=I.size(s),i=l.hexToNumber(u.slice(s,0,1));if(r!==32)throw new h.InvalidVersionedHashSizeError({hash:s,size:r});if(i!==E.versionedHashVersionKzg)throw new h.InvalidVersionedHashVersionError({hash:s,version:i})}}f(o)}function f(o){const{chainId:e,maxPriorityFeePerGas:s,maxFeePerGas:r,to:i}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(i&&!c.isAddress(i))throw new t.InvalidAddressError({address:i});if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r});if(s&&r&&s>r)throw new n.TipAboveFeeCapError({maxFeePerGas:r,maxPriorityFeePerGas:s})}function x(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}function v(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(typeof e<"u"&&e<=0)throw new d.InvalidChainIdError({chainId:e});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}exports.assertTransactionEIP1559=f;exports.assertTransactionEIP2930=x;exports.assertTransactionEIP4844=T;exports.assertTransactionEIP7702=m;exports.assertTransactionLegacy=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index53.cjs");function i(e){return t.isHex(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}exports.size=i;
package/dist/index68.js CHANGED
@@ -1,81 +1,7 @@
1
- import { versionedHashVersionKzg as c } from "./index96.js";
2
- import { maxUint256 as m } from "./index97.js";
3
- import { InvalidAddressError as s } from "./index32.js";
4
- import { BaseError as h } from "./index56.js";
5
- import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index98.js";
6
- import { InvalidChainIdError as n } from "./index76.js";
7
- import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index80.js";
8
- import { isAddress as f } from "./index33.js";
9
- import { size as F } from "./index74.js";
10
- import { slice as I } from "./index99.js";
11
- import { hexToNumber as G } from "./index35.js";
12
- function C(t) {
13
- const { authorizationList: e } = t;
14
- if (e)
15
- for (const o of e) {
16
- const { chainId: r } = o, i = o.address;
17
- if (!f(i))
18
- throw new s({ address: i });
19
- if (r < 0)
20
- throw new n({ chainId: r });
21
- }
22
- d(t);
23
- }
24
- function L(t) {
25
- const { blobVersionedHashes: e } = t;
26
- if (e) {
27
- if (e.length === 0)
28
- throw new P();
29
- for (const o of e) {
30
- const r = F(o), i = G(I(o, 0, 1));
31
- if (r !== 32)
32
- throw new p({ hash: o, size: r });
33
- if (i !== c)
34
- throw new x({
35
- hash: o,
36
- version: i
37
- });
38
- }
39
- }
40
- d(t);
41
- }
42
- function d(t) {
43
- const { chainId: e, maxPriorityFeePerGas: o, maxFeePerGas: r, to: i } = t;
44
- if (e <= 0)
45
- throw new n({ chainId: e });
46
- if (i && !f(i))
47
- throw new s({ address: i });
48
- if (r && r > m)
49
- throw new w({ maxFeePerGas: r });
50
- if (o && r && o > r)
51
- throw new E({ maxFeePerGas: r, maxPriorityFeePerGas: o });
52
- }
53
- function B(t) {
54
- const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
55
- if (e <= 0)
56
- throw new n({ chainId: e });
57
- if (a && !f(a))
58
- throw new s({ address: a });
59
- if (o || i)
60
- throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
61
- if (r && r > m)
62
- throw new w({ maxFeePerGas: r });
63
- }
64
- function K(t) {
65
- const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
66
- if (a && !f(a))
67
- throw new s({ address: a });
68
- if (typeof e < "u" && e <= 0)
69
- throw new n({ chainId: e });
70
- if (o || i)
71
- throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
72
- if (r && r > m)
73
- throw new w({ maxFeePerGas: r });
1
+ import { isHex as r } from "./index53.js";
2
+ function i(t) {
3
+ return r(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
74
4
  }
75
5
  export {
76
- d as assertTransactionEIP1559,
77
- B as assertTransactionEIP2930,
78
- L as assertTransactionEIP4844,
79
- C as assertTransactionEIP7702,
80
- K as assertTransactionLegacy
6
+ i as size
81
7
  };
package/dist/index69.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index43.cjs");function f(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new i.InvalidSerializableTransactionError({transaction:e})}exports.getTransactionType=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index70.cjs"),c=require("./index71.cjs");class r extends c.Hash{constructor(t,i){super(),this.finished=!1,this.destroyed=!1,o.ahash(t);const h=c.toBytes(i);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,e=new Uint8Array(a);e.set(h.length>a?t.create().update(h).digest():h);for(let s=0;s<e.length;s++)e[s]^=54;this.iHash.update(e),this.oHash=t.create();for(let s=0;s<e.length;s++)e[s]^=106;this.oHash.update(e),e.fill(0)}update(t){return o.aexists(this),this.iHash.update(t),this}digestInto(t){o.aexists(this),o.abytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:i,iHash:h,finished:a,destroyed:e,blockLen:s,outputLen:u}=this;return t=t,t.finished=a,t.destroyed=e,t.blockLen=s,t.outputLen=u,t.oHash=i._cloneInto(t.oHash),t.iHash=h._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const d=(n,t,i)=>new r(n,t).update(i).digest();d.create=(n,t)=>new r(n,t);exports.HMAC=r;exports.hmac=d;
package/dist/index69.js CHANGED
@@ -1,17 +1,43 @@
1
- import { InvalidSerializableTransactionError as f } from "./index43.js";
2
- function d(e) {
3
- if (e.type)
4
- return e.type;
5
- if (typeof e.authorizationList < "u")
6
- return "eip7702";
7
- if (typeof e.blobs < "u" || typeof e.blobVersionedHashes < "u" || typeof e.maxFeePerBlobGas < "u" || typeof e.sidecars < "u")
8
- return "eip4844";
9
- if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u")
10
- return "eip1559";
11
- if (typeof e.gasPrice < "u")
12
- return typeof e.accessList < "u" ? "eip2930" : "legacy";
13
- throw new f({ transaction: e });
1
+ import { ahash as c, aexists as a, abytes as u } from "./index70.js";
2
+ import { Hash as H, toBytes as p } from "./index71.js";
3
+ class r extends H {
4
+ constructor(t, i) {
5
+ super(), this.finished = !1, this.destroyed = !1, c(t);
6
+ const h = p(i);
7
+ if (this.iHash = t.create(), typeof this.iHash.update != "function")
8
+ throw new Error("Expected instance of class which extends utils.Hash");
9
+ this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
10
+ const o = this.blockLen, e = new Uint8Array(o);
11
+ e.set(h.length > o ? t.create().update(h).digest() : h);
12
+ for (let s = 0; s < e.length; s++)
13
+ e[s] ^= 54;
14
+ this.iHash.update(e), this.oHash = t.create();
15
+ for (let s = 0; s < e.length; s++)
16
+ e[s] ^= 106;
17
+ this.oHash.update(e), e.fill(0);
18
+ }
19
+ update(t) {
20
+ return a(this), this.iHash.update(t), this;
21
+ }
22
+ digestInto(t) {
23
+ a(this), u(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
24
+ }
25
+ digest() {
26
+ const t = new Uint8Array(this.oHash.outputLen);
27
+ return this.digestInto(t), t;
28
+ }
29
+ _cloneInto(t) {
30
+ t || (t = Object.create(Object.getPrototypeOf(this), {}));
31
+ const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: d } = this;
32
+ return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = d, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
33
+ }
34
+ destroy() {
35
+ this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
36
+ }
14
37
  }
38
+ const l = (n, t, i) => new r(n, t).update(i).digest();
39
+ l.create = (n, t) => new r(n, t);
15
40
  export {
16
- d as getTransactionType
41
+ r as HMAC,
42
+ l as hmac
17
43
  };
package/dist/index70.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index32.cjs"),d=require("./index43.cjs"),l=require("./index33.cjs");function a(e){if(!e||e.length===0)return[];const n=[];for(let t=0;t<e.length;t++){const{address:i,storageKeys:r}=e[t];for(let s=0;s<r.length;s++)if(r[s].length-2!==64)throw new d.InvalidStorageKeySizeError({storageKey:r[s]});if(!l.isAddress(i,{strict:!1}))throw new o.InvalidAddressError({address:i});n.push([i,r])}return n}exports.serializeAccessList=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function o(e,...t){if(!i(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");r(e.outputLen),r(e.blockLen)}function s(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(e,t){o(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}exports.abytes=o;exports.aexists=s;exports.ahash=a;exports.anumber=r;exports.aoutput=u;
package/dist/index70.js CHANGED
@@ -1,21 +1,37 @@
1
- import { InvalidAddressError as s } from "./index32.js";
2
- import { InvalidStorageKeySizeError as l } from "./index43.js";
3
- import { isAddress as f } from "./index33.js";
4
- function a(r) {
5
- if (!r || r.length === 0)
6
- return [];
7
- const n = [];
8
- for (let o = 0; o < r.length; o++) {
9
- const { address: i, storageKeys: e } = r[o];
10
- for (let t = 0; t < e.length; t++)
11
- if (e[t].length - 2 !== 64)
12
- throw new l({ storageKey: e[t] });
13
- if (!f(i, { strict: !1 }))
14
- throw new s({ address: i });
15
- n.push([i, e]);
16
- }
17
- return n;
1
+ function n(e) {
2
+ if (!Number.isSafeInteger(e) || e < 0)
3
+ throw new Error("positive integer expected, got " + e);
4
+ }
5
+ function o(e) {
6
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
7
+ }
8
+ function i(e, ...t) {
9
+ if (!o(e))
10
+ throw new Error("Uint8Array expected");
11
+ if (t.length > 0 && !t.includes(e.length))
12
+ throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
13
+ }
14
+ function f(e) {
15
+ if (typeof e != "function" || typeof e.create != "function")
16
+ throw new Error("Hash should be wrapped by utils.wrapConstructor");
17
+ n(e.outputLen), n(e.blockLen);
18
+ }
19
+ function s(e, t = !0) {
20
+ if (e.destroyed)
21
+ throw new Error("Hash instance has been destroyed");
22
+ if (t && e.finished)
23
+ throw new Error("Hash#digest() has already been called");
24
+ }
25
+ function u(e, t) {
26
+ i(e);
27
+ const r = t.outputLen;
28
+ if (e.length < r)
29
+ throw new Error("digestInto() expects output buffer of length at least " + r);
18
30
  }
19
31
  export {
20
- a as serializeAccessList
32
+ i as abytes,
33
+ s as aexists,
34
+ f as ahash,
35
+ n as anumber,
36
+ u as aoutput
21
37
  };
package/dist/index71.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index95.cjs"),o=require("./index65.cjs"),s=require("./index74.cjs"),r=require("./index24.cjs");function c(e){const t=typeof e=="string"?r.stringToHex(e):typeof e.raw=="string"?e.raw:r.bytesToHex(e.raw),i=r.stringToHex(`${n.presignMessagePrefix}${s.size(t)}`);return o.concat([i,t])}exports.toPrefixedMessage=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index73.cjs"),f=require("./index70.cjs");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function p(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function a(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function l(t,e){return t<<32-e|t>>>e}const b=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function i(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function w(t){for(let e=0;e<t.length;e++)t[e]=i(t[e])}function y(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function s(t){return typeof t=="string"&&(t=y(t)),f.abytes(t),t}function g(...t){let e=0;for(let n=0;n<t.length;n++){const u=t[n];f.abytes(u),e+=u.length}const r=new Uint8Array(e);for(let n=0,u=0;n<t.length;n++){const c=t[n];r.set(c,u),u+=c.length}return r}class m{clone(){return this._cloneInto()}}function B(t){const e=n=>t().update(s(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function d(t=32){if(o.crypto&&typeof o.crypto.getRandomValues=="function")return o.crypto.getRandomValues(new Uint8Array(t));if(o.crypto&&typeof o.crypto.randomBytes=="function")return o.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}exports.Hash=m;exports.byteSwap=i;exports.byteSwap32=w;exports.concatBytes=g;exports.createView=a;exports.isLE=b;exports.randomBytes=d;exports.rotr=l;exports.toBytes=s;exports.u32=p;exports.utf8ToBytes=y;exports.wrapConstructor=B;
package/dist/index71.js CHANGED
@@ -1,11 +1,72 @@
1
- import { presignMessagePrefix as e } from "./index95.js";
2
- import { concat as n } from "./index65.js";
3
- import { size as f } from "./index74.js";
4
- import { stringToHex as o, bytesToHex as p } from "./index24.js";
5
- function u(r) {
6
- const t = typeof r == "string" ? o(r) : typeof r.raw == "string" ? r.raw : p(r.raw), i = o(`${e}${f(t)}`);
7
- return n([i, t]);
1
+ import { crypto as o } from "./index73.js";
2
+ import { abytes as i } from "./index70.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));
6
+ }
7
+ function m(t) {
8
+ return new DataView(t.buffer, t.byteOffset, t.byteLength);
9
+ }
10
+ function w(t, e) {
11
+ return t << 32 - e | t >>> e;
12
+ }
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));
25
+ }
26
+ function y(t) {
27
+ return typeof t == "string" && (t = s(t)), i(t), t;
28
+ }
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;
34
+ }
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;
39
+ }
40
+ return f;
41
+ }
42
+ class h {
43
+ // Safe version that clones internal state
44
+ clone() {
45
+ return this._cloneInto();
46
+ }
47
+ }
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;
51
+ }
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");
8
58
  }
9
59
  export {
10
- u as toPrefixedMessage
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
11
72
  };