@gardenfi/utils 2.5.1 → 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 (192) 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/index11.cjs +1 -1
  5. package/dist/index11.js +16 -20
  6. package/dist/index112.cjs +1 -1
  7. package/dist/index112.js +15 -15
  8. package/dist/index121.cjs +1 -1
  9. package/dist/index121.js +1 -1
  10. package/dist/index130.cjs +1 -1
  11. package/dist/index130.js +1 -1
  12. package/dist/index18.cjs +1 -1
  13. package/dist/index18.js +20 -9
  14. package/dist/index197.cjs +1 -1
  15. package/dist/index197.js +17 -30
  16. package/dist/index22.cjs +1 -1
  17. package/dist/index22.js +84 -51
  18. package/dist/index226.cjs +1 -1
  19. package/dist/index226.js +2 -2
  20. package/dist/index229.cjs +1 -1
  21. package/dist/index229.js +2 -2
  22. package/dist/index230.cjs +1 -1
  23. package/dist/index230.js +1 -1
  24. package/dist/index234.cjs +1 -1
  25. package/dist/index234.js +7 -8
  26. package/dist/index235.cjs +1 -1
  27. package/dist/index235.js +1 -1
  28. package/dist/index236.cjs +1 -1
  29. package/dist/index236.js +1 -1
  30. package/dist/index237.cjs +1 -1
  31. package/dist/index237.js +2 -2
  32. package/dist/index24.cjs +1 -1
  33. package/dist/index24.js +4 -5
  34. package/dist/index249.cjs +1 -1
  35. package/dist/index249.js +3 -3
  36. package/dist/index25.cjs +1 -1
  37. package/dist/index25.js +3 -5
  38. package/dist/index250.cjs +1 -1
  39. package/dist/index250.js +3 -3
  40. package/dist/index256.cjs +1 -1
  41. package/dist/index256.js +17 -12
  42. package/dist/index269.cjs +1 -1
  43. package/dist/index269.js +4 -4
  44. package/dist/index270.cjs +1 -1
  45. package/dist/index270.js +5 -5
  46. package/dist/index271.cjs +1 -1
  47. package/dist/index271.js +27 -21
  48. package/dist/index272.cjs +1 -1
  49. package/dist/index272.js +54 -20
  50. package/dist/index273.cjs +1 -1
  51. package/dist/index273.js +18 -54
  52. package/dist/index274.cjs +1 -1
  53. package/dist/index274.js +10 -34
  54. package/dist/index275.cjs +1 -1
  55. package/dist/index275.js +7 -10
  56. package/dist/index276.cjs +1 -1
  57. package/dist/index276.js +12 -13
  58. package/dist/index277.cjs +1 -1
  59. package/dist/index277.js +11 -12
  60. package/dist/index280.cjs +1 -1
  61. package/dist/index280.js +103 -11
  62. package/dist/index281.cjs +1 -1
  63. package/dist/index281.js +6 -103
  64. package/dist/index282.cjs +1 -1
  65. package/dist/index282.js +243 -5
  66. package/dist/index283.cjs +1 -1
  67. package/dist/index283.js +6 -224
  68. package/dist/index284.cjs +1 -1
  69. package/dist/index284.js +7 -7
  70. package/dist/index285.cjs +1 -1
  71. package/dist/index285.js +27 -7
  72. package/dist/index286.cjs +1 -1
  73. package/dist/index286.js +18 -25
  74. package/dist/index287.cjs +1 -1
  75. package/dist/index287.js +145 -18
  76. package/dist/index288.cjs +1 -1
  77. package/dist/index288.js +3 -146
  78. package/dist/index289.cjs +1 -1
  79. package/dist/index289.js +155 -3
  80. package/dist/index29.cjs +1 -1
  81. package/dist/index29.js +2 -2
  82. package/dist/index290.cjs +1 -1
  83. package/dist/index290.js +7 -138
  84. package/dist/index291.cjs +1 -1
  85. package/dist/index291.js +128 -143
  86. package/dist/index292.cjs +1 -1
  87. package/dist/index292.js +111 -7
  88. package/dist/index293.cjs +2 -1
  89. package/dist/index293.js +116 -95
  90. package/dist/index294.cjs +1 -2
  91. package/dist/index294.js +35 -127
  92. package/dist/index295.cjs +1 -1
  93. package/dist/index295.js +66 -30
  94. package/dist/index296.cjs +1 -1
  95. package/dist/index296.js +2 -79
  96. package/dist/index297.cjs +1 -1
  97. package/dist/index297.js +12 -2
  98. package/dist/index298.cjs +1 -1
  99. package/dist/index298.js +19 -11
  100. package/dist/index299.cjs +1 -1
  101. package/dist/index299.js +68 -19
  102. package/dist/index3.cjs +1 -1
  103. package/dist/index3.js +10 -8
  104. package/dist/index300.cjs +1 -1
  105. package/dist/index300.js +786 -66
  106. package/dist/index301.cjs +1 -1
  107. package/dist/index301.js +134 -684
  108. package/dist/index302.cjs +1 -1
  109. package/dist/index302.js +185 -124
  110. package/dist/index303.cjs +2 -1
  111. package/dist/index303.js +63 -198
  112. package/dist/index304.cjs +1 -2
  113. package/dist/index304.js +7 -66
  114. package/dist/index305.cjs +1 -1
  115. package/dist/index305.js +62 -4
  116. package/dist/index306.cjs +1 -1
  117. package/dist/index306.js +22 -40
  118. package/dist/index307.cjs +1 -1
  119. package/dist/index307.js +5 -7
  120. package/dist/index308.cjs +1 -1
  121. package/dist/index308.js +72 -57
  122. package/dist/index309.cjs +1 -1
  123. package/dist/index309.js +4 -78
  124. package/dist/index310.cjs +1 -1
  125. package/dist/index310.js +195 -4
  126. package/dist/index311.cjs +1 -1
  127. package/dist/index311.js +4 -194
  128. package/dist/index312.cjs +1 -1
  129. package/dist/index312.js +35 -58
  130. package/dist/index313.cjs +2 -1
  131. package/dist/index313.js +40 -43
  132. package/dist/index314.cjs +1 -1
  133. package/dist/index314.js +2 -5
  134. package/dist/index315.cjs +1 -1
  135. package/dist/index315.js +11 -5
  136. package/dist/index316.cjs +1 -1
  137. package/dist/index316.js +20 -2
  138. package/dist/index317.cjs +1 -1
  139. package/dist/index317.js +8 -21
  140. package/dist/index318.cjs +1 -0
  141. package/dist/index318.js +45 -0
  142. package/dist/index319.cjs +1 -0
  143. package/dist/index319.js +69 -0
  144. package/dist/index320.cjs +1 -0
  145. package/dist/index320.js +68 -0
  146. package/dist/index321.cjs +1 -0
  147. package/dist/index321.js +191 -0
  148. package/dist/index322.cjs +1 -0
  149. package/dist/index322.js +79 -0
  150. package/dist/index323.cjs +1 -0
  151. package/dist/index323.js +43 -0
  152. package/dist/index324.cjs +1 -0
  153. package/dist/index324.js +19 -0
  154. package/dist/index325.cjs +1 -0
  155. package/dist/index325.js +16 -0
  156. package/dist/index326.cjs +1 -0
  157. package/dist/index326.js +7 -0
  158. package/dist/index327.cjs +1 -0
  159. package/dist/index327.js +66 -0
  160. package/dist/index328.cjs +1 -0
  161. package/dist/index328.js +7 -0
  162. package/dist/index329.cjs +1 -0
  163. package/dist/index329.js +47 -0
  164. package/dist/index330.cjs +1 -0
  165. package/dist/index330.js +71 -0
  166. package/dist/index331.cjs +1 -0
  167. package/dist/index331.js +4 -0
  168. package/dist/index332.cjs +1 -0
  169. package/dist/index332.js +24 -0
  170. package/dist/index4.cjs +1 -1
  171. package/dist/index4.js +38 -38
  172. package/dist/index55.cjs +1 -1
  173. package/dist/index55.js +1 -1
  174. package/dist/index58.cjs +1 -1
  175. package/dist/index58.js +35 -34
  176. package/dist/index60.cjs +1 -1
  177. package/dist/index60.js +26 -30
  178. package/dist/index61.cjs +1 -1
  179. package/dist/index61.js +13 -9
  180. package/dist/index62.cjs +1 -1
  181. package/dist/index62.js +19 -19
  182. package/dist/index89.cjs +1 -1
  183. package/dist/index89.js +31 -30
  184. package/dist/index9.cjs +1 -1
  185. package/dist/index9.js +2 -2
  186. package/dist/index95.cjs +1 -1
  187. package/dist/index95.js +73 -73
  188. package/dist/src/lib/auth/apikey/apikey.d.ts +1 -1
  189. package/dist/src/lib/auth/auth.types.d.ts +1 -1
  190. package/dist/src/lib/fetcher/fetcher.d.ts +2 -0
  191. package/dist/src/lib/utils.d.ts +1 -0
  192. package/package.json +2 -2
package/dist/index310.js CHANGED
@@ -1,6 +1,197 @@
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)?$/;
1
+ import { InvalidTypeError as g, InvalidArrayError as b, ArrayLengthMismatchError as w, BytesSizeMismatchError as z } from "./index293.js";
2
+ import { assert as x } from "./index308.js";
3
+ import { BaseError as S } from "./index303.js";
4
+ import { size as d, fromNumber as f, concat as p, padLeft as h, fromBoolean as A, IntegerOutOfRangeError as E, padRight as y, fromString as I, slice as B } from "./index289.js";
5
+ import { integerRegex as L } from "./index309.js";
6
+ function q({ checksumAddress: e, parameters: n, values: r }) {
7
+ const t = [];
8
+ for (let o = 0; o < n.length; o++)
9
+ t.push(u({
10
+ checksumAddress: e,
11
+ parameter: n[o],
12
+ value: r[o]
13
+ }));
14
+ return t;
15
+ }
16
+ function u({ checksumAddress: e = !1, parameter: n, value: r }) {
17
+ const t = n, o = k(t.type);
18
+ if (o) {
19
+ const [i, c] = o;
20
+ return P(r, {
21
+ checksumAddress: e,
22
+ length: i,
23
+ parameter: {
24
+ ...t,
25
+ type: c
26
+ }
27
+ });
28
+ }
29
+ if (t.type === "tuple")
30
+ return R(r, {
31
+ checksumAddress: e,
32
+ parameter: t
33
+ });
34
+ if (t.type === "address")
35
+ return N(r, {
36
+ checksum: e
37
+ });
38
+ if (t.type === "bool")
39
+ return C(r);
40
+ if (t.type.startsWith("uint") || t.type.startsWith("int")) {
41
+ const i = t.type.startsWith("int"), [, , c = "256"] = L.exec(t.type) ?? [];
42
+ return M(r, {
43
+ signed: i,
44
+ size: Number(c)
45
+ });
46
+ }
47
+ if (t.type.startsWith("bytes"))
48
+ return $(r, { type: t.type });
49
+ if (t.type === "string")
50
+ return W(r);
51
+ throw new g(t.type);
52
+ }
53
+ function l(e) {
54
+ let n = 0;
55
+ for (let i = 0; i < e.length; i++) {
56
+ const { dynamic: c, encoded: s } = e[i];
57
+ c ? n += 32 : n += d(s);
58
+ }
59
+ const r = [], t = [];
60
+ let o = 0;
61
+ for (let i = 0; i < e.length; i++) {
62
+ const { dynamic: c, encoded: s } = e[i];
63
+ c ? (r.push(f(n + o, { size: 32 })), t.push(s), o += d(s)) : r.push(s);
64
+ }
65
+ return p(...r, ...t);
66
+ }
67
+ function N(e, n) {
68
+ const { checksum: r = !1 } = n;
69
+ return x(e, { strict: r }), {
70
+ dynamic: !1,
71
+ encoded: h(e.toLowerCase())
72
+ };
73
+ }
74
+ function P(e, n) {
75
+ const { checksumAddress: r, length: t, parameter: o } = n, i = t === null;
76
+ if (!Array.isArray(e))
77
+ throw new b(e);
78
+ if (!i && e.length !== t)
79
+ throw new w({
80
+ expectedLength: t,
81
+ givenLength: e.length,
82
+ type: `${o.type}[${t}]`
83
+ });
84
+ let c = !1;
85
+ const s = [];
86
+ for (let a = 0; a < e.length; a++) {
87
+ const m = u({
88
+ checksumAddress: r,
89
+ parameter: o,
90
+ value: e[a]
91
+ });
92
+ m.dynamic && (c = !0), s.push(m);
93
+ }
94
+ if (i || c) {
95
+ const a = l(s);
96
+ if (i) {
97
+ const m = f(s.length, { size: 32 });
98
+ return {
99
+ dynamic: !0,
100
+ encoded: s.length > 0 ? p(m, a) : m
101
+ };
102
+ }
103
+ if (c)
104
+ return { dynamic: !0, encoded: a };
105
+ }
106
+ return {
107
+ dynamic: !1,
108
+ encoded: p(...s.map(({ encoded: a }) => a))
109
+ };
110
+ }
111
+ function $(e, { type: n }) {
112
+ const [, r] = n.split("bytes"), t = d(e);
113
+ if (!r) {
114
+ let o = e;
115
+ return t % 32 !== 0 && (o = y(o, Math.ceil((e.length - 2) / 2 / 32) * 32)), {
116
+ dynamic: !0,
117
+ encoded: p(h(f(t, { size: 32 })), o)
118
+ };
119
+ }
120
+ if (t !== Number.parseInt(r))
121
+ throw new z({
122
+ expectedSize: Number.parseInt(r),
123
+ value: e
124
+ });
125
+ return { dynamic: !1, encoded: y(e) };
126
+ }
127
+ function C(e) {
128
+ if (typeof e != "boolean")
129
+ throw new S(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
130
+ return { dynamic: !1, encoded: h(A(e)) };
131
+ }
132
+ function M(e, { signed: n, size: r }) {
133
+ if (typeof r == "number") {
134
+ const t = 2n ** (BigInt(r) - (n ? 1n : 0n)) - 1n, o = n ? -t - 1n : 0n;
135
+ if (e > t || e < o)
136
+ throw new E({
137
+ max: t.toString(),
138
+ min: o.toString(),
139
+ signed: n,
140
+ size: r / 8,
141
+ value: e.toString()
142
+ });
143
+ }
144
+ return {
145
+ dynamic: !1,
146
+ encoded: f(e, {
147
+ size: 32,
148
+ signed: n
149
+ })
150
+ };
151
+ }
152
+ function W(e) {
153
+ const n = I(e), r = Math.ceil(d(n) / 32), t = [];
154
+ for (let o = 0; o < r; o++)
155
+ t.push(y(B(n, o * 32, (o + 1) * 32)));
156
+ return {
157
+ dynamic: !0,
158
+ encoded: p(y(f(d(n), { size: 32 })), ...t)
159
+ };
160
+ }
161
+ function R(e, n) {
162
+ const { checksumAddress: r, parameter: t } = n;
163
+ let o = !1;
164
+ const i = [];
165
+ for (let c = 0; c < t.components.length; c++) {
166
+ const s = t.components[c], a = Array.isArray(e) ? c : s.name, m = u({
167
+ checksumAddress: r,
168
+ parameter: s,
169
+ value: e[a]
170
+ });
171
+ i.push(m), m.dynamic && (o = !0);
172
+ }
173
+ return {
174
+ dynamic: o,
175
+ encoded: o ? l(i) : p(...i.map(({ encoded: c }) => c))
176
+ };
177
+ }
178
+ function k(e) {
179
+ const n = e.match(/^(.*)\[(\d+)?\]$/);
180
+ return n ? (
181
+ // Return `null` if the array is dynamic.
182
+ [n[2] ? Number(n[2]) : null, n[1]]
183
+ ) : void 0;
184
+ }
2
185
  export {
3
- e as arrayRegex,
4
- t as bytesRegex,
5
- n as integerRegex
186
+ l as encode,
187
+ N as encodeAddress,
188
+ P as encodeArray,
189
+ C as encodeBoolean,
190
+ $ as encodeBytes,
191
+ M as encodeNumber,
192
+ W as encodeString,
193
+ R as encodeTuple,
194
+ k as getArrayComponents,
195
+ u as prepareParameter,
196
+ q as prepareParameters
6
197
  };
package/dist/index311.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index294.cjs"),w=require("./index309.cjs"),N=require("./index304.cjs"),c=require("./index291.cjs"),x=require("./index310.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;
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;
package/dist/index311.js CHANGED
@@ -1,197 +1,7 @@
1
- import { InvalidTypeError as g, InvalidArrayError as b, ArrayLengthMismatchError as w, BytesSizeMismatchError as z } from "./index294.js";
2
- import { assert as x } from "./index309.js";
3
- import { BaseError as S } from "./index304.js";
4
- import { size as d, fromNumber as f, concat as p, padLeft as h, fromBoolean as A, IntegerOutOfRangeError as E, padRight as y, fromString as I, slice as B } from "./index291.js";
5
- import { integerRegex as L } from "./index310.js";
6
- function q({ checksumAddress: e, parameters: n, values: r }) {
7
- const t = [];
8
- for (let o = 0; o < n.length; o++)
9
- t.push(u({
10
- checksumAddress: e,
11
- parameter: n[o],
12
- value: r[o]
13
- }));
14
- return t;
15
- }
16
- function u({ checksumAddress: e = !1, parameter: n, value: r }) {
17
- const t = n, o = k(t.type);
18
- if (o) {
19
- const [i, c] = o;
20
- return P(r, {
21
- checksumAddress: e,
22
- length: i,
23
- parameter: {
24
- ...t,
25
- type: c
26
- }
27
- });
28
- }
29
- if (t.type === "tuple")
30
- return R(r, {
31
- checksumAddress: e,
32
- parameter: t
33
- });
34
- if (t.type === "address")
35
- return N(r, {
36
- checksum: e
37
- });
38
- if (t.type === "bool")
39
- return C(r);
40
- if (t.type.startsWith("uint") || t.type.startsWith("int")) {
41
- const i = t.type.startsWith("int"), [, , c = "256"] = L.exec(t.type) ?? [];
42
- return M(r, {
43
- signed: i,
44
- size: Number(c)
45
- });
46
- }
47
- if (t.type.startsWith("bytes"))
48
- return $(r, { type: t.type });
49
- if (t.type === "string")
50
- return W(r);
51
- throw new g(t.type);
52
- }
53
- function l(e) {
54
- let n = 0;
55
- for (let i = 0; i < e.length; i++) {
56
- const { dynamic: c, encoded: s } = e[i];
57
- c ? n += 32 : n += d(s);
58
- }
59
- const r = [], t = [];
60
- let o = 0;
61
- for (let i = 0; i < e.length; i++) {
62
- const { dynamic: c, encoded: s } = e[i];
63
- c ? (r.push(f(n + o, { size: 32 })), t.push(s), o += d(s)) : r.push(s);
64
- }
65
- return p(...r, ...t);
66
- }
67
- function N(e, n) {
68
- const { checksum: r = !1 } = n;
69
- return x(e, { strict: r }), {
70
- dynamic: !1,
71
- encoded: h(e.toLowerCase())
72
- };
73
- }
74
- function P(e, n) {
75
- const { checksumAddress: r, length: t, parameter: o } = n, i = t === null;
76
- if (!Array.isArray(e))
77
- throw new b(e);
78
- if (!i && e.length !== t)
79
- throw new w({
80
- expectedLength: t,
81
- givenLength: e.length,
82
- type: `${o.type}[${t}]`
83
- });
84
- let c = !1;
85
- const s = [];
86
- for (let a = 0; a < e.length; a++) {
87
- const m = u({
88
- checksumAddress: r,
89
- parameter: o,
90
- value: e[a]
91
- });
92
- m.dynamic && (c = !0), s.push(m);
93
- }
94
- if (i || c) {
95
- const a = l(s);
96
- if (i) {
97
- const m = f(s.length, { size: 32 });
98
- return {
99
- dynamic: !0,
100
- encoded: s.length > 0 ? p(m, a) : m
101
- };
102
- }
103
- if (c)
104
- return { dynamic: !0, encoded: a };
105
- }
106
- return {
107
- dynamic: !1,
108
- encoded: p(...s.map(({ encoded: a }) => a))
109
- };
110
- }
111
- function $(e, { type: n }) {
112
- const [, r] = n.split("bytes"), t = d(e);
113
- if (!r) {
114
- let o = e;
115
- return t % 32 !== 0 && (o = y(o, Math.ceil((e.length - 2) / 2 / 32) * 32)), {
116
- dynamic: !0,
117
- encoded: p(h(f(t, { size: 32 })), o)
118
- };
119
- }
120
- if (t !== Number.parseInt(r))
121
- throw new z({
122
- expectedSize: Number.parseInt(r),
123
- value: e
124
- });
125
- return { dynamic: !1, encoded: y(e) };
126
- }
127
- function C(e) {
128
- if (typeof e != "boolean")
129
- throw new S(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
130
- return { dynamic: !1, encoded: h(A(e)) };
131
- }
132
- function M(e, { signed: n, size: r }) {
133
- if (typeof r == "number") {
134
- const t = 2n ** (BigInt(r) - (n ? 1n : 0n)) - 1n, o = n ? -t - 1n : 0n;
135
- if (e > t || e < o)
136
- throw new E({
137
- max: t.toString(),
138
- min: o.toString(),
139
- signed: n,
140
- size: r / 8,
141
- value: e.toString()
142
- });
143
- }
144
- return {
145
- dynamic: !1,
146
- encoded: f(e, {
147
- size: 32,
148
- signed: n
149
- })
150
- };
151
- }
152
- function W(e) {
153
- const n = I(e), r = Math.ceil(d(n) / 32), t = [];
154
- for (let o = 0; o < r; o++)
155
- t.push(y(B(n, o * 32, (o + 1) * 32)));
156
- return {
157
- dynamic: !0,
158
- encoded: p(y(f(d(n), { size: 32 })), ...t)
159
- };
160
- }
161
- function R(e, n) {
162
- const { checksumAddress: r, parameter: t } = n;
163
- let o = !1;
164
- const i = [];
165
- for (let c = 0; c < t.components.length; c++) {
166
- const s = t.components[c], a = Array.isArray(e) ? c : s.name, m = u({
167
- checksumAddress: r,
168
- parameter: s,
169
- value: e[a]
170
- });
171
- i.push(m), m.dynamic && (o = !0);
172
- }
173
- return {
174
- dynamic: o,
175
- encoded: o ? l(i) : p(...i.map(({ encoded: c }) => c))
176
- };
177
- }
178
- function k(e) {
179
- const n = e.match(/^(.*)\[(\d+)?\]$/);
180
- return n ? (
181
- // Return `null` if the array is dynamic.
182
- [n[2] ? Number(n[2]) : null, n[1]]
183
- ) : void 0;
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);
184
4
  }
185
5
  export {
186
- l as encode,
187
- N as encodeAddress,
188
- P as encodeArray,
189
- C as encodeBoolean,
190
- $ as encodeBytes,
191
- M as encodeNumber,
192
- W as encodeString,
193
- R as encodeTuple,
194
- k as getArrayComponents,
195
- u as prepareParameter,
196
- q as prepareParameters
6
+ g as stringify
197
7
  };
package/dist/index312.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index304.cjs"),y=require("./index291.cjs"),s=require("./index313.cjs"),z=require("./index306.cjs"),S=new TextEncoder;function x(e){return e instanceof Uint8Array?e:typeof e=="string"?h(e):g(e)}function g(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function h(e,t={}){const{size:r}=t;let n=e;r&&(z.assertSize(e,r),n=y.padRight(e,r));let i=n.slice(2);i.length%2&&(i=`0${i}`);const d=i.length/2,f=new Uint8Array(d);for(let c=0,o=0;c<d;c++){const u=s.charCodeToBase16(i.charCodeAt(o++)),b=s.charCodeToBase16(i.charCodeAt(o++));if(u===void 0||b===void 0)throw new a.BaseError(`Invalid byte sequence ("${i[o-2]}${i[o-1]}" in "${i}").`);f[c]=u*16+b}return f}function m(e,t={}){const{size:r}=t,n=S.encode(e);return typeof r=="number"?(s.assertSize(n,r),l(n,r)):n}function l(e,t){return s.pad(e,{dir:"right",size:t})}function E(e){return e.length}class p extends a.BaseError{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class $ extends a.BaseError{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=$;exports.SizeOverflowError=p;exports.from=x;exports.fromArray=g;exports.fromHex=h;exports.fromString=m;exports.padRight=l;exports.size=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index289.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;
package/dist/index312.js CHANGED
@@ -1,66 +1,43 @@
1
- import { BaseError as c } from "./index304.js";
2
- import { padRight as h } from "./index291.js";
3
- import { charCodeToBase16 as b, assertSize as g, pad as m } from "./index313.js";
4
- import { assertSize as p } from "./index306.js";
5
- const l = /* @__PURE__ */ new TextEncoder();
6
- function E(e) {
7
- return e instanceof Uint8Array ? e : typeof e == "string" ? y(e) : z(e);
8
- }
9
- function z(e) {
10
- return e instanceof Uint8Array ? e : new Uint8Array(e);
11
- }
12
- function y(e, t = {}) {
13
- const { size: r } = t;
14
- let n = e;
15
- r && (p(e, r), n = h(e, r));
16
- let i = n.slice(2);
17
- i.length % 2 && (i = `0${i}`);
18
- const f = i.length / 2, a = new Uint8Array(f);
19
- for (let s = 0, o = 0; s < f; s++) {
20
- const d = b(i.charCodeAt(o++)), u = b(i.charCodeAt(o++));
21
- if (d === void 0 || u === void 0)
22
- throw new c(`Invalid byte sequence ("${i[o - 2]}${i[o - 1]}" in "${i}").`);
23
- a[s] = d * 16 + u;
24
- }
25
- return a;
26
- }
27
- function C(e, t = {}) {
28
- const { size: r } = t, n = l.encode(e);
29
- return typeof r == "number" ? (g(n, r), x(n, r)) : n;
30
- }
31
- function x(e, t) {
32
- return m(e, { dir: "right", size: t });
1
+ import { SizeExceedsPaddingSizeError as s, size as i, SliceOffsetOutOfBoundsError as f, SizeOverflowError as p } from "./index289.js";
2
+ function c(t, e) {
3
+ if (i(t) > e)
4
+ throw new p({
5
+ givenSize: i(t),
6
+ maxSize: e
7
+ });
33
8
  }
34
- function U(e) {
35
- return e.length;
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
+ });
36
16
  }
37
- class B extends c {
38
- constructor({ givenSize: t, maxSize: r }) {
39
- super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`), Object.defineProperty(this, "name", {
40
- enumerable: !0,
41
- configurable: !0,
42
- writable: !0,
43
- value: "Bytes.SizeOverflowError"
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)
44
23
  });
45
- }
46
24
  }
47
- class O extends c {
48
- constructor({ size: t, targetSize: r, type: n }) {
49
- super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`), Object.defineProperty(this, "name", {
50
- enumerable: !0,
51
- configurable: !0,
52
- writable: !0,
53
- value: "Bytes.SizeExceedsPaddingSizeError"
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"
54
35
  });
55
- }
36
+ return `0x${o[r === "right" ? "padEnd" : "padStart"](n * 2, "0")}`;
56
37
  }
57
38
  export {
58
- O as SizeExceedsPaddingSizeError,
59
- B as SizeOverflowError,
60
- E as from,
61
- z as fromArray,
62
- y as fromHex,
63
- C as fromString,
64
- x as padRight,
65
- U as size
39
+ d as assertEndOffset,
40
+ c as assertSize,
41
+ S as assertStartOffset,
42
+ u as pad
66
43
  };
package/dist/index313.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index312.cjs");function s(e,t){if(o.size(e)>t)throw new o.SizeOverflowError({givenSize:o.size(e),maxSize:t})}const n={zero:48,nine:57,A:65,F:70,a:97,f:102};function u(e){if(e>=n.zero&&e<=n.nine)return e-n.zero;if(e>=n.A&&e<=n.F)return e-(n.A-10);if(e>=n.a&&e<=n.f)return e-(n.a-10)}function z(e,t={}){const{dir:f,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new o.SizeExceedsPaddingSizeError({size:e.length,targetSize:r,type:"Bytes"});const d=new Uint8Array(r);for(let i=0;i<r;i++){const a=f==="right";d[a?i:r-i-1]=e[a?i:e.length-i-1]}return d}exports.assertSize=s;exports.charCodeMap=n;exports.charCodeToBase16=u;exports.pad=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index314.cjs");class t extends Error{constructor(a,e={}){var i;const s=e.cause instanceof t?e.cause.details:(i=e.cause)!=null&&i.message?e.cause.message:e.details,r=e.cause instanceof t&&e.cause.docsPath||e.docsPath,u=[a||"An error occurred.","",...e.metaMessages?[...e.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...s?[`Details: ${s}`]:[],`Version: abitype@${o.version}`].join(`
2
+ `);super(u),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,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),e.cause&&(this.cause=e.cause),this.details=s,this.docsPath=r,this.metaMessages=e.metaMessages,this.shortMessage=a}}exports.BaseError=t;
package/dist/index313.js CHANGED
@@ -1,47 +1,44 @@
1
- import { size as d, SizeOverflowError as u, SizeExceedsPaddingSizeError as a } from "./index312.js";
2
- function p(e, t) {
3
- if (d(e) > t)
4
- throw new u({
5
- givenSize: d(e),
6
- maxSize: t
7
- });
8
- }
9
- const n = {
10
- zero: 48,
11
- nine: 57,
12
- A: 65,
13
- F: 70,
14
- a: 97,
15
- f: 102
16
- };
17
- function s(e) {
18
- if (e >= n.zero && e <= n.nine)
19
- return e - n.zero;
20
- if (e >= n.A && e <= n.F)
21
- return e - (n.A - 10);
22
- if (e >= n.a && e <= n.f)
23
- return e - (n.a - 10);
24
- }
25
- function S(e, t = {}) {
26
- const { dir: z, size: i = 32 } = t;
27
- if (i === 0)
28
- return e;
29
- if (e.length > i)
30
- throw new a({
31
- size: e.length,
32
- targetSize: i,
33
- type: "Bytes"
34
- });
35
- const o = new Uint8Array(i);
36
- for (let r = 0; r < i; r++) {
37
- const f = z === "right";
38
- o[f ? r : i - r - 1] = e[f ? r : e.length - r - 1];
1
+ import { version as o } from "./index314.js";
2
+ class a extends Error {
3
+ constructor(i, e = {}) {
4
+ var r;
5
+ const t = e.cause instanceof a ? e.cause.details : (r = e.cause) != null && r.message ? e.cause.message : e.details, s = e.cause instanceof a && e.cause.docsPath || e.docsPath, u = [
6
+ i || "An error occurred.",
7
+ "",
8
+ ...e.metaMessages ? [...e.metaMessages, ""] : [],
9
+ ...s ? [`Docs: https://abitype.dev${s}`] : [],
10
+ ...t ? [`Details: ${t}`] : [],
11
+ `Version: abitype@${o}`
12
+ ].join(`
13
+ `);
14
+ super(u), Object.defineProperty(this, "details", {
15
+ enumerable: !0,
16
+ configurable: !0,
17
+ writable: !0,
18
+ value: void 0
19
+ }), Object.defineProperty(this, "docsPath", {
20
+ enumerable: !0,
21
+ configurable: !0,
22
+ writable: !0,
23
+ value: void 0
24
+ }), Object.defineProperty(this, "metaMessages", {
25
+ enumerable: !0,
26
+ configurable: !0,
27
+ writable: !0,
28
+ value: void 0
29
+ }), Object.defineProperty(this, "shortMessage", {
30
+ enumerable: !0,
31
+ configurable: !0,
32
+ writable: !0,
33
+ value: void 0
34
+ }), Object.defineProperty(this, "name", {
35
+ enumerable: !0,
36
+ configurable: !0,
37
+ writable: !0,
38
+ value: "AbiTypeError"
39
+ }), e.cause && (this.cause = e.cause), this.details = t, this.docsPath = s, this.metaMessages = e.metaMessages, this.shortMessage = i;
39
40
  }
40
- return o;
41
41
  }
42
42
  export {
43
- p as assertSize,
44
- n as charCodeMap,
45
- s as charCodeToBase16,
46
- S as pad
43
+ a as BaseError
47
44
  };
package/dist/index314.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index316.cjs");function r(){return e.version}exports.getVersion=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="1.0.9";exports.version=e;
package/dist/index314.js CHANGED
@@ -1,7 +1,4 @@
1
- import { version as r } from "./index316.js";
2
- function e() {
3
- return r;
4
- }
1
+ const o = "1.0.9";
5
2
  export {
6
- e as getVersion
3
+ o as version
7
4
  };
package/dist/index315.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index317.cjs"),e={checksum:new c.LruMap(8192)},s=e.checksum;exports.checksum=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index316.cjs");function m(r){let e="";const a=r.length;for(let t=0;t<a;t++){const o=r[t];e+=i.formatAbiParameter(o),t!==a-1&&(e+=", ")}return e}exports.formatAbiParameters=m;
package/dist/index315.js CHANGED
@@ -1,7 +1,13 @@
1
- import { LruMap as c } from "./index317.js";
2
- const e = {
3
- checksum: /* @__PURE__ */ new c(8192)
4
- }, m = e.checksum;
1
+ import { formatAbiParameter as m } from "./index316.js";
2
+ function f(e) {
3
+ let r = "";
4
+ const o = e.length;
5
+ for (let t = 0; t < o; t++) {
6
+ const a = e[t];
7
+ r += m(a), t !== o - 1 && (r += ", ");
8
+ }
9
+ return r;
10
+ }
5
11
  export {
6
- m as checksum
12
+ f as formatAbiParameters
7
13
  };
package/dist/index316.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.1.1";exports.version=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index317.cjs"),d=/^tuple(?<array>(\[(\d*)\])*)$/;function c(n){let e=n.type;if(d.test(n.type)&&"components"in n){e="(";const p=n.components.length;for(let t=0;t<p;t++){const s=n.components[t];e+=c(s),t<p-1&&(e+=", ")}const o=f.execTyped(d,n.type);return e+=`)${(o==null?void 0:o.array)??""}`,c({...n,type:e})}return"indexed"in n&&n.indexed&&(e=`${e} indexed`),n.name?`${e} ${n.name}`:e}exports.formatAbiParameter=c;