@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/index293.js CHANGED
@@ -1,116 +1,137 @@
1
- import { BaseError as y } from "./index304.js";
2
- import { keccak256 as v } from "./index307.js";
3
- import { validate as $, slice as A, fromString as S } from "./index291.js";
4
- import { isArgOfType as E, normalizeSignature as p, getAmbiguousTypes as B } from "./index308.js";
5
- import { parseAbiItem as l } from "./index271.js";
6
- import { formatAbiItem as h } from "./index264.js";
7
- function H(e, r = {}) {
8
- const { prepare: i = !0 } = r, n = Array.isArray(e) ? l(e) : typeof e == "string" ? l(e) : e;
9
- return {
10
- ...n,
11
- ...i ? { hash: s(n) } : {}
12
- };
1
+ import { assert as p } from "./index308.js";
2
+ import { BaseError as u } from "./index303.js";
3
+ import { size as y, padLeft as f, fromString as x, fromBoolean as w, fromNumber as E, padRight as P, concat as g } from "./index289.js";
4
+ import { integerRegex as A, bytesRegex as $, arrayRegex as L } from "./index309.js";
5
+ import { prepareParameters as z, encode as I } from "./index310.js";
6
+ function N(n, e, t) {
7
+ const { checksumAddress: r = !1 } = {};
8
+ if (n.length !== e.length)
9
+ throw new b({
10
+ expectedLength: n.length,
11
+ givenLength: e.length
12
+ });
13
+ const a = z({
14
+ checksumAddress: r,
15
+ parameters: n,
16
+ values: e
17
+ }), s = I(a);
18
+ return s.length === 0 ? "0x" : s;
19
+ }
20
+ function m(n, e) {
21
+ if (n.length !== e.length)
22
+ throw new b({
23
+ expectedLength: n.length,
24
+ givenLength: e.length
25
+ });
26
+ const t = [];
27
+ for (let r = 0; r < n.length; r++) {
28
+ const a = n[r], s = e[r];
29
+ t.push(m.encode(a, s));
30
+ }
31
+ return g(...t);
13
32
  }
14
- function M(e, r, i) {
15
- const { args: n = [], prepare: f = !0 } = i ?? {}, b = $(r, { strict: !1 }), u = e.filter((t) => b ? t.type === "function" || t.type === "error" ? T(t) === A(r, 0, 4) : t.type === "event" ? s(t) === r : !1 : "name" in t && t.name === r);
16
- if (u.length === 0)
17
- throw new d({ name: r });
18
- if (u.length === 1)
19
- return {
20
- ...u[0],
21
- ...f ? { hash: s(u[0]) } : {}
22
- };
23
- let o;
24
- for (const t of u) {
25
- if (!("inputs" in t))
26
- continue;
27
- if (!n || n.length === 0) {
28
- if (!t.inputs || t.inputs.length === 0)
29
- return {
30
- ...t,
31
- ...f ? { hash: s(t) } : {}
32
- };
33
- continue;
33
+ (function(n) {
34
+ function e(t, r, a = !1) {
35
+ if (t === "address") {
36
+ const i = r;
37
+ return p(i), f(i.toLowerCase(), a ? 32 : 0);
38
+ }
39
+ if (t === "string")
40
+ return x(r);
41
+ if (t === "bytes")
42
+ return r;
43
+ if (t === "bool")
44
+ return f(w(r), a ? 32 : 1);
45
+ const s = t.match(A);
46
+ if (s) {
47
+ const [i, o, c = "256"] = s, h = Number.parseInt(c) / 8;
48
+ return E(r, {
49
+ size: a ? 32 : h,
50
+ signed: o === "int"
51
+ });
52
+ }
53
+ const d = t.match($);
54
+ if (d) {
55
+ const [i, o] = d;
56
+ if (Number.parseInt(o) !== (r.length - 2) / 2)
57
+ throw new M({
58
+ expectedSize: Number.parseInt(o),
59
+ value: r
60
+ });
61
+ return P(r, a ? 32 : 0);
34
62
  }
35
- if (!t.inputs || t.inputs.length === 0 || t.inputs.length !== n.length)
36
- continue;
37
- if (n.every((a, w) => {
38
- const g = "inputs" in t && t.inputs[w];
39
- return g ? E(a, g) : !1;
40
- })) {
41
- if (o && "inputs" in o && o.inputs) {
42
- const a = B(t.inputs, o.inputs, n);
43
- if (a)
44
- throw new O({
45
- abiItem: t,
46
- type: a[0]
47
- }, {
48
- abiItem: o,
49
- type: a[1]
50
- });
51
- }
52
- o = t;
63
+ const l = t.match(L);
64
+ if (l && Array.isArray(r)) {
65
+ const [i, o] = l, c = [];
66
+ for (let h = 0; h < r.length; h++)
67
+ c.push(e(o, r[h], !0));
68
+ return c.length === 0 ? "0x" : g(...c);
53
69
  }
70
+ throw new j(t);
71
+ }
72
+ n.encode = e;
73
+ })(m || (m = {}));
74
+ class R extends u {
75
+ constructor({ expectedLength: e, givenLength: t, type: r }) {
76
+ super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${t}\`.`), Object.defineProperty(this, "name", {
77
+ enumerable: !0,
78
+ configurable: !0,
79
+ writable: !0,
80
+ value: "AbiParameters.ArrayLengthMismatchError"
81
+ });
54
82
  }
55
- const c = (() => {
56
- if (o)
57
- return o;
58
- const [t, ...m] = u;
59
- return { ...t, overloads: m };
60
- })();
61
- if (!c)
62
- throw new d({ name: r });
63
- return {
64
- ...c,
65
- ...f ? { hash: s(c) } : {}
66
- };
67
- }
68
- function T(e) {
69
- return A(s(e), 0, 4);
70
83
  }
71
- function F(e) {
72
- const r = typeof e == "string" ? e : h(e);
73
- return p(r);
84
+ class M extends u {
85
+ constructor({ expectedSize: e, value: t }) {
86
+ super(`Size of bytes "${t}" (bytes${y(t)}) does not match expected size (bytes${e}).`), Object.defineProperty(this, "name", {
87
+ enumerable: !0,
88
+ configurable: !0,
89
+ writable: !0,
90
+ value: "AbiParameters.BytesSizeMismatchError"
91
+ });
92
+ }
74
93
  }
75
- function s(e) {
76
- return typeof e != "string" && "hash" in e && e.hash ? e.hash : v(S(F(e)));
94
+ class b extends u {
95
+ constructor({ expectedLength: e, givenLength: t }) {
96
+ super([
97
+ "ABI encoding parameters/values length mismatch.",
98
+ `Expected length (parameters): ${e}`,
99
+ `Given length (values): ${t}`
100
+ ].join(`
101
+ `)), Object.defineProperty(this, "name", {
102
+ enumerable: !0,
103
+ configurable: !0,
104
+ writable: !0,
105
+ value: "AbiParameters.LengthMismatchError"
106
+ });
107
+ }
77
108
  }
78
- class O extends y {
79
- constructor(r, i) {
80
- super("Found ambiguous types in overloaded ABI Items.", {
81
- metaMessages: [
82
- // TODO: abitype to add support for signature-formatted ABI items.
83
- `\`${r.type}\` in \`${p(h(r.abiItem))}\`, and`,
84
- `\`${i.type}\` in \`${p(h(i.abiItem))}\``,
85
- "",
86
- "These types encode differently and cannot be distinguished at runtime.",
87
- "Remove one of the ambiguous items in the ABI."
88
- ]
89
- }), Object.defineProperty(this, "name", {
109
+ class _ extends u {
110
+ constructor(e) {
111
+ super(`Value \`${e}\` is not a valid array.`), Object.defineProperty(this, "name", {
90
112
  enumerable: !0,
91
113
  configurable: !0,
92
114
  writable: !0,
93
- value: "AbiItem.AmbiguityError"
115
+ value: "AbiParameters.InvalidArrayError"
94
116
  });
95
117
  }
96
118
  }
97
- class d extends y {
98
- constructor({ name: r, data: i, type: n = "item" }) {
99
- const f = r ? ` with name "${r}"` : i ? ` with data "${i}"` : "";
100
- super(`ABI ${n}${f} not found.`), Object.defineProperty(this, "name", {
119
+ class j extends u {
120
+ constructor(e) {
121
+ super(`Type \`${e}\` is not a valid ABI Type.`), Object.defineProperty(this, "name", {
101
122
  enumerable: !0,
102
123
  configurable: !0,
103
124
  writable: !0,
104
- value: "AbiItem.NotFoundError"
125
+ value: "AbiParameters.InvalidTypeError"
105
126
  });
106
127
  }
107
128
  }
108
129
  export {
109
- O as AmbiguityError,
110
- d as NotFoundError,
111
- H as from,
112
- M as fromAbi,
113
- T as getSelector,
114
- F as getSignature,
115
- s as getSignatureHash
130
+ R as ArrayLengthMismatchError,
131
+ M as BytesSizeMismatchError,
132
+ _ as InvalidArrayError,
133
+ j as InvalidTypeError,
134
+ b as LengthMismatchError,
135
+ N as encode,
136
+ m as encodePacked
116
137
  };
package/dist/index294.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./index309.cjs"),d=require("./index304.cjs"),a=require("./index291.cjs"),g=require("./index310.cjs"),p=require("./index311.cjs");function P(n,e,t){const{checksumAddress:r=!1}={};if(n.length!==e.length)throw new m({expectedLength:n.length,givenLength:e.length});const s=p.prepareParameters({checksumAddress:r,parameters:n,values:e}),o=p.encode(s);return o.length===0?"0x":o}function l(n,e){if(n.length!==e.length)throw new m({expectedLength:n.length,givenLength:e.length});const t=[];for(let r=0;r<n.length;r++){const s=n[r],o=e[r];t.push(l.encode(s,o))}return a.concat(...t)}(function(n){function e(t,r,s=!1){if(t==="address"){const c=r;return x.assert(c),a.padLeft(c.toLowerCase(),s?32:0)}if(t==="string")return a.fromString(r);if(t==="bytes")return r;if(t==="bool")return a.padLeft(a.fromBoolean(r),s?32:1);const o=t.match(g.integerRegex);if(o){const[c,i,u="256"]=o,h=Number.parseInt(u)/8;return a.fromNumber(r,{size:s?32:h,signed:i==="int"})}const b=t.match(g.bytesRegex);if(b){const[c,i]=b;if(Number.parseInt(i)!==(r.length-2)/2)throw new y({expectedSize:Number.parseInt(i),value:r});return a.padRight(r,s?32:0)}const f=t.match(g.arrayRegex);if(f&&Array.isArray(r)){const[c,i]=f,u=[];for(let h=0;h<r.length;h++)u.push(e(i,r[h],!0));return u.length===0?"0x":a.concat(...u)}throw new E(t)}n.encode=e})(l||(l={}));class A extends d.BaseError{constructor({expectedLength:e,givenLength:t,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class y extends d.BaseError{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${a.size(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class m extends d.BaseError{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join(`
2
- `)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class w extends d.BaseError{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class E extends d.BaseError{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}exports.ArrayLengthMismatchError=A;exports.BytesSizeMismatchError=y;exports.InvalidArrayError=w;exports.InvalidTypeError=E;exports.LengthMismatchError=m;exports.encode=P;exports.encodePacked=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index287.cjs");class r extends i.Hash{constructor(t,h){super(),this.finished=!1,this.destroyed=!1,i.ahash(t);const n=i.toBytes(h);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,e=new Uint8Array(a);e.set(n.length>a?t.create().update(n).digest():n);for(let s=0;s<e.length;s++)e[s]^=54;this.iHash.update(e),this.oHash=t.create();for(let s=0;s<e.length;s++)e[s]^=106;this.oHash.update(e),i.clean(e)}update(t){return i.aexists(this),this.iHash.update(t),this}digestInto(t){i.aexists(this),i.abytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:h,iHash:n,finished:a,destroyed:e,blockLen:s,outputLen:d}=this;return t=t,t.finished=a,t.destroyed=e,t.blockLen=s,t.outputLen=d,t.oHash=h._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const c=(o,t,h)=>new r(o,t).update(h).digest();c.create=(o,t)=>new r(o,t);exports.HMAC=r;exports.hmac=c;
package/dist/index294.js CHANGED
@@ -1,137 +1,45 @@
1
- import { assert as p } from "./index309.js";
2
- import { BaseError as u } from "./index304.js";
3
- import { size as y, padLeft as f, fromString as x, fromBoolean as w, fromNumber as E, padRight as P, concat as g } from "./index291.js";
4
- import { integerRegex as A, bytesRegex as $, arrayRegex as L } from "./index310.js";
5
- import { prepareParameters as z, encode as I } from "./index311.js";
6
- function N(n, e, t) {
7
- const { checksumAddress: r = !1 } = {};
8
- if (n.length !== e.length)
9
- throw new b({
10
- expectedLength: n.length,
11
- givenLength: e.length
12
- });
13
- const a = z({
14
- checksumAddress: r,
15
- parameters: n,
16
- values: e
17
- }), s = I(a);
18
- return s.length === 0 ? "0x" : s;
19
- }
20
- function m(n, e) {
21
- if (n.length !== e.length)
22
- throw new b({
23
- expectedLength: n.length,
24
- givenLength: e.length
25
- });
26
- const t = [];
27
- for (let r = 0; r < n.length; r++) {
28
- const a = n[r], s = e[r];
29
- t.push(m.encode(a, s));
1
+ import { Hash as d, ahash as u, toBytes as H, clean as l, aexists as a, abytes as p } from "./index287.js";
2
+ class r extends d {
3
+ constructor(t, i) {
4
+ super(), this.finished = !1, this.destroyed = !1, u(t);
5
+ const h = H(i);
6
+ if (this.iHash = t.create(), typeof this.iHash.update != "function")
7
+ throw new Error("Expected instance of class which extends utils.Hash");
8
+ this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
9
+ const o = this.blockLen, e = new Uint8Array(o);
10
+ e.set(h.length > o ? t.create().update(h).digest() : h);
11
+ for (let s = 0; s < e.length; s++)
12
+ e[s] ^= 54;
13
+ this.iHash.update(e), this.oHash = t.create();
14
+ for (let s = 0; s < e.length; s++)
15
+ e[s] ^= 106;
16
+ this.oHash.update(e), l(e);
30
17
  }
31
- return g(...t);
32
- }
33
- (function(n) {
34
- function e(t, r, a = !1) {
35
- if (t === "address") {
36
- const i = r;
37
- return p(i), f(i.toLowerCase(), a ? 32 : 0);
38
- }
39
- if (t === "string")
40
- return x(r);
41
- if (t === "bytes")
42
- return r;
43
- if (t === "bool")
44
- return f(w(r), a ? 32 : 1);
45
- const s = t.match(A);
46
- if (s) {
47
- const [i, o, c = "256"] = s, h = Number.parseInt(c) / 8;
48
- return E(r, {
49
- size: a ? 32 : h,
50
- signed: o === "int"
51
- });
52
- }
53
- const d = t.match($);
54
- if (d) {
55
- const [i, o] = d;
56
- if (Number.parseInt(o) !== (r.length - 2) / 2)
57
- throw new M({
58
- expectedSize: Number.parseInt(o),
59
- value: r
60
- });
61
- return P(r, a ? 32 : 0);
62
- }
63
- const l = t.match(L);
64
- if (l && Array.isArray(r)) {
65
- const [i, o] = l, c = [];
66
- for (let h = 0; h < r.length; h++)
67
- c.push(e(o, r[h], !0));
68
- return c.length === 0 ? "0x" : g(...c);
69
- }
70
- throw new j(t);
18
+ update(t) {
19
+ return a(this), this.iHash.update(t), this;
71
20
  }
72
- n.encode = e;
73
- })(m || (m = {}));
74
- class R extends u {
75
- constructor({ expectedLength: e, givenLength: t, type: r }) {
76
- super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${t}\`.`), Object.defineProperty(this, "name", {
77
- enumerable: !0,
78
- configurable: !0,
79
- writable: !0,
80
- value: "AbiParameters.ArrayLengthMismatchError"
81
- });
21
+ digestInto(t) {
22
+ a(this), p(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
82
23
  }
83
- }
84
- class M extends u {
85
- constructor({ expectedSize: e, value: t }) {
86
- super(`Size of bytes "${t}" (bytes${y(t)}) does not match expected size (bytes${e}).`), Object.defineProperty(this, "name", {
87
- enumerable: !0,
88
- configurable: !0,
89
- writable: !0,
90
- value: "AbiParameters.BytesSizeMismatchError"
91
- });
24
+ digest() {
25
+ const t = new Uint8Array(this.oHash.outputLen);
26
+ return this.digestInto(t), t;
92
27
  }
93
- }
94
- class b extends u {
95
- constructor({ expectedLength: e, givenLength: t }) {
96
- super([
97
- "ABI encoding parameters/values length mismatch.",
98
- `Expected length (parameters): ${e}`,
99
- `Given length (values): ${t}`
100
- ].join(`
101
- `)), Object.defineProperty(this, "name", {
102
- enumerable: !0,
103
- configurable: !0,
104
- writable: !0,
105
- value: "AbiParameters.LengthMismatchError"
106
- });
28
+ _cloneInto(t) {
29
+ t || (t = Object.create(Object.getPrototypeOf(this), {}));
30
+ const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: c } = this;
31
+ return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = c, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
107
32
  }
108
- }
109
- class _ extends u {
110
- constructor(e) {
111
- super(`Value \`${e}\` is not a valid array.`), Object.defineProperty(this, "name", {
112
- enumerable: !0,
113
- configurable: !0,
114
- writable: !0,
115
- value: "AbiParameters.InvalidArrayError"
116
- });
33
+ clone() {
34
+ return this._cloneInto();
117
35
  }
118
- }
119
- class j extends u {
120
- constructor(e) {
121
- super(`Type \`${e}\` is not a valid ABI Type.`), Object.defineProperty(this, "name", {
122
- enumerable: !0,
123
- configurable: !0,
124
- writable: !0,
125
- value: "AbiParameters.InvalidTypeError"
126
- });
36
+ destroy() {
37
+ this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
127
38
  }
128
39
  }
40
+ const y = (n, t, i) => new r(n, t).update(i).digest();
41
+ y.create = (n, t) => new r(n, t);
129
42
  export {
130
- R as ArrayLengthMismatchError,
131
- M as BytesSizeMismatchError,
132
- _ as InvalidArrayError,
133
- j as InvalidTypeError,
134
- b as LengthMismatchError,
135
- N as encode,
136
- m as encodePacked
43
+ r as HMAC,
44
+ y as hmac
137
45
  };
package/dist/index295.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index288.cjs");class r extends i.Hash{constructor(t,h){super(),this.finished=!1,this.destroyed=!1,i.ahash(t);const n=i.toBytes(h);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,e=new Uint8Array(a);e.set(n.length>a?t.create().update(n).digest():n);for(let s=0;s<e.length;s++)e[s]^=54;this.iHash.update(e),this.oHash=t.create();for(let s=0;s<e.length;s++)e[s]^=106;this.oHash.update(e),i.clean(e)}update(t){return i.aexists(this),this.iHash.update(t),this}digestInto(t){i.aexists(this),i.abytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:h,iHash:n,finished:a,destroyed:e,blockLen:s,outputLen:d}=this;return t=t,t.finished=a,t.destroyed=e,t.blockLen=s,t.outputLen=d,t.oHash=h._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const c=(o,t,h)=>new r(o,t).update(h).digest();c.create=(o,t)=>new r(o,t);exports.HMAC=r;exports.hmac=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index287.cjs");function p(o,t,s,i){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,s,i);const n=BigInt(32),r=BigInt(4294967295),e=Number(s>>n&r),h=Number(s&r),u=i?4:0,l=i?0:4;o.setUint32(t+u,e,i),o.setUint32(t+l,h,i)}function g(o,t,s){return o&t^~o&s}function b(o,t,s){return o&t^o&s^t&s}class d extends f.Hash{constructor(t,s,i,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=s,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(t),this.view=f.createView(this.buffer)}update(t){f.aexists(this),t=f.toBytes(t),f.abytes(t);const{view:s,buffer:i,blockLen:n}=this,r=t.length;for(let e=0;e<r;){const h=Math.min(n-this.pos,r-e);if(h===n){const u=f.createView(t);for(;n<=r-e;e+=n)this.process(u,e);continue}i.set(t.subarray(e,e+h),this.pos),this.pos+=h,e+=h,this.pos===n&&(this.process(s,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){f.aexists(this),f.aoutput(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:n,isLE:r}=this;let{pos:e}=this;s[e++]=128,f.clean(this.buffer.subarray(e)),this.padOffset>n-e&&(this.process(i,0),e=0);for(let c=e;c<n;c++)s[c]=0;p(i,n-8,BigInt(this.length*8),r),this.process(i,0);const h=f.createView(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,a=this.get();if(l>a.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<l;c++)h.setUint32(4*c,a[c],r)}digest(){const{buffer:t,outputLen:s}=this;this.digestInto(t);const i=t.slice(0,s);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:s,buffer:i,length:n,finished:r,destroyed:e,pos:h}=this;return t.destroyed=e,t.finished=r,t.length=n,t.pos=h,n%s&&t.buffer.set(i),t}clone(){return this._cloneInto()}}const w=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);exports.Chi=g;exports.HashMD=d;exports.Maj=b;exports.SHA256_IV=w;exports.setBigUint64=p;
package/dist/index295.js CHANGED
@@ -1,45 +1,81 @@
1
- import { Hash as d, ahash as u, toBytes as H, clean as l, aexists as a, abytes as p } from "./index288.js";
2
- class r extends d {
3
- constructor(t, i) {
4
- super(), this.finished = !1, this.destroyed = !1, u(t);
5
- const h = H(i);
6
- if (this.iHash = t.create(), typeof this.iHash.update != "function")
7
- throw new Error("Expected instance of class which extends utils.Hash");
8
- this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
9
- const o = this.blockLen, e = new Uint8Array(o);
10
- e.set(h.length > o ? t.create().update(h).digest() : h);
11
- for (let s = 0; s < e.length; s++)
12
- e[s] ^= 54;
13
- this.iHash.update(e), this.oHash = t.create();
14
- for (let s = 0; s < e.length; s++)
15
- e[s] ^= 106;
16
- this.oHash.update(e), l(e);
1
+ import { Hash as g, createView as l, aexists as b, toBytes as a, abytes as d, aoutput as x, clean as w } from "./index287.js";
2
+ function y(o, t, s, n) {
3
+ if (typeof o.setBigUint64 == "function")
4
+ return o.setBigUint64(t, s, n);
5
+ const i = BigInt(32), h = BigInt(4294967295), e = Number(s >> i & h), r = Number(s & h), c = n ? 4 : 0, u = n ? 0 : 4;
6
+ o.setUint32(t + c, e, n), o.setUint32(t + u, r, n);
7
+ }
8
+ function U(o, t, s) {
9
+ return o & t ^ ~o & s;
10
+ }
11
+ function _(o, t, s) {
12
+ return o & t ^ o & s ^ t & s;
13
+ }
14
+ class m extends g {
15
+ constructor(t, s, n, i) {
16
+ super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = s, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(t), this.view = l(this.buffer);
17
17
  }
18
18
  update(t) {
19
- return a(this), this.iHash.update(t), this;
19
+ b(this), t = a(t), d(t);
20
+ const { view: s, buffer: n, blockLen: i } = this, h = t.length;
21
+ for (let e = 0; e < h; ) {
22
+ const r = Math.min(i - this.pos, h - e);
23
+ if (r === i) {
24
+ const c = l(t);
25
+ for (; i <= h - e; e += i)
26
+ this.process(c, e);
27
+ continue;
28
+ }
29
+ n.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === i && (this.process(s, 0), this.pos = 0);
30
+ }
31
+ return this.length += t.length, this.roundClean(), this;
20
32
  }
21
33
  digestInto(t) {
22
- a(this), p(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
34
+ b(this), x(t, this), this.finished = !0;
35
+ const { buffer: s, view: n, blockLen: i, isLE: h } = this;
36
+ let { pos: e } = this;
37
+ s[e++] = 128, w(this.buffer.subarray(e)), this.padOffset > i - e && (this.process(n, 0), e = 0);
38
+ for (let f = e; f < i; f++)
39
+ s[f] = 0;
40
+ y(n, i - 8, BigInt(this.length * 8), h), this.process(n, 0);
41
+ const r = l(t), c = this.outputLen;
42
+ if (c % 4)
43
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
44
+ const u = c / 4, p = this.get();
45
+ if (u > p.length)
46
+ throw new Error("_sha2: outputLen bigger than state");
47
+ for (let f = 0; f < u; f++)
48
+ r.setUint32(4 * f, p[f], h);
23
49
  }
24
50
  digest() {
25
- const t = new Uint8Array(this.oHash.outputLen);
26
- return this.digestInto(t), t;
51
+ const { buffer: t, outputLen: s } = this;
52
+ this.digestInto(t);
53
+ const n = t.slice(0, s);
54
+ return this.destroy(), n;
27
55
  }
28
56
  _cloneInto(t) {
29
- t || (t = Object.create(Object.getPrototypeOf(this), {}));
30
- const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: c } = this;
31
- return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = c, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
57
+ t || (t = new this.constructor()), t.set(...this.get());
58
+ const { blockLen: s, buffer: n, length: i, finished: h, destroyed: e, pos: r } = this;
59
+ return t.destroyed = e, t.finished = h, t.length = i, t.pos = r, i % s && t.buffer.set(n), t;
32
60
  }
33
61
  clone() {
34
62
  return this._cloneInto();
35
63
  }
36
- destroy() {
37
- this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
38
- }
39
64
  }
40
- const y = (n, t, i) => new r(n, t).update(i).digest();
41
- y.create = (n, t) => new r(n, t);
65
+ const B = /* @__PURE__ */ Uint32Array.from([
66
+ 1779033703,
67
+ 3144134277,
68
+ 1013904242,
69
+ 2773480762,
70
+ 1359893119,
71
+ 2600822924,
72
+ 528734635,
73
+ 1541459225
74
+ ]);
42
75
  export {
43
- r as HMAC,
44
- y as hmac
76
+ U as Chi,
77
+ m as HashMD,
78
+ _ as Maj,
79
+ B as SHA256_IV,
80
+ y as setBigUint64
45
81
  };
package/dist/index296.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index288.cjs");function p(o,t,s,i){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,s,i);const n=BigInt(32),r=BigInt(4294967295),e=Number(s>>n&r),h=Number(s&r),u=i?4:0,l=i?0:4;o.setUint32(t+u,e,i),o.setUint32(t+l,h,i)}function g(o,t,s){return o&t^~o&s}function b(o,t,s){return o&t^o&s^t&s}class d extends f.Hash{constructor(t,s,i,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=s,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(t),this.view=f.createView(this.buffer)}update(t){f.aexists(this),t=f.toBytes(t),f.abytes(t);const{view:s,buffer:i,blockLen:n}=this,r=t.length;for(let e=0;e<r;){const h=Math.min(n-this.pos,r-e);if(h===n){const u=f.createView(t);for(;n<=r-e;e+=n)this.process(u,e);continue}i.set(t.subarray(e,e+h),this.pos),this.pos+=h,e+=h,this.pos===n&&(this.process(s,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){f.aexists(this),f.aoutput(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:n,isLE:r}=this;let{pos:e}=this;s[e++]=128,f.clean(this.buffer.subarray(e)),this.padOffset>n-e&&(this.process(i,0),e=0);for(let c=e;c<n;c++)s[c]=0;p(i,n-8,BigInt(this.length*8),r),this.process(i,0);const h=f.createView(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,a=this.get();if(l>a.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<l;c++)h.setUint32(4*c,a[c],r)}digest(){const{buffer:t,outputLen:s}=this;this.digestInto(t);const i=t.slice(0,s);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:s,buffer:i,length:n,finished:r,destroyed:e,pos:h}=this;return t.destroyed=e,t.finished=r,t.length=n,t.pos=h,n%s&&t.buffer.set(i),t}clone(){return this._cloneInto()}}const w=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);exports.Chi=g;exports.HashMD=d;exports.Maj=b;exports.SHA256_IV=w;exports.setBigUint64=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;exports.crypto=o;
package/dist/index296.js CHANGED
@@ -1,81 +1,4 @@
1
- import { Hash as g, createView as l, aexists as b, toBytes as a, abytes as d, aoutput as x, clean as w } from "./index288.js";
2
- function y(o, t, s, n) {
3
- if (typeof o.setBigUint64 == "function")
4
- return o.setBigUint64(t, s, n);
5
- const i = BigInt(32), h = BigInt(4294967295), e = Number(s >> i & h), r = Number(s & h), c = n ? 4 : 0, u = n ? 0 : 4;
6
- o.setUint32(t + c, e, n), o.setUint32(t + u, r, n);
7
- }
8
- function U(o, t, s) {
9
- return o & t ^ ~o & s;
10
- }
11
- function _(o, t, s) {
12
- return o & t ^ o & s ^ t & s;
13
- }
14
- class m extends g {
15
- constructor(t, s, n, i) {
16
- super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = s, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(t), this.view = l(this.buffer);
17
- }
18
- update(t) {
19
- b(this), t = a(t), d(t);
20
- const { view: s, buffer: n, blockLen: i } = this, h = t.length;
21
- for (let e = 0; e < h; ) {
22
- const r = Math.min(i - this.pos, h - e);
23
- if (r === i) {
24
- const c = l(t);
25
- for (; i <= h - e; e += i)
26
- this.process(c, e);
27
- continue;
28
- }
29
- n.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === i && (this.process(s, 0), this.pos = 0);
30
- }
31
- return this.length += t.length, this.roundClean(), this;
32
- }
33
- digestInto(t) {
34
- b(this), x(t, this), this.finished = !0;
35
- const { buffer: s, view: n, blockLen: i, isLE: h } = this;
36
- let { pos: e } = this;
37
- s[e++] = 128, w(this.buffer.subarray(e)), this.padOffset > i - e && (this.process(n, 0), e = 0);
38
- for (let f = e; f < i; f++)
39
- s[f] = 0;
40
- y(n, i - 8, BigInt(this.length * 8), h), this.process(n, 0);
41
- const r = l(t), c = this.outputLen;
42
- if (c % 4)
43
- throw new Error("_sha2: outputLen should be aligned to 32bit");
44
- const u = c / 4, p = this.get();
45
- if (u > p.length)
46
- throw new Error("_sha2: outputLen bigger than state");
47
- for (let f = 0; f < u; f++)
48
- r.setUint32(4 * f, p[f], h);
49
- }
50
- digest() {
51
- const { buffer: t, outputLen: s } = this;
52
- this.digestInto(t);
53
- const n = t.slice(0, s);
54
- return this.destroy(), n;
55
- }
56
- _cloneInto(t) {
57
- t || (t = new this.constructor()), t.set(...this.get());
58
- const { blockLen: s, buffer: n, length: i, finished: h, destroyed: e, pos: r } = this;
59
- return t.destroyed = e, t.finished = h, t.length = i, t.pos = r, i % s && t.buffer.set(n), t;
60
- }
61
- clone() {
62
- return this._cloneInto();
63
- }
64
- }
65
- const B = /* @__PURE__ */ Uint32Array.from([
66
- 1779033703,
67
- 3144134277,
68
- 1013904242,
69
- 2773480762,
70
- 1359893119,
71
- 2600822924,
72
- 528734635,
73
- 1541459225
74
- ]);
1
+ const o = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
75
2
  export {
76
- U as Chi,
77
- m as HashMD,
78
- _ as Maj,
79
- B as SHA256_IV,
80
- y as setBigUint64
3
+ o as crypto
81
4
  };