@gardenfi/utils 2.5.2 → 2.5.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +9 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +37 -36
  4. package/dist/index10.cjs +1 -1
  5. package/dist/index10.js +4 -4
  6. package/dist/index11.cjs +1 -1
  7. package/dist/index11.js +16 -20
  8. package/dist/index112.cjs +1 -1
  9. package/dist/index112.js +15 -15
  10. package/dist/index121.cjs +1 -1
  11. package/dist/index121.js +1 -1
  12. package/dist/index130.cjs +1 -1
  13. package/dist/index130.js +1 -1
  14. package/dist/index16.cjs +1 -1
  15. package/dist/index16.js +4 -4
  16. package/dist/index18.cjs +1 -1
  17. package/dist/index18.js +20 -9
  18. package/dist/index197.cjs +1 -1
  19. package/dist/index197.js +17 -30
  20. package/dist/index22.cjs +1 -1
  21. package/dist/index22.js +84 -51
  22. package/dist/index226.cjs +1 -1
  23. package/dist/index226.js +2 -2
  24. package/dist/index229.cjs +1 -1
  25. package/dist/index229.js +2 -2
  26. package/dist/index230.cjs +1 -1
  27. package/dist/index230.js +1 -1
  28. package/dist/index234.cjs +1 -1
  29. package/dist/index234.js +7 -8
  30. package/dist/index235.cjs +1 -1
  31. package/dist/index235.js +1 -1
  32. package/dist/index236.cjs +1 -1
  33. package/dist/index236.js +1 -1
  34. package/dist/index237.cjs +1 -1
  35. package/dist/index237.js +2 -2
  36. package/dist/index24.cjs +1 -1
  37. package/dist/index24.js +30 -13
  38. package/dist/index249.cjs +1 -1
  39. package/dist/index249.js +3 -3
  40. package/dist/index25.cjs +1 -1
  41. package/dist/index25.js +30 -58
  42. package/dist/index250.cjs +1 -1
  43. package/dist/index250.js +3 -3
  44. package/dist/index256.cjs +1 -1
  45. package/dist/index256.js +17 -12
  46. package/dist/index26.cjs +1 -16
  47. package/dist/index26.js +11 -113
  48. package/dist/index269.cjs +1 -1
  49. package/dist/index269.js +4 -4
  50. package/dist/index27.cjs +1 -1
  51. package/dist/index27.js +58 -32
  52. package/dist/index270.cjs +1 -1
  53. package/dist/index270.js +5 -5
  54. package/dist/index271.cjs +1 -1
  55. package/dist/index271.js +27 -21
  56. package/dist/index272.cjs +1 -1
  57. package/dist/index272.js +54 -20
  58. package/dist/index273.cjs +1 -1
  59. package/dist/index273.js +18 -54
  60. package/dist/index274.cjs +1 -1
  61. package/dist/index274.js +10 -34
  62. package/dist/index275.cjs +1 -1
  63. package/dist/index275.js +7 -10
  64. package/dist/index276.cjs +1 -1
  65. package/dist/index276.js +12 -13
  66. package/dist/index277.cjs +1 -1
  67. package/dist/index277.js +11 -12
  68. package/dist/index28.cjs +1 -1
  69. package/dist/index28.js +13 -31
  70. package/dist/index280.cjs +1 -1
  71. package/dist/index280.js +103 -11
  72. package/dist/index281.cjs +1 -1
  73. package/dist/index281.js +6 -103
  74. package/dist/index282.cjs +1 -1
  75. package/dist/index282.js +243 -5
  76. package/dist/index283.cjs +1 -1
  77. package/dist/index283.js +6 -224
  78. package/dist/index284.cjs +1 -1
  79. package/dist/index284.js +7 -7
  80. package/dist/index285.cjs +1 -1
  81. package/dist/index285.js +27 -7
  82. package/dist/index286.cjs +1 -1
  83. package/dist/index286.js +18 -25
  84. package/dist/index287.cjs +1 -1
  85. package/dist/index287.js +145 -18
  86. package/dist/index288.cjs +1 -1
  87. package/dist/index288.js +3 -146
  88. package/dist/index289.cjs +1 -1
  89. package/dist/index289.js +155 -3
  90. package/dist/index29.cjs +16 -1
  91. package/dist/index29.js +113 -11
  92. package/dist/index290.cjs +1 -1
  93. package/dist/index290.js +7 -138
  94. package/dist/index291.cjs +1 -1
  95. package/dist/index291.js +128 -143
  96. package/dist/index292.cjs +1 -1
  97. package/dist/index292.js +111 -7
  98. package/dist/index293.cjs +2 -1
  99. package/dist/index293.js +116 -95
  100. package/dist/index294.cjs +1 -2
  101. package/dist/index294.js +35 -127
  102. package/dist/index295.cjs +1 -1
  103. package/dist/index295.js +66 -30
  104. package/dist/index296.cjs +1 -1
  105. package/dist/index296.js +2 -79
  106. package/dist/index297.cjs +1 -1
  107. package/dist/index297.js +12 -2
  108. package/dist/index298.cjs +1 -1
  109. package/dist/index298.js +19 -11
  110. package/dist/index299.cjs +1 -1
  111. package/dist/index299.js +68 -19
  112. package/dist/index3.cjs +1 -1
  113. package/dist/index3.js +10 -8
  114. package/dist/index300.cjs +1 -1
  115. package/dist/index300.js +786 -66
  116. package/dist/index301.cjs +1 -1
  117. package/dist/index301.js +134 -684
  118. package/dist/index302.cjs +1 -1
  119. package/dist/index302.js +185 -124
  120. package/dist/index303.cjs +2 -1
  121. package/dist/index303.js +63 -198
  122. package/dist/index304.cjs +1 -2
  123. package/dist/index304.js +7 -66
  124. package/dist/index305.cjs +1 -1
  125. package/dist/index305.js +62 -4
  126. package/dist/index306.cjs +1 -1
  127. package/dist/index306.js +22 -40
  128. package/dist/index307.cjs +1 -1
  129. package/dist/index307.js +5 -7
  130. package/dist/index308.cjs +1 -1
  131. package/dist/index308.js +72 -57
  132. package/dist/index309.cjs +1 -1
  133. package/dist/index309.js +4 -78
  134. package/dist/index310.cjs +1 -1
  135. package/dist/index310.js +195 -4
  136. package/dist/index311.cjs +1 -1
  137. package/dist/index311.js +4 -194
  138. package/dist/index312.cjs +1 -1
  139. package/dist/index312.js +35 -58
  140. package/dist/index313.cjs +2 -1
  141. package/dist/index313.js +40 -43
  142. package/dist/index314.cjs +1 -1
  143. package/dist/index314.js +2 -5
  144. package/dist/index315.cjs +1 -1
  145. package/dist/index315.js +11 -5
  146. package/dist/index316.cjs +1 -1
  147. package/dist/index316.js +20 -2
  148. package/dist/index317.cjs +1 -1
  149. package/dist/index317.js +8 -21
  150. package/dist/index318.cjs +1 -0
  151. package/dist/index318.js +45 -0
  152. package/dist/index319.cjs +1 -0
  153. package/dist/index319.js +69 -0
  154. package/dist/index320.cjs +1 -0
  155. package/dist/index320.js +68 -0
  156. package/dist/index321.cjs +1 -0
  157. package/dist/index321.js +191 -0
  158. package/dist/index322.cjs +1 -0
  159. package/dist/index322.js +79 -0
  160. package/dist/index323.cjs +1 -0
  161. package/dist/index323.js +43 -0
  162. package/dist/index324.cjs +1 -0
  163. package/dist/index324.js +19 -0
  164. package/dist/index325.cjs +1 -0
  165. package/dist/index325.js +16 -0
  166. package/dist/index326.cjs +1 -0
  167. package/dist/index326.js +7 -0
  168. package/dist/index327.cjs +1 -0
  169. package/dist/index327.js +66 -0
  170. package/dist/index328.cjs +1 -0
  171. package/dist/index328.js +7 -0
  172. package/dist/index329.cjs +1 -0
  173. package/dist/index329.js +47 -0
  174. package/dist/index330.cjs +1 -0
  175. package/dist/index330.js +71 -0
  176. package/dist/index331.cjs +1 -0
  177. package/dist/index331.js +4 -0
  178. package/dist/index332.cjs +1 -0
  179. package/dist/index332.js +24 -0
  180. package/dist/index55.cjs +1 -1
  181. package/dist/index55.js +1 -1
  182. package/dist/index58.cjs +1 -1
  183. package/dist/index58.js +35 -34
  184. package/dist/index60.cjs +1 -1
  185. package/dist/index60.js +26 -30
  186. package/dist/index61.cjs +1 -1
  187. package/dist/index61.js +13 -9
  188. package/dist/index62.cjs +1 -1
  189. package/dist/index62.js +19 -19
  190. package/dist/index89.cjs +1 -1
  191. package/dist/index89.js +31 -30
  192. package/dist/index9.cjs +1 -1
  193. package/dist/index9.js +2 -2
  194. package/dist/index95.cjs +1 -1
  195. package/dist/index95.js +73 -73
  196. package/dist/src/lib/auth/apikey/apikey.d.ts +1 -1
  197. package/dist/src/lib/auth/auth.types.d.ts +1 -1
  198. package/dist/src/lib/fetcher/fetcher.d.ts +2 -0
  199. package/dist/src/lib/utils.d.ts +1 -0
  200. package/package.json +2 -2
package/dist/index304.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index314.cjs");class c extends Error{constructor(r,e={}){const a=(()=>{var s;if(e.cause instanceof c){if(e.cause.details)return e.cause.details;if(e.cause.shortMessage)return e.cause.shortMessage}return e.cause&&"details"in e.cause&&typeof e.cause.details=="string"?e.cause.details:(s=e.cause)!=null&&s.message?e.cause.message:e.details})(),u=e.cause instanceof c&&e.cause.docsPath||e.docsPath,i=`https://oxlib.sh${u??""}`,d=[r||"An error occurred.",...e.metaMessages?["",...e.metaMessages]:[],...a||u?["",a?`Details: ${a}`:void 0,u?`See: ${i}`:void 0]:[]].filter(s=>typeof s=="string").join(`
2
- `);super(d,e.cause?{cause:e.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{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,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${n.getVersion()}`}),this.cause=e.cause,this.details=a,this.docs=i,this.docsPath=u,this.shortMessage=r}walk(r){return l(this,r)}}function l(t,r){return r!=null&&r(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?l(t.cause,r):r?null:t}exports.BaseError=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index229.cjs"),o=require("./index327.cjs"),n=require("./index289.cjs");function i(e,r={}){const{as:s=typeof e=="string"?"Hex":"Bytes"}=r,t=c.keccak_256(o.from(e));return s==="Bytes"?t:n.fromBytes(t)}exports.keccak256=i;
package/dist/index304.js CHANGED
@@ -1,69 +1,10 @@
1
- import { getVersion as n } from "./index314.js";
2
- class c extends Error {
3
- constructor(t, e = {}) {
4
- const a = (() => {
5
- var s;
6
- if (e.cause instanceof c) {
7
- if (e.cause.details)
8
- return e.cause.details;
9
- if (e.cause.shortMessage)
10
- return e.cause.shortMessage;
11
- }
12
- return e.cause && "details" in e.cause && typeof e.cause.details == "string" ? e.cause.details : (s = e.cause) != null && s.message ? e.cause.message : e.details;
13
- })(), u = e.cause instanceof c && e.cause.docsPath || e.docsPath, i = `https://oxlib.sh${u ?? ""}`, d = [
14
- t || "An error occurred.",
15
- ...e.metaMessages ? ["", ...e.metaMessages] : [],
16
- ...a || u ? [
17
- "",
18
- a ? `Details: ${a}` : void 0,
19
- u ? `See: ${i}` : void 0
20
- ] : []
21
- ].filter((s) => typeof s == "string").join(`
22
- `);
23
- super(d, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
24
- enumerable: !0,
25
- configurable: !0,
26
- writable: !0,
27
- value: void 0
28
- }), Object.defineProperty(this, "docs", {
29
- enumerable: !0,
30
- configurable: !0,
31
- writable: !0,
32
- value: void 0
33
- }), Object.defineProperty(this, "docsPath", {
34
- enumerable: !0,
35
- configurable: !0,
36
- writable: !0,
37
- value: void 0
38
- }), Object.defineProperty(this, "shortMessage", {
39
- enumerable: !0,
40
- configurable: !0,
41
- writable: !0,
42
- value: void 0
43
- }), Object.defineProperty(this, "cause", {
44
- enumerable: !0,
45
- configurable: !0,
46
- writable: !0,
47
- value: void 0
48
- }), Object.defineProperty(this, "name", {
49
- enumerable: !0,
50
- configurable: !0,
51
- writable: !0,
52
- value: "BaseError"
53
- }), Object.defineProperty(this, "version", {
54
- enumerable: !0,
55
- configurable: !0,
56
- writable: !0,
57
- value: `ox@${n()}`
58
- }), this.cause = e.cause, this.details = a, this.docs = i, this.docsPath = u, this.shortMessage = t;
59
- }
60
- walk(t) {
61
- return l(this, t);
62
- }
63
- }
64
- function l(r, t) {
65
- return t != null && t(r) ? r : r && typeof r == "object" && "cause" in r && r.cause ? l(r.cause, t) : t ? null : r;
1
+ import { keccak_256 as f } from "./index229.js";
2
+ import { from as m } from "./index327.js";
3
+ import { fromBytes as s } from "./index289.js";
4
+ function p(t, o = {}) {
5
+ const { as: e = typeof t == "string" ? "Hex" : "Bytes" } = o, r = f(m(t));
6
+ return e === "Bytes" ? r : s(r);
66
7
  }
67
8
  export {
68
- c as BaseError
9
+ p as keccak256
69
10
  };
package/dist/index305.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n="#__bigint";function e(i,f,r){return JSON.stringify(i,(g,t)=>typeof t=="bigint"?t.toString()+n:t,r)}exports.stringify=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index308.cjs"),a=require("./index303.cjs");function d(r){let i=!0,t="",e=0,n="",o=!1;for(let s=0;s<r.length;s++){const u=r[s];if(["(",")",","].includes(u)&&(i=!0),u==="("&&e++,u===")"&&e--,!!i){if(e===0){if(u===" "&&["event","function","error",""].includes(n))n="";else if(n+=u,u===")"){o=!0;break}continue}if(u===" "){r[s-1]!==","&&t!==","&&t!==",("&&(t="",i=!1);continue}n+=u,t+=u}}if(!o)throw new a.BaseError("Unable to normalize signature.");return n}function l(r,i){const t=typeof r,e=i.type;switch(e){case"address":return c.validate(r,{strict:!1});case"bool":return t==="boolean";case"function":return t==="string";case"string":return t==="string";default:return e==="tuple"&&"components"in i?Object.values(i.components).every((n,o)=>l(Object.values(r)[o],n)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e)?t==="number"||t==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e)?t==="string"||r instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e)?Array.isArray(r)&&r.every(n=>l(n,{...i,type:e.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function f(r,i,t){for(const e in r){const n=r[e],o=i[e];if(n.type==="tuple"&&o.type==="tuple"&&"components"in n&&"components"in o)return f(n.components,o.components,t[e]);const s=[n.type,o.type];if(s.includes("address")&&s.includes("bytes20")?!0:s.includes("address")&&s.includes("string")?c.validate(t[e],{strict:!1}):s.includes("address")&&s.includes("bytes")?c.validate(t[e],{strict:!1}):!1)return s}}exports.getAmbiguousTypes=f;exports.isArgOfType=l;exports.normalizeSignature=d;
package/dist/index305.js CHANGED
@@ -1,7 +1,65 @@
1
- const r = "#__bigint";
2
- function g(i, f, n) {
3
- return JSON.stringify(i, (e, t) => typeof t == "bigint" ? t.toString() + r : t, n);
1
+ import { validate as c } from "./index308.js";
2
+ import { BaseError as f } from "./index303.js";
3
+ function y(r) {
4
+ let i = !0, t = "", e = 0, n = "", o = !1;
5
+ for (let s = 0; s < r.length; s++) {
6
+ const u = r[s];
7
+ if (["(", ")", ","].includes(u) && (i = !0), u === "(" && e++, u === ")" && e--, !!i) {
8
+ if (e === 0) {
9
+ if (u === " " && ["event", "function", "error", ""].includes(n))
10
+ n = "";
11
+ else if (n += u, u === ")") {
12
+ o = !0;
13
+ break;
14
+ }
15
+ continue;
16
+ }
17
+ if (u === " ") {
18
+ r[s - 1] !== "," && t !== "," && t !== ",(" && (t = "", i = !1);
19
+ continue;
20
+ }
21
+ n += u, t += u;
22
+ }
23
+ }
24
+ if (!o)
25
+ throw new f("Unable to normalize signature.");
26
+ return n;
27
+ }
28
+ function l(r, i) {
29
+ const t = typeof r, e = i.type;
30
+ switch (e) {
31
+ case "address":
32
+ return c(r, { strict: !1 });
33
+ case "bool":
34
+ return t === "boolean";
35
+ case "function":
36
+ return t === "string";
37
+ case "string":
38
+ return t === "string";
39
+ default:
40
+ return e === "tuple" && "components" in i ? Object.values(i.components).every((n, o) => l(Object.values(r)[o], n)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e) ? t === "number" || t === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e) ? t === "string" || r instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e) ? Array.isArray(r) && r.every((n) => l(n, {
41
+ ...i,
42
+ // Pop off `[]` or `[M]` from end of type
43
+ type: e.replace(/(\[[0-9]{0,}\])$/, "")
44
+ })) : !1;
45
+ }
46
+ }
47
+ function a(r, i, t) {
48
+ for (const e in r) {
49
+ const n = r[e], o = i[e];
50
+ if (n.type === "tuple" && o.type === "tuple" && "components" in n && "components" in o)
51
+ return a(n.components, o.components, t[e]);
52
+ const s = [n.type, o.type];
53
+ if (s.includes("address") && s.includes("bytes20") ? !0 : s.includes("address") && s.includes("string") ? c(t[e], {
54
+ strict: !1
55
+ }) : s.includes("address") && s.includes("bytes") ? c(t[e], {
56
+ strict: !1
57
+ }) : !1)
58
+ return s;
59
+ }
4
60
  }
5
61
  export {
6
- g as stringify
62
+ a as getAmbiguousTypes,
63
+ l as isArgOfType,
64
+ y as normalizeSignature
7
65
  };
package/dist/index306.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index291.cjs");function n(t,e){if(i.size(t)>e)throw new i.SizeOverflowError({givenSize:i.size(t),maxSize:e})}function o(t,e){if(typeof e=="number"&&e>0&&e>i.size(t)-1)throw new i.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:i.size(t)})}function z(t,e,r){if(typeof e=="number"&&typeof r=="number"&&i.size(t)!==r-e)throw new i.SliceOffsetOutOfBoundsError({offset:r,position:"end",size:i.size(t)})}function a(t,e={}){const{dir:r,size:s=32}=e;if(s===0)return t;const f=t.replace("0x","");if(f.length>s*2)throw new i.SizeExceedsPaddingSizeError({size:Math.ceil(f.length/2),targetSize:s,type:"Hex"});return`0x${f[r==="right"?"padEnd":"padStart"](s*2,"0")}`}exports.assertEndOffset=z;exports.assertSize=n;exports.assertStartOffset=o;exports.pad=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index318.cjs"),u=require("./index319.cjs"),a=require("./index320.cjs"),s=require("./index321.cjs");function l(t){let e;if(typeof t=="string")e=s.parseSignature(t);else{const n=a.parseStructs(t),o=t.length;for(let r=0;r<o;r++){const i=t[r];if(!u.isStructSignature(i)){e=s.parseSignature(i,n);break}}}if(!e)throw new c.InvalidAbiItemError({signature:t});return e}exports.parseAbiItem=l;
package/dist/index306.js CHANGED
@@ -1,43 +1,25 @@
1
- import { SizeExceedsPaddingSizeError as s, size as i, SliceOffsetOutOfBoundsError as f, SizeOverflowError as p } from "./index291.js";
2
- function c(t, e) {
3
- if (i(t) > e)
4
- throw new p({
5
- givenSize: i(t),
6
- maxSize: e
7
- });
8
- }
9
- function S(t, e) {
10
- if (typeof e == "number" && e > 0 && e > i(t) - 1)
11
- throw new f({
12
- offset: e,
13
- position: "start",
14
- size: i(t)
15
- });
16
- }
17
- function d(t, e, r) {
18
- if (typeof e == "number" && typeof r == "number" && i(t) !== r - e)
19
- throw new f({
20
- offset: r,
21
- position: "end",
22
- size: i(t)
23
- });
24
- }
25
- function u(t, e = {}) {
26
- const { dir: r, size: n = 32 } = e;
27
- if (n === 0)
28
- return t;
29
- const o = t.replace("0x", "");
30
- if (o.length > n * 2)
31
- throw new s({
32
- size: Math.ceil(o.length / 2),
33
- targetSize: n,
34
- type: "Hex"
35
- });
36
- return `0x${o[r === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
1
+ import { InvalidAbiItemError as f } from "./index318.js";
2
+ import { isStructSignature as p } from "./index319.js";
3
+ import { parseStructs as c } from "./index320.js";
4
+ import { parseSignature as i } from "./index321.js";
5
+ function u(t) {
6
+ let r;
7
+ if (typeof t == "string")
8
+ r = i(t);
9
+ else {
10
+ const m = c(t), n = t.length;
11
+ for (let o = 0; o < n; o++) {
12
+ const e = t[o];
13
+ if (!p(e)) {
14
+ r = i(e, m);
15
+ break;
16
+ }
17
+ }
18
+ }
19
+ if (!r)
20
+ throw new f({ signature: t });
21
+ return r;
37
22
  }
38
23
  export {
39
- d as assertEndOffset,
40
- c as assertSize,
41
- S as assertStartOffset,
42
- u as pad
24
+ u as parseAbiItem
43
25
  };
package/dist/index307.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index229.cjs"),o=require("./index312.cjs"),n=require("./index291.cjs");function i(e,r={}){const{as:s=typeof e=="string"?"Hex":"Bytes"}=r,t=c.keccak_256(o.from(e));return s==="Bytes"?t:n.fromBytes(t)}exports.keccak256=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index315.cjs");function a(t){var e;return t.type==="function"?`function ${t.name}(${r.formatAbiParameters(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${(e=t.outputs)!=null&&e.length?` returns (${r.formatAbiParameters(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${r.formatAbiParameters(t.inputs)})`:t.type==="error"?`error ${t.name}(${r.formatAbiParameters(t.inputs)})`:t.type==="constructor"?`constructor(${r.formatAbiParameters(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?`fallback() external${t.stateMutability==="payable"?" payable":""}`:"receive() external payable"}exports.formatAbiItem=a;
package/dist/index307.js CHANGED
@@ -1,10 +1,8 @@
1
- import { keccak_256 as f } from "./index229.js";
2
- import { from as m } from "./index312.js";
3
- import { fromBytes as s } from "./index291.js";
4
- function p(t, o = {}) {
5
- const { as: e = typeof t == "string" ? "Hex" : "Bytes" } = o, r = f(m(t));
6
- return e === "Bytes" ? r : s(r);
1
+ import { formatAbiParameters as r } from "./index315.js";
2
+ function u(t) {
3
+ var n;
4
+ return t.type === "function" ? `function ${t.name}(${r(t.inputs)})${t.stateMutability && t.stateMutability !== "nonpayable" ? ` ${t.stateMutability}` : ""}${(n = t.outputs) != null && n.length ? ` returns (${r(t.outputs)})` : ""}` : t.type === "event" ? `event ${t.name}(${r(t.inputs)})` : t.type === "error" ? `error ${t.name}(${r(t.inputs)})` : t.type === "constructor" ? `constructor(${r(t.inputs)})${t.stateMutability === "payable" ? " payable" : ""}` : t.type === "fallback" ? `fallback() external${t.stateMutability === "payable" ? " payable" : ""}` : "receive() external payable";
7
5
  }
8
6
  export {
9
- p as keccak256
7
+ u as formatAbiItem
10
8
  };
package/dist/index308.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index309.cjs"),a=require("./index304.cjs");function d(r){let i=!0,t="",e=0,n="",o=!1;for(let s=0;s<r.length;s++){const u=r[s];if(["(",")",","].includes(u)&&(i=!0),u==="("&&e++,u===")"&&e--,!!i){if(e===0){if(u===" "&&["event","function","error",""].includes(n))n="";else if(n+=u,u===")"){o=!0;break}continue}if(u===" "){r[s-1]!==","&&t!==","&&t!==",("&&(t="",i=!1);continue}n+=u,t+=u}}if(!o)throw new a.BaseError("Unable to normalize signature.");return n}function l(r,i){const t=typeof r,e=i.type;switch(e){case"address":return c.validate(r,{strict:!1});case"bool":return t==="boolean";case"function":return t==="string";case"string":return t==="string";default:return e==="tuple"&&"components"in i?Object.values(i.components).every((n,o)=>l(Object.values(r)[o],n)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e)?t==="number"||t==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e)?t==="string"||r instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e)?Array.isArray(r)&&r.every(n=>l(n,{...i,type:e.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function f(r,i,t){for(const e in r){const n=r[e],o=i[e];if(n.type==="tuple"&&o.type==="tuple"&&"components"in n&&"components"in o)return f(n.components,o.components,t[e]);const s=[n.type,o.type];if(s.includes("address")&&s.includes("bytes20")?!0:s.includes("address")&&s.includes("string")?c.validate(t[e],{strict:!1}):s.includes("address")&&s.includes("bytes")?c.validate(t[e],{strict:!1}):!1)return s}}exports.getAmbiguousTypes=f;exports.isArgOfType=l;exports.normalizeSignature=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index327.cjs"),c=require("./index328.cjs"),o=require("./index303.cjs"),m=require("./index304.cjs"),b=/^0x[a-fA-F0-9]{40}$/;function i(e,t={}){const{strict:s=!0}=t;if(!b.test(e))throw new a({address:e,cause:new l});if(s){if(e.toLowerCase()===e)return;if(d(e)!==e)throw new a({address:e,cause:new h})}}function d(e){if(c.checksum.has(e))return c.checksum.get(e);i(e,{strict:!1});const t=e.substring(2).toLowerCase(),s=m.keccak256(f.fromString(t),{as:"Bytes"}),n=t.split("");for(let r=0;r<40;r+=2)s[r>>1]>>4>=8&&n[r]&&(n[r]=n[r].toUpperCase()),(s[r>>1]&15)>=8&&n[r+1]&&(n[r+1]=n[r+1].toUpperCase());const u=`0x${n.join("")}`;return c.checksum.set(e,u),u}function p(e,t={}){const{strict:s=!0}=t??{};try{return i(e,{strict:s}),!0}catch{return!1}}class a extends o.BaseError{constructor({address:t,cause:s}){super(`Address "${t}" is invalid.`,{cause:s}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class l extends o.BaseError{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class h extends o.BaseError{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}exports.InvalidAddressError=a;exports.InvalidChecksumError=h;exports.InvalidInputError=l;exports.assert=i;exports.checksum=d;exports.validate=p;
package/dist/index308.js CHANGED
@@ -1,65 +1,80 @@
1
- import { validate as c } from "./index309.js";
2
- import { BaseError as f } from "./index304.js";
3
- function y(r) {
4
- let i = !0, t = "", e = 0, n = "", o = !1;
5
- for (let s = 0; s < r.length; s++) {
6
- const u = r[s];
7
- if (["(", ")", ","].includes(u) && (i = !0), u === "(" && e++, u === ")" && e--, !!i) {
8
- if (e === 0) {
9
- if (u === " " && ["event", "function", "error", ""].includes(n))
10
- n = "";
11
- else if (n += u, u === ")") {
12
- o = !0;
13
- break;
14
- }
15
- continue;
16
- }
17
- if (u === " ") {
18
- r[s - 1] !== "," && t !== "," && t !== ",(" && (t = "", i = !1);
19
- continue;
20
- }
21
- n += u, t += u;
22
- }
1
+ import { fromString as d } from "./index327.js";
2
+ import { checksum as o } from "./index328.js";
3
+ import { BaseError as c } from "./index303.js";
4
+ import { keccak256 as f } from "./index304.js";
5
+ const l = /^0x[a-fA-F0-9]{40}$/;
6
+ function u(r, t = {}) {
7
+ const { strict: s = !0 } = t;
8
+ if (!l.test(r))
9
+ throw new i({
10
+ address: r,
11
+ cause: new h()
12
+ });
13
+ if (s) {
14
+ if (r.toLowerCase() === r)
15
+ return;
16
+ if (m(r) !== r)
17
+ throw new i({
18
+ address: r,
19
+ cause: new p()
20
+ });
23
21
  }
24
- if (!o)
25
- throw new f("Unable to normalize signature.");
26
- return n;
27
22
  }
28
- function l(r, i) {
29
- const t = typeof r, e = i.type;
30
- switch (e) {
31
- case "address":
32
- return c(r, { strict: !1 });
33
- case "bool":
34
- return t === "boolean";
35
- case "function":
36
- return t === "string";
37
- case "string":
38
- return t === "string";
39
- default:
40
- return e === "tuple" && "components" in i ? Object.values(i.components).every((n, o) => l(Object.values(r)[o], n)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e) ? t === "number" || t === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e) ? t === "string" || r instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e) ? Array.isArray(r) && r.every((n) => l(n, {
41
- ...i,
42
- // Pop off `[]` or `[M]` from end of type
43
- type: e.replace(/(\[[0-9]{0,}\])$/, "")
44
- })) : !1;
23
+ function m(r) {
24
+ if (o.has(r))
25
+ return o.get(r);
26
+ u(r, { strict: !1 });
27
+ const t = r.substring(2).toLowerCase(), s = f(d(t), { as: "Bytes" }), n = t.split("");
28
+ for (let e = 0; e < 40; e += 2)
29
+ s[e >> 1] >> 4 >= 8 && n[e] && (n[e] = n[e].toUpperCase()), (s[e >> 1] & 15) >= 8 && n[e + 1] && (n[e + 1] = n[e + 1].toUpperCase());
30
+ const a = `0x${n.join("")}`;
31
+ return o.set(r, a), a;
32
+ }
33
+ function k(r, t = {}) {
34
+ const { strict: s = !0 } = t ?? {};
35
+ try {
36
+ return u(r, { strict: s }), !0;
37
+ } catch {
38
+ return !1;
39
+ }
40
+ }
41
+ class i extends c {
42
+ constructor({ address: t, cause: s }) {
43
+ super(`Address "${t}" is invalid.`, {
44
+ cause: s
45
+ }), Object.defineProperty(this, "name", {
46
+ enumerable: !0,
47
+ configurable: !0,
48
+ writable: !0,
49
+ value: "Address.InvalidAddressError"
50
+ });
51
+ }
52
+ }
53
+ class h extends c {
54
+ constructor() {
55
+ super("Address is not a 20 byte (40 hexadecimal character) value."), Object.defineProperty(this, "name", {
56
+ enumerable: !0,
57
+ configurable: !0,
58
+ writable: !0,
59
+ value: "Address.InvalidInputError"
60
+ });
45
61
  }
46
62
  }
47
- function a(r, i, t) {
48
- for (const e in r) {
49
- const n = r[e], o = i[e];
50
- if (n.type === "tuple" && o.type === "tuple" && "components" in n && "components" in o)
51
- return a(n.components, o.components, t[e]);
52
- const s = [n.type, o.type];
53
- if (s.includes("address") && s.includes("bytes20") ? !0 : s.includes("address") && s.includes("string") ? c(t[e], {
54
- strict: !1
55
- }) : s.includes("address") && s.includes("bytes") ? c(t[e], {
56
- strict: !1
57
- }) : !1)
58
- return s;
63
+ class p extends c {
64
+ constructor() {
65
+ super("Address does not match its checksum counterpart."), Object.defineProperty(this, "name", {
66
+ enumerable: !0,
67
+ configurable: !0,
68
+ writable: !0,
69
+ value: "Address.InvalidChecksumError"
70
+ });
59
71
  }
60
72
  }
61
73
  export {
62
- a as getAmbiguousTypes,
63
- l as isArgOfType,
64
- y as normalizeSignature
74
+ i as InvalidAddressError,
75
+ p as InvalidChecksumError,
76
+ h as InvalidInputError,
77
+ u as assert,
78
+ m as checksum,
79
+ k as validate
65
80
  };
package/dist/index309.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index312.cjs"),c=require("./index315.cjs"),o=require("./index304.cjs"),m=require("./index307.cjs"),b=/^0x[a-fA-F0-9]{40}$/;function i(e,t={}){const{strict:s=!0}=t;if(!b.test(e))throw new a({address:e,cause:new l});if(s){if(e.toLowerCase()===e)return;if(d(e)!==e)throw new a({address:e,cause:new h})}}function d(e){if(c.checksum.has(e))return c.checksum.get(e);i(e,{strict:!1});const t=e.substring(2).toLowerCase(),s=m.keccak256(f.fromString(t),{as:"Bytes"}),n=t.split("");for(let r=0;r<40;r+=2)s[r>>1]>>4>=8&&n[r]&&(n[r]=n[r].toUpperCase()),(s[r>>1]&15)>=8&&n[r+1]&&(n[r+1]=n[r+1].toUpperCase());const u=`0x${n.join("")}`;return c.checksum.set(e,u),u}function p(e,t={}){const{strict:s=!0}=t??{};try{return i(e,{strict:s}),!0}catch{return!1}}class a extends o.BaseError{constructor({address:t,cause:s}){super(`Address "${t}" is invalid.`,{cause:s}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class l extends o.BaseError{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class h extends o.BaseError{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}exports.InvalidAddressError=a;exports.InvalidChecksumError=h;exports.InvalidInputError=l;exports.assert=i;exports.checksum=d;exports.validate=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/^(.*)\[([0-9]*)\]$/,t=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,g=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;exports.arrayRegex=e;exports.bytesRegex=t;exports.integerRegex=g;
package/dist/index309.js CHANGED
@@ -1,80 +1,6 @@
1
- import { fromString as d } from "./index312.js";
2
- import { checksum as o } from "./index315.js";
3
- import { BaseError as c } from "./index304.js";
4
- import { keccak256 as f } from "./index307.js";
5
- const l = /^0x[a-fA-F0-9]{40}$/;
6
- function u(r, t = {}) {
7
- const { strict: s = !0 } = t;
8
- if (!l.test(r))
9
- throw new i({
10
- address: r,
11
- cause: new h()
12
- });
13
- if (s) {
14
- if (r.toLowerCase() === r)
15
- return;
16
- if (m(r) !== r)
17
- throw new i({
18
- address: r,
19
- cause: new p()
20
- });
21
- }
22
- }
23
- function m(r) {
24
- if (o.has(r))
25
- return o.get(r);
26
- u(r, { strict: !1 });
27
- const t = r.substring(2).toLowerCase(), s = f(d(t), { as: "Bytes" }), n = t.split("");
28
- for (let e = 0; e < 40; e += 2)
29
- s[e >> 1] >> 4 >= 8 && n[e] && (n[e] = n[e].toUpperCase()), (s[e >> 1] & 15) >= 8 && n[e + 1] && (n[e + 1] = n[e + 1].toUpperCase());
30
- const a = `0x${n.join("")}`;
31
- return o.set(r, a), a;
32
- }
33
- function k(r, t = {}) {
34
- const { strict: s = !0 } = t ?? {};
35
- try {
36
- return u(r, { strict: s }), !0;
37
- } catch {
38
- return !1;
39
- }
40
- }
41
- class i extends c {
42
- constructor({ address: t, cause: s }) {
43
- super(`Address "${t}" is invalid.`, {
44
- cause: s
45
- }), Object.defineProperty(this, "name", {
46
- enumerable: !0,
47
- configurable: !0,
48
- writable: !0,
49
- value: "Address.InvalidAddressError"
50
- });
51
- }
52
- }
53
- class h extends c {
54
- constructor() {
55
- super("Address is not a 20 byte (40 hexadecimal character) value."), Object.defineProperty(this, "name", {
56
- enumerable: !0,
57
- configurable: !0,
58
- writable: !0,
59
- value: "Address.InvalidInputError"
60
- });
61
- }
62
- }
63
- class p extends c {
64
- constructor() {
65
- super("Address does not match its checksum counterpart."), Object.defineProperty(this, "name", {
66
- enumerable: !0,
67
- configurable: !0,
68
- writable: !0,
69
- value: "Address.InvalidChecksumError"
70
- });
71
- }
72
- }
1
+ const e = /^(.*)\[([0-9]*)\]$/, t = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, n = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
73
2
  export {
74
- i as InvalidAddressError,
75
- p as InvalidChecksumError,
76
- h as InvalidInputError,
77
- u as assert,
78
- m as checksum,
79
- k as validate
3
+ e as arrayRegex,
4
+ t as bytesRegex,
5
+ n as integerRegex
80
6
  };
package/dist/index310.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/^(.*)\[([0-9]*)\]$/,t=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,g=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;exports.arrayRegex=e;exports.bytesRegex=t;exports.integerRegex=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index293.cjs"),w=require("./index308.cjs"),N=require("./index303.cjs"),c=require("./index289.cjs"),x=require("./index309.cjs");function P({checksumAddress:e,parameters:r,values:n}){const t=[];for(let o=0;o<r.length;o++)t.push(f({checksumAddress:e,parameter:r[o],value:n[o]}));return t}function f({checksumAddress:e=!1,parameter:r,value:n}){const t=r,o=S(t.type);if(o){const[i,s]=o;return h(n,{checksumAddress:e,length:i,parameter:{...t,type:s}})}if(t.type==="tuple")return A(n,{checksumAddress:e,parameter:t});if(t.type==="address")return y(n,{checksum:e});if(t.type==="bool")return g(n);if(t.type.startsWith("uint")||t.type.startsWith("int")){const i=t.type.startsWith("int"),[,,s="256"]=x.integerRegex.exec(t.type)??[];return b(n,{signed:i,size:Number(s)})}if(t.type.startsWith("bytes"))return l(n,{type:t.type});if(t.type==="string")return z(n);throw new m.InvalidTypeError(t.type)}function u(e){let r=0;for(let i=0;i<e.length;i++){const{dynamic:s,encoded:a}=e[i];s?r+=32:r+=c.size(a)}const n=[],t=[];let o=0;for(let i=0;i<e.length;i++){const{dynamic:s,encoded:a}=e[i];s?(n.push(c.fromNumber(r+o,{size:32})),t.push(a),o+=c.size(a)):n.push(a)}return c.concat(...n,...t)}function y(e,r){const{checksum:n=!1}=r;return w.assert(e,{strict:n}),{dynamic:!1,encoded:c.padLeft(e.toLowerCase())}}function h(e,r){const{checksumAddress:n,length:t,parameter:o}=r,i=t===null;if(!Array.isArray(e))throw new m.InvalidArrayError(e);if(!i&&e.length!==t)throw new m.ArrayLengthMismatchError({expectedLength:t,givenLength:e.length,type:`${o.type}[${t}]`});let s=!1;const a=[];for(let d=0;d<e.length;d++){const p=f({checksumAddress:n,parameter:o,value:e[d]});p.dynamic&&(s=!0),a.push(p)}if(i||s){const d=u(a);if(i){const p=c.fromNumber(a.length,{size:32});return{dynamic:!0,encoded:a.length>0?c.concat(p,d):p}}if(s)return{dynamic:!0,encoded:d}}return{dynamic:!1,encoded:c.concat(...a.map(({encoded:d})=>d))}}function l(e,{type:r}){const[,n]=r.split("bytes"),t=c.size(e);if(!n){let o=e;return t%32!==0&&(o=c.padRight(o,Math.ceil((e.length-2)/2/32)*32)),{dynamic:!0,encoded:c.concat(c.padLeft(c.fromNumber(t,{size:32})),o)}}if(t!==Number.parseInt(n))throw new m.BytesSizeMismatchError({expectedSize:Number.parseInt(n),value:e});return{dynamic:!1,encoded:c.padRight(e)}}function g(e){if(typeof e!="boolean")throw new N.BaseError(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:c.padLeft(c.fromBoolean(e))}}function b(e,{signed:r,size:n}){if(typeof n=="number"){const t=2n**(BigInt(n)-(r?1n:0n))-1n,o=r?-t-1n:0n;if(e>t||e<o)throw new c.IntegerOutOfRangeError({max:t.toString(),min:o.toString(),signed:r,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:c.fromNumber(e,{size:32,signed:r})}}function z(e){const r=c.fromString(e),n=Math.ceil(c.size(r)/32),t=[];for(let o=0;o<n;o++)t.push(c.padRight(c.slice(r,o*32,(o+1)*32)));return{dynamic:!0,encoded:c.concat(c.padRight(c.fromNumber(c.size(r),{size:32})),...t)}}function A(e,r){const{checksumAddress:n,parameter:t}=r;let o=!1;const i=[];for(let s=0;s<t.components.length;s++){const a=t.components[s],d=Array.isArray(e)?s:a.name,p=f({checksumAddress:n,parameter:a,value:e[d]});i.push(p),p.dynamic&&(o=!0)}return{dynamic:o,encoded:o?u(i):c.concat(...i.map(({encoded:s})=>s))}}function S(e){const r=e.match(/^(.*)\[(\d+)?\]$/);return r?[r[2]?Number(r[2]):null,r[1]]:void 0}exports.encode=u;exports.encodeAddress=y;exports.encodeArray=h;exports.encodeBoolean=g;exports.encodeBytes=l;exports.encodeNumber=b;exports.encodeString=z;exports.encodeTuple=A;exports.getArrayComponents=S;exports.prepareParameter=f;exports.prepareParameters=P;