@gardenfi/utils 2.1.2-beta.4 → 2.1.2-beta.6

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 (177) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +5 -5
  3. package/dist/index101.cjs +1 -2
  4. package/dist/index101.js +11 -3
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +18 -16
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +6 -643
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +5 -173
  11. package/dist/index18.cjs +1 -1
  12. package/dist/index18.js +2 -2
  13. package/dist/index19.cjs +1 -1
  14. package/dist/index19.js +9 -9
  15. package/dist/index20.cjs +1 -1
  16. package/dist/index20.js +1 -1
  17. package/dist/index21.cjs +1 -1
  18. package/dist/index21.js +3 -3
  19. package/dist/index22.cjs +1 -1
  20. package/dist/index22.js +1 -1
  21. package/dist/index23.cjs +1 -2
  22. package/dist/index23.js +40 -49
  23. package/dist/index24.cjs +1 -1
  24. package/dist/index24.js +45 -24
  25. package/dist/index25.cjs +1 -1
  26. package/dist/index25.js +25 -41
  27. package/dist/index26.cjs +1 -1
  28. package/dist/index26.js +6 -45
  29. package/dist/index27.cjs +1 -1
  30. package/dist/index27.js +12 -24
  31. package/dist/index28.cjs +1 -1
  32. package/dist/index28.js +15 -6
  33. package/dist/index29.cjs +1 -1
  34. package/dist/index29.js +5 -13
  35. package/dist/index30.cjs +1 -1
  36. package/dist/index30.js +12 -14
  37. package/dist/index31.cjs +1 -1
  38. package/dist/index31.js +10 -5
  39. package/dist/index32.cjs +1 -1
  40. package/dist/index32.js +12 -13
  41. package/dist/index33.cjs +1 -1
  42. package/dist/index33.js +11 -10
  43. package/dist/index34.cjs +1 -1
  44. package/dist/index34.js +13 -12
  45. package/dist/index35.cjs +1 -1
  46. package/dist/index35.js +23 -11
  47. package/dist/index36.cjs +1 -1
  48. package/dist/index36.js +55 -13
  49. package/dist/index37.cjs +1 -1
  50. package/dist/index37.js +16 -23
  51. package/dist/index38.cjs +1 -1
  52. package/dist/index38.js +5 -55
  53. package/dist/index39.cjs +1 -1
  54. package/dist/index39.js +8 -16
  55. package/dist/index4.cjs +1 -1
  56. package/dist/index4.js +23 -22
  57. package/dist/index40.cjs +1 -1
  58. package/dist/index40.js +171 -5
  59. package/dist/index41.cjs +1 -1
  60. package/dist/index41.js +103 -8
  61. package/dist/index42.cjs +1 -1
  62. package/dist/index42.js +20 -170
  63. package/dist/index43.cjs +2 -1
  64. package/dist/index43.js +44 -97
  65. package/dist/index44.cjs +1 -1
  66. package/dist/index44.js +24 -21
  67. package/dist/index45.cjs +1 -1
  68. package/dist/index45.js +38 -10
  69. package/dist/index46.cjs +1 -1
  70. package/dist/index46.js +32 -32
  71. package/dist/index47.cjs +1 -1
  72. package/dist/index47.js +69 -6
  73. package/dist/index48.cjs +1 -2
  74. package/dist/index48.js +110 -57
  75. package/dist/index49.cjs +1 -1
  76. package/dist/index49.js +68 -2
  77. package/dist/index50.cjs +1 -1
  78. package/dist/index50.js +2 -7
  79. package/dist/index51.cjs +1 -1
  80. package/dist/index51.js +16 -4
  81. package/dist/index52.cjs +1 -1
  82. package/dist/index52.js +222 -10
  83. package/dist/index53.cjs +1 -1
  84. package/dist/index53.js +231 -7
  85. package/dist/index54.cjs +1 -5
  86. package/dist/index54.js +9 -53
  87. package/dist/index55.cjs +1 -2
  88. package/dist/index55.js +30 -30
  89. package/dist/index56.cjs +2 -1
  90. package/dist/index56.js +59 -5
  91. package/dist/index57.cjs +1 -1
  92. package/dist/index57.js +22 -2
  93. package/dist/index58.cjs +1 -1
  94. package/dist/index58.js +101 -18
  95. package/dist/index59.cjs +1 -1
  96. package/dist/index59.js +3 -8
  97. package/dist/index60.cjs +1 -1
  98. package/dist/index60.js +16 -9
  99. package/dist/index61.cjs +1 -1
  100. package/dist/index61.js +8 -11
  101. package/dist/index62.cjs +1 -1
  102. package/dist/index62.js +10 -6
  103. package/dist/index63.cjs +1 -1
  104. package/dist/index63.js +11 -13
  105. package/dist/index64.cjs +1 -1
  106. package/dist/index64.js +12 -31
  107. package/dist/index65.cjs +1 -1
  108. package/dist/index65.js +18 -14
  109. package/dist/index66.cjs +1 -1
  110. package/dist/index66.js +6 -64
  111. package/dist/index67.cjs +1 -1
  112. package/dist/index67.js +40 -25
  113. package/dist/index68.cjs +1 -1
  114. package/dist/index68.js +79 -3
  115. package/dist/index69.cjs +1 -1
  116. package/dist/index69.js +14 -3
  117. package/dist/index70.cjs +1 -1
  118. package/dist/index70.js +18 -8
  119. package/dist/index71.cjs +1 -1
  120. package/dist/index71.js +8 -191
  121. package/dist/index72.cjs +1 -1
  122. package/dist/index72.js +3 -17
  123. package/dist/index73.cjs +1 -1
  124. package/dist/index73.js +189 -9
  125. package/dist/index74.cjs +1 -1
  126. package/dist/index74.js +63 -18
  127. package/dist/index75.cjs +1 -1
  128. package/dist/index75.js +2 -41
  129. package/dist/index76.cjs +1 -1
  130. package/dist/index76.js +6 -34
  131. package/dist/index77.cjs +1 -1
  132. package/dist/index77.js +11 -69
  133. package/dist/index78.cjs +1 -1
  134. package/dist/index78.js +8 -113
  135. package/dist/index79.cjs +5 -1
  136. package/dist/index79.js +50 -61
  137. package/dist/index80.cjs +1 -1
  138. package/dist/index80.js +2 -2
  139. package/dist/index81.cjs +2 -1
  140. package/dist/index81.js +33 -15
  141. package/dist/index82.cjs +1 -1
  142. package/dist/index82.js +5 -223
  143. package/dist/index83.cjs +1 -1
  144. package/dist/index83.js +6 -231
  145. package/dist/index84.cjs +1 -1
  146. package/dist/index84.js +32 -8
  147. package/dist/index85.cjs +1 -1
  148. package/dist/index85.js +25 -40
  149. package/dist/index86.cjs +1 -1
  150. package/dist/index86.js +3 -105
  151. package/dist/index87.cjs +1 -1
  152. package/dist/index87.js +10 -16
  153. package/dist/index88.cjs +1 -1
  154. package/dist/index88.js +18 -77
  155. package/dist/index89.cjs +1 -1
  156. package/dist/index89.js +8 -18
  157. package/dist/index90.cjs +1 -1
  158. package/dist/index90.js +16 -10
  159. package/dist/index91.cjs +1 -1
  160. package/dist/index91.js +638 -33
  161. package/dist/index92.cjs +1 -1
  162. package/dist/index92.js +173 -5
  163. package/dist/index93.cjs +1 -1
  164. package/dist/index93.js +12 -10
  165. package/dist/index94.cjs +1 -1
  166. package/dist/index94.js +128 -2
  167. package/dist/index95.cjs +2 -1
  168. package/dist/index95.js +3 -128
  169. package/dist/index96.cjs +1 -1
  170. package/dist/index96.js +2 -7
  171. package/dist/index97.cjs +1 -1
  172. package/dist/index97.js +2 -2
  173. package/dist/index98.cjs +1 -1
  174. package/dist/index98.js +2 -2
  175. package/dist/index99.cjs +1 -1
  176. package/dist/index99.js +35 -17
  177. package/package.json +1 -1
package/dist/index27.js CHANGED
@@ -1,28 +1,16 @@
1
- import { InvalidAddressError as s } from "./index34.js";
2
- import { isAddress as a } from "./index35.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 { secp256k1 as u } from "./index23.js";
2
+ import { numberToHex as i } from "./index24.js";
3
+ import { serializeSignature as a } from "./index34.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
24
11
  };
12
+ return r === "bytes" || r === "hex" ? a({ ...t, to: r }) : t;
25
13
  }
26
14
  export {
27
- r as toAccount
15
+ y as sign
28
16
  };
package/dist/index28.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index44.cjs"),c=require("./index41.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 c=require("./index37.cjs"),a=require("./index27.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;
package/dist/index28.js CHANGED
@@ -1,9 +1,18 @@
1
- import { checksumAddress as e } from "./index44.js";
2
- import { keccak256 as o } from "./index41.js";
3
- function d(r) {
4
- const s = o(`0x${r.substring(4)}`).substring(26);
5
- return e(`0x${s}`);
1
+ import { hashAuthorization as a } from "./index37.js";
2
+ import { sign as e } from "./index27.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;
6
15
  }
7
16
  export {
8
- d as publicKeyToAddress
17
+ u as signAuthorization
9
18
  };
package/dist/index29.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index25.cjs"),s=require("./index26.cjs"),a=require("./index36.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 a=require("./index38.cjs"),n=require("./index27.cjs");async function t({message:e,privateKey:s}){return await n.sign({hash:a.hashMessage(e),privateKey:s,to:"hex"})}exports.signMessage=t;
package/dist/index29.js CHANGED
@@ -1,16 +1,8 @@
1
- import { secp256k1 as u } from "./index25.js";
2
- import { numberToHex as i } from "./index26.js";
3
- import { serializeSignature as a } from "./index36.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 { hashMessage as e } from "./index38.js";
2
+ import { sign as o } from "./index27.js";
3
+ async function i({ message: s, privateKey: a }) {
4
+ return await o({ hash: e(s), privateKey: a, to: "hex" });
13
5
  }
14
6
  export {
15
- y as sign
7
+ i as signMessage
16
8
  };
package/dist/index30.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index39.cjs"),a=require("./index29.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 t=require("./index39.cjs"),c=require("./index40.cjs"),o=require("./index27.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;
package/dist/index30.js CHANGED
@@ -1,18 +1,16 @@
1
- import { hashAuthorization as a } from "./index39.js";
2
- import { sign as e } from "./index29.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
1
+ import { keccak256 as e } from "./index39.js";
2
+ import { serializeTransaction as o } from "./index40.js";
3
+ import { sign as c } from "./index27.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
8
11
  });
9
- return i === "object" ? {
10
- address: r,
11
- chainId: o,
12
- nonce: n,
13
- ...s
14
- } : s;
12
+ return i(r, s);
15
13
  }
16
14
  export {
17
- u as signAuthorization
15
+ u as signTransaction
18
16
  };
package/dist/index31.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index40.cjs"),n=require("./index29.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"});const n=require("./index41.cjs"),s=require("./index27.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;
package/dist/index31.js CHANGED
@@ -1,8 +1,13 @@
1
- import { hashMessage as e } from "./index40.js";
2
- import { sign as o } from "./index29.js";
3
- async function i({ message: s, privateKey: a }) {
4
- return await o({ hash: e(s), privateKey: a, to: "hex" });
1
+ import { hashTypedData as o } from "./index41.js";
2
+ import { sign as r } from "./index27.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
+ });
5
10
  }
6
11
  export {
7
- i as signMessage
12
+ p as signTypedData
8
13
  };
package/dist/index32.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index41.cjs"),c=require("./index42.cjs"),o=require("./index29.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 s=require("./index56.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;
package/dist/index32.js CHANGED
@@ -1,16 +1,15 @@
1
- import { keccak256 as e } from "./index41.js";
2
- import { serializeTransaction as o } from "./index42.js";
3
- import { sign as c } from "./index29.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 { BaseError as r } from "./index56.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
+ });
11
+ }
13
12
  }
14
13
  export {
15
- u as signTransaction
14
+ d as InvalidAddressError
16
15
  };
package/dist/index33.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index43.cjs"),s=require("./index29.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 c=require("./index57.cjs"),i=require("./index42.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;
package/dist/index33.js CHANGED
@@ -1,13 +1,14 @@
1
- import { hashTypedData as o } from "./index43.js";
2
- import { sign as r } from "./index29.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
- });
1
+ import { LruMap as u } from "./index57.js";
2
+ import { checksumAddress as c } from "./index42.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;
10
10
  }
11
11
  export {
12
- p as signTypedData
12
+ h as isAddress,
13
+ r as isAddressCache
13
14
  };
package/dist/index34.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index48.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 c=require("./index23.cjs"),n=require("./index35.cjs"),a=require("./index36.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;
package/dist/index34.js CHANGED
@@ -1,15 +1,16 @@
1
- import { BaseError as r } from "./index48.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
- });
11
- }
1
+ import { secp256k1 as f } from "./index23.js";
2
+ import { hexToBigInt as t } from "./index35.js";
3
+ import { hexToBytes as m } from "./index36.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);
12
13
  }
13
14
  export {
14
- d as InvalidAddressError
15
+ s as serializeSignature
15
16
  };
package/dist/index35.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index58.cjs"),i=require("./index44.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 z=require("./index54.cjs"),r=require("./index72.cjs");function o(e,{size:n}){if(r.size(e)>n)throw new z.SizeOverflowError({givenSize:r.size(e),maxSize:n})}function s(e,n={}){const{signed:u}=n;n.size&&o(e,{size:n.size});const i=BigInt(e);if(!u)return i;const t=(e.length-2)/2,c=(1n<<BigInt(t)*8n-1n)-1n;return i<=c?i:i-BigInt(`0x${"f".padStart(t*2,"f")}`)-1n}function f(e,n={}){return Number(s(e,n))}exports.assertSize=o;exports.hexToBigInt=s;exports.hexToNumber=f;
package/dist/index35.js CHANGED
@@ -1,14 +1,26 @@
1
- import { LruMap as u } from "./index58.js";
2
- import { checksumAddress as c } from "./index44.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 { SizeOverflowError as u } from "./index54.js";
2
+ import { size as t } from "./index72.js";
3
+ function s(n, { size: i }) {
4
+ if (t(n) > i)
5
+ throw new u({
6
+ givenSize: t(n),
7
+ maxSize: i
8
+ });
9
+ }
10
+ function z(n, i = {}) {
11
+ const { signed: o } = i;
12
+ i.size && s(n, { size: i.size });
13
+ const e = BigInt(n);
14
+ if (!o)
15
+ return e;
16
+ const r = (n.length - 2) / 2, f = (1n << BigInt(r) * 8n - 1n) - 1n;
17
+ return e <= f ? e : e - BigInt(`0x${"f".padStart(r * 2, "f")}`) - 1n;
18
+ }
19
+ function g(n, i = {}) {
20
+ return Number(z(n, i));
10
21
  }
11
22
  export {
12
- h as isAddress,
13
- r as isAddressCache
23
+ s as assertSize,
24
+ z as hexToBigInt,
25
+ g as hexToNumber
14
26
  };
package/dist/index36.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index25.cjs"),n=require("./index37.cjs"),a=require("./index38.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"});const a=require("./index56.cjs"),l=require("./index59.cjs"),u=require("./index55.cjs"),f=require("./index35.cjs"),m=require("./index24.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;
package/dist/index36.js CHANGED
@@ -1,16 +1,58 @@
1
- import { secp256k1 as f } from "./index25.js";
2
- import { hexToBigInt as t } from "./index37.js";
3
- import { hexToBytes as m } from "./index38.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
+ import { BaseError as g } from "./index56.js";
2
+ import { isHex as x } from "./index59.js";
3
+ import { pad as s } from "./index55.js";
4
+ import { assertSize as u } from "./index35.js";
5
+ import { numberToHex as h } from "./index24.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
21
+ };
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;
13
51
  }
14
52
  export {
15
- s as serializeSignature
53
+ B as boolToBytes,
54
+ y as hexToBytes,
55
+ T as numberToBytes,
56
+ l as stringToBytes,
57
+ F as toBytes
16
58
  };
package/dist/index37.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("./index45.cjs"),r=require("./index51.cjs");function o(e,{size:n}){if(r.size(e)>n)throw new z.SizeOverflowError({givenSize:r.size(e),maxSize:n})}function s(e,n={}){const{signed:u}=n;n.size&&o(e,{size:n.size});const i=BigInt(e);if(!u)return i;const t=(e.length-2)/2,c=(1n<<BigInt(t)*8n-1n)-1n;return i<=c?i:i-BigInt(`0x${"f".padStart(t*2,"f")}`)-1n}function f(e,n={}){return Number(s(e,n))}exports.assertSize=o;exports.hexToBigInt=s;exports.hexToNumber=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index65.cjs"),u=require("./index36.cjs"),c=require("./index24.cjs"),a=require("./index67.cjs"),h=require("./index39.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;
package/dist/index37.js CHANGED
@@ -1,26 +1,19 @@
1
- import { SizeOverflowError as u } from "./index45.js";
2
- import { size as t } from "./index51.js";
3
- function s(n, { size: i }) {
4
- if (t(n) > i)
5
- throw new u({
6
- givenSize: t(n),
7
- maxSize: i
8
- });
9
- }
10
- function z(n, i = {}) {
11
- const { signed: o } = i;
12
- i.size && s(n, { size: i.size });
13
- const e = BigInt(n);
14
- if (!o)
15
- return e;
16
- const r = (n.length - 2) / 2, f = (1n << BigInt(r) * 8n - 1n) - 1n;
17
- return e <= f ? e : e - BigInt(`0x${"f".padStart(r * 2, "f")}`) - 1n;
18
- }
19
- function g(n, i = {}) {
20
- return Number(z(n, i));
1
+ import { concatHex as i } from "./index65.js";
2
+ import { hexToBytes as m } from "./index36.js";
3
+ import { numberToHex as c } from "./index24.js";
4
+ import { toRlp as d } from "./index67.js";
5
+ import { keccak256 as f } from "./index39.js";
6
+ function b(o) {
7
+ const { chainId: t, nonce: r, to: s } = o, e = o.contractAddress ?? o.address, n = f(i([
8
+ "0x05",
9
+ d([
10
+ t ? c(t) : "0x",
11
+ e,
12
+ r ? c(r) : "0x"
13
+ ])
14
+ ]));
15
+ return s === "bytes" ? m(n) : n;
21
16
  }
22
17
  export {
23
- s as assertSize,
24
- z as hexToBigInt,
25
- g as hexToNumber
18
+ b as hashAuthorization
26
19
  };
package/dist/index38.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index48.cjs"),l=require("./index69.cjs"),u=require("./index46.cjs"),f=require("./index37.cjs"),m=require("./index26.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 r=require("./index39.cjs"),t=require("./index71.cjs");function a(e,s){return r.keccak256(t.toPrefixedMessage(e),s)}exports.hashMessage=a;
package/dist/index38.js CHANGED
@@ -1,58 +1,8 @@
1
- import { BaseError as g } from "./index48.js";
2
- import { isHex as x } from "./index69.js";
3
- import { pad as s } from "./index46.js";
4
- import { assertSize as u } from "./index37.js";
5
- import { numberToHex as h } from "./index26.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
21
- };
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;
1
+ import { keccak256 as o } from "./index39.js";
2
+ import { toPrefixedMessage as t } from "./index71.js";
3
+ function f(e, r) {
4
+ return o(t(e), r);
51
5
  }
52
6
  export {
53
- B as boolToBytes,
54
- y as hexToBytes,
55
- T as numberToBytes,
56
- l as stringToBytes,
57
- F as toBytes
7
+ f as hashMessage
58
8
  };
package/dist/index39.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index72.cjs"),u=require("./index38.cjs"),c=require("./index26.cjs"),a=require("./index85.cjs"),h=require("./index41.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 c=require("./index58.cjs"),o=require("./index59.cjs"),i=require("./index36.cjs"),n=require("./index24.cjs");function u(e,r){const s=r||"hex",t=c.keccak_256(o.isHex(e,{strict:!1})?i.toBytes(e):e);return s==="bytes"?t:n.toHex(t)}exports.keccak256=u;
package/dist/index39.js CHANGED
@@ -1,19 +1,11 @@
1
- import { concatHex as i } from "./index72.js";
2
- import { hexToBytes as m } from "./index38.js";
3
- import { numberToHex as c } from "./index26.js";
4
- import { toRlp as d } from "./index85.js";
5
- import { keccak256 as f } from "./index41.js";
6
- function b(o) {
7
- const { chainId: t, nonce: r, to: s } = o, e = o.contractAddress ?? o.address, n = f(i([
8
- "0x05",
9
- d([
10
- t ? c(t) : "0x",
11
- e,
12
- r ? c(r) : "0x"
13
- ])
14
- ]));
15
- return s === "bytes" ? m(n) : n;
1
+ import { keccak_256 as c } from "./index58.js";
2
+ import { isHex as i } from "./index59.js";
3
+ import { toBytes as m } from "./index36.js";
4
+ import { toHex as s } from "./index24.js";
5
+ function x(t, r) {
6
+ const e = r || "hex", o = c(i(t, { strict: !1 }) ? m(t) : t);
7
+ return e === "bytes" ? o : s(o);
16
8
  }
17
9
  export {
18
- b as hashAuthorization
10
+ x as keccak256
19
11
  };
package/dist/index4.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index17.cjs"),p=require("viem"),n=require("./index3.cjs"),w=require("./index18.cjs"),f=async(s,i,o,t)=>{if(!t.account)return e.Err("No account found");const a=p.getContract({address:n.with0x(i),abi:p.erc20Abi,client:t});try{const c=await a.read.allowance([n.with0x(t.account.address),n.with0x(o)]);if(BigInt(c)<BigInt(s)){const r=await a.write.approve([n.with0x(o),p.maxUint256],{account:t.account,chain:t.chain});console.log("approval tx: ",r);const u=await d(t,r);return u.error?e.Err(u.error):u.val.status!=="success"?e.Err("Failed to approve"):e.Ok(r)}return e.Ok("Already approved")}catch(c){return e.Err("Failed to approve: "+c)}},d=async(s,i,o=2e3,t=12e4)=>{const a=Math.ceil(t/o);for(let c=0;c<a;c++){try{const r=await w.getTransactionReceipt(s,{hash:i});if(r)return e.Ok(r)}catch(r){if(console.log("txReceipt err: ",r),!r.message.includes("Transaction receipt with hash"))return e.Err(r.message)}c<a-1&&await new Promise(r=>setTimeout(r,o))}return e.Err(`Timed out waiting for receipt of ${i}`)};exports.checkAllowanceAndApprove=f;exports.waitForTransactionReceipt=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index17.cjs"),p=require("viem"),n=require("./index3.cjs"),w=require("./index18.cjs"),f=async(s,a,o,t)=>{if(!t.account)return e.Err("No account found");const i=p.getContract({address:n.with0x(a),abi:p.erc20Abi,client:t});try{const c=await i.read.allowance([n.with0x(t.account.address),n.with0x(o)]);if(BigInt(c)<BigInt(s)){const r=await i.write.approve([n.with0x(o),p.maxUint256],{account:t.account,chain:t.chain}),u=await d(t,r);return u.error?e.Err(u.error):u.val.status!=="success"?e.Err("Failed to approve"):e.Ok(r)}return e.Ok("Already approved")}catch(c){return e.Err("Failed to approve: "+c)}},d=async(s,a,o=2e3,t=12e4)=>{const i=Math.ceil(t/o);for(let c=0;c<i;c++){try{const r=await w.getTransactionReceipt(s,{hash:a});if(r)return e.Ok(r)}catch(r){if(!r.message.includes(`Transaction receipt with hash "${a}" could not be found.`))return e.Err(r.message)}c<i-1&&await new Promise(r=>setTimeout(r,o))}return e.Err(`Timed out waiting for receipt of ${a}`)};exports.checkAllowanceAndApprove=f;exports.waitForTransactionReceipt=d;