@gardenfi/utils 2.5.3-beta.4 → 2.5.3-beta.5

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 (47) hide show
  1. package/dist/index133.cjs +1 -1
  2. package/dist/index133.js +1 -1
  3. package/dist/index184.cjs +1 -1
  4. package/dist/index184.js +1 -1
  5. package/dist/index185.cjs +1 -1
  6. package/dist/index185.js +2 -2
  7. package/dist/index194.cjs +1 -1
  8. package/dist/index194.js +1 -1
  9. package/dist/index212.cjs +1 -2
  10. package/dist/index212.js +11 -41
  11. package/dist/index213.cjs +2 -1
  12. package/dist/index213.js +42 -2
  13. package/dist/index214.cjs +1 -1
  14. package/dist/index214.js +2 -6
  15. package/dist/index215.cjs +1 -1
  16. package/dist/index215.js +5 -10
  17. package/dist/index216.cjs +1 -1
  18. package/dist/index216.js +9 -18
  19. package/dist/index217.cjs +1 -1
  20. package/dist/index217.js +19 -8
  21. package/dist/index218.cjs +1 -1
  22. package/dist/index218.js +8 -66
  23. package/dist/index219.cjs +1 -1
  24. package/dist/index219.js +65 -64
  25. package/dist/index220.cjs +1 -1
  26. package/dist/index220.js +60 -183
  27. package/dist/index221.cjs +1 -1
  28. package/dist/index221.js +185 -25
  29. package/dist/index222.cjs +1 -1
  30. package/dist/index222.js +13 -61
  31. package/dist/index223.cjs +1 -1
  32. package/dist/index223.js +54 -18
  33. package/dist/index224.cjs +1 -1
  34. package/dist/index224.js +34 -10
  35. package/dist/index225.cjs +1 -1
  36. package/dist/index225.js +10 -7
  37. package/dist/index226.cjs +1 -1
  38. package/dist/index226.js +13 -11
  39. package/dist/index230.cjs +1 -1
  40. package/dist/index230.js +103 -6
  41. package/dist/index231.cjs +1 -1
  42. package/dist/index231.js +7 -7
  43. package/dist/index232.cjs +1 -1
  44. package/dist/index232.js +7 -104
  45. package/dist/index49.cjs +1 -1
  46. package/dist/index49.js +3 -3
  47. package/package.json +1 -1
package/dist/index220.js CHANGED
@@ -1,191 +1,68 @@
1
- import { execTyped as E, isTupleRegex as P, bytesRegex as x, integerRegex as $ } from "./index217.js";
2
- import { UnknownSolidityTypeError as M } from "./index221.js";
3
- import { InvalidParameterError as R, SolidityProtectedKeywordError as k, InvalidModifierError as z, InvalidFunctionModifierError as A } from "./index222.js";
4
- import { UnknownSignatureError as F, InvalidSignatureError as m } from "./index223.js";
5
- import { InvalidParenthesisError as T } from "./index224.js";
6
- import { getParameterCacheKey as _, parameterCache as p } from "./index243.js";
7
- import { isFunctionSignature as C, isEventSignature as I, isErrorSignature as Z, isConstructorSignature as K, isFallbackSignature as L, isReceiveSignature as U, functionModifiers as h, execFunctionSignature as W, execEventSignature as D, eventModifiers as V, execErrorSignature as j, execConstructorSignature as q, execFallbackSignature as B } from "./index218.js";
8
- function le(e, t = {}) {
9
- if (C(e))
10
- return G(e, t);
11
- if (I(e))
12
- return H(e, t);
13
- if (Z(e))
14
- return J(e, t);
15
- if (K(e))
16
- return N(e, t);
17
- if (L(e))
18
- return O(e);
19
- if (U(e))
20
- return {
21
- type: "receive",
22
- stateMutability: "payable"
23
- };
24
- throw new F({ signature: e });
25
- }
26
- function G(e, t = {}) {
27
- const n = W(e);
28
- if (!n)
29
- throw new m({ signature: e, type: "function" });
30
- const a = u(n.parameters), r = [], c = a.length;
31
- for (let o = 0; o < c; o++)
32
- r.push(l(a[o], {
33
- modifiers: h,
34
- structs: t,
35
- type: "function"
36
- }));
37
- const i = [];
38
- if (n.returns) {
39
- const o = u(n.returns), s = o.length;
40
- for (let f = 0; f < s; f++)
41
- i.push(l(o[f], {
42
- modifiers: h,
43
- structs: t,
44
- type: "function"
45
- }));
46
- }
47
- return {
48
- name: n.name,
49
- type: "function",
50
- stateMutability: n.stateMutability ?? "nonpayable",
51
- inputs: r,
52
- outputs: i
53
- };
54
- }
55
- function H(e, t = {}) {
56
- const n = D(e);
57
- if (!n)
58
- throw new m({ signature: e, type: "event" });
59
- const a = u(n.parameters), r = [], c = a.length;
60
- for (let i = 0; i < c; i++)
61
- r.push(l(a[i], {
62
- modifiers: V,
63
- structs: t,
64
- type: "event"
65
- }));
66
- return { name: n.name, type: "event", inputs: r };
67
- }
68
- function J(e, t = {}) {
69
- const n = j(e);
70
- if (!n)
71
- throw new m({ signature: e, type: "error" });
72
- const a = u(n.parameters), r = [], c = a.length;
73
- for (let i = 0; i < c; i++)
74
- r.push(l(a[i], { structs: t, type: "error" }));
75
- return { name: n.name, type: "error", inputs: r };
76
- }
77
- function N(e, t = {}) {
78
- const n = q(e);
79
- if (!n)
80
- throw new m({ signature: e, type: "constructor" });
81
- const a = u(n.parameters), r = [], c = a.length;
82
- for (let i = 0; i < c; i++)
83
- r.push(l(a[i], { structs: t, type: "constructor" }));
84
- return {
85
- type: "constructor",
86
- stateMutability: n.stateMutability ?? "nonpayable",
87
- inputs: r
88
- };
89
- }
90
- function O(e) {
91
- const t = B(e);
92
- if (!t)
93
- throw new m({ signature: e, type: "fallback" });
94
- return {
95
- type: "fallback",
96
- stateMutability: t.stateMutability ?? "nonpayable"
97
- };
98
- }
99
- const Q = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, X = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, Y = /^u?int$/;
100
- function l(e, t) {
101
- var y, b;
102
- const n = _(e, t == null ? void 0 : t.type, t == null ? void 0 : t.structs);
103
- if (p.has(n))
104
- return p.get(n);
105
- const a = P.test(e), r = E(a ? X : Q, e);
106
- if (!r)
107
- throw new R({ param: e });
108
- if (r.name && re(r.name))
109
- throw new k({ param: e, name: r.name });
110
- const c = r.name ? { name: r.name } : {}, i = r.modifier === "indexed" ? { indexed: !0 } : {}, o = (t == null ? void 0 : t.structs) ?? {};
111
- let s, f = {};
112
- if (a) {
113
- s = "tuple";
114
- const w = u(r.type), S = [], v = w.length;
115
- for (let d = 0; d < v; d++)
116
- S.push(l(w[d], { structs: o }));
117
- f = { components: S };
118
- } else if (r.type in o)
119
- s = "tuple", f = { components: o[r.type] };
120
- else if (Y.test(r.type))
121
- s = `${r.type}256`;
122
- else if (r.type === "address payable")
123
- s = "address";
124
- else if (s = r.type, (t == null ? void 0 : t.type) !== "struct" && !ee(s))
125
- throw new M({ type: s });
126
- if (r.modifier) {
127
- if (!((b = (y = t == null ? void 0 : t.modifiers) == null ? void 0 : y.has) != null && b.call(y, r.modifier)))
128
- throw new z({
129
- param: e,
130
- type: t == null ? void 0 : t.type,
131
- modifier: r.modifier
132
- });
133
- if (h.has(r.modifier) && !ne(s, !!r.array))
134
- throw new A({
135
- param: e,
136
- type: t == null ? void 0 : t.type,
137
- modifier: r.modifier
1
+ import { isTupleRegex as g, execTyped as w } from "./index218.js";
2
+ import { UnknownTypeError as S } from "./index222.js";
3
+ import { InvalidAbiTypeParameterError as d } from "./index223.js";
4
+ import { InvalidSignatureError as T, InvalidStructSignatureError as v } from "./index224.js";
5
+ import { CircularReferenceError as x } from "./index226.js";
6
+ import { isStructSignature as E, execStructSignature as b } from "./index219.js";
7
+ import { parseAbiParameter as A, isSolidityType as $ } from "./index221.js";
8
+ function C(s) {
9
+ const n = {}, c = s.length;
10
+ for (let t = 0; t < c; t++) {
11
+ const i = s[t];
12
+ if (!E(i))
13
+ continue;
14
+ const r = b(i);
15
+ if (!r)
16
+ throw new T({ signature: i, type: "struct" });
17
+ const u = r.properties.split(";"), e = [], h = u.length;
18
+ for (let l = 0; l < h; l++) {
19
+ const m = u[l].trim();
20
+ if (!m)
21
+ continue;
22
+ const y = A(m, {
23
+ type: "struct"
138
24
  });
25
+ e.push(y);
26
+ }
27
+ if (!e.length)
28
+ throw new v({ signature: i });
29
+ n[r.name] = e;
30
+ }
31
+ const o = {}, a = Object.entries(n), p = a.length;
32
+ for (let t = 0; t < p; t++) {
33
+ const [i, r] = a[t];
34
+ o[i] = f(r, n);
139
35
  }
140
- const g = {
141
- type: `${s}${r.array ?? ""}`,
142
- ...c,
143
- ...i,
144
- ...f
145
- };
146
- return p.set(n, g), g;
36
+ return o;
147
37
  }
148
- function u(e, t = [], n = "", a = 0) {
149
- const r = e.trim().length;
150
- for (let c = 0; c < r; c++) {
151
- const i = e[c], o = e.slice(c + 1);
152
- switch (i) {
153
- case ",":
154
- return a === 0 ? u(o, [...t, n.trim()]) : u(o, t, `${n}${i}`, a);
155
- case "(":
156
- return u(o, t, `${n}${i}`, a + 1);
157
- case ")":
158
- return u(o, t, `${n}${i}`, a - 1);
159
- default:
160
- return u(o, t, `${n}${i}`, a);
38
+ const I = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
39
+ function f(s, n, c = /* @__PURE__ */ new Set()) {
40
+ const o = [], a = s.length;
41
+ for (let p = 0; p < a; p++) {
42
+ const t = s[p];
43
+ if (g.test(t.type))
44
+ o.push(t);
45
+ else {
46
+ const r = w(I, t.type);
47
+ if (!(r != null && r.type))
48
+ throw new d({ abiParameter: t });
49
+ const { array: u, type: e } = r;
50
+ if (e in n) {
51
+ if (c.has(e))
52
+ throw new x({ type: e });
53
+ o.push({
54
+ ...t,
55
+ type: `tuple${u ?? ""}`,
56
+ components: f(n[e] ?? [], n, /* @__PURE__ */ new Set([...c, e]))
57
+ });
58
+ } else if ($(e))
59
+ o.push(t);
60
+ else
61
+ throw new S({ type: e });
161
62
  }
162
63
  }
163
- if (n === "")
164
- return t;
165
- if (a !== 0)
166
- throw new T({ current: n, depth: a });
167
- return t.push(n.trim()), t;
168
- }
169
- function ee(e) {
170
- return e === "address" || e === "bool" || e === "function" || e === "string" || x.test(e) || $.test(e);
171
- }
172
- const te = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
173
- function re(e) {
174
- return e === "address" || e === "bool" || e === "function" || e === "string" || e === "tuple" || x.test(e) || $.test(e) || te.test(e);
175
- }
176
- function ne(e, t) {
177
- return t || e === "bytes" || e === "string" || e === "tuple";
64
+ return o;
178
65
  }
179
66
  export {
180
- re as isSolidityKeyword,
181
- ee as isSolidityType,
182
- ne as isValidDataLocation,
183
- l as parseAbiParameter,
184
- N as parseConstructorSignature,
185
- J as parseErrorSignature,
186
- H as parseEventSignature,
187
- O as parseFallbackSignature,
188
- G as parseFunctionSignature,
189
- le as parseSignature,
190
- u as splitParameters
67
+ C as parseStructs
191
68
  };
package/dist/index221.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index212.cjs");class t extends r.BaseError{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class o extends r.BaseError{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}exports.UnknownSolidityTypeError=o;exports.UnknownTypeError=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index218.cjs"),A=require("./index222.cjs"),g=require("./index223.cjs"),d=require("./index224.cjs"),q=require("./index225.cjs"),h=require("./index243.cjs"),o=require("./index219.cjs");function z(e,t={}){if(o.isFunctionSignature(e))return E(e,t);if(o.isEventSignature(e))return P(e,t);if(o.isErrorSignature(e))return M(e,t);if(o.isConstructorSignature(e))return I(e,t);if(o.isFallbackSignature(e))return R(e);if(o.isReceiveSignature(e))return{type:"receive",stateMutability:"payable"};throw new d.UnknownSignatureError({signature:e})}function E(e,t={}){const a=o.execFunctionSignature(e);if(!a)throw new d.InvalidSignatureError({signature:e,type:"function"});const n=u(a.parameters),r=[],c=n.length;for(let s=0;s<c;s++)r.push(y(n[s],{modifiers:o.functionModifiers,structs:t,type:"function"}));const i=[];if(a.returns){const s=u(a.returns),l=s.length;for(let f=0;f<l;f++)i.push(y(s[f],{modifiers:o.functionModifiers,structs:t,type:"function"}))}return{name:a.name,type:"function",stateMutability:a.stateMutability??"nonpayable",inputs:r,outputs:i}}function P(e,t={}){const a=o.execEventSignature(e);if(!a)throw new d.InvalidSignatureError({signature:e,type:"event"});const n=u(a.parameters),r=[],c=n.length;for(let i=0;i<c;i++)r.push(y(n[i],{modifiers:o.eventModifiers,structs:t,type:"event"}));return{name:a.name,type:"event",inputs:r}}function M(e,t={}){const a=o.execErrorSignature(e);if(!a)throw new d.InvalidSignatureError({signature:e,type:"error"});const n=u(a.parameters),r=[],c=n.length;for(let i=0;i<c;i++)r.push(y(n[i],{structs:t,type:"error"}));return{name:a.name,type:"error",inputs:r}}function I(e,t={}){const a=o.execConstructorSignature(e);if(!a)throw new d.InvalidSignatureError({signature:e,type:"constructor"});const n=u(a.parameters),r=[],c=n.length;for(let i=0;i<c;i++)r.push(y(n[i],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:a.stateMutability??"nonpayable",inputs:r}}function R(e){const t=o.execFallbackSignature(e);if(!t)throw new d.InvalidSignatureError({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const _=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,$=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,K=/^u?int$/;function y(e,t){var p,w;const a=h.getParameterCacheKey(e,t==null?void 0:t.type,t==null?void 0:t.structs);if(h.parameterCache.has(a))return h.parameterCache.get(a);const n=m.isTupleRegex.test(e),r=m.execTyped(n?$:_,e);if(!r)throw new g.InvalidParameterError({param:e});if(r.name&&F(r.name))throw new g.SolidityProtectedKeywordError({param:e,name:r.name});const c=r.name?{name:r.name}:{},i=r.modifier==="indexed"?{indexed:!0}:{},s=(t==null?void 0:t.structs)??{};let l,f={};if(n){l="tuple";const v=u(r.type),x=[],k=v.length;for(let b=0;b<k;b++)x.push(y(v[b],{structs:s}));f={components:x}}else if(r.type in s)l="tuple",f={components:s[r.type]};else if(K.test(r.type))l=`${r.type}256`;else if(r.type==="address payable")l="address";else if(l=r.type,(t==null?void 0:t.type)!=="struct"&&!C(l))throw new A.UnknownSolidityTypeError({type:l});if(r.modifier){if(!((w=(p=t==null?void 0:t.modifiers)==null?void 0:p.has)!=null&&w.call(p,r.modifier)))throw new g.InvalidModifierError({param:e,type:t==null?void 0:t.type,modifier:r.modifier});if(o.functionModifiers.has(r.modifier)&&!T(l,!!r.array))throw new g.InvalidFunctionModifierError({param:e,type:t==null?void 0:t.type,modifier:r.modifier})}const S={type:`${l}${r.array??""}`,...c,...i,...f};return h.parameterCache.set(a,S),S}function u(e,t=[],a="",n=0){const r=e.trim().length;for(let c=0;c<r;c++){const i=e[c],s=e.slice(c+1);switch(i){case",":return n===0?u(s,[...t,a.trim()]):u(s,t,`${a}${i}`,n);case"(":return u(s,t,`${a}${i}`,n+1);case")":return u(s,t,`${a}${i}`,n-1);default:return u(s,t,`${a}${i}`,n)}}if(a==="")return t;if(n!==0)throw new q.InvalidParenthesisError({current:a,depth:n});return t.push(a.trim()),t}function C(e){return e==="address"||e==="bool"||e==="function"||e==="string"||m.bytesRegex.test(e)||m.integerRegex.test(e)}const Z=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function F(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||m.bytesRegex.test(e)||m.integerRegex.test(e)||Z.test(e)}function T(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}exports.isSolidityKeyword=F;exports.isSolidityType=C;exports.isValidDataLocation=T;exports.parseAbiParameter=y;exports.parseConstructorSignature=I;exports.parseErrorSignature=M;exports.parseEventSignature=P;exports.parseFallbackSignature=R;exports.parseFunctionSignature=E;exports.parseSignature=z;exports.splitParameters=u;
package/dist/index221.js CHANGED
@@ -1,31 +1,191 @@
1
- import { BaseError as r } from "./index212.js";
2
- class o extends r {
3
- constructor({ type: e }) {
4
- super("Unknown type.", {
5
- metaMessages: [
6
- `Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
7
- ]
8
- }), Object.defineProperty(this, "name", {
9
- enumerable: !0,
10
- configurable: !0,
11
- writable: !0,
12
- value: "UnknownTypeError"
13
- });
1
+ import { execTyped as E, isTupleRegex as P, bytesRegex as x, integerRegex as $ } from "./index218.js";
2
+ import { UnknownSolidityTypeError as M } from "./index222.js";
3
+ import { InvalidParameterError as R, SolidityProtectedKeywordError as k, InvalidModifierError as z, InvalidFunctionModifierError as A } from "./index223.js";
4
+ import { UnknownSignatureError as F, InvalidSignatureError as m } from "./index224.js";
5
+ import { InvalidParenthesisError as T } from "./index225.js";
6
+ import { getParameterCacheKey as _, parameterCache as p } from "./index243.js";
7
+ import { isFunctionSignature as C, isEventSignature as I, isErrorSignature as Z, isConstructorSignature as K, isFallbackSignature as L, isReceiveSignature as U, functionModifiers as h, execFunctionSignature as W, execEventSignature as D, eventModifiers as V, execErrorSignature as j, execConstructorSignature as q, execFallbackSignature as B } from "./index219.js";
8
+ function le(e, t = {}) {
9
+ if (C(e))
10
+ return G(e, t);
11
+ if (I(e))
12
+ return H(e, t);
13
+ if (Z(e))
14
+ return J(e, t);
15
+ if (K(e))
16
+ return N(e, t);
17
+ if (L(e))
18
+ return O(e);
19
+ if (U(e))
20
+ return {
21
+ type: "receive",
22
+ stateMutability: "payable"
23
+ };
24
+ throw new F({ signature: e });
25
+ }
26
+ function G(e, t = {}) {
27
+ const n = W(e);
28
+ if (!n)
29
+ throw new m({ signature: e, type: "function" });
30
+ const a = u(n.parameters), r = [], c = a.length;
31
+ for (let o = 0; o < c; o++)
32
+ r.push(l(a[o], {
33
+ modifiers: h,
34
+ structs: t,
35
+ type: "function"
36
+ }));
37
+ const i = [];
38
+ if (n.returns) {
39
+ const o = u(n.returns), s = o.length;
40
+ for (let f = 0; f < s; f++)
41
+ i.push(l(o[f], {
42
+ modifiers: h,
43
+ structs: t,
44
+ type: "function"
45
+ }));
46
+ }
47
+ return {
48
+ name: n.name,
49
+ type: "function",
50
+ stateMutability: n.stateMutability ?? "nonpayable",
51
+ inputs: r,
52
+ outputs: i
53
+ };
54
+ }
55
+ function H(e, t = {}) {
56
+ const n = D(e);
57
+ if (!n)
58
+ throw new m({ signature: e, type: "event" });
59
+ const a = u(n.parameters), r = [], c = a.length;
60
+ for (let i = 0; i < c; i++)
61
+ r.push(l(a[i], {
62
+ modifiers: V,
63
+ structs: t,
64
+ type: "event"
65
+ }));
66
+ return { name: n.name, type: "event", inputs: r };
67
+ }
68
+ function J(e, t = {}) {
69
+ const n = j(e);
70
+ if (!n)
71
+ throw new m({ signature: e, type: "error" });
72
+ const a = u(n.parameters), r = [], c = a.length;
73
+ for (let i = 0; i < c; i++)
74
+ r.push(l(a[i], { structs: t, type: "error" }));
75
+ return { name: n.name, type: "error", inputs: r };
76
+ }
77
+ function N(e, t = {}) {
78
+ const n = q(e);
79
+ if (!n)
80
+ throw new m({ signature: e, type: "constructor" });
81
+ const a = u(n.parameters), r = [], c = a.length;
82
+ for (let i = 0; i < c; i++)
83
+ r.push(l(a[i], { structs: t, type: "constructor" }));
84
+ return {
85
+ type: "constructor",
86
+ stateMutability: n.stateMutability ?? "nonpayable",
87
+ inputs: r
88
+ };
89
+ }
90
+ function O(e) {
91
+ const t = B(e);
92
+ if (!t)
93
+ throw new m({ signature: e, type: "fallback" });
94
+ return {
95
+ type: "fallback",
96
+ stateMutability: t.stateMutability ?? "nonpayable"
97
+ };
98
+ }
99
+ const Q = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, X = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/, Y = /^u?int$/;
100
+ function l(e, t) {
101
+ var y, b;
102
+ const n = _(e, t == null ? void 0 : t.type, t == null ? void 0 : t.structs);
103
+ if (p.has(n))
104
+ return p.get(n);
105
+ const a = P.test(e), r = E(a ? X : Q, e);
106
+ if (!r)
107
+ throw new R({ param: e });
108
+ if (r.name && re(r.name))
109
+ throw new k({ param: e, name: r.name });
110
+ const c = r.name ? { name: r.name } : {}, i = r.modifier === "indexed" ? { indexed: !0 } : {}, o = (t == null ? void 0 : t.structs) ?? {};
111
+ let s, f = {};
112
+ if (a) {
113
+ s = "tuple";
114
+ const w = u(r.type), S = [], v = w.length;
115
+ for (let d = 0; d < v; d++)
116
+ S.push(l(w[d], { structs: o }));
117
+ f = { components: S };
118
+ } else if (r.type in o)
119
+ s = "tuple", f = { components: o[r.type] };
120
+ else if (Y.test(r.type))
121
+ s = `${r.type}256`;
122
+ else if (r.type === "address payable")
123
+ s = "address";
124
+ else if (s = r.type, (t == null ? void 0 : t.type) !== "struct" && !ee(s))
125
+ throw new M({ type: s });
126
+ if (r.modifier) {
127
+ if (!((b = (y = t == null ? void 0 : t.modifiers) == null ? void 0 : y.has) != null && b.call(y, r.modifier)))
128
+ throw new z({
129
+ param: e,
130
+ type: t == null ? void 0 : t.type,
131
+ modifier: r.modifier
132
+ });
133
+ if (h.has(r.modifier) && !ne(s, !!r.array))
134
+ throw new A({
135
+ param: e,
136
+ type: t == null ? void 0 : t.type,
137
+ modifier: r.modifier
138
+ });
14
139
  }
140
+ const g = {
141
+ type: `${s}${r.array ?? ""}`,
142
+ ...c,
143
+ ...i,
144
+ ...f
145
+ };
146
+ return p.set(n, g), g;
15
147
  }
16
- class a extends r {
17
- constructor({ type: e }) {
18
- super("Unknown type.", {
19
- metaMessages: [`Type "${e}" is not a valid ABI type.`]
20
- }), Object.defineProperty(this, "name", {
21
- enumerable: !0,
22
- configurable: !0,
23
- writable: !0,
24
- value: "UnknownSolidityTypeError"
25
- });
148
+ function u(e, t = [], n = "", a = 0) {
149
+ const r = e.trim().length;
150
+ for (let c = 0; c < r; c++) {
151
+ const i = e[c], o = e.slice(c + 1);
152
+ switch (i) {
153
+ case ",":
154
+ return a === 0 ? u(o, [...t, n.trim()]) : u(o, t, `${n}${i}`, a);
155
+ case "(":
156
+ return u(o, t, `${n}${i}`, a + 1);
157
+ case ")":
158
+ return u(o, t, `${n}${i}`, a - 1);
159
+ default:
160
+ return u(o, t, `${n}${i}`, a);
161
+ }
26
162
  }
163
+ if (n === "")
164
+ return t;
165
+ if (a !== 0)
166
+ throw new T({ current: n, depth: a });
167
+ return t.push(n.trim()), t;
168
+ }
169
+ function ee(e) {
170
+ return e === "address" || e === "bool" || e === "function" || e === "string" || x.test(e) || $.test(e);
171
+ }
172
+ const te = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
173
+ function re(e) {
174
+ return e === "address" || e === "bool" || e === "function" || e === "string" || e === "tuple" || x.test(e) || $.test(e) || te.test(e);
175
+ }
176
+ function ne(e, t) {
177
+ return t || e === "bytes" || e === "string" || e === "tuple";
27
178
  }
28
179
  export {
29
- a as UnknownSolidityTypeError,
30
- o as UnknownTypeError
180
+ re as isSolidityKeyword,
181
+ ee as isSolidityType,
182
+ ne as isValidDataLocation,
183
+ l as parseAbiParameter,
184
+ N as parseConstructorSignature,
185
+ J as parseErrorSignature,
186
+ H as parseEventSignature,
187
+ O as parseFallbackSignature,
188
+ G as parseFunctionSignature,
189
+ le as parseSignature,
190
+ u as splitParameters
31
191
  };
package/dist/index222.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index212.cjs");class o extends t.BaseError{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class n extends t.BaseError{constructor({param:e,name:r}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${r}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class s extends t.BaseError{constructor({param:e,type:r,modifier:i}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${i}" not allowed${r?` in "${r}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class l extends t.BaseError{constructor({param:e,type:r,modifier:i}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${i}" not allowed${r?` in "${r}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${i}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class d extends t.BaseError{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}exports.InvalidAbiTypeParameterError=d;exports.InvalidFunctionModifierError=l;exports.InvalidModifierError=s;exports.InvalidParameterError=o;exports.SolidityProtectedKeywordError=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index213.cjs");class t extends r.BaseError{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class o extends r.BaseError{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}exports.UnknownSolidityTypeError=o;exports.UnknownTypeError=t;
package/dist/index222.js CHANGED
@@ -1,79 +1,31 @@
1
- import { BaseError as t } from "./index212.js";
2
- class n extends t {
3
- constructor({ param: e }) {
4
- super("Invalid ABI parameter.", {
5
- details: e
6
- }), Object.defineProperty(this, "name", {
7
- enumerable: !0,
8
- configurable: !0,
9
- writable: !0,
10
- value: "InvalidParameterError"
11
- });
12
- }
13
- }
14
- class s extends t {
15
- constructor({ param: e, name: r }) {
16
- super("Invalid ABI parameter.", {
17
- details: e,
18
- metaMessages: [
19
- `"${r}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
20
- ]
21
- }), Object.defineProperty(this, "name", {
22
- enumerable: !0,
23
- configurable: !0,
24
- writable: !0,
25
- value: "SolidityProtectedKeywordError"
26
- });
27
- }
28
- }
29
- class l extends t {
30
- constructor({ param: e, type: r, modifier: i }) {
31
- super("Invalid ABI parameter.", {
32
- details: e,
33
- metaMessages: [
34
- `Modifier "${i}" not allowed${r ? ` in "${r}" type` : ""}.`
35
- ]
36
- }), Object.defineProperty(this, "name", {
37
- enumerable: !0,
38
- configurable: !0,
39
- writable: !0,
40
- value: "InvalidModifierError"
41
- });
42
- }
43
- }
44
- class d extends t {
45
- constructor({ param: e, type: r, modifier: i }) {
46
- super("Invalid ABI parameter.", {
47
- details: e,
1
+ import { BaseError as r } from "./index213.js";
2
+ class o extends r {
3
+ constructor({ type: e }) {
4
+ super("Unknown type.", {
48
5
  metaMessages: [
49
- `Modifier "${i}" not allowed${r ? ` in "${r}" type` : ""}.`,
50
- `Data location can only be specified for array, struct, or mapping types, but "${i}" was given.`
6
+ `Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
51
7
  ]
52
8
  }), Object.defineProperty(this, "name", {
53
9
  enumerable: !0,
54
10
  configurable: !0,
55
11
  writable: !0,
56
- value: "InvalidFunctionModifierError"
12
+ value: "UnknownTypeError"
57
13
  });
58
14
  }
59
15
  }
60
- class u extends t {
61
- constructor({ abiParameter: e }) {
62
- super("Invalid ABI parameter.", {
63
- details: JSON.stringify(e, null, 2),
64
- metaMessages: ["ABI parameter type is invalid."]
16
+ class a extends r {
17
+ constructor({ type: e }) {
18
+ super("Unknown type.", {
19
+ metaMessages: [`Type "${e}" is not a valid ABI type.`]
65
20
  }), Object.defineProperty(this, "name", {
66
21
  enumerable: !0,
67
22
  configurable: !0,
68
23
  writable: !0,
69
- value: "InvalidAbiTypeParameterError"
24
+ value: "UnknownSolidityTypeError"
70
25
  });
71
26
  }
72
27
  }
73
28
  export {
74
- u as InvalidAbiTypeParameterError,
75
- d as InvalidFunctionModifierError,
76
- l as InvalidModifierError,
77
- n as InvalidParameterError,
78
- s as SolidityProtectedKeywordError
29
+ a as UnknownSolidityTypeError,
30
+ o as UnknownTypeError
79
31
  };
package/dist/index223.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index212.cjs");class a extends e.BaseError{constructor({signature:r,type:n}){super(`Invalid ${n} signature.`,{details:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class u extends e.BaseError{constructor({signature:r}){super("Unknown signature.",{details:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class i extends e.BaseError{constructor({signature:r}){super("Invalid struct signature.",{details:r,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}exports.InvalidSignatureError=a;exports.InvalidStructSignatureError=i;exports.UnknownSignatureError=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index213.cjs");class o extends t.BaseError{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class n extends t.BaseError{constructor({param:e,name:r}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${r}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class s extends t.BaseError{constructor({param:e,type:r,modifier:i}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${i}" not allowed${r?` in "${r}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class l extends t.BaseError{constructor({param:e,type:r,modifier:i}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${i}" not allowed${r?` in "${r}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${i}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class d extends t.BaseError{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}exports.InvalidAbiTypeParameterError=d;exports.InvalidFunctionModifierError=l;exports.InvalidModifierError=s;exports.InvalidParameterError=o;exports.SolidityProtectedKeywordError=n;