@gardenfi/utils 2.1.1 → 2.1.2-beta.0

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 (198) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +19 -3
  3. package/dist/index101.cjs +1 -1
  4. package/dist/index101.js +1 -1
  5. package/dist/index104.cjs +1 -1
  6. package/dist/index104.js +1 -1
  7. package/dist/index105.cjs +1 -1
  8. package/dist/index105.js +33 -638
  9. package/dist/index106.cjs +1 -1
  10. package/dist/index106.js +5 -173
  11. package/dist/index107.cjs +1 -1
  12. package/dist/index107.js +10 -18
  13. package/dist/index108.cjs +1 -1
  14. package/dist/index108.js +2 -128
  15. package/dist/index109.cjs +1 -1
  16. package/dist/index109.js +128 -2
  17. package/dist/index110.cjs +1 -1
  18. package/dist/index110.js +7 -2
  19. package/dist/index111.cjs +1 -1
  20. package/dist/index111.js +2 -38
  21. package/dist/index112.cjs +1 -1
  22. package/dist/index112.js +33 -34
  23. package/dist/index113.cjs +1 -2
  24. package/dist/index113.js +21 -3
  25. package/dist/index114.cjs +1 -1
  26. package/dist/index114.js +5 -5
  27. package/dist/index115.cjs +2 -1
  28. package/dist/index115.js +3 -11
  29. package/dist/index116.cjs +1 -1
  30. package/dist/index116.js +18 -6
  31. package/dist/index117.cjs +1 -1
  32. package/dist/index117.js +638 -15
  33. package/dist/index118.cjs +1 -1
  34. package/dist/index118.js +173 -5
  35. package/dist/index18.cjs +1 -1
  36. package/dist/index18.js +11 -11
  37. package/dist/index19.cjs +1 -1
  38. package/dist/index19.js +9 -9
  39. package/dist/index21.cjs +1 -1
  40. package/dist/index21.js +1 -1
  41. package/dist/index23.cjs +1 -1
  42. package/dist/index23.js +17 -41
  43. package/dist/index24.cjs +1 -1
  44. package/dist/index24.js +6 -44
  45. package/dist/index25.cjs +1 -1
  46. package/dist/index25.js +44 -24
  47. package/dist/index26.cjs +1 -1
  48. package/dist/index26.js +21 -6
  49. package/dist/index27.cjs +1 -1
  50. package/dist/index27.js +8 -13
  51. package/dist/index28.cjs +1 -1
  52. package/dist/index28.js +31 -15
  53. package/dist/index29.cjs +1 -1
  54. package/dist/index29.js +26 -5
  55. package/dist/index30.cjs +2 -1
  56. package/dist/index30.js +65 -13
  57. package/dist/index31.cjs +1 -1
  58. package/dist/index31.js +51 -10
  59. package/dist/index32.cjs +1 -1
  60. package/dist/index32.js +12 -12
  61. package/dist/index33.cjs +1 -1
  62. package/dist/index33.js +24 -11
  63. package/dist/index34.cjs +1 -1
  64. package/dist/index34.js +75 -13
  65. package/dist/index35.cjs +1 -1
  66. package/dist/index35.js +1 -1
  67. package/dist/index36.cjs +1 -1
  68. package/dist/index36.js +7 -55
  69. package/dist/index37.cjs +1 -1
  70. package/dist/index37.js +32 -16
  71. package/dist/index38.cjs +1 -1
  72. package/dist/index38.js +15 -5
  73. package/dist/index39.cjs +1 -1
  74. package/dist/index39.js +2 -9
  75. package/dist/index4.cjs +1 -1
  76. package/dist/index4.js +19 -18
  77. package/dist/index40.cjs +1 -1
  78. package/dist/index40.js +8 -171
  79. package/dist/index41.cjs +1 -1
  80. package/dist/index41.js +19 -102
  81. package/dist/index42.cjs +1 -1
  82. package/dist/index42.js +41 -21
  83. package/dist/index43.cjs +1 -1
  84. package/dist/index43.js +25 -17
  85. package/dist/index44.cjs +1 -1
  86. package/dist/index44.js +6 -7
  87. package/dist/index45.cjs +1 -1
  88. package/dist/index45.js +12 -20
  89. package/dist/index46.cjs +1 -1
  90. package/dist/index46.js +15 -8
  91. package/dist/index47.cjs +1 -1
  92. package/dist/index47.js +5 -31
  93. package/dist/index48.cjs +1 -1
  94. package/dist/index48.js +13 -26
  95. package/dist/index49.cjs +1 -2
  96. package/dist/index49.js +10 -65
  97. package/dist/index50.cjs +1 -1
  98. package/dist/index50.js +12 -51
  99. package/dist/index51.cjs +1 -1
  100. package/dist/index51.js +11 -12
  101. package/dist/index52.cjs +1 -1
  102. package/dist/index52.js +13 -24
  103. package/dist/index53.cjs +1 -1
  104. package/dist/index53.js +55 -75
  105. package/dist/index54.cjs +1 -1
  106. package/dist/index54.js +16 -7
  107. package/dist/index55.cjs +1 -1
  108. package/dist/index55.js +5 -32
  109. package/dist/index56.cjs +1 -1
  110. package/dist/index56.js +8 -15
  111. package/dist/index57.cjs +1 -1
  112. package/dist/index57.js +172 -2
  113. package/dist/index58.cjs +1 -1
  114. package/dist/index58.js +102 -7
  115. package/dist/index59.cjs +1 -1
  116. package/dist/index59.js +21 -20
  117. package/dist/index60.cjs +1 -1
  118. package/dist/index60.js +1 -1
  119. package/dist/index62.cjs +1 -1
  120. package/dist/index62.js +6 -112
  121. package/dist/index63.cjs +2 -1
  122. package/dist/index63.js +58 -15
  123. package/dist/index64.cjs +1 -1
  124. package/dist/index64.js +2 -224
  125. package/dist/index65.cjs +1 -2
  126. package/dist/index65.js +5 -58
  127. package/dist/index66.cjs +1 -1
  128. package/dist/index66.js +4 -21
  129. package/dist/index67.cjs +1 -1
  130. package/dist/index67.js +11 -40
  131. package/dist/index68.cjs +5 -1
  132. package/dist/index68.js +51 -29
  133. package/dist/index69.cjs +2 -1
  134. package/dist/index69.js +31 -66
  135. package/dist/index70.cjs +1 -1
  136. package/dist/index70.js +5 -67
  137. package/dist/index71.cjs +1 -1
  138. package/dist/index71.js +4 -2
  139. package/dist/index72.cjs +1 -1
  140. package/dist/index72.js +18 -228
  141. package/dist/index73.cjs +1 -1
  142. package/dist/index73.js +8 -18
  143. package/dist/index74.cjs +1 -1
  144. package/dist/index74.js +10 -42
  145. package/dist/index75.cjs +1 -1
  146. package/dist/index75.js +11 -4
  147. package/dist/index76.cjs +1 -1
  148. package/dist/index76.js +6 -3
  149. package/dist/index77.cjs +1 -1
  150. package/dist/index77.js +13 -8
  151. package/dist/index78.cjs +1 -1
  152. package/dist/index78.js +30 -102
  153. package/dist/index79.cjs +1 -1
  154. package/dist/index79.js +14 -17
  155. package/dist/index80.cjs +1 -1
  156. package/dist/index80.js +64 -8
  157. package/dist/index81.cjs +1 -1
  158. package/dist/index81.js +26 -9
  159. package/dist/index82.cjs +1 -1
  160. package/dist/index82.js +3 -12
  161. package/dist/index83.cjs +1 -1
  162. package/dist/index83.js +3 -13
  163. package/dist/index84.cjs +1 -1
  164. package/dist/index84.js +8 -6
  165. package/dist/index85.cjs +1 -1
  166. package/dist/index85.js +185 -72
  167. package/dist/index86.cjs +1 -1
  168. package/dist/index86.js +18 -14
  169. package/dist/index87.cjs +1 -1
  170. package/dist/index87.js +39 -17
  171. package/dist/index88.cjs +1 -1
  172. package/dist/index88.js +34 -191
  173. package/dist/index89.cjs +1 -1
  174. package/dist/index89.js +66 -61
  175. package/dist/index9.cjs +1 -1
  176. package/dist/index9.js +49 -41
  177. package/dist/index90.cjs +1 -1
  178. package/dist/index90.js +113 -2
  179. package/dist/index91.cjs +1 -1
  180. package/dist/index91.js +66 -5
  181. package/dist/index92.cjs +1 -1
  182. package/dist/index92.js +2 -12
  183. package/dist/index93.cjs +1 -5
  184. package/dist/index93.js +15 -55
  185. package/dist/index94.cjs +1 -2
  186. package/dist/index94.js +220 -31
  187. package/dist/index95.cjs +1 -1
  188. package/dist/index95.js +231 -5
  189. package/dist/index96.cjs +1 -1
  190. package/dist/index96.js +42 -3
  191. package/dist/index97.cjs +1 -1
  192. package/dist/index97.js +104 -6
  193. package/dist/index98.cjs +1 -1
  194. package/dist/index98.js +16 -31
  195. package/dist/index99.cjs +1 -1
  196. package/dist/index99.js +75 -24
  197. package/dist/src/lib/utils.d.ts +1 -1
  198. package/package.json +1 -1
package/dist/index78.js CHANGED
@@ -1,107 +1,35 @@
1
- import { anumber as d, aexists as k, abytes as B, aoutput as A } from "./index68.js";
2
- import { rotlSH as H, rotlSL as m, rotlBH as S, rotlBL as T, split as F } from "./index107.js";
3
- import { wrapConstructor as X, Hash as E, u32 as U, isLE as x, byteSwap32 as I, toBytes as P } from "./index69.js";
4
- const y = [], L = [], b = [], M = /* @__PURE__ */ BigInt(0), f = /* @__PURE__ */ BigInt(1), R = /* @__PURE__ */ BigInt(2), j = /* @__PURE__ */ BigInt(7), C = /* @__PURE__ */ BigInt(256), q = /* @__PURE__ */ BigInt(113);
5
- for (let e = 0, t = f, s = 1, n = 0; e < 24; e++) {
6
- [s, n] = [n, (2 * s + 3 * n) % 5], y.push(2 * (5 * n + s)), L.push((e + 1) * (e + 2) / 2 % 64);
7
- let o = M;
8
- for (let r = 0; r < 7; r++)
9
- t = (t << f ^ (t >> j) * q) % C, t & R && (o ^= f << (f << /* @__PURE__ */ BigInt(r)) - f);
10
- b.push(o);
11
- }
12
- const [v, z] = /* @__PURE__ */ F(b, !0), O = (e, t, s) => s > 32 ? S(e, t, s) : H(e, t, s), w = (e, t, s) => s > 32 ? T(e, t, s) : m(e, t, s);
13
- function D(e, t = 24) {
14
- const s = new Uint32Array(10);
15
- for (let n = 24 - t; n < 24; n++) {
16
- for (let i = 0; i < 10; i++)
17
- s[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
18
- for (let i = 0; i < 10; i += 2) {
19
- const h = (i + 8) % 10, l = (i + 2) % 10, u = s[l], c = s[l + 1], _ = O(u, c, 1) ^ s[h], g = w(u, c, 1) ^ s[h + 1];
20
- for (let a = 0; a < 50; a += 10)
21
- e[i + a] ^= _, e[i + a + 1] ^= g;
22
- }
23
- let o = e[2], r = e[3];
24
- for (let i = 0; i < 24; i++) {
25
- const h = L[i], l = O(o, r, h), u = w(o, r, h), c = y[i];
26
- o = e[c], r = e[c + 1], e[c] = l, e[c + 1] = u;
27
- }
28
- for (let i = 0; i < 50; i += 10) {
29
- for (let h = 0; h < 10; h++)
30
- s[h] = e[i + h];
31
- for (let h = 0; h < 10; h++)
32
- e[i + h] ^= ~s[(h + 2) % 10] & s[(h + 4) % 10];
1
+ import { maxBytesPerTransaction as y, bytesPerBlob as a, fieldElementsPerBlob as f, bytesPerFieldElement as p } from "./index114.js";
2
+ import { EmptyBlobError as c, BlobSizeTooLargeError as h } from "./index112.js";
3
+ import { createCursor as B } from "./index109.js";
4
+ import { size as u } from "./index66.js";
5
+ import { hexToBytes as x } from "./index53.js";
6
+ import { bytesToHex as d } from "./index25.js";
7
+ function S(e) {
8
+ const m = e.to ?? (typeof e.data == "string" ? "hex" : "bytes"), i = typeof e.data == "string" ? x(e.data) : e.data, o = u(i);
9
+ if (!o)
10
+ throw new c();
11
+ if (o > y)
12
+ throw new h({
13
+ maxSize: y,
14
+ size: o
15
+ });
16
+ const s = [];
17
+ let n = !0, r = 0;
18
+ for (; n; ) {
19
+ const t = B(new Uint8Array(a));
20
+ let l = 0;
21
+ for (; l < f; ) {
22
+ const b = i.slice(r, r + (p - 1));
23
+ if (t.pushByte(0), t.pushBytes(b), b.length < 31) {
24
+ t.pushByte(128), n = !1;
25
+ break;
26
+ }
27
+ l++, r += 31;
33
28
  }
34
- e[0] ^= v[n], e[1] ^= z[n];
35
- }
36
- s.fill(0);
37
- }
38
- class p extends E {
39
- // NOTE: we accept arguments in bytes instead of bits here.
40
- constructor(t, s, n, o = !1, r = 24) {
41
- 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, d(n), 0 >= this.blockLen || this.blockLen >= 200)
42
- throw new Error("Sha3 supports only keccak-f1600 function");
43
- this.state = new Uint8Array(200), this.state32 = U(this.state);
44
- }
45
- keccak() {
46
- x || I(this.state32), D(this.state32, this.rounds), x || I(this.state32), this.posOut = 0, this.pos = 0;
47
- }
48
- update(t) {
49
- k(this);
50
- const { blockLen: s, state: n } = this;
51
- t = P(t);
52
- const o = t.length;
53
- for (let r = 0; r < o; ) {
54
- const i = Math.min(s - this.pos, o - r);
55
- for (let h = 0; h < i; h++)
56
- n[this.pos++] ^= t[r++];
57
- this.pos === s && this.keccak();
58
- }
59
- return this;
60
- }
61
- finish() {
62
- if (this.finished)
63
- return;
64
- this.finished = !0;
65
- const { state: t, suffix: s, pos: n, blockLen: o } = this;
66
- t[n] ^= s, s & 128 && n === o - 1 && this.keccak(), t[o - 1] ^= 128, this.keccak();
67
- }
68
- writeInto(t) {
69
- k(this, !1), B(t), this.finish();
70
- const s = this.state, { blockLen: n } = this;
71
- for (let o = 0, r = t.length; o < r; ) {
72
- this.posOut >= n && this.keccak();
73
- const i = Math.min(n - this.posOut, r - o);
74
- t.set(s.subarray(this.posOut, this.posOut + i), o), this.posOut += i, o += i;
75
- }
76
- return t;
77
- }
78
- xofInto(t) {
79
- if (!this.enableXOF)
80
- throw new Error("XOF is not possible for this instance");
81
- return this.writeInto(t);
82
- }
83
- xof(t) {
84
- return d(t), this.xofInto(new Uint8Array(t));
85
- }
86
- digestInto(t) {
87
- if (A(t, this), this.finished)
88
- throw new Error("digest() was already called");
89
- return this.writeInto(t), this.destroy(), t;
90
- }
91
- digest() {
92
- return this.digestInto(new Uint8Array(this.outputLen));
93
- }
94
- destroy() {
95
- this.destroyed = !0, this.state.fill(0);
96
- }
97
- _cloneInto(t) {
98
- const { blockLen: s, suffix: n, outputLen: o, rounds: r, enableXOF: i } = this;
99
- return t || (t = new p(s, n, o, i, 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 = i, t.destroyed = this.destroyed, t;
29
+ s.push(t);
100
30
  }
31
+ return m === "bytes" ? s.map((t) => t.bytes) : s.map((t) => d(t.bytes));
101
32
  }
102
- const G = (e, t, s) => X(() => new p(t, e, s)), Q = /* @__PURE__ */ G(1, 136, 256 / 8);
103
33
  export {
104
- p as Keccak,
105
- D as keccakP,
106
- Q as keccak_256
34
+ S as toBlobs
107
35
  };
package/dist/index79.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index24.cjs"),c=require("./index40.cjs");function u(t){if(!t||t.length===0)return[];const e=[];for(const r of t){const{chainId:i,nonce:o,...s}=r,a=r.address;e.push([i?n.toHex(i):"0x",a,o?n.toHex(o):"0x",...c.toYParitySignatureArray({},s)])}return e}exports.serializeAuthorizationList=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index30.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;
package/dist/index79.js CHANGED
@@ -1,20 +1,17 @@
1
- import { toHex as i } from "./index24.js";
2
- import { toYParitySignatureArray as c } from "./index40.js";
3
- function f(r) {
4
- if (!r || r.length === 0)
5
- return [];
6
- const t = [];
7
- for (const o of r) {
8
- const { chainId: n, nonce: e, ...s } = o, a = o.address;
9
- t.push([
10
- n ? i(n) : "0x",
11
- a,
12
- e ? i(e) : "0x",
13
- ...c({}, s)
14
- ]);
15
- }
16
- return t;
1
+ import { InvalidSerializableTransactionError as f } from "./index30.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 });
17
14
  }
18
15
  export {
19
- f as serializeAuthorizationList
16
+ d as getTransactionType
20
17
  };
package/dist/index80.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index36.cjs"),l=require("./index24.cjs");function c(o){const{kzg:s}=o,n=o.to??(typeof o.blobs[0]=="string"?"hex":"bytes"),e=typeof o.blobs[0]=="string"?o.blobs.map(t=>i.hexToBytes(t)):o.blobs,b=[];for(const t of e)b.push(Uint8Array.from(s.blobToKzgCommitment(t)));return n==="bytes"?b:b.map(t=>l.bytesToHex(t))}exports.blobsToCommitments=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index68.cjs"),z=require("./index50.cjs"),o=require("./index81.cjs"),T=require("./index51.cjs"),u=require("./index66.cjs"),q=require("./index25.cjs"),g=require("./index82.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/index80.js CHANGED
@@ -1,11 +1,67 @@
1
- import { hexToBytes as i } from "./index36.js";
2
- import { bytesToHex as f } from "./index24.js";
3
- function y(o) {
4
- const { kzg: s } = o, n = o.to ?? (typeof o.blobs[0] == "string" ? "hex" : "bytes"), m = typeof o.blobs[0] == "string" ? o.blobs.map((t) => i(t)) : o.blobs, b = [];
5
- for (const t of m)
6
- b.push(Uint8Array.from(s.blobToKzgCommitment(t)));
7
- return n === "bytes" ? b : b.map((t) => f(t));
1
+ import { BytesSizeMismatchError as m } from "./index68.js";
2
+ import { InvalidAddressError as w } from "./index50.js";
3
+ import { InvalidDomainError as E, InvalidPrimaryTypeError as z, InvalidStructTypeError as D } from "./index81.js";
4
+ import { isAddress as T } from "./index51.js";
5
+ import { size as y } from "./index66.js";
6
+ import { numberToHex as x } from "./index25.js";
7
+ import { integerRegex as P, bytesRegex as S } from "./index82.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));
32
+ }
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 });
44
+ }
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);
59
+ }
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 });
8
63
  }
9
64
  export {
10
- y as blobsToCommitments
65
+ F as getTypesForEIP712Domain,
66
+ j as validateTypedData
11
67
  };
package/dist/index81.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index36.cjs"),y=require("./index24.cjs");function f(t){const{kzg:c}=t,e=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(o=>b.hexToBytes(o)):t.blobs,i=typeof t.commitments[0]=="string"?t.commitments.map(o=>b.hexToBytes(o)):t.commitments,s=[];for(let o=0;o<n.length;o++){const l=n[o],m=i[o];s.push(Uint8Array.from(c.computeBlobKzgProof(l,m)))}return e==="bytes"?s:s.map(o=>y.bytesToHex(o))}exports.blobsToProofs=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index39.cjs"),e=require("./index63.cjs");class i extends e.BaseError{constructor({domain:r}){super(`Invalid domain "${s.stringify(r)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class o extends e.BaseError{constructor({primaryType:r,types:a}){super(`Invalid primary type \`${r}\` must be one of \`${JSON.stringify(Object.keys(a))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class n extends e.BaseError{constructor({type:r}){super(`Struct type "${r}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}exports.InvalidDomainError=i;exports.InvalidPrimaryTypeError=o;exports.InvalidStructTypeError=n;
package/dist/index81.js CHANGED
@@ -1,13 +1,30 @@
1
- import { hexToBytes as b } from "./index36.js";
2
- import { bytesToHex as y } from "./index24.js";
3
- function h(t) {
4
- const { kzg: m } = t, c = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), s = typeof t.blobs[0] == "string" ? t.blobs.map((o) => b(o)) : t.blobs, i = typeof t.commitments[0] == "string" ? t.commitments.map((o) => b(o)) : t.commitments, n = [];
5
- for (let o = 0; o < s.length; o++) {
6
- const f = s[o], l = i[o];
7
- n.push(Uint8Array.from(m.computeBlobKzgProof(f, l)));
1
+ import { stringify as a } from "./index39.js";
2
+ import { BaseError as t } from "./index63.js";
3
+ class n extends t {
4
+ constructor({ domain: r }) {
5
+ super(`Invalid domain "${a(r)}".`, {
6
+ metaMessages: ["Must be a valid EIP-712 domain."]
7
+ });
8
+ }
9
+ }
10
+ class p extends t {
11
+ constructor({ primaryType: r, types: s }) {
12
+ super(`Invalid primary type \`${r}\` must be one of \`${JSON.stringify(Object.keys(s))}\`.`, {
13
+ docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror",
14
+ metaMessages: ["Check that the primary type is a key in `types`."]
15
+ });
16
+ }
17
+ }
18
+ class y extends t {
19
+ constructor({ type: r }) {
20
+ super(`Struct type "${r}" is invalid.`, {
21
+ metaMessages: ["Struct type must not be a Solidity type."],
22
+ name: "InvalidStructTypeError"
23
+ });
8
24
  }
9
- return c === "bytes" ? n : n.map((o) => y(o));
10
25
  }
11
26
  export {
12
- h as blobsToProofs
27
+ n as InvalidDomainError,
28
+ p as InvalidPrimaryTypeError,
29
+ y as InvalidStructTypeError
13
30
  };
package/dist/index82.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index97.cjs");function c(o){const{commitments:e,version:s}=o,n=o.to??(typeof e[0]=="string"?"hex":"bytes"),t=[];for(const m of e)t.push(i.commitmentToVersionedHash({commitment:m,to:n,version:s}));return t}exports.commitmentsToVersionedHashes=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,t=/^(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)?$/;exports.bytesRegex=e;exports.integerRegex=t;
package/dist/index82.js CHANGED
@@ -1,14 +1,5 @@
1
- import { commitmentToVersionedHash as i } from "./index97.js";
2
- function r(o) {
3
- const { commitments: t, version: n } = o, e = o.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
4
- for (const m of t)
5
- s.push(i({
6
- commitment: m,
7
- to: e,
8
- version: n
9
- }));
10
- return s;
11
- }
1
+ const e = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, t = /^(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)?$/;
12
2
  export {
13
- r as commitmentsToVersionedHashes
3
+ e as bytesRegex,
4
+ t as integerRegex
14
5
  };
package/dist/index83.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index80.cjs"),m=require("./index81.cjs"),u=require("./index98.cjs");function f(t){const{data:i,kzg:n,to:b}=t,s=t.blobs??u.toBlobs({data:i,to:b}),e=t.commitments??r.blobsToCommitments({blobs:s,kzg:n,to:b}),l=t.proofs??m.blobsToProofs({blobs:s,commitments:e,kzg:n,to:b}),c=[];for(let o=0;o<s.length;o++)c.push({blob:s[o],commitment:e[o],proof:l[o]});return c}exports.toBlobSidecars=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}exports.isHex=r;
package/dist/index83.js CHANGED
@@ -1,16 +1,6 @@
1
- import { blobsToCommitments as f } from "./index80.js";
2
- import { blobsToProofs as l } from "./index81.js";
3
- import { toBlobs as p } from "./index98.js";
4
- function k(t) {
5
- const { data: i, kzg: n, to: m } = t, s = t.blobs ?? p({ data: i, to: m }), b = t.commitments ?? f({ blobs: s, kzg: n, to: m }), r = t.proofs ?? l({ blobs: s, commitments: b, kzg: n, to: m }), c = [];
6
- for (let o = 0; o < s.length; o++)
7
- c.push({
8
- blob: s[o],
9
- commitment: b[o],
10
- proof: r[o]
11
- });
12
- return c;
1
+ function e(t, { strict: r = !0 } = {}) {
2
+ return !t || typeof t != "string" ? !1 : r ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x");
13
3
  }
14
4
  export {
15
- k as toBlobSidecars
5
+ e as isHex
16
6
  };
package/dist/index84.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(e,{dir:i="left"}={}){let t=typeof e=="string"?e.replace("0x",""):e,n=0;for(let l=0;l<t.length-1&&t[i==="left"?l:t.length-l-1].toString()==="0";l++)n++;return t=i==="left"?t.slice(n):t.slice(0,t.length-n),typeof e=="string"?(t.length===1&&i==="right"&&(t=`${t}0`),`0x${t.length%2===1?`0${t}`:t}`):t}exports.trim=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index115.cjs"),o=require("./index86.cjs"),s=require("./index66.cjs"),r=require("./index25.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;
package/dist/index84.js CHANGED
@@ -1,9 +1,11 @@
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 { presignMessagePrefix as e } from "./index115.js";
2
+ import { concat as n } from "./index86.js";
3
+ import { size as f } from "./index66.js";
4
+ import { stringToHex as o, bytesToHex as p } from "./index25.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]);
6
8
  }
7
9
  export {
8
- f as trim
10
+ u as toPrefixedMessage
9
11
  };
package/dist/index85.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index109.cjs"),w=require("./index110.cjs"),t=require("./index32.cjs"),P=require("./index65.cjs"),h=require("./index111.cjs"),d=require("./index91.cjs"),n=require("./index94.cjs"),c=require("./index33.cjs"),I=require("./index75.cjs"),u=require("./index112.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 f=require("./index68.cjs"),g=require("./index50.cjs"),l=require("./index63.cjs"),b=require("./index60.cjs"),x=require("./index51.cjs"),u=require("./index86.cjs"),d=require("./index61.cjs"),y=require("./index66.cjs"),A=require("./index105.cjs"),a=require("./index25.cjs"),z=require("./index82.cjs");function w(e,n){if(e.length!==n.length)throw new f.AbiEncodingLengthMismatchError({expectedLength:e.length,givenLength:n.length});const o=H({params:e,values:n}),t=p(o);return t.length===0?"0x":t}function H({params:e,values:n}){const o=[];for(let t=0;t<e.length;t++)o.push(h({param:e[t],value:n[t]}));return o}function h({param:e,value:n}){const o=m(e.type);if(o){const[t,r]=o;return P(n,{length:t,param:{...e,type:r}})}if(e.type==="tuple")return L(n,{param:e});if(e.type==="address")return E(n);if(e.type==="bool")return q(n);if(e.type.startsWith("uint")||e.type.startsWith("int")){const t=e.type.startsWith("int"),[,,r="256"]=z.integerRegex.exec(e.type)??[];return T(n,{signed:t,size:Number(r)})}if(e.type.startsWith("bytes"))return S(n,{param:e});if(e.type==="string")return I(n);throw new f.InvalidAbiEncodingTypeError(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function p(e){let n=0;for(let i=0;i<e.length;i++){const{dynamic:c,encoded:s}=e[i];c?n+=32:n+=y.size(s)}const o=[],t=[];let r=0;for(let i=0;i<e.length;i++){const{dynamic:c,encoded:s}=e[i];c?(o.push(a.numberToHex(n+r,{size:32})),t.push(s),r+=y.size(s)):o.push(s)}return u.concat([...o,...t])}function E(e){if(!x.isAddress(e))throw new g.InvalidAddressError({address:e});return{dynamic:!1,encoded:d.padHex(e.toLowerCase())}}function P(e,{length:n,param:o}){const t=n===null;if(!Array.isArray(e))throw new f.InvalidArrayError(e);if(!t&&e.length!==n)throw new f.AbiEncodingArrayLengthMismatchError({expectedLength:n,givenLength:e.length,type:`${o.type}[${n}]`});let r=!1;const i=[];for(let c=0;c<e.length;c++){const s=h({param:o,value:e[c]});s.dynamic&&(r=!0),i.push(s)}if(t||r){const c=p(i);if(t){const s=a.numberToHex(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?u.concat([s,c]):s}}if(r)return{dynamic:!0,encoded:c}}return{dynamic:!1,encoded:u.concat(i.map(({encoded:c})=>c))}}function S(e,{param:n}){const[,o]=n.type.split("bytes"),t=y.size(e);if(!o){let r=e;return t%32!==0&&(r=d.padHex(r,{dir:"right",size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:u.concat([d.padHex(a.numberToHex(t,{size:32})),r])}}if(t!==Number.parseInt(o))throw new f.AbiEncodingBytesSizeMismatchError({expectedSize:Number.parseInt(o),value:e});return{dynamic:!1,encoded:d.padHex(e,{dir:"right"})}}function q(e){if(typeof e!="boolean")throw new l.BaseError(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:d.padHex(a.boolToHex(e))}}function T(e,{signed:n,size:o=256}){if(typeof o=="number"){const t=2n**(BigInt(o)-(n?1n:0n))-1n,r=n?-t-1n:0n;if(e>t||e<r)throw new b.IntegerOutOfRangeError({max:t.toString(),min:r.toString(),signed:n,size:o/8,value:e.toString()})}return{dynamic:!1,encoded:a.numberToHex(e,{size:32,signed:n})}}function I(e){const n=a.stringToHex(e),o=Math.ceil(y.size(n)/32),t=[];for(let r=0;r<o;r++)t.push(d.padHex(A.slice(n,r*32,(r+1)*32),{dir:"right"}));return{dynamic:!0,encoded:u.concat([d.padHex(a.numberToHex(y.size(n),{size:32})),...t])}}function L(e,{param:n}){let o=!1;const t=[];for(let r=0;r<n.components.length;r++){const i=n.components[r],c=Array.isArray(e)?r:i.name,s=h({param:i,value:e[c]});t.push(s),s.dynamic&&(o=!0)}return{dynamic:o,encoded:o?p(t):u.concat(t.map(({encoded:r})=>r))}}function m(e){const n=e.match(/^(.*)\[(\d+)?\]$/);return n?[n[2]?Number(n[2]):null,n[1]]:void 0}exports.encodeAbiParameters=w;exports.getArrayComponents=m;