@gardenfi/utils 2.0.0 → 2.0.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 (103) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +12 -11
  3. package/dist/index11.cjs +1 -1
  4. package/dist/index11.js +186 -92
  5. package/dist/index12.cjs +1 -16
  6. package/dist/index12.js +93 -113
  7. package/dist/index13.cjs +16 -1
  8. package/dist/index13.js +112 -30
  9. package/dist/index14.cjs +1 -1
  10. package/dist/index14.js +18 -17
  11. package/dist/index15.cjs +1 -1
  12. package/dist/index15.js +31 -18
  13. package/dist/index16.cjs +1 -1
  14. package/dist/index16.js +17 -7
  15. package/dist/index17.cjs +1 -1
  16. package/dist/index17.js +6 -19
  17. package/dist/index18.cjs +1 -1
  18. package/dist/index18.js +20 -22
  19. package/dist/index19.cjs +1 -1
  20. package/dist/index19.js +21 -8
  21. package/dist/index20.cjs +1 -1
  22. package/dist/index20.js +8 -31
  23. package/dist/index21.cjs +1 -1
  24. package/dist/index21.js +31 -26
  25. package/dist/index22.cjs +1 -1
  26. package/dist/index22.js +25 -22
  27. package/dist/index23.cjs +1 -1
  28. package/dist/index23.js +22 -50
  29. package/dist/index24.cjs +1 -1
  30. package/dist/index24.js +51 -12
  31. package/dist/index25.cjs +1 -1
  32. package/dist/index25.js +12 -24
  33. package/dist/index26.cjs +1 -1
  34. package/dist/index26.js +24 -75
  35. package/dist/index27.cjs +1 -1
  36. package/dist/index27.js +74 -22
  37. package/dist/index28.cjs +1 -1
  38. package/dist/index28.js +23 -7
  39. package/dist/index29.cjs +1 -1
  40. package/dist/index29.js +7 -29
  41. package/dist/index30.cjs +1 -1
  42. package/dist/index30.js +31 -14
  43. package/dist/index31.cjs +1 -1
  44. package/dist/index31.js +16 -2
  45. package/dist/index32.cjs +1 -1
  46. package/dist/index32.js +2 -9
  47. package/dist/index33.cjs +1 -1
  48. package/dist/index33.js +8 -20
  49. package/dist/index34.cjs +1 -1
  50. package/dist/index34.js +20 -12
  51. package/dist/index35.cjs +1 -1
  52. package/dist/index35.js +10 -32
  53. package/dist/index36.cjs +1 -2
  54. package/dist/index36.js +33 -58
  55. package/dist/index37.cjs +2 -1
  56. package/dist/index37.js +60 -2
  57. package/dist/index38.cjs +1 -1
  58. package/dist/index38.js +2 -5
  59. package/dist/index39.cjs +1 -1
  60. package/dist/index39.js +4 -11
  61. package/dist/index4.cjs +1 -1
  62. package/dist/index4.js +15 -15
  63. package/dist/index40.cjs +1 -1
  64. package/dist/index40.js +11 -3
  65. package/dist/index41.cjs +1 -1
  66. package/dist/index41.js +3 -21
  67. package/dist/index42.cjs +1 -1
  68. package/dist/index42.js +21 -12
  69. package/dist/index43.cjs +1 -1
  70. package/dist/index43.js +11 -54
  71. package/dist/index44.cjs +1 -1
  72. package/dist/index44.js +55 -6
  73. package/dist/index45.cjs +1 -1
  74. package/dist/index45.js +6 -21
  75. package/dist/index46.cjs +1 -1
  76. package/dist/index46.js +21 -11
  77. package/dist/index47.cjs +1 -1
  78. package/dist/index47.js +11 -3
  79. package/dist/index48.cjs +1 -1
  80. package/dist/index48.js +3 -11
  81. package/dist/index49.cjs +1 -1
  82. package/dist/index49.js +11 -19
  83. package/dist/index50.cjs +1 -1
  84. package/dist/index50.js +19 -8
  85. package/dist/index51.cjs +1 -1
  86. package/dist/index51.js +1 -1
  87. package/dist/index52.cjs +1 -1
  88. package/dist/index52.js +8 -104
  89. package/dist/index53.cjs +1 -1
  90. package/dist/index53.js +102 -27
  91. package/dist/index54.cjs +1 -1
  92. package/dist/index54.js +27 -17
  93. package/dist/index55.cjs +1 -1
  94. package/dist/index55.js +16 -30
  95. package/dist/index56.cjs +1 -0
  96. package/dist/index56.js +41 -0
  97. package/dist/index6.cjs +1 -1
  98. package/dist/index6.js +65 -49
  99. package/dist/index9.cjs +1 -1
  100. package/dist/index9.js +6 -6
  101. package/dist/src/lib/auth/auth.types.d.ts +9 -10
  102. package/dist/src/lib/auth/siwe.d.ts +13 -3
  103. package/package.json +2 -4
package/dist/index32.js CHANGED
@@ -1,11 +1,4 @@
1
- function i() {
2
- let e = () => {
3
- }, n = () => {
4
- };
5
- return { promise: new Promise((r, o) => {
6
- e = r, n = o;
7
- }), resolve: e, reject: n };
8
- }
1
+ const g = (r, n, i) => JSON.stringify(r, (e, t) => typeof t == "bigint" ? t.toString() : t, i);
9
2
  export {
10
- i as withResolvers
3
+ g as stringify
11
4
  };
package/dist/index33.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index40.cjs");function f(n,{delay:e=100,retryCount:o=2,shouldRetry:c=()=>!0}={}){return new Promise((s,y)=>{const a=async({count:r=0}={})=>{const w=async({error:t})=>{const i=typeof e=="function"?e({count:r,error:t}):e;i&&await u.wait(i),a({count:r+1})};try{const t=await n();s(t)}catch(t){if(r<o&&await c({count:r,error:t}))return w({error:t});y(t)}};a()})}exports.withRetry=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(){let e=()=>{},t=()=>{};return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}exports.withResolvers=i;
package/dist/index33.js CHANGED
@@ -1,23 +1,11 @@
1
- import { wait as w } from "./index40.js";
2
- function p(n, { delay: e = 100, retryCount: o = 2, shouldRetry: c = () => !0 } = {}) {
3
- return new Promise((s, y) => {
4
- const a = async ({ count: r = 0 } = {}) => {
5
- const f = async ({ error: t }) => {
6
- const i = typeof e == "function" ? e({ count: r, error: t }) : e;
7
- i && await w(i), a({ count: r + 1 });
8
- };
9
- try {
10
- const t = await n();
11
- s(t);
12
- } catch (t) {
13
- if (r < o && await c({ count: r, error: t }))
14
- return f({ error: t });
15
- y(t);
16
- }
17
- };
18
- a();
19
- });
1
+ function i() {
2
+ let e = () => {
3
+ }, n = () => {
4
+ };
5
+ return { promise: new Promise((r, o) => {
6
+ e = r, n = o;
7
+ }), resolve: e, reject: n };
20
8
  }
21
9
  export {
22
- p as withRetry
10
+ i as withResolvers
23
11
  };
package/dist/index34.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index36.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index41.cjs");function f(n,{delay:e=100,retryCount:o=2,shouldRetry:c=()=>!0}={}){return new Promise((s,y)=>{const a=async({count:r=0}={})=>{const w=async({error:t})=>{const i=typeof e=="function"?e({count:r,error:t}):e;i&&await u.wait(i),a({count:r+1})};try{const t=await n();s(t)}catch(t){if(r<o&&await c({count:r,error:t}))return w({error:t});y(t)}};a()})}exports.withRetry=f;
package/dist/index34.js CHANGED
@@ -1,15 +1,23 @@
1
- import { BaseError as t } from "./index36.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
- }
1
+ import { wait as w } from "./index41.js";
2
+ function p(n, { delay: e = 100, retryCount: o = 2, shouldRetry: c = () => !0 } = {}) {
3
+ return new Promise((s, y) => {
4
+ const a = async ({ count: r = 0 } = {}) => {
5
+ const f = async ({ error: t }) => {
6
+ const i = typeof e == "function" ? e({ count: r, error: t }) : e;
7
+ i && await w(i), a({ count: r + 1 });
8
+ };
9
+ try {
10
+ const t = await n();
11
+ s(t);
12
+ } catch (t) {
13
+ if (r < o && await c({ count: r, error: t }))
14
+ return f({ error: t });
15
+ y(t);
16
+ }
17
+ };
18
+ a();
19
+ });
11
20
  }
12
21
  export {
13
- $ as IntegerOutOfRangeError,
14
- c as SizeOverflowError
22
+ p as withRetry
15
23
  };
package/dist/index35.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index51.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index37.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/index35.js CHANGED
@@ -1,37 +1,15 @@
1
- import { SizeExceedsPaddingSizeError as d } from "./index51.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")}`;
1
+ import { BaseError as t } from "./index37.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
+ }
16
6
  }
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];
7
+ class c extends t {
8
+ constructor({ givenSize: e, maxSize: r }) {
9
+ super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" });
30
10
  }
31
- return e;
32
11
  }
33
12
  export {
34
- f as pad,
35
- i as padBytes,
36
- p as padHex
13
+ $ as IntegerOutOfRangeError,
14
+ c as SizeOverflowError
37
15
  };
package/dist/index36.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index37.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index51.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/index36.js CHANGED
@@ -1,62 +1,37 @@
1
- import { version as l } from "./index37.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
- }
1
+ import { SizeExceedsPaddingSizeError as d } from "./index51.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 });
56
4
  }
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;
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;
59
32
  }
60
33
  export {
61
- r as BaseError
34
+ f as pad,
35
+ i as padBytes,
36
+ p as padHex
62
37
  };
package/dist/index37.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.21.41";exports.version=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index38.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/index37.js CHANGED
@@ -1,4 +1,62 @@
1
- const o = "2.21.41";
1
+ import { version as l } from "./index38.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;
59
+ }
2
60
  export {
3
- o as version
61
+ r as BaseError
4
62
  };
package/dist/index38.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index47.cjs");function i(e){return t.isHex(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}exports.size=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="2.22.23";exports.version=e;
package/dist/index38.js CHANGED
@@ -1,7 +1,4 @@
1
- import { isHex as r } from "./index47.js";
2
- function i(t) {
3
- return r(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
4
- }
1
+ const o = "2.22.23";
5
2
  export {
6
- i as size
3
+ o as version
7
4
  };
package/dist/index39.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index48.cjs");function i(e){return t.isHex(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}exports.size=i;
package/dist/index39.js CHANGED
@@ -1,14 +1,7 @@
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
- };
1
+ import { isHex as r } from "./index48.js";
2
+ function i(t) {
3
+ return r(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
11
4
  }
12
5
  export {
13
- r as formatLog
6
+ i as size
14
7
  };
package/dist/index4.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@catalogfi/utils"),a=require("viem"),c=require("./index3.cjs"),p=require("./index11.cjs"),d=async(s,u,o,r)=>{if(!r.account)return t.Err("No account found");const n=a.getContract({address:c.with0x(u),abi:a.erc20Abi,client:r});try{const e=await n.read.allowance([c.with0x(r.account.address),c.with0x(o)]);if(BigInt(e)<BigInt(s)){const i=await n.write.approve([c.with0x(o),a.maxUint256],{account:r.account,chain:r.chain});return(await p.waitForTransactionReceipt(r,{hash:i})).status!=="success"?t.Err("Failed to approve"):t.Ok(i)}return t.Ok("Already approved")}catch(e){return t.Err("Failed to approve: "+e)}};exports.checkAllowanceAndApprove=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index11.cjs"),a=require("viem"),e=require("./index3.cjs"),p=require("./index12.cjs"),d=async(s,u,o,r)=>{if(!r.account)return c.Err("No account found");const n=a.getContract({address:e.with0x(u),abi:a.erc20Abi,client:r});try{const t=await n.read.allowance([e.with0x(r.account.address),e.with0x(o)]);if(BigInt(t)<BigInt(s)){const i=await n.write.approve([e.with0x(o),a.maxUint256],{account:r.account,chain:r.chain});return(await p.waitForTransactionReceipt(r,{hash:i})).status!=="success"?c.Err("Failed to approve"):c.Ok(i)}return c.Ok("Already approved")}catch(t){return c.Err("Failed to approve: "+t)}};exports.checkAllowanceAndApprove=d;
package/dist/index4.js CHANGED
@@ -1,22 +1,22 @@
1
- import { Err as a, Ok as i } from "@catalogfi/utils";
1
+ import { Err as c, Ok as i } from "./index11.js";
2
2
  import { getContract as u, erc20Abi as d, maxUint256 as m } from "viem";
3
- import { with0x as o } from "./index3.js";
4
- import { waitForTransactionReceipt as f } from "./index11.js";
5
- const x = async (p, s, t, r) => {
6
- if (!r.account) return a("No account found");
3
+ import { with0x as a } from "./index3.js";
4
+ import { waitForTransactionReceipt as f } from "./index12.js";
5
+ const g = async (p, s, t, r) => {
6
+ if (!r.account) return c("No account found");
7
7
  const n = u({
8
- address: o(s),
8
+ address: a(s),
9
9
  abi: d,
10
10
  client: r
11
11
  });
12
12
  try {
13
- const c = await n.read.allowance([
14
- o(r.account.address),
15
- o(t)
13
+ const o = await n.read.allowance([
14
+ a(r.account.address),
15
+ a(t)
16
16
  ]);
17
- if (BigInt(c) < BigInt(p)) {
17
+ if (BigInt(o) < BigInt(p)) {
18
18
  const e = await n.write.approve(
19
- [o(t), m],
19
+ [a(t), m],
20
20
  {
21
21
  account: r.account,
22
22
  chain: r.chain
@@ -24,13 +24,13 @@ const x = async (p, s, t, r) => {
24
24
  );
25
25
  return (await f(r, {
26
26
  hash: e
27
- })).status !== "success" ? a("Failed to approve") : i(e);
27
+ })).status !== "success" ? c("Failed to approve") : i(e);
28
28
  }
29
29
  return i("Already approved");
30
- } catch (c) {
31
- return a("Failed to approve: " + c);
30
+ } catch (o) {
31
+ return c("Failed to approve: " + o);
32
32
  }
33
33
  };
34
34
  export {
35
- x as checkAllowanceAndApprove
35
+ g as checkAllowanceAndApprove
36
36
  };
package/dist/index40.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function i(e){return new Promise(t=>setTimeout(t,e))}exports.wait=i;
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/index40.js CHANGED
@@ -1,6 +1,14 @@
1
- async function n(e) {
2
- return new Promise((t) => setTimeout(t, e));
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
+ };
3
11
  }
4
12
  export {
5
- n as wait
13
+ r as formatLog
6
14
  };
package/dist/index41.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index42.cjs"),f=require("./index43.cjs"),a=require("./index44.cjs"),l=require("./index45.cjs"),A=require("./index46.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)),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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function i(e){return new Promise(t=>setTimeout(t,e))}exports.wait=i;
package/dist/index41.js CHANGED
@@ -1,24 +1,6 @@
1
- import { InvalidAddressError as c } from "./index42.js";
2
- import { stringToBytes as m } from "./index43.js";
3
- import { keccak256 as p } from "./index44.js";
4
- import { LruMap as u } from "./index45.js";
5
- import { isAddress as $ } from "./index46.js";
6
- const s = /* @__PURE__ */ new u(8192);
7
- function h(t, e) {
8
- if (s.has(`${t}.${e}`))
9
- return s.get(`${t}.${e}`);
10
- const i = t.substring(2).toLowerCase(), n = p(m(i)), o = i.split("");
11
- for (let r = 0; r < 40; r += 2)
12
- n[r >> 1] >> 4 >= 8 && o[r] && (o[r] = o[r].toUpperCase()), (n[r >> 1] & 15) >= 8 && o[r + 1] && (o[r + 1] = o[r + 1].toUpperCase());
13
- const f = `0x${o.join("")}`;
14
- return s.set(`${t}.${e}`, f), f;
15
- }
16
- function w(t, e) {
17
- if (!$(t, { strict: !1 }))
18
- throw new c({ address: t });
19
- return h(t, e);
1
+ async function n(e) {
2
+ return new Promise((t) => setTimeout(t, e));
20
3
  }
21
4
  export {
22
- h as checksumAddress,
23
- w as getAddress
5
+ n as wait
24
6
  };
package/dist/index42.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index36.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 d=require("./index43.cjs"),f=require("./index44.cjs"),a=require("./index45.cjs"),l=require("./index46.cjs"),A=require("./index47.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)),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/index42.js CHANGED
@@ -1,15 +1,24 @@
1
- import { BaseError as r } from "./index36.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 { InvalidAddressError as c } from "./index43.js";
2
+ import { stringToBytes as m } from "./index44.js";
3
+ import { keccak256 as p } from "./index45.js";
4
+ import { LruMap as u } from "./index46.js";
5
+ import { isAddress as $ } from "./index47.js";
6
+ const s = /* @__PURE__ */ new u(8192);
7
+ function h(t, e) {
8
+ if (s.has(`${t}.${e}`))
9
+ return s.get(`${t}.${e}`);
10
+ const i = t.substring(2).toLowerCase(), n = p(m(i)), o = i.split("");
11
+ for (let r = 0; r < 40; r += 2)
12
+ n[r >> 1] >> 4 >= 8 && o[r] && (o[r] = o[r].toUpperCase()), (n[r >> 1] & 15) >= 8 && o[r + 1] && (o[r + 1] = o[r + 1].toUpperCase());
13
+ const f = `0x${o.join("")}`;
14
+ return s.set(`${t}.${e}`, f), f;
15
+ }
16
+ function w(t, e) {
17
+ if (!$(t, { strict: !1 }))
18
+ throw new c({ address: t });
19
+ return h(t, e);
12
20
  }
13
21
  export {
14
- d as InvalidAddressError
22
+ h as checksumAddress,
23
+ w as getAddress
15
24
  };
package/dist/index43.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index36.cjs"),l=require("./index47.cjs"),u=require("./index35.cjs"),f=require("./index27.cjs"),m=require("./index17.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 s=require("./index37.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/index43.js CHANGED
@@ -1,58 +1,15 @@
1
- import { BaseError as g } from "./index36.js";
2
- import { isHex as x } from "./index47.js";
3
- import { pad as s } from "./index35.js";
4
- import { assertSize as u } from "./index27.js";
5
- import { numberToHex as h } from "./index17.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;
1
+ import { BaseError as r } from "./index37.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
+ });
41
11
  }
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
12
  }
52
13
  export {
53
- B as boolToBytes,
54
- y as hexToBytes,
55
- T as numberToBytes,
56
- l as stringToBytes,
57
- F as toBytes
14
+ d as InvalidAddressError
58
15
  };
package/dist/index44.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index52.cjs"),s=require("./index47.cjs"),c=require("./index43.cjs");function r(e,o){return t.keccak_256(s.isHex(e,{strict:!1})?c.toBytes(e):e)}exports.keccak256=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index37.cjs"),l=require("./index48.cjs"),u=require("./index36.cjs"),f=require("./index28.cjs"),m=require("./index18.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;