@gardenfi/utils 2.1.2-beta.0 → 2.1.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +28 -27
  3. package/dist/index100.cjs +1 -1
  4. package/dist/index100.js +5 -19
  5. package/dist/index101.cjs +2 -1
  6. package/dist/index101.js +3 -12
  7. package/dist/index102.cjs +1 -1
  8. package/dist/index102.js +17 -18
  9. package/dist/index103.cjs +1 -1
  10. package/dist/index103.js +641 -6
  11. package/dist/index104.cjs +1 -1
  12. package/dist/index104.js +170 -10
  13. package/dist/index18.cjs +1 -1
  14. package/dist/index18.js +12 -93
  15. package/dist/index19.cjs +1 -1
  16. package/dist/index19.js +9 -9
  17. package/dist/index20.cjs +1 -1
  18. package/dist/index20.js +1 -1
  19. package/dist/index21.cjs +1 -1
  20. package/dist/index21.js +3 -3
  21. package/dist/index22.cjs +1 -1
  22. package/dist/index22.js +1 -1
  23. package/dist/index23.cjs +2 -1
  24. package/dist/index23.js +50 -17
  25. package/dist/index24.cjs +1 -1
  26. package/dist/index24.js +24 -7
  27. package/dist/index25.cjs +1 -1
  28. package/dist/index25.js +40 -44
  29. package/dist/index26.cjs +1 -1
  30. package/dist/index26.js +45 -21
  31. package/dist/index27.cjs +1 -1
  32. package/dist/index27.js +25 -8
  33. package/dist/index28.cjs +1 -1
  34. package/dist/index28.js +6 -31
  35. package/dist/index29.cjs +1 -1
  36. package/dist/index29.js +13 -26
  37. package/dist/index30.cjs +1 -2
  38. package/dist/index30.js +15 -65
  39. package/dist/index31.cjs +1 -1
  40. package/dist/index31.js +5 -51
  41. package/dist/index32.cjs +1 -1
  42. package/dist/index32.js +13 -12
  43. package/dist/index33.cjs +1 -1
  44. package/dist/index33.js +10 -24
  45. package/dist/index34.cjs +1 -1
  46. package/dist/index34.js +11 -74
  47. package/dist/index35.cjs +1 -1
  48. package/dist/index35.js +11 -23
  49. package/dist/index36.cjs +1 -1
  50. package/dist/index36.js +13 -7
  51. package/dist/index37.cjs +1 -1
  52. package/dist/index37.js +23 -32
  53. package/dist/index38.cjs +1 -1
  54. package/dist/index38.js +55 -15
  55. package/dist/index39.cjs +1 -1
  56. package/dist/index39.js +17 -2
  57. package/dist/index4.cjs +1 -1
  58. package/dist/index4.js +33 -23
  59. package/dist/index40.cjs +1 -1
  60. package/dist/index40.js +5 -8
  61. package/dist/index41.cjs +1 -1
  62. package/dist/index41.js +8 -20
  63. package/dist/index42.cjs +1 -1
  64. package/dist/index42.js +169 -39
  65. package/dist/index43.cjs +1 -1
  66. package/dist/index43.js +102 -24
  67. package/dist/index44.cjs +1 -1
  68. package/dist/index44.js +21 -6
  69. package/dist/index45.cjs +1 -1
  70. package/dist/index45.js +12 -13
  71. package/dist/index46.cjs +1 -1
  72. package/dist/index46.js +34 -15
  73. package/dist/index47.cjs +1 -1
  74. package/dist/index47.js +6 -5
  75. package/dist/index48.cjs +2 -1
  76. package/dist/index48.js +59 -13
  77. package/dist/index49.cjs +1 -1
  78. package/dist/index49.js +2 -11
  79. package/dist/index50.cjs +1 -1
  80. package/dist/index50.js +5 -11
  81. package/dist/index51.cjs +1 -1
  82. package/dist/index51.js +4 -11
  83. package/dist/index52.cjs +1 -1
  84. package/dist/index52.js +11 -13
  85. package/dist/index53.cjs +1 -1
  86. package/dist/index53.js +7 -55
  87. package/dist/index54.cjs +5 -1
  88. package/dist/index54.js +56 -16
  89. package/dist/index55.cjs +2 -1
  90. package/dist/index55.js +34 -5
  91. package/dist/index56.cjs +1 -1
  92. package/dist/index56.js +5 -8
  93. package/dist/index57.cjs +1 -1
  94. package/dist/index57.js +2 -172
  95. package/dist/index58.cjs +1 -1
  96. package/dist/index58.js +19 -101
  97. package/dist/index59.cjs +1 -1
  98. package/dist/index59.js +8 -21
  99. package/dist/index60.cjs +1 -1
  100. package/dist/index60.js +9 -11
  101. package/dist/index61.cjs +1 -1
  102. package/dist/index61.js +11 -34
  103. package/dist/index62.cjs +1 -1
  104. package/dist/index62.js +6 -6
  105. package/dist/index63.cjs +1 -2
  106. package/dist/index63.js +13 -59
  107. package/dist/index64.cjs +1 -1
  108. package/dist/index64.js +33 -2
  109. package/dist/index65.cjs +1 -1
  110. package/dist/index65.js +14 -6
  111. package/dist/index66.cjs +1 -1
  112. package/dist/index66.js +64 -4
  113. package/dist/index67.cjs +1 -1
  114. package/dist/index67.js +27 -11
  115. package/dist/index68.cjs +1 -5
  116. package/dist/index68.js +3 -57
  117. package/dist/index69.cjs +1 -2
  118. package/dist/index69.js +3 -34
  119. package/dist/index70.cjs +1 -1
  120. package/dist/index70.js +8 -5
  121. package/dist/index71.cjs +1 -1
  122. package/dist/index71.js +191 -3
  123. package/dist/index72.cjs +1 -1
  124. package/dist/index72.js +18 -21
  125. package/dist/index73.cjs +1 -1
  126. package/dist/index73.js +40 -8
  127. package/dist/index74.cjs +1 -1
  128. package/dist/index74.js +34 -10
  129. package/dist/index75.cjs +1 -1
  130. package/dist/index75.js +69 -11
  131. package/dist/index76.cjs +1 -1
  132. package/dist/index76.js +112 -6
  133. package/dist/index77.cjs +1 -1
  134. package/dist/index77.js +67 -13
  135. package/dist/index78.cjs +1 -1
  136. package/dist/index78.js +2 -33
  137. package/dist/index79.cjs +1 -1
  138. package/dist/index79.js +16 -14
  139. package/dist/index80.cjs +1 -1
  140. package/dist/index80.js +217 -58
  141. package/dist/index81.cjs +1 -1
  142. package/dist/index81.js +227 -23
  143. package/dist/index82.cjs +1 -1
  144. package/dist/index82.js +43 -3
  145. package/dist/index83.cjs +1 -1
  146. package/dist/index83.js +104 -3
  147. package/dist/index84.cjs +1 -1
  148. package/dist/index84.js +17 -8
  149. package/dist/index85.cjs +1 -1
  150. package/dist/index85.js +72 -185
  151. package/dist/index86.cjs +1 -1
  152. package/dist/index86.js +18 -18
  153. package/dist/index87.cjs +1 -1
  154. package/dist/index87.js +10 -39
  155. package/dist/index88.cjs +1 -1
  156. package/dist/index88.js +17 -32
  157. package/dist/index89.cjs +1 -1
  158. package/dist/index89.js +9 -66
  159. package/dist/index90.cjs +1 -1
  160. package/dist/index90.js +8 -112
  161. package/dist/index91.cjs +1 -1
  162. package/dist/index91.js +35 -64
  163. package/dist/index92.cjs +1 -1
  164. package/dist/index92.js +2 -2
  165. package/dist/index93.cjs +1 -1
  166. package/dist/index93.js +5 -17
  167. package/dist/index94.cjs +1 -1
  168. package/dist/index94.js +10 -223
  169. package/dist/index95.cjs +1 -1
  170. package/dist/index95.js +125 -229
  171. package/dist/index96.cjs +1 -1
  172. package/dist/index96.js +6 -42
  173. package/dist/index97.cjs +1 -1
  174. package/dist/index97.js +2 -105
  175. package/dist/index98.cjs +1 -1
  176. package/dist/index98.js +36 -16
  177. package/dist/index99.cjs +1 -1
  178. package/dist/index99.js +17 -75
  179. package/dist/src/lib/approve.d.ts +2 -1
  180. package/package.json +1 -1
  181. package/dist/index105.cjs +0 -1
  182. package/dist/index105.js +0 -41
  183. package/dist/index106.cjs +0 -1
  184. package/dist/index106.js +0 -7
  185. package/dist/index107.cjs +0 -1
  186. package/dist/index107.js +0 -13
  187. package/dist/index108.cjs +0 -1
  188. package/dist/index108.js +0 -4
  189. package/dist/index109.cjs +0 -1
  190. package/dist/index109.js +0 -130
  191. package/dist/index110.cjs +0 -1
  192. package/dist/index110.js +0 -9
  193. package/dist/index111.cjs +0 -1
  194. package/dist/index111.js +0 -4
  195. package/dist/index112.cjs +0 -1
  196. package/dist/index112.js +0 -40
  197. package/dist/index113.cjs +0 -1
  198. package/dist/index113.js +0 -23
  199. package/dist/index114.cjs +0 -1
  200. package/dist/index114.js +0 -7
  201. package/dist/index115.cjs +0 -2
  202. package/dist/index115.js +0 -5
  203. package/dist/index116.cjs +0 -1
  204. package/dist/index116.js +0 -21
  205. package/dist/index117.cjs +0 -1
  206. package/dist/index117.js +0 -646
  207. package/dist/index118.cjs +0 -1
  208. package/dist/index118.js +0 -175
package/dist/index43.js CHANGED
@@ -1,28 +1,106 @@
1
- import { InvalidAddressError as s } from "./index50.js";
2
- import { isAddress as a } from "./index51.js";
3
- function r(n) {
4
- if (typeof n == "string") {
5
- if (!a(n, { strict: !1 }))
6
- throw new s({ address: n });
7
- return {
8
- address: n,
9
- type: "json-rpc"
10
- };
11
- }
12
- if (!a(n.address, { strict: !1 }))
13
- throw new s({ address: n.address });
14
- return {
15
- address: n.address,
16
- nonceManager: n.nonceManager,
17
- sign: n.sign,
18
- signAuthorization: n.signAuthorization,
19
- signMessage: n.signMessage,
20
- signTransaction: n.signTransaction,
21
- signTypedData: n.signTypedData,
22
- source: "custom",
23
- type: "local"
1
+ import { encodeAbiParameters as p } from "./index71.js";
2
+ import { concat as h } from "./index72.js";
3
+ import { toHex as d } from "./index26.js";
4
+ import { keccak256 as c } from "./index41.js";
5
+ import { getTypesForEIP712Domain as T, validateTypedData as D } from "./index66.js";
6
+ function k(o) {
7
+ const { domain: t = {}, message: e, primaryType: n } = o, r = {
8
+ EIP712Domain: T({ domain: t }),
9
+ ...o.types
24
10
  };
11
+ D({
12
+ domain: t,
13
+ message: e,
14
+ primaryType: n,
15
+ types: r
16
+ });
17
+ const a = ["0x1901"];
18
+ return t && a.push(b({
19
+ domain: t,
20
+ types: r
21
+ })), n !== "EIP712Domain" && a.push(f({
22
+ data: e,
23
+ primaryType: n,
24
+ types: r
25
+ })), c(h(a));
26
+ }
27
+ function b({ domain: o, types: t }) {
28
+ return f({
29
+ data: o,
30
+ primaryType: "EIP712Domain",
31
+ types: t
32
+ });
33
+ }
34
+ function f({ data: o, primaryType: t, types: e }) {
35
+ const n = m({
36
+ data: o,
37
+ primaryType: t,
38
+ types: e
39
+ });
40
+ return c(n);
41
+ }
42
+ function m({ data: o, primaryType: t, types: e }) {
43
+ const n = [{ type: "bytes32" }], r = [l({ primaryType: t, types: e })];
44
+ for (const a of e[t]) {
45
+ const [i, s] = y({
46
+ types: e,
47
+ name: a.name,
48
+ type: a.type,
49
+ value: o[a.name]
50
+ });
51
+ n.push(i), r.push(s);
52
+ }
53
+ return p(n, r);
54
+ }
55
+ function l({ primaryType: o, types: t }) {
56
+ const e = d(x({ primaryType: o, types: t }));
57
+ return c(e);
58
+ }
59
+ function x({ primaryType: o, types: t }) {
60
+ let e = "";
61
+ const n = u({ primaryType: o, types: t });
62
+ n.delete(o);
63
+ const r = [o, ...Array.from(n).sort()];
64
+ for (const a of r)
65
+ e += `${a}(${t[a].map(({ name: i, type: s }) => `${s} ${i}`).join(",")})`;
66
+ return e;
67
+ }
68
+ function u({ primaryType: o, types: t }, e = /* @__PURE__ */ new Set()) {
69
+ const n = o.match(/^\w*/u), r = n == null ? void 0 : n[0];
70
+ if (e.has(r) || t[r] === void 0)
71
+ return e;
72
+ e.add(r);
73
+ for (const a of t[r])
74
+ u({ primaryType: a.type, types: t }, e);
75
+ return e;
76
+ }
77
+ function y({ types: o, name: t, type: e, value: n }) {
78
+ if (o[e] !== void 0)
79
+ return [
80
+ { type: "bytes32" },
81
+ c(m({ data: n, primaryType: e, types: o }))
82
+ ];
83
+ if (e === "bytes")
84
+ return n = `0x${(n.length % 2 ? "0" : "") + n.slice(2)}`, [{ type: "bytes32" }, c(n)];
85
+ if (e === "string")
86
+ return [{ type: "bytes32" }, c(d(n))];
87
+ if (e.lastIndexOf("]") === e.length - 1) {
88
+ const r = e.slice(0, e.lastIndexOf("[")), a = n.map((i) => y({
89
+ name: t,
90
+ type: r,
91
+ types: o,
92
+ value: i
93
+ }));
94
+ return [
95
+ { type: "bytes32" },
96
+ c(p(a.map(([i]) => i), a.map(([, i]) => i)))
97
+ ];
98
+ }
99
+ return [{ type: e }, n];
25
100
  }
26
101
  export {
27
- r as toAccount
102
+ x as encodeType,
103
+ b as hashDomain,
104
+ f as hashStruct,
105
+ k as hashTypedData
28
106
  };
package/dist/index44.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index59.cjs"),c=require("./index56.cjs");function t(e){const s=c.keccak256(`0x${e.substring(4)}`).substring(26);return r.checksumAddress(`0x${s}`)}exports.publicKeyToAddress=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index34.cjs"),f=require("./index38.cjs"),a=require("./index41.cjs"),l=require("./index58.cjs"),A=require("./index35.cjs"),o=new l.LruMap(8192);function u(s,t){if(o.has(`${s}.${t}`))return o.get(`${s}.${t}`);const c=s.substring(2).toLowerCase(),n=a.keccak256(f.stringToBytes(c),"bytes"),r=c.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(n[e>>1]&15)>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const i=`0x${r.join("")}`;return o.set(`${s}.${t}`,i),i}function g(s,t){if(!A.isAddress(s,{strict:!1}))throw new d.InvalidAddressError({address:s});return u(s,t)}exports.checksumAddress=u;exports.getAddress=g;
package/dist/index44.js CHANGED
@@ -1,9 +1,24 @@
1
- import { checksumAddress as e } from "./index59.js";
2
- import { keccak256 as o } from "./index56.js";
3
- function d(r) {
4
- const s = o(`0x${r.substring(4)}`).substring(26);
5
- return e(`0x${s}`);
1
+ import { InvalidAddressError as c } from "./index34.js";
2
+ import { stringToBytes as m } from "./index38.js";
3
+ import { keccak256 as p } from "./index41.js";
4
+ import { LruMap as u } from "./index58.js";
5
+ import { isAddress as $ } from "./index35.js";
6
+ const s = /* @__PURE__ */ new u(8192);
7
+ function h(t, o) {
8
+ if (s.has(`${t}.${o}`))
9
+ return s.get(`${t}.${o}`);
10
+ const i = t.substring(2).toLowerCase(), n = p(m(i), "bytes"), e = i.split("");
11
+ for (let r = 0; r < 40; r += 2)
12
+ n[r >> 1] >> 4 >= 8 && e[r] && (e[r] = e[r].toUpperCase()), (n[r >> 1] & 15) >= 8 && e[r + 1] && (e[r + 1] = e[r + 1].toUpperCase());
13
+ const f = `0x${e.join("")}`;
14
+ return s.set(`${t}.${o}`, f), f;
15
+ }
16
+ function w(t, o) {
17
+ if (!$(t, { strict: !1 }))
18
+ throw new c({ address: t });
19
+ return h(t, o);
6
20
  }
7
21
  export {
8
- d as publicKeyToAddress
22
+ h as checksumAddress,
23
+ w as getAddress
9
24
  };
package/dist/index45.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index42.cjs"),s=require("./index25.cjs"),a=require("./index52.cjs");let l=!1;async function g({hash:t,privateKey:i,to:e="object"}){const{r:u,s:c,recovery:r}=o.secp256k1.sign(t.slice(2),i.slice(2),{lowS:!0,extraEntropy:l}),n={r:s.numberToHex(u,{size:32}),s:s.numberToHex(c,{size:32}),v:r?28n:27n,yParity:r};return e==="bytes"||e==="hex"?a.serializeSignature({...n,to:e}):n}exports.sign=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index48.cjs");class i extends n.BaseError{constructor({max:e,min:r,signed:s,size:t,value:a}){super(`Number "${a}" is not in safe ${t?`${t*8}-bit ${s?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class u extends n.BaseError{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}exports.IntegerOutOfRangeError=i;exports.SizeOverflowError=u;
package/dist/index45.js CHANGED
@@ -1,16 +1,15 @@
1
- import { secp256k1 as u } from "./index42.js";
2
- import { numberToHex as i } from "./index25.js";
3
- import { serializeSignature as a } from "./index52.js";
4
- let m = !1;
5
- async function y({ hash: n, privateKey: s, to: r = "object" }) {
6
- const { r: o, s: c, recovery: e } = u.sign(n.slice(2), s.slice(2), { lowS: !0, extraEntropy: m }), t = {
7
- r: i(o, { size: 32 }),
8
- s: i(c, { size: 32 }),
9
- v: e ? 28n : 27n,
10
- yParity: e
11
- };
12
- return r === "bytes" || r === "hex" ? a({ ...t, to: r }) : t;
1
+ import { BaseError as t } from "./index48.js";
2
+ class $ extends t {
3
+ constructor({ max: e, min: r, signed: s, size: n, value: a }) {
4
+ super(`Number "${a}" is not in safe ${n ? `${n * 8}-bit ${s ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${r} to ${e})` : `(above ${r})`}`, { name: "IntegerOutOfRangeError" });
5
+ }
6
+ }
7
+ class c extends t {
8
+ constructor({ givenSize: e, maxSize: r }) {
9
+ super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" });
10
+ }
13
11
  }
14
12
  export {
15
- y as sign
13
+ $ as IntegerOutOfRangeError,
14
+ c as SizeOverflowError
16
15
  };
package/dist/index46.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index54.cjs"),a=require("./index45.cjs");async function u(t){const{chainId:n,nonce:i,privateKey:r,to:o="object"}=t,s=t.contractAddress??t.address,e=await a.sign({hash:c.hashAuthorization({address:s,chainId:n,nonce:i}),privateKey:r,to:o});return o==="object"?{address:s,chainId:n,nonce:i,...e}:e}exports.signAuthorization=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index89.cjs");function p(e,{dir:n,size:t=32}={}){return typeof e=="string"?o(e,{dir:n,size:t}):l(e,{dir:n,size:t})}function o(e,{dir:n,size:t=32}={}){if(t===null)return e;const r=e.replace("0x","");if(r.length>t*2)throw new i.SizeExceedsPaddingSizeError({size:Math.ceil(r.length/2),targetSize:t,type:"hex"});return`0x${r[n==="right"?"padEnd":"padStart"](t*2,"0")}`}function l(e,{dir:n,size:t=32}={}){if(t===null)return e;if(e.length>t)throw new i.SizeExceedsPaddingSizeError({size:e.length,targetSize:t,type:"bytes"});const r=new Uint8Array(t);for(let a=0;a<t;a++){const d=n==="right";r[d?a:t-a-1]=e[d?a:e.length-a-1]}return r}exports.pad=p;exports.padBytes=l;exports.padHex=o;
package/dist/index46.js CHANGED
@@ -1,18 +1,37 @@
1
- import { hashAuthorization as a } from "./index54.js";
2
- import { sign as e } from "./index45.js";
3
- async function u(t) {
4
- const { chainId: o, nonce: n, privateKey: c, to: i = "object" } = t, r = t.contractAddress ?? t.address, s = await e({
5
- hash: a({ address: r, chainId: o, nonce: n }),
6
- privateKey: c,
7
- to: i
8
- });
9
- return i === "object" ? {
10
- address: r,
11
- chainId: o,
12
- nonce: n,
13
- ...s
14
- } : s;
1
+ import { SizeExceedsPaddingSizeError as d } from "./index89.js";
2
+ function f(n, { dir: r, size: t = 32 } = {}) {
3
+ return typeof n == "string" ? p(n, { dir: r, size: t }) : i(n, { dir: r, size: t });
4
+ }
5
+ function p(n, { dir: r, size: t = 32 } = {}) {
6
+ if (t === null)
7
+ return n;
8
+ const e = n.replace("0x", "");
9
+ if (e.length > t * 2)
10
+ throw new d({
11
+ size: Math.ceil(e.length / 2),
12
+ targetSize: t,
13
+ type: "hex"
14
+ });
15
+ return `0x${e[r === "right" ? "padEnd" : "padStart"](t * 2, "0")}`;
16
+ }
17
+ function i(n, { dir: r, size: t = 32 } = {}) {
18
+ if (t === null)
19
+ return n;
20
+ if (n.length > t)
21
+ throw new d({
22
+ size: n.length,
23
+ targetSize: t,
24
+ type: "bytes"
25
+ });
26
+ const e = new Uint8Array(t);
27
+ for (let a = 0; a < t; a++) {
28
+ const o = r === "right";
29
+ e[o ? a : t - a - 1] = n[o ? a : n.length - a - 1];
30
+ }
31
+ return e;
15
32
  }
16
33
  export {
17
- u as signAuthorization
34
+ f as pad,
35
+ i as padBytes,
36
+ p as padHex
18
37
  };
package/dist/index47.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index55.cjs"),n=require("./index45.cjs");async function t({message:e,privateKey:s}){return await n.sign({hash:a.hashMessage(e),privateKey:s,to:"hex"})}exports.signMessage=t;
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;
package/dist/index47.js CHANGED
@@ -1,8 +1,9 @@
1
- import { hashMessage as e } from "./index55.js";
2
- import { sign as o } from "./index45.js";
3
- async function i({ message: s, privateKey: a }) {
4
- return await o({ hash: e(s), privateKey: a, to: "hex" });
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;
5
6
  }
6
7
  export {
7
- i as signMessage
8
+ f as trim
8
9
  };
package/dist/index48.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index56.cjs"),c=require("./index57.cjs"),o=require("./index45.cjs");async function u(i){const{privateKey:r,transaction:e,serializer:n=c.serializeTransaction}=i,a=e.type==="eip4844"?{...e,sidecars:!1}:e,s=await o.sign({hash:t.keccak256(n(a)),privateKey:r});return n(e,s)}exports.signTransaction=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index49.cjs");let i={getDocsUrl:({docsBaseUrl:s,docsPath:t="",docsSlug:e})=>t?`${s??"https://viem.sh"}${t}${e?`#${e}`:""}`:void 0,version:`viem@${l.version}`};class u extends Error{constructor(t,e={}){var o;const r=(()=>{var c;return e.cause instanceof u?e.cause.details:(c=e.cause)!=null&&c.message?e.cause.message:e.details})(),n=e.cause instanceof u&&e.cause.docsPath||e.docsPath,a=(o=i.getDocsUrl)==null?void 0:o.call(i,{...e,docsPath:n}),b=[t||"An error occurred.","",...e.metaMessages?[...e.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...i.version?[`Version: ${i.version}`]:[]].join(`
2
+ `);super(b,e.cause?{cause:e.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=e.metaMessages,this.name=e.name??this.name,this.shortMessage=t,this.version=l.version}walk(t){return d(this,t)}}function d(s,t){return t!=null&&t(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?d(s.cause,t):t?null:s}exports.BaseError=u;
package/dist/index48.js CHANGED
@@ -1,16 +1,62 @@
1
- import { keccak256 as e } from "./index56.js";
2
- import { serializeTransaction as o } from "./index57.js";
3
- import { sign as c } from "./index45.js";
4
- async function u(n) {
5
- const { privateKey: a, transaction: r, serializer: i = o } = n, t = r.type === "eip4844" ? {
6
- ...r,
7
- sidecars: !1
8
- } : r, s = await c({
9
- hash: e(i(t)),
10
- privateKey: a
11
- });
12
- return i(r, s);
1
+ import { version as l } from "./index49.js";
2
+ let i = {
3
+ getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
4
+ version: `viem@${l}`
5
+ };
6
+ class r extends Error {
7
+ constructor(t, e = {}) {
8
+ var o;
9
+ const u = (() => {
10
+ var c;
11
+ return e.cause instanceof r ? e.cause.details : (c = e.cause) != null && c.message ? e.cause.message : e.details;
12
+ })(), a = e.cause instanceof r && e.cause.docsPath || e.docsPath, n = (o = i.getDocsUrl) == null ? void 0 : o.call(i, { ...e, docsPath: a }), b = [
13
+ t || "An error occurred.",
14
+ "",
15
+ ...e.metaMessages ? [...e.metaMessages, ""] : [],
16
+ ...n ? [`Docs: ${n}`] : [],
17
+ ...u ? [`Details: ${u}`] : [],
18
+ ...i.version ? [`Version: ${i.version}`] : []
19
+ ].join(`
20
+ `);
21
+ super(b, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
22
+ enumerable: !0,
23
+ configurable: !0,
24
+ writable: !0,
25
+ value: void 0
26
+ }), Object.defineProperty(this, "docsPath", {
27
+ enumerable: !0,
28
+ configurable: !0,
29
+ writable: !0,
30
+ value: void 0
31
+ }), Object.defineProperty(this, "metaMessages", {
32
+ enumerable: !0,
33
+ configurable: !0,
34
+ writable: !0,
35
+ value: void 0
36
+ }), Object.defineProperty(this, "shortMessage", {
37
+ enumerable: !0,
38
+ configurable: !0,
39
+ writable: !0,
40
+ value: void 0
41
+ }), Object.defineProperty(this, "version", {
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0,
45
+ value: void 0
46
+ }), Object.defineProperty(this, "name", {
47
+ enumerable: !0,
48
+ configurable: !0,
49
+ writable: !0,
50
+ value: "BaseError"
51
+ }), this.details = u, this.docsPath = a, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = l;
52
+ }
53
+ walk(t) {
54
+ return d(this, t);
55
+ }
56
+ }
57
+ function d(s, t) {
58
+ return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? d(s.cause, t) : t ? null : s;
13
59
  }
14
60
  export {
15
- u as signTransaction
61
+ r as BaseError
16
62
  };
package/dist/index49.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index58.cjs"),s=require("./index45.cjs");async function i(e){const{privateKey:t,...a}=e;return await s.sign({hash:n.hashTypedData(a),privateKey:t,to:"hex"})}exports.signTypedData=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.26.3";exports.version=e;
package/dist/index49.js CHANGED
@@ -1,13 +1,4 @@
1
- import { hashTypedData as o } from "./index58.js";
2
- import { sign as r } from "./index45.js";
3
- async function p(t) {
4
- const { privateKey: a, ...e } = t;
5
- return await r({
6
- hash: o(e),
7
- privateKey: a,
8
- to: "hex"
9
- });
10
- }
1
+ const o = "2.26.3";
11
2
  export {
12
- p as signTypedData
3
+ o as version
13
4
  };
package/dist/index50.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index63.cjs");class r extends s.BaseError{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}exports.InvalidAddressError=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index48.cjs");class i extends e.BaseError{constructor({chainId:r}){super(typeof r=="number"?`Chain ID "${r}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}exports.InvalidChainIdError=i;
package/dist/index50.js CHANGED
@@ -1,15 +1,9 @@
1
- import { BaseError as r } from "./index63.js";
2
- class d extends r {
3
- constructor({ address: s }) {
4
- super(`Address "${s}" is invalid.`, {
5
- metaMessages: [
6
- "- Address must be a hex value of 20 bytes (40 hex characters).",
7
- "- Address must match its checksum counterpart."
8
- ],
9
- name: "InvalidAddressError"
10
- });
1
+ import { BaseError as i } from "./index48.js";
2
+ class o extends i {
3
+ constructor({ chainId: r }) {
4
+ super(typeof r == "number" ? `Chain ID "${r}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
11
5
  }
12
6
  }
13
7
  export {
14
- d as InvalidAddressError
8
+ o as InvalidChainIdError
15
9
  };
package/dist/index51.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index72.cjs"),i=require("./index59.cjs"),o=/^0x[a-fA-F0-9]{40}$/,t=new c.LruMap(8192);function f(e,n){const{strict:s=!0}=n??{},r=`${e}.${s}`;if(t.has(r))return t.get(r);const u=o.test(e)?e.toLowerCase()===e?!0:s?i.checksumAddress(e)===e:!0:!1;return t.set(r,u),u}exports.isAddress=f;exports.isAddressCache=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index69.cjs");function i(e){return t.isHex(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}exports.size=i;
package/dist/index51.js CHANGED
@@ -1,14 +1,7 @@
1
- import { LruMap as u } from "./index72.js";
2
- import { checksumAddress as c } from "./index59.js";
3
- const i = /^0x[a-fA-F0-9]{40}$/, r = /* @__PURE__ */ new u(8192);
4
- function h(t, s) {
5
- const { strict: n = !0 } = s ?? {}, e = `${t}.${n}`;
6
- if (r.has(e))
7
- return r.get(e);
8
- const o = i.test(t) ? t.toLowerCase() === t ? !0 : n ? c(t) === t : !0 : !1;
9
- return r.set(e, o), o;
1
+ import { isHex as r } from "./index69.js";
2
+ function i(t) {
3
+ return r(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
10
4
  }
11
5
  export {
12
- h as isAddress,
13
- r as isAddressCache
6
+ i as size
14
7
  };
package/dist/index52.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index42.cjs"),n=require("./index35.cjs"),a=require("./index53.cjs");function g({r:i,s:o,to:u="hex",v:e,yParity:r}){const s=(()=>{if(r===0||r===1)return r;if(e&&(e===27n||e===28n||e>=35n))return e%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),t=`0x${new c.secp256k1.Signature(n.hexToBigInt(i),n.hexToBigInt(o)).toCompactHex()}${s===0?"1b":"1c"}`;return u==="hex"?t:a.hexToBytes(t)}exports.serializeSignature=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(n,{args:a,eventName:t}={}){return{...n,blockHash:n.blockHash?n.blockHash:null,blockNumber:n.blockNumber?BigInt(n.blockNumber):null,logIndex:n.logIndex?Number(n.logIndex):null,transactionHash:n.transactionHash?n.transactionHash:null,transactionIndex:n.transactionIndex?Number(n.transactionIndex):null,...t?{args:a,eventName:t}:{}}}exports.formatLog=r;
package/dist/index52.js CHANGED
@@ -1,16 +1,14 @@
1
- import { secp256k1 as f } from "./index42.js";
2
- import { hexToBigInt as t } from "./index35.js";
3
- import { hexToBytes as m } from "./index53.js";
4
- function s({ r: o, s: i, to: u = "hex", v: r, yParity: e }) {
5
- const a = (() => {
6
- if (e === 0 || e === 1)
7
- return e;
8
- if (r && (r === 27n || r === 28n || r >= 35n))
9
- return r % 2n === 0n ? 1 : 0;
10
- throw new Error("Invalid `v` or `yParity` value");
11
- })(), n = `0x${new f.Signature(t(o), t(i)).toCompactHex()}${a === 0 ? "1b" : "1c"}`;
12
- return u === "hex" ? n : m(n);
1
+ function r(n, { args: t, eventName: a } = {}) {
2
+ return {
3
+ ...n,
4
+ blockHash: n.blockHash ? n.blockHash : null,
5
+ blockNumber: n.blockNumber ? BigInt(n.blockNumber) : null,
6
+ logIndex: n.logIndex ? Number(n.logIndex) : null,
7
+ transactionHash: n.transactionHash ? n.transactionHash : null,
8
+ transactionIndex: n.transactionIndex ? Number(n.transactionIndex) : null,
9
+ ...a ? { args: t, eventName: a } : {}
10
+ };
13
11
  }
14
12
  export {
15
- s as serializeSignature
13
+ r as formatLog
16
14
  };
package/dist/index53.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index63.cjs"),l=require("./index83.cjs"),u=require("./index61.cjs"),f=require("./index35.cjs"),m=require("./index25.cjs"),h=new TextEncoder;function A(e,n={}){return typeof e=="number"||typeof e=="bigint"?B(e,n):typeof e=="boolean"?x(e,n):l.isHex(e)?c(e,n):T(e,n)}function x(e,n={}){const t=new Uint8Array(1);return t[0]=Number(e),typeof n.size=="number"?(f.assertSize(t,{size:n.size}),u.pad(t,{size:n.size})):t}const i={zero:48,nine:57,A:65,F:70,a:97,f:102};function g(e){if(e>=i.zero&&e<=i.nine)return e-i.zero;if(e>=i.A&&e<=i.F)return e-(i.A-10);if(e>=i.a&&e<=i.f)return e-(i.a-10)}function c(e,n={}){let t=e;n.size&&(f.assertSize(t,{size:n.size}),t=u.pad(t,{dir:"right",size:n.size}));let r=t.slice(2);r.length%2&&(r=`0${r}`);const d=r.length/2,y=new Uint8Array(d);for(let s=0,o=0;s<d;s++){const b=g(r.charCodeAt(o++)),z=g(r.charCodeAt(o++));if(b===void 0||z===void 0)throw new a.BaseError(`Invalid byte sequence ("${r[o-2]}${r[o-1]}" in "${r}").`);y[s]=b*16+z}return y}function B(e,n){const t=m.numberToHex(e,n);return c(t)}function T(e,n={}){const t=h.encode(e);return typeof n.size=="number"?(f.assertSize(t,{size:n.size}),u.pad(t,{dir:"right",size:n.size})):t}exports.boolToBytes=x;exports.hexToBytes=c;exports.numberToBytes=B;exports.stringToBytes=T;exports.toBytes=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};exports.transactionType=e;
package/dist/index53.js CHANGED
@@ -1,58 +1,10 @@
1
- import { BaseError as g } from "./index63.js";
2
- import { isHex as x } from "./index83.js";
3
- import { pad as s } from "./index61.js";
4
- import { assertSize as u } from "./index35.js";
5
- import { numberToHex as h } from "./index25.js";
6
- const A = /* @__PURE__ */ new TextEncoder();
7
- function F(e, n = {}) {
8
- return typeof e == "number" || typeof e == "bigint" ? T(e, n) : typeof e == "boolean" ? B(e, n) : x(e) ? y(e, n) : l(e, n);
9
- }
10
- function B(e, n = {}) {
11
- const r = new Uint8Array(1);
12
- return r[0] = Number(e), typeof n.size == "number" ? (u(r, { size: n.size }), s(r, { size: n.size })) : r;
13
- }
14
- const t = {
15
- zero: 48,
16
- nine: 57,
17
- A: 65,
18
- F: 70,
19
- a: 97,
20
- f: 102
1
+ const e = {
2
+ "0x0": "legacy",
3
+ "0x1": "eip2930",
4
+ "0x2": "eip1559",
5
+ "0x3": "eip4844",
6
+ "0x4": "eip7702"
21
7
  };
22
- function m(e) {
23
- if (e >= t.zero && e <= t.nine)
24
- return e - t.zero;
25
- if (e >= t.A && e <= t.F)
26
- return e - (t.A - 10);
27
- if (e >= t.a && e <= t.f)
28
- return e - (t.a - 10);
29
- }
30
- function y(e, n = {}) {
31
- let r = e;
32
- n.size && (u(r, { size: n.size }), r = s(r, { dir: "right", size: n.size }));
33
- let i = r.slice(2);
34
- i.length % 2 && (i = `0${i}`);
35
- const z = i.length / 2, d = new Uint8Array(z);
36
- for (let f = 0, o = 0; f < z; f++) {
37
- const b = m(i.charCodeAt(o++)), c = m(i.charCodeAt(o++));
38
- if (b === void 0 || c === void 0)
39
- throw new g(`Invalid byte sequence ("${i[o - 2]}${i[o - 1]}" in "${i}").`);
40
- d[f] = b * 16 + c;
41
- }
42
- return d;
43
- }
44
- function T(e, n) {
45
- const r = h(e, n);
46
- return y(r);
47
- }
48
- function l(e, n = {}) {
49
- const r = A.encode(e);
50
- return typeof n.size == "number" ? (u(r, { size: n.size }), s(r, { dir: "right", size: n.size })) : r;
51
- }
52
8
  export {
53
- B as boolToBytes,
54
- y as hexToBytes,
55
- T as numberToBytes,
56
- l as stringToBytes,
57
- F as toBytes
9
+ e as transactionType
58
10
  };
package/dist/index54.cjs CHANGED
@@ -1 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index86.cjs"),u=require("./index53.cjs"),c=require("./index25.cjs"),a=require("./index96.cjs"),h=require("./index56.cjs");function d(e){const{chainId:t,nonce:o,to:r}=e,s=e.contractAddress??e.address,n=h.keccak256(i.concatHex(["0x05",a.toRlp([t?c.numberToHex(t):"0x",s,o?c.numberToHex(o):"0x"])]));return r==="bytes"?u.hexToBytes(n):n}exports.hashAuthorization=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index51.cjs"),n=require("./index48.cjs");class o extends n.BaseError{constructor({expectedLength:r,givenLength:e,type:t}){super([`ABI encoding array length mismatch for type ${t}.`,`Expected length: ${r}`,`Given length: ${e}`].join(`
2
+ `),{name:"AbiEncodingArrayLengthMismatchError"})}}class a extends n.BaseError{constructor({expectedSize:r,value:e}){super(`Size of bytes "${e}" (bytes${i.size(e)}) does not match expected size (bytes${r}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class c extends n.BaseError{constructor({expectedLength:r,givenLength:e}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${r}`,`Given length (values): ${e}`].join(`
3
+ `),{name:"AbiEncodingLengthMismatchError"})}}class d extends n.BaseError{constructor({expectedSize:r,givenSize:e}){super(`Expected bytes${r}, got bytes${e}.`,{name:"BytesSizeMismatchError"})}}class E extends n.BaseError{constructor(r,{docsPath:e}){super([`Type "${r}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
4
+ `),{docsPath:e,name:"InvalidAbiEncodingType"})}}class g extends n.BaseError{constructor(r){super([`Value "${r}" is not a valid array.`].join(`
5
+ `),{name:"InvalidArrayError"})}}exports.AbiEncodingArrayLengthMismatchError=o;exports.AbiEncodingBytesSizeMismatchError=a;exports.AbiEncodingLengthMismatchError=c;exports.BytesSizeMismatchError=d;exports.InvalidAbiEncodingTypeError=E;exports.InvalidArrayError=g;